@workit-dev/opencode 2.27.7 → 2.27.8

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 +366 -156
  2. package/package.json +2 -2
package/dist/plugin.js CHANGED
@@ -27417,7 +27417,7 @@ function heavyGate(cwd, command, options) {
27417
27417
  // packages/workit-core/src/hooks/write-gate.ts
27418
27418
  import {
27419
27419
  existsSync as existsSync16,
27420
- readdirSync as readdirSync5,
27420
+ readdirSync as readdirSync6,
27421
27421
  readFileSync as readFileSync12,
27422
27422
  readlinkSync as readlinkSync3,
27423
27423
  realpathSync as realpathSync11,
@@ -27425,7 +27425,7 @@ import {
27425
27425
  } from "node:fs";
27426
27426
  import { builtinModules } from "node:module";
27427
27427
  import os10 from "node:os";
27428
- import path42 from "node:path";
27428
+ import path43 from "node:path";
27429
27429
 
27430
27430
  // packages/workit-core/src/core/live-session.ts
27431
27431
  import { spawnSync as spawnSync23 } from "node:child_process";
@@ -27628,6 +27628,41 @@ var claimLiveSession = (target, owner, deps = {}) => {
27628
27628
  } catch {}
27629
27629
  };
27630
27630
 
27631
+ // packages/workit-core/src/hooks/path-glob.ts
27632
+ import { readdirSync as readdirSync5 } from "node:fs";
27633
+ import path42 from "node:path";
27634
+ var GLOB2 = /[*?[]/u;
27635
+ var globPattern = (glob, dots = false) => {
27636
+ try {
27637
+ return new RegExp(`^${dots || glob.startsWith(".") ? "" : "(?!\\.)"}${glob.replace(/[.+^$(){}|\\]/gu, "\\$&").replace(/\[!/gu, "[^").replaceAll("*", ".*").replaceAll("?", ".")}$`, "u");
27638
+ } catch {
27639
+ return null;
27640
+ }
27641
+ };
27642
+ var expandGlob = (file, limit = 64) => {
27643
+ if (!GLOB2.test(file))
27644
+ return [file];
27645
+ const { root } = path42.parse(file);
27646
+ let found = [root];
27647
+ for (const part of file.slice(root.length).split(/[\\/]/u).filter(Boolean)) {
27648
+ if (!GLOB2.test(part)) {
27649
+ found = found.map((dir) => path42.join(dir, part));
27650
+ continue;
27651
+ }
27652
+ const pattern = globPattern(part);
27653
+ if (pattern === null)
27654
+ return [file];
27655
+ found = found.flatMap((dir) => {
27656
+ try {
27657
+ return readdirSync5(dir).filter((name) => pattern.test(name)).map((name) => path42.join(dir, name));
27658
+ } catch {
27659
+ return [];
27660
+ }
27661
+ }).slice(0, limit);
27662
+ }
27663
+ return found.length > 0 ? found : [file];
27664
+ };
27665
+
27631
27666
  // packages/workit-core/src/hooks/windows-reads.ts
27632
27667
  var READ_CMDLETS = new Set([
27633
27668
  "foreach-object",
@@ -27945,44 +27980,44 @@ var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "wi
27945
27980
  var linkTarget = (file) => {
27946
27981
  try {
27947
27982
  const to = readlinkSync3(file);
27948
- let from = path42.dirname(file);
27983
+ let from = path43.dirname(file);
27949
27984
  try {
27950
27985
  from = realpathSync11.native(from);
27951
27986
  } catch {}
27952
- return path42.resolve(from, to);
27987
+ return path43.resolve(from, to);
27953
27988
  } catch {
27954
27989
  return null;
27955
27990
  }
27956
27991
  };
27957
27992
  var realPath = (file, dangling = true) => {
27958
- let dir = path42.resolve(file);
27993
+ let dir = path43.resolve(file);
27959
27994
  let rest = "";
27960
27995
  for (let hops = 0;; ) {
27961
27996
  try {
27962
- return path42.join(realpathSync11.native(dir), rest);
27997
+ return path43.join(realpathSync11.native(dir), rest);
27963
27998
  } catch {
27964
27999
  const link = dangling ? linkTarget(dir) : null;
27965
28000
  if (link !== null) {
27966
28001
  if (++hops > 40)
27967
28002
  return null;
27968
- dir = path42.join(link, rest);
28003
+ dir = path43.join(link, rest);
27969
28004
  rest = "";
27970
- } else if (path42.dirname(dir) === dir)
27971
- return path42.resolve(file);
28005
+ } else if (path43.dirname(dir) === dir)
28006
+ return path43.resolve(file);
27972
28007
  else {
27973
- rest = rest ? path42.join(path42.basename(dir), rest) : path42.basename(dir);
27974
- dir = path42.dirname(dir);
28008
+ rest = rest ? path43.join(path43.basename(dir), rest) : path43.basename(dir);
28009
+ dir = path43.dirname(dir);
27975
28010
  }
27976
28011
  }
27977
28012
  }
27978
28013
  };
27979
- var canonical5 = (file, dangling = true) => realPath(file, dangling) ?? path42.resolve(file);
28014
+ var canonical5 = (file, dangling = true) => realPath(file, dangling) ?? path43.resolve(file);
27980
28015
  var exempt = (cwd, root, file, plans) => {
27981
28016
  const fold = (value) => CASE_INSENSITIVE ? value.toLowerCase() : value;
27982
- const relative = path42.relative(fold(canonical5(root, false)), fold(canonical5(path42.resolve(cwd, file), false)));
27983
- if (relative.startsWith("..") || path42.isAbsolute(relative))
28017
+ const relative = path43.relative(fold(canonical5(root, false)), fold(canonical5(path43.resolve(cwd, file), false)));
28018
+ if (relative.startsWith("..") || path43.isAbsolute(relative))
27984
28019
  return true;
27985
- const posix = relative.split(path42.sep).join("/");
28020
+ const posix = relative.split(path43.sep).join("/");
27986
28021
  const segments = posix.split("/");
27987
28022
  return /\.mdx?$/i.test(posix) || segments[0] === "docs" || segments.includes("plans") || [...plans].some((plan) => fold(plan) === posix);
27988
28023
  };
@@ -28062,7 +28097,7 @@ var editsOf = (input) => {
28062
28097
  return [into];
28063
28098
  const files = operands(args);
28064
28099
  if (name === "ln" && files.length === 1)
28065
- return [path42.basename(files[0])];
28100
+ return [path43.basename(files[0])];
28066
28101
  return files.length ? [files.at(-1)] : null;
28067
28102
  }
28068
28103
  case "mklink": {
@@ -28124,6 +28159,35 @@ var editsOf = (input) => {
28124
28159
  return [];
28125
28160
  }
28126
28161
  };
28162
+ var removalsOf = (input) => {
28163
+ const [verb = "", ...args] = pastLead(input);
28164
+ const name = (verb.split(/[\\/]/).at(-1) ?? "").toLowerCase();
28165
+ const files = operands(args);
28166
+ if (/^(?:rm|rmdir|rd|unlink|shred|remove-item|ri|del|erase)$/.test(name))
28167
+ return { files };
28168
+ if (/^(?:mv|move-item|mi|move)$/.test(name)) {
28169
+ const into = valueOf(args, /^(?:-[a-zA-Z]*t|--target-directory=?)(.*)$/s);
28170
+ return {
28171
+ files: into === undefined ? files.slice(0, -1) : files.filter((file) => file !== into)
28172
+ };
28173
+ }
28174
+ if (name === "rsync" && args.some((arg) => /^--del(?:ete|$)/.test(arg)))
28175
+ return { files: files.slice(-1) };
28176
+ const removes = args.some((arg, at) => arg === "-delete" || /^-(?:exec|execdir|ok|okdir)$/.test(arg) && /^(?:rm|rmdir|unlink|shred|mv|truncate|cp|dd|tee|sh|bash|dash|zsh)$/.test(commandName2(args[at + 1] ?? "")));
28177
+ if (name !== "find" || !removes)
28178
+ return { files: [] };
28179
+ const end = args.findIndex((arg) => /^[-(!]/.test(arg));
28180
+ const roots = end === 0 ? ["."] : args.slice(0, end);
28181
+ const tests = [];
28182
+ for (const [at, arg] of args.entries()) {
28183
+ const kind = /^-(i?)(?:name|path|wholename|regex)$/.exec(arg);
28184
+ const value = args[at + 1];
28185
+ if (kind && value !== undefined)
28186
+ tests.push([`${arg.replace(/^-i?/, "").replace("wholename", "path")}${kind[1]}`, value]);
28187
+ }
28188
+ const negated = args.some((arg) => arg === "!" || arg === "-not");
28189
+ return { files: roots, find: { roots, tests: negated ? [] : tests } };
28190
+ };
28127
28191
  var WRAPPERS3 = {
28128
28192
  sudo: "ugCDhpRrTtU",
28129
28193
  doas: "uC",
@@ -28147,7 +28211,7 @@ var WRAPPERS3 = {
28147
28211
  var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php|tsx|ts-node)$/;
28148
28212
  var INLINE_CODE = /^-[a-zA-Z]*[cep]$|^--(?:eval|print)(?:=|$)/;
28149
28213
  var isConfigDir = (file) => configDirs().some((dir) => canonical5(dir) === canonical5(file));
28150
- var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals|verdicts|agent-stamps)$/.test(path42.relative(canonical5(resolveStateDir()), canonical5(file)));
28214
+ var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals|verdicts|agent-stamps)$/.test(path43.relative(canonical5(resolveStateDir()), canonical5(file)));
28151
28215
  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)$/;
28152
28216
  var MUTATING_CALLS = /^(?:renames?(?:Sync)?|move(?:_into)?|copy(?:2|file|tree|File|_into)?(?: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*|f?truncate(?:Sync)?|ch(?:mod|own)(?:Sync)?|touch|open(?:Sync)?|dump|save|extractall|unpack_archive|put_contents|mv|FileUtils)$/;
28153
28217
  var SPAWNS = /getattr|Reflect|getOwnPropertyDescriptor|FileIO|\.copy\s*\((?!\s*\))|utime|ch(?:mod|own)|\.delete\s*\(\s*\)|(?:PYTHON|NODE_)\w*\+?=|-r\b|--(?:require|import|env-file|[\w-]*loader)|\b(?:exec\w*|eval|(?:unlink|rename|remove)\w*)\b|\]\s*\(/;
@@ -28672,10 +28736,10 @@ var linkSources = (args, at) => {
28672
28736
  const sources = names.filter((name, index) => into >= 0 ? name !== dest : index < names.length - 1 || names.length === 1);
28673
28737
  const target = dest === undefined ? null : at(dest);
28674
28738
  const symbolic = args.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg));
28675
- const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync16(target) || /[\\/]$/.test(dest ?? "") ? target : path42.dirname(target);
28739
+ const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync16(target) || /[\\/]$/.test(dest ?? "") ? target : path43.dirname(target);
28676
28740
  return sources.flatMap((source) => {
28677
- if (symbolic && base !== null && !path42.isAbsolute(homeExpanded(source)))
28678
- return [path42.resolve(base, source)];
28741
+ if (symbolic && base !== null && !path43.isAbsolute(homeExpanded(source)))
28742
+ return [path43.resolve(base, source)];
28679
28743
  const resolved = at(source);
28680
28744
  return resolved ? [resolved] : [];
28681
28745
  });
@@ -28720,7 +28784,7 @@ var linkReach = (verb, args, at, atAll) => {
28720
28784
  const dir = match ? match[1] ?? args[index + 1] : undefined;
28721
28785
  if (!dir)
28722
28786
  return [];
28723
- return [...atAll(dir), ...dest && !path42.isAbsolute(dir) ? atAll(path42.join(dest, dir)) : []];
28787
+ return [...atAll(dir), ...dest && !path43.isAbsolute(dir) ? atAll(path43.join(dest, dir)) : []];
28724
28788
  });
28725
28789
  }
