@workit-dev/opencode 1.8.0 → 1.8.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.
Files changed (2) hide show
  1. package/dist/plugin.js +198 -133
  2. package/package.json +2 -2
package/dist/plugin.js CHANGED
@@ -182,7 +182,7 @@ function define(plugin) {
182
182
  }
183
183
 
184
184
  // packages/workit-core/src/core.ts
185
- import { spawnSync as spawnSync21 } from "node:child_process";
185
+ import { spawnSync as spawnSync22 } from "node:child_process";
186
186
  import { existsSync as existsSync12, realpathSync as realpathSync8 } from "node:fs";
187
187
  import path34 from "node:path";
188
188
 
@@ -8083,15 +8083,14 @@ var gitContext = (workspaceRoot, paths = []) => {
8083
8083
  };
8084
8084
 
8085
8085
  // packages/workit-core/src/core/workspaces.ts
8086
- import { spawnSync as spawnSync5 } from "node:child_process";
8086
+ import { spawnSync as spawnSync6 } from "node:child_process";
8087
8087
  import { createHash as createHash5 } from "node:crypto";
8088
- import { existsSync as existsSync2, lstatSync as lstatSync2, readFileSync as readFileSync3, realpathSync as realpathSync2 } from "node:fs";
8088
+ import { existsSync as existsSync2, lstatSync as lstatSync2, readFileSync as readFileSync4, realpathSync as realpathSync2 } from "node:fs";
8089
8089
  import path9 from "node:path";
8090
8090
 
8091
8091
  // packages/workit-core/src/core/remotes.ts
8092
- import { lstatSync, readFileSync as readFileSync2, realpathSync, statSync } from "node:fs";
8093
- import { spawnSync as spawnSync4 } from "node:child_process";
8094
- import os3 from "node:os";
8092
+ import { lstatSync, readFileSync as readFileSync3, realpathSync, statSync } from "node:fs";
8093
+ import { spawnSync as spawnSync5 } from "node:child_process";
8095
8094
  import path8 from "node:path";
8096
8095
 
8097
8096
  // packages/workit-core/src/git/rev.ts
@@ -9046,6 +9045,56 @@ function resolveSshHost(alias, sshConfig) {
9046
9045
  return { hostname: (hostname ?? alias).replace(/\.$/u, ""), port };
9047
9046
  }
9048
9047
 
9048
+ // packages/workit-core/src/core/account-home.ts
9049
+ import { spawnSync as spawnSync4 } from "node:child_process";
9050
+ import { readFileSync as readFileSync2 } from "node:fs";
9051
+ import os3 from "node:os";
9052
+ var WINDOWS = "C:\\Windows";
9053
+ var SYSTEM32 = `${WINDOWS}\\System32\\`;
9054
+ var PROFILES = "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\";
9055
+ var childEnv = (platform) => platform === "win32" ? { SystemRoot: WINDOWS } : {};
9056
+ var hostIo = {
9057
+ bun: Boolean(process.versions.bun),
9058
+ uid: process.getuid?.() ?? -1,
9059
+ userInfo: () => os3.userInfo().homedir,
9060
+ passwd: () => readFileSync2("/etc/passwd", "utf8"),
9061
+ run: (file, args) => {
9062
+ const done = spawnSync4(file, args, {
9063
+ encoding: "utf8",
9064
+ env: childEnv(process.platform),
9065
+ timeout: 3000,
9066
+ windowsHide: true
9067
+ });
9068
+ return done.status === 0 ? done.stdout : "";
9069
+ }
9070
+ };
9071
+ var field = (text, uid, at) => text.split(`
9072
+ `).filter((line) => !line.startsWith("#")).map((line) => line.split(":")).find((fields) => fields[2] === uid)?.[at];
9073
+ var profilePath = (raw) => {
9074
+ const value = raw.replaceAll(/%SystemDrive%/giu, WINDOWS.slice(0, 2)).replaceAll(/%SystemRoot%/giu, WINDOWS);
9075
+ return /^[A-Za-z]:\\/u.test(value) && !value.includes("%") ? value : null;
9076
+ };
9077
+ var accountHome = (platform = process.platform, io = hostIo) => {
9078
+ try {
9079
+ if (!io.bun)
9080
+ return io.userInfo() || null;
9081
+ if (platform === "win32") {
9082
+ const sid = /S-1-[\d-]+/u.exec(io.run(`${SYSTEM32}whoami.exe`, ["/user", "/fo", "csv"]));
9083
+ const key = sid && io.run(`${SYSTEM32}reg.exe`, ["query", PROFILES + sid[0], "/v", "ProfileImagePath"]);
9084
+ const raw = /ProfileImagePath\s+REG_\w+\s+(.+)/u.exec(key || "")?.[1]?.trim();
9085
+ return raw ? profilePath(raw) : null;
9086
+ }
9087
+ const uid = String(io.uid);
9088
+ let passwd = "";
9089
+ try {
9090
+ passwd = io.passwd();
9091
+ } catch {}
9092
+ return field(passwd, uid, 5) || (platform === "darwin" ? field(io.run("/usr/bin/id", ["-P"]), uid, 8) : field(io.run("/usr/bin/getent", ["passwd", uid]), uid, 5)) || null;
9093
+ } catch {
9094
+ return null;
9095
+ }
9096
+ };
9097
+
9049
9098
  // packages/workit-core/src/core/remotes.ts
9050
9099
  var FORGE_SCHEMES = new Set(["ssh", "git", "http", "https", "git+ssh", "ssh+git"]);
9051
9100
  var SSH_SCHEMES = new Set(["ssh", "git+ssh", "ssh+git"]);
@@ -9055,15 +9104,11 @@ var SSH_443 = {
9055
9104
  };
9056
9105
  var WINDOWS_DRIVE = /^[A-Za-z]:[\\/]/u;
9057
9106
  var SCP_LIKE = /^(?:[^@/\\]+@)?([^/\\:]+):(.+)$/u;
9058
- var accountHome = () => {
9059
- try {
9060
- return os3.userInfo().homedir;
9061
- } catch {
9062
- return os3.homedir();
9063
- }
9064
- };
9065
9107
  var sshSeam = {
9066
- read: () => readSshConfig(accountHome())
9108
+ read: () => {
9109
+ const home = accountHome();
9110
+ return home === null ? { text: "", home: "" } : readSshConfig(home);
9111
+ }
9067
9112
  };
