@workit-dev/pi 2.20.6 → 2.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/worker.js +11 -10
  2. package/dist/workit.js +298 -174
  3. package/package.json +1 -1
package/dist/worker.js CHANGED
@@ -7421,7 +7421,8 @@ var workspaceConfigSchema = object({
7421
7421
  youtrack: object({
7422
7422
  baseUrl: nonBlank.optional().describe("This workspace's YouTrack URL."),
7423
7423
  link_issues: boolean2().optional().describe("Legacy alias of `issues: { provider: youtrack, link: true }`."),
7424
- 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.")
7424
+ 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."),
7425
+ 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`).")
7425
7426
  }).passthrough().optional().describe("YouTrack settings for this workspace."),
7426
7427
  issues: object({
7427
7428
  provider: _enum(["github", "gitlab", "youtrack"]).optional().describe("The issue tracker PRs link to."),
@@ -8929,6 +8930,15 @@ Skills: load the skill, never act from memory.
8929
8930
  // packages/workit-core/src/core/grant-seal.ts
8930
8931
  var SEAL_COMMAND = "workit workspace seal";
8931
8932
 
8933
+ // packages/workit-core/src/forge/redact.ts
8934
+ 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_.-]*`;
8935
+ var ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*["']?)((?:bearer|basic|token|digest)\s+)?([^\s"',;&]+)`, "giu");
8936
+ var QUOTED_ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*)(["'])([^"'\n]*[^\s"'][^"'\n]*)\2`, "giu");
8937
+ var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\u0007`, "gu");
8938
+
8939
+ // packages/workit-core/src/forge/exec.ts
8940
+ var MAX_BUFFER2 = 64 * 1024 * 1024;
8941
+
8932
8942
  // packages/workit-core/src/autonomy.ts
8933
8943
  var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own terminal: ${SEAL_COMMAND}`;
8934
8944
  var NO_SEAL_UNBLOCK = `ask the user to review and seal the grants, in their own terminal: ${SEAL_COMMAND}`;
@@ -9123,15 +9133,6 @@ var repoRoot = assetRoot();
9123
9133
  var PLUGIN_ROOT = packageRoot();
9124
9134
  var ASSET_ROOT = assetRoot();
9125
9135
 
9126
- // packages/workit-core/src/forge/redact.ts
9127
- 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_.-]*`;
9128
- var ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*["']?)((?:bearer|basic|token|digest)\s+)?([^\s"',;&]+)`, "giu");
9129
- var QUOTED_ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*)(["'])([^"'\n]*[^\s"'][^"'\n]*)\2`, "giu");
9130
- var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\u0007`, "gu");
9131
-
9132
- // packages/workit-core/src/forge/exec.ts
9133
- var MAX_BUFFER2 = 64 * 1024 * 1024;
9134
-
9135
9136
  // packages/workit-core/src/core/context-read.ts
9136
9137
  var contextReadSchema = object({
9137
9138
  kind: _enum([
package/dist/workit.js CHANGED
@@ -9185,7 +9185,8 @@ var workspaceConfigSchema = object({
9185
9185
  youtrack: object({
9186
9186
  baseUrl: nonBlank.optional().describe("This workspace's YouTrack URL."),
9187
9187
  link_issues: boolean2().optional().describe("Legacy alias of `issues: { provider: youtrack, link: true }`."),
9188
- 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.")
9188
+ 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."),
9189
+ 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`).")
9189
9190
  }).passthrough().optional().describe("YouTrack settings for this workspace."),
9190
9191
  issues: object({
9191
9192
  provider: _enum(["github", "gitlab", "youtrack"]).optional().describe("The issue tracker PRs link to."),
@@ -19150,20 +19151,20 @@ var exportDigest = (bundle) => sha256({
19150
19151
  task: bundle.task
19151
19152
  });
19152
19153
  // packages/workit-core/src/core/route-intent.ts
19153
- import { spawnSync as spawnSync17 } from "node:child_process";
19154
+ import { spawnSync as spawnSync18 } from "node:child_process";
19154
19155
  import { existsSync as existsSync12 } from "node:fs";
19155
- import path30 from "node:path";
19156
+ import path31 from "node:path";
19156
19157
 
19157
19158
  // packages/workit-core/src/hooks/raw-git.ts
19158
- import { spawnSync as spawnSync16 } from "node:child_process";
19159
+ import { spawnSync as spawnSync17 } from "node:child_process";
19159
19160
  import { createHash as createHash16 } from "node:crypto";
19160
- import fs19 from "node:fs";
19161
+ import fs20 from "node:fs";
19161
19162
  import os6 from "node:os";
19162
- import path29 from "node:path";
19163
+ import path30 from "node:path";
19163
19164
 
19164
19165
  // packages/workit-core/src/autonomy.ts
19165
19166
  import { closeSync as closeSync3, copyFileSync as copyFileSync2, existsSync as existsSync11, openSync as openSync3 } from "node:fs";
19166
- import path27 from "node:path";
19167
+ import path28 from "node:path";
19167
19168
 
19168
19169
  // packages/workit-core/src/core/eval-world.ts
19169
19170
  import { existsSync as existsSync10, realpathSync as realpathSync6 } from "node:fs";
@@ -19297,7 +19298,7 @@ var sealProjection = (entries) => entries.map((entry) => {
19297
19298
  return pick2({
19298
19299
  ...all,
19299
19300
  vcs: pick2(all.vcs, IDENTITY_KEYS),
19300
- youtrack: pick2(all.youtrack, ["writes"])
19301
+ youtrack: pick2(all.youtrack, ["writes", "autoHosts"])
19301
19302
  }, ENTRY_KEYS);
19302
19303
  });
19303
19304
  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);
@@ -19327,6 +19328,95 @@ function checkSeal(dir) {
19327
19328
  return ok && sealDigest(sealProjection(current.entries)) === seal.sha256 ? { state: "valid" } : broken("workspaces.json changed since it was sealed", sealed.entries);
19328
19329
  }
19329
19330
 
19331
+ // packages/workit-core/src/core/youtrack-ytrack.ts
19332
+ import { spawnSync as spawnSync16 } from "node:child_process";
19333
+
19334
+ // packages/workit-core/src/forge/exec.ts
19335
+ import fs18 from "node:fs";
19336
+ import path27 from "node:path";
19337
+
19338
+ // packages/workit-core/src/forge/redact.ts
19339
+ 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_.-]*`;
19340
+ var ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*["']?)((?:bearer|basic|token|digest)\s+)?([^\s"',;&]+)`, "giu");
19341
+ var QUOTED_ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*)(["'])([^"'\n]*[^\s"'][^"'\n]*)\2`, "giu");
19342
+ var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\u0007`, "gu");
19343
+
19344
+ // packages/workit-core/src/forge/exec.ts
19345
+ var MAX_BUFFER2 = 64 * 1024 * 1024;
19346
+ function findExecutable(bin, env) {
19347
+ const dirs = (env.PATH ?? env.Path ?? "").split(path27.delimiter).filter(Boolean);
19348
+ const exts = process.platform === "win32" ? [".exe"] : [""];
19349
+ for (const dir of dirs)
19350
+ for (const ext of exts) {
19351
+ const candidate = path27.join(dir, `${bin}${ext}`);
19352
+ try {
19353
+ const stat = fs18.statSync(candidate);
19354
+ if (stat.isFile())
19355
+ return candidate;
19356
+ } catch {}
19357
+ }
19358
+ return null;
19359
+ }
19360
+
19361
+ // packages/workit-core/src/core/youtrack-ytrack.ts
19362
+ var TIMEOUT_MS = 60000;
19363
+ var YTRACK_EXIT = { ok: 0, failed: 1, cancelled: 2, auth: 4 };
19364
+ var findYtrack = (env) => env.WORKIT_NO_YTRACK === "1" ? null : findExecutable("ytrack", env);
19365
+ var YTRACK_QUIET_ENV = {
19366
+ YTRACK_NO_UPDATE_NOTIFIER: "1",
19367
+ YTRACK_NO_AUTO_UPGRADE: "1"
19368
+ };
19369
+ function ytrackRunner(env, host, timeoutMs = TIMEOUT_MS) {
19370
+ return (args, input) => {
19371
+ const exe = findYtrack(env);
19372
+ if (!exe)
19373
+ return { status: null, stdout: "", stderr: "", missing: true };
19374
+ const result = spawnSync16(exe, args, {
19375
+ encoding: "utf8",
19376
+ env: {
19377
+ ...env,
19378
+ NO_COLOR: "1",
19379
+ ...YTRACK_QUIET_ENV,
19380
+ ...host ? { YTRACK_HOST: host } : {}
19381
+ },
19382
+ timeout: timeoutMs,
19383
+ killSignal: "SIGKILL",
19384
+ windowsHide: true,
19385
+ ...input === undefined ? { stdio: ["ignore", "pipe", "pipe"] } : { input, stdio: ["pipe", "pipe", "pipe"] }
19386
+ });
19387
+ const error = result.error;
19388
+ if (error?.code === "ENOENT")
19389
+ return { status: null, stdout: "", stderr: "", missing: true };
19390
+ return {
19391
+ status: result.status,
19392
+ stdout: result.stdout ?? "",
19393
+ stderr: result.stderr || (error ? error.message : "")
19394
+ };
19395
+ };
19396
+ }
19397
+ var ytrackDetail = (out) => out.stderr.trim().split(`
19398
+ `).slice(-3).join(" ").slice(0, 300);
19399
+ var youTrackHostKey = (input) => {
19400
+ const text = input.trim();
19401
+ if (!text || /\s/u.test(text))
19402
+ return null;
19403
+ let url;
19404
+ try {
19405
+ url = new URL(text.includes("://") ? text : `https://${text}`);
19406
+ } catch {
19407
+ return null;
19408
+ }
19409
+ if (!/^https?:$/u.test(url.protocol) || !url.hostname || url.username || url.password)
19410
+ return null;
19411
+ const service = url.pathname.replace(/\/+$/u, "").replace(/\/api$/u, "").replace(/\/+$/u, "");
19412
+ return `${url.host.toLowerCase()}${service}`;
19413
+ };
19414
+ var youTrackHostAllowed = (allowed, host) => {
19415
+ const key = host ? youTrackHostKey(host) : null;
19416
+ return key !== null && allowed.some((entry) => youTrackHostKey(entry) === key);
19417
+ };
19418
+ var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only through ytrack";
19419
+
19330
19420
  // packages/workit-core/src/autonomy.ts