28726
28790
  if (verb === "mklink")
@@ -28756,7 +28820,7 @@ var shellWrites = (command, depth = 0) => {
28756
28820
  return { writes: true, targets: unknown ? null : targets };
28757
28821
  };
28758
28822
  var cache3 = new Map;
28759
- var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path42.resolve(root, file)) ?? "-").join("\x00");
28823
+ var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path43.resolve(root, file)) ?? "-").join("\x00");
28760
28824
  var gateFor = (cwd) => {
28761
28825
  const store = new TaskReader(cwd);
28762
28826
  const listed = store.listTaskIndex();
@@ -28819,7 +28883,7 @@ var DIR_TARGET = ".workit-live-target";
28819
28883
  var PLACEHOLDERS = new WeakMap;
28820
28884
  var collecting = null;
28821
28885
  var placeholderIn = (dir, name) => {
28822
- const target = path42.join(dir, name);
28886
+ const target = path43.join(dir, name);
28823
28887
  collecting?.add(target);
28824
28888
  return target;
28825
28889
  };
@@ -28845,6 +28909,7 @@ var recording = (make) => {
28845
28909
  var OPAQUE_TARGET = ".workit-runs-";
28846
28910
  var UNRESOLVED_TARGET = ".workit-unresolved-target";
28847
28911
  var LINK_SOURCE = ".workit-link-source";
28912
+ var REMOVED_SOURCE = ".workit-removed-source";
28848
28913
  var OVERRIDE = "WORKIT_LIVE_SESSION=override";
28849
28914
  var inert = (args, sub) => args.some((arg) => arg === "--help" || arg === "-h" || arg === "--dry-run" || DRY_N.has(sub) && /^-[a-zA-Z]*n[a-zA-Z]*$/.test(arg) && !arg.startsWith("--"));
28850
28915
  var gitMutationDirs = (cwd, command, dialect) => {
@@ -28864,13 +28929,13 @@ var gitMutationDirs = (cwd, command, dialect) => {
28864
28929
  return [];
28865
28930
  if (sub === "stash" && ["list", "show"].includes(rest[0] ?? ""))
28866
28931
  return [];
28867
- return [path42.resolve(cwd, invocation.dir ?? ".")];
28932
+ return [path43.resolve(cwd, invocation.dir ?? ".")];
28868
28933
  });
28869
28934
  };
28870
28935
  var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
28871
28936
  var PUSHD2 = new Set(["pushd", "push-location"]);
28872
28937
  var POPD2 = new Set(["popd", "pop-location"]);
28873
- var UNKNOWN_DIR = path42.resolve(path42.parse(process.cwd()).root, ".workit-unknown-dir");
28938
+ var UNKNOWN_DIR = path43.resolve(path43.parse(process.cwd()).root, ".workit-unknown-dir");
28874
28939
  var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
28875
28940
  const lost = strict ? UNKNOWN_DIR : undefined;
28876
28941
  const found = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
@@ -28880,7 +28945,7 @@ var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
28880
28945
  return lost;
28881
28946
  if (dir === undefined)
28882
28947
  return lost;
28883
- return target === undefined ? os10.homedir() : path42.resolve(dir, target);
28948
+ return target === undefined ? os10.homedir() : path43.resolve(dir, target);
28884
28949
  };
28885
28950
  var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
28886
28951
  var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
@@ -29028,7 +29093,7 @@ var untrustedVars = (segments) => {
29028
29093
  }
29029
29094
  return { all, names };
29030
29095
  };
29031
- var UNKNOWN_VAR = path42.resolve(path42.parse(process.cwd()).root, ".workit-unknown-var");
29096
+ var UNKNOWN_VAR = path43.resolve(path43.parse(process.cwd()).root, ".workit-unknown-var");
29032
29097
  var REFERENCE = /\$\{(\w+)[^}]*\}|\$(\w+)|\$\([^)]*\)?|`[^`]*`?/g;
29033
29098
  var unresolvedRefs = (text) => [
29034
29099
  ...new Set([...text.matchAll(REFERENCE)].map((match) => {
@@ -29038,7 +29103,7 @@ var unresolvedRefs = (text) => [
29038
29103
  ];
29039
29104
  var unknownVarTarget = (text) => {
29040
29105
  const refs = unresolvedRefs(text);
29041
- return path42.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
29106
+ return path43.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
29042
29107
  };
29043
29108
  var applyOperator = (value, operator) => {
29044
29109
  if (operator === "")
@@ -29099,12 +29164,12 @@ var mktempPath = (value, dir) => {
29099
29164
  if (base === null && (temp || template === undefined))
29100
29165
  base = os10.tmpdir();
29101
29166
  const name = homeExpanded(template ?? "tmp.XXXXXXXXXX");
29102
- if (path42.isAbsolute(name))
29167
+ if (path43.isAbsolute(name))
29103
29168
  return name;
29104
29169
  const from = base === null ? dir : homeExpanded(base);
29105
- if (from === undefined || !path42.isAbsolute(from) && dir === undefined)
29170
+ if (from === undefined || !path43.isAbsolute(from) && dir === undefined)
29106
29171
  return null;
29107
- return path42.resolve(dir ?? from, from, name);
29172
+ return path43.resolve(dir ?? from, from, name);
29108
29173
  };
29109
29174
  var homeExpanded = (file) => {
29110
29175
  const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
@@ -29128,7 +29193,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
29128
29193
  const home = homeExpanded(text);
29129
29194
  if (strict && unresolvedRefs(home).length > 0)
29130
29195
  return [unknownVarTarget(home)];
29131
- if (path42.isAbsolute(home))
29196
+ if (path43.isAbsolute(home))
29132
29197
  return [home];
29133
29198
  return base === undefined ? [] : [resolvedUnder(base, home)];
29134
29199
  });
@@ -29199,7 +29264,8 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
29199
29264
  if (loop >= 0) {
29200
29265
  const [name = "", keyword, ...items] = segment.words.slice(loop + 1);
29201
29266
  const expanding = new Set(segment.expands ?? []);
29202
- const list = items.flatMap((item, index) => expanding.has(loop + 3 + index) ? listWords(item) : [listWord(homeExpanded(item))]);
29267
+ const globbedItem = (item) => strict === "registry" && dir !== undefined && /[*?[]/.test(item) ? expandGlob(path43.resolve(dir, homeExpanded(item))) : null;
29268
+ const list = items.flatMap((item, index) => globbedItem(item) ?? (expanding.has(loop + 3 + index) ? listWords(item) : [listWord(homeExpanded(item))]));
29203
29269
  vars.delete(name);
29204
29270
  if (keyword === "in" && list.length <= MAX_EXPANSIONS2 && !list.includes(null) && !untrusted.all && !untrusted.names.has(name))
29205
29271
  loops.set(name, list);
@@ -29338,7 +29404,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
29338
29404
  index
29339
29405
  }));
29340
29406
  const homes = /homedir\(|expanduser\(|Path\.home\(|['"]HOME['"]|env\.HOME|\$HOME|~/.test(text);
29341
- const under = (word) => homes ? [path42.join(homeExpanded("~"), word.replace(/^~/, ""))] : [];
29407
+ const under = (word) => homes ? [path43.join(homeExpanded("~"), word.replace(/^~/, ""))] : [];
29342
29408
  const found = [
29343
29409
  ...[...text.matchAll(PATHS)].flatMap(({ 0: word, index }) => [...atAll(word), ...under(word)].map((file) => ({ file, index }))),
29344
29410
  ...joined.flatMap(({ word, index }) => under(word).map((file) => ({ file, index })))
@@ -29346,7 +29412,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
29346
29412
  for (const { file, index } of found) {
29347
29413
  const use = isRoot(file) ? rootUse(text, index) : "takes";
29348
29414
  if (use !== "reads")
29349
- targets.push(use === "builds" ? path42.join(file, UNRESOLVED_TARGET) : file);
29415
+ targets.push(use === "builds" ? path43.join(file, UNRESOLVED_TARGET) : file);
29350
29416
  }
29351
29417
  }
29352
29418
  if (/^(?:n?vim?|ex|ed|emacs)$/.test(verb) && (segment.stdin || inputs.length > 0 || feeder || args.some((arg, index) => /^(?:-[a-zA-Z]*[se]|--(?:batch|eval|script))$/.test(arg) || /^(?:-c|--cmd)$/.test(arg) && !inertEdit(args[index + 1] ?? "") || arg.startsWith("+") && !inertEdit(arg.slice(1) || "1"))))
@@ -29356,7 +29422,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
29356
29422
  `);