9068
9113
  var forgeKey = (rawHost, repo, ssh) => {
9069
9114
  let host = rawHost.toLowerCase().replace(/\.$/u, "");
@@ -9110,7 +9155,7 @@ var gitDirAt = (at, depth = 0) => {
9110
9155
  return null;
9111
9156
  try {
9112
9157
  if (statSync(real).isFile()) {
9113
- const pointer = /^gitdir:\s*(.+?)\s*$/mu.exec(readFileSync2(real, "utf8"))?.[1];
9158
+ const pointer = /^gitdir:\s*(.+?)\s*$/mu.exec(readFileSync3(real, "utf8"))?.[1];
9114
9159
  if (!pointer)
9115
9160
  return null;
9116
9161
  const target = path8.isAbsolute(pointer) ? pointer : `${path8.dirname(real)}/${pointer}`;
@@ -9118,7 +9163,7 @@ var gitDirAt = (at, depth = 0) => {
9118
9163
  }
9119
9164
  let common;
9120
9165
  try {
9121
- common = readFileSync2(`${real}/commondir`, "utf8").trim();
9166
+ common = readFileSync3(`${real}/commondir`, "utf8").trim();
9122
9167
  } catch {}
9123
9168
  if (common !== undefined) {
9124
9169
  lstatSync(`${real}/HEAD`);
@@ -9222,7 +9267,7 @@ var checkoutRemotes = (cwd) => {
9222
9267
  const env = { ...process.env };
9223
9268
  for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
9224
9269
  delete env[name];
9225
- const git = (args) => spawnSync4("git", args, {
9270
+ const git = (args) => spawnSync5("git", args, {
9226
9271
  cwd,
9227
9272
  env,
9228
9273
  encoding: "utf8",
@@ -9273,6 +9318,8 @@ var userLevel = (scope, origin) => {
9273
9318
  return false;
9274
9319
  const file = realOrSelf(origin.slice("file:".length));
9275
9320
  const home = userGitSeam.home();
9321
+ if (home === null)
9322
+ return false;
9276
9323
  return [path8.join(home, ".gitconfig"), path8.join(home, ".config", "git", "config")].map(realOrSelf).includes(file);
9277
9324
  };
9278
9325
  var escapeRegex2 = (value) => value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
@@ -9283,7 +9330,7 @@ var transportOverride = (git, remote, vars) => {
9283
9330
  const execPath = vars.GIT_EXEC_PATH;
9284
9331
  if (execPath) {
9285
9332
  const { GIT_EXEC_PATH: _set, ...rest } = vars;
9286
- const own = spawnSync4("git", ["--exec-path"], {
9333
+ const own = spawnSync5("git", ["--exec-path"], {
9287
9334
  env: rest,
9288
9335
  encoding: "utf8"
9289
9336
  });
@@ -9319,7 +9366,7 @@ var pushTarget = (cwd, remote, replay = {}) => {
9319
9366
  delete env[name];
9320
9367
  if (!remote || remote.startsWith("-"))
9321
9368
  return Error(`push remote ${JSON.stringify(remote)} cannot be resolved`);
9322
- const git = (args) => spawnSync4("git", [...replay.config ?? [], ...args], {
9369
+ const git = (args) => spawnSync5("git", [...replay.config ?? [], ...args], {
9323
9370
  cwd,
9324
9371
  env,
9325
9372
  encoding: "utf8",
@@ -9551,7 +9598,7 @@ var readWorkspacesResult = (dir = configDir2()) => {
9551
9598
  const file = path9.join(dir, "workspaces.json");
9552
9599
  let raw;
9553
9600
  try {
9554
- raw = readFileSync3(file, "utf8");
9601
+ raw = readFileSync4(file, "utf8");
9555
9602
  } catch (error) {
9556
9603
  if (error.code === "ENOENT")
9557
9604
  return {
@@ -9672,7 +9719,7 @@ var probeCheckout = (cwd) => {
9672
9719
  for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
9673
9720
  delete env[name];
9674
9721
  const git = (args) => {
9675
- const run = spawnSync5("git", args, {
9722
+ const run = spawnSync6("git", args, {
9676
9723
  cwd,
9677
9724
  env,
9678
9725
  encoding: "utf8",
@@ -9869,7 +9916,7 @@ var matchRuntimeWorkspace = (cwd, dir = configDir2()) => {
9869
9916
  const file = path9.join(dir, "workspaces.json");
9870
9917
  let raw;
9871
9918
  try {
9872
- raw = readFileSync3(file, "utf8");
9919
+ raw = readFileSync4(file, "utf8");
9873
9920
  } catch (error) {
9874
9921
  if (error.code === "ENOENT")
9875
9922
  return null;
@@ -9937,7 +9984,7 @@ var modelSources = (cwd, dir) => {
9937
9984
  }
9938
9985
  } catch {}
9939
9986
  try {
9940
- const document = JSON.parse(readFileSync3(path9.join(dir ?? configDir2(), "workspaces.json"), "utf8"));
9987
+ const document = JSON.parse(readFileSync4(path9.join(dir ?? configDir2(), "workspaces.json"), "utf8"));
9941
9988
  if (document && typeof document === "object" && !Array.isArray(document))
9942
9989
  out.push({
9943
9990
  name: "global",
@@ -10003,11 +10050,11 @@ function workspaceDefaultTarget(cwd, globalDefault) {
10003
10050
  // packages/workit-core/src/core/vcs-config.ts
10004
10051
  import fs6 from "node:fs";
10005
10052
  import path10 from "node:path";
10006
- import { spawnSync as spawnSync7 } from "node:child_process";
10053
+ import { spawnSync as spawnSync8 } from "node:child_process";
10007
10054
 
10008
10055
  // packages/workit-core/src/core/release-tracks.ts
10009
10056
  import { createHash as createHash6 } from "node:crypto";
10010
- import { spawnSync as spawnSync6 } from "node:child_process";
10057
+ import { spawnSync as spawnSync7 } from "node:child_process";
10011
10058
  class ReleaseTrackError extends Error {
10012
10059
  }
10013
10060
  var KNOWN_FIELDS = new Set([
@@ -10292,7 +10339,7 @@ function resolveReleaseTrack(input) {
10292
10339
  return fallback(`${branch} has the same or unrelated fork points with ${[...new Set(newest.map((fork) => `${fork.ref} (${fork.track.name === IMPLICIT ? "workspace default" : fork.track.name})`))].join(" and ")}`);
10293
10340
  }
10294
10341
  var git2 = (cwd, args) => {
10295
- const run = spawnSync6("git", args, {
10342
+ const run = spawnSync7("git", args, {
10296
10343
  cwd,
10297
10344
  encoding: "utf8",
10298
10345
  timeout: 20000,
@@ -10441,7 +10488,7 @@ var remoteEndpoint = (remote) => {
10441
10488
  var configuredSshEndpoint = (host) => {
10442
10489
  if (host.startsWith("-"))
10443
10490
  return null;
10444
- const resolved = spawnSync7("ssh", ["-G", host], {
10491
+ const resolved = spawnSync8("ssh", ["-G", host], {
10445
10492
  encoding: "utf8",
10446
10493
  timeout: 5000,
10447
10494
  maxBuffer: 1024 * 1024,
@@ -10655,7 +10702,7 @@ function mergedPrStyle(limit = 6, cwd) {
10655
10702
  `).filter((l) => l.startsWith("## ")).map((l) => l.trim()),
10656
10703
  descriptionPreview: desc.slice(0, 600)
10657
10704
  });
10658
- const remoteResult = spawnSync7("git", ["remote", "get-url", "--push", "--all", "origin"], {
10705
+ const remoteResult = spawnSync8("git", ["remote", "get-url", "--push", "--all", "origin"], {
10659
10706
  cwd,
10660
10707
  encoding: "utf8"
10661
10708
  });
@@ -10671,7 +10718,7 @@ function mergedPrStyle(limit = 6, cwd) {
10671
10718
  if (!hostingApiHostMatches(remote, host))
10672
10719
  return { ok: false, error: "PR style target does not match the provider host" };
10673
10720
  if (provider === "gitlab") {
10674
- const run = (args) => spawnSync7("glab", ["api", ...args], {
10721
+ const run = (args) => spawnSync8("glab", ["api", ...args], {
10675
10722
  cwd,
10676
10723
  encoding: "utf8",
10677
10724
  env
@@ -10691,7 +10738,7 @@ function mergedPrStyle(limit = 6, cwd) {
10691
10738
  });
10692
10739
  }
10693
10740
  } else if (provider === "github") {
10694
- const r = spawnSync7("gh", [
10741
+ const r = spawnSync8("gh", [
10695
10742
  "pr",
10696
10743
  "list",
10697
10744
  "--repo",
@@ -10958,13 +11005,13 @@ var resolveStateDir = () => stateDir(process.env);
10958
11005
  var homePattern = new RegExp(`${escapeRegExp2(os4.homedir())}(?=[/\\\\]|$)|\\$HOME(?=[/\\\\]|$)`, "g");
10959
11006
 
10960
11007
  // packages/workit-core/src/store/paths.ts
10961
- import { spawnSync as spawnSync8 } from "node:child_process";
11008
+ import { spawnSync as spawnSync9 } from "node:child_process";
10962
11009
  import { createHash as createHash8 } from "node:crypto";
10963
11010
  import fs7 from "node:fs";
10964
11011
  import path11 from "node:path";
10965
11012
  var NOT_A_REPO = /not a git repository \(or any (of the parent directories|parent up to)/u;
10966
11013
  var gitRun = (cwd, args) => {
10967
- const run = spawnSync8("git", args, {
11014
+ const run = spawnSync9("git", args, {
10968
11015
  cwd,
10969
11016
  encoding: "utf8",
10970
11017
  timeout: 20000,
@@ -12409,7 +12456,7 @@ var assetRoot = () => {
12409
12456
  };
12410
12457
 
12411
12458
  // packages/workit-core/src/core/store-lock.ts
12412
- import { spawnSync as spawnSync9 } from "node:child_process";
12459
+ import { spawnSync as spawnSync10 } from "node:child_process";
12413
12460
  import fs13 from "node:fs";
12414
12461
  import { hostname } from "node:os";
12415
12462
  var metadataLockSchema = object({
@@ -12460,7 +12507,7 @@ var readProcStat = (pid) => {
12460
12507
  };
12461
12508
  var psStart = (pid) => {
12462
12509
  try {
12463
- const run = spawnSync9("ps", ["-o", "lstart=", "-p", String(pid)], {
12510
+ const run = spawnSync10("ps", ["-o", "lstart=", "-p", String(pid)], {
12464
12511
  encoding: "utf8",
12465
12512
  timeout: 1000,
12466
12513
  env: { ...process.env, LC_ALL: "C" }
@@ -14469,11 +14516,11 @@ var holdsLiveState = (state, dirty) => state === "running" || dirty === true;
14469
14516
  // packages/workit-core/src/core/task-evaluation.ts
14470
14517
  import { createHash as createHash13 } from "node:crypto";
14471
14518
  import * as fs18 from "node:fs";
14472
- import { spawnSync as spawnSync14 } from "node:child_process";
14519
+ import { spawnSync as spawnSync15 } from "node:child_process";
14473
14520
  import path23 from "node:path";
14474
14521
 
14475
14522
  // packages/workit-core/src/check-config.ts
14476
- import { spawnSync as spawnSync10 } from "node:child_process";
14523
+ import { spawnSync as spawnSync11 } from "node:child_process";
14477
14524
  import fs16 from "node:fs";
14478
14525
  import path19 from "node:path";
14479
14526
  var SCRIPT_CHECKS = ["test", "lint", "typecheck", "check"];
@@ -14538,7 +14585,7 @@ function splitCommand(command) {
14538
14585
  return argv.length ? argv : new Error("empty command");
14539
14586
  }
14540
14587
  var git3 = (cwd, args) => {
14541
- const run = spawnSync10("git", args, {
14588
+ const run = spawnSync11("git", args, {
14542
14589
  cwd,
14543
14590
  encoding: "utf8",
14544
14591
  timeout: 20000,
@@ -14915,19 +14962,19 @@ import { existsSync as existsSync7 } from "node:fs";
14915
14962
  import path22 from "node:path";
14916
14963
 
14917
14964
  // packages/workit-core/src/ledger.ts
14918
- import { spawnSync as spawnSync13 } from "node:child_process";
14965
+ import { spawnSync as spawnSync14 } from "node:child_process";
14919
14966
  import { createHash as createHash12, randomBytes as randomBytes3 } from "node:crypto";
14920
14967
  import fs17 from "node:fs";
14921
14968
  import path21 from "node:path";
14922
14969
 
14923
14970
  // packages/workit-core/src/core/policy/bookkeeping.ts
14924
- import { spawnSync as spawnSync11 } from "node:child_process";
14971
+ import { spawnSync as spawnSync12 } from "node:child_process";
14925
14972
  var OID = /^[0-9a-f]{40,64}$/u;
14926
14973
  var safe = (value) => value.length > 0 && !value.startsWith("-");
14927
14974
  function replayTree(cwd, from, fromFork, toFork) {
14928
14975
  if (![from, fromFork, toFork].every(safe))
14929
14976
  return null;
14930
- const run = spawnSync11("git", ["merge-tree", "--write-tree", "--no-messages", `--merge-base=${fromFork}`, toFork, from], {
14977
+ const run = spawnSync12("git", ["merge-tree", "--write-tree", "--no-messages", `--merge-base=${fromFork}`, toFork, from], {
14931
14978
  cwd,
14932
14979
  encoding: "utf8",
14933
14980
  timeout: GIT_TIMEOUTS.worktree,
@@ -14998,11 +15045,11 @@ function bookkeepingPaths(cwd, input) {
14998
15045
  }
14999
15046
 
15000
15047
  // packages/workit-core/src/core/policy/lane.ts
15001
- import { existsSync as existsSync6, readFileSync as readFileSync6 } from "node:fs";
15048
+ import { existsSync as existsSync6, readFileSync as readFileSync7 } from "node:fs";
15002
15049
  import path20 from "node:path";
15003
15050
 
15004
15051
  // packages/workit-core/src/git/default-base.ts
15005
- import { spawnSync as spawnSync12 } from "node:child_process";
15052
+ import { spawnSync as spawnSync13 } from "node:child_process";
15006
15053
  var safeRef = (value) => value.length > 0 && !value.startsWith("-");
15007
15054
  var trackTrunk = (cwd) => {
15008
15055
  try {
@@ -15052,7 +15099,7 @@ var shorten = (table, full) => {
15052
15099
  return full;
15053
15100
  };
15054
15101
  function refTable(cwd) {
15055
- const run = spawnSync12("git", ["for-each-ref", "--format=%(refname)%00%(objecttype)%00%(*objecttype)%00%(symref)"], { cwd, encoding: "utf8", timeout: 20000, killSignal: "SIGKILL", windowsHide: true });
15102
+ const run = spawnSync13("git", ["for-each-ref", "--format=%(refname)%00%(objecttype)%00%(*objecttype)%00%(symref)"], { cwd, encoding: "utf8", timeout: 20000, killSignal: "SIGKILL", windowsHide: true });
15056
15103
  if (run.status !== 0)
15057
15104
  return null;
15058
15105
  const refs = new Map;
@@ -15653,7 +15700,7 @@ function computeLane(input) {
15653
15700
  }
15654
15701
  function untrackedStat(cwd, file) {
15655
15702
  try {
15656
- const bytes = readFileSync6(path20.join(cwd, file));
15703
+ const bytes = readFileSync7(path20.join(cwd, file));
15657
15704
  if (bytes.includes(0))
15658
15705
  return { path: file, added: 0, deleted: 0, binary: true };
15659
15706
  const text = bytes.toString("utf8");
@@ -15684,7 +15731,7 @@ function cosmeticFiles(cwd, fork, head) {
15684
15731
  let after = blobs.get(entry.newBlob);
15685
15732
  if (!after && head === null && ABSENT.test(entry.newBlob))
15686
15733
  try {
15687
- after = readFileSync6(path20.join(cwd, entry.path));
15734
+ after = readFileSync7(path20.join(cwd, entry.path));
15688
15735
  } catch {
15689
15736
  after = undefined;
15690
15737
  }
@@ -15861,7 +15908,7 @@ var err = (code, error, unblock) => ({
15861
15908
  ...unblock ? { unblock } : {}
15862
15909
  });
15863
15910
  var gitRun2 = (cwd, args, timeoutMs = GIT_TIMEOUTS.local) => {
15864
- const run = spawnSync13("git", args, {
15911
+ const run = spawnSync14("git", args, {
15865
15912
  cwd,
15866
15913
  encoding: "utf8",
15867
15914
  timeout: timeoutMs,
@@ -17198,7 +17245,7 @@ var compareCodeUnits2 = (left, right) => {
17198
17245
  return left.length - right.length;
17199
17246
  };
17200
17247
  var gitPaths = (root) => {
17201
- const result = spawnSync14("git", ["ls-files", "-z", "--cached", "--others", "--exclude-standard"], {
17248
+ const result = spawnSync15("git", ["ls-files", "-z", "--cached", "--others", "--exclude-standard"], {
17202
17249
  cwd: root,
17203
17250
  encoding: "buffer"
17204
17251
  });
@@ -17211,7 +17258,7 @@ var gitPaths = (root) => {
17211
17258
  };
17212
17259
  }
17213
17260
  const paths = result.stdout ? result.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path23.sep).join("/")) : [];
17214
- const stagedDeleted = spawnSync14("git", ["diff", "--cached", "--name-only", "--diff-filter=D", "-z"], { cwd: root, encoding: "buffer" });
17261
+ const stagedDeleted = spawnSync15("git", ["diff", "--cached", "--name-only", "--diff-filter=D", "-z"], { cwd: root, encoding: "buffer" });
17215
17262
  if (stagedDeleted.status !== 0) {
17216
17263
  const stderr = stagedDeleted.stderr?.toString("utf8") ?? "";
17217
17264
  if (!/not a git repository/i.test(stderr))
@@ -17342,7 +17389,7 @@ function captureCandidate(root, scope, environment = []) {
17342
17389
  const values = supplied.toSorted((left, right) => compareCodeUnits2(left.name, right.name)).map(({ name, value }) => ({ name, value, refs: [] }));
17343
17390
  if (values.some(({ value }) => value === null))
17344
17391
  completeness = "uncertain";
17345
- const headResult = spawnSync14("git", ["rev-parse", "HEAD"], { cwd: checkout, encoding: "utf8" });
17392
+ const headResult = spawnSync15("git", ["rev-parse", "HEAD"], { cwd: checkout, encoding: "utf8" });
17346
17393
  if (headResult.status !== 0 && !/not a git repository/i.test(headResult.stderr ?? ""))
17347
17394
  completeness = "uncertain";
17348
17395
  const head = headResult.status === 0 ? headResult.stdout.trim() : null;
@@ -17869,7 +17916,7 @@ function boundTaskSummary(summary) {
17869
17916
 
17870
17917
  // packages/workit-core/src/core/model-fallback.ts
17871
17918
  import { createHash as createHash14 } from "node:crypto";
17872
- import { mkdirSync as mkdirSync4, readFileSync as readFileSync8, renameSync as renameSync3, writeFileSync as writeFileSync4 } from "node:fs";
17919
+ import { mkdirSync as mkdirSync4, readFileSync as readFileSync9, renameSync as renameSync3, writeFileSync as writeFileSync4 } from "node:fs";
17873
17920
  import path24 from "node:path";
17874
17921
  var LIMITS_FILE = "model-limits.json";
17875
17922
  var DEFAULT_LIMIT_WINDOW_MS = 5 * 3600000;
@@ -17896,7 +17943,7 @@ var empty = () => ({ exhausted: {}, seen: {}, redispatched: {} });
17896
17943
  var storePath = (stateDir) => path24.join(stateDir ?? resolveStateDir(), LIMITS_FILE);
17897
17944
  var readStore = (stateDir) => {
17898
17945
  try {
17899
- const parsed = JSON.parse(readFileSync8(storePath(stateDir), "utf8"));
17946
+ const parsed = JSON.parse(readFileSync9(storePath(stateDir), "utf8"));
17900
17947
  const store = empty();
17901
17948
  for (const key of ["exhausted", "seen", "redispatched"])
17902
17949
  if (parsed[key] && typeof parsed[key] === "object")
@@ -18507,19 +18554,18 @@ var exportDigest = (bundle) => sha256({
18507
18554
  task: bundle.task
18508
18555
  });
18509
18556
  // packages/workit-core/src/core/route-intent.ts
18510
- import { spawnSync as spawnSync16 } from "node:child_process";
18557
+ import { spawnSync as spawnSync17 } from "node:child_process";
18511
18558
  import { existsSync as existsSync10 } from "node:fs";
18512
18559
  import path29 from "node:path";
18513
18560
 
18514
18561
  // packages/workit-core/src/hooks/raw-git.ts
18515
- import { spawnSync as spawnSync15 } from "node:child_process";
18562
+ import { spawnSync as spawnSync16 } from "node:child_process";
18516
18563
  import { createHash as createHash16 } from "node:crypto";
18517
18564
  import fs20 from "node:fs";
18518
- import os7 from "node:os";
18565
+ import os6 from "node:os";
18519
18566
  import path28 from "node:path";
18520
18567
 
18521
18568
  // packages/workit-core/src/autonomy.ts
18522
- import os6 from "node:os";
18523
18569
  import path26 from "node:path";
18524
18570
 
18525
18571
  // packages/workit-core/src/core/eval-world.ts
@@ -18532,30 +18578,43 @@ var inside2 = (dir, file) => {
18532
18578
  const rel = path25.relative(dir, file);
18533
18579
  return !rel.startsWith("..") && !path25.isAbsolute(rel);
18534
18580
  };
18535
- var evalWorldEntry = (cwd) => {
18581
+ var evalWorld = (cwd) => {
18536
18582
  const raw = process.env[EVAL_WORLD_ENV];
18537
18583
  if (!raw || !path25.isAbsolute(raw))
18538
18584
  return null;
18539
18585
  try {
18540
18586
  const world = realpathSync5(raw);
18541
- if (!inside2(realpathSync5(os5.tmpdir()), world) || !inside2(world, realpathSync5(cwd)) || !existsSync9(path25.join(world, EVAL_WORLD_MARKER)))
18542
- return null;
18543
- return loadWorkspacesFrom(path25.join(world, "config"))[0] ?? null;
18587
+ return inside2(realpathSync5(os5.tmpdir()), world) && inside2(world, realpathSync5(cwd)) && existsSync9(path25.join(world, EVAL_WORLD_MARKER)) ? world : null;
18544
18588
  } catch {
18545
18589
  return null;
18546
18590
  }
18547
18591
  };
18548
-
18549
- // packages/workit-core/src/autonomy.ts
18550
- var accountHome2 = () => {
18592
+ var evalWorldEntry = (cwd) => {
18593
+ const world = evalWorld(cwd);
18551
18594
  try {
18552
- return os6.userInfo().homedir;
18595
+ return world ? loadWorkspacesFrom(path25.join(world, "config"))[0] ?? null : null;
18553
18596
  } catch {
18554
- return os6.homedir();
18597
+ return null;
18555
18598
  }
18556
18599
  };
18557
- var grantsHome = { resolve: accountHome2 };
18558
- var grantsDir = () => configDir({ HOME: grantsHome.resolve() });
18600
+
18601
+ // packages/workit-core/src/autonomy.ts
18602
+ var grantsHome = { resolve: accountHome };
18603
+ var accountDir = () => {
18604
+ const home = grantsHome.resolve();
18605
+ return home === null ? null : configDir({ HOME: home });
18606
+ };
18607
+ var grantsDir = () => accountDir() ?? resolveConfigDir();
18608
+ var NO_ACCOUNT = "no OS account record answered (core/account-home.ts), so no grants are read: the D4 defaults apply";
18609
+ var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
18610
+ var resolveFrom = (cwd, name) => {
18611
+ const dir = accountDir();
18612
+ return dir === null ? null : resolveWorkspaceFrom(cwd, dir, name);
18613
+ };
18614
+ var shownGrantsDir = () => {
18615
+ const world = evalWorld(process.cwd());
18616
+ return world ? path26.join(world, "config") : accountDir();
18617
+ };
18559
18618
  var benchWorld = (cwd) => {
18560
18619
  const entry = evalWorldEntry(cwd);
18561
18620
  if (!entry)
@@ -18575,8 +18634,11 @@ var benchWorld = (cwd) => {
18575
18634
  };
18576
18635
  };
18577
18636
  var grantsOverride = () => {
18637
+ const shown = shownGrantsDir();
18638
+ if (shown === null)
18639
+ return NO_ACCOUNT;
18578
18640
  const configured = path26.resolve(resolveConfigDir());
18579
- return configured === path26.resolve(grantsDir()) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path26.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
18641
+ return configured === path26.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path26.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
18580
18642
  };
18581
18643
  var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
18582
18644
  var DEFAULT_GRANTS = Object.freeze({
@@ -18702,7 +18764,7 @@ function capAt(named, where, by, why, main = false) {
18702
18764
  try {
18703
18765
  if (where instanceof Error)
18704
18766
  throw where;
18705
- folder = autonomyOf(typeof where === "string" ? resolveWorkspaceFrom(where, grantsDir()) : where.entry);
18767
+ folder = autonomyOf(typeof where === "string" ? resolveFrom(where) : where.entry);
18706
18768
  } catch (error) {
18707
18769
  none = error.message;
18708
18770
  }
@@ -18746,7 +18808,10 @@ function resolveAutonomy(cwd, target) {
18746
18808
  if (override)
18747
18809
  return { ...autonomyOf(null), note: override };
18748
18810
  const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
18749
- let autonomy = autonomyOf(resolveWorkspaceFrom(cwd, grantsDir(), name) ?? world);
18811
+ const real = resolveFrom(cwd, name);
18812
+ let autonomy = autonomyOf(real ?? world);
18813
+ if (!real && world)
18814
+ autonomy.world = evalWorld(cwd) ?? undefined;
18750
18815
  if (name)
18751
18816
  autonomy = capAt(autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
18752
18817
  const above = checkoutsAbove(cwd);
@@ -18755,7 +18820,7 @@ function resolveAutonomy(cwd, target) {
18755
18820
  return capAtRemotes(autonomy, cwd, target);
18756
18821
  }
18757
18822
  function capAtRemotes(autonomy, cwd, target) {
18758
- const claiming = loadWorkspacesFrom(grantsDir()).filter((entry) => entry.remotes?.length);
18823
+ const claiming = entriesIn(accountDir()).filter((entry) => entry.remotes?.length);
18759
18824
  if (claiming.length === 0)
18760
18825
  return autonomy;
18761
18826
  const remotes = target === undefined ? checkoutRemotes(cwd) : typeof target === "function" ? target() : target;
@@ -18770,15 +18835,15 @@ function capAtRemotes(autonomy, cwd, target) {
18770
18835
  }
18771
18836
  return capped;
18772
18837
  }
18773
- var grantsMatter = (kind) => !grantsOverride() && loadWorkspacesFrom(grantsDir()).some((entry) => {
18838
+ var grantsMatter = (kind) => !grantsOverride() && entriesIn(accountDir()).some((entry) => {
18774
18839
  const autonomy = autonomyOf(entry);
18775
18840
  return entry.remotes?.length || autonomy.grants[kind] === false || autonomy.configured.length > 0 && !autonomy.accountConfigured;
18776
18841
  });
18777
- var remotesClaimed = (dir = grantsDir()) => loadWorkspacesFrom(dir).some((entry) => entry.remotes?.length);
18778
- function targetClaims(target, dir = grantsDir()) {
18842
+ var remotesClaimed = (dir = accountDir()) => entriesIn(dir).some((entry) => entry.remotes?.length);
18843
+ function targetClaims(target, dir = accountDir()) {
18779
18844
  if (target instanceof Error)
18780
18845
  return target;
18781
- const claiming = loadWorkspacesFrom(dir).filter((entry) => entry.remotes?.length);
18846
+ const claiming = entriesIn(dir).filter((entry) => entry.remotes?.length);
18782
18847
  return target.remotes.flatMap((remote) => claiming.flatMap((entry) => {
18783
18848
  const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
18784
18849
  return pattern ? [{ url: remote.url, workspace: entry.name, pattern }] : [];
@@ -18816,7 +18881,7 @@ function rawGrantDenial(cwd, kind, target) {
18816
18881
  const claims = targetClaims(lazy());
18817
18882
  if (claims instanceof Error)
18818
18883
  return { error: `${kind}: ${claims.message}`, unblock: "name a target workit can resolve" };
18819
- const entries = loadWorkspacesFrom(grantsDir());
18884
+ const entries = entriesIn(accountDir());
18820
18885
  const strict = claims.find(({ workspace: name }) => {
18821
18886
  const entry = entries.find((item) => item.name === name);
18822
18887
  return entry && autonomyOf(entry).grants[kind] === false;
@@ -19448,7 +19513,7 @@ var joinDir = (base, raw) => {
19448
19513
  const next = raw.replace(HERE, ".");
19449
19514
  if (base === undefined || /[$`*?]/.test(next) || next === "-")
19450
19515
  return;
19451
- const expanded = next === "~" || next.startsWith("~/") ? path28.join(os7.homedir(), next.slice(1)) : next;
19516
+ const expanded = next === "~" || next.startsWith("~/") ? path28.join(os6.homedir(), next.slice(1)) : next;
19452
19517
  return base === null || isAbsolute(expanded) ? expanded : path28.join(base, expanded);
19453
19518
  };
19454
19519
  var rebase = (base, inner) => inner === null ? base : inner === undefined ? undefined : joinDir(base, inner);
@@ -19850,7 +19915,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
19850
19915
  }
19851
19916
  if (CD.has(name)) {
19852
19917
  const target = cdTarget(words);
19853
- dir = target === null ? os7.homedir() : joinDir(dir, target);
19918
+ dir = target === null ? os6.homedir() : joinDir(dir, target);
19854
19919
  } else if (PUSHD.has(name)) {
19855
19920
  const target = cdTarget(words);
19856
19921
  stack.push(dir);
@@ -20393,7 +20458,7 @@ var gitConfig = (dir, invocation, cache) => {
20393
20458
  if (cached)
20394
20459
  return cached;
20395
20460
  const config = new Map;
20396
- const listed = spawnSync15("git", [...invocation.config ?? [], "config", "-z", "--list"], {
20461
+ const listed = spawnSync16("git", [...invocation.config ?? [], "config", "-z", "--list"], {
20397
20462
  cwd: dir,
20398
20463
  encoding: "utf8",
20399
20464
  timeout: 3000,
@@ -20566,7 +20631,7 @@ var refFacts = (repo, remote) => {
20566
20631
  tags: new Set,
20567
20632
  remoteHeads: new Set
20568
20633
  };
20569
- const listed = spawnSync15("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/tags", `refs/remotes/${remote}`], { cwd: repo.dir, encoding: "utf8", timeout: 5000 });
20634
+ const listed = spawnSync16("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/tags", `refs/remotes/${remote}`], { cwd: repo.dir, encoding: "utf8", timeout: 5000 });
20570
20635
  const remotePrefix = `refs/remotes/${remote}/`;
20571
20636
  for (const ref of (listed.stdout ?? "").split(`
20572
20637
  `)) {
@@ -20583,7 +20648,7 @@ var globBranches = (repo, glob) => {
20583
20648
  const source = glob.source.startsWith("refs/") ? glob.source : `refs/heads/${glob.source}`;
20584
20649
  const [sourcePrefix, sourceSuffix = ""] = source.split("*");
20585
20650
  const [destinationPrefix, destinationSuffix = ""] = glob.destination.split("*");
20586
- const listed = spawnSync15("git", [
20651
+ const listed = spawnSync16("git", [
20587
20652
  "for-each-ref",
20588
20653
  "--format=%(refname)",
20589
20654
  sourcePrefix.slice(0, sourcePrefix.lastIndexOf("/") + 1)
@@ -20660,7 +20725,7 @@ var tagRefusal = (action, facts, dir) => {
20660
20725
  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}`)} (${shape} 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")}).`;
20661
20726
  };
20662
20727
  var remoteHeads = (repo, remote) => {
20663
- const listed = spawnSync15("git", ["ls-remote", "--heads", remote], {
20728
+ const listed = spawnSync16("git", ["ls-remote", "--heads", remote], {
20664
20729
  cwd: repo.dir,
20665
20730
  encoding: "utf8",
20666
20731
  timeout: 3000,
@@ -20881,7 +20946,7 @@ var cdCommitCall = (input, command, target, repo) => {
20881
20946
  if (!messages.length)
20882
20947
  return null;
20883
20948
  if (!all) {
20884
- const staged = spawnSync15("git", ["diff", "--cached", "--quiet"], {
20949
+ const staged = spawnSync16("git", ["diff", "--cached", "--quiet"], {
20885
20950
  cwd: target,
20886
20951
  timeout: 5000
20887
20952
  });
@@ -21042,7 +21107,7 @@ function noteRawCommit(input, command, key) {
21042
21107
  } catch {}
21043
21108
  }
21044
21109
  var headCommit = (dir) => {
21045
- const run = spawnSync15("git", [
21110
+ const run = spawnSync16("git", [
21046
21111
  "log",
21047
21112
  "-1",
21048
21113
  "--format=%H%x1f%ct%x1f%s%x1f%(trailers:key=Workit-Session,valueonly,separator=%x2c)"
@@ -21254,7 +21319,7 @@ var targetsOf = (invocations) => invocations.flatMap((invocation) => invocation.
21254
21319
  branch,
21255
21320
  dir: invocation.dir
21256
21321
  })) : []);
21257
- var localBranchExists = (dir, branch) => spawnSync16("git", ["show-ref", "--verify", "--quiet", `refs/heads/${branch}`], {
21322
+ var localBranchExists = (dir, branch) => spawnSync17("git", ["show-ref", "--verify", "--quiet", `refs/heads/${branch}`], {
21258
21323
  cwd: dir,
21259
21324
  stdio: "ignore",
21260
21325
  timeout: 5000
@@ -23260,8 +23325,8 @@ class WorkitCore {
23260
23325
  }
23261
23326
  }
23262
23327
  // packages/workit-core/src/core/repo-context.ts
23263
- import { spawnSync as spawnSync17 } from "node:child_process";
23264
- import { existsSync as existsSync11, readFileSync as readFileSync9, readdirSync as readdirSync4 } from "node:fs";
23328
+ import { spawnSync as spawnSync18 } from "node:child_process";
23329
+ import { existsSync as existsSync11, readFileSync as readFileSync10, readdirSync as readdirSync4 } from "node:fs";
23265
23330
  import path30 from "node:path";
23266
23331
  var isSafeContextRange = (value) => value.length <= 4096 && (() => {
23267
23332
  try {
@@ -23289,7 +23354,7 @@ var invalidRange = (cwd) => ({
23289
23354
  cwd
23290
23355
  });
23291
23356
  var runGit = (cwd, args) => {
23292
- const result = spawnSync17("git", args, { cwd, encoding: "utf8" });
23357
+ const result = spawnSync18("git", args, { cwd, encoding: "utf8" });
23293
23358
  return {
23294
23359
  stdout: (result.stdout ?? "").trimEnd(),
23295
23360
  stderr: (result.stderr ?? "").trimEnd(),
@@ -23446,7 +23511,7 @@ var packageScripts = (cwd, keys) => {
23446
23511
  if (!existsSync11(pkgPath))
23447
23512
  return [];
23448
23513
  try {
23449
- const pkg = JSON.parse(readFileSync9(pkgPath, "utf8"));
23514
+ const pkg = JSON.parse(readFileSync10(pkgPath, "utf8"));
23450
23515
  return keys.filter((k) => pkg.scripts && typeof pkg.scripts[k] === "string").map((k) => `${k}: ${pkg.scripts?.[k]}`);
23451
23516
  } catch {
23452
23517
  return [];
@@ -23480,7 +23545,7 @@ var documentationFiles = (cwd) => {
23480
23545
  var readTrimmed2 = (file, maxLines) => {
23481
23546
  if (!existsSync11(file))
23482
23547
  return "";
23483
- const lines = readFileSync9(file, "utf8").split(`
23548
+ const lines = readFileSync10(file, "utf8").split(`
23484
23549
  `);
23485
23550
  return lines.slice(0, maxLines).join(`
23486
23551
  `);
@@ -23668,7 +23733,7 @@ function docsRefreshContext(root, range) {
23668
23733
  const pkgPath = path30.join(cwd, "package.json");
23669
23734
  if (existsSync11(pkgPath)) {
23670
23735
  try {
23671
- const pkg = JSON.parse(readFileSync9(pkgPath, "utf8"));
23736
+ const pkg = JSON.parse(readFileSync10(pkgPath, "utf8"));
23672
23737
  stdout += JSON.stringify({ name: pkg.name, version: pkg.version, scripts: pkg.scripts }, null, 2) + `
23673
23738
  `;
23674
23739
  } catch {}
@@ -23750,12 +23815,12 @@ function releaseNotesContext(root, rangeOrTag) {
23750
23815
  }
23751
23816
 
23752
23817
  // packages/workit-core/src/core/tracker-issues.ts
23753
- import { spawnSync as spawnSync19 } from "node:child_process";
23818
+ import { spawnSync as spawnSync20 } from "node:child_process";
23754
23819
 
23755
23820
  // packages/workit-core/src/core/pr-create.ts
23756
23821
  import fs21 from "node:fs";
23757
23822
  import path31 from "node:path";
23758
- import { spawnSync as spawnSync18 } from "node:child_process";
23823
+ import { spawnSync as spawnSync19 } from "node:child_process";
23759
23824
  import { pathToFileURL } from "node:url";
23760
23825
  // packages/workit-core/src/forge/pr-body.ts
23761
23826
  function parseGhIssue(value) {
@@ -23790,7 +23855,7 @@ function whichOnPath(tool) {
23790
23855
  }
23791
23856
  var hostingCliAvailable = (provider) => whichOnPath(provider === "gitlab" ? "glab" : "gh") !== null;
23792
23857
  var pushRemote = (cwd) => {
23793
- const result = spawnSync18("git", ["remote", "get-url", "--push", "--all", "origin"], {
23858
+ const result = spawnSync19("git", ["remote", "get-url", "--push", "--all", "origin"], {
23794
23859
  cwd,
23795
23860
  ...LOCAL
23796
23861
  });
@@ -23826,7 +23891,7 @@ var pushTargetIsStable = (cwd, remote) => {
23826
23891
  const target = safePushUrl(remote);
23827
23892
  if (!target)
23828
23893
  return false;
23829
- const result = spawnSync18("git", ["config", "--get-regexp", "^url\\..*\\.(insteadof|pushinsteadof)$"], { cwd, ...LOCAL });
23894
+ const result = spawnSync19("git", ["config", "--get-regexp", "^url\\..*\\.(insteadof|pushinsteadof)$"], { cwd, ...LOCAL });
23830
23895
  if (result.status !== 0 && result.status !== 1)
23831
23896
  return false;
23832
23897
  const prefixes = (result.stdout ?? "").split(/\r?\n/u).map((line) => line.trim().slice(line.trim().indexOf(" ") + 1)).filter(Boolean);
@@ -23854,7 +23919,7 @@ var defaultCli = (bin, available) => {
23854
23919
  if (!available)
23855
23920
  return null;
23856
23921
  return (args, root) => {
23857
- const out = spawnSync19(bin, args, {
23922
+ const out = spawnSync20(bin, args, {
23858
23923
  cwd: root,
23859
23924
  encoding: "utf8",
23860
23925
  env: { ...process.env, PATH: process.env.PATH ?? "" }
@@ -23944,7 +24009,7 @@ var ASSET_ROOT = assetRoot();
23944
24009
  var resolveWorkspaceRoot = (explicit) => explicit || process.cwd();
23945
24010
 
23946
24011
  // packages/workit-core/src/core/youtrack-ytrack.ts
23947
- import { spawnSync as spawnSync20 } from "node:child_process";
24012
+ import { spawnSync as spawnSync21 } from "node:child_process";
23948
24013
 
23949
24014
  // packages/workit-core/src/forge/exec.ts
23950
24015
  import fs22 from "node:fs";
@@ -23986,7 +24051,7 @@ function ytrackRunner(env, host, timeoutMs = TIMEOUT_MS) {
23986
24051
  const exe = findYtrack(env);
23987
24052
  if (!exe)
23988
24053
  return { status: null, stdout: "", stderr: "", missing: true };
23989
- const result = spawnSync20(exe, args, {
24054
+ const result = spawnSync21(exe, args, {
23990
24055
  encoding: "utf8",
23991
24056
  env: { ...env, NO_COLOR: "1", ...host ? { YTRACK_HOST: host } : {} },
23992
24057
  timeout: timeoutMs,
@@ -24469,7 +24534,7 @@ function resolveInside(root, candidate) {
24469
24534
  }
24470
24535
  function run2(root, executable, args, env = {}) {
24471
24536
  const cwd = realpathSync8(root);
24472
- const result = spawnSync21(executable, args, {
24537
+ const result = spawnSync22(executable, args, {
24473
24538
  cwd,
24474
24539
  encoding: "utf8",
24475
24540
  env: { ...process.env, ...env }
@@ -24711,7 +24776,7 @@ var isAllowedWorkitCommand = (command) => {
24711
24776
  };
24712
24777
  // packages/workit-core/src/core/heavy-rules.ts
24713
24778
  import fs24 from "node:fs";
24714
- import os8 from "node:os";
24779
+ import os7 from "node:os";
24715
24780
  import path36 from "node:path";
24716
24781
  var EMPTY2 = () => ({ deny: [], allow: [] });
24717
24782
  var readText3 = (file) => {
@@ -24769,7 +24834,7 @@ var projectDirs = (cwd) => {
24769
24834
  return dirs;
24770
24835
  }
24771
24836
  };
24772
- var homeOf = (env) => env.HOME || os8.homedir();
24837
+ var homeOf = (env) => env.HOME || os7.homedir();
24773
24838
  var CLAUDE_MANAGED = {
24774
24839
  linux: "/etc/claude-code/managed-settings.json",
24775
24840
  darwin: "/Library/Application Support/ClaudeCode/managed-settings.json",
@@ -25490,20 +25555,20 @@ function heavyGate(cwd, command, options) {
25490
25555
  }
25491
25556
  // packages/workit-core/src/hooks/write-gate.ts
25492
25557
  import { existsSync as existsSync13, realpathSync as realpathSync9, statSync as statSync5 } from "node:fs";
25493
- import os10 from "node:os";
25558
+ import os9 from "node:os";
25494
25559
  import path40 from "node:path";
25495
25560
 
25496
25561
  // packages/workit-core/src/core/live-session.ts
25497
- import { spawnSync as spawnSync22 } from "node:child_process";
25562
+ import { spawnSync as spawnSync23 } from "node:child_process";
25498
25563
  import { createHash as createHash17 } from "node:crypto";
25499
25564
  import fs27 from "node:fs";
25500
- import os9 from "node:os";
25565
+ import os8 from "node:os";
25501
25566
  import path39 from "node:path";
25502
25567
  var LIVE_SESSION_TTL_MS = 15 * 60000;
25503
25568
  var HEARTBEAT_EVERY_MS = 30000;
25504
25569
  var liveProbe = {
25505
25570
  platform: process.platform,
25506
- run: (args) => spawnSync22("ps", args, { encoding: "utf8", timeout: 2000 }).stdout ?? "",
25571
+ run: (args) => spawnSync23("ps", args, { encoding: "utf8", timeout: 2000 }).stdout ?? "",
25507
25572
  start: (pid) => processStartOf(pid)
25508
25573
  };
25509
25574
  var leadOf = (session) => session.split(":")[0].replace(/-w-.*$/su, "") || session;
@@ -25623,7 +25688,7 @@ var isLive = (marker, deps) => {
25623
25688
  const age = ageOf2(marker, deps.now ?? new Date);
25624
25689
  if (age > (deps.ttlMs ?? LIVE_SESSION_TTL_MS))
25625
25690
  return false;
25626
- if (marker.machine !== (deps.machine ?? os9.hostname()) || marker.pid === null)
25691
+ if (marker.machine !== (deps.machine ?? os8.hostname()) || marker.pid === null)
25627
25692
  return true;
25628
25693
  if (!(deps.alive ?? processAlive)(marker.pid))
25629
25694
  return false;
@@ -25652,7 +25717,7 @@ var liveConflict = (target, owner, deps = {}) => {
25652
25717
  const marker = readMarker(file);
25653
25718
  if (!marker || sameLead(marker, owner) || !isLive(marker, deps))
25654
25719
  return null;
25655
- if (sameOwner(marker, owner, deps.machine ?? os9.hostname()))
25720
+ if (sameOwner(marker, owner, deps.machine ?? os8.hostname()))
25656
25721
  return null;
25657
25722
  return { marker, file, ageMs: ageOf2(marker, deps.now ?? new Date), checkout };
25658
25723
  } catch {
@@ -25666,7 +25731,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
25666
25731
  return;
25667
25732
  const file = markerFile2(checkout);
25668
25733
  const now = deps.now ?? new Date;
25669
- const machine = deps.machine ?? os9.hostname();
25734
+ const machine = deps.machine ?? os8.hostname();
25670
25735
  const current = readMarker(file);
25671
25736
  if (current) {
25672
25737
  const age = ageOf2(current, now);
@@ -26193,7 +26258,7 @@ var cdInto = (dir, words, strict = false, vars = new Map) => {
26193
26258
  return lost;
26194
26259
  if (dir === undefined)
26195
26260
  return lost;
26196
- return target === undefined ? os10.homedir() : path40.resolve(dir, target);
26261
+ return target === undefined ? os9.homedir() : path40.resolve(dir, target);
26197
26262
  };
26198
26263
  var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
26199
26264
  var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
@@ -26395,7 +26460,7 @@ var mktempPath = (value, dir) => {
26395
26460
  template = arg;
26396
26461
  }
26397
26462
  if (base === null && (temp || template === undefined))
26398
- base = os10.tmpdir();
26463
+ base = os9.tmpdir();
26399
26464
  const name = homeExpanded(template ?? "tmp.XXXXXXXXXX");
26400
26465
  if (path40.isAbsolute(name))
26401
26466
  return name;
@@ -26406,7 +26471,7 @@ var mktempPath = (value, dir) => {
26406
26471
  };
26407
26472
  var homeExpanded = (file) => {
26408
26473
  const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
26409
- return match ? (process.env.HOME || os10.homedir()) + file.slice(match[0].length) : file;
26474
+ return match ? (process.env.HOME || os9.homedir()) + file.slice(match[0].length) : file;
26410
26475
  };
26411
26476
  var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherited = new Map) => {
26412
26477
  const targets = [];
@@ -26803,7 +26868,7 @@ function beforeWriteGate(cwd, paths) {
26803
26868
  }
26804
26869
  }
26805
26870
  // packages/workit-core/src/hooks/stop.ts
26806
- import { spawnSync as spawnSync23 } from "node:child_process";
26871
+ import { spawnSync as spawnSync24 } from "node:child_process";
26807
26872
 
26808
26873
  // packages/workit-core/src/ci-waiter.ts
26809
26874
  import fs28 from "node:fs";
@@ -26902,7 +26967,7 @@ var asksUser = (message) => {
26902
26967
  };
26903
26968
  var short = (sha) => (sha ?? "?").slice(0, 12);
26904
26969
  var gitList = (cwd, args) => {
26905
- const run = spawnSync23("git", args, {
26970
+ const run = spawnSync24("git", args, {
26906
26971
  cwd,
26907
26972
  encoding: "utf8",
26908
26973
  timeout: 3000,
@@ -28178,7 +28243,7 @@ if (false) {}
28178
28243
  import path47 from "node:path";
28179
28244
 
28180
28245
  // packages/workit-core/src/core/gitignore.ts
28181
- import { existsSync as existsSync14, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "node:fs";
28246
+ import { existsSync as existsSync14, readFileSync as readFileSync11, writeFileSync as writeFileSync5 } from "node:fs";
28182
28247
  import path43 from "node:path";
28183
28248
  var GITIGNORE_ENTRIES = [
28184
28249
  "# workit: SDD working state (never commit)",
@@ -28200,7 +28265,7 @@ var ensureProjectGitignore = (workspaceRoot, confirmed) => {
28200
28265
  if (!confirmed)
28201
28266
  return { ok: false, error: "confirmed: true required" };
28202
28267
  const file = path43.join(workspaceRoot, ".gitignore");
28203
- const existing = existsSync14(file) ? readFileSync10(file, "utf8") : "";
28268
+ const existing = existsSync14(file) ? readFileSync11(file, "utf8") : "";
28204
28269
  const existingLines = new Set(existing.split(`
28205
28270
  `).map((l) => l.trim()).filter(Boolean));
28206
28271
  const added = [];
@@ -28226,7 +28291,7 @@ var ensureProjectGitignore = (workspaceRoot, confirmed) => {
28226
28291
  };
28227
28292
 
28228
28293
  // packages/workit-core/src/core/hygiene.ts
28229
- import { existsSync as existsSync15, readFileSync as readFileSync11, readdirSync as readdirSync5, writeFileSync as writeFileSync6 } from "node:fs";
28294
+ import { existsSync as existsSync15, readFileSync as readFileSync12, readdirSync as readdirSync5, writeFileSync as writeFileSync6 } from "node:fs";
28230
28295
  import path44 from "node:path";
28231
28296
  var repoRoot3 = assetRoot();
28232
28297
  var templatesDir = () => path44.join(repoRoot3, "templates", "hygiene");
@@ -28234,7 +28299,7 @@ var packageJson = (root) => {
28234
28299
  if (!existsSync15(path44.join(root, "package.json")))
28235
28300
  return null;
28236
28301
  try {
28237
- return JSON.parse(readFileSync11(path44.join(root, "package.json"), "utf8"));
28302
+ return JSON.parse(readFileSync12(path44.join(root, "package.json"), "utf8"));
28238
28303
  } catch {
28239
28304
  return null;
28240
28305
  }
@@ -28273,7 +28338,7 @@ var planHygieneFiles = (root, opts = {}) => {
28273
28338
  const tpl = path44.join(templatesDir(), file);
28274
28339
  if (!existsSync15(tpl))
28275
28340
  continue;
28276
- const content = readFileSync11(tpl, "utf8").replace(/<PROJECT>/g, path44.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
28341
+ const content = readFileSync12(tpl, "utf8").replace(/<PROJECT>/g, path44.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
28277
28342
  planned.push({ path: path44.join(root, file), content });
28278
28343
  }
28279
28344
  return planned;
@@ -28292,15 +28357,15 @@ var ensureHygieneFiles = (root, opts) => {
28292
28357
  // packages/workit-core/src/core/init.ts
28293
28358
  import fs30 from "node:fs";
28294
28359
  import path46 from "node:path";
28295
- import { spawnSync as spawnSync24 } from "node:child_process";
28360
+ import { spawnSync as spawnSync25 } from "node:child_process";
28296
28361
 
28297
28362
  // packages/workit-core/src/core/workspace-branch-policy.ts
28298
- import { mkdirSync as mkdirSync5, readFileSync as readFileSync12, renameSync as renameSync4, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "node:fs";
28363
+ import { mkdirSync as mkdirSync5, readFileSync as readFileSync13, renameSync as renameSync4, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "node:fs";
28299
28364
  import path45 from "node:path";
28300
28365
  import { isDeepStrictEqual } from "node:util";
28301
28366
  var readFileSafe = (p) => {
28302
28367
  try {
28303
- return readFileSync12(p, "utf8");
28368
+ return readFileSync13(p, "utf8");
28304
28369
  } catch {
28305
28370
  return null;
28306
28371
  }
@@ -28414,7 +28479,7 @@ var resolveInitProvider = (cwd) => {
28414
28479
  return env.toLowerCase();
28415
28480
  const root = cwd ?? process.env.WORKIT_WORKSPACE_ROOT ?? process.cwd();
28416
28481
  try {
28417
- const out = spawnSync24("git", ["remote", "get-url", "origin"], {
28482
+ const out = spawnSync25("git", ["remote", "get-url", "origin"], {
28418
28483
  cwd: root,
28419
28484
  encoding: "utf8"
28420
28485
  });
@@ -28779,13 +28844,13 @@ var workerCoordinatorFor = (task, worker) => {
28779
28844
  };
28780
28845
 
28781
28846
  // packages/workit-core/src/fanout.ts
28782
- import { spawnSync as spawnSync28 } from "node:child_process";
28847
+ import { spawnSync as spawnSync29 } from "node:child_process";
28783
28848
  import { createHash as createHash19 } from "node:crypto";
28784
28849
  import fs32 from "node:fs";
28785
28850
  import path52 from "node:path";
28786
28851
 
28787
28852
  // packages/workit-core/src/fanout-landed.ts
28788
- import { spawnSync as spawnSync25 } from "node:child_process";
28853
+ import { spawnSync as spawnSync26 } from "node:child_process";
28789
28854
  function trunkRefresher(cwd, trunk) {
28790
28855
  const match = /^refs\/remotes\/([^/]+)\/(.+)$/u.exec(trunk);
28791
28856
  if (!match)
@@ -28874,7 +28939,7 @@ function trunkPatchIds(ctx, fork) {
28874
28939
  "--"
28875
28940
  ]);
28876
28941
  if (log.ok && log.stdout.trim()) {
28877
- const run = spawnSync25("git", ["patch-id", "--stable"], {
28942
+ const run = spawnSync26("git", ["patch-id", "--stable"], {
28878
28943
  cwd: ctx.cwd,
28879
28944
  input: log.stdout,
28880
28945
  encoding: "utf8",
@@ -29009,18 +29074,18 @@ var GRANT_TTL_MS2 = 2 * 3600000;
29009
29074
  var NOTICE_TTL_MS = 7 * 86400000;
29010
29075
 
29011
29076
  // packages/workit-core/src/stack.ts
29012
- import { spawnSync as spawnSync27 } from "node:child_process";
29077
+ import { spawnSync as spawnSync28 } from "node:child_process";
29013
29078
  import { createHash as createHash18, randomBytes as randomBytes4 } from "node:crypto";
29014
29079
  import fs31 from "node:fs";
29015
29080
  import path51 from "node:path";
29016
29081
 
29017
29082
  // packages/workit-core/src/git/ops.ts
29018
- import { spawnSync as spawnSync26 } from "node:child_process";
29019
- import { copyFileSync as copyFileSync2, existsSync as existsSync16, readdirSync as readdirSync6, readFileSync as readFileSync13, rmSync as rmSync4 } from "node:fs";
29083
+ import { spawnSync as spawnSync27 } from "node:child_process";
29084
+ import { copyFileSync as copyFileSync2, existsSync as existsSync16, readdirSync as readdirSync6, readFileSync as readFileSync14, rmSync as rmSync4 } from "node:fs";
29020
29085
  import path50 from "node:path";
29021
29086
  var COMMIT_TIMEOUT_MS = 10 * 60000;
29022
29087
  var git5 = (cwd, args, options = {}) => {
29023
- const result = spawnSync26("git", args, {
29088
+ const result = spawnSync27("git", args, {
29024
29089
  cwd,
29025
29090
  encoding: "utf8",
29026
29091
  env: { ...options.env ?? process.env, GIT_TERMINAL_PROMPT: "0" },
@@ -29061,7 +29126,7 @@ function operationInProgress(cwd) {
29061
29126
  if (index === 0 && existsSync16(path50.join(marker, "amend")) && !conflicted()) {
29062
29127
  let headName = "";
29063
29128
  try {
29064
- headName = readFileSync13(path50.join(marker, "head-name"), "utf8").trim();
29129
+ headName = readFileSync14(path50.join(marker, "head-name"), "utf8").trim();
29065
29130
  } catch {}
29066
29131
  const branch = headName.startsWith("refs/heads/") ? headName.slice("refs/heads/".length) : null;
29067
29132
  return { operation, commitAllowed: branch !== null, branch };
@@ -29127,7 +29192,7 @@ var stackDeps = {
29127
29192
  rebaseTimeoutMs: Number(process.env.WORKIT_STACK_REBASE_TIMEOUT_MS) || 10 * 60000
29128
29193
  };
29129
29194
  var gitRun4 = (cwd, args, timeoutMs = GIT_TIMEOUTS.local) => {
29130
- const run = spawnSync27("git", args, {
29195
+ const run = spawnSync28("git", args, {
29131
29196
  cwd,
29132
29197
  encoding: "utf8",
29133
29198
  timeout: timeoutMs,
@@ -29358,7 +29423,7 @@ function findCycle(slices) {
29358
29423
  return null;
29359
29424
  }
29360
29425
  var gitRun3 = (cwd, args, timeoutMs = GIT_TIMEOUTS.local) => {
29361
- const run = spawnSync28("git", args, {
29426
+ const run = spawnSync29("git", args, {
29362
29427
  cwd,
29363
29428
  encoding: "utf8",
29364
29429
  timeout: timeoutMs,
@@ -30687,7 +30752,7 @@ var createStopControl = (root, port) => {
30687
30752
  };
30688
30753
 
30689
30754
  // packages/workit-opencode/src/v2/registry.ts
30690
- import { existsSync as existsSync18, readFileSync as readFileSync14 } from "node:fs";
30755
+ import { existsSync as existsSync18, readFileSync as readFileSync15 } from "node:fs";
30691
30756
  import path55 from "node:path";
30692
30757
 
30693
30758
  // packages/workit-opencode/src/shared/assets.ts
@@ -30758,7 +30823,7 @@ var registerSkills = async (ctx) => {
30758
30823
  for (const [id, file] of packaged) {
30759
30824
  if (existing.has(id))
30760
30825
  continue;
30761
- const parsed = parseFrontmatter(readFileSync14(file, "utf8"));
30826
+ const parsed = parseFrontmatter(readFileSync15(file, "utf8"));
30762
30827
  editor.add({
30763
30828
  id,
30764
30829
  name: parsed.name || id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/opencode",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "private": false,
5
5
  "description": "Workit OpenCode plugin — native tools, adaptive policy, and sixteen method skills",
6
6
  "keywords": [
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@opencode/plugin": "2.0.18",
44
- "@workit-dev/core": "^1.8.0"
44
+ "@workit-dev/core": "^1.8.1"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24"