@workit-dev/codex 2.27.13 → 2.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workit",
3
- "version": "2.27.13",
3
+ "version": "2.29.0",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -14733,6 +14733,101 @@ var checkoutRemotes = (cwd) => {
14733
14733
  }
14734
14734
  return out;
14735
14735
  };
14736
+ var TRANSPORT_ENV = ["GIT_SSH", "GIT_SSH_COMMAND", "GIT_PROXY_COMMAND"];
14737
+ var userGitSeam = { home: accountHome };
14738
+ var realOrSelf = (file) => {
14739
+ try {
14740
+ return realpathSync3.native(file);
14741
+ } catch {
14742
+ return path6.resolve(file);
14743
+ }
14744
+ };
14745
+ var userLevel = (scope, origin) => {
14746
+ if (scope === "system")
14747
+ return process.env.GIT_CONFIG_SYSTEM === undefined;
14748
+ if (scope !== "global" || !origin.startsWith("file:"))
14749
+ return false;
14750
+ const file = realOrSelf(origin.slice("file:".length));
14751
+ const home = userGitSeam.home();
14752
+ if (home === null)
14753
+ return false;
14754
+ return [path6.join(home, ".gitconfig"), path6.join(home, ".config", "git", "config")].map(realOrSelf).includes(file);
14755
+ };
14756
+ var escapeRegex2 = (value) => value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
14757
+ var transportOverride = (git, remote, vars) => {
14758
+ const env = TRANSPORT_ENV.find((name) => vars[name]);
14759
+ if (env)
14760
+ return env;
14761
+ const execPath = vars.GIT_EXEC_PATH;
14762
+ if (execPath) {
14763
+ const { GIT_EXEC_PATH: _set, ...rest } = vars;
14764
+ const own = spawnSync5("git", ["--exec-path"], {
14765
+ env: rest,
14766
+ encoding: "utf8"
14767
+ });
14768
+ if (own.status !== 0 || realOrSelf(own.stdout.trim()) !== realOrSelf(execPath))
14769
+ return "GIT_EXEC_PATH";
14770
+ }
14771
+ const name = escapeRegex2(remote);
14772
+ const run = git([
14773
+ "config",
14774
+ "--show-scope",
14775
+ "--show-origin",
14776
+ "--get-regexp",
14777
+ `^(remote\\.${name}\\.(receivepack|vcs)|core\\.(sshcommand|gitproxy))$`
14778
+ ]);
14779
+ if (run.status === 1)
14780
+ return null;
14781
+ if (run.status !== 0)
14782
+ return "a git config that cannot be read";
14783
+ for (const line of String(run.stdout).split(/\r?\n/u)) {
14784
+ const match = /^(\S+)\t(.*?)\t(\S+)(?: |$)/u.exec(line);
14785
+ if (!match)
14786
+ continue;
14787
+ const [, scope, origin, key] = match;
14788
+ if (key === "core.sshcommand" && userLevel(scope, origin))
14789
+ continue;
14790
+ return `${key} (${scope} ${origin})`;
14791
+ }
14792
+ return null;
14793
+ };
14794
+ var pushTarget = (cwd, remote, replay = {}) => {
14795
+ const env = { ...process.env, ...replay.env };
14796
+ for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
14797
+ delete env[name];
14798
+ if (!remote || remote.startsWith("-"))
14799
+ return Error(`push remote ${JSON.stringify(remote)} cannot be resolved`);
14800
+ const git = (args) => spawnSync5("git", [...replay.config ?? [], ...args], {
14801
+ cwd,
14802
+ env,
14803
+ encoding: "utf8",
14804
+ timeout: 5000,
14805
+ windowsHide: true
14806
+ });
14807
+ const override = transportOverride(git, remote, env);
14808
+ if (override)
14809
+ return Error(`${override} decides what the push to ${remote} reaches, not its URL, so its target is unknown`);
14810
+ const run = git(["remote", "get-url", "--push", "--all", remote]);
14811
+ const urls = run.status === 0 ? run.stdout.split(/\r?\n/u).map((url) => url.trim()) : run.status === 2 ? [remote] : [];
14812
+ if (!urls.some(Boolean))
14813
+ return Error(`git could not resolve the push URLs of remote ${remote} in ${cwd}`);
14814
+ let top;
14815
+ const base = () => {
14816
+ if (top === undefined) {
14817
+ const at = git(["rev-parse", "--show-toplevel"]);
14818
+ top = at.status === 0 && at.stdout.trim() ? at.stdout.trim() : cwd;
14819
+ }
14820
+ return top;
14821
+ };
14822
+ const remotes = [];
14823
+ for (const url of urls.filter(Boolean)) {
14824
+ const key = remoteKey(url, base);
14825
+ if (key === null)
14826
+ return Error(`remote ${remote} has a push URL that names no repository workit can read: ${url}`);
14827
+ remotes.push({ name: remote, url, key });
14828
+ }
14829
+ return { remotes };
14830
+ };
14736
14831
 
