@workit-dev/pi 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.
package/dist/worker.js CHANGED
@@ -5860,12 +5860,13 @@ var COMMIT_PRESETS = [
5860
5860
  ];
5861
5861
 
5862
5862
  // packages/workit-core/src/core/workspaces.ts
5863
- import { spawnSync as spawnSync4 } from "node:child_process";
5863
+ import { spawnSync as spawnSync5 } from "node:child_process";
5864
5864
  import { existsSync as existsSync3, lstatSync as lstatSync3, readFileSync as readFileSync3, realpathSync as realpathSync4 } from "node:fs";
5865
5865
  import path6 from "node:path";
5866
5866
 
5867
5867
  // packages/workit-core/src/core/remotes.ts
5868
5868
  import { lstatSync as lstatSync2, readFileSync as readFileSync2, realpathSync as realpathSync3, statSync } from "node:fs";
5869
+ import { spawnSync as spawnSync4 } from "node:child_process";
5869
5870
  import path5 from "node:path";
5870
5871
 
5871
5872
  // packages/workit-core/src/git/rev.ts
@@ -6413,6 +6414,51 @@ var remotePattern = (pattern) => {
6413
6414
  const key = remoteKey(owner ? trimmed.slice(0, -2) : trimmed);
6414
6415
  return key ? { key, owner } : null;
6415
6416
  };
6417
+ var remoteMatches = (pattern, key) => {
6418
+ const parsed = remotePattern(pattern);
6419
+ if (!parsed)
6420
+ return false;
6421
+ return parsed.owner ? key.startsWith(`${parsed.key}/`) : key === parsed.key;
6422
+ };
6423
+ var checkoutRemotes = (cwd) => {
6424
+ const env = { ...process.env };
6425
+ for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
6426
+ delete env[name];
6427
+ const git = (args) => spawnSync4("git", args, {
6428
+ cwd,
6429
+ env,
6430
+ encoding: "utf8",
6431
+ timeout: 5000,
6432
+ windowsHide: true
6433
+ });
6434
+ const listed = git(["remote", "-v"]);
6435
+ if (listed.status !== 0) {
6436
+ if (/not a git repository/iu.test(listed.stderr ?? ""))
6437
+ return [];
6438
+ return Error(`git could not list the remotes of ${cwd}`);
6439
+ }
6440
+ let top;
6441
+ const base = () => {
6442
+ if (top === undefined) {
6443
+ const run = git(["rev-parse", "--show-toplevel"]);
6444
+ top = run.status === 0 && run.stdout.trim() ? run.stdout.trim() : cwd;
6445
+ }
6446
+ return top;
6447
+ };
6448
+ const out = [];
6449
+ for (const line of listed.stdout.split(/\r?\n/u)) {
6450
+ const match = /^([^\t]+)\t(.*) \((?:fetch|push)\)$/u.exec(line);
6451
+ if (!match)
6452
+ continue;
6453
+ const [, name, url] = match;
6454
+ const key = remoteKey(url, base);
6455
+ if (key === null)
6456
+ return Error(`remote ${name} of ${cwd} has a URL workit cannot read: ${url}`);
6457
+ if (!out.some((item) => item.key === key))
6458
+ out.push({ name, url, key });
6459
+ }
6460
+ return out;
6461
+ };
6416
6462
 
6417
6463
  // packages/workit-core/src/core/workspaces.ts
6418
6464
  var nonBlank = string2().check(refine((value) => value.trim().length > 0, "must not be blank"));
@@ -6429,7 +6475,8 @@ var workspaceBranchPolicySchema = strictObject({
6429
6475
  })),
6430
6476
  allowed: optional(array(nonBlank)),
6431
6477
  protected: optional(array(nonBlank)),
6432
- integration: optional(_enum(["pr", "merge"]))
6478
+ integration: optional(_enum(["pr", "merge"])),
6479
+ releaseTagPrefix: optional(string2())
6433
6480
  });
6434
6481
  var workspaceCommitPolicySchema = strictObject({
6435
6482
  preset: commitPreset,
@@ -6519,7 +6566,7 @@ var workspaceConfigSchema = looseObject({
6519
6566
  })),
6520
6567
  models: optional(looseObject({ roles: modelRoles })),
6521
6568
  resources: optional(unknown()),
6522
- 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/*)")))),
6569
+ 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/*)")))),
6523
6570
  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")))),
6524
6571
  additiveRiskPaths: optional(array(nonBlank)),
6525
6572
  autonomy: optional(looseObject(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
@@ -6546,7 +6593,9 @@ var workspaceConfigSchema = looseObject({
6546
6593
  defaultProfile: optional(nonBlank),
6547
6594
  profiles: optional(record(nonBlank, workspaceProfileSchema)),
6548
6595
  releaseTracks: optional(record(nonBlank, releaseTrackSchema)),
6549
- releasePackages: optional(unknown())
6596
+ releasePackages: optional(unknown()),
6597
+ releaseTagPrefix: optional(string2()),
6598
+ trunkCi: optional(unknown())
6550
6599
  }).check(superRefine((workspace, context) => {
6551
6600
  if (workspace.defaultProfile !== undefined && !Object.hasOwn(workspace.profiles ?? {}, workspace.defaultProfile)) {
6552
6601
  context.addIssue({
@@ -6662,7 +6711,7 @@ var probeCheckout = (cwd) => {
6662
6711
  for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
6663
6712
  delete env[name];
6664
6713
  const git = (args) => {
6665
- const run = spawnSync4("git", args, {
6714
+ const run = spawnSync5("git", args, {
6666
6715
  cwd,
6667
6716
  env,
6668
6717
  encoding: "utf8",
@@ -6809,6 +6858,27 @@ var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
6809
6858
  }
6810
6859
  return mostSpecific[0];
6811
6860
  };
6861
+ var HOSTLESS_REMOTE = /^[\w-]+\/\*$/u;
6862
+ var expandRemotePattern = (entry, pattern) => {
6863
+ if (!HOSTLESS_REMOTE.test(pattern.trim()))
6864
+ return pattern;
6865
+ const vcs = entry.vcs ?? {};
6866
+ const host = typeof vcs.host === "string" && vcs.host.trim().replace(/^https?:\/\/|\/.*$/giu, "") || `${vcs.provider === "gitlab" ? "gitlab" : "github"}.com`;
6867
+ return `https://${host}/${pattern.trim()}`;
6868
+ };
6869
+ var isRemotePattern = (pattern) => !!remotePattern(expandRemotePattern({}, pattern));
6870
+ 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));
6871
+ var resolveWorkspaceFromEntries = (cwd, entries, workspaceName, remotes) => {
6872
+ const globbed = matchingEntries(cwd, entries);
6873
+ const listed = !remotes || globbed.length || !entries.some((entry) => entry.remotes) ? [] : checkoutRemotes(cwd);
6874
+ const origin = listed instanceof Error ? [] : listed.filter((item) => item.name === "origin");
6875
+ const hits = entries.filter((entry) => origin.length && origin.every((item) => remoteClaimOf(entry, item.key)));
6876
+ const exact = hits.filter((entry) => origin.every((item) => remoteClaimOf(entry, item.key, true)));
6877
+ const ranked = exact.length ? exact : hits;
6878
+ if (workspaceName === undefined && ranked.length > 1)
6879
+ return null;
6880
+ return selectWorkspaceMatch(hits.length ? workspaceName ? hits : ranked : globbed, cwd, workspaceName) ?? null;
6881
+ };
6812
6882
  var runtimeWorkspaceIndexSchema = looseObject({
6813
6883
  workspaces: optional(array(looseObject({ name: nonBlank, glob: nonBlank })))
6814
6884
  });
@@ -6839,10 +6909,12 @@ var matchRuntimeWorkspace = (cwd, dir = configDir2()) => {
6839
6909
  if (!glob.ok)
6840
6910
  throw new WorkspaceConfigError(`${file} workspace ${entry.name}: ${glob.error}`);
6841
6911
  }
6842
- const matches = matchingEntries(cwd, entries ?? []);
6843
6912
  const workspaceName = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
6844
- const selected = selectWorkspaceMatch(matches, cwd, workspaceName);
6845
- return selected ? { file, selected, matches } : null;
6913
+ const selected = resolveWorkspaceFromEntries(cwd, entries ?? [], workspaceName, true);
6914
+ if (!selected)
6915
+ return null;
6916
+ const matches = matchingEntries(cwd, entries ?? []);
6917
+ return { file, selected, matches: matches.length ? matches : [selected] };
6846
6918
  };
6847
6919
  var modelSources = (cwd, dir) => {
6848
6920
  const out = [];
@@ -7256,12 +7328,12 @@ Merge them by hand (cp -Rn ${workit}/. ${target}/), then delete them here.
7256
7328
  }
7257
7329
 
7258
7330
  // packages/workit-core/src/store/paths.ts
7259
- import { spawnSync as spawnSync5 } from "node:child_process";
7331
+ import { spawnSync as spawnSync6 } from "node:child_process";
7260
7332
  import fs5 from "node:fs";
7261
7333
  import path8 from "node:path";
7262
7334
  var NOT_A_REPO = /not a git repository \(or any (of the parent directories|parent up to)/u;
7263
7335
  var gitRun = (cwd, args) => {
7264
- const run = spawnSync5("git", args, {
7336
+ const run = spawnSync6("git", args, {
7265
7337
  cwd,
7266
7338
  encoding: "utf8",
7267
7339
  timeout: 20000,
@@ -7483,7 +7555,7 @@ var assetRoot = () => {
7483
7555
  };
7484
7556
 
7485
7557
  // packages/workit-core/src/core/store-lock.ts
7486
- import { spawnSync as spawnSync6 } from "node:child_process";
7558
+ import { spawnSync as spawnSync7 } from "node:child_process";
7487
7559
  import fs6 from "node:fs";
7488
7560
  var metadataLockSchema = strictObject({
7489
7561
  pid: number2().check(int(), _nonnegative(), int()),
@@ -7508,7 +7580,7 @@ var readProcStat = (pid) => {
7508
7580
  };
7509
7581
  var psStart = (pid) => {
7510
7582
  try {
7511
- const run = spawnSync6("ps", ["-o", "lstart=", "-p", String(pid)], {
7583
+ const run = spawnSync7("ps", ["-o", "lstart=", "-p", String(pid)], {
7512
7584
  encoding: "utf8",
7513
7585
  timeout: 1000,
7514
7586
  env: { ...process.env, LC_ALL: "C" }
@@ -7595,7 +7667,7 @@ var PM_RUN = new Set(["run", "run-script"]);
7595
7667
  var PYTHON_RUNNERS = new Set(["uv", "poetry", "pipenv", "pdm", "hatch", "rye"]);
7596
7668
 
7597
7669
  // packages/workit-core/src/ledger.ts
7598
- import { spawnSync as spawnSync7 } from "node:child_process";
7670
+ import { spawnSync as spawnSync8 } from "node:child_process";
7599
7671
  import { createHash as createHash4, randomBytes } from "node:crypto";
7600
7672
  import fs8 from "node:fs";
7601
7673
  import path11 from "node:path";
@@ -7775,7 +7847,7 @@ var err = (code, error, unblock) => ({
7775
7847
  ...unblock ? { unblock } : {}
7776
7848
  });
7777
7849
  var gitRun2 = (cwd, args, timeoutMs = GIT_TIMEOUTS.local) => {
7778
- const run = spawnSync7("git", args, {
7850
+ const run = spawnSync8("git", args, {
7779
7851
  cwd,
7780
7852
  encoding: "utf8",
7781
7853
  timeout: timeoutMs,
@@ -9985,11 +10057,11 @@ var READ_CMDLETS = new Set([
9985
10057
  import path14 from "node:path";
9986
10058
 
9987
10059
  // packages/workit-core/src/core/live-session.ts
9988
- import { spawnSync as spawnSync8 } from "node:child_process";
10060
+ import { spawnSync as spawnSync9 } from "node:child_process";
9989
10061
  var LIVE_SESSION_TTL_MS = 15 * 60000;
9990
10062
  var liveProbe = {
9991
10063
  platform: process.platform,
9992
- run: (args) => spawnSync8("ps", args, { encoding: "utf8", timeout: 2000 }).stdout ?? "",
10064
+ run: (args) => spawnSync9("ps", args, { encoding: "utf8", timeout: 2000 }).stdout ?? "",
9993
10065
  start: (pid) => processStartOf(pid)
9994
10066
  };
9995
10067
  var PIDS = new Map;
package/dist/workit.js CHANGED
@@ -8383,7 +8383,8 @@ var workspaceBranchPolicySchema = strictObject({
8383
8383
  })),
8384
8384
  allowed: optional(array(nonBlank)),
8385
8385
  protected: optional(array(nonBlank)),
8386
- integration: optional(_enum(["pr", "merge"]))
8386
+ integration: optional(_enum(["pr", "merge"])),
8387
+ releaseTagPrefix: optional(string2())
8387
8388
  });
8388
8389
  var workspaceCommitPolicySchema = strictObject({
8389
8390
  preset: commitPreset,
@@ -8473,7 +8474,7 @@ var workspaceConfigSchema = looseObject({
8473
8474
  })),
8474
8475
  models: optional(looseObject({ roles: modelRoles })),
8475
8476
  resources: optional(unknown()),
8476
- 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/*)")))),
8477
+ 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/*)")))),
8477
8478
  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")))),
8478
8479
  additiveRiskPaths: optional(array(nonBlank)),
8479
8480
  autonomy: optional(looseObject(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
@@ -8500,7 +8501,9 @@ var workspaceConfigSchema = looseObject({
8500
8501
  defaultProfile: optional(nonBlank),
8501
8502
  profiles: optional(record(nonBlank, workspaceProfileSchema)),
8502
8503
  releaseTracks: optional(record(nonBlank, releaseTrackSchema)),
8503
- releasePackages: optional(unknown())
8504
+ releasePackages: optional(unknown()),
8505
+ releaseTagPrefix: optional(string2()),
8506
+ trunkCi: optional(unknown())
8504
8507
  }).check(superRefine((workspace, context) => {
8505
8508
  if (workspace.defaultProfile !== undefined && !Object.hasOwn(workspace.profiles ?? {}, workspace.defaultProfile)) {
8506
8509
  context.addIssue({
@@ -8840,6 +8843,7 @@ var canonicalGlob = (glob) => {
8840
8843
  return real + (prefix.endsWith("/") ? "/" : "") + rest;
8841
8844
  };
8842
8845
  var globSpecificity = (glob) => glob.replaceAll("\\", "/").split("/").filter((segment) => segment.length > 0 && !/[*?[\]{]/.test(segment)).length;
8846
+ var workspaceMatches = (cwd, entries) => matchingEntries(cwd, entries);
8843
8847
  var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
8844
8848
  if (workspaceName !== undefined) {
8845
8849
  const named = matches.filter((entry) => entry.name === workspaceName);
@@ -8861,15 +8865,32 @@ var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
8861
8865
  }
8862
8866
  return mostSpecific[0];
8863
8867
  };
8864
- var resolveWorkspaceFromEntries = (cwd, entries, workspaceName) => {
8865
- const matches = matchingEntries(cwd, entries);
8866
- return selectWorkspaceMatch(matches, cwd, workspaceName) ?? null;
8867
- };
8868
- var resolveWorkspaceFrom = (cwd, dir, workspaceName) => {
8868
+ var HOSTLESS_REMOTE = /^[\w-]+\/\*$/u;
8869
+ var expandRemotePattern = (entry, pattern) => {
8870
+ if (!HOSTLESS_REMOTE.test(pattern.trim()))
8871
+ return pattern;
8872
+ const vcs = entry.vcs ?? {};
8873
+ const host = typeof vcs.host === "string" && vcs.host.trim().replace(/^https?:\/\/|\/.*$/giu, "") || `${vcs.provider === "gitlab" ? "gitlab" : "github"}.com`;
8874
+ return `https://${host}/${pattern.trim()}`;
8875
+ };
8876
+ var isRemotePattern = (pattern) => !!remotePattern(expandRemotePattern({}, pattern));
8877
+ 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));
8878
+ var resolveWorkspaceFromEntries = (cwd, entries, workspaceName, remotes) => {
8879
+ const globbed = matchingEntries(cwd, entries);
8880
+ const listed = !remotes || globbed.length || !entries.some((entry) => entry.remotes) ? [] : checkoutRemotes(cwd);
8881
+ const origin = listed instanceof Error ? [] : listed.filter((item) => item.name === "origin");
8882
+ const hits = entries.filter((entry) => origin.length && origin.every((item) => remoteClaimOf(entry, item.key)));
8883
+ const exact = hits.filter((entry) => origin.every((item) => remoteClaimOf(entry, item.key, true)));
8884
+ const ranked = exact.length ? exact : hits;
8885
+ if (workspaceName === undefined && ranked.length > 1)
8886
+ return null;
8887
+ return selectWorkspaceMatch(hits.length ? workspaceName ? hits : ranked : globbed, cwd, workspaceName) ?? null;
8888
+ };
8889
+ var resolveWorkspaceFrom = (cwd, dir, workspaceName, remotes) => {
8869
8890
  const result = readWorkspacesResult(dir);
8870
8891
  if (result.status === "malformed" || result.status === "invalid")
8871
8892
  throw new WorkspaceConfigError(result.error);
8872
- return resolveWorkspaceFromEntries(cwd, result.entries, workspaceName);
8893
+ return resolveWorkspaceFromEntries(cwd, result.entries, workspaceName, remotes);
8873
8894
  };
8874
8895
  var runtimeWorkspacePolicySchema = (kind) => {
8875
8896
  const key = kind === "branch" ? "branchPolicy" : kind === "commit" ? "commitPolicy" : "vcs";
@@ -8919,10 +8940,12 @@ var matchRuntimeWorkspace = (cwd, dir = configDir2()) => {
8919
8940
  if (!glob.ok)
8920
8941
  throw new WorkspaceConfigError(`${file} workspace ${entry.name}: ${glob.error}`);
8921
8942
  }
8922
- const matches = matchingEntries(cwd, entries ?? []);
8923
8943
  const workspaceName = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
8924
- const selected = selectWorkspaceMatch(matches, cwd, workspaceName);
8925
- return selected ? { file, selected, matches } : null;
8944
+ const selected = resolveWorkspaceFromEntries(cwd, entries ?? [], workspaceName, true);
8945
+ if (!selected)
8946
+ return null;
8947
+ const matches = matchingEntries(cwd, entries ?? []);
8948
+ return { file, selected, matches: matches.length ? matches : [selected] };
8926
8949
  };
8927
8950
  var resolveRuntimeReleaseTracks = (cwd) => {
8928
8951
  const matched = matchRuntimeWorkspace(cwd);
@@ -19069,6 +19092,7 @@ var youTrackHostAllowed = (allowed, host) => {
19069
19092
  var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only through ytrack";
19070
19093
 
19071
19094
  // packages/workit-core/src/autonomy.ts
19095
+ var resolveWorkspaceFrom2 = (cwd, dir, name) => resolveWorkspaceFrom(cwd, dir, name, true);
19072
19096
  var accountHomeDir = () => {
19073
19097
  const home = grantsHome.resolve();
19074
19098
  return home === null ? null : configDir({ HOME: home });
@@ -19101,11 +19125,11 @@ var accountUnread = () => {
19101
19125
  };
19102
19126
  var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
19103
19127
  var fileSource = (dir = accountDir()) => ({
19104
- resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom(cwd, dir, name),
19128
+ resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom2(cwd, dir, name),
19105
19129
  entries: () => entriesIn(dir)
19106
19130
  });
19107
19131
  var sealedSource = (entries) => ({
19108
- resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name),
19132
+ resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name, true),
19109
19133
  entries: () => entries
19110
19134
  });
19111
19135
  var sealOf = () => {
@@ -19131,8 +19155,8 @@ var youTrackWritesPolicy = (cwd) => {
19131
19155
  return ASK;
19132
19156
  const auto = (entry) => youtrackOf(entry)?.writes === "auto";
19133
19157
  const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
19134
- const named = resolveWorkspaceFrom(cwd, dir, name);
19135
- const folder = name ? resolveWorkspaceFrom(cwd, dir) : named;
19158
+ const named = resolveWorkspaceFrom2(cwd, dir, name);
19159
+ const folder = name ? resolveWorkspaceFrom2(cwd, dir) : named;
19136
19160
  if (!auto(named) || !auto(folder))
19137
19161
  return ASK;
19138
19162
  const [a, b] = [autoHostsOf(named), autoHostsOf(folder)];
@@ -19393,7 +19417,8 @@ function resolveWith(source, cwd, world, target) {
19393
19417
  const above = checkoutsAbove(cwd);
19394
19418
  for (const where of above instanceof Error ? [above] : above)
19395
19419
  autonomy = capAt(source, autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
19396
- return capAtRemotes(source, autonomy, cwd, target);
19420
+ const own = real && workspaceMatches(cwd, source.entries()).length === 0 ? real : undefined;
19421
+ return capAtRemotes(source, autonomy, cwd, target, own);
19397
19422
  }
19398
19423
  var needsAccount = (autonomy) => autonomy.configured.length > 0 && !autonomy.accountConfigured;
19399
19424
  function stricter(current, sealed, note, unblock) {
@@ -19432,17 +19457,31 @@ function stricter(current, sealed, note, unblock) {
19432
19457
  note: current.note ? `${current.note}; ${note}` : note
19433
19458
  };
19434
19459
  }
19435
- function capAtRemotes(source, autonomy, cwd, target) {
19460
+ function capAtRemotes(source, autonomy, cwd, target, own) {
19436
19461
  const claiming = source.entries().filter((entry) => entry.remotes?.length);
19437
19462
  if (claiming.length === 0)
19438
19463
  return autonomy;
19439
19464
  const remotes = target === undefined ? checkoutRemotes(cwd) : typeof target === "function" ? target() : target;
19440
19465
  if (remotes instanceof Error)
19441
19466
  return capAt(source, autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
19467
+ const listed = Array.isArray(remotes) ? remotes : remotes.remotes;
19468
+ const capped = own ? capAtOwnClaim(source, autonomy, cwd, own, target && listed) : autonomy;
19469
+ return capAtClaims(source, capped, listed, claiming);
19470
+ }
19471
+ function capAtOwnClaim(source, autonomy, cwd, own, judged) {
19472
+ const push = judged ? { remotes: judged } : pushTarget(cwd, pushRemoteName(cwd) ?? "");
19473
+ if (push instanceof Error)
19474
+ return capAt(source, autonomy, push, "push target", "a target that cannot be resolved never raises grants");
19475
+ const unclaimed = push.remotes.filter((remote) => !remoteClaimOf(own, remote.key));
19476
+ if (unclaimed.length === 0 && push.remotes.length > 0)
19477
+ return autonomy;
19478
+ 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>`);
19479
+ }
19480
+ function capAtClaims(source, autonomy, listed, claiming) {
19442
19481
  let capped = autonomy;
19443
- for (const remote of Array.isArray(remotes) ? remotes : remotes.remotes)
19482
+ for (const remote of listed)
19444
19483
  for (const entry of claiming) {
19445
- const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
19484
+ const pattern = remoteClaimOf(entry, remote.key);
19446
19485
  if (pattern)
19447
19486
  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");
19448
19487
  }
@@ -19470,7 +19509,7 @@ function claimsIn(target, entries) {
19470
19509
  return target;
19471
19510
  const claiming = entries.filter((entry) => entry.remotes?.length);
19472
19511
  return target.remotes.flatMap((remote) => claiming.flatMap((entry) => {
19473
- const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
19512
+ const pattern = remoteClaimOf(entry, remote.key);
19474
19513
  return pattern ? [{ url: remote.url, workspace: entry.name, pattern }] : [];
19475
19514
  }));
19476
19515
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/pi",
3
- "version": "2.27.13",
3
+ "version": "2.29.0",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",