29357
29423
  for (const [linker = "", ...rest] of fedRuns(words, feed))
29358
29424
  for (const source of linkReach(commandName2(linker), rest, at, atAll))
29359
- targets.push(path42.join(source, LINK_SOURCE));
29425
+ targets.push(path43.join(source, LINK_SOURCE));
29360
29426
  }
29361
29427
  if (strict && dir !== undefined) {
29362
29428
  const runIn = dir;
@@ -29383,7 +29449,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
29383
29449
  for (const file of opaque ?? [])
29384
29450
  for (const resolved of atAll(file))
29385
29451
  if (!quiet || !isRoot(resolved))
29386
- targets.push(file === "." ? placeholderIn(resolved, here) : path42.basename(resolved).startsWith(OPAQUE_TARGET) ? placeholderIn(path42.dirname(resolved), path42.basename(resolved)) : resolved);
29452
+ targets.push(file === "." ? placeholderIn(resolved, here) : path43.basename(resolved).startsWith(OPAQUE_TARGET) ? placeholderIn(path43.dirname(resolved), path43.basename(resolved)) : resolved);
29387
29453
  const [shell = "", ...shellArgs] = pastLead(words);
29388
29454
  const verb = (shell.split(/[\\/]/).at(-1) ?? "").toLowerCase();
29389
29455
  const named = (SCRIPT_SHELLS.has(verb) || verb === "source" || verb === ".") && shellScript2([verb, ...shellArgs]) === null ? scriptArgs(verb, shellArgs).named ?? "" : null;
@@ -29404,6 +29470,12 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
29404
29470
  if (dir !== undefined)
29405
29471
  targets.push(placeholderIn(dir, DIR_TARGET));
29406
29472
  }
29473
+ if (strict === "registry") {
29474
+ const { files: gone, find } = removalsOf(body);
29475
+ for (const root of gone)
29476
+ for (const file of atAll(root))
29477
+ targets.push(path43.join(file, find ? `${REMOVED_SOURCE}~${encodeURIComponent(JSON.stringify({ root, tests: find.tests }))}` : REMOVED_SOURCE));
29478
+ }
29407
29479
  for (const file of [...segment.redirects, ...edits ?? []])
29408
29480
  if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file) && !(dialect === "powershell" && /^(?:\$null|nul)$/i.test(file)))
29409
29481
  targets.push(...atAll(file));
@@ -29430,7 +29502,10 @@ var workitCwd = (dir, args, resolve) => {
29430
29502
  };