19331
19421
  var accountHomeDir = () => {
19332
19422
  const home = grantsHome.resolve();
@@ -19334,7 +19424,7 @@ var accountHomeDir = () => {
19334
19424
  };
19335
19425
  var deniedFile = (dir) => {
19336
19426
  for (const name of ["workspaces.json", SEAL_FILE]) {
19337
- const file = path27.join(dir, name);
19427
+ const file = path28.join(dir, name);
19338
19428
  try {
19339
19429
  closeSync3(openSync3(file, "r"));
19340
19430
  } catch (error) {
@@ -19356,7 +19446,7 @@ var accountUnread = () => {
19356
19446
  if (dir === null)
19357
19447
  return NO_ACCOUNT;
19358
19448
  const file = deniedFile(dir);
19359
- 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`;
19449
+ return file === null ? null : `the account's ${path28.basename(file)} cannot be read (permission denied), so it reads as no workspace entries: no grants, no models, the D4 defaults apply`;
19360
19450
  };
19361
19451
  var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
19362
19452
  var fileSource = (dir = accountDir()) => ({
@@ -19375,26 +19465,46 @@ var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own
19375
19465
  var NO_SEAL_UNBLOCK = `ask the user to review and seal the grants, in their own terminal: ${SEAL_COMMAND}`;
19376
19466
  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}`;
19377
19467
  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;
19378
- var youTrackWritesMode = (cwd) => {
19468
+ var ASK = { mode: "ask" };
19469
+ var youtrackOf = (entry) => entry?.youtrack;
19470
+ var autoHostsOf = (entry) => {
19471
+ const hosts = youtrackOf(entry)?.autoHosts;
19472
+ return Array.isArray(hosts) ? hosts.filter((host) => typeof host === "string") : null;
19473
+ };
19474
+ var youTrackWritesPolicy = (cwd) => {
19379
19475
  try {
19380
19476
  const dir = accountDir();
19381
19477
  if (dir === null || redirected(dir) || evalWorld(cwd))
19382
- return "ask";
19478
+ return ASK;
19383
19479
  if (checkSeal(dir).state !== "valid")
19384
- return "ask";
19385
- const auto = (entry) => entry?.youtrack?.writes === "auto";
19480
+ return ASK;
19481
+ const auto = (entry) => youtrackOf(entry)?.writes === "auto";
19386
19482
  const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
19387
- if (!auto(resolveWorkspaceFrom(cwd, dir, name)))
19388
- return "ask";
19389
- return !name || auto(resolveWorkspaceFrom(cwd, dir)) ? "auto" : "ask";
19483
+ const named = resolveWorkspaceFrom(cwd, dir, name);
19484
+ const folder = name ? resolveWorkspaceFrom(cwd, dir) : named;
19485
+ if (!auto(named) || !auto(folder))
19486
+ return ASK;
19487
+ const [a, b] = [autoHostsOf(named), autoHostsOf(folder)];
19488
+ const base = youtrackOf(named)?.baseUrl;
19489
+ return {
19490
+ mode: "auto",
19491
+ hosts: a === null ? b : b === null ? a : a.filter((host) => youTrackHostAllowed(b, host)),
19492
+ baseUrl: typeof base === "string" && base.trim() ? base.trim() : null
19493
+ };
19390
19494
  } catch {
19391
- return "ask";
19495
+ return ASK;
19392
19496
  }
19393
19497
  };
19394
- var redirected = (dir) => path27.resolve(resolveConfigDir()) !== path27.resolve(dir);
19498
+ var youTrackWritesMode = (cwd, host) => {
19499
+ const policy = youTrackWritesPolicy(cwd);
19500
+ if (policy.mode === "ask" || policy.hosts === null)
19501
+ return policy.mode;
19502
+ return youTrackHostAllowed(policy.hosts, host === undefined ? policy.baseUrl : host) ? "auto" : "ask";
19503
+ };
19504
+ var redirected = (dir) => path28.resolve(resolveConfigDir()) !== path28.resolve(dir);
19395
19505
  var shownGrantsDir = () => {
19396
19506
  const world = evalWorld(process.cwd());
19397
- return world ? path27.join(world, "config") : accountDir();
19507
+ return world ? path28.join(world, "config") : accountDir();
19398
19508
  };
19399
19509
  var benchWorld = (cwd) => {
19400
19510
  const entry = evalWorldEntry(cwd);
@@ -19418,10 +19528,10 @@ var grantsOverride = () => {
19418
19528
  const shown = shownGrantsDir();
19419
19529
  if (shown === null)
19420
19530
  return accountUnread() ?? NO_ACCOUNT;
19421
- const configured = path27.resolve(resolveConfigDir());
19422
- 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`;
19531
+ const configured = path28.resolve(resolveConfigDir());
19532
+ return configured === path28.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 ${path28.join(grantsDir(), "workspaces.json")}, and under a redirect they never exceed the D4 defaults`;
19423
19533
  };
19424
- 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")}`;
19534
+ 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 ${path28.join(grantsDir(), "workspaces.json")}`;
19425
19535
  var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
19426
19536
  var DEFAULT_GRANTS = Object.freeze({
19427
19537
  push: true,
@@ -19829,8 +19939,8 @@ var packageTagShapes = (packages) => packages.map((entry) => `${entry.tagNamespa
19829
19939
 
19830
19940
  // packages/workit-core/src/hooks/session-marker.ts
19831
19941
  import { createHash as createHash15 } from "node:crypto";
19832
- import fs18 from "node:fs";
19833
- import path28 from "node:path";
19942
+ import fs19 from "node:fs";
19943
+ import path29 from "node:path";
19834
19944
  var sessionMarkerFile = (input, session, store) => {
19835
19945
  let dir = store;
19836
19946
  if (dir === undefined) {
@@ -19840,7 +19950,7 @@ var sessionMarkerFile = (input, session, store) => {
19840
19950
  dir = location.dir;
19841
19951
  }
19842
19952
  const name = createHash15("sha256").update(`${input.host}\x00${session}`).digest("hex").slice(0, 32);
19843
- return path28.join(dir, "hooks", `skills-${name}.json`);
19953
+ return path29.join(dir, "hooks", `skills-${name}.json`);
19844
19954
  };
19845
19955
  var list2 = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
19846
19956
  var EMPTY = {
@@ -19853,7 +19963,7 @@ var EMPTY = {
19853
19963
  };
19854
19964
  var readRaw = (file) => {
19855
19965
  try {
19856
- return fs18.readFileSync(file, "utf8");
19966
+ return fs19.readFileSync(file, "utf8");
19857
19967
  } catch {
19858
19968
  return "";
19859
19969
  }
@@ -19875,13 +19985,13 @@ var parseMarker = (text) => {
19875
19985
  };
19876
19986
  var readSessionMarker = (file) => parseMarker(readRaw(file));
19877
19987
  var writeAtomic = (file, marker) => {
19878
- fs18.mkdirSync(path28.dirname(file), { recursive: true });
19988
+ fs19.mkdirSync(path29.dirname(file), { recursive: true });
19879
19989
  const temp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
19880
19990
  try {
19881
- fs18.writeFileSync(temp, JSON.stringify(marker));
19882
- fs18.renameSync(temp, file);
19991
+ fs19.writeFileSync(temp, JSON.stringify(marker));
19992
+ fs19.renameSync(temp, file);
19883
19993
  } catch (error) {
19884
- fs18.rmSync(temp, { force: true });
19994
+ fs19.rmSync(temp, { force: true });
19885
19995
  throw error;
19886
19996
  }
19887
19997
  };
@@ -20460,17 +20570,17 @@ var GIT_VALUE_OPTIONS = new Set([
20460
20570
  ]);
20461
20571
  var GIT_CONFIG_OPTIONS = new Set(["-c", "--config-env", "--git-dir"]);
20462
20572
  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)$/;
20463
- var ASSIGNMENT = /^([A-Za-z_]\w*)=([\s\S]*)$/;
20573
+ var ASSIGNMENT2 = /^([A-Za-z_]\w*)=([\s\S]*)$/;
20464
20574
  var MAX_DEPTH = 4;
20465
20575
  var MAX_EXPANSIONS = 16;
20466
- var isAbsolute = (value) => path29.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
20576
+ var isAbsolute = (value) => path30.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
20467
20577
  var HERE = /^(?:\$PWD|\$\{PWD\}|\$\(\s*pwd\s*\)|`pwd`|\$\(\s*git\s+rev-parse\s+--show-toplevel\s*\))(?=$|[\\/])/;
20468
20578
  var joinDir = (base, raw) => {
20469
20579
  const next = raw.replace(HERE, ".");
20470
20580
  if (base === undefined || /[$`*?]/.test(next) || next === "-")
20471
20581
  return;
20472
- const expanded = next === "~" || next.startsWith("~/") ? path29.join(os6.homedir(), next.slice(1)) : next;
20473
- return base === null || isAbsolute(expanded) ? expanded : path29.join(base, expanded);
20582
+ const expanded = next === "~" || next.startsWith("~/") ? path30.join(os6.homedir(), next.slice(1)) : next;
20583
+ return base === null || isAbsolute(expanded) ? expanded : path30.join(base, expanded);
20474
20584
  };
20475
20585
  var rebase = (base, inner) => inner === null ? base : inner === undefined ? undefined : joinDir(base, inner);
20476
20586
  var cdTarget = (words) => {
@@ -20487,7 +20597,7 @@ var stripPrefixes = (input) => {
20487
20597
  const first = words[0];
20488
20598
  if (first === undefined)
20489
20599
  return { words, env };
20490
- const assignment = ASSIGNMENT.exec(first);
20600
+ const assignment = ASSIGNMENT2.exec(first);
20491
20601
  if (assignment) {
20492
20602
  if (GIT_CONFIG_ENV.test(assignment[1]))
20493
20603
  env[assignment[1]] = assignment[2];
@@ -20546,10 +20656,10 @@ var assignments = (words, vars) => {
20546
20656
  while (rest[0]?.startsWith("-"))
20547
20657
  rest = rest.slice(1);
20548
20658
  }
20549
- if (rest.length === 0 || !rest.every((word) => ASSIGNMENT.test(word)))
20659
+ if (rest.length === 0 || !rest.every((word) => ASSIGNMENT2.test(word)))
20550
20660
  return null;
20551
20661
  return rest.map((word) => {
20552
- const [, name, value] = ASSIGNMENT.exec(word);
20662
+ const [, name, value] = ASSIGNMENT2.exec(word);
20553
20663
  return [name, expandWord(value, vars)];
20554
20664
  });
20555
20665
  };
@@ -20737,7 +20847,7 @@ var splitString = (line) => {
20737
20847
  return line.slice(index).join(" ").slice(15);
20738
20848
  if (/^-S./.test(word))
20739
20849
  return [word.slice(2), ...line.slice(index + 1)].join(" ");
20740
- if (!word.startsWith("-") && !ASSIGNMENT.test(word))
20850
+ if (!word.startsWith("-") && !ASSIGNMENT2.test(word))
20741
20851
  return null;
20742
20852
  }
20743
20853
  return null;
@@ -21371,7 +21481,7 @@ var repoAt = (dir) => {
21371
21481
  return { location, dir, branch: resolveTaskKey(dir, location).branch };
21372
21482
  };
21373
21483
  var isWorkitWorkspace = (repo) => {
21374
- if (fs19.existsSync(repo.location.dir))
21484
+ if (fs20.existsSync(repo.location.dir))
21375
21485
  return true;
21376
21486
  try {
21377
21487
  return resolveRuntimeWorkspaceVcs(repo.location.top ?? repo.dir) !== null;
@@ -21392,17 +21502,17 @@ var headSha2 = (repo) => {
21392
21502
  if (!git || git.reftable)
21393
21503
  return null;
21394
21504
  try {
21395
- const head = fs19.readFileSync(path29.join(git.gitDir, "HEAD"), "utf8").trim();
21505
+ const head = fs20.readFileSync(path30.join(git.gitDir, "HEAD"), "utf8").trim();
21396
21506
  if (/^[0-9a-f]{40,64}$/.test(head))
21397
21507
  return head;
21398
21508
  const ref = /^ref: (refs\/.+)$/.exec(head)?.[1];
21399
21509
  if (!ref)
21400
21510
  return null;
21401
- const common = path29.dirname(repo.location.dir);
21511
+ const common = path30.dirname(repo.location.dir);
21402
21512
  try {
21403
- return fs19.readFileSync(path29.join(common, ref), "utf8").trim() || null;
21513
+ return fs20.readFileSync(path30.join(common, ref), "utf8").trim() || null;
21404
21514
  } catch {}
21405
- const packed = fs19.readFileSync(path29.join(common, "packed-refs"), "utf8");
21515
+ const packed = fs20.readFileSync(path30.join(common, "packed-refs"), "utf8");
21406
21516
  return new RegExp(`^([0-9a-f]{40,64}) ${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`, "m").exec(packed)?.[1] ?? null;
21407
21517
  } catch {
21408
21518
  return null;
@@ -21414,7 +21524,7 @@ var gitConfig = (dir, invocation, cache) => {
21414
21524
  if (cached)
21415
21525
  return cached;
21416
21526
  const config = new Map;
21417
- const listed = spawnSync16("git", [...invocation.config ?? [], "config", "-z", "--list"], {
21527
+ const listed = spawnSync17("git", [...invocation.config ?? [], "config", "-z", "--list"], {
21418
21528
  cwd: dir,
21419
21529
  encoding: "utf8",
21420
21530
  timeout: 3000,
@@ -21495,8 +21605,8 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
21495
21605
  const sub = invocation.args[0];
21496
21606
  if (invocation.tool !== "git" || invocation.dir === undefined || !sub || sub.startsWith("-") || GIT_COMMANDS.has(sub) || depth >= MAX_DEPTH)
21497
21607
  return [invocation];
21498
- const dir = path29.resolve(root, invocation.dir ?? ".");
21499
- if (!fs19.existsSync(dir))
21608
+ const dir = path30.resolve(root, invocation.dir ?? ".");
21609
+ if (!fs20.existsSync(dir))
21500
21610
  return [invocation];
21501
21611
  const config = gitConfig(dir, invocation, cache);
21502
21612
  const alias = configValue(config, `alias.${sub.toLowerCase()}`);
@@ -21518,11 +21628,11 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
21518
21628
  var normalizedUrl = (url, dir) => {
21519
21629
  const trimmed = url.trim();
21520
21630
  if (/^file:\/\//i.test(trimmed))
21521
- return path29.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
21631
+ return path30.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
21522
21632
  const scheme = /^[a-z][a-z0-9+.-]*:\/\//i.exec(trimmed);
21523
21633
  const scp = !scheme && /^(?:[^@/\\]+@)?[^/\\:]{2,}:/.test(trimmed);
21524
21634
  if (!scheme && !scp)
21525
- return path29.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
21635
+ return path30.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
21526
21636
  const value = scheme ? trimmed.slice(scheme[0].length).replace(/^[^@/]*@/, "").replace(/^([^/:]+):\d+(?=\/)/, "$1") : trimmed.replace(/^[^@/]*@/, "").replace(":", "/");
21527
21637
  return value.toLowerCase().replace(/\/{2,}/g, "/").replace(/^www\./, "").replace(/\/+$/, "").replace(/\.git$/, "");
21528
21638
  };
@@ -21587,7 +21697,7 @@ var refFacts = (repo, remote) => {
21587
21697
  tags: new Set,
21588
21698
  remoteHeads: new Set
21589
21699
  };
21590
- const listed = spawnSync16("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/tags", `refs/remotes/${remote}`], { cwd: repo.dir, encoding: "utf8", timeout: 5000 });
21700
+ const listed = spawnSync17("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/tags", `refs/remotes/${remote}`], { cwd: repo.dir, encoding: "utf8", timeout: 5000 });
21591
21701
  const remotePrefix = `refs/remotes/${remote}/`;
21592
21702
  for (const ref of (listed.stdout ?? "").split(`
21593
21703
  `)) {
@@ -21604,7 +21714,7 @@ var globBranches = (repo, glob) => {
21604
21714
  const source = glob.source.startsWith("refs/") ? glob.source : `refs/heads/${glob.source}`;
21605
21715
  const [sourcePrefix, sourceSuffix = ""] = source.split("*");
21606
21716
  const [destinationPrefix, destinationSuffix = ""] = glob.destination.split("*");
21607
- const listed = spawnSync16("git", [
21717
+ const listed = spawnSync17("git", [
21608
21718
  "for-each-ref",
21609
21719
  "--format=%(refname)",
21610
21720
  sourcePrefix.slice(0, sourcePrefix.lastIndexOf("/") + 1)
@@ -21686,7 +21796,7 @@ var tagRefusal = (action, facts, dir) => {
21686
21796
  return `workit: raw ${quote(`git push${action.allTags ? " --tags" : ""}`)} of ${tags.length ? `tag ${tags.join(", ")}` : "tags"} bypasses the release grant. Push a release tag with ${quote(`workit git push --release ${named}`)} (${shapes.join(", ")} tags whose commit the production branch already has; a tag never moves), under the ${quote("release")} grant (if refused, ask the user to run ${quote("workit grant set <workspace> release=true")}).${create}`;
21687
21797
  };
21688
21798
  var remoteHeads = (repo, remote) => {
21689
- const listed = spawnSync16("git", ["ls-remote", "--heads", remote], {
21799
+ const listed = spawnSync17("git", ["ls-remote", "--heads", remote], {
21690
21800
  cwd: repo.dir,
21691
21801
  encoding: "utf8",
21692
21802
  timeout: 3000,
@@ -21755,7 +21865,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
21755
21865
  const out = [];
21756
21866
  const repos = new Map;
21757
21867
  const repoFor = (relative) => {
21758
- const dir = path29.resolve(cwd, relative ?? ".");
21868
+ const dir = path30.resolve(cwd, relative ?? ".");
21759
21869
  if (!repos.has(dir)) {
21760
21870
  const repo = repoAt(dir);
21761
21871
  const workit = repo !== null && isWorkitWorkspace(repo);
@@ -21776,7 +21886,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
21776
21886
  const action = rawAction(invocation);
21777
21887
  const at = !action ? null : repoFor(invocation.dir) ?? (all && invocation.tool !== "git" && explicitRepo(invocation.tool === "gh", "repo" in action && action.repo || "", invocation.env ?? {}) ? {
21778
21888
  repo: {
21779
- dir: path29.resolve(cwd, invocation.dir ?? "."),
21889
+ dir: path30.resolve(cwd, invocation.dir ?? "."),
21780
21890
  branch: null
21781
21891
  },
21782
21892
  workit: false
@@ -21849,13 +21959,13 @@ var messageOf = (segment, index) => {
21849
21959
  };
21850
21960
  var sameGitDir = (a, b, platform = process.platform) => {
21851
21961
  if (platform !== "win32")
21852
- return path29.posix.resolve(a) === path29.posix.resolve(b);
21853
- const fold = (value) => path29.win32.resolve(value).toLowerCase();
21962
+ return path30.posix.resolve(a) === path30.posix.resolve(b);
21963
+ const fold = (value) => path30.win32.resolve(value).toLowerCase();
21854
21964
  return fold(a) === fold(b);
21855
21965
  };
21856
21966
  var cdCommitCall = (input, command, target, repo) => {
21857
21967
  const { top, git, dir: store } = repo.location;
21858
- if (!top || !git || sameGitDir(git.gitDir, path29.dirname(store)) || repoAt(input.cwd)?.location.top === top)
21968
+ if (!top || !git || sameGitDir(git.gitDir, path30.dirname(store)) || repoAt(input.cwd)?.location.top === top)
21859
21969
  return null;
21860
21970
  const bare = command.replaceAll(/'[^']*'|"(?:[^"\\]|\\.)*"/gu, "").replaceAll("&&", "");
21861
21971
  if (/[;|&<>`$()\n\\]/u.test(bare))
@@ -21864,7 +21974,7 @@ var cdCommitCall = (input, command, target, repo) => {
21864
21974
  const commit = rest.at(-1);
21865
21975
  if (cd?.words[0] !== "cd" || cd.words.length !== 2 || cd.expands?.length || !commit)
21866
21976
  return null;
21867
- if (path29.resolve(input.cwd, cd.words[1]) !== target)
21977
+ if (path30.resolve(input.cwd, cd.words[1]) !== target)
21868
21978
  return null;
21869
21979
  if (rest.some((each) => each.redirects.length || each.stdin?.length || each.group))
21870
21980
  return null;
@@ -21907,7 +22017,7 @@ var cdCommitCall = (input, command, target, repo) => {
21907
22017
  if (!messages.length)
21908
22018
  return null;
21909
22019
  if (!all) {
21910
- const staged = spawnSync16("git", ["diff", "--cached", "--quiet"], {
22020
+ const staged = spawnSync17("git", ["diff", "--cached", "--quiet"], {
21911
22021
  cwd: target,
21912
22022
  timeout: 5000
21913
22023
  });
@@ -21931,7 +22041,7 @@ var commitRefusal = (input, command, dialect, { action, repo, invocation, workit
21931
22041
  } catch {}
21932
22042
  if (guarded && !switches)
21933
22043
  return `workit: raw ${quote("git commit")} on ${repo.branch}, a protected branch. Branch first: ${quote("workit git branch --kind feature --slug <slug>")} (uncommitted changes come along), then ${quote("workit git commit -m '<msg>' -- <paths>")}.`;
21934
- const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path29.resolve(input.cwd, invocation.dir), repo);
22044
+ const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path30.resolve(input.cwd, invocation.dir), repo);
21935
22045
  return call && `workit: no ${quote("cd … &&")} chain; run ${quote(call)}.`;
21936
22046
  };
21937
22047
  function rawGitPre(input, command, options = {}) {
@@ -22029,9 +22139,9 @@ var grantRefusal = (action, repo, invocation, cache) => {
22029
22139
  return null;
22030
22140
  };
22031
22141
  var localTag = (repo, name) => {
22032
- const common = path29.dirname(repo.location.dir);
22142
+ const common = path30.dirname(repo.location.dir);
22033
22143
  try {
22034
- return fs19.existsSync(path29.join(common, "refs/tags", name)) || fs19.readFileSync(path29.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
22144
+ return fs20.existsSync(path30.join(common, "refs/tags", name)) || fs20.readFileSync(path30.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
22035
22145
  `);
22036
22146
  } catch {
22037
22147
  return false;
@@ -22051,7 +22161,7 @@ var analysisDenial = (error) => ({
22051
22161
  });
22052
22162
  var NEXT_COMMAND = "next";
22053
22163
  var MARKER_TTL_SECONDS = 3600;
22054
- var markerFile = (repo, session, key) => path29.join(repo.location.dir, "hooks", `commit-${createHash16("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
22164
+ var markerFile = (repo, session, key) => path30.join(repo.location.dir, "hooks", `commit-${createHash16("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
22055
22165
  var callKey = (toolUseId, command) => toolUseId ?? `cmd:${createHash16("sha256").update(command).digest("hex")}`;
22056
22166
  function noteRawCommit(input, command, key) {
22057
22167
  try {
@@ -22062,14 +22172,14 @@ function noteRawCommit(input, command, key) {
22062
22172
  if (action.kind !== "commit")
22063
22173
  continue;
22064
22174
  const file = markerFile(repo, input.session.id, key);
22065
- fs19.mkdirSync(path29.dirname(file), { recursive: true });
22066
- fs19.writeFileSync(file, `${JSON.stringify({ head: headSha2(repo), at })}
22175
+ fs20.mkdirSync(path30.dirname(file), { recursive: true });
22176
+ fs20.writeFileSync(file, `${JSON.stringify({ head: headSha2(repo), at })}
22067
22177
  `);
22068
22178
  }
22069
22179
  } catch {}
22070
22180
  }
22071
22181
  var headCommit = (dir) => {
22072
- const run = spawnSync16("git", [
22182
+ const run = spawnSync17("git", [
22073
22183
  "log",
22074
22184
  "-1",
22075
22185
  "--format=%H%x1f%ct%x1f%s%x1f%(trailers:key=Workit-Session,valueonly,separator=%x2c)"
@@ -22096,11 +22206,11 @@ var headCommit = (dir) => {
22096
22206
  var settle2 = (input, repo, file) => {
22097
22207
  let marker;
22098
22208
  try {
22099
- marker = JSON.parse(fs19.readFileSync(file, "utf8"));
22209
+ marker = JSON.parse(fs20.readFileSync(file, "utf8"));
22100
22210
  } catch {
22101
22211
  return;
22102
22212
  }
22103
- fs19.rmSync(file, { force: true });
22213
+ fs20.rmSync(file, { force: true });
22104
22214
  const session = input.session.id;
22105
22215
  const now = Date.now() / 1000;
22106
22216
  if (typeof marker.at !== "number" || now - marker.at > MARKER_TTL_SECONDS)
@@ -22149,7 +22259,7 @@ function settlePendingCommit(input) {
22149
22259
  if (!repo)
22150
22260
  return;
22151
22261
  const file = markerFile(repo, input.session.id, NEXT_COMMAND);
22152
- if (fs19.existsSync(file))
22262
+ if (fs20.existsSync(file))
22153
22263
  settle2(input, repo, file);
22154
22264
  } catch {}
22155
22265
  }
@@ -22293,7 +22403,7 @@ var targetsOf = (invocations) => invocations.flatMap((invocation) => invocation.
22293
22403
  branch,
22294
22404
  dir: invocation.dir
22295
22405
  })) : []);
22296
- var localBranchExists = (dir, branch) => spawnSync17("git", ["show-ref", "--verify", "--quiet", `refs/heads/${branch}`], {
22406
+ var localBranchExists = (dir, branch) => spawnSync18("git", ["show-ref", "--verify", "--quiet", `refs/heads/${branch}`], {
22297
22407
  cwd: dir,
22298
22408
  stdio: "ignore",
22299
22409
  timeout: 5000
@@ -22303,7 +22413,7 @@ var judgedDir = (root, dir) => {
22303
22413
  return null;
22304
22414
  if (dir === null)
22305
22415
  return root;
22306
- const resolved = path30.resolve(root, dir);
22416
+ const resolved = path31.resolve(root, dir);
22307
22417
  return existsSync12(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
22308
22418
  };
22309
22419
  var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
@@ -24299,9 +24409,9 @@ class WorkitCore {
24299
24409
  }
24300
24410
  }
24301
24411
  // packages/workit-core/src/core/repo-context.ts
24302
- import { spawnSync as spawnSync18 } from "node:child_process";
24412
+ import { spawnSync as spawnSync19 } from "node:child_process";
24303
24413
  import { existsSync as existsSync13, readFileSync as readFileSync11, readdirSync as readdirSync4 } from "node:fs";
24304
- import path31 from "node:path";
24414
+ import path32 from "node:path";
24305
24415
  var isSafeContextRange = (value) => value.length <= 4096 && (() => {
24306
24416
  try {
24307
24417
  gitRevisionParts(value);
@@ -24328,7 +24438,7 @@ var invalidRange = (cwd) => ({
24328
24438
  cwd
24329
24439
  });
24330
24440
  var runGit = (cwd, args) => {
24331
- const result = spawnSync18("git", args, { cwd, encoding: "utf8" });
24441
+ const result = spawnSync19("git", args, { cwd, encoding: "utf8" });
24332
24442
  return {
24333
24443
  stdout: (result.stdout ?? "").trimEnd(),
24334
24444
  stderr: (result.stderr ?? "").trimEnd(),
@@ -24445,13 +24555,13 @@ var findPrTemplate = (cwd) => {
24445
24555
  for (const rel of PR_TEMPLATE_FILES) {
24446
24556
  const parts = rel.split("/");
24447
24557
  const base = parts[parts.length - 1];
24448
- const dir = parts.length > 1 ? path31.join(cwd, ...parts.slice(0, -1)) : cwd;
24558
+ const dir = parts.length > 1 ? path32.join(cwd, ...parts.slice(0, -1)) : cwd;
24449
24559
  const actual = probeCaseInsensitive(dir, base);
24450
24560
  if (actual)
24451
24561
  return [...parts.slice(0, -1), actual].join("/");
24452
24562
  }
24453
24563
  for (const rel of PR_TEMPLATE_DIRS) {
24454
- const only = singleMarkdown(path31.join(cwd, ...rel.split("/")));
24564
+ const only = singleMarkdown(path32.join(cwd, ...rel.split("/")));
24455
24565
  if (only)
24456
24566
  return `${rel}/${only}`;
24457
24567
  }
@@ -24481,7 +24591,7 @@ var diffStatForRange = (cwd, range) => {
24481
24591
  return runGit(cwd, ["diff", "--stat", "--"]).stdout;
24482
24592
  };
24483
24593
  var packageScripts = (cwd, keys) => {
24484
- const pkgPath = path31.join(cwd, "package.json");
24594
+ const pkgPath = path32.join(cwd, "package.json");
24485
24595
  if (!existsSync13(pkgPath))
24486
24596
  return [];
24487
24597
  try {
@@ -24507,9 +24617,9 @@ var documentationFiles = (cwd) => {
24507
24617
  if (entry.isDirectory()) {
24508
24618
  if (excluded.has(entry.name))
24509
24619
  continue;
24510
- walk(path31.join(dir, entry.name), depth + 1);
24620
+ walk(path32.join(dir, entry.name), depth + 1);
24511
24621
  } else if (entry.isFile() && (entry.name === "README.md" || entry.name.endsWith(".md"))) {
24512
- matches.push("./" + path31.relative(cwd, path31.join(dir, entry.name)).replaceAll("\\", "/"));
24622
+ matches.push("./" + path32.relative(cwd, path32.join(dir, entry.name)).replaceAll("\\", "/"));
24513
24623
  }
24514
24624
  }
24515
24625
  };
@@ -24525,7 +24635,7 @@ var readTrimmed2 = (file, maxLines) => {
24525
24635
  `);
24526
24636
  };
24527
24637
  function prReadyContext(root, range) {
24528
- const cwd = path31.resolve(repoRoot(root));
24638
+ const cwd = path32.resolve(repoRoot(root));
24529
24639
  if (range !== undefined && !isResolvableContextRange(cwd, range))
24530
24640
  return invalidRange(cwd);
24531
24641
  let stdout = "";
@@ -24583,7 +24693,7 @@ ${status.stderr}` : "");
24583
24693
  stdout += `template_path: ${template}
24584
24694
 
24585
24695
  `;
24586
- stdout += readTrimmed2(path31.join(cwd, template), 220);
24696
+ stdout += readTrimmed2(path32.join(cwd, template), 220);
24587
24697
  } else {
24588
24698
  stdout += `template_path: none
24589
24699
 
@@ -24593,7 +24703,7 @@ ${status.stderr}` : "");
24593
24703
  stdout += `
24594
24704
  `;
24595
24705
  stdout += printSection("Recent Validation Signals");
24596
- if (existsSync13(path31.join(cwd, "package.json"))) {
24706
+ if (existsSync13(path32.join(cwd, "package.json"))) {
24597
24707
  stdout += `package.json detected. Common scripts:
24598
24708
  `;
24599
24709
  const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
@@ -24602,7 +24712,7 @@ ${status.stderr}` : "");
24602
24712
  `) + `
24603
24713
  `;
24604
24714
  }
24605
- if (existsSync13(path31.join(cwd, "Cargo.toml")) || existsSync13(path31.join(cwd, "src-tauri/Cargo.toml"))) {
24715
+ if (existsSync13(path32.join(cwd, "Cargo.toml")) || existsSync13(path32.join(cwd, "src-tauri/Cargo.toml"))) {
24606
24716
  stdout += `Rust project detected.
24607
24717
  `;
24608
24718
  }
@@ -24635,7 +24745,7 @@ var CHANGELOG_RULES = `- Use an [Unreleased] section.
24635
24745
  - Apply with the host-native editor, preserving the repository changelog conventions.
24636
24746
  - If Unreleased already has duplicate category headings, normalize_only first.`;
24637
24747
  function changelogContext(root, range) {
24638
- const cwd = path31.resolve(repoRoot(root));
24748
+ const cwd = path32.resolve(repoRoot(root));
24639
24749
  if (range !== undefined && !isResolvableContextRange(cwd, range))
24640
24750
  return invalidRange(cwd);
24641
24751
  const resolvedRange = rangeArgOrDefault(range, cwd);
@@ -24653,7 +24763,7 @@ function changelogContext(root, range) {
24653
24763
  stdout += CHANGELOG_RULES + `
24654
24764
  `;
24655
24765
  stdout += printSection("Existing CHANGELOG.md");
24656
- const changelogPath = path31.join(cwd, "CHANGELOG.md");
24766
+ const changelogPath = path32.join(cwd, "CHANGELOG.md");
24657
24767
  if (existsSync13(changelogPath)) {
24658
24768
  stdout += readTrimmed2(changelogPath, 260) + `
24659
24769
  `;
@@ -24673,7 +24783,7 @@ function changelogContext(root, range) {
24673
24783
  return { stdout, stderr: "", exitCode: 0, cwd };
24674
24784
  }
24675
24785
  function docsRefreshContext(root, range) {
24676
- const cwd = path31.resolve(repoRoot(root));
24786
+ const cwd = path32.resolve(repoRoot(root));
24677
24787
  if (range !== undefined && !isResolvableContextRange(cwd, range))
24678
24788
  return invalidRange(cwd);
24679
24789
  const resolvedRange = rangeArgOrDefault(range, cwd);
@@ -24695,7 +24805,7 @@ function docsRefreshContext(root, range) {
24695
24805
  `) + `
24696
24806
  `;
24697
24807
  stdout += printSection("README Preview");
24698
- const readme = path31.join(cwd, "README.md");
24808
+ const readme = path32.join(cwd, "README.md");
24699
24809
  if (existsSync13(readme)) {
24700
24810
  stdout += readTrimmed2(readme, 220) + `
24701
24811
  `;
@@ -24704,7 +24814,7 @@ function docsRefreshContext(root, range) {
24704
24814
  `;
24705
24815
  }
24706
24816
  stdout += printSection("Package Scripts");
24707
- const pkgPath = path31.join(cwd, "package.json");
24817
+ const pkgPath = path32.join(cwd, "package.json");
24708
24818
  if (existsSync13(pkgPath)) {
24709
24819
  try {
24710
24820
  const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
@@ -24718,7 +24828,7 @@ function docsRefreshContext(root, range) {
24718
24828
  return { stdout, stderr: "", exitCode: 0, cwd };
24719
24829
  }
24720
24830
  function releaseNotesContext(root, rangeOrTag) {
24721
- const cwd = path31.resolve(repoRoot(root));
24831
+ const cwd = path32.resolve(repoRoot(root));
24722
24832
  if (!rangeOrTag) {
24723
24833
  return {
24724
24834
  stdout: "",
@@ -24761,7 +24871,7 @@ function releaseNotesContext(root, rangeOrTag) {
24761
24871
  `;
24762
24872
  stdout += printSection("Existing Release Files");
24763
24873
  for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
24764
- if (existsSync13(path31.join(cwd, rel)))
24874
+ if (existsSync13(path32.join(cwd, rel)))
24765
24875
  stdout += rel + `
24766
24876
  `;
24767
24877
  }
@@ -24789,12 +24899,12 @@ function releaseNotesContext(root, rangeOrTag) {
24789
24899
  }
24790
24900
 
24791
24901
  // packages/workit-core/src/core/tracker-issues.ts
24792
- import { spawnSync as spawnSync20 } from "node:child_process";
24902
+ import { spawnSync as spawnSync21 } from "node:child_process";
24793
24903
 
24794
24904
  // packages/workit-core/src/core/pr-create.ts
24795
- import fs20 from "node:fs";
24796
- import path32 from "node:path";
24797
- import { spawnSync as spawnSync19 } from "node:child_process";
24905
+ import fs21 from "node:fs";
24906
+ import path33 from "node:path";
24907
+ import { spawnSync as spawnSync20 } from "node:child_process";
24798
24908
  // packages/workit-core/src/forge/pr-body.ts
24799
24909
  function parseGhIssue(value) {
24800
24910
  const m = /issues\/(\d+)/.exec(value);
@@ -24813,13 +24923,13 @@ var LOCAL = bounded(20000);
24813
24923
  var NETWORK = bounded(60000);
24814
24924
  function whichOnPath(tool) {
24815
24925
  const names = process.platform === "win32" ? [tool, `${tool}.exe`, `${tool}.cmd`] : [tool];
24816
- for (const dir of (process.env.PATH ?? "").split(path32.delimiter)) {
24926
+ for (const dir of (process.env.PATH ?? "").split(path33.delimiter)) {
24817
24927
  if (!dir)
24818
24928
  continue;
24819
24929
  for (const name of names) {
24820
- const candidate = path32.join(dir, name);
24930
+ const candidate = path33.join(dir, name);
24821
24931
  try {
24822
- fs20.accessSync(candidate, fs20.constants.X_OK);
24932
+ fs21.accessSync(candidate, fs21.constants.X_OK);
24823
24933
  return candidate;
24824
24934
  } catch {}
24825
24935
  }
@@ -24828,7 +24938,7 @@ function whichOnPath(tool) {
24828
24938
  }
24829
24939
  var hostingCliAvailable = (provider) => whichOnPath(provider === "gitlab" ? "glab" : "gh") !== null;
24830
24940
  var pushRemote = (cwd) => {
24831
- const result = spawnSync19("git", ["remote", "get-url", "--push", "--all", "origin"], {
24941
+ const result = spawnSync20("git", ["remote", "get-url", "--push", "--all", "origin"], {
24832
24942
  cwd,
24833
24943
  ...LOCAL
24834
24944
  });
@@ -24859,7 +24969,7 @@ var defaultCli = (bin, available) => {
24859
24969
  if (!available)
24860
24970
  return null;
24861
24971
  return (args, root) => {
24862
- const out = spawnSync20(bin, args, {
24972
+ const out = spawnSync21(bin, args, {
24863
24973
  cwd: root,
24864
24974
  encoding: "utf8",
24865
24975
  env: { ...process.env, PATH: process.env.PATH ?? "" }
@@ -24948,76 +25058,6 @@ var PLUGIN_ROOT = packageRoot();
24948
25058
  var ASSET_ROOT = assetRoot();
24949
25059
  var resolveWorkspaceRoot = (explicit) => explicit || process.cwd();
24950
25060
 
24951
- // packages/workit-core/src/core/youtrack-ytrack.ts
24952
- import { spawnSync as spawnSync21 } from "node:child_process";
24953
-
24954
- // packages/workit-core/src/forge/exec.ts
24955
- import fs21 from "node:fs";
24956
- import path33 from "node:path";
24957
-
24958
- // packages/workit-core/src/forge/redact.ts
24959
- 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_.-]*`;
24960
- var ASSIGNMENT2 = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*["']?)((?:bearer|basic|token|digest)\s+)?([^\s"',;&]+)`, "giu");
24961
- var QUOTED_ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*)(["'])([^"'\n]*[^\s"'][^"'\n]*)\2`, "giu");
24962
- var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\u0007`, "gu");
24963
-
24964
- // packages/workit-core/src/forge/exec.ts
24965
- var MAX_BUFFER2 = 64 * 1024 * 1024;
24966
- function findExecutable(bin, env) {
24967
- const dirs = (env.PATH ?? env.Path ?? "").split(path33.delimiter).filter(Boolean);
24968
- const exts = process.platform === "win32" ? [".exe"] : [""];
24969
- for (const dir of dirs)
24970
- for (const ext of exts) {
24971
- const candidate = path33.join(dir, `${bin}${ext}`);
24972
- try {
24973
- const stat = fs21.statSync(candidate);
24974
- if (stat.isFile())
24975
- return candidate;
24976
- } catch {}
24977
- }
24978
- return null;
24979
- }
24980
-
24981
- // packages/workit-core/src/core/youtrack-ytrack.ts
24982
- var TIMEOUT_MS = 60000;
24983
- var YTRACK_EXIT = { ok: 0, failed: 1, cancelled: 2, auth: 4 };
24984
- var findYtrack = (env) => env.WORKIT_NO_YTRACK === "1" ? null : findExecutable("ytrack", env);
24985
- var YTRACK_QUIET_ENV = {
24986
- YTRACK_NO_UPDATE_NOTIFIER: "1",
24987
- YTRACK_NO_AUTO_UPGRADE: "1"
24988
- };
24989
- function ytrackRunner(env, host, timeoutMs = TIMEOUT_MS) {
24990
- return (args, input) => {
24991
- const exe = findYtrack(env);
24992
- if (!exe)
24993
- return { status: null, stdout: "", stderr: "", missing: true };
24994
- const result = spawnSync21(exe, args, {
24995
- encoding: "utf8",
24996
- env: {
24997
- ...env,
24998
- NO_COLOR: "1",
24999
- ...YTRACK_QUIET_ENV,
25000
- ...host ? { YTRACK_HOST: host } : {}
25001
- },
25002
- timeout: timeoutMs,
25003
- killSignal: "SIGKILL",
25004
- windowsHide: true,
25005
- ...input === undefined ? { stdio: ["ignore", "pipe", "pipe"] } : { input, stdio: ["pipe", "pipe", "pipe"] }
25006
- });
25007
- const error = result.error;
25008
- if (error?.code === "ENOENT")
25009
- return { status: null, stdout: "", stderr: "", missing: true };
25010
- return {
25011
- status: result.status,
25012
- stdout: result.stdout ?? "",
25013
- stderr: result.stderr || (error ? error.message : "")
25014
- };
25015
- };
25016
- }
25017
- var ytrackDetail = (out) => out.stderr.trim().split(`
25018
- `).slice(-3).join(" ").slice(0, 300);
25019
- var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only through ytrack";
25020
-
25021
25061
  // packages/workit-core/src/core/youtrack.ts
25022
25062
  var ISSUE_RE = /^[A-Z][A-Z0-9_]*-\d+$/;
25023
25063
  var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path34.join(resolveConfigDir(), "youtrack.json");
@@ -31987,6 +32027,29 @@ var judge = (args, words) => {
31987
32027
  return mapIssueWrite("attach", args);
31988
32028
  return /^(?:edit|update|delete|rm)$/.test(verb) ? UNCOVERED : null;
31989
32029
  };
32030
+ var hostsOf = (args) => {
32031
+ const end = args.indexOf("--");
32032
+ const hosts = [];
32033
+ const bare = [];
32034
+ let literal = true;
32035
+ let named = false;
32036
+ for (let at = 0;at < args.length; at++) {
32037
+ const arg = args[at];
32038
+ if (end >= 0 && at >= end || !/^--host(?:=|$)/.test(arg)) {
32039
+ bare.push(arg);
32040
+ continue;
32041
+ }
32042
+ named ||= standsAlone(args, at);
32043
+ const value = arg === "--host" ? args[++at] : arg.slice("--host=".length);
32044
+ if (value === undefined || !value.trim() || EXPANDS.test(value))
32045
+ literal = false;
32046
+ else
32047
+ hosts.push(value);
32048
+ }
32049
+ if (!literal)
32050
+ return { hosts: null, bare };
32051
+ return named ? { hosts, bare } : { hosts: [], bare: [...args] };
32052
+ };
31990
32053
  var SHELLS3 = /^(?:sh|bash|zsh|dash|ksh|ash|mksh|yash|fish)$/;
31991
32054
  var MAX_DEPTH2 = 4;
31992
32055
  var READ = new Map;
@@ -31994,10 +32057,19 @@ var NOT_PLAIN = gap("a ytrack call that is not a plain command of its own (a wra
31994
32057
  var timeOnly = (effect) => effect?.minutes !== undefined && Object.keys(effect).every((key) => /^(?:issue|minutes|text|date)$/u.test(key));
31995
32058
  var ungrant = (write) => write.workit ? {
31996
32059
  command: write.command,
32060
+ hosts: write.hosts,
32061
+ bare: write.bare,
32062
+ plain: write.plain,
31997
32063
  ...NOT_PLAIN,
31998
32064
  ...timeOnly(write.effect) ? { hint: write.workit } : {}
31999
32065
  } : write;
32000
- var hinted = (write) => write.hint ? { command: write.command, workit: write.hint } : write;
32066
+ var hinted = (write) => write.hint ? {
32067
+ command: write.command,
32068
+ hosts: write.hosts,
32069
+ bare: write.bare,
32070
+ plain: false,
32071
+ workit: write.hint
32072
+ } : write;
32001
32073
  var ytrackArgs = (line, found, depth, names, plain) => {
32002
32074
  const inner = (script) => void found.push(...ytrackWrites(script, "posix", depth + 1, plain));
32003
32075
  const tail = workitCheckTail(line);
@@ -32032,7 +32104,12 @@ var ytrackArgs = (line, found, depth, names, plain) => {
32032
32104
  const argv = [...alias ?? [], ...line.slice(at + 1)];
32033
32105
  const write = classify2(argv);
32034
32106
  if (write) {
32035
- const one = { command: ["ytrack", ...argv].map(quote3).join(" "), ...write };
32107
+ const one = {
32108
+ command: ["ytrack", ...argv].map(quote3).join(" "),
32109
+ ...write,
32110
+ ...hostsOf(argv),
32111
+ plain
32112
+ };
32036
32113
  found.push(plain ? one : ungrant(one));
32037
32114
  }
32038
32115
  return true;
@@ -32109,7 +32186,15 @@ var chained = (first, chain, depth) => {
32109
32186
  const effect = combine(effects);
32110
32187
  if (!effect)
32111
32188
  return null;
32112
- return [{ command: found.map((write) => write.command).join(" && "), ...mapped(effect) }];
32189
+ const hosts = found.map((write) => write.hosts);
32190
+ return [
32191
+ {
32192
+ command: found.map((write) => write.command).join(" && "),
32193
+ ...mapped(effect),
32194
+ hosts: hosts.includes(null) ? null : hosts.some((list) => !list?.length) ? [] : hosts.flatMap((list) => list ?? []),
32195
+ plain: true
32196
+ }
32197
+ ];
32113
32198
  };
32114
32199
  var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
32115
32200
  if (!namesYtrack(command))
@@ -32138,6 +32223,32 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
32138
32223
  READ.delete(READ.keys().next().value);
32139
32224
  return found;
32140
32225
  };
32226
+ var RELOCATES = /(?<![$\w])YTRACK_CONFIG_DIR\b/;
32227
+ var reachesOnly = (allowed, write) => write.plain && !!write.hosts?.length && write.hosts.every((host) => youTrackHostAllowed(allowed, host));
32228
+ var scopedGate = (allowed, command, writes) => {
32229
+ const scope = `youtrack.autoHosts (${allowed.join(", ")})`;
32230
+ if (RELOCATES.test(command))
32231
+ return {
32232
+ kind: "deny",
32233
+ 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.`,
32234
+ unblock: null
32235
+ };
32236
+ const first = allowed.map(youTrackHostKey).find(Boolean);
32237
+ if (!first)
32238
+ return null;
32239
+ const unnamed = writes.filter((write) => !reachesOnly(allowed, write) && (!write.hosts?.length || write.hosts.every((host) => youTrackHostAllowed(allowed, host))));
32240
+ if (!unnamed.length)
32241
+ return null;
32242
+ 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";
32243
+ const bare = unnamed.find((write) => write.bare)?.bare;
32244
+ const retry = bare ? ["ytrack", "--host", first, ...bare].map(quote3).join(" ") : null;
32245
+ return {
32246
+ kind: "deny",
32247
+ 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 ? `
32248
+ Retry as: ${retry}` : ""}`,
32249
+ unblock: retry
32250
+ };
32251
+ };
32141
32252
  var ytrackGate = (cwd, command, dialect, ask) => {
32142
32253
  if (namesTicket(command))
32143
32254
  return { kind: "deny", reason: TICKET_DENY, unblock: null };
@@ -32150,7 +32261,8 @@ var ytrackGate = (cwd, command, dialect, ask) => {
32150
32261
  }
32151
32262
  writes = [...merged.values()];
32152
32263
  } catch {
32153
- if (youTrackWritesMode(cwd) === "auto")
32264
+ const policy = youTrackWritesPolicy(cwd);
32265
+ if (policy.mode === "auto" && policy.hosts === null)
32154
32266
  return null;
32155
32267
  return {
32156
32268
  kind: "deny",
@@ -32158,7 +32270,19 @@ var ytrackGate = (cwd, command, dialect, ask) => {
32158
32270
  unblock: null
32159
32271
  };
32160
32272
  }
32161
- if (!writes.length || youTrackWritesMode(cwd) === "auto")
32273
+ if (!writes.length && !RELOCATES.test(command))
32274
+ return null;
32275
+ const policy = youTrackWritesPolicy(cwd);
32276
+ if (policy.mode === "auto") {
32277
+ const hosts = policy.hosts;
32278
+ if (hosts === null)
32279
+ return null;
32280
+ const scoped = scopedGate(hosts, command, writes);
32281
+ if (scoped)
32282
+ return scoped;
32283
+ writes = writes.filter((write) => !reachesOnly(hosts, write));
32284
+ }
32285
+ if (!writes.length)
32162
32286
  return null;
32163
32287
  const calls = writes.flatMap((write) => write.workit ? [`\`${write.workit}\``] : []);
32164
32288
  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"})`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/pi",
3
- "version": "2.20.6",
3
+ "version": "2.21.0",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",