@workit-dev/opencode 2.21.9 → 2.22.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/plugin.js +43 -7
- 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
|
-
|
|
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();
|
|
@@ -22333,25 +22336,58 @@ function rawGitPre(input, command, options = {}) {
|
|
|
22333
22336
|
return error instanceof ShellAnalysisError ? analysisDenial(error) : NONE2;
|
|
22334
22337
|
}
|
|
22335
22338
|
}
|
|
22336
|
-
var forgeRepo = (gh, named, env, config) => {
|
|
22339
|
+
var forgeRepo = (gh, named, env, config, branch, dir) => {
|
|
22337
22340
|
const repo = explicitRepo(gh, named, env);
|
|
22338
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, "");
|
|
22339
22342
|
const parts = repo.split("/");
|
|
22340
22343
|
const hosted = gh ? parts.length > 2 : parts.length > 2 && parts[0].includes(".");
|
|
22341
22344
|
let url = /:\/\/|@/.test(repo) ? repo : parts.length > 1 ? `https://${hosted ? "" : `${host}/`}${repo}` : "";
|
|
22342
22345
|
if (!repo) {
|
|
22343
|
-
const
|
|
22344
|
-
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`));
|
|
22345
22347
|
url = rewrittenUrl(configValue(config, `remote.${remote}.url`) ?? "", config);
|
|
22346
22348
|
}
|
|
22347
22349
|
const key = remoteKey(url);
|
|
22348
22350
|
return key ? { remotes: [{ name: "forge", url, key }] } : Error("its repository is unknown");
|
|
22349
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
|
+
};
|
|
22350
22386
|
var explicitRepo = (gh, named, env) => named || (gh ? env.GH_REPO ?? process.env.GH_REPO ?? "" : "");
|
|
22351
22387
|
var grantRefusal = (action, repo, invocation, cache) => {
|
|
22352
22388
|
const env = invocation.env ?? {};
|
|
22353
22389
|
const kinds = [];
|
|
22354
|
-
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);
|
|
22355
22391
|
if (action.kind === "push") {
|
|
22356
22392
|
target = () => {
|
|
22357
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.
|
|
3
|
+
"version": "2.22.0",
|
|
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.
|
|
44
|
+
"@workit-dev/core": "^2.22.0"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=24"
|