29431
29503
  var shellMutationTargets = (cwd, command, dialect = "posix", strict = false) => {
29432
29504
  try {
29433
- 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]] ?? ""]) : []);
29505
+ const env = new Map(strict === "registry" ? [
29506
+ ...[...command.matchAll(/\$\{?([A-Za-z_]\w*)/g)].filter((match) => !/^(?:OLD)?PWD$/.test(match[1])).map((match) => [match[1], process.env[match[1]] ?? ""]),
29507
+ ["PWD", cwd]
29508
+ ] : []);
29434
29509
  return recording(() => [
29435
29510
  ...segmentTargets(cwd, command, dialect, 0, strict, env),
29436
29511
  ...gitMutationDirs(cwd, command, dialect).map((dir) => placeholderIn(dir, DIR_TARGET))
@@ -29472,7 +29547,7 @@ var liveDeny = ({ marker, checkout, ageMs, file }) => {
29472
29547
  var guarded = (targets) => {
29473
29548
  const seen = new Set;
29474
29549
  return targets.filter((target) => {
29475
- const dir = path42.dirname(target);
29550
+ const dir = path43.dirname(target);
29476
29551
  if (seen.has(dir))
29477
29552
  return false;
29478
29553
  seen.add(dir);
@@ -29493,17 +29568,17 @@ var claimAll = (owner, targets, deps) => {
29493
29568
  for (const target of guarded(targets))
29494
29569
  claimLiveSession(target, owner, deps);
29495
29570
  };
29496
- var resolvedUnder = (dir, file) => !/(?:^|[\\/])\.\.(?:[\\/]|$)/.test(file) ? path42.resolve(dir, file) : path42.isAbsolute(file) ? file : `${dir}${path42.sep}${file}`;
29571
+ var resolvedUnder = (dir, file) => !/(?:^|[\\/])\.\.(?:[\\/]|$)/.test(file) ? path43.resolve(dir, file) : path43.isAbsolute(file) ? file : `${dir}${path43.sep}${file}`;
29497
29572
  var liveTargets = (cwd, paths) => recording(() => paths?.length ? paths.map((file) => resolvedUnder(cwd, file)) : [placeholderIn(cwd, DIR_TARGET)]);
29498
29573
  var CONFIG_FILES = ["workspaces.json", SEAL_FILE];
29499
29574
  var configDirs = () => [resolveConfigDir(), grantsDir()];
29500
29575
  var globbed = (cwd, target, state, configs) => {
29501
29576
  if (!/[*?[]/.test(target))
29502
29577
  return [];
29503
- const raw = path42.resolve(cwd, target).split(path42.sep);
29578
+ const raw = path43.resolve(cwd, target).split(path43.sep);
29504
29579
  const literal = raw.findIndex((part) => /[*?[]/.test(part));
29505
29580
  const pattern = [
29506
- ...canonical5(raw.slice(0, literal).join(path42.sep) || path42.sep).replace(/[\\/]+$/, "").split(path42.sep),
29581
+ ...canonical5(raw.slice(0, literal).join(path43.sep) || path43.sep).replace(/[\\/]+$/, "").split(path43.sep),
29507
29582
  ...raw.slice(literal)
29508
29583
  ];
29509
29584
  const segment = (glob, name) => {
@@ -29514,16 +29589,16 @@ var globbed = (cwd, target, state, configs) => {
29514
29589
  }
29515
29590
  };
29516
29591
  const hit = (file, below) => {
29517
- const parts = canonical5(file).split(path42.sep);
29592
+ const parts = canonical5(file).split(path43.sep);
29518
29593
  return (below ? pattern.length >= parts.length : pattern.length === parts.length) && parts.every((part, index) => segment(pattern[index], part));
29519
29594
  };
29520
29595
  let roots = [];
29521
29596
  try {
29522
- roots = readdirSync5(state).filter((name) => /^(?:issued|approvals$|verdicts$|agent-stamps$)/.test(name));
29597
+ roots = readdirSync6(state).filter((name) => /^(?:issued|approvals$|verdicts$|agent-stamps$)/.test(name));
29523
29598
  } catch {}
29524
29599
  return [
29525
- ...roots.map((name) => path42.join(state, name)).filter((root) => hit(root, true)),
29526
- ...configs.flatMap((dir) => [dir, ...CONFIG_FILES.map((name) => path42.join(dir, name))]).filter((file) => hit(file, false))
29600
+ ...roots.map((name) => path43.join(state, name)).filter((root) => hit(root, true)),
29601
+ ...configs.flatMap((dir) => [dir, ...CONFIG_FILES.map((name) => path43.join(dir, name))]).filter((file) => hit(file, false))
29527
29602
  ];
29528
29603
  };
29529
29604
  var guardedInodes = (state, configs) => {
@@ -29536,18 +29611,18 @@ var guardedInodes = (state, configs) => {
29536
29611
  if (stat?.isFile())
29537
29612
  seen.set(`${stat.dev}:${stat.ino}`, registry);
29538
29613
  else if (stat?.isDirectory())
29539
- for (const name of readdirSync5(file))
29540
- add(path42.join(file, name), registry);
29614
+ for (const name of readdirSync6(file))
29615
+ add(path43.join(file, name), registry);
29541
29616
  };
29542
29617
  try {
29543
29618
  for (const dir of configs)
29544
29619
  for (const name of CONFIG_FILES)
29545
- add(path42.join(dir, name), "grants");
29546
- for (const name of readdirSync5(state))
29620
+ add(path43.join(dir, name), "grants");
29621
+ for (const name of readdirSync6(state))
29547
29622
  if (/^(?:issued|approvals$|verdicts$|agent-stamps$)/.test(name))
29548
- add(path42.join(state, name), name === "approvals" ? "approvals" : name === "verdicts" || name === "agent-stamps" ? "ledger" : "issued");
29549
- for (const slug of readdirSync5(path42.join(state, "folders")))
29550
- add(path42.join(state, "folders", slug, "ledger"), "ledger");
29623
+ add(path43.join(state, name), name === "approvals" ? "approvals" : name === "verdicts" || name === "agent-stamps" ? "ledger" : "issued");
29624
+ for (const slug of readdirSync6(path43.join(state, "folders")))
29625
+ add(path43.join(state, "folders", slug, "ledger"), "ledger");
29551
29626
  } catch {}
29552
29627
  return seen;
29553
29628
  };
@@ -29564,19 +29639,87 @@ var hardLinked = (file, state, configs, inodes) => {
29564
29639
  };
29565
29640
  var inRepoLedger = (file) => [...file.matchAll(/[\\/]workit[\\/]ledger(?=[\\/]|$)/g)].some(({ index }) => {
29566
29641
  const gitDir = file.slice(0, index);
29567
- return /(?:^|[\\/])\.git$/.test(gitDir) || existsSync16(path42.join(gitDir, "HEAD")) && existsSync16(path42.join(gitDir, "objects"));
29642
+ return /(?:^|[\\/])\.git$/.test(gitDir) || existsSync16(path43.join(gitDir, "HEAD")) && existsSync16(path43.join(gitDir, "objects"));
29568
29643
  });
29569
29644
  var holdsGuarded = (cwd, source, state, configs) => {
29570
29645
  const real = canonical5(source);
29571
29646
  const below = (parent, child) => {
29572
- const rel = path42.relative(parent, child);
29573
- return rel === "" || !rel.startsWith("..") && !path42.isAbsolute(rel);
29647
+ const rel = path43.relative(parent, child);
29648
+ return rel === "" || !rel.startsWith("..") && !path43.isAbsolute(rel);
29574
29649
  };
29575
29650
  const holds = (file) => below(real, canonical5(file));
29576
- const inState = path42.relative(canonical5(state), real).split(path42.sep);
29577
- const ledgers = ["ledger", "workit/ledger", ".git/workit/ledger"].map((rel) => path42.join(real, rel)).filter((dir) => existsSync16(dir) && inRepoLedger(dir));
29651
+ const inState = path43.relative(canonical5(state), real).split(path43.sep);
29652
+ const ledgers = ["ledger", "workit/ledger", ".git/workit/ledger"].map((rel) => path43.join(real, rel)).filter((dir) => existsSync16(dir) && inRepoLedger(dir));
29653
+ const own = ledgerPath(cwd);
29654
+ return holds(state) || below(canonical5(state), real) && inState[0] === "folders" && inState.length <= 2 || configs.some(holds) || ledgers.length > 0 || own.ok && existsSync16(own.value) && holds(path43.dirname(own.value));
29655
+ };
29656
+ var removesLedger = (cwd, source, state, configs) => {
29657
+ const real = canonical5(source);
29658
+ if (/(?:^|[\\/])\.git(?:[\\/]workit)?$/i.test(real) || inRepoLedger(real))
29659
+ return true;
29660
+ const own = ledgerPath(cwd);
29661
+ if (own.ok) {
29662
+ const rel = path43.relative(real, canonical5(path43.dirname(own.value)));
29663
+ if (rel === "" || !rel.startsWith("..") && !path43.isAbsolute(rel))
29664
+ return true;
29665
+ }
29666
+ return holdsGuarded(cwd, source, state, configs);
29667
+ };
29668
+ var findTests = (marker) => {
29669
+ try {
29670
+ return JSON.parse(decodeURIComponent(marker.slice(REMOVED_SOURCE.length + 1)));
29671
+ } catch {
29672
+ return null;
29673
+ }
29674
+ };
29675
+ var findReachesLedger = (cwd, root, find) => {
29676
+ if (find === null)
29677
+ return true;
29678
+ const real = canonical5(root);
29578
29679
  const own = ledgerPath(cwd);
29579
- return holds(state) || below(canonical5(state), real) && inState[0] === "folders" && inState.length <= 2 || configs.some(holds) || ledgers.length > 0 || own.ok && existsSync16(own.value) && holds(path42.dirname(own.value));
29680
+ const ledgers = [
29681
+ ...own.ok ? [canonical5(path43.dirname(own.value))] : [],
29682
+ ...[".git/workit/ledger", "workit/ledger", "ledger"].map((rel) => path43.join(real, rel)).filter((dir) => existsSync16(dir) && inRepoLedger(dir))
29683
+ ];
29684
+ const under = (parent, child) => {
29685
+ const rel = path43.relative(parent, child);
29686
+ return rel === "" || !rel.startsWith("..") && !path43.isAbsolute(rel);
29687
+ };
29688
+ const patterns = find.tests.map(([kind, pattern]) => {
29689
+ const fold = kind.endsWith("i");
29690
+ const glob = globPattern(pattern, true);
29691
+ let test = /(?:)/;
29692
+ try {
29693
+ test = kind.startsWith("regex") ? new RegExp(`^${pattern}$`, fold ? "i" : "") : glob ? new RegExp(glob.source, fold ? "iu" : "u") : test;
29694
+ } catch {}
29695
+ return { kind, test };
29696
+ });
29697
+ const matches = (entry) => patterns.length === 0 || patterns.some(({ kind, test }) => test.test(kind.startsWith("name") ? path43.basename(entry) : path43.join(find.root, path43.relative(real, entry)).replaceAll("\\", "/")));
29698
+ for (const ledger of ledgers) {
29699
+ if (!existsSync16(ledger) || !under(real, ledger) && !under(ledger, real))
29700
+ continue;
29701
+ const entries = [];
29702
+ for (let dir = ledger;under(real, dir) && dir !== real; dir = path43.dirname(dir))
29703
+ entries.push(dir);
29704
+ const walk = (dir) => {
29705
+ for (const item of readdirSync6(dir, { withFileTypes: true })) {
29706
+ if (entries.length > 500)
29707
+ return;
29708
+ const file = path43.join(dir, item.name);
29709
+ entries.push(file);
29710
+ if (item.isDirectory())
29711
+ walk(file);
29712
+ }
29713
+ };
29714
+ try {
29715
+ walk(ledger);
29716
+ } catch {
29717
+ return true;
29718
+ }
29719
+ if (entries.some((entry) => under(real, entry) && matches(entry)))
29720
+ return true;
29721
+ }
29722
+ return false;
29580
29723
  };
29581
29724
  var registryTarget = (cwd, targets) => {
29582
29725
  const state = resolveStateDir();
@@ -29584,20 +29727,28 @@ var registryTarget = (cwd, targets) => {
29584
29727
  const inodes = {};
29585
29728
  for (const target of targets) {
29586
29729
  const file = homeExpanded(target);
29587
- if (path42.basename(file) === LINK_SOURCE) {
29588
- const source = path42.dirname(path42.resolve(cwd, file));
29730
+ if (path43.basename(file).startsWith(REMOVED_SOURCE)) {
29731
+ const marker = path43.basename(file);
29732
+ const source = path43.dirname(path43.resolve(cwd, file));
29733
+ const find = marker === REMOVED_SOURCE ? null : findTests(marker);
29734
+ if (expandGlob(source).some((gone) => find ? findReachesLedger(cwd, gone, find) : removesLedger(cwd, gone, state, configs)))
29735
+ return { file: path43.join(source, REMOVED_SOURCE), registry: "removes" };
29736
+ continue;
29737
+ }
29738
+ if (path43.basename(file) === LINK_SOURCE) {
29739
+ const source = path43.dirname(path43.resolve(cwd, file));
29589
29740
  const reached = registryTarget(cwd, [source])?.registry ?? (holdsGuarded(cwd, source, state, configs) ? "holds" : null);
29590
29741
  if (reached)
29591
29742
  return { file: target, registry: reached };
29592
29743
  continue;
29593
29744
  }
29594
- if (realPath(path42.resolve(cwd, file)) === null)
29745
+ if (realPath(path43.resolve(cwd, file)) === null)
29595
29746
  return { file: target, registry: "link" };
29596
29747
  const glob = globbed(cwd, file, state, configs)[0];
29597
29748
  const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
29598
29749
  if (viaGlob)
29599
29750
  return { file: target, registry: viaGlob.registry };
29600
- const registry = hardLinked(path42.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical5) ?? (inRepoLedger(canonical5(path42.resolve(cwd, file))) ? "ledger" : null) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical5)) ? "grants" : null);
29751
+ const registry = hardLinked(path43.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical5) ?? (inRepoLedger(canonical5(path43.resolve(cwd, file))) ? "ledger" : null) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical5)) ? "grants" : null);
29601
29752
  if (registry)
29602
29753
  return { file: target, registry };
29603
29754
  }
@@ -29605,7 +29756,7 @@ var registryTarget = (cwd, targets) => {
29605
29756
  };
29606
29757
  var partsUnder = (dir, cwd, target, platform, real) => {
29607
29758
  const win = platform === "win32";
29608
- const p = win ? path42.win32 : path42.posix;
29759
+ const p = win ? path43.win32 : path43.posix;
29609
29760
  const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
29610
29761
  const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
29611
29762
  const relative = p.relative(fold(real(p.resolve(dir))), fold(real(p.resolve(cwd, named))));
@@ -29658,6 +29809,11 @@ var REGISTRY_DENY = {
29658
29809
  what: "a symlink chain Workit could not resolve (over 40 links), which may reach a guarded path",
29659
29810
  unblock: "Write to the file's real path."
29660
29811
  },
29812
+ removes: {
29813
+ label: "ledger guard",
29814
+ what: "a Workit ledger, the git dir that holds one or Workit's state",
29815
+ unblock: "Never remove or move `.git`, `.git/workit` or a dir that holds a Workit ledger: the ledger keeps the session's verdicts and pins. Remove the files you made by name."
29816
+ },
29661
29817
  holds: {
29662
29818
  label: "registry guard",
29663
29819
  what: "Workit's state, its config or a repository ledger",
@@ -29686,19 +29842,25 @@ var REGISTRY_DENY = {
29686
29842
  };
29687
29843
  var registryDeny = ({ file, registry }) => {
29688
29844
  const { label, what, unblock } = REGISTRY_DENY[registry];
29689
- if (path42.basename(file) === LINK_SOURCE)
29845
+ if (path43.basename(file) === LINK_SOURCE)
29690
29846
  return {
29691
29847
  kind: "deny",
29692
- reason: `workit ${label}: this command links or mounts ${path42.dirname(file)}, which is or holds ${what}. ${LINK_UNBLOCK}`,
29848
+ reason: `workit ${label}: this command links or mounts ${path43.dirname(file)}, which is or holds ${what}. ${LINK_UNBLOCK}`,
29693
29849
  unblock: LINK_UNBLOCK
29694
29850
  };
29695
- if (path42.basename(file) === UNRESOLVED_TARGET)
29851
+ if (path43.basename(file) === REMOVED_SOURCE)
29852
+ return {
29853
+ kind: "deny",
29854
+ reason: `workit ${label}: this command removes or moves ${path43.dirname(file)}, which is or holds ${what}. ${unblock}`,
29855
+ unblock
29856
+ };
29857
+ if (path43.basename(file) === UNRESOLVED_TARGET)
29696
29858
  return {
29697
29859
  kind: "deny",
29698
29860
  reason: `workit ${label}: Workit could not resolve the file this command's script writes, which it builds from a path under ${what}. ${unblock}`,
29699
29861
  unblock
29700
29862
  };
29701
- const named = path42.basename(file).startsWith(".workit-") ? path42.dirname(file) : file;
29863
+ const named = path43.basename(file).startsWith(".workit-") ? path43.dirname(file) : file;
29702
29864
  return {
29703
29865
  kind: "deny",
29704
29866
  reason: `workit ${label}: ${named} is under ${what}. ${unblock}`,
@@ -29789,10 +29951,10 @@ import { spawnSync as spawnSync24 } from "node:child_process";
29789
29951
 
29790
29952
  // packages/workit-core/src/ci-waiter.ts
29791
29953
  import fs29 from "node:fs";
29792
- import path43 from "node:path";
29954
+ import path44 from "node:path";
29793
29955
  var waiterFile = (cwd, pr) => {
29794
29956
  const common = gitCommonDir(cwd);
29795
- return common ? path43.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
29957
+ return common ? path44.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
29796
29958
  };
29797
29959
  var pidAlive2 = (pid) => {
29798
29960
  if (!Number.isSafeInteger(pid) || pid <= 0)
@@ -29864,11 +30026,11 @@ function currentJudgment(cwd) {
29864
30026
  }
29865
30027
 
29866
30028
  // packages/workit-core/src/core/verdict-set.ts
29867
- import path44 from "node:path";
30029
+ import path45 from "node:path";
29868
30030
  var SET_TTL_MS = 7 * 86400000;
29869
30031
  var SET_ROW = "verdict.set";
29870
30032
  var SET_VOID = "verdict.set.voided";
29871
- var setStorePath = () => path44.join(resolveStateDir(), "verdicts", "sets", "ledger.jsonl");
30033
+ var setStorePath = () => path45.join(resolveStateDir(), "verdicts", "sets", "ledger.jsonl");
29872
30034
  var distrusted = (cwd, id, rows, type) => rows.some((row) => row.type === type && row.id === id && trustReasons(cwd, row).length > 0);
29873
30035
  function gateStands(cwd, gate, rows, now = Date.now()) {
29874
30036
  const id = typeof gate.verdictId === "string" ? gate.verdictId : null;
@@ -30327,7 +30489,7 @@ var WRITE_TOOLS = new Set([
30327
30489
  ]);
30328
30490
  // packages/workit-core/src/hooks/standing.ts
30329
30491
  import fs30 from "node:fs";
30330
- import path45 from "node:path";
30492
+ import path46 from "node:path";
30331
30493
 
30332
30494
  // packages/workit-core/src/approvals/store.ts
30333
30495
  var REQUEST_TTL_MS = 30 * 60000;
@@ -30842,7 +31004,7 @@ var workitRole = (descriptor, agentType) => {
30842
31004
 
30843
31005
  // packages/workit-core/src/hooks/standing.ts
30844
31006
  var readPlans = (store) => {
30845
- const dir = path45.join(store, "fanouts");
31007
+ const dir = path46.join(store, "fanouts");
30846
31008
  let names;
30847
31009
  try {
30848
31010
  names = fs30.readdirSync(dir).filter((name) => name.endsWith(".json"));
@@ -30852,7 +31014,7 @@ var readPlans = (store) => {
30852
31014
  const plans = [];
30853
31015
  for (const name of names) {
30854
31016
  try {
30855
- const raw = JSON.parse(fs30.readFileSync(path45.join(dir, name), "utf8"));
31017
+ const raw = JSON.parse(fs30.readFileSync(path46.join(dir, name), "utf8"));
30856
31018
  if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
30857
31019
  continue;
30858
31020
  const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
@@ -31171,8 +31333,8 @@ var UNLISTED = new Set(["description", "prompt"]);
31171
31333
 
31172
31334
  // packages/workit-core/src/hooks/server-gate.ts
31173
31335
  import fs31 from "node:fs";
31174
- import path46 from "node:path";
31175
- var procNoticeFile = (env, session) => path46.join(stateDir(env), "procs", "notices", `${session.replace(/[^A-Za-z0-9_.@+-]/gu, "-").slice(0, 120) || "none"}.json`);
31336
+ import path47 from "node:path";
31337
+ var procNoticeFile = (env, session) => path47.join(stateDir(env), "procs", "notices", `${session.replace(/[^A-Za-z0-9_.@+-]/gu, "-").slice(0, 120) || "none"}.json`);
31176
31338
  var mb = (bytes) => `${Math.round(Number(bytes) / 1048576)} MB`;
31177
31339
  function takeProcNotice(session, env = process.env) {
31178
31340
  if (!session)
@@ -31210,21 +31372,21 @@ function takeProcNotice(session, env = process.env) {
31210
31372
  // packages/workit-core/src/hooks/teardown.ts
31211
31373
  import { spawn } from "node:child_process";
31212
31374
  import fs32 from "node:fs";
31213
- import path48 from "node:path";
31375
+ import path49 from "node:path";
31214
31376
 
31215
31377
  // packages/workit-core/src/core/cli-locate.ts
31216
31378
  import { closeSync as closeSync3, existsSync as existsSync17, openSync as openSync3, readSync } from "node:fs";
31217
- import path47 from "node:path";
31379
+ import path48 from "node:path";
31218
31380
  var LAUNCHER_MARKER = "workit-owned-launcher";
31219
31381
  var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
31220
31382
  var installRoot = (env, platform = process.platform) => {
31221
31383
  if (env.WORKIT_INSTALL_ROOT)
31222
31384
  return env.WORKIT_INSTALL_ROOT;
31223
31385
  const data = dataDir(env, platform);
31224
- return platform === "win32" ? path47.join(data, "install") : data;
31386
+ return platform === "win32" ? path48.join(data, "install") : data;
31225
31387
  };
31226
- var ownedLauncherPath = (env, platform = process.platform) => path47.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
31227
- var ownedCurrentEntry = (env, platform = process.platform) => path47.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
31388
+ var ownedLauncherPath = (env, platform = process.platform) => path48.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
31389
+ var ownedCurrentEntry = (env, platform = process.platform) => path48.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
31228
31390
  var head = (file) => {
31229
31391
  let fd;
31230
31392
  try {
@@ -31251,7 +31413,7 @@ var locateWorkitCli = (options = {}) => {
31251
31413
  source: "owned-launcher",
31252
31414
  command: launcher,
31253
31415
  args: [],
31254
- binDir: path47.dirname(launcher)
31416
+ binDir: path48.dirname(launcher)
31255
31417
  };
31256
31418
  const current = ownedCurrentEntry(env, platform);
31257
31419
  if (exists(current))
@@ -31280,7 +31442,7 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
31280
31442
  if (located.binDir) {
31281
31443
  const key = pathKey(env);
31282
31444
  const delimiter = platform === "win32" ? ";" : ":";
31283
- const same = (dir) => platform === "win32" ? path47.win32.normalize(dir).toLowerCase() === path47.win32.normalize(located.binDir).toLowerCase() : path47.posix.normalize(dir) === path47.posix.normalize(located.binDir);
31445
+ const same = (dir) => platform === "win32" ? path48.win32.normalize(dir).toLowerCase() === path48.win32.normalize(located.binDir).toLowerCase() : path48.posix.normalize(dir) === path48.posix.normalize(located.binDir);
31284
31446
  const rest = (env[key] ?? "").split(delimiter).filter((dir) => dir && !same(dir));
31285
31447
  patch[key] = [located.binDir, ...rest].join(delimiter);
31286
31448
  }
@@ -31304,9 +31466,9 @@ var ENDS = {
31304
31466
  };
31305
31467
  var SAFE_SESSION = /^[\w.@+][\w.:@/+-]{0,127}$/u;
31306
31468
  var HOST_SESSION_VARS2 = ["OPENCODE_SESSION_ID", "PI_SESSION_ID", "CODEX_THREAD_ID"];
31307
- var teardownDir = (env) => path48.join(stateDir(env), "procs");
31308
- var teardownLog = (env) => path48.join(teardownDir(env), "teardown.log");
31309
- var reapStamp = (env) => path48.join(teardownDir(env), "reap-at-start.stamp");
31469
+ var teardownDir = (env) => path49.join(stateDir(env), "procs");
31470
+ var teardownLog = (env) => path49.join(teardownDir(env), "teardown.log");
31471
+ var reapStamp = (env) => path49.join(teardownDir(env), "reap-at-start.stamp");
31310
31472
  function spawnDetached(request) {
31311
31473
  try {
31312
31474
  const shell = process.platform === "win32" && !/\.exe$/iu.test(request.command);
@@ -31333,7 +31495,7 @@ var teardownDeps = {
31333
31495
  var openLog = (env, args) => {
31334
31496
  try {
31335
31497
  const file = teardownLog(env);
31336
- fs32.mkdirSync(path48.dirname(file), { recursive: true });
31498
+ fs32.mkdirSync(path49.dirname(file), { recursive: true });
31337
31499
  let size = 0;
31338
31500
  try {
31339
31501
  size = fs32.statSync(file).size;
@@ -31418,7 +31580,7 @@ function reapAtStart(_cwd, env = process.env) {
31418
31580
  try {
31419
31581
  if (fresh(stamp, now))
31420
31582
  return false;
31421
- fs32.mkdirSync(path48.dirname(stamp), { recursive: true });
31583
+ fs32.mkdirSync(path49.dirname(stamp), { recursive: true });
31422
31584
  if (!claim2(lock, now))
31423
31585
  return false;
31424
31586
  } catch {
@@ -32107,6 +32269,54 @@ Retry as: ${retry}`,
32107
32269
  return null;
32108
32270
  }
32109
32271
 
32272
+ // packages/workit-core/src/hooks/hook-entry.ts
32273
+ var RUNNERS2 = new Set([
32274
+ "node",
32275
+ "nodejs",
32276
+ "bun",
32277
+ "deno",
32278
+ "tsx",
32279
+ "ts-node",
32280
+ "sh",
32281
+ "bash",
32282
+ "zsh",
32283
+ "dash",
32284
+ "ksh",
32285
+ "fish",
32286
+ "source",
32287
+ "."
32288
+ ]);
32289
+ var PACKAGE_RUNNERS2 = new Set(["npx", "bunx", "pnpx"]);
32290
+ var NO_RUN = new Set([
32291
+ "build",
32292
+ "test",
32293
+ "fmt",
32294
+ "lint",
32295
+ "check",
32296
+ "doc",
32297
+ "info",
32298
+ "install",
32299
+ "add",
32300
+ "pm"
32301
+ ]);
32302
+ var MORE_WRAPPERS = new Set(["strace", "ltrace", "watch", "unshare", "firejail", "xargs", "&"]);
32303
+ var KEYWORDS3 = new Set([
32304
+ "{",
32305
+ "}",
32306
+ "if",
32307
+ "then",
32308
+ "elif",
32309
+ "else",
32310
+ "fi",
32311
+ "while",
32312
+ "until",
32313
+ "do",
32314
+ "done",
32315
+ "esac",
32316
+ "!"
32317
+ ]);
32318
+ var READERS2 = new Set(("cat less more head tail ls dir stat file wc grep egrep fgrep rg ag diff cmp sha256sum md5sum " + "shasum du bat echo printf cp mv rm chmod touch mkdir realpath readlink dirname basename tee " + "oxfmt oxlint prettier eslint tsc gh jq sort uniq cut tr nl od xxd hexdump strings code vim " + "nano sed get-content gc type select-string get-childitem test-path").split(" "));
32319
+
32110
32320
  // packages/workit-core/src/hooks/identity-env.ts
32111
32321
  var NAMES = "WORKIT_(?:AGENT_ID|HOST|SESSION_ID|SESSION_TOKEN)";
32112
32322
  var HOST_NAMES = "(?:OPENCODE_SESSION_ID|PI_SESSION_ID|CODEX_THREAD_ID|CLAUDECODE|CLAUDE_CODE_ENTRYPOINT)";
@@ -32148,11 +32358,11 @@ var PROCESS_START = performance.timeOrigin;
32148
32358
  // packages/workit-core/src/hooks/run.ts
32149
32359
  if (false) {}
32150
32360
  // packages/workit-opencode/src/shared/init-apply.ts
32151
- import path54 from "node:path";
32361
+ import path55 from "node:path";
32152
32362
 
32153
32363
  // packages/workit-core/src/core/gitignore.ts
32154
32364
  import { existsSync as existsSync18, readFileSync as readFileSync13, writeFileSync as writeFileSync6 } from "node:fs";
32155
- import path49 from "node:path";
32365
+ import path50 from "node:path";
32156
32366
  var GITIGNORE_ENTRIES = [
32157
32367
  "# workit: SDD working state (never commit)",
32158
32368
  "docs/*/sdd/",
@@ -32172,7 +32382,7 @@ var GITIGNORE_ENTRIES = [
32172
32382
  var ensureProjectGitignore = (workspaceRoot, confirmed) => {
32173
32383
  if (!confirmed)
32174
32384
  return { ok: false, error: "confirmed: true required" };
32175
- const file = path49.join(workspaceRoot, ".gitignore");
32385
+ const file = path50.join(workspaceRoot, ".gitignore");
32176
32386
  const existing = existsSync18(file) ? readFileSync13(file, "utf8") : "";
32177
32387
  const existingLines = new Set(existing.split(`
32178
32388
  `).map((l) => l.trim()).filter(Boolean));
@@ -32199,8 +32409,8 @@ var ensureProjectGitignore = (workspaceRoot, confirmed) => {
32199
32409
  };
32200
32410
 
32201
32411
  // packages/workit-core/src/core/hygiene.ts
32202
- import { existsSync as existsSync20, readFileSync as readFileSync15, readdirSync as readdirSync7, writeFileSync as writeFileSync8 } from "node:fs";
32203
- import path51 from "node:path";
32412
+ import { existsSync as existsSync20, readFileSync as readFileSync15, readdirSync as readdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
32413
+ import path52 from "node:path";
32204
32414
 
32205
32415
  // packages/workit-core/src/git/ops.ts
32206
32416
  import { spawnSync as spawnSync25 } from "node:child_process";
@@ -32208,12 +32418,12 @@ import {
32208
32418
  copyFileSync as copyFileSync3,
32209
32419
  existsSync as existsSync19,
32210
32420
  mkdirSync as mkdirSync6,
32211
- readdirSync as readdirSync6,
32421
+ readdirSync as readdirSync7,
32212
32422
  readFileSync as readFileSync14,
32213
32423
  rmSync as rmSync3,
32214
32424
  writeFileSync as writeFileSync7
32215
32425
  } from "node:fs";
32216
- import path50 from "node:path";
32426
+ import path51 from "node:path";
32217
32427
  var COMMIT_TIMEOUT_MS = 10 * 60000;
32218
32428
  var git5 = (cwd, args, options = {}) => {
32219
32429
  const result = spawnSync25("git", args, {
@@ -32246,18 +32456,18 @@ function operationInProgress(cwd) {
32246
32456
  if (!run.ok)
32247
32457
  return null;
32248
32458
  const found = run.stdout.split(`
32249
- `).map((line) => path50.resolve(cwd, line.trim()));
32459
+ `).map((line) => path51.resolve(cwd, line.trim()));
32250
32460
  const conflicted = () => git5(cwd, ["ls-files", "-u"]).stdout.trim() !== "";
32251
32461
  for (const [index, [, operation]] of markers.entries()) {
32252
32462
  const marker = found[index];
32253
32463
  if (!marker || !existsSync19(marker))
32254
32464
  continue;
32255
- if (index === 1 && existsSync19(path50.join(marker, "applying")))
32465
+ if (index === 1 && existsSync19(path51.join(marker, "applying")))
32256
32466
  return { operation: "am", commitAllowed: false, branch: null };
32257
- if (index === 0 && existsSync19(path50.join(marker, "amend")) && !conflicted()) {
32467
+ if (index === 0 && existsSync19(path51.join(marker, "amend")) && !conflicted()) {
32258
32468
  let headName = "";
32259
32469
  try {
32260
- headName = readFileSync14(path50.join(marker, "head-name"), "utf8").trim();
32470
+ headName = readFileSync14(path51.join(marker, "head-name"), "utf8").trim();
32261
32471
  } catch {}
32262
32472
  const branch = headName.startsWith("refs/heads/") ? headName.slice("refs/heads/".length) : null;
32263
32473
  return { operation, commitAllowed: branch !== null, branch };
@@ -32310,23 +32520,23 @@ var BATCH_BYTES = 16 * 1024 * 1024;
32310
32520
 
32311
32521
  // packages/workit-core/src/core/hygiene.ts
32312
32522
  var repoRoot3 = assetRoot();
32313
- var templatesDir = () => path51.join(repoRoot3, "templates", "hygiene");
32523
+ var templatesDir = () => path52.join(repoRoot3, "templates", "hygiene");
32314
32524
  var packageJson2 = (root) => {
32315
- if (!existsSync20(path51.join(root, "package.json")))
32525
+ if (!existsSync20(path52.join(root, "package.json")))
32316
32526
  return null;
32317
32527
  try {
32318
- return JSON.parse(readFileSync15(path51.join(root, "package.json"), "utf8"));
32528
+ return JSON.parse(readFileSync15(path52.join(root, "package.json"), "utf8"));
32319
32529
  } catch {
32320
32530
  return null;
32321
32531
  }
32322
32532
  };
32323
32533
  var isOpenSource = (root) => {
32324
- if (existsSync20(path51.join(root, "LICENSE")))
32534
+ if (existsSync20(path52.join(root, "LICENSE")))
32325
32535
  return true;
32326
32536
  const pkg = packageJson2(root);
32327
32537
  if (pkg && !pkg.private)
32328
32538
  return true;
32329
- return path51.basename(root) === "workit";
32539
+ return path52.basename(root) === "workit";
32330
32540
  };
32331
32541
  var licenseHolder = (root) => {
32332
32542
  const pkg = packageJson2(root);
@@ -32349,13 +32559,13 @@ var planHygieneFiles = (root, opts = {}) => {
32349
32559
  files.push("LICENSE", "CONTRIBUTING.md");
32350
32560
  const planned = [];
32351
32561
  for (const file of files) {
32352
- if (existsSync20(path51.join(root, file)))
32562
+ if (existsSync20(path52.join(root, file)))
32353
32563
  continue;
32354
- const tpl = path51.join(templatesDir(), file);
32564
+ const tpl = path52.join(templatesDir(), file);
32355
32565
  if (!existsSync20(tpl))
32356
32566
  continue;
32357
- const content = readFileSync15(tpl, "utf8").replace(/<PROJECT>/g, path51.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
32358
- planned.push({ path: path51.join(root, file), content });
32567
+ const content = readFileSync15(tpl, "utf8").replace(/<PROJECT>/g, path52.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
32568
+ planned.push({ path: path52.join(root, file), content });
32359
32569
  }
32360
32570
  return planned;
32361
32571
  };
@@ -32365,19 +32575,19 @@ var ensureHygieneFiles = (root, opts) => {
32365
32575
  const created = [];
32366
32576
  for (const planned of planHygieneFiles(root, opts)) {
32367
32577
  writeFileSync8(planned.path, planned.content, "utf8");
32368
- created.push(path51.basename(planned.path));
32578
+ created.push(path52.basename(planned.path));
32369
32579
  }
32370
32580
  return { ok: true, created };
32371
32581
  };
32372
32582
 
32373
32583
  // packages/workit-core/src/core/init.ts
32374
32584
  import fs33 from "node:fs";
32375
- import path53 from "node:path";
32585
+ import path54 from "node:path";
32376
32586
  import { spawnSync as spawnSync26 } from "node:child_process";
32377
32587
 
32378
32588
  // packages/workit-core/src/core/workspace-branch-policy.ts
32379
32589
  import { mkdirSync as mkdirSync7, readFileSync as readFileSync16, renameSync as renameSync5, rmSync as rmSync4, writeFileSync as writeFileSync9 } from "node:fs";
32380
- import path52 from "node:path";
32590
+ import path53 from "node:path";
32381
32591
  import { isDeepStrictEqual } from "node:util";
32382
32592
  var readFileSafe = (p) => {
32383
32593
  try {
@@ -32388,7 +32598,7 @@ var readFileSafe = (p) => {
32388
32598
  };
32389
32599
  function applyWorkspaceBranchPolicy(opts) {
32390
32600
  const { workspace_root, env = process.env } = opts;
32391
- const dir = path52.join(env.WORKIT_CONFIG ?? configDir2());
32601
+ const dir = path53.join(env.WORKIT_CONFIG ?? configDir2());
32392
32602
  const {
32393
32603
  status,
32394
32604
  path: wsPath,
@@ -32400,7 +32610,7 @@ function applyWorkspaceBranchPolicy(opts) {
32400
32610
  if (status === "malformed" || status === "invalid")
32401
32611
  return { ok: false, error: workspacesError ?? `invalid workspaces.json: ${wsPath}` };
32402
32612
  const detection = detectBranchPolicy(workspace_root);
32403
- const name = String(env.WORKIT_BP_NAME ?? path52.basename(workspace_root));
32613
+ const name = String(env.WORKIT_BP_NAME ?? path53.basename(workspace_root));
32404
32614
  const integration = env.WORKIT_BP_INTEGRATION ?? detection.integration;
32405
32615
  const policy = {
32406
32616
  preset: detection.preset,
@@ -32449,7 +32659,7 @@ function applyWorkspaceBranchPolicy(opts) {
32449
32659
  ok: false,
32450
32660
  error: `workspaces.json changed while applying the branch policy: ${wsPath}`
32451
32661
  };
32452
- mkdirSync7(path52.dirname(wsPath), { recursive: true });
32662
+ mkdirSync7(path53.dirname(wsPath), { recursive: true });
32453
32663
  const tmp = `${wsPath}.${process.pid}.tmp`;
32454
32664
  try {
32455
32665
  writeFileSync9(tmp, JSON.stringify({ ...document, workspaces: next }, null, 2) + `
@@ -32549,7 +32759,7 @@ function initApplyData(action, env = process.env) {
32549
32759
  fs33.mkdirSync(dir, { recursive: true });
32550
32760
  switch (action) {
32551
32761
  case "youtrack_json": {
32552
- const out = path53.join(dir, "youtrack.json");
32762
+ const out = path54.join(dir, "youtrack.json");
32553
32763
  fs33.writeFileSync(out, JSON.stringify(youtrackJsonContent(), null, 2) + `
32554
32764
  `, "utf8");
32555
32765
  return { action, ok: true, path: out };
@@ -32563,10 +32773,10 @@ function initApplyData(action, env = process.env) {
32563
32773
  };
32564
32774
  }
32565
32775
  case "youtrack_scaffold": {
32566
- const jsonOut = path53.join(dir, "youtrack.json");
32776
+ const jsonOut = path54.join(dir, "youtrack.json");
32567
32777
  fs33.writeFileSync(jsonOut, JSON.stringify(youtrackJsonContent(), null, 2) + `
32568
32778
  `, "utf8");
32569
- const configPath = path53.resolve(jsonOut);
32779
+ const configPath = path54.resolve(jsonOut);
32570
32780
  const cfg = readJson3(configPath) ?? {};
32571
32781
  const base = String(cfg.baseUrl ?? "").replace(/\/+$/, "");
32572
32782
  const meeting = String(cfg.meetingIssue ?? "");
@@ -32602,10 +32812,10 @@ function initApplyData(action, env = process.env) {
32602
32812
  };
32603
32813
  }
32604
32814
  case "vcs_scaffold": {
32605
- const jsonOut = path53.join(dir, "vcs.json");
32815
+ const jsonOut = path54.join(dir, "vcs.json");
32606
32816
  fs33.writeFileSync(jsonOut, JSON.stringify(vcsJsonContent(), null, 2) + `
32607
32817
  `, "utf8");
32608
- const configPath = path53.resolve(jsonOut);
32818
+ const configPath = path54.resolve(jsonOut);
32609
32819
  const prev = process.env.WORKIT_VCS_CONFIG;
32610
32820
  process.env.WORKIT_VCS_CONFIG = configPath;
32611
32821
  try {
@@ -32724,7 +32934,7 @@ var executeInitApply = (args, directory, runtime) => {
32724
32934
  protectedNames: args.branch_policy_protected
32725
32935
  }, current);
32726
32936
  writeConfig(next);
32727
- return output(ok({ action: "config", path: path54.join(configDir2(), "config.json"), ...next }));
32937
+ return output(ok({ action: "config", path: path55.join(configDir2(), "config.json"), ...next }));
32728
32938
  }
32729
32939
  const env = Object.fromEntries(Object.entries({
32730
32940
  WORKIT_YT_BASE_URL: args.base_url,
@@ -32741,14 +32951,14 @@ var executeInitApply = (args, directory, runtime) => {
32741
32951
 
32742
32952
  // packages/workit-opencode/src/shared/session.ts
32743
32953
  import { realpathSync as realpathSync12 } from "node:fs";
32744
- import path55 from "node:path";
32954
+ import path56 from "node:path";
32745
32955
  var sameWorkspace = (expected, observed) => {
32746
32956
  if (typeof observed !== "string" || !observed)
32747
32957
  return false;
32748
32958
  try {
32749
32959
  return realpathSync12(expected) === realpathSync12(observed);
32750
32960
  } catch {
32751
- return path55.resolve(expected) === path55.resolve(observed);
32961
+ return path56.resolve(expected) === path56.resolve(observed);
32752
32962
  }
32753
32963
  };
32754
32964
 
@@ -32820,7 +33030,7 @@ var workitFamilyOf = (toolName) => {
32820
33030
 
32821
33031
  // packages/workit-opencode/src/tools/context.ts
32822
33032
  import { realpathSync as realpathSync13 } from "node:fs";
32823
- import path56 from "node:path";
33033
+ import path57 from "node:path";
32824
33034
  var createContextTool = () => ({
32825
33035
  description: "Read Git, pull request, YouTrack, issue, changelog, release, or affected-file context.",
32826
33036
  execute: async (args, context) => {
@@ -32830,7 +33040,7 @@ var createContextTool = () => ({
32830
33040
  let root;
32831
33041
  try {
32832
33042
  const cwd = parsed.data.cwd;
32833
- root = realpathSync13(cwd ? path56.resolve(context.directory, cwd) : context.directory);
33043
+ root = realpathSync13(cwd ? path57.resolve(context.directory, cwd) : context.directory);
32834
33044
  } catch {
32835
33045
  return JSON.stringify(failure2("invalid_input", "context target directory cannot be resolved"), null, 2);
32836
33046
  }
@@ -32863,7 +33073,7 @@ var workerCoordinatorFor = (task, worker) => {
32863
33073
  import { spawnSync as spawnSync29 } from "node:child_process";
32864
33074
  import { createHash as createHash21 } from "node:crypto";
32865
33075
  import fs35 from "node:fs";
32866
- import path58 from "node:path";
33076
+ import path59 from "node:path";
32867
33077
 
32868
33078
  // packages/workit-core/src/fanout-landed.ts
32869
33079
  import { spawnSync as spawnSync27 } from "node:child_process";
@@ -33097,7 +33307,7 @@ var NOTICE_TTL_MS = 7 * 86400000;
33097
33307
  import { spawnSync as spawnSync28 } from "node:child_process";
33098
33308
  import { createHash as createHash20, randomBytes as randomBytes4 } from "node:crypto";
33099
33309
  import fs34 from "node:fs";
33100
- import path57 from "node:path";
33310
+ import path58 from "node:path";
33101
33311
 
33102
33312
  // packages/workit-core/src/forge/report.ts
33103
33313
  var GITLAB_MERGEABLE = new Set(["mergeable"]);
@@ -33179,7 +33389,7 @@ function rebaseInProgress(dir) {
33179
33389
  }
33180
33390
  var scratchDir = (cwd) => {
33181
33391
  const dir = stacksDir(cwd);
33182
- return dir.ok ? path57.join(dir.data, "worktrees") : null;
33392
+ return dir.ok ? path58.join(dir.data, "worktrees") : null;
33183
33393
  };
33184
33394
  function gitRestack(cwd, input) {
33185
33395
  const owner = worktreeOf(cwd, input.branch);
@@ -33194,7 +33404,7 @@ function gitRestack(cwd, input) {
33194
33404
  error: "no store root"
33195
33405
  };
33196
33406
  fs34.mkdirSync(scratch, { recursive: true });
33197
- dir = path57.join(scratch, `${input.branch.replace(/[^A-Za-z0-9._-]+/gu, "_").slice(0, 40)}-${randomBytes4(4).toString("hex")}`);
33407
+ dir = path58.join(scratch, `${input.branch.replace(/[^A-Za-z0-9._-]+/gu, "_").slice(0, 40)}-${randomBytes4(4).toString("hex")}`);
33198
33408
  const added = gitRun4(cwd, ["worktree", "add", "-q", dir, input.branch], GIT_TIMEOUTS.worktree);
33199
33409
  if (!added.ok)
33200
33410
  return {
@@ -33253,7 +33463,7 @@ function stacksDir(cwd) {
33253
33463
  const root = storeRoot(cwd);
33254
33464
  if (!root.ok)
33255
33465
  return stackFail(root.code, root.error, root.unblock);
33256
- return { ok: true, data: path57.join(root.value.root, "stacks") };
33466
+ return { ok: true, data: path58.join(root.value.root, "stacks") };
33257
33467
  }
33258
33468
  var HEARTBEAT_STALE_MS = 2 * 60000;
33259
33469
  var SETTLED_BY_RESTACK = new Set(["checks_pending", "behind_base_required"]);
@@ -33400,7 +33610,7 @@ function fanoutsDir(cwd) {
33400
33610
  const root = storeRoot(cwd);
33401
33611
  if (!root.ok)
33402
33612
  return fanoutFail(root.code, root.error, root.unblock);
33403
- return { ok: true, data: path58.join(root.value.root, "fanouts") };
33613
+ return { ok: true, data: path59.join(root.value.root, "fanouts") };
33404
33614
  }
33405
33615
  function parseStored(raw) {
33406
33616
  if (!isRecord9(raw) || typeof raw.name !== "string" || typeof raw.trunk !== "string")
@@ -33468,7 +33678,7 @@ function readFanout(cwd, name) {
33468
33678
  const dir = fanoutsDir(cwd);
33469
33679
  if (!dir.ok)
33470
33680
  return dir;
33471
- const file = path58.join(dir.data, stackFileName(name));
33681
+ const file = path59.join(dir.data, stackFileName(name));
33472
33682
  let parsed = null;
33473
33683
  try {
33474
33684
  parsed = parseStored(JSON.parse(fs35.readFileSync(file, "utf8")));
@@ -33493,7 +33703,7 @@ function listFanouts(cwd) {
33493
33703
  for (const entry of names) {
33494
33704
  let parsed = null;
33495
33705
  try {
33496
- parsed = parseStored(JSON.parse(fs35.readFileSync(path58.join(dir.data, entry), "utf8")));
33706
+ parsed = parseStored(JSON.parse(fs35.readFileSync(path59.join(dir.data, entry), "utf8")));
33497
33707
  } catch {
33498
33708
  parsed = null;
33499
33709
  }
@@ -34386,7 +34596,7 @@ var childTaskMissing = (store, input) => {
34386
34596
  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`;
34387
34597
 
34388
34598
  // packages/workit-opencode/src/v2/shell.ts
34389
- import path59 from "node:path";
34599
+ import path60 from "node:path";
34390
34600
 
34391
34601
  // packages/workit-core/src/hooks/repeat-failure.ts
34392
34602
  import { createHash as createHash22 } from "node:crypto";
@@ -34449,7 +34659,7 @@ var commandOf = (input) => {
34449
34659
  };
34450
34660
  var hookInput = (root, sessionID, id, shell) => ({
34451
34661
  host: "opencode",
34452
- cwd: shell.workdir ? path59.resolve(root, shell.workdir) : root,
34662
+ cwd: shell.workdir ? path60.resolve(root, shell.workdir) : root,
34453
34663
  session: { id: sessionID, agentId: null, agentType: null, parentId: null },
34454
34664
  permissionMode: null,
34455
34665
  transcriptPath: null,
@@ -34973,37 +35183,37 @@ var createStopControl = (root, port) => {
34973
35183
 
34974
35184
  // packages/workit-opencode/src/v2/registry.ts
34975
35185
  import { existsSync as existsSync22, readFileSync as readFileSync17 } from "node:fs";
34976
- import path61 from "node:path";
35186
+ import path62 from "node:path";
34977
35187
 
34978
35188
  // packages/workit-opencode/src/shared/assets.ts
34979
35189
  import { existsSync as existsSync21, realpathSync as realpathSync14 } from "node:fs";
34980
- import path60 from "node:path";
35190
+ import path61 from "node:path";
34981
35191
  import { fileURLToPath as fileURLToPath2 } from "node:url";
34982
35192
  var moduleDir = () => {
34983
35193
  try {
34984
- return realpathSync14(path60.dirname(fileURLToPath2(import.meta.url)));
35194
+ return realpathSync14(path61.dirname(fileURLToPath2(import.meta.url)));
34985
35195
  } catch {
34986
- return path60.dirname(fileURLToPath2(import.meta.url));
35196
+ return path61.dirname(fileURLToPath2(import.meta.url));
34987
35197
  }
34988
35198
  };
34989
35199
  var packageRoot2 = () => {
34990
35200
  const dir = moduleDir();
34991
35201
  for (const candidate of [
34992
- path60.resolve(dir, ".."),
34993
- path60.resolve(dir, "..", ".."),
34994
- path60.resolve(dir, "..", "..", "..")
35202
+ path61.resolve(dir, ".."),
35203
+ path61.resolve(dir, "..", ".."),
35204
+ path61.resolve(dir, "..", "..", "..")
34995
35205
  ]) {
34996
- if (existsSync21(path60.join(candidate, "package.json")))
35206
+ if (existsSync21(path61.join(candidate, "package.json")))
34997
35207
  return candidate;
34998
35208
  }
34999
- return path60.resolve(dir, "..");
35209
+ return path61.resolve(dir, "..");
35000
35210
  };
35001
35211
  var skillsRoot = () => {
35002
35212
  const root = packageRoot2();
35003
- const canonical = path60.resolve(root, "..", "workit-core", "skills");
35004
- if (existsSync21(path60.join(root, "src")) && existsSync21(canonical))
35213
+ const canonical = path61.resolve(root, "..", "workit-core", "skills");
35214
+ if (existsSync21(path61.join(root, "src")) && existsSync21(canonical))
35005
35215
  return canonical;
35006
- return path60.join(root, "assets", "skills");
35216
+ return path61.join(root, "assets", "skills");
35007
35217
  };
35008
35218
 
35009
35219
  // packages/workit-opencode/src/v2/registry.ts
@@ -35030,11 +35240,11 @@ var registerSkills = async (ctx) => {
35030
35240
  if (!existsSync22(skillsDir))
35031
35241
  return new Set;
35032
35242
  const listed = await ctx.skill.list().catch(() => ({ data: [] }));
35033
- const own = (skill) => typeof skill.path === "string" && path61.resolve(skill.path).startsWith(skillsDir + path61.sep);
35243
+ const own = (skill) => typeof skill.path === "string" && path62.resolve(skill.path).startsWith(skillsDir + path62.sep);
35034
35244
  const userSkills = new Set((listed?.data ?? []).filter((skill) => !own(skill)).map((skill) => skill.id));
35035
35245
  const packaged = new Map;
35036
35246
  for (const id of WORKIT_METHOD_SKILLS) {
35037
- const file = path61.join(skillsDir, id, "SKILL.md");
35247
+ const file = path62.join(skillsDir, id, "SKILL.md");
35038
35248
  if (!userSkills.has(id) && existsSync22(file))
35039
35249
  packaged.set(id, file);
35040
35250
  }
@@ -35081,23 +35291,23 @@ var registerCommands = async (ctx, registeredSkills) => {
35081
35291
  };
35082
35292
 
35083
35293
  // packages/workit-opencode/src/stale-sources.ts
35084
- import { existsSync as existsSync23, readdirSync as readdirSync8 } from "node:fs";
35085
- import path62 from "node:path";
35294
+ import { existsSync as existsSync23, readdirSync as readdirSync9 } from "node:fs";
35295
+ import path63 from "node:path";
35086
35296
  import { fileURLToPath as fileURLToPath3 } from "node:url";
35087
35297
  var typescriptFiles = (directory) => {
35088
35298
  if (!existsSync23(directory))
35089
35299
  return [];
35090
- return readdirSync8(directory, { withFileTypes: true }).flatMap((entry) => {
35091
- const file = path62.join(directory, entry.name);
35300
+ return readdirSync9(directory, { withFileTypes: true }).flatMap((entry) => {
35301
+ const file = path63.join(directory, entry.name);
35092
35302
  return entry.isDirectory() ? typescriptFiles(file) : entry.isFile() && file.endsWith(".ts") ? [file] : [];
35093
35303
  });
35094
35304
  };
35095
35305
  var pluginSourceFiles = [
35096
35306
  ...new Set([
35097
35307
  fileURLToPath3(import.meta.url),
35098
- ...typescriptFiles(path62.join(packageRoot2(), "src")),
35099
- path62.join(packageRoot2(), "..", "workit-core", "src", "core.ts"),
35100
- ...typescriptFiles(path62.join(packageRoot2(), "..", "workit-core", "src", "core"))
35308
+ ...typescriptFiles(path63.join(packageRoot2(), "src")),
35309
+ path63.join(packageRoot2(), "..", "workit-core", "src", "core.ts"),
35310
+ ...typescriptFiles(path63.join(packageRoot2(), "..", "workit-core", "src", "core"))
35101
35311
  ])
35102
35312
  ].filter((file) => existsSync23(file)).toSorted();
35103
35313
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/opencode",
3
- "version": "2.27.7",
3
+ "version": "2.27.8",
4
4
  "private": false,
5
5
  "description": "Workit OpenCode plugin — native tools, adaptive policy, and sixteen method skills",
6
6
  "keywords": [
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@opencode/plugin": "2.3.2",
44
- "@workit-dev/core": "^2.27.7"
44
+ "@workit-dev/core": "^2.27.8"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24"