@workit-dev/pi 2.21.9 → 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.
Files changed (2) hide show
  1. package/dist/workit.js +37 -4
  2. package/package.json +1 -1
package/dist/workit.js CHANGED
@@ -22135,25 +22135,58 @@ function rawGitPre(input, command, options = {}) {
22135
22135
  return error instanceof ShellAnalysisError ? analysisDenial(error) : NONE2;
22136
22136
  }
22137
22137
  }
22138
- var forgeRepo = (gh, named, env, config) => {
22138
+ var forgeRepo = (gh, named, env, config, branch, dir) => {
22139
22139
  const repo = explicitRepo(gh, named, env);
22140
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, "");
22141
22141
  const parts = repo.split("/");
22142
22142
  const hosted = gh ? parts.length > 2 : parts.length > 2 && parts[0].includes(".");
22143
22143
  let url = /:\/\/|@/.test(repo) ? repo : parts.length > 1 ? `https://${hosted ? "" : `${host}/`}${repo}` : "";
22144
22144
  if (!repo) {
22145
- const resolved = gh ? [...config.keys()].find((key) => /^remote\..+\.gh-resolved$/.test(key))?.slice(7, -12) : undefined;
22146
- 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`));
22147
22146
  url = rewrittenUrl(configValue(config, `remote.${remote}.url`) ?? "", config);
22148
22147
  }
22149
22148
  const key = remoteKey(url);
22150
22149
  return key ? { remotes: [{ name: "forge", url, key }] } : Error("its repository is unknown");
22151
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
+ };
22152
22185
  var explicitRepo = (gh, named, env) => named || (gh ? env.GH_REPO ?? process.env.GH_REPO ?? "" : "");
22153
22186
  var grantRefusal = (action, repo, invocation, cache) => {
22154
22187
  const env = invocation.env ?? {};
22155
22188
  const kinds = [];
22156
- 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);
22157
22190
  if (action.kind === "push") {
22158
22191
  target = () => {
22159
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.9",
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",