@workit-dev/opencode 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.
Files changed (2) hide show
  1. package/dist/plugin.js +45 -7
  2. package/package.json +2 -2
package/dist/plugin.js CHANGED
@@ -8950,11 +8950,14 @@ function pushRemoteName(cwd, branch) {
8950
8950
  return remotes.length === 1 ? remotes[0] : null;
8951
8951
  }
8952
8952
  function pushUrl(cwd, remote) {
8953
- if (!safeArg(remote))
8954
- return null;
8955
- const urls = git(cwd, ["remote", "get-url", "--push", "--all", remote]).stdout.split(/\r?\n/u).map((value) => value.trim()).filter(Boolean);
8953
+ const urls = pushUrls(cwd, remote);
8956
8954
  return urls.length === 1 ? urls[0] : null;
8957
8955
  }
8956
+ function pushUrls(cwd, remote) {
8957
+ if (!safeArg(remote) || config2(cwd, `remote.${remote}.url`) === null && config2(cwd, `remote.${remote}.pushurl`) === null)
8958
+ return [];
8959
+ return git(cwd, ["remote", "get-url", "--push", "--all", remote]).stdout.split(/\r?\n/u).map((value) => value.trim()).filter(Boolean);
8960
+ }
8958
8961
  var cleanPath = (value) => value.replace(/^\/+/u, "").replace(/\/+$/u, "").replace(/\.git$/u, "");
8959
8962
  function parseRemoteUrl(raw) {
8960
8963
  const value = raw.trim();
@@ -9542,6 +9545,7 @@ var workspaceConfigSchema = object({
9542
9545
  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."),
9543
9546
  resources: unknown().optional().describe("Heavy-check limits on this machine: slots, scope, heavy, light, memoryMax, cpuQuota, wait."),
9544
9547
  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."),
9548
+ 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."),
9545
9549
  autonomy: object(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
9546
9550
  kind,
9547
9551
  union([boolean2(), literal("verified")]).optional().describe(`The ${kind} grant: true, false, or "verified" (only after a verdict).`)
@@ -19476,6 +19480,7 @@ var ENTRY_KEYS = [
19476
19480
  "name",
19477
19481
  "glob",
19478
19482
  "remotes",
19483
+ "externalRepos",
19479
19484
  "vcs",
19480
19485
  "autonomy",
19481
19486
  "autoApprove",
@@ -22331,25 +22336,58 @@ function rawGitPre(input, command, options = {}) {
22331
22336
  return error instanceof ShellAnalysisError ? analysisDenial(error) : NONE2;
22332
22337
  }
22333
22338
  }
22334
- var forgeRepo = (gh, named, env, config) => {
22339
+ var forgeRepo = (gh, named, env, config, branch, dir) => {
22335
22340
  const repo = explicitRepo(gh, named, env);
22336
22341
  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, "");
22337
22342
  const parts = repo.split("/");
22338
22343
  const hosted = gh ? parts.length > 2 : parts.length > 2 && parts[0].includes(".");
22339
22344
  let url = /:\/\/|@/.test(repo) ? repo : parts.length > 1 ? `https://${hosted ? "" : `${host}/`}${repo}` : "";
22340
22345
  if (!repo) {
22341
- const resolved = gh ? [...config.keys()].find((key) => /^remote\..+\.gh-resolved$/.test(key))?.slice(7, -12) : undefined;
22342
- const remote = resolved ?? ["upstream", "origin"].find((name) => config.has(`remote.${name}.url`));
22346
+ const remote = (gh ? ghDefaultOf(config, branch, dir, env) : null) ?? ["upstream", "origin"].find((name) => config.has(`remote.${name}.url`));
22343
22347
  url = rewrittenUrl(configValue(config, `remote.${remote}.url`) ?? "", config);
22344
22348
  }
22345
22349
  const key = remoteKey(url);
22346
22350
  return key ? { remotes: [{ name: "forge", url, key }] } : Error("its repository is unknown");
22347
22351
  };
22352
+ var pushHostOf = (config, remote) => {
22353
+ const urls = config.get(`remote.${remote}.pushurl`) ?? config.get(`remote.${remote}.url`) ?? [];
22354
+ if (urls.length !== 1)
22355
+ return null;
22356
+ return remoteKey(rewrittenUrl(urls[0], config))?.split("/")[0] ?? null;
22357
+ };
22358
+ var ghDefaultOf = (config, branch, dir, env) => {
22359
+ const pushHost = pushHostOf(config, pushRemoteOf(config, branch) ?? "origin");
22360
+ for (const [key, value] of localGhResolved(dir, env)) {
22361
+ const name = key.slice(7, -12);
22362
+ if (!name || value !== "base")
22363
+ continue;
22364
+ const host = pushHostOf(config, name);
22365
+ return host !== null && host === pushHost ? name : null;
22366
+ }
22367
+ return null;
22368
+ };
22369
+ var localGhResolved = (dir, env) => {
22370
+ const values = new Map;
22371
+ const listed = spawnSync17("git", ["config", "--local", "-z", "--get-regexp", "^remote\\..+\\.gh-resolved$"], {
22372
+ cwd: dir,
22373
+ encoding: "utf8",
22374
+ timeout: 3000,
22375
+ windowsHide: true,
22376
+ env: { ...process.env, ...env }
22377
+ });
22378
+ for (const entry of (listed.stdout ?? "").split("\x00")) {
22379
+ const split = entry.indexOf(`
22380
+ `);
22381
+ if (split > 0)
22382
+ values.set(entry.slice(0, split), entry.slice(split + 1));
22383
+ }
22384
+ return values;
22385
+ };
22348
22386
  var explicitRepo = (gh, named, env) => named || (gh ? env.GH_REPO ?? process.env.GH_REPO ?? "" : "");
22349
22387
  var grantRefusal = (action, repo, invocation, cache) => {
22350
22388
  const env = invocation.env ?? {};
22351
22389
  const kinds = [];
22352
- let target = () => forgeRepo(action.kind !== "commit" && "forge" in action && action.forge === "gh", "repo" in action && action.repo || "", env, gitConfig(repo.dir, invocation, cache));
22390
+ 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);
22353
22391
  if (action.kind === "push") {
22354
22392
  target = () => {
22355
22393
  const config = gitConfig(repo.dir, invocation, cache);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/opencode",
3
- "version": "2.21.7",
3
+ "version": "2.21.10",
4
4
  "private": false,
5
5
  "description": "Workit OpenCode plugin — native tools, adaptive policy, and sixteen method skills",
6
6
  "keywords": [
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@opencode/plugin": "2.3.2",
44
- "@workit-dev/core": "^2.21.7"
44
+ "@workit-dev/core": "^2.21.10"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24"