@workit-dev/codex 1.7.5 → 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.
@@ -278,9 +278,9 @@ var releaseTagPrefixOf = (workspaceRoot, policyPrefix) => {
278
278
  };
279
279
 
280
280
  // packages/workit-core/src/core/workspaces.ts
281
- import { spawnSync as spawnSync4 } from "node:child_process";
281
+ import { spawnSync as spawnSync5 } from "node:child_process";
282
282
  import { createHash as createHash2 } from "node:crypto";
283
- import { existsSync as existsSync2, lstatSync as lstatSync2, readFileSync as readFileSync3, realpathSync as realpathSync2 } from "node:fs";
283
+ import { existsSync as existsSync2, lstatSync as lstatSync2, readFileSync as readFileSync4, realpathSync as realpathSync2 } from "node:fs";
284
284
  import path5 from "node:path";
285
285
 
286
286
  // node_modules/zod/v4/core/util.js
@@ -6157,9 +6157,8 @@ function superRefine(fn, params) {
6157
6157
  return _superRefine(fn, params);
6158
6158
  }
6159
6159
  // packages/workit-core/src/core/remotes.ts
6160
- import { lstatSync, readFileSync as readFileSync2, realpathSync, statSync } from "node:fs";
6161
- import { spawnSync as spawnSync3 } from "node:child_process";
6162
- import os2 from "node:os";
6160
+ import { lstatSync, readFileSync as readFileSync3, realpathSync, statSync } from "node:fs";
6161
+ import { spawnSync as spawnSync4 } from "node:child_process";
6163
6162
  import path4 from "node:path";
6164
6163
 
6165
6164
  // packages/workit-core/src/git/rev.ts
@@ -6899,6 +6898,56 @@ function resolveSshHost(alias, sshConfig) {
6899
6898
  return { hostname: (hostname ?? alias).replace(/\.$/u, ""), port };
6900
6899
  }
6901
6900
 
6901
+ // packages/workit-core/src/core/account-home.ts
6902
+ import { spawnSync as spawnSync3 } from "node:child_process";
6903
+ import { readFileSync as readFileSync2 } from "node:fs";
6904
+ import os2 from "node:os";
6905
+ var WINDOWS = "C:\\Windows";
6906
+ var SYSTEM32 = `${WINDOWS}\\System32\\`;
6907
+ var PROFILES = "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\";
6908
+ var childEnv = (platform) => platform === "win32" ? { SystemRoot: WINDOWS } : {};
6909
+ var hostIo = {
6910
+ bun: Boolean(process.versions.bun),
6911
+ uid: process.getuid?.() ?? -1,
6912
+ userInfo: () => os2.userInfo().homedir,
6913
+ passwd: () => readFileSync2("/etc/passwd", "utf8"),
6914
+ run: (file, args) => {
6915
+ const done = spawnSync3(file, args, {
6916
+ encoding: "utf8",
6917
+ env: childEnv(process.platform),
6918
+ timeout: 3000,
6919
+ windowsHide: true
6920
+ });
6921
+ return done.status === 0 ? done.stdout : "";
6922
+ }
6923
+ };
6924
+ var field = (text, uid, at) => text.split(`
6925
+ `).filter((line) => !line.startsWith("#")).map((line) => line.split(":")).find((fields) => fields[2] === uid)?.[at];
6926
+ var profilePath = (raw) => {
6927
+ const value = raw.replaceAll(/%SystemDrive%/giu, WINDOWS.slice(0, 2)).replaceAll(/%SystemRoot%/giu, WINDOWS);
6928
+ return /^[A-Za-z]:\\/u.test(value) && !value.includes("%") ? value : null;
6929
+ };
6930
+ var accountHome = (platform = process.platform, io = hostIo) => {
6931
+ try {
6932
+ if (!io.bun)
6933
+ return io.userInfo() || null;
6934
+ if (platform === "win32") {
6935
+ const sid = /S-1-[\d-]+/u.exec(io.run(`${SYSTEM32}whoami.exe`, ["/user", "/fo", "csv"]));
6936
+ const key = sid && io.run(`${SYSTEM32}reg.exe`, ["query", PROFILES + sid[0], "/v", "ProfileImagePath"]);
6937
+ const raw = /ProfileImagePath\s+REG_\w+\s+(.+)/u.exec(key || "")?.[1]?.trim();
6938
+ return raw ? profilePath(raw) : null;
6939
+ }
6940
+ const uid = String(io.uid);
6941
+ let passwd = "";
6942
+ try {
6943
+ passwd = io.passwd();
6944
+ } catch {}
6945
+ 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;
6946
+ } catch {
6947
+ return null;
6948
+ }
6949
+ };
6950
+
6902
6951
  // packages/workit-core/src/core/remotes.ts
6903
6952
  var FORGE_SCHEMES = new Set(["ssh", "git", "http", "https", "git+ssh", "ssh+git"]);
6904
6953
  var SSH_SCHEMES = new Set(["ssh", "git+ssh", "ssh+git"]);
@@ -6908,15 +6957,11 @@ var SSH_443 = {
6908
6957
  };
6909
6958
  var WINDOWS_DRIVE = /^[A-Za-z]:[\\/]/u;
6910
6959
  var SCP_LIKE = /^(?:[^@/\\]+@)?([^/\\:]+):(.+)$/u;
6911
- var accountHome = () => {
6912
- try {
6913
- return os2.userInfo().homedir;
6914
- } catch {
6915
- return os2.homedir();
6916
- }
6917
- };
6918
6960
  var sshSeam = {
6919
- read: () => readSshConfig(accountHome())
6961
+ read: () => {
6962
+ const home = accountHome();
6963
+ return home === null ? { text: "", home: "" } : readSshConfig(home);
6964
+ }
6920
6965
  };
