@workit-dev/codex 2.20.6 → 2.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workit",
3
- "version": "2.20.6",
3
+ "version": "2.21.1",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -15526,7 +15526,8 @@ var workspaceConfigSchema = object({
15526
15526
  youtrack: object({
15527
15527
  baseUrl: nonBlank.optional().describe("This workspace's YouTrack URL."),
15528
15528
  link_issues: boolean2().optional().describe("Legacy alias of `issues: { provider: youtrack, link: true }`."),
15529
- writes: _enum(["ask", "auto"]).optional().describe("ask (default): each workit youtrack write waits for the user's yes. auto: posts without asking, behind WORKIT_YT_WRITE=1.")
15529
+ writes: _enum(["ask", "auto"]).optional().describe("ask (default): each workit youtrack write waits for the user's yes. auto: posts without asking, behind WORKIT_YT_WRITE=1."),
15530
+ autoHosts: array(nonBlank).optional().describe("With writes auto: the only YouTrack hosts (`acme.youtrack.cloud`) a write may reach without asking. A raw ytrack write must name one with --host; a write elsewhere asks. Only the user widens it, in their own terminal (`workit workspace seal`).")
15530
15531
  }).passthrough().optional().describe("YouTrack settings for this workspace."),
15531
15532
  issues: object({
15532
15533
  provider: _enum(["github", "gitlab", "youtrack"]).optional().describe("The issue tracker PRs link to."),
@@ -24817,7 +24818,7 @@ var exportDigest = (bundle) => sha256({
24817
24818
  });
24818
24819
  // packages/workit-core/src/autonomy.ts
24819
24820
  import { closeSync as closeSync2, copyFileSync as copyFileSync2, existsSync as existsSync11, openSync as openSync2 } from "node:fs";
24820
- import path26 from "node:path";
24821
+ import path27 from "node:path";
24821
24822
 
24822
24823
  // packages/workit-core/src/core/eval-world.ts
24823
24824
  import { existsSync as existsSync10, realpathSync as realpathSync6 } from "node:fs";
@@ -24882,7 +24883,7 @@ var sealProjection = (entries) => entries.map((entry) => {
24882
24883
  return pick2({
24883
24884
  ...all,
24884
24885
  vcs: pick2(all.vcs, IDENTITY_KEYS),
24885
- youtrack: pick2(all.youtrack, ["writes"])
24886
+ youtrack: pick2(all.youtrack, ["writes", "autoHosts"])
24886
24887
  }, ENTRY_KEYS);
24887
24888
  });
24888
24889
  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);
@@ -24912,6 +24913,78 @@ function checkSeal(dir) {
24912
24913
  return ok && sealDigest(sealProjection(current.entries)) === seal.sha256 ? { state: "valid" } : broken("workspaces.json changed since it was sealed", sealed.entries);
24913
24914
  }
24914
24915
 
24916
+ // packages/workit-core/src/core/youtrack-ytrack.ts
24917
+ import { spawnSync as spawnSync16 } from "node:child_process";
24918
+
24919
+ // packages/workit-core/src/forge/exec.ts
24920
+ import fs18 from "node:fs";
24921
+ import path26 from "node:path";
24922
+
24923
+ // packages/workit-core/src/forge/redact.ts
24924
+ var NAME = "[A-Za-z0-9_.-]";
24925
+ var KEY = String.raw`(?<!${NAME})(?=${NAME}*?(?:token|secret|password|passwd|pwd|api[_-]?key|access[_-]?key|account[_-]?key|private[_-]?key|client[_-]?secret|credentials?|authorization|cookie|signature))${NAME}+`;
24926
+ var ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*["']?)((?:bearer|basic|token|digest)\s+)?([^\s"',;&]+)`, "giu");
24927
+ var QUOTED_ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*)(["'])([^"'\n]*[^\s"'][^"'\n]*)\2`, "giu");
24928
+ var SECRET_FLAG = new RegExp(String.raw`(?<![\w-])(--(?=[\w-]*?(?<![a-z0-9])(?:password|passwd|pwd|secret|token|api[-_]?key|auth|authorization|credentials?|private[-_]?key|access[-_]?key)(?![a-z0-9]))[\w-]+(?:\s+|=))((?:bearer|basic|token|digest)\s+(?![\s-]))?(?:(["'])(?:[^\n]*?\3|[^\n]*)|(?!-)[^\s"']+)`, "giu");
24929
+ var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*\u0007`, "gu");
24930
+
24931
+ // packages/workit-core/src/forge/exec.ts
24932
+ var MAX_BUFFER2 = 64 * 1024 * 1024;
24933
+ function findExecutable(bin, env) {
24934
+ const dirs = (env.PATH ?? env.Path ?? "").split(path26.delimiter).filter(Boolean);
24935
+ const exts = process.platform === "win32" ? [".exe"] : [""];
24936
+ for (const dir of dirs)
24937
+ for (const ext of exts) {
24938
+ const candidate = path26.join(dir, `${bin}${ext}`);
24939
+ try {
24940
+ const stat = fs18.statSync(candidate);
24941
+ if (stat.isFile())
24942
+ return candidate;
24943
+ } catch {}
24944
+ }
24945
+ return null;
24946
+ }
24947
+
24948
+ // packages/workit-core/src/core/youtrack-ytrack.ts
24949
+ var TIMEOUT_MS = 60000;
24950
+ var YTRACK_EXIT = { ok: 0, failed: 1, cancelled: 2, auth: 4 };
24951
+ var findYtrack = (env) => env.WORKIT_NO_YTRACK === "1" ? null : findExecutable("ytrack", env);
24952
+ var YTRACK_QUIET_ENV = {
24953
+ YTRACK_NO_UPDATE_NOTIFIER: "1",
24954
+ YTRACK_NO_AUTO_UPGRADE: "1"
24955
+ };
24956
+ function ytrackRunner(env, host, timeoutMs = TIMEOUT_MS) {
24957
+ return (args, input) => {
24958
+ const exe = findYtrack(env);
24959
+ if (!exe)
24960
+ return { status: null, stdout: "", stderr: "", missing: true };
24961
+ const result = spawnSync16(exe, args, {
24962
+ encoding: "utf8",
24963
+ env: {
24964
+ ...env,
24965
+ NO_COLOR: "1",
24966
+ ...YTRACK_QUIET_ENV,
24967
+ ...host ? { YTRACK_HOST: host } : {}
24968
+ },
24969
+ timeout: timeoutMs,
24970
+ killSignal: "SIGKILL",
24971
+ windowsHide: true,
24972
+ ...input === undefined ? { stdio: ["ignore", "pipe", "pipe"] } : { input, stdio: ["pipe", "pipe", "pipe"] }
24973
+ });
24974
+ const error = result.error;
24975
+ if (error?.code === "ENOENT")
24976
+ return { status: null, stdout: "", stderr: "", missing: true };
24977
+ return {
24978
+ status: result.status,
24979
+ stdout: result.stdout ?? "",
24980
+ stderr: result.stderr || (error ? error.message : "")
24981
+ };
24982
+ };
24983
+ }
24984
+ var ytrackDetail = (out) => out.stderr.trim().split(`
24985
+ `).slice(-3).join(" ").slice(0, 300);
24986
+ var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only through ytrack";
24987
+
24915
24988
  // packages/workit-core/src/autonomy.ts
24916
24989
  var accountHomeDir = () => {
24917
24990
  const home = grantsHome.resolve();
@@ -24919,7 +24992,7 @@ var accountHomeDir = () => {
24919
24992
  };
24920
24993
  var deniedFile = (dir) => {
24921
24994
  for (const name of ["workspaces.json", SEAL_FILE]) {
24922
- const file = path26.join(dir, name);
24995
+ const file = path27.join(dir, name);
24923
24996
  try {
24924
24997
  closeSync2(openSync2(file, "r"));
24925
24998
  } catch (error) {
@@ -24941,7 +25014,7 @@ var accountUnread = () => {
24941
25014
  if (dir === null)
24942
25015
  return NO_ACCOUNT;
24943
25016
  const file = deniedFile(dir);
24944
- return file === null ? null : `the account's ${path26.basename(file)} cannot be read (permission denied), so it reads as no workspace entries: no grants, no models, the D4 defaults apply`;
25017
+ return file === null ? null : `the account's ${path27.basename(file)} cannot be read (permission denied), so it reads as no workspace entries: no grants, no models, the D4 defaults apply`;
24945
25018
  };
24946
25019
  var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
24947
25020
  var fileSource = (dir = accountDir()) => ({
@@ -24962,7 +25035,7 @@ var NO_SEAL_NOTE = `workspaces.json has no seal yet (${SEAL_COMMAND} has never r
24962
25035
  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;
24963
25036
  var shownGrantsDir = () => {
24964
25037
  const world = evalWorld(process.cwd());
24965
- return world ? path26.join(world, "config") : accountDir();
25038
+ return world ? path27.join(world, "config") : accountDir();
24966
25039
  };
24967
25040
  var benchWorld = (cwd) => {
24968
25041
  const entry = evalWorldEntry(cwd);
@@ -24986,10 +25059,10 @@ var grantsOverride = () => {
24986
25059
  const shown = shownGrantsDir();
24987
25060
  if (shown === null)
24988
25061
  return accountUnread() ?? NO_ACCOUNT;
24989
- const configured = path26.resolve(resolveConfigDir());
24990
- 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")}, and under a redirect they never exceed the D4 defaults`;
25062
+ const configured = path27.resolve(resolveConfigDir());
25063
+ 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")}, and under a redirect they never exceed the D4 defaults`;
24991
25064
  };
24992
- var redirectUnblock = () => `ask the user: grants above the D4 defaults apply only without a config redirect (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), and are read from ${path26.join(grantsDir(), "workspaces.json")}`;
25065
+ var redirectUnblock = () => `ask the user: grants above the D4 defaults apply only without a config redirect (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), and are read from ${path27.join(grantsDir(), "workspaces.json")}`;
24993
25066
  var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
24994
25067
  var DEFAULT_GRANTS = Object.freeze({
24995
25068
  push: true,
@@ -27364,9 +27437,9 @@ class WorkitCore {
27364
27437
  }
27365
27438
  }
27366
27439
  // packages/workit-core/src/core/repo-context.ts
27367
- import { spawnSync as spawnSync16 } from "node:child_process";
27440
+ import { spawnSync as spawnSync17 } from "node:child_process";
27368
27441
  import { existsSync as existsSync12, readFileSync as readFileSync11, readdirSync as readdirSync4 } from "node:fs";
27369
- import path27 from "node:path";
27442
+ import path28 from "node:path";
27370
27443
  var isSafeContextRange = (value) => value.length <= 4096 && (() => {
27371
27444
  try {
27372
27445
  gitRevisionParts(value);
@@ -27393,7 +27466,7 @@ var invalidRange = (cwd) => ({
27393
27466
  cwd
27394
27467
  });
27395
27468
  var runGit = (cwd, args) => {
27396
- const result = spawnSync16("git", args, { cwd, encoding: "utf8" });
27469
+ const result = spawnSync17("git", args, { cwd, encoding: "utf8" });
27397
27470
  return {
27398
27471
  stdout: (result.stdout ?? "").trimEnd(),
27399
27472
  stderr: (result.stderr ?? "").trimEnd(),
@@ -27510,13 +27583,13 @@ var findPrTemplate = (cwd) => {
27510
27583
  for (const rel of PR_TEMPLATE_FILES) {
27511
27584
  const parts = rel.split("/");
27512
27585
  const base = parts[parts.length - 1];
27513
- const dir = parts.length > 1 ? path27.join(cwd, ...parts.slice(0, -1)) : cwd;
27586
+ const dir = parts.length > 1 ? path28.join(cwd, ...parts.slice(0, -1)) : cwd;
27514
27587
  const actual = probeCaseInsensitive(dir, base);
27515
27588
  if (actual)
27516
27589
  return [...parts.slice(0, -1), actual].join("/");
27517
27590
  }
27518
27591
  for (const rel of PR_TEMPLATE_DIRS) {
27519
- const only = singleMarkdown(path27.join(cwd, ...rel.split("/")));
27592
+ const only = singleMarkdown(path28.join(cwd, ...rel.split("/")));
27520
27593
  if (only)
27521
27594
  return `${rel}/${only}`;
27522
27595
  }
@@ -27546,7 +27619,7 @@ var diffStatForRange = (cwd, range) => {
27546
27619
  return runGit(cwd, ["diff", "--stat", "--"]).stdout;
27547
27620
  };
27548
27621
  var packageScripts = (cwd, keys) => {
27549
- const pkgPath = path27.join(cwd, "package.json");
27622
+ const pkgPath = path28.join(cwd, "package.json");
27550
27623
  if (!existsSync12(pkgPath))
27551
27624
  return [];
27552
27625
  try {
@@ -27572,9 +27645,9 @@ var documentationFiles = (cwd) => {
27572
27645
  if (entry.isDirectory()) {
27573
27646
  if (excluded.has(entry.name))
27574
27647
  continue;
27575
- walk(path27.join(dir, entry.name), depth + 1);
27648
+ walk(path28.join(dir, entry.name), depth + 1);
27576
27649
  } else if (entry.isFile() && (entry.name === "README.md" || entry.name.endsWith(".md"))) {
27577
- matches.push("./" + path27.relative(cwd, path27.join(dir, entry.name)).replaceAll("\\", "/"));
27650
+ matches.push("./" + path28.relative(cwd, path28.join(dir, entry.name)).replaceAll("\\", "/"));
27578
27651
  }
27579
27652
  }
27580
27653
  };
@@ -27590,7 +27663,7 @@ var readTrimmed2 = (file, maxLines) => {
27590
27663
  `);
27591
27664
  };
27592
27665
  function prReadyContext(root, range) {
27593
- const cwd = path27.resolve(repoRoot(root));
27666
+ const cwd = path28.resolve(repoRoot(root));
27594
27667
  if (range !== undefined && !isResolvableContextRange(cwd, range))
27595
27668
  return invalidRange(cwd);
27596
27669
  let stdout = "";
@@ -27648,7 +27721,7 @@ ${status.stderr}` : "");
27648
27721
  stdout += `template_path: ${template}
27649
27722
 
27650
27723
  `;
27651
- stdout += readTrimmed2(path27.join(cwd, template), 220);
27724
+ stdout += readTrimmed2(path28.join(cwd, template), 220);
27652
27725
  } else {
27653
27726
  stdout += `template_path: none
27654
27727
 
@@ -27658,7 +27731,7 @@ ${status.stderr}` : "");
27658
27731
  stdout += `
27659
27732
  `;
27660
27733
  stdout += printSection("Recent Validation Signals");
27661
- if (existsSync12(path27.join(cwd, "package.json"))) {
27734
+ if (existsSync12(path28.join(cwd, "package.json"))) {
27662
27735
  stdout += `package.json detected. Common scripts:
27663
27736
  `;
27664
27737
  const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
@@ -27667,7 +27740,7 @@ ${status.stderr}` : "");
27667
27740
  `) + `
27668
27741
  `;
27669
27742
  }
27670
- if (existsSync12(path27.join(cwd, "Cargo.toml")) || existsSync12(path27.join(cwd, "src-tauri/Cargo.toml"))) {
27743
+ if (existsSync12(path28.join(cwd, "Cargo.toml")) || existsSync12(path28.join(cwd, "src-tauri/Cargo.toml"))) {
27671
27744
  stdout += `Rust project detected.
27672
27745
  `;
27673
27746
  }
@@ -27700,7 +27773,7 @@ var CHANGELOG_RULES = `- Use an [Unreleased] section.
27700
27773
  - Apply with the host-native editor, preserving the repository changelog conventions.
27701
27774
  - If Unreleased already has duplicate category headings, normalize_only first.`;
27702
27775
  function changelogContext(root, range) {
27703
- const cwd = path27.resolve(repoRoot(root));
27776
+ const cwd = path28.resolve(repoRoot(root));
27704
27777
  if (range !== undefined && !isResolvableContextRange(cwd, range))
27705
27778
  return invalidRange(cwd);
27706
27779
  const resolvedRange = rangeArgOrDefault(range, cwd);
@@ -27718,7 +27791,7 @@ function changelogContext(root, range) {
27718
27791
  stdout += CHANGELOG_RULES + `
27719
27792
  `;
27720
27793
  stdout += printSection("Existing CHANGELOG.md");
27721
- const changelogPath = path27.join(cwd, "CHANGELOG.md");
27794
+ const changelogPath = path28.join(cwd, "CHANGELOG.md");
27722
27795
  if (existsSync12(changelogPath)) {
27723
27796
  stdout += readTrimmed2(changelogPath, 260) + `
27724
27797
  `;
@@ -27738,7 +27811,7 @@ function changelogContext(root, range) {
27738
27811
  return { stdout, stderr: "", exitCode: 0, cwd };
27739
27812
  }
27740
27813
  function docsRefreshContext(root, range) {
27741
- const cwd = path27.resolve(repoRoot(root));
27814
+ const cwd = path28.resolve(repoRoot(root));
27742
27815
  if (range !== undefined && !isResolvableContextRange(cwd, range))
27743
27816
  return invalidRange(cwd);
27744
27817
  const resolvedRange = rangeArgOrDefault(range, cwd);
@@ -27760,7 +27833,7 @@ function docsRefreshContext(root, range) {
27760
27833
  `) + `
27761
27834
  `;
27762
27835
  stdout += printSection("README Preview");
27763
- const readme = path27.join(cwd, "README.md");
27836
+ const readme = path28.join(cwd, "README.md");
27764
27837
  if (existsSync12(readme)) {
27765
27838
  stdout += readTrimmed2(readme, 220) + `
27766
27839
  `;
@@ -27769,7 +27842,7 @@ function docsRefreshContext(root, range) {
27769
27842
  `;
27770
27843
  }
27771
27844
  stdout += printSection("Package Scripts");
27772
- const pkgPath = path27.join(cwd, "package.json");
27845
+ const pkgPath = path28.join(cwd, "package.json");
27773
27846
  if (existsSync12(pkgPath)) {
27774
27847
  try {
27775
27848
  const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
@@ -27783,7 +27856,7 @@ function docsRefreshContext(root, range) {
27783
27856
  return { stdout, stderr: "", exitCode: 0, cwd };
27784
27857
  }
27785
27858
  function releaseNotesContext(root, rangeOrTag) {
27786
- const cwd = path27.resolve(repoRoot(root));
27859
+ const cwd = path28.resolve(repoRoot(root));
27787
27860
  if (!rangeOrTag) {
27788
27861
  return {
27789
27862
  stdout: "",
@@ -27826,7 +27899,7 @@ function releaseNotesContext(root, rangeOrTag) {
27826
27899
  `;
27827
27900
  stdout += printSection("Existing Release Files");
27828
27901
  for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
27829
- if (existsSync12(path27.join(cwd, rel)))
27902
+ if (existsSync12(path28.join(cwd, rel)))
27830
27903
  stdout += rel + `
27831
27904
  `;
27832
27905
  }
@@ -27854,12 +27927,12 @@ function releaseNotesContext(root, rangeOrTag) {
27854
27927
  }
27855
27928
 
27856
27929
  // packages/workit-core/src/core/tracker-issues.ts
27857
- import { spawnSync as spawnSync18 } from "node:child_process";
27930
+ import { spawnSync as spawnSync19 } from "node:child_process";
27858
27931
 
27859
27932
  // packages/workit-core/src/core/pr-create.ts
27860
- import fs18 from "node:fs";
27861
- import path28 from "node:path";
27862
- import { spawnSync as spawnSync17 } from "node:child_process";
27933
+ import fs19 from "node:fs";
27934
+ import path29 from "node:path";
27935
+ import { spawnSync as spawnSync18 } from "node:child_process";
27863
27936
  // packages/workit-core/src/forge/pr-body.ts
27864
27937
  function parseGhIssue(value) {
27865
27938
  const m = /issues\/(\d+)/.exec(value);
@@ -27878,13 +27951,13 @@ var LOCAL = bounded(20000);
27878
27951
  var NETWORK = bounded(60000);
27879
27952
  function whichOnPath(tool) {
27880
27953
  const names = process.platform === "win32" ? [tool, `${tool}.exe`, `${tool}.cmd`] : [tool];
27881
- for (const dir of (process.env.PATH ?? "").split(path28.delimiter)) {
27954
+ for (const dir of (process.env.PATH ?? "").split(path29.delimiter)) {
27882
27955
  if (!dir)
27883
27956
  continue;
27884
27957
  for (const name of names) {
27885
- const candidate = path28.join(dir, name);
27958
+ const candidate = path29.join(dir, name);
27886
27959
  try {
27887
- fs18.accessSync(candidate, fs18.constants.X_OK);
27960
+ fs19.accessSync(candidate, fs19.constants.X_OK);
27888
27961
  return candidate;
27889
27962
  } catch {}
27890
27963
  }
@@ -27893,7 +27966,7 @@ function whichOnPath(tool) {
27893
27966
  }
27894
27967
  var hostingCliAvailable = (provider) => whichOnPath(provider === "gitlab" ? "glab" : "gh") !== null;
27895
27968
  var pushRemote = (cwd) => {
27896
- const result = spawnSync17("git", ["remote", "get-url", "--push", "--all", "origin"], {
27969
+ const result = spawnSync18("git", ["remote", "get-url", "--push", "--all", "origin"], {
27897
27970
  cwd,
27898
27971
  ...LOCAL
27899
27972
  });
@@ -27924,7 +27997,7 @@ var defaultCli = (bin, available) => {
27924
27997
  if (!available)
27925
27998
  return null;
27926
27999
  return (args, root) => {
27927
- const out = spawnSync18(bin, args, {
28000
+ const out = spawnSync19(bin, args, {
27928
28001
  cwd: root,
27929
28002
  encoding: "utf8",
27930
28003
  env: { ...process.env, PATH: process.env.PATH ?? "" }
@@ -28013,76 +28086,6 @@ var PLUGIN_ROOT = packageRoot();
28013
28086
  var ASSET_ROOT = assetRoot();
28014
28087
  var resolveWorkspaceRoot = (explicit) => explicit || process.cwd();
28015
28088
 
28016
- // packages/workit-core/src/core/youtrack-ytrack.ts
28017
- import { spawnSync as spawnSync19 } from "node:child_process";
28018
-
28019
- // packages/workit-core/src/forge/exec.ts
28020
- import fs19 from "node:fs";
28021
- import path29 from "node:path";
28022
-
28023
- // packages/workit-core/src/forge/redact.ts
28024
- 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_.-]*`;
28025
- var ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*["']?)((?:bearer|basic|token|digest)\s+)?([^\s"',;&]+)`, "giu");
28026
- var QUOTED_ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*)(["'])([^"'\n]*[^\s"'][^"'\n]*)\2`, "giu");
28027
- var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\u0007`, "gu");
28028
-
28029
- // packages/workit-core/src/forge/exec.ts
28030
- var MAX_BUFFER2 = 64 * 1024 * 1024;
28031
- function findExecutable(bin, env) {
28032
- const dirs = (env.PATH ?? env.Path ?? "").split(path29.delimiter).filter(Boolean);
28033
- const exts = process.platform === "win32" ? [".exe"] : [""];
28034
- for (const dir of dirs)
28035
- for (const ext of exts) {
28036
- const candidate = path29.join(dir, `${bin}${ext}`);
28037
- try {
28038
- const stat = fs19.statSync(candidate);
28039
- if (stat.isFile())
28040
- return candidate;
28041
- } catch {}
28042
- }
28043
- return null;
28044
- }
28045
-
28046
- // packages/workit-core/src/core/youtrack-ytrack.ts
28047
- var TIMEOUT_MS = 60000;
28048
- var YTRACK_EXIT = { ok: 0, failed: 1, cancelled: 2, auth: 4 };
28049
- var findYtrack = (env) => env.WORKIT_NO_YTRACK === "1" ? null : findExecutable("ytrack", env);
28050
- var YTRACK_QUIET_ENV = {
28051
- YTRACK_NO_UPDATE_NOTIFIER: "1",
28052
- YTRACK_NO_AUTO_UPGRADE: "1"
28053
- };
28054
- function ytrackRunner(env, host, timeoutMs = TIMEOUT_MS) {
28055
- return (args, input) => {
28056
- const exe = findYtrack(env);
28057
- if (!exe)
28058
- return { status: null, stdout: "", stderr: "", missing: true };
28059
- const result = spawnSync19(exe, args, {
28060
- encoding: "utf8",
28061
- env: {
28062
- ...env,
28063
- NO_COLOR: "1",
28064
- ...YTRACK_QUIET_ENV,
28065
- ...host ? { YTRACK_HOST: host } : {}
28066
- },
28067
- timeout: timeoutMs,
28068
- killSignal: "SIGKILL",
28069
- windowsHide: true,
28070
- ...input === undefined ? { stdio: ["ignore", "pipe", "pipe"] } : { input, stdio: ["pipe", "pipe", "pipe"] }
28071
- });
28072
- const error = result.error;
28073
- if (error?.code === "ENOENT")
28074
- return { status: null, stdout: "", stderr: "", missing: true };
28075
- return {
28076
- status: result.status,
28077
- stdout: result.stdout ?? "",
28078
- stderr: result.stderr || (error ? error.message : "")
28079
- };
28080
- };
28081
- }
28082
- var ytrackDetail = (out) => out.stderr.trim().split(`
28083
- `).slice(-3).join(" ").slice(0, 300);
28084
- var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only through ytrack";
28085
-
28086
28089
  // packages/workit-core/src/core/youtrack.ts
28087
28090
  var ISSUE_RE = /^[A-Z][A-Z0-9_]*-\d+$/;
28088
28091
  var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path30.join(resolveConfigDir(), "youtrack.json");
@@ -7373,7 +7373,8 @@ var workspaceConfigSchema = object({
7373
7373
  youtrack: object({
7374
7374
  baseUrl: nonBlank.optional().describe("This workspace's YouTrack URL."),
7375
7375
  link_issues: boolean2().optional().describe("Legacy alias of `issues: { provider: youtrack, link: true }`."),
7376
- writes: _enum(["ask", "auto"]).optional().describe("ask (default): each workit youtrack write waits for the user's yes. auto: posts without asking, behind WORKIT_YT_WRITE=1.")
7376
+ writes: _enum(["ask", "auto"]).optional().describe("ask (default): each workit youtrack write waits for the user's yes. auto: posts without asking, behind WORKIT_YT_WRITE=1."),
7377
+ autoHosts: array(nonBlank).optional().describe("With writes auto: the only YouTrack hosts (`acme.youtrack.cloud`) a write may reach without asking. A raw ytrack write must name one with --host; a write elsewhere asks. Only the user widens it, in their own terminal (`workit workspace seal`).")
7377
7378
  }).passthrough().optional().describe("YouTrack settings for this workspace."),
7378
7379
  issues: object({
7379
7380
  provider: _enum(["github", "gitlab", "youtrack"]).optional().describe("The issue tracker PRs link to."),
@@ -16363,7 +16364,7 @@ var sealProjection = (entries) => entries.map((entry) => {
16363
16364
  return pick2({
16364
16365
  ...all,
16365
16366
  vcs: pick2(all.vcs, IDENTITY_KEYS),
16366
- youtrack: pick2(all.youtrack, ["writes"])
16367
+ youtrack: pick2(all.youtrack, ["writes", "autoHosts"])
16367
16368
  }, ENTRY_KEYS);
16368
16369
  });
16369
16370
  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);
@@ -16393,6 +16394,38 @@ function checkSeal(dir) {
16393
16394
  return ok && sealDigest(sealProjection(current.entries)) === seal.sha256 ? { state: "valid" } : broken("workspaces.json changed since it was sealed", sealed.entries);
16394
16395
  }
16395
16396
 
16397
+ // packages/workit-core/src/forge/redact.ts
16398
+ var NAME = "[A-Za-z0-9_.-]";
16399
+ var KEY = String.raw`(?<!${NAME})(?=${NAME}*?(?:token|secret|password|passwd|pwd|api[_-]?key|access[_-]?key|account[_-]?key|private[_-]?key|client[_-]?secret|credentials?|authorization|cookie|signature))${NAME}+`;
16400
+ var ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*["']?)((?:bearer|basic|token|digest)\s+)?([^\s"',;&]+)`, "giu");
16401
+ var QUOTED_ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*)(["'])([^"'\n]*[^\s"'][^"'\n]*)\2`, "giu");
16402
+ var SECRET_FLAG = new RegExp(String.raw`(?<![\w-])(--(?=[\w-]*?(?<![a-z0-9])(?:password|passwd|pwd|secret|token|api[-_]?key|auth|authorization|credentials?|private[-_]?key|access[-_]?key)(?![a-z0-9]))[\w-]+(?:\s+|=))((?:bearer|basic|token|digest)\s+(?![\s-]))?(?:(["'])(?:[^\n]*?\3|[^\n]*)|(?!-)[^\s"']+)`, "giu");
16403
+ var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*\u0007`, "gu");
16404
+
16405
+ // packages/workit-core/src/forge/exec.ts
16406
+ var MAX_BUFFER2 = 64 * 1024 * 1024;
16407
+
16408
+ // packages/workit-core/src/core/youtrack-ytrack.ts
16409
+ var youTrackHostKey = (input) => {
16410
+ const text = input.trim();
16411
+ if (!text || /\s/u.test(text))
16412
+ return null;
16413
+ let url;
16414
+ try {
16415
+ url = new URL(text.includes("://") ? text : `https://${text}`);
16416
+ } catch {
16417
+ return null;
16418
+ }
16419
+ if (!/^https?:$/u.test(url.protocol) || !url.hostname || url.username || url.password)
16420
+ return null;
16421
+ const service = url.pathname.replace(/\/+$/u, "").replace(/\/api$/u, "").replace(/\/+$/u, "");
16422
+ return `${url.host.toLowerCase()}${service}`;
16423
+ };
16424
+ var youTrackHostAllowed = (allowed, host) => {
16425
+ const key = host ? youTrackHostKey(host) : null;
16426
+ return key !== null && allowed.some((entry) => youTrackHostKey(entry) === key);
16427
+ };
16428
+
16396
16429
  // packages/workit-core/src/autonomy.ts
16397
16430
  var accountHomeDir = () => {
16398
16431
  const home = grantsHome.resolve();
@@ -16441,20 +16474,34 @@ var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own
16441
16474
  var NO_SEAL_UNBLOCK = `ask the user to review and seal the grants, in their own terminal: ${SEAL_COMMAND}`;
16442
16475
  var NO_SEAL_NOTE = `workspaces.json has no seal yet (${SEAL_COMMAND} has never run), so grants, endpoint, verification and youtrack.writes stay at or below the D4 defaults; ${NO_SEAL_UNBLOCK}`;
16443
16476
  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;
16444
- var youTrackWritesMode = (cwd) => {
16477
+ var ASK = { mode: "ask" };
16478
+ var youtrackOf = (entry) => entry?.youtrack;
16479
+ var autoHostsOf = (entry) => {
16480
+ const hosts = youtrackOf(entry)?.autoHosts;
16481
+ return Array.isArray(hosts) ? hosts.filter((host) => typeof host === "string") : null;
16482
+ };
16483
+ var youTrackWritesPolicy = (cwd) => {
16445
16484
  try {
16446
16485
  const dir = accountDir();
16447
16486
  if (dir === null || redirected(dir) || evalWorld(cwd))
16448
- return "ask";
16487
+ return ASK;
16449
16488
  if (checkSeal(dir).state !== "valid")
16450
- return "ask";
16451
- const auto = (entry) => entry?.youtrack?.writes === "auto";
16489
+ return ASK;
16490
+ const auto = (entry) => youtrackOf(entry)?.writes === "auto";
16452
16491
  const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
16453
- if (!auto(resolveWorkspaceFrom(cwd, dir, name)))
16454
- return "ask";
16455
- return !name || auto(resolveWorkspaceFrom(cwd, dir)) ? "auto" : "ask";
16492
+ const named = resolveWorkspaceFrom(cwd, dir, name);
16493
+ const folder = name ? resolveWorkspaceFrom(cwd, dir) : named;
16494
+ if (!auto(named) || !auto(folder))
16495
+ return ASK;
16496
+ const [a, b] = [autoHostsOf(named), autoHostsOf(folder)];
16497
+ const base = youtrackOf(named)?.baseUrl;
16498
+ return {
16499
+ mode: "auto",
16500
+ hosts: a === null ? b : b === null ? a : a.filter((host) => youTrackHostAllowed(b, host)),
16501
+ baseUrl: typeof base === "string" && base.trim() ? base.trim() : null
16502
+ };
16456
16503
  } catch {
16457
- return "ask";
16504
+ return ASK;
16458
16505
  }
16459
16506
  };
16460
16507
  var redirected = (dir) => path22.resolve(resolveConfigDir()) !== path22.resolve(dir);
@@ -17526,7 +17573,7 @@ var GIT_VALUE_OPTIONS = new Set([
17526
17573
  ]);
17527
17574
  var GIT_CONFIG_OPTIONS = new Set(["-c", "--config-env", "--git-dir"]);
17528
17575
  var GIT_CONFIG_ENV = /^(?:GIT_(?:CONFIG\w*|DIR|COMMON_DIR|WORK_TREE|SSH|SSH_COMMAND|PROXY_COMMAND|EXEC_PATH)|GH_HOST|GH_REPO|GITLAB_HOST|GL_HOST)$/;
17529
- var ASSIGNMENT = /^([A-Za-z_]\w*)=([\s\S]*)$/;
17576
+ var ASSIGNMENT2 = /^([A-Za-z_]\w*)=([\s\S]*)$/;
17530
17577
  var MAX_DEPTH = 4;
17531
17578
  var MAX_EXPANSIONS = 16;
17532
17579
  var isAbsolute = (value) => path24.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
@@ -17553,7 +17600,7 @@ var stripPrefixes = (input) => {
17553
17600
  const first = words[0];
17554
17601
  if (first === undefined)
17555
17602
  return { words, env };
17556
- const assignment = ASSIGNMENT.exec(first);
17603
+ const assignment = ASSIGNMENT2.exec(first);
17557
17604
  if (assignment) {
17558
17605
  if (GIT_CONFIG_ENV.test(assignment[1]))
17559
17606
  env[assignment[1]] = assignment[2];
@@ -17612,10 +17659,10 @@ var assignments = (words, vars) => {
17612
17659
  while (rest[0]?.startsWith("-"))
17613
17660
  rest = rest.slice(1);
17614
17661
  }
17615
- if (rest.length === 0 || !rest.every((word) => ASSIGNMENT.test(word)))
17662
+ if (rest.length === 0 || !rest.every((word) => ASSIGNMENT2.test(word)))
17616
17663
  return null;
17617
17664
  return rest.map((word) => {
17618
- const [, name, value] = ASSIGNMENT.exec(word);
17665
+ const [, name, value] = ASSIGNMENT2.exec(word);
17619
17666
  return [name, expandWord(value, vars)];
17620
17667
  });
17621
17668
  };
@@ -17803,7 +17850,7 @@ var splitString = (line) => {
17803
17850
  return line.slice(index).join(" ").slice(15);
17804
17851
  if (/^-S./.test(word))
17805
17852
  return [word.slice(2), ...line.slice(index + 1)].join(" ");
17806
- if (!word.startsWith("-") && !ASSIGNMENT.test(word))
17853
+ if (!word.startsWith("-") && !ASSIGNMENT2.test(word))
17807
17854
  return null;
17808
17855
  }
17809
17856
  return null;
@@ -25337,6 +25384,29 @@ var judge = (args, words) => {
25337
25384
  return mapIssueWrite("attach", args);
25338
25385
  return /^(?:edit|update|delete|rm)$/.test(verb) ? UNCOVERED : null;
25339
25386
  };
25387
+ var hostsOf = (args) => {
25388
+ const end = args.indexOf("--");
25389
+ const hosts = [];
25390
+ const bare = [];
25391
+ let literal = true;
25392
+ let named = false;
25393
+ for (let at = 0;at < args.length; at++) {
25394
+ const arg = args[at];
25395
+ if (end >= 0 && at >= end || !/^--host(?:=|$)/.test(arg)) {
25396
+ bare.push(arg);
25397
+ continue;
25398
+ }
25399
+ named ||= standsAlone(args, at);
25400
+ const value = arg === "--host" ? args[++at] : arg.slice("--host=".length);
25401
+ if (value === undefined || !value.trim() || EXPANDS.test(value))
25402
+ literal = false;
25403
+ else
25404
+ hosts.push(value);
25405
+ }
25406
+ if (!literal)
25407
+ return { hosts: null, bare };
25408
+ return named ? { hosts, bare } : { hosts: [], bare: [...args] };
25409
+ };
25340
25410
  var SHELLS3 = /^(?:sh|bash|zsh|dash|ksh|ash|mksh|yash|fish)$/;
25341
25411
  var MAX_DEPTH2 = 4;
25342
25412
  var READ = new Map;
@@ -25344,10 +25414,19 @@ var NOT_PLAIN = gap("a ytrack call that is not a plain command of its own (a wra
25344
25414
  var timeOnly = (effect) => effect?.minutes !== undefined && Object.keys(effect).every((key) => /^(?:issue|minutes|text|date)$/u.test(key));
25345
25415
  var ungrant = (write) => write.workit ? {
25346
25416
  command: write.command,
25417
+ hosts: write.hosts,
25418
+ bare: write.bare,
25419
+ plain: write.plain,
25347
25420
  ...NOT_PLAIN,
25348
25421
  ...timeOnly(write.effect) ? { hint: write.workit } : {}
25349
25422
  } : write;
25350
- var hinted = (write) => write.hint ? { command: write.command, workit: write.hint } : write;
25423
+ var hinted = (write) => write.hint ? {
25424
+ command: write.command,
25425
+ hosts: write.hosts,
25426
+ bare: write.bare,
25427
+ plain: false,
25428
+ workit: write.hint
25429
+ } : write;
25351
25430
  var ytrackArgs = (line, found, depth, names, plain) => {
25352
25431
  const inner = (script) => void found.push(...ytrackWrites(script, "posix", depth + 1, plain));
25353
25432
  const tail = workitCheckTail(line);
@@ -25382,7 +25461,12 @@ var ytrackArgs = (line, found, depth, names, plain) => {
25382
25461
  const argv = [...alias ?? [], ...line.slice(at + 1)];
25383
25462
  const write = classify(argv);
25384
25463
  if (write) {
25385
- const one = { command: ["ytrack", ...argv].map(quote2).join(" "), ...write };
25464
+ const one = {
25465
+ command: ["ytrack", ...argv].map(quote2).join(" "),
25466
+ ...write,
25467
+ ...hostsOf(argv),
25468
+ plain
25469
+ };
25386
25470
  found.push(plain ? one : ungrant(one));
25387
25471
  }
25388
25472
  return true;
@@ -25459,7 +25543,15 @@ var chained = (first, chain, depth) => {
25459
25543
  const effect = combine(effects);
25460
25544
  if (!effect)
25461
25545
  return null;
25462
- return [{ command: found.map((write) => write.command).join(" && "), ...mapped(effect) }];
25546
+ const hosts = found.map((write) => write.hosts);
25547
+ return [
25548
+ {
25549
+ command: found.map((write) => write.command).join(" && "),
25550
+ ...mapped(effect),
25551
+ hosts: hosts.includes(null) ? null : hosts.some((list) => !list?.length) ? [] : hosts.flatMap((list) => list ?? []),
25552
+ plain: true
25553
+ }
25554
+ ];
25463
25555
  };
25464
25556
  var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
25465
25557
  if (!namesYtrack(command))
@@ -25488,6 +25580,32 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
25488
25580
  READ.delete(READ.keys().next().value);
25489
25581
  return found;
25490
25582
  };
25583
+ var RELOCATES = /(?<![$\w])YTRACK_CONFIG_DIR\b/;
25584
+ var reachesOnly = (allowed, write) => write.plain && !!write.hosts?.length && write.hosts.every((host) => youTrackHostAllowed(allowed, host));
25585
+ var scopedGate = (allowed, command, writes) => {
25586
+ const scope = `youtrack.autoHosts (${allowed.join(", ")})`;
25587
+ if (RELOCATES.test(command))
25588
+ return {
25589
+ kind: "deny",
25590
+ reason: `This command sets YTRACK_CONFIG_DIR, where ytrack reads its hosts, so a --host may reach another instance: ${scope} lets a YouTrack write through only with ytrack's own config. Run the ytrack call without it.`,
25591
+ unblock: null
25592
+ };
25593
+ const first = allowed.map(youTrackHostKey).find(Boolean);
25594
+ if (!first)
25595
+ return null;
25596
+ const unnamed = writes.filter((write) => !reachesOnly(allowed, write) && (!write.hosts?.length || write.hosts.every((host) => youTrackHostAllowed(allowed, host))));
25597
+ if (!unnamed.length)
25598
+ return null;
25599
+ const why = (write) => write.hosts === null ? "its --host is no literal host" : !write.hosts.length ? "it names no --host" : "it is not a plain command of its own";
25600
+ const bare = unnamed.find((write) => write.bare)?.bare;
25601
+ const retry = bare ? ["ytrack", "--host", first, ...bare].map(quote2).join(" ") : null;
25602
+ return {
25603
+ kind: "deny",
25604
+ reason: `${scope} posts to YouTrack unasked only from a plain ytrack call that names an allowed host with --host: ${unnamed.map((write) => `\`${write.command}\` (${why(write)})`).join(", ")}. Name the host, as its own plain call.${retry ? `
25605
+ Retry as: ${retry}` : ""}`,
25606
+ unblock: retry
25607
+ };
25608
+ };
25491
25609
  var ytrackGate = (cwd, command, dialect, ask) => {
25492
25610
  if (namesTicket(command))
25493
25611
  return { kind: "deny", reason: TICKET_DENY, unblock: null };
@@ -25500,7 +25618,8 @@ var ytrackGate = (cwd, command, dialect, ask) => {
25500
25618
  }
25501
25619
  writes = [...merged.values()];
25502
25620
  } catch {
25503
- if (youTrackWritesMode(cwd) === "auto")
25621
+ const policy = youTrackWritesPolicy(cwd);
25622
+ if (policy.mode === "auto" && policy.hosts === null)
25504
25623
  return null;
25505
25624
  return {
25506
25625
  kind: "deny",
@@ -25508,7 +25627,19 @@ var ytrackGate = (cwd, command, dialect, ask) => {
25508
25627
  unblock: null
25509
25628
  };
25510
25629
  }
25511
- if (!writes.length || youTrackWritesMode(cwd) === "auto")
25630
+ if (!writes.length && !RELOCATES.test(command))
25631
+ return null;
25632
+ const policy = youTrackWritesPolicy(cwd);
25633
+ if (policy.mode === "auto") {
25634
+ const hosts = policy.hosts;
25635
+ if (hosts === null)
25636
+ return null;
25637
+ const scoped = scopedGate(hosts, command, writes);
25638
+ if (scoped)
25639
+ return scoped;
25640
+ writes = writes.filter((write) => !reachesOnly(hosts, write));
25641
+ }
25642
+ if (!writes.length)
25512
25643
  return null;
25513
25644
  const calls = writes.flatMap((write) => write.workit ? [`\`${write.workit}\``] : []);
25514
25645
  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"})`);
@@ -101,7 +101,7 @@ if (quiet) {
101
101
  `);
102
102
  } else {
103
103
  try {
104
- const { runCodexHook } = await import("./workit-hook-0fd33f54.js");
104
+ const { runCodexHook } = await import("./workit-hook-nfrvjnhd.js");
105
105
  await runCodexHook([payload]);
106
106
  } catch (error) {
107
107
  const { answerRuntimeFailure } = await import("./workit-hook-52cm7mqd.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/codex",
3
- "version": "2.20.6",
3
+ "version": "2.21.1",
4
4
  "private": false,
5
5
  "description": "Workit Codex CLI/desktop plugin — shared MCP transport, hooks, method skills, and verifier/reviewer/implementer agents",
6
6
  "keywords": [
@@ -41,8 +41,8 @@
41
41
  "build": "bun scripts/build.ts"
42
42
  },
43
43
  "devDependencies": {
44
- "@workit-dev/core": "^2.20.6",
45
- "@workit-dev/mcp": "^2.20.6"
44
+ "@workit-dev/core": "^2.21.1",
45
+ "@workit-dev/mcp": "^2.21.1"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=24"