14737
14832
  // packages/workit-core/src/core/workspaces.ts
14738
14833
  var nonBlank = string2().check(refine((value) => value.trim().length > 0, "must not be blank"));
@@ -14749,7 +14844,8 @@ var workspaceBranchPolicySchema = strictObject({
14749
14844
  })),
14750
14845
  allowed: optional(array(nonBlank)),
14751
14846
  protected: optional(array(nonBlank)),
14752
- integration: optional(_enum(["pr", "merge"]))
14847
+ integration: optional(_enum(["pr", "merge"])),
14848
+ releaseTagPrefix: optional(string2())
14753
14849
  });
14754
14850
  var workspaceCommitPolicySchema = strictObject({
14755
14851
  preset: commitPreset,
@@ -14839,7 +14935,7 @@ var workspaceConfigSchema = looseObject({
14839
14935
  })),
14840
14936
  models: optional(looseObject({ roles: modelRoles })),
14841
14937
  resources: optional(unknown()),
14842
- remotes: optional(array(nonBlank.check(refine((pattern) => remotePattern(pattern) !== null, "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")))),
14938
+ remotes: optional(array(nonBlank.check(refine((pattern) => isRemotePattern(pattern), "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")))),
14843
14939
  externalRepos: optional(array(nonBlank.check(_regex(/^[\w-]+(?:\/\w[\w.-]*)*\/(?:\w[\w.-]*|\*)$/u, "is owner/name, group/project or owner/* on the checkout's forge host, without the host")))),
14844
14940
  additiveRiskPaths: optional(array(nonBlank)),
14845
14941
  autonomy: optional(looseObject(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
@@ -14866,7 +14962,9 @@ var workspaceConfigSchema = looseObject({
14866
14962
  defaultProfile: optional(nonBlank),
14867
14963
  profiles: optional(record(nonBlank, workspaceProfileSchema)),
14868
14964
  releaseTracks: optional(record(nonBlank, releaseTrackSchema)),
14869
- releasePackages: optional(unknown())
14965
+ releasePackages: optional(unknown()),
14966
+ releaseTagPrefix: optional(string2()),
14967
+ trunkCi: optional(unknown())
14870
14968
  }).check(superRefine((workspace, context) => {
14871
14969
  if (workspace.defaultProfile !== undefined && !Object.hasOwn(workspace.profiles ?? {}, workspace.defaultProfile)) {
14872
14970
  context.addIssue({
@@ -15206,6 +15304,7 @@ var canonicalGlob = (glob) => {
15206
15304
  return real + (prefix.endsWith("/") ? "/" : "") + rest;
15207
15305
  };
15208
15306
  var globSpecificity = (glob) => glob.replaceAll("\\", "/").split("/").filter((segment) => segment.length > 0 && !/[*?[\]{]/.test(segment)).length;
15307
+ var workspaceMatches = (cwd, entries) => matchingEntries(cwd, entries);
15209
15308
  var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
15210
15309
  if (workspaceName !== undefined) {
15211
15310
  const named = matches.filter((entry) => entry.name === workspaceName);
@@ -15227,15 +15326,32 @@ var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
15227
15326
  }
15228
15327
  return mostSpecific[0];
15229
15328
  };
15230
- var resolveWorkspaceFromEntries = (cwd, entries, workspaceName) => {
15231
- const matches = matchingEntries(cwd, entries);
15232
- return selectWorkspaceMatch(matches, cwd, workspaceName) ?? null;
15329
+ var HOSTLESS_REMOTE = /^[\w-]+\/\*$/u;
15330
+ var expandRemotePattern = (entry, pattern) => {
15331
+ if (!HOSTLESS_REMOTE.test(pattern.trim()))
15332
+ return pattern;
15333
+ const vcs = entry.vcs ?? {};
15334
+ const host = typeof vcs.host === "string" && vcs.host.trim().replace(/^https?:\/\/|\/.*$/giu, "") || `${vcs.provider === "gitlab" ? "gitlab" : "github"}.com`;
15335
+ return `https://${host}/${pattern.trim()}`;
15336
+ };
15337
+ var isRemotePattern = (pattern) => !!remotePattern(expandRemotePattern({}, pattern));
15338
+ var remoteClaimOf = (entry, key, exact = false) => (Array.isArray(entry.remotes) ? entry.remotes : []).find((pattern) => typeof pattern === "string" && !(exact && pattern.trim().endsWith("/*")) && remoteMatches(expandRemotePattern(entry, pattern), key));
15339
+ var resolveWorkspaceFromEntries = (cwd, entries, workspaceName, remotes) => {
15340
+ const globbed = matchingEntries(cwd, entries);
15341
+ const listed = !remotes || globbed.length || !entries.some((entry) => entry.remotes) ? [] : checkoutRemotes(cwd);
15342
+ const origin = listed instanceof Error ? [] : listed.filter((item) => item.name === "origin");
15343
+ const hits = entries.filter((entry) => origin.length && origin.every((item) => remoteClaimOf(entry, item.key)));
15344
+ const exact = hits.filter((entry) => origin.every((item) => remoteClaimOf(entry, item.key, true)));
15345
+ const ranked = exact.length ? exact : hits;
15346
+ if (workspaceName === undefined && ranked.length > 1)
15347
+ return null;
15348
+ return selectWorkspaceMatch(hits.length ? workspaceName ? hits : ranked : globbed, cwd, workspaceName) ?? null;
15233
15349
  };
15234
- var resolveWorkspaceFrom = (cwd, dir, workspaceName) => {
15350
+ var resolveWorkspaceFrom = (cwd, dir, workspaceName, remotes) => {
15235
15351
  const result = readWorkspacesResult(dir);
15236
15352
  if (result.status === "malformed" || result.status === "invalid")
15237
15353
  throw new WorkspaceConfigError(result.error);
15238
- return resolveWorkspaceFromEntries(cwd, result.entries, workspaceName);
15354
+ return resolveWorkspaceFromEntries(cwd, result.entries, workspaceName, remotes);
15239
15355
  };
15240
15356
  var runtimeWorkspacePolicySchema = (kind) => {
15241
15357
  const key = kind === "branch" ? "branchPolicy" : kind === "commit" ? "commitPolicy" : "vcs";
@@ -15285,10 +15401,12 @@ var matchRuntimeWorkspace = (cwd, dir = configDir2()) => {
15285
15401
  if (!glob.ok)
15286
15402
  throw new WorkspaceConfigError(`${file} workspace ${entry.name}: ${glob.error}`);
15287
15403
  }
15288
- const matches = matchingEntries(cwd, entries ?? []);
15289
15404
  const workspaceName = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
15290
- const selected = selectWorkspaceMatch(matches, cwd, workspaceName);
15291
- return selected ? { file, selected, matches } : null;
15405
+ const selected = resolveWorkspaceFromEntries(cwd, entries ?? [], workspaceName, true);
15406
+ if (!selected)
15407
+ return null;
15408
+ const matches = matchingEntries(cwd, entries ?? []);
15409
+ return { file, selected, matches: matches.length ? matches : [selected] };
15292
15410
  };
15293
15411
  var resolveRuntimeReleaseTracks = (cwd) => {
15294
15412
  const matched = matchRuntimeWorkspace(cwd);
@@ -24640,6 +24758,7 @@ var ytrackDetail = (out) => out.stderr.trim().split(`
24640
24758
  var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only through ytrack";
24641
24759
 
24642
24760
  // packages/workit-core/src/autonomy.ts
24761
+ var resolveWorkspaceFrom2 = (cwd, dir, name) => resolveWorkspaceFrom(cwd, dir, name, true);
24643
24762
  var accountHomeDir = () => {
24644
24763
  const home = grantsHome.resolve();
24645
24764
  return home === null ? null : configDir({ HOME: home });
@@ -24672,11 +24791,11 @@ var accountUnread = () => {
24672
24791
  };
24673
24792
  var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
24674
24793
  var fileSource = (dir = accountDir()) => ({
24675
- resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom(cwd, dir, name),
24794
+ resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom2(cwd, dir, name),
24676
24795
  entries: () => entriesIn(dir)
24677
24796
  });
24678
24797
  var sealedSource = (entries) => ({
24679
- resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name),
24798
+ resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name, true),
24680
24799
  entries: () => entries
24681
24800
  });
24682
24801
  var sealOf = () => {
@@ -24927,7 +25046,8 @@ function resolveWith(source, cwd, world, target) {
24927
25046
  const above = checkoutsAbove(cwd);
24928
25047
  for (const where of above instanceof Error ? [above] : above)
24929
25048
  autonomy = capAt(source, autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
24930
- return capAtRemotes(source, autonomy, cwd, target);
25049
+ const own = real && workspaceMatches(cwd, source.entries()).length === 0 ? real : undefined;
25050
+ return capAtRemotes(source, autonomy, cwd, target, own);
24931
25051
  }
24932
25052
  var needsAccount = (autonomy) => autonomy.configured.length > 0 && !autonomy.accountConfigured;
24933
25053
  function stricter(current, sealed, note, unblock) {
@@ -24966,17 +25086,31 @@ function stricter(current, sealed, note, unblock) {
24966
25086
  note: current.note ? `${current.note}; ${note}` : note
24967
25087
  };
24968
25088
  }
24969
- function capAtRemotes(source, autonomy, cwd, target) {
25089
+ function capAtRemotes(source, autonomy, cwd, target, own) {
24970
25090
  const claiming = source.entries().filter((entry) => entry.remotes?.length);
24971
25091
  if (claiming.length === 0)
24972
25092
  return autonomy;
24973
25093
  const remotes = target === undefined ? checkoutRemotes(cwd) : typeof target === "function" ? target() : target;
24974
25094
  if (remotes instanceof Error)
24975
25095
  return capAt(source, autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
25096
+ const listed = Array.isArray(remotes) ? remotes : remotes.remotes;
25097
+ const capped = own ? capAtOwnClaim(source, autonomy, cwd, own, target && listed) : autonomy;
25098
+ return capAtClaims(source, capped, listed, claiming);
25099
+ }
25100
+ function capAtOwnClaim(source, autonomy, cwd, own, judged) {
25101
+ const push = judged ? { remotes: judged } : pushTarget(cwd, pushRemoteName(cwd) ?? "");
25102
+ if (push instanceof Error)
25103
+ return capAt(source, autonomy, push, "push target", "a target that cannot be resolved never raises grants");
25104
+ const unclaimed = push.remotes.filter((remote) => !remoteClaimOf(own, remote.key));
25105
+ if (unclaimed.length === 0 && push.remotes.length > 0)
25106
+ return autonomy;
25107
+ return stricter(autonomy, autonomyOf(null), `${unclaimed.map((remote) => `remote ${remote.name} ${remote.url}`).join(", ") || "no target"}: not in workspace ${own.name}'s remotes, which matched this checkout by its origin; grants capped at the defaults`, `ask the user to add that repository to workspace ${own.name}'s remotes, in their own terminal: workit workspace set ${own.name} remotes=<patterns>`);
25108
+ }
25109
+ function capAtClaims(source, autonomy, listed, claiming) {
24976
25110
  let capped = autonomy;
24977
- for (const remote of Array.isArray(remotes) ? remotes : remotes.remotes)
25111
+ for (const remote of listed)
24978
25112
  for (const entry of claiming) {
24979
- const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
25113
+ const pattern = remoteClaimOf(entry, remote.key);
24980
25114
  if (pattern)
24981
25115
  capped = capAt(source, capped, { entry }, `remote ${remote.name} ${remote.url} (workspace ${entry.name} claims ${pattern})`, "a checkout never exceeds the workspace that owns its remote");
24982
25116
  }
@@ -4056,7 +4056,8 @@ var workspaceBranchPolicySchema = strictObject({
4056
4056
  })),
4057
4057
  allowed: optional(array(nonBlank)),
4058
4058
  protected: optional(array(nonBlank)),
4059
- integration: optional(_enum(["pr", "merge"]))
4059
+ integration: optional(_enum(["pr", "merge"])),
4060
+ releaseTagPrefix: optional(string2())
4060
4061
  });
4061
4062
  var workspaceCommitPolicySchema = strictObject({
4062
4063
  preset: commitPreset,
@@ -4146,7 +4147,7 @@ var workspaceConfigSchema = looseObject({
4146
4147
  })),
4147
4148
  models: optional(looseObject({ roles: modelRoles })),
4148
4149
  resources: optional(unknown()),
4149
- remotes: optional(array(nonBlank.check(refine((pattern) => remotePattern(pattern) !== null, "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")))),
4150
+ remotes: optional(array(nonBlank.check(refine((pattern) => isRemotePattern(pattern), "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")))),
4150
4151
  externalRepos: optional(array(nonBlank.check(_regex(/^[\w-]+(?:\/\w[\w.-]*)*\/(?:\w[\w.-]*|\*)$/u, "is owner/name, group/project or owner/* on the checkout's forge host, without the host")))),
4151
4152
  additiveRiskPaths: optional(array(nonBlank)),
4152
4153
  autonomy: optional(looseObject(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
@@ -4173,7 +4174,9 @@ var workspaceConfigSchema = looseObject({
4173
4174
  defaultProfile: optional(nonBlank),
4174
4175
  profiles: optional(record(nonBlank, workspaceProfileSchema)),
4175
4176
  releaseTracks: optional(record(nonBlank, releaseTrackSchema)),
4176
- releasePackages: optional(unknown())
4177
+ releasePackages: optional(unknown()),
4178
+ releaseTagPrefix: optional(string2()),
4179
+ trunkCi: optional(unknown())
4177
4180
  }).check(superRefine((workspace, context) => {
4178
4181
  if (workspace.defaultProfile !== undefined && !Object.hasOwn(workspace.profiles ?? {}, workspace.defaultProfile)) {
4179
4182
  context.addIssue({
@@ -4513,6 +4516,7 @@ var canonicalGlob = (glob) => {
4513
4516
  return real + (prefix.endsWith("/") ? "/" : "") + rest;
4514
4517
  };
4515
4518
  var globSpecificity = (glob) => glob.replaceAll("\\", "/").split("/").filter((segment) => segment.length > 0 && !/[*?[\]{]/.test(segment)).length;
4519
+ var workspaceMatches = (cwd, entries) => matchingEntries(cwd, entries);
4516
4520
  var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
4517
4521
  if (workspaceName !== undefined) {
4518
4522
  const named = matches.filter((entry) => entry.name === workspaceName);
@@ -4534,15 +4538,32 @@ var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
4534
4538
  }
4535
4539
  return mostSpecific[0];
4536
4540
  };
4537
- var resolveWorkspaceFromEntries = (cwd, entries, workspaceName) => {
4538
- const matches = matchingEntries(cwd, entries);
4539
- return selectWorkspaceMatch(matches, cwd, workspaceName) ?? null;
4540
- };
4541
- var resolveWorkspaceFrom = (cwd, dir, workspaceName) => {
4541
+ var HOSTLESS_REMOTE = /^[\w-]+\/\*$/u;
4542
+ var expandRemotePattern = (entry, pattern) => {
4543
+ if (!HOSTLESS_REMOTE.test(pattern.trim()))
4544
+ return pattern;
4545
+ const vcs = entry.vcs ?? {};
4546
+ const host = typeof vcs.host === "string" && vcs.host.trim().replace(/^https?:\/\/|\/.*$/giu, "") || `${vcs.provider === "gitlab" ? "gitlab" : "github"}.com`;
4547
+ return `https://${host}/${pattern.trim()}`;
4548
+ };
4549
+ var isRemotePattern = (pattern) => !!remotePattern(expandRemotePattern({}, pattern));
4550
+ var remoteClaimOf = (entry, key, exact = false) => (Array.isArray(entry.remotes) ? entry.remotes : []).find((pattern) => typeof pattern === "string" && !(exact && pattern.trim().endsWith("/*")) && remoteMatches(expandRemotePattern(entry, pattern), key));
4551
+ var resolveWorkspaceFromEntries = (cwd, entries, workspaceName, remotes) => {
4552
+ const globbed = matchingEntries(cwd, entries);
4553
+ const listed = !remotes || globbed.length || !entries.some((entry) => entry.remotes) ? [] : checkoutRemotes(cwd);
4554
+ const origin = listed instanceof Error ? [] : listed.filter((item) => item.name === "origin");
4555
+ const hits = entries.filter((entry) => origin.length && origin.every((item) => remoteClaimOf(entry, item.key)));
4556
+ const exact = hits.filter((entry) => origin.every((item) => remoteClaimOf(entry, item.key, true)));
4557
+ const ranked = exact.length ? exact : hits;
4558
+ if (workspaceName === undefined && ranked.length > 1)
4559
+ return null;
4560
+ return selectWorkspaceMatch(hits.length ? workspaceName ? hits : ranked : globbed, cwd, workspaceName) ?? null;
4561
+ };
4562
+ var resolveWorkspaceFrom = (cwd, dir, workspaceName, remotes) => {
4542
4563
  const result = readWorkspacesResult(dir);
4543
4564
  if (result.status === "malformed" || result.status === "invalid")
4544
4565
  throw new WorkspaceConfigError(result.error);
4545
- return resolveWorkspaceFromEntries(cwd, result.entries, workspaceName);
4566
+ return resolveWorkspaceFromEntries(cwd, result.entries, workspaceName, remotes);
4546
4567
  };
4547
4568
  var runtimeWorkspacePolicySchema = (kind) => {
4548
4569
  const key = kind === "branch" ? "branchPolicy" : kind === "commit" ? "commitPolicy" : "vcs";
@@ -4592,10 +4613,12 @@ var matchRuntimeWorkspace = (cwd, dir = configDir()) => {
4592
4613
  if (!glob.ok)
4593
4614
  throw new WorkspaceConfigError(`${file} workspace ${entry.name}: ${glob.error}`);
4594
4615
  }
4595
- const matches = matchingEntries(cwd, entries ?? []);
4596
4616
  const workspaceName = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
4597
- const selected = selectWorkspaceMatch(matches, cwd, workspaceName);
4598
- return selected ? { file, selected, matches } : null;
4617
+ const selected = resolveWorkspaceFromEntries(cwd, entries ?? [], workspaceName, true);
4618
+ if (!selected)
4619
+ return null;
4620
+ const matches = matchingEntries(cwd, entries ?? []);
4621
+ return { file, selected, matches: matches.length ? matches : [selected] };
4599
4622
  };
4600
4623
  var resolveRuntimeReleaseTracks = (cwd) => {
4601
4624
  const matched = matchRuntimeWorkspace(cwd);
@@ -13385,6 +13408,7 @@ var youTrackHostAllowed = (allowed, host) => {
13385
13408
  };
13386
13409
 
13387
13410
  // packages/workit-core/src/autonomy.ts
13411
+ var resolveWorkspaceFrom2 = (cwd, dir, name) => resolveWorkspaceFrom(cwd, dir, name, true);
13388
13412
  var accountHomeDir = () => {
13389
13413
  const home = grantsHome.resolve();
13390
13414
  return home === null ? null : configDir2({ HOME: home });
@@ -13417,11 +13441,11 @@ var accountUnread = () => {
13417
13441
  };
13418
13442
  var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
13419
13443
  var fileSource = (dir = accountDir()) => ({
13420
- resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom(cwd, dir, name),
13444
+ resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom2(cwd, dir, name),
13421
13445
  entries: () => entriesIn(dir)
13422
13446
  });
13423
13447
  var sealedSource = (entries) => ({
13424
- resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name),
13448
+ resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name, true),
13425
13449
  entries: () => entries
13426
13450
  });
13427
13451
  var sealOf = () => {
@@ -13447,8 +13471,8 @@ var youTrackWritesPolicy = (cwd) => {
13447
13471
  return ASK;
13448
13472
  const auto = (entry) => youtrackOf(entry)?.writes === "auto";
13449
13473
  const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
13450
- const named = resolveWorkspaceFrom(cwd, dir, name);
13451
- const folder = name ? resolveWorkspaceFrom(cwd, dir) : named;
13474
+ const named = resolveWorkspaceFrom2(cwd, dir, name);
13475
+ const folder = name ? resolveWorkspaceFrom2(cwd, dir) : named;
13452
13476
  if (!auto(named) || !auto(folder))
13453
13477
  return ASK;
13454
13478
  const [a, b] = [autoHostsOf(named), autoHostsOf(folder)];
@@ -13703,7 +13727,8 @@ function resolveWith(source, cwd, world, target) {
13703
13727
  const above = checkoutsAbove(cwd);
13704
13728
  for (const where of above instanceof Error ? [above] : above)
13705
13729
  autonomy = capAt(source, autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
13706
- return capAtRemotes(source, autonomy, cwd, target);
13730
+ const own = real && workspaceMatches(cwd, source.entries()).length === 0 ? real : undefined;
13731
+ return capAtRemotes(source, autonomy, cwd, target, own);
13707
13732
  }
13708
13733
  var needsAccount = (autonomy) => autonomy.configured.length > 0 && !autonomy.accountConfigured;
13709
13734
  function stricter(current, sealed, note, unblock) {
@@ -13742,17 +13767,31 @@ function stricter(current, sealed, note, unblock) {
13742
13767
  note: current.note ? `${current.note}; ${note}` : note
13743
13768
  };
13744
13769
  }
13745
- function capAtRemotes(source, autonomy, cwd, target) {
13770
+ function capAtRemotes(source, autonomy, cwd, target, own) {
13746
13771
  const claiming = source.entries().filter((entry) => entry.remotes?.length);
13747
13772
  if (claiming.length === 0)
13748
13773
  return autonomy;
13749
13774
  const remotes = target === undefined ? checkoutRemotes(cwd) : typeof target === "function" ? target() : target;
13750
13775
  if (remotes instanceof Error)
13751
13776
  return capAt(source, autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
13777
+ const listed = Array.isArray(remotes) ? remotes : remotes.remotes;
13778
+ const capped = own ? capAtOwnClaim(source, autonomy, cwd, own, target && listed) : autonomy;
13779
+ return capAtClaims(source, capped, listed, claiming);
13780
+ }
13781
+ function capAtOwnClaim(source, autonomy, cwd, own, judged) {
13782
+ const push = judged ? { remotes: judged } : pushTarget(cwd, pushRemoteName(cwd) ?? "");
13783
+ if (push instanceof Error)
13784
+ return capAt(source, autonomy, push, "push target", "a target that cannot be resolved never raises grants");
13785
+ const unclaimed = push.remotes.filter((remote) => !remoteClaimOf(own, remote.key));
13786
+ if (unclaimed.length === 0 && push.remotes.length > 0)
13787
+ return autonomy;
13788
+ return stricter(autonomy, autonomyOf(null), `${unclaimed.map((remote) => `remote ${remote.name} ${remote.url}`).join(", ") || "no target"}: not in workspace ${own.name}'s remotes, which matched this checkout by its origin; grants capped at the defaults`, `ask the user to add that repository to workspace ${own.name}'s remotes, in their own terminal: workit workspace set ${own.name} remotes=<patterns>`);
13789
+ }
13790
+ function capAtClaims(source, autonomy, listed, claiming) {
13752
13791
  let capped = autonomy;
13753
- for (const remote of Array.isArray(remotes) ? remotes : remotes.remotes)
13792
+ for (const remote of listed)
13754
13793
  for (const entry of claiming) {
13755
- const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
13794
+ const pattern = remoteClaimOf(entry, remote.key);
13756
13795
  if (pattern)
13757
13796
  capped = capAt(source, capped, { entry }, `remote ${remote.name} ${remote.url} (workspace ${entry.name} claims ${pattern})`, "a checkout never exceeds the workspace that owns its remote");
13758
13797
  }
@@ -13780,7 +13819,7 @@ function claimsIn(target, entries) {
13780
13819
  return target;
13781
13820
  const claiming = entries.filter((entry) => entry.remotes?.length);
13782
13821
  return target.remotes.flatMap((remote) => claiming.flatMap((entry) => {
13783
- const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
13822
+ const pattern = remoteClaimOf(entry, remote.key);
13784
13823
  return pattern ? [{ url: remote.url, workspace: entry.name, pattern }] : [];
13785
13824
  }));
13786
13825
  }
@@ -106,7 +106,7 @@ if (quiet) {
106
106
  `);
107
107
  } else {
108
108
  try {
109
- const { runCodexHook } = await import("./workit-hook-3rs7jcpj.js");
109
+ const { runCodexHook } = await import("./workit-hook-zw7g7g4e.js");
110
110
  await runCodexHook([payload]);
111
111
  } catch (error) {
112
112
  const { answerRuntimeFailure } = await import("./workit-hook-8kebgc9b.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/codex",
3
- "version": "2.27.13",
3
+ "version": "2.29.0",
4
4
  "private": false,
5
5
  "description": "Workit Codex CLI/desktop plugin — shared MCP transport, hooks, method skills, and verifier/reviewer/implementer agents",
6
6
  "keywords": [
@@ -41,8 +41,8 @@
41
41
  "build": "bun scripts/build.ts"
42
42
  },
43
43
  "devDependencies": {
44
- "@workit-dev/core": "^2.27.13",
45
- "@workit-dev/mcp": "^2.27.13"
44
+ "@workit-dev/core": "^2.29.0",
45
+ "@workit-dev/mcp": "^2.29.0"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=24"