6921
6966
  var forgeKey = (rawHost, repo, ssh) => {
6922
6967
  let host = rawHost.toLowerCase().replace(/\.$/u, "");
@@ -6963,7 +7008,7 @@ var gitDirAt = (at, depth = 0) => {
6963
7008
  return null;
6964
7009
  try {
6965
7010
  if (statSync(real).isFile()) {
6966
- const pointer = /^gitdir:\s*(.+?)\s*$/mu.exec(readFileSync2(real, "utf8"))?.[1];
7011
+ const pointer = /^gitdir:\s*(.+?)\s*$/mu.exec(readFileSync3(real, "utf8"))?.[1];
6967
7012
  if (!pointer)
6968
7013
  return null;
6969
7014
  const target = path4.isAbsolute(pointer) ? pointer : `${path4.dirname(real)}/${pointer}`;
@@ -6971,7 +7016,7 @@ var gitDirAt = (at, depth = 0) => {
6971
7016
  }
6972
7017
  let common;
6973
7018
  try {
6974
- common = readFileSync2(`${real}/commondir`, "utf8").trim();
7019
+ common = readFileSync3(`${real}/commondir`, "utf8").trim();
6975
7020
  } catch {}
6976
7021
  if (common !== undefined) {
6977
7022
  lstatSync(`${real}/HEAD`);
@@ -7075,7 +7120,7 @@ var checkoutRemotes = (cwd) => {
7075
7120
  const env = { ...process.env };
7076
7121
  for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
7077
7122
  delete env[name];
7078
- const git = (args) => spawnSync3("git", args, {
7123
+ const git = (args) => spawnSync4("git", args, {
7079
7124
  cwd,
7080
7125
  env,
7081
7126
  encoding: "utf8",
@@ -7126,6 +7171,8 @@ var userLevel = (scope, origin) => {
7126
7171
  return false;
7127
7172
  const file = realOrSelf(origin.slice("file:".length));
7128
7173
  const home = userGitSeam.home();
7174
+ if (home === null)
7175
+ return false;
7129
7176
  return [path4.join(home, ".gitconfig"), path4.join(home, ".config", "git", "config")].map(realOrSelf).includes(file);
7130
7177
  };
7131
7178
  var escapeRegex2 = (value) => value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
@@ -7136,7 +7183,7 @@ var transportOverride = (git, remote, vars) => {
7136
7183
  const execPath = vars.GIT_EXEC_PATH;
7137
7184
  if (execPath) {
7138
7185
  const { GIT_EXEC_PATH: _set, ...rest } = vars;
7139
- const own = spawnSync3("git", ["--exec-path"], {
7186
+ const own = spawnSync4("git", ["--exec-path"], {
7140
7187
  env: rest,
7141
7188
  encoding: "utf8"
7142
7189
  });
@@ -7172,7 +7219,7 @@ var pushTarget = (cwd, remote, replay = {}) => {
7172
7219
  delete env[name];
7173
7220
  if (!remote || remote.startsWith("-"))
7174
7221
  return Error(`push remote ${JSON.stringify(remote)} cannot be resolved`);
7175
- const git = (args) => spawnSync3("git", [...replay.config ?? [], ...args], {
7222
+ const git = (args) => spawnSync4("git", [...replay.config ?? [], ...args], {
7176
7223
  cwd,
7177
7224
  env,
7178
7225
  encoding: "utf8",
@@ -7404,7 +7451,7 @@ var readWorkspacesResult = (dir = configDir()) => {
7404
7451
  const file = path5.join(dir, "workspaces.json");
7405
7452
  let raw;
7406
7453
  try {
7407
- raw = readFileSync3(file, "utf8");
7454
+ raw = readFileSync4(file, "utf8");
7408
7455
  } catch (error) {
7409
7456
  if (error.code === "ENOENT")
7410
7457
  return {
@@ -7525,7 +7572,7 @@ var probeCheckout = (cwd) => {
7525
7572
  for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
7526
7573
  delete env[name];
7527
7574
  const git = (args) => {
7528
- const run = spawnSync4("git", args, {
7575
+ const run = spawnSync5("git", args, {
7529
7576
  cwd,
7530
7577
  env,
7531
7578
  encoding: "utf8",
@@ -7722,7 +7769,7 @@ var matchRuntimeWorkspace = (cwd, dir = configDir()) => {
7722
7769
  const file = path5.join(dir, "workspaces.json");
7723
7770
  let raw;
7724
7771
  try {
7725
- raw = readFileSync3(file, "utf8");
7772
+ raw = readFileSync4(file, "utf8");
7726
7773
  } catch (error) {
7727
7774
  if (error.code === "ENOENT")
7728
7775
  return null;
@@ -7798,7 +7845,7 @@ var modelSources = (cwd, dir) => {
7798
7845
  }
7799
7846
  } catch {}
7800
7847
  try {
7801
- const document = JSON.parse(readFileSync3(path5.join(dir ?? configDir(), "workspaces.json"), "utf8"));
7848
+ const document = JSON.parse(readFileSync4(path5.join(dir ?? configDir(), "workspaces.json"), "utf8"));
7802
7849
  if (document && typeof document === "object" && !Array.isArray(document))
7803
7850
  out.push({
7804
7851
  name: "global",
@@ -7867,7 +7914,7 @@ import path6 from "node:path";
7867
7914
 
7868
7915
  // packages/workit-core/src/core/release-tracks.ts
7869
7916
  import { createHash as createHash3 } from "node:crypto";
7870
- import { spawnSync as spawnSync5 } from "node:child_process";
7917
+ import { spawnSync as spawnSync6 } from "node:child_process";
7871
7918
  class ReleaseTrackError extends Error {
7872
7919
  }
7873
7920
  var KNOWN_FIELDS = new Set([
@@ -8152,7 +8199,7 @@ function resolveReleaseTrack(input) {
8152
8199
  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 ")}`);
8153
8200
  }
8154
8201
  var git2 = (cwd, args) => {
8155
- const run = spawnSync5("git", args, {
8202
+ const run = spawnSync6("git", args, {
8156
8203
  cwd,
8157
8204
  encoding: "utf8",
8158
8205
  timeout: 20000,
@@ -8648,7 +8695,7 @@ var isProtectedTarget = (root, name) => {
8648
8695
 
8649
8696
  // packages/workit-core/src/core/model-fallback.ts
8650
8697
  import { createHash as createHash5 } from "node:crypto";
8651
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, renameSync, writeFileSync as writeFileSync2 } from "node:fs";
8698
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync5, renameSync, writeFileSync as writeFileSync2 } from "node:fs";
8652
8699
  import path7 from "node:path";
8653
8700
 
8654
8701
  // packages/workit-core/src/core/logger.ts
@@ -8720,7 +8767,7 @@ var empty = () => ({ exhausted: {}, seen: {}, redispatched: {} });
8720
8767
  var storePath = (stateDir) => path7.join(stateDir ?? resolveStateDir(), LIMITS_FILE);
8721
8768
  var readStore = (stateDir) => {
8722
8769
  try {
8723
- const parsed = JSON.parse(readFileSync4(storePath(stateDir), "utf8"));
8770
+ const parsed = JSON.parse(readFileSync5(storePath(stateDir), "utf8"));
8724
8771
  const store = empty();
8725
8772
  for (const key of ["exhausted", "seen", "redispatched"])
8726
8773
  if (parsed[key] && typeof parsed[key] === "object")
@@ -9182,13 +9229,13 @@ ${table}` : BOOTSTRAP;
9182
9229
  };
9183
9230
 
9184
9231
  // packages/workit-core/src/store/paths.ts
9185
- import { spawnSync as spawnSync6 } from "node:child_process";
9232
+ import { spawnSync as spawnSync7 } from "node:child_process";
9186
9233
  import { createHash as createHash6 } from "node:crypto";
9187
9234
  import fs4 from "node:fs";
9188
9235
  import path8 from "node:path";
9189
9236
  var NOT_A_REPO = /not a git repository \(or any (of the parent directories|parent up to)/u;
9190
9237
  var gitRun = (cwd, args) => {
9191
- const run = spawnSync6("git", args, {
9238
+ const run = spawnSync7("git", args, {
9192
9239
  cwd,
9193
9240
  encoding: "utf8",
9194
9241
  timeout: 20000,
@@ -10280,7 +10327,7 @@ function candidateDigest(input) {
10280
10327
  // packages/workit-core/src/core/task-evaluation.ts
10281
10328
  import { createHash as createHash10 } from "node:crypto";
10282
10329
  import * as fs13 from "node:fs";
10283
- import { spawnSync as spawnSync11 } from "node:child_process";
10330
+ import { spawnSync as spawnSync12 } from "node:child_process";
10284
10331
  import path18 from "node:path";
10285
10332
 
10286
10333
  // packages/workit-core/src/core/task-read.ts
@@ -10904,7 +10951,7 @@ var packageRoot = () => {
10904
10951
  };
10905
10952
 
10906
10953
  // packages/workit-core/src/core/store-lock.ts
10907
- import { spawnSync as spawnSync7 } from "node:child_process";
10954
+ import { spawnSync as spawnSync8 } from "node:child_process";
10908
10955
  import fs8 from "node:fs";
10909
10956
  import { hostname } from "node:os";
10910
10957
  var metadataLockSchema = object({
@@ -10955,7 +11002,7 @@ var readProcStat = (pid) => {
10955
11002
  };
10956
11003
  var psStart = (pid) => {
10957
11004
  try {
10958
- const run = spawnSync7("ps", ["-o", "lstart=", "-p", String(pid)], {
11005
+ const run = spawnSync8("ps", ["-o", "lstart=", "-p", String(pid)], {
10959
11006
  encoding: "utf8",
10960
11007
  timeout: 1000,
10961
11008
  env: { ...process.env, LC_ALL: "C" }
@@ -12181,19 +12228,19 @@ import { existsSync as existsSync6 } from "node:fs";
12181
12228
  import path17 from "node:path";
12182
12229
 
12183
12230
  // packages/workit-core/src/ledger.ts
12184
- import { spawnSync as spawnSync10 } from "node:child_process";
12231
+ import { spawnSync as spawnSync11 } from "node:child_process";
12185
12232
  import { createHash as createHash9, randomBytes as randomBytes3 } from "node:crypto";
12186
12233
  import fs12 from "node:fs";
12187
12234
  import path16 from "node:path";
12188
12235
 
12189
12236
  // packages/workit-core/src/core/policy/bookkeeping.ts
12190
- import { spawnSync as spawnSync8 } from "node:child_process";
12237
+ import { spawnSync as spawnSync9 } from "node:child_process";
12191
12238
  var OID = /^[0-9a-f]{40,64}$/u;
12192
12239
  var safe = (value) => value.length > 0 && !value.startsWith("-");
12193
12240
  function replayTree(cwd, from, fromFork, toFork) {
12194
12241
  if (![from, fromFork, toFork].every(safe))
12195
12242
  return null;
12196
- const run = spawnSync8("git", ["merge-tree", "--write-tree", "--no-messages", `--merge-base=${fromFork}`, toFork, from], {
12243
+ const run = spawnSync9("git", ["merge-tree", "--write-tree", "--no-messages", `--merge-base=${fromFork}`, toFork, from], {
12197
12244
  cwd,
12198
12245
  encoding: "utf8",
12199
12246
  timeout: GIT_TIMEOUTS.worktree,
@@ -12264,11 +12311,11 @@ function bookkeepingPaths(cwd, input) {
12264
12311
  }
12265
12312
 
12266
12313
  // packages/workit-core/src/core/policy/lane.ts
12267
- import { existsSync as existsSync5, readFileSync as readFileSync6 } from "node:fs";
12314
+ import { existsSync as existsSync5, readFileSync as readFileSync7 } from "node:fs";
12268
12315
  import path14 from "node:path";
12269
12316
 
12270
12317
  // packages/workit-core/src/git/default-base.ts
12271
- import { spawnSync as spawnSync9 } from "node:child_process";
12318
+ import { spawnSync as spawnSync10 } from "node:child_process";
12272
12319
  var safeRef = (value) => value.length > 0 && !value.startsWith("-");
12273
12320
  var trackTrunk = (cwd) => {
12274
12321
  try {
@@ -12318,7 +12365,7 @@ var shorten = (table, full) => {
12318
12365
  return full;
12319
12366
  };
12320
12367
  function refTable(cwd) {
12321
- const run = spawnSync9("git", ["for-each-ref", "--format=%(refname)%00%(objecttype)%00%(*objecttype)%00%(symref)"], { cwd, encoding: "utf8", timeout: 20000, killSignal: "SIGKILL", windowsHide: true });
12368
+ const run = spawnSync10("git", ["for-each-ref", "--format=%(refname)%00%(objecttype)%00%(*objecttype)%00%(symref)"], { cwd, encoding: "utf8", timeout: 20000, killSignal: "SIGKILL", windowsHide: true });
12322
12369
  if (run.status !== 0)
12323
12370
  return null;
12324
12371
  const refs = new Map;
@@ -12919,7 +12966,7 @@ function computeLane(input) {
12919
12966
  }
12920
12967
  function untrackedStat(cwd, file) {
12921
12968
  try {
12922
- const bytes = readFileSync6(path14.join(cwd, file));
12969
+ const bytes = readFileSync7(path14.join(cwd, file));
12923
12970
  if (bytes.includes(0))
12924
12971
  return { path: file, added: 0, deleted: 0, binary: true };
12925
12972
  const text = bytes.toString("utf8");
@@ -12950,7 +12997,7 @@ function cosmeticFiles(cwd, fork, head) {
12950
12997
  let after = blobs.get(entry.newBlob);
12951
12998
  if (!after && head === null && ABSENT.test(entry.newBlob))
12952
12999
  try {
12953
- after = readFileSync6(path14.join(cwd, entry.path));
13000
+ after = readFileSync7(path14.join(cwd, entry.path));
12954
13001
  } catch {
12955
13002
  after = undefined;
12956
13003
  }
@@ -13265,7 +13312,7 @@ var err = (code, error, unblock) => ({
13265
13312
  ...unblock ? { unblock } : {}
13266
13313
  });
13267
13314
  var gitRun2 = (cwd, args, timeoutMs = GIT_TIMEOUTS.local) => {
13268
- const run = spawnSync10("git", args, {
13315
+ const run = spawnSync11("git", args, {
13269
13316
  cwd,
13270
13317
  encoding: "utf8",
13271
13318
  timeout: timeoutMs,
@@ -14485,7 +14532,7 @@ var compareCodeUnits2 = (left, right) => {
14485
14532
  return left.length - right.length;
14486
14533
  };
14487
14534
  var gitPaths = (root) => {
14488
- const result = spawnSync11("git", ["ls-files", "-z", "--cached", "--others", "--exclude-standard"], {
14535
+ const result = spawnSync12("git", ["ls-files", "-z", "--cached", "--others", "--exclude-standard"], {
14489
14536
  cwd: root,
14490
14537
  encoding: "buffer"
14491
14538
  });
@@ -14498,7 +14545,7 @@ var gitPaths = (root) => {
14498
14545
  };
14499
14546
  }
14500
14547
  const paths = result.stdout ? result.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path18.sep).join("/")) : [];
14501
- const stagedDeleted = spawnSync11("git", ["diff", "--cached", "--name-only", "--diff-filter=D", "-z"], { cwd: root, encoding: "buffer" });
14548
+ const stagedDeleted = spawnSync12("git", ["diff", "--cached", "--name-only", "--diff-filter=D", "-z"], { cwd: root, encoding: "buffer" });
14502
14549
  if (stagedDeleted.status !== 0) {
14503
14550
  const stderr = stagedDeleted.stderr?.toString("utf8") ?? "";
14504
14551
  if (!/not a git repository/i.test(stderr))
@@ -14629,7 +14676,7 @@ function captureCandidate(root, scope, environment = []) {
14629
14676
  const values = supplied.toSorted((left, right) => compareCodeUnits2(left.name, right.name)).map(({ name, value }) => ({ name, value, refs: [] }));
14630
14677
  if (values.some(({ value }) => value === null))
14631
14678
  completeness = "uncertain";
14632
- const headResult = spawnSync11("git", ["rev-parse", "HEAD"], { cwd: checkout, encoding: "utf8" });
14679
+ const headResult = spawnSync12("git", ["rev-parse", "HEAD"], { cwd: checkout, encoding: "utf8" });
14633
14680
  if (headResult.status !== 0 && !/not a git repository/i.test(headResult.stderr ?? ""))
14634
14681
  completeness = "uncertain";
14635
14682
  const head = headResult.status === 0 ? headResult.stdout.trim() : null;
@@ -15443,19 +15490,18 @@ var seedTurnContext = (input, descriptor, text = turnContextText(input, descript
15443
15490
  clearTurnDigest(file);
15444
15491
  };
15445
15492
  // packages/workit-core/src/core/route-intent.ts
15446
- import { spawnSync as spawnSync13 } from "node:child_process";
15493
+ import { spawnSync as spawnSync14 } from "node:child_process";
15447
15494
  import { existsSync as existsSync9 } from "node:fs";
15448
15495
  import path24 from "node:path";
15449
15496
 
15450
15497
  // packages/workit-core/src/hooks/raw-git.ts
15451
- import { spawnSync as spawnSync12 } from "node:child_process";
15498
+ import { spawnSync as spawnSync13 } from "node:child_process";
15452
15499
  import { createHash as createHash13 } from "node:crypto";
15453
15500
  import fs16 from "node:fs";
15454
- import os6 from "node:os";
15501
+ import os5 from "node:os";
15455
15502
  import path23 from "node:path";
15456
15503
 
15457
15504
  // packages/workit-core/src/autonomy.ts
15458
- import os5 from "node:os";
15459
15505
  import path21 from "node:path";
15460
15506
 
15461
15507
  // packages/workit-core/src/core/eval-world.ts
@@ -15468,30 +15514,43 @@ var inside2 = (dir, file) => {
15468
15514
  const rel = path20.relative(dir, file);
15469
15515
  return !rel.startsWith("..") && !path20.isAbsolute(rel);
15470
15516
  };
15471
- var evalWorldEntry = (cwd) => {
15517
+ var evalWorld = (cwd) => {
15472
15518
  const raw = process.env[EVAL_WORLD_ENV];
15473
15519
  if (!raw || !path20.isAbsolute(raw))
15474
15520
  return null;
15475
15521
  try {
15476
15522
  const world = realpathSync6(raw);
15477
- if (!inside2(realpathSync6(os4.tmpdir()), world) || !inside2(world, realpathSync6(cwd)) || !existsSync8(path20.join(world, EVAL_WORLD_MARKER)))
15478
- return null;
15479
- return loadWorkspacesFrom(path20.join(world, "config"))[0] ?? null;
15523
+ return inside2(realpathSync6(os4.tmpdir()), world) && inside2(world, realpathSync6(cwd)) && existsSync8(path20.join(world, EVAL_WORLD_MARKER)) ? world : null;
15480
15524
  } catch {
15481
15525
  return null;
15482
15526
  }
15483
15527
  };
15484
-
15485
- // packages/workit-core/src/autonomy.ts
15486
- var accountHome2 = () => {
15528
+ var evalWorldEntry = (cwd) => {
15529
+ const world = evalWorld(cwd);
15487
15530
  try {
15488
- return os5.userInfo().homedir;
15531
+ return world ? loadWorkspacesFrom(path20.join(world, "config"))[0] ?? null : null;
15489
15532
  } catch {
15490
- return os5.homedir();
15533
+ return null;
15491
15534
  }
15492
15535
  };
15493
- var grantsHome = { resolve: accountHome2 };
15494
- var grantsDir = () => configDir2({ HOME: grantsHome.resolve() });
15536
+
15537
+ // packages/workit-core/src/autonomy.ts
15538
+ var grantsHome = { resolve: accountHome };
15539
+ var accountDir = () => {
15540
+ const home = grantsHome.resolve();
15541
+ return home === null ? null : configDir2({ HOME: home });
15542
+ };
15543
+ var grantsDir = () => accountDir() ?? resolveConfigDir();
15544
+ var NO_ACCOUNT = "no OS account record answered (core/account-home.ts), so no grants are read: the D4 defaults apply";
15545
+ var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
15546
+ var resolveFrom = (cwd, name) => {
15547
+ const dir = accountDir();
15548
+ return dir === null ? null : resolveWorkspaceFrom(cwd, dir, name);
15549
+ };
15550
+ var shownGrantsDir = () => {
15551
+ const world = evalWorld(process.cwd());
15552
+ return world ? path21.join(world, "config") : accountDir();
15553
+ };
15495
15554
  var benchWorld = (cwd) => {
15496
15555
  const entry = evalWorldEntry(cwd);
15497
15556
  if (!entry)
@@ -15511,8 +15570,11 @@ var benchWorld = (cwd) => {
15511
15570
  };
15512
15571
  };
15513
15572
  var grantsOverride = () => {
15573
+ const shown = shownGrantsDir();
15574
+ if (shown === null)
15575
+ return NO_ACCOUNT;
15514
15576
  const configured = path21.resolve(resolveConfigDir());
15515
- return configured === path21.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 ${path21.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
15577
+ return configured === path21.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 ${path21.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
15516
15578
  };
15517
15579
  var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
15518
15580
  var DEFAULT_GRANTS = Object.freeze({
@@ -15638,7 +15700,7 @@ function capAt(named, where, by, why, main = false) {
15638
15700
  try {
15639
15701
  if (where instanceof Error)
15640
15702
  throw where;
15641
- folder = autonomyOf(typeof where === "string" ? resolveWorkspaceFrom(where, grantsDir()) : where.entry);
15703
+ folder = autonomyOf(typeof where === "string" ? resolveFrom(where) : where.entry);
15642
15704
  } catch (error) {
15643
15705
  none = error.message;
15644
15706
  }
@@ -15682,7 +15744,10 @@ function resolveAutonomy(cwd, target) {
15682
15744
  if (override)
15683
15745
  return { ...autonomyOf(null), note: override };
15684
15746
  const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
15685
- let autonomy = autonomyOf(resolveWorkspaceFrom(cwd, grantsDir(), name) ?? world);
15747
+ const real = resolveFrom(cwd, name);
15748
+ let autonomy = autonomyOf(real ?? world);
15749
+ if (!real && world)
15750
+ autonomy.world = evalWorld(cwd) ?? undefined;
15686
15751
  if (name)
15687
15752
  autonomy = capAt(autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
15688
15753
  const above = checkoutsAbove(cwd);
@@ -15691,7 +15756,7 @@ function resolveAutonomy(cwd, target) {
15691
15756
  return capAtRemotes(autonomy, cwd, target);
15692
15757
  }
15693
15758
  function capAtRemotes(autonomy, cwd, target) {
15694
- const claiming = loadWorkspacesFrom(grantsDir()).filter((entry) => entry.remotes?.length);
15759
+ const claiming = entriesIn(accountDir()).filter((entry) => entry.remotes?.length);
15695
15760
  if (claiming.length === 0)
15696
15761
  return autonomy;
15697
15762
  const remotes = target === undefined ? checkoutRemotes(cwd) : typeof target === "function" ? target() : target;
@@ -15706,15 +15771,15 @@ function capAtRemotes(autonomy, cwd, target) {
15706
15771
  }
15707
15772
  return capped;
15708
15773
  }
15709
- var grantsMatter = (kind) => !grantsOverride() && loadWorkspacesFrom(grantsDir()).some((entry) => {
15774
+ var grantsMatter = (kind) => !grantsOverride() && entriesIn(accountDir()).some((entry) => {
15710
15775
  const autonomy = autonomyOf(entry);
15711
15776
  return entry.remotes?.length || autonomy.grants[kind] === false || autonomy.configured.length > 0 && !autonomy.accountConfigured;
15712
15777
  });
15713
- var remotesClaimed = (dir = grantsDir()) => loadWorkspacesFrom(dir).some((entry) => entry.remotes?.length);
15714
- function targetClaims(target, dir = grantsDir()) {
15778
+ var remotesClaimed = (dir = accountDir()) => entriesIn(dir).some((entry) => entry.remotes?.length);
15779
+ function targetClaims(target, dir = accountDir()) {
15715
15780
  if (target instanceof Error)
15716
15781
  return target;
15717
- const claiming = loadWorkspacesFrom(dir).filter((entry) => entry.remotes?.length);
15782
+ const claiming = entriesIn(dir).filter((entry) => entry.remotes?.length);
15718
15783
  return target.remotes.flatMap((remote) => claiming.flatMap((entry) => {
15719
15784
  const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
15720
15785
  return pattern ? [{ url: remote.url, workspace: entry.name, pattern }] : [];
@@ -15752,7 +15817,7 @@ function rawGrantDenial(cwd, kind, target) {
15752
15817
  const claims = targetClaims(lazy());
15753
15818
  if (claims instanceof Error)
15754
15819
  return { error: `${kind}: ${claims.message}`, unblock: "name a target workit can resolve" };
15755
- const entries = loadWorkspacesFrom(grantsDir());
15820
+ const entries = entriesIn(accountDir());
15756
15821
  const strict = claims.find(({ workspace: name }) => {
15757
15822
  const entry = entries.find((item) => item.name === name);
15758
15823
  return entry && autonomyOf(entry).grants[kind] === false;
@@ -16406,7 +16471,7 @@ var joinDir = (base, raw) => {
16406
16471
  const next = raw.replace(HERE, ".");
16407
16472
  if (base === undefined || /[$`*?]/.test(next) || next === "-")
16408
16473
  return;
16409
- const expanded = next === "~" || next.startsWith("~/") ? path23.join(os6.homedir(), next.slice(1)) : next;
16474
+ const expanded = next === "~" || next.startsWith("~/") ? path23.join(os5.homedir(), next.slice(1)) : next;
16410
16475
  return base === null || isAbsolute(expanded) ? expanded : path23.join(base, expanded);
16411
16476
  };
16412
16477
  var rebase = (base, inner) => inner === null ? base : inner === undefined ? undefined : joinDir(base, inner);
@@ -16808,7 +16873,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
16808
16873
  }
16809
16874
  if (CD.has(name)) {
16810
16875
  const target = cdTarget(words);
16811
- dir = target === null ? os6.homedir() : joinDir(dir, target);
16876
+ dir = target === null ? os5.homedir() : joinDir(dir, target);
16812
16877
  } else if (PUSHD.has(name)) {
16813
16878
  const target = cdTarget(words);
16814
16879
  stack.push(dir);
@@ -17351,7 +17416,7 @@ var gitConfig = (dir, invocation, cache) => {
17351
17416
  if (cached)
17352
17417
  return cached;
17353
17418
  const config = new Map;
17354
- const listed = spawnSync12("git", [...invocation.config ?? [], "config", "-z", "--list"], {
17419
+ const listed = spawnSync13("git", [...invocation.config ?? [], "config", "-z", "--list"], {
17355
17420
  cwd: dir,
17356
17421
  encoding: "utf8",
17357
17422
  timeout: 3000,
@@ -17524,7 +17589,7 @@ var refFacts = (repo, remote) => {
17524
17589
  tags: new Set,
17525
17590
  remoteHeads: new Set
17526
17591
  };
17527
- const listed = spawnSync12("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/tags", `refs/remotes/${remote}`], { cwd: repo.dir, encoding: "utf8", timeout: 5000 });
17592
+ const listed = spawnSync13("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/tags", `refs/remotes/${remote}`], { cwd: repo.dir, encoding: "utf8", timeout: 5000 });
17528
17593
  const remotePrefix = `refs/remotes/${remote}/`;
17529
17594
  for (const ref of (listed.stdout ?? "").split(`
17530
17595
  `)) {
@@ -17541,7 +17606,7 @@ var globBranches = (repo, glob) => {
17541
17606
  const source = glob.source.startsWith("refs/") ? glob.source : `refs/heads/${glob.source}`;
17542
17607
  const [sourcePrefix, sourceSuffix = ""] = source.split("*");
17543
17608
  const [destinationPrefix, destinationSuffix = ""] = glob.destination.split("*");
17544
- const listed = spawnSync12("git", [
17609
+ const listed = spawnSync13("git", [
17545
17610
  "for-each-ref",
17546
17611
  "--format=%(refname)",
17547
17612
  sourcePrefix.slice(0, sourcePrefix.lastIndexOf("/") + 1)
@@ -17618,7 +17683,7 @@ var tagRefusal = (action, facts, dir) => {
17618
17683
  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")}).`;
17619
17684
  };
17620
17685
  var remoteHeads = (repo, remote) => {
17621
- const listed = spawnSync12("git", ["ls-remote", "--heads", remote], {
17686
+ const listed = spawnSync13("git", ["ls-remote", "--heads", remote], {
17622
17687
  cwd: repo.dir,
17623
17688
  encoding: "utf8",
17624
17689
  timeout: 3000,
@@ -17839,7 +17904,7 @@ var cdCommitCall = (input, command, target, repo) => {
17839
17904
  if (!messages.length)
17840
17905
  return null;
17841
17906
  if (!all) {
17842
- const staged = spawnSync12("git", ["diff", "--cached", "--quiet"], {
17907
+ const staged = spawnSync13("git", ["diff", "--cached", "--quiet"], {
17843
17908
  cwd: target,
17844
17909
  timeout: 5000
17845
17910
  });
@@ -18001,7 +18066,7 @@ function noteRawCommit(input, command, key) {
18001
18066
  } catch {}
18002
18067
  }
18003
18068
  var headCommit = (dir) => {
18004
- const run = spawnSync12("git", [
18069
+ const run = spawnSync13("git", [
18005
18070
  "log",
18006
18071
  "-1",
18007
18072
  "--format=%H%x1f%ct%x1f%s%x1f%(trailers:key=Workit-Session,valueonly,separator=%x2c)"
@@ -18225,7 +18290,7 @@ var targetsOf = (invocations) => invocations.flatMap((invocation) => invocation.
18225
18290
  branch,
18226
18291
  dir: invocation.dir
18227
18292
  })) : []);
18228
- var localBranchExists = (dir, branch) => spawnSync13("git", ["show-ref", "--verify", "--quiet", `refs/heads/${branch}`], {
18293
+ var localBranchExists = (dir, branch) => spawnSync14("git", ["show-ref", "--verify", "--quiet", `refs/heads/${branch}`], {
18229
18294
  cwd: dir,
18230
18295
  stdio: "ignore",
18231
18296
  timeout: 5000
@@ -18357,7 +18422,7 @@ var userOnlyWorkitCall = (command, dialect = "posix") => {
18357
18422
  };
18358
18423
  // packages/workit-core/src/core/heavy-rules.ts
18359
18424
  import fs17 from "node:fs";
18360
- import os7 from "node:os";
18425
+ import os6 from "node:os";
18361
18426
  import path25 from "node:path";
18362
18427
  var EMPTY2 = () => ({ deny: [], allow: [] });
18363
18428
  var readText3 = (file) => {
@@ -18415,7 +18480,7 @@ var projectDirs = (cwd) => {
18415
18480
  return dirs;
18416
18481
  }
18417
18482
  };
18418
- var homeOf = (env) => env.HOME || os7.homedir();
18483
+ var homeOf = (env) => env.HOME || os6.homedir();
18419
18484
  var CLAUDE_MANAGED = {
18420
18485
  linux: "/etc/claude-code/managed-settings.json",
18421
18486
  darwin: "/Library/Application Support/ClaudeCode/managed-settings.json",
@@ -19098,20 +19163,20 @@ var splitDenial = (plan) => ({
19098
19163
  });
19099
19164
  // packages/workit-core/src/hooks/write-gate.ts
19100
19165
  import { existsSync as existsSync10, realpathSync as realpathSync7, statSync as statSync3 } from "node:fs";
19101
- import os9 from "node:os";
19166
+ import os8 from "node:os";
19102
19167
  import path28 from "node:path";
19103
19168
 
19104
19169
  // packages/workit-core/src/core/live-session.ts
19105
- import { spawnSync as spawnSync14 } from "node:child_process";
19170
+ import { spawnSync as spawnSync15 } from "node:child_process";
19106
19171
  import { createHash as createHash14 } from "node:crypto";
19107
19172
  import fs19 from "node:fs";
19108
- import os8 from "node:os";
19173
+ import os7 from "node:os";
19109
19174
  import path27 from "node:path";
19110
19175
  var LIVE_SESSION_TTL_MS = 15 * 60000;
19111
19176
  var HEARTBEAT_EVERY_MS = 30000;
19112
19177
  var liveProbe = {
19113
19178
  platform: process.platform,
19114
- run: (args) => spawnSync14("ps", args, { encoding: "utf8", timeout: 2000 }).stdout ?? "",
19179
+ run: (args) => spawnSync15("ps", args, { encoding: "utf8", timeout: 2000 }).stdout ?? "",
19115
19180
  start: (pid) => processStartOf(pid)
19116
19181
  };
19117
19182
  var leadOf = (session) => session.split(":")[0].replace(/-w-.*$/su, "") || session;
@@ -19231,7 +19296,7 @@ var isLive = (marker, deps) => {
19231
19296
  const age = ageOf2(marker, deps.now ?? new Date);
19232
19297
  if (age > (deps.ttlMs ?? LIVE_SESSION_TTL_MS))
19233
19298
  return false;
19234
- if (marker.machine !== (deps.machine ?? os8.hostname()) || marker.pid === null)
19299
+ if (marker.machine !== (deps.machine ?? os7.hostname()) || marker.pid === null)
19235
19300
  return true;
19236
19301
  if (!(deps.alive ?? processAlive)(marker.pid))
19237
19302
  return false;
@@ -19260,7 +19325,7 @@ var liveConflict = (target, owner, deps = {}) => {
19260
19325
  const marker = readMarker(file);
19261
19326
  if (!marker || sameLead(marker, owner) || !isLive(marker, deps))
19262
19327
  return null;
19263
- if (sameOwner(marker, owner, deps.machine ?? os8.hostname()))
19328
+ if (sameOwner(marker, owner, deps.machine ?? os7.hostname()))
19264
19329
  return null;
19265
19330
  return { marker, file, ageMs: ageOf2(marker, deps.now ?? new Date), checkout };
19266
19331
  } catch {
@@ -19274,7 +19339,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
19274
19339
  return;
19275
19340
  const file = markerFile2(checkout);
19276
19341
  const now = deps.now ?? new Date;
19277
- const machine = deps.machine ?? os8.hostname();
19342
+ const machine = deps.machine ?? os7.hostname();
19278
19343
  const current = readMarker(file);
19279
19344
  if (current) {
19280
19345
  const age = ageOf2(current, now);
@@ -19801,7 +19866,7 @@ var cdInto = (dir, words, strict = false, vars = new Map) => {
19801
19866
  return lost;
19802
19867
  if (dir === undefined)
19803
19868
  return lost;
19804
- return target === undefined ? os9.homedir() : path28.resolve(dir, target);
19869
+ return target === undefined ? os8.homedir() : path28.resolve(dir, target);
19805
19870
  };
19806
19871
  var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
19807
19872
  var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
@@ -20003,7 +20068,7 @@ var mktempPath = (value, dir) => {
20003
20068
  template = arg;
20004
20069
  }
20005
20070
  if (base === null && (temp || template === undefined))
20006
- base = os9.tmpdir();
20071
+ base = os8.tmpdir();
20007
20072
  const name = homeExpanded(template ?? "tmp.XXXXXXXXXX");
20008
20073
  if (path28.isAbsolute(name))
20009
20074
  return name;
@@ -20014,7 +20079,7 @@ var mktempPath = (value, dir) => {
20014
20079
  };
20015
20080
  var homeExpanded = (file) => {
20016
20081
  const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
20017
- return match ? (process.env.HOME || os9.homedir()) + file.slice(match[0].length) : file;
20082
+ return match ? (process.env.HOME || os8.homedir()) + file.slice(match[0].length) : file;
20018
20083
  };
20019
20084
  var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherited = new Map) => {
20020
20085
  const targets = [];
@@ -20411,7 +20476,7 @@ function beforeWriteGate(cwd, paths) {
20411
20476
  }
20412
20477
  }
20413
20478
  // packages/workit-core/src/hooks/stop.ts
20414
- import { spawnSync as spawnSync15 } from "node:child_process";
20479
+ import { spawnSync as spawnSync16 } from "node:child_process";
20415
20480
 
20416
20481
  // packages/workit-core/src/ci-waiter.ts
20417
20482
  import fs20 from "node:fs";
@@ -20510,7 +20575,7 @@ var asksUser = (message) => {
20510
20575
  };
20511
20576
  var short = (sha) => (sha ?? "?").slice(0, 12);
20512
20577
  var gitList = (cwd, args) => {
20513
- const run = spawnSync15("git", args, {
20578
+ const run = spawnSync16("git", args, {
20514
20579
  cwd,
20515
20580
  encoding: "utf8",
20516
20581
  timeout: 3000,
@@ -22440,7 +22505,7 @@ var cdWorkitSplit = (command) => {
22440
22505
 
22441
22506
  // packages/workit-core/src/hooks/model-limit.ts
22442
22507
  import { closeSync as closeSync2, openSync as openSync2, readdirSync as readdirSync3, readSync, statSync as statSync5 } from "node:fs";
22443
- import os10 from "node:os";
22508
+ import os9 from "node:os";
22444
22509
  import path33 from "node:path";
22445
22510
  var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
22446
22511
  var WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
@@ -22646,7 +22711,7 @@ var listDir = (dir) => {
22646
22711
  };
22647
22712
  var SCAN_MS = 30 * 60000;
22648
22713
  var scanClaudeTranscripts = (cwd, env, now = new Date) => {
22649
- const projects = path33.join(env.CLAUDE_CONFIG_DIR || path33.join(env.HOME || os10.homedir(), ".claude"), "projects");
22714
+ const projects = path33.join(env.CLAUDE_CONFIG_DIR || path33.join(env.HOME || os9.homedir(), ".claude"), "projects");
22650
22715
  const project = path33.join(projects, claudeProjectSlug(cwd));
22651
22716
  const notes = [];
22652
22717
  const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path33.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));