@workit-dev/pi 2.21.7 → 2.21.10

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
@@ -7452,6 +7452,7 @@ var workspaceConfigSchema = object({
7452
7452
  models: object({ roles: modelRoles }).passthrough().optional().describe("Model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false); the same key at the top of workspaces.json is the global default."),
7453
7453
  resources: unknown().optional().describe("Heavy-check limits on this machine: slots, scope, heavy, light, memoryMax, cpuQuota, wait."),
7454
7454
  remotes: array(nonBlank.refine((pattern) => remotePattern(pattern) !== null, "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")).optional().describe("Remote URLs this entry owns: a checkout pushing to or opening PRs on one never exceeds this entry's grants, wherever the folder is (`owner/*` claims a whole owner). Only the user changes it, in their own terminal."),
7455
+ externalRepos: array(nonBlank.regex(/^[\w-]+(?:\/\w[\w.-]*)*\/(?:\w[\w.-]*|\*)$/u, "is owner/name, group/project or owner/* on the checkout's forge host, without the host")).optional().describe("Repositories outside this workspace's own forge owners that `workit issue create|comment|close --repo` may write to: `owner/name`, or `owner/*` for a whole owner. Only the user changes it, in their own terminal."),
7455
7456
  autonomy: object(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
7456
7457
  kind,
7457
7458
  union([boolean2(), literal("verified")]).optional().describe(`The ${kind} grant: true, false, or "verified" (only after a verdict).`)
package/dist/workit.js CHANGED
@@ -9216,6 +9216,7 @@ var workspaceConfigSchema = object({
9216
9216
  models: object({ roles: modelRoles }).passthrough().optional().describe("Model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false); the same key at the top of workspaces.json is the global default."),
9217
9217
  resources: unknown().optional().describe("Heavy-check limits on this machine: slots, scope, heavy, light, memoryMax, cpuQuota, wait."),
9218
9218
  remotes: array(nonBlank.refine((pattern) => remotePattern(pattern) !== null, "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")).optional().describe("Remote URLs this entry owns: a checkout pushing to or opening PRs on one never exceeds this entry's grants, wherever the folder is (`owner/*` claims a whole owner). Only the user changes it, in their own terminal."),
9219
+ externalRepos: array(nonBlank.regex(/^[\w-]+(?:\/\w[\w.-]*)*\/(?:\w[\w.-]*|\*)$/u, "is owner/name, group/project or owner/* on the checkout's forge host, without the host")).optional().describe("Repositories outside this workspace's own forge owners that `workit issue create|comment|close --repo` may write to: `owner/name`, or `owner/*` for a whole owner. Only the user changes it, in their own terminal."),
9219
9220
  autonomy: object(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
9220
9221
  kind,
9221
9222
  union([boolean2(), literal("verified")]).optional().describe(`The ${kind} grant: true, false, or "verified" (only after a verdict).`)
@@ -19323,6 +19324,7 @@ var ENTRY_KEYS = [
19323
19324
  "name",
19324
19325
  "glob",
19325
19326
  "remotes",
19327
+ "externalRepos",
19326
19328
  "vcs",
19327
19329
  "autonomy",
19328
19330
  "autoApprove",
@@ -22133,25 +22135,58 @@ function rawGitPre(input, command, options = {}) {
22133
22135
  return error instanceof ShellAnalysisError ? analysisDenial(error) : NONE2;
22134
22136
  }
22135
22137
  }
22136
- var forgeRepo = (gh, named, env, config) => {
22138
+ var forgeRepo = (gh, named, env, config, branch, dir) => {
22137
22139
  const repo = explicitRepo(gh, named, env);
22138
22140
  const host = (gh ? env.GH_HOST ?? process.env.GH_HOST ?? "github.com" : env.GITLAB_HOST ?? env.GL_HOST ?? process.env.GITLAB_HOST ?? process.env.GL_HOST ?? "gitlab.com").replace(/^\w+:\/\/|\/+$/g, "");
22139
22141
  const parts = repo.split("/");
22140
22142
  const hosted = gh ? parts.length > 2 : parts.length > 2 && parts[0].includes(".");
22141
22143
  let url = /:\/\/|@/.test(repo) ? repo : parts.length > 1 ? `https://${hosted ? "" : `${host}/`}${repo}` : "";
22142
22144
  if (!repo) {
22143
- const resolved = gh ? [...config.keys()].find((key) => /^remote\..+\.gh-resolved$/.test(key))?.slice(7, -12) : undefined;
22144
- const remote = resolved ?? ["upstream", "origin"].find((name) => config.has(`remote.${name}.url`));
22145
+ const remote = (gh ? ghDefaultOf(config, branch, dir, env) : null) ?? ["upstream", "origin"].find((name) => config.has(`remote.${name}.url`));
22145
22146
  url = rewrittenUrl(configValue(config, `remote.${remote}.url`) ?? "", config);
22146
22147
  }
22147
22148
  const key = remoteKey(url);
22148
22149
  return key ? { remotes: [{ name: "forge", url, key }] } : Error("its repository is unknown");
22149
22150
  };
22151
+ var pushHostOf = (config, remote) => {
22152
+ const urls = config.get(`remote.${remote}.pushurl`) ?? config.get(`remote.${remote}.url`) ?? [];
22153
+ if (urls.length !== 1)
22154
+ return null;
22155
+ return remoteKey(rewrittenUrl(urls[0], config))?.split("/")[0] ?? null;
22156
+ };
22157
+ var ghDefaultOf = (config, branch, dir, env) => {
22158
+ const pushHost = pushHostOf(config, pushRemoteOf(config, branch) ?? "origin");
22159
+ for (const [key, value] of localGhResolved(dir, env)) {
22160
+ const name = key.slice(7, -12);
22161
+ if (!name || value !== "base")
22162
+ continue;
22163
+ const host = pushHostOf(config, name);
22164
+ return host !== null && host === pushHost ? name : null;
22165
+ }
22166
+ return null;
22167
+ };
22168
+ var localGhResolved = (dir, env) => {
22169
+ const values = new Map;
22170
+ const listed = spawnSync17("git", ["config", "--local", "-z", "--get-regexp", "^remote\\..+\\.gh-resolved$"], {
22171
+ cwd: dir,
22172
+ encoding: "utf8",
22173
+ timeout: 3000,
22174
+ windowsHide: true,
22175
+ env: { ...process.env, ...env }
22176
+ });
22177
+ for (const entry of (listed.stdout ?? "").split("\x00")) {
22178
+ const split = entry.indexOf(`
22179
+ `);
22180
+ if (split > 0)
22181
+ values.set(entry.slice(0, split), entry.slice(split + 1));
22182
+ }
22183
+ return values;
22184
+ };
22150
22185
  var explicitRepo = (gh, named, env) => named || (gh ? env.GH_REPO ?? process.env.GH_REPO ?? "" : "");
22151
22186
  var grantRefusal = (action, repo, invocation, cache) => {
22152
22187
  const env = invocation.env ?? {};
22153
22188
  const kinds = [];
22154
- let target = () => forgeRepo(action.kind !== "commit" && "forge" in action && action.forge === "gh", "repo" in action && action.repo || "", env, gitConfig(repo.dir, invocation, cache));
22189
+ let target = () => forgeRepo(action.kind !== "commit" && "forge" in action && action.forge === "gh", "repo" in action && action.repo || "", env, gitConfig(repo.dir, invocation, cache), repo.branch, repo.dir);
22155
22190
  if (action.kind === "push") {
22156
22191
  target = () => {
22157
22192
  const config = gitConfig(repo.dir, invocation, cache);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/pi",
3
- "version": "2.21.7",
3
+ "version": "2.21.10",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",