@workit-dev/opencode 2.20.6 → 2.21.1
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 +368 -248
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -9511,7 +9511,8 @@ var workspaceConfigSchema = object({
|
|
|
9511
9511
|
youtrack: object({
|
|
9512
9512
|
baseUrl: nonBlank.optional().describe("This workspace's YouTrack URL."),
|
|
9513
9513
|
link_issues: boolean2().optional().describe("Legacy alias of `issues: { provider: youtrack, link: true }`."),
|
|
9514
|
-
writes: _enum(["ask", "auto"]).optional().describe("ask (default): each workit youtrack write waits for the user's yes. auto: posts without asking, behind WORKIT_YT_WRITE=1.")
|
|
9514
|
+
writes: _enum(["ask", "auto"]).optional().describe("ask (default): each workit youtrack write waits for the user's yes. auto: posts without asking, behind WORKIT_YT_WRITE=1."),
|
|
9515
|
+
autoHosts: array(nonBlank).optional().describe("With writes auto: the only YouTrack hosts (`acme.youtrack.cloud`) a write may reach without asking. A raw ytrack write must name one with --host; a write elsewhere asks. Only the user widens it, in their own terminal (`workit workspace seal`).")
|
|
9515
9516
|
}).passthrough().optional().describe("YouTrack settings for this workspace."),
|
|
9516
9517
|
issues: object({
|
|
9517
9518
|
provider: _enum(["github", "gitlab", "youtrack"]).optional().describe("The issue tracker PRs link to."),
|
|
@@ -19372,20 +19373,20 @@ var exportDigest = (bundle) => sha256({
|
|
|
19372
19373
|
task: bundle.task
|
|
19373
19374
|
});
|
|
19374
19375
|
// packages/workit-core/src/core/route-intent.ts
|
|
19375
|
-
import { spawnSync as
|
|
19376
|
+
import { spawnSync as spawnSync18 } from "node:child_process";
|
|
19376
19377
|
import { existsSync as existsSync12 } from "node:fs";
|
|
19377
|
-
import
|
|
19378
|
+
import path31 from "node:path";
|
|
19378
19379
|
|
|
19379
19380
|
// packages/workit-core/src/hooks/raw-git.ts
|
|
19380
|
-
import { spawnSync as
|
|
19381
|
+
import { spawnSync as spawnSync17 } from "node:child_process";
|
|
19381
19382
|
import { createHash as createHash17 } from "node:crypto";
|
|
19382
|
-
import
|
|
19383
|
+
import fs21 from "node:fs";
|
|
19383
19384
|
import os6 from "node:os";
|
|
19384
|
-
import
|
|
19385
|
+
import path30 from "node:path";
|
|
19385
19386
|
|
|
19386
19387
|
// packages/workit-core/src/autonomy.ts
|
|
19387
19388
|
import { closeSync as closeSync2, copyFileSync as copyFileSync2, existsSync as existsSync11, openSync as openSync2 } from "node:fs";
|
|
19388
|
-
import
|
|
19389
|
+
import path28 from "node:path";
|
|
19389
19390
|
|
|
19390
19391
|
// packages/workit-core/src/core/eval-world.ts
|
|
19391
19392
|
import { existsSync as existsSync10, realpathSync as realpathSync6 } from "node:fs";
|
|
@@ -19450,7 +19451,7 @@ var sealProjection = (entries) => entries.map((entry) => {
|
|
|
19450
19451
|
return pick2({
|
|
19451
19452
|
...all,
|
|
19452
19453
|
vcs: pick2(all.vcs, IDENTITY_KEYS),
|
|
19453
|
-
youtrack: pick2(all.youtrack, ["writes"])
|
|
19454
|
+
youtrack: pick2(all.youtrack, ["writes", "autoHosts"])
|
|
19454
19455
|
}, ENTRY_KEYS);
|
|
19455
19456
|
});
|
|
19456
19457
|
var canonical3 = (value) => JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) : item);
|
|
@@ -19480,6 +19481,170 @@ function checkSeal(dir) {
|
|
|
19480
19481
|
return ok && sealDigest(sealProjection(current.entries)) === seal.sha256 ? { state: "valid" } : broken("workspaces.json changed since it was sealed", sealed.entries);
|
|
19481
19482
|
}
|
|
19482
19483
|
|
|
19484
|
+
// packages/workit-core/src/core/youtrack-ytrack.ts
|
|
19485
|
+
import { spawnSync as spawnSync16 } from "node:child_process";
|
|
19486
|
+
|
|
19487
|
+
// packages/workit-core/src/forge/exec.ts
|
|
19488
|
+
import fs19 from "node:fs";
|
|
19489
|
+
import path27 from "node:path";
|
|
19490
|
+
|
|
19491
|
+
// packages/workit-core/src/forge/redact.ts
|
|
19492
|
+
var NAME = "[A-Za-z0-9_.-]";
|
|
19493
|
+
var KEY = String.raw`(?<!${NAME})(?=${NAME}*?(?:token|secret|password|passwd|pwd|api[_-]?key|access[_-]?key|account[_-]?key|private[_-]?key|client[_-]?secret|credentials?|authorization|cookie|signature))${NAME}+`;
|
|
19494
|
+
var ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*["']?)((?:bearer|basic|token|digest)\s+)?([^\s"',;&]+)`, "giu");
|
|
19495
|
+
var QUOTED_ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*)(["'])([^"'\n]*[^\s"'][^"'\n]*)\2`, "giu");
|
|
19496
|
+
var SECRET_FLAG = new RegExp(String.raw`(?<![\w-])(--(?=[\w-]*?(?<![a-z0-9])(?:password|passwd|pwd|secret|token|api[-_]?key|auth|authorization|credentials?|private[-_]?key|access[-_]?key)(?![a-z0-9]))[\w-]+(?:\s+|=))((?:bearer|basic|token|digest)\s+(?![\s-]))?(?:(["'])(?:[^\n]*?\3|[^\n]*)|(?!-)[^\s"']+)`, "giu");
|
|
19497
|
+
var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*\u0007`, "gu");
|
|
19498
|
+
|
|
19499
|
+
// packages/workit-core/src/forge/types.ts
|
|
19500
|
+
var success2 = (data) => ({ ok: true, data });
|
|
19501
|
+
var failure3 = (code, error, unblock) => ({ ok: false, code, error, ...unblock ? { unblock } : {} });
|
|
19502
|
+
|
|
19503
|
+
// packages/workit-core/src/forge/exec.ts
|
|
19504
|
+
var MAX_BUFFER2 = 64 * 1024 * 1024;
|
|
19505
|
+
function findExecutable(bin, env) {
|
|
19506
|
+
const dirs = (env.PATH ?? env.Path ?? "").split(path27.delimiter).filter(Boolean);
|
|
19507
|
+
const exts = process.platform === "win32" ? [".exe"] : [""];
|
|
19508
|
+
for (const dir of dirs)
|
|
19509
|
+
for (const ext of exts) {
|
|
19510
|
+
const candidate = path27.join(dir, `${bin}${ext}`);
|
|
19511
|
+
try {
|
|
19512
|
+
const stat = fs19.statSync(candidate);
|
|
19513
|
+
if (stat.isFile())
|
|
19514
|
+
return candidate;
|
|
19515
|
+
} catch {}
|
|
19516
|
+
}
|
|
19517
|
+
return null;
|
|
19518
|
+
}
|
|
19519
|
+
|
|
19520
|
+
// packages/workit-core/src/core/youtrack-ytrack.ts
|
|
19521
|
+
var TIMEOUT_MS = 60000;
|
|
19522
|
+
var YTRACK_EXIT = { ok: 0, failed: 1, cancelled: 2, auth: 4 };
|
|
19523
|
+
var findYtrack = (env) => env.WORKIT_NO_YTRACK === "1" ? null : findExecutable("ytrack", env);
|
|
19524
|
+
var YTRACK_QUIET_ENV = {
|
|
19525
|
+
YTRACK_NO_UPDATE_NOTIFIER: "1",
|
|
19526
|
+
YTRACK_NO_AUTO_UPGRADE: "1"
|
|
19527
|
+
};
|
|
19528
|
+
function ytrackRunner(env, host, timeoutMs = TIMEOUT_MS) {
|
|
19529
|
+
return (args, input) => {
|
|
19530
|
+
const exe = findYtrack(env);
|
|
19531
|
+
if (!exe)
|
|
19532
|
+
return { status: null, stdout: "", stderr: "", missing: true };
|
|
19533
|
+
const result = spawnSync16(exe, args, {
|
|
19534
|
+
encoding: "utf8",
|
|
19535
|
+
env: {
|
|
19536
|
+
...env,
|
|
19537
|
+
NO_COLOR: "1",
|
|
19538
|
+
...YTRACK_QUIET_ENV,
|
|
19539
|
+
...host ? { YTRACK_HOST: host } : {}
|
|
19540
|
+
},
|
|
19541
|
+
timeout: timeoutMs,
|
|
19542
|
+
killSignal: "SIGKILL",
|
|
19543
|
+
windowsHide: true,
|
|
19544
|
+
...input === undefined ? { stdio: ["ignore", "pipe", "pipe"] } : { input, stdio: ["pipe", "pipe", "pipe"] }
|
|
19545
|
+
});
|
|
19546
|
+
const error = result.error;
|
|
19547
|
+
if (error?.code === "ENOENT")
|
|
19548
|
+
return { status: null, stdout: "", stderr: "", missing: true };
|
|
19549
|
+
return {
|
|
19550
|
+
status: result.status,
|
|
19551
|
+
stdout: result.stdout ?? "",
|
|
19552
|
+
stderr: result.stderr || (error ? error.message : "")
|
|
19553
|
+
};
|
|
19554
|
+
};
|
|
19555
|
+
}
|
|
19556
|
+
var ytrackDetail = (out) => out.stderr.trim().split(`
|
|
19557
|
+
`).slice(-3).join(" ").slice(0, 300);
|
|
19558
|
+
var STATUS_FIELDS = "host,active,login,state,tokenSource,error";
|
|
19559
|
+
function ytrackStatus(run) {
|
|
19560
|
+
const version = run(["version"]);
|
|
19561
|
+
if (version.missing)
|
|
19562
|
+
return { installed: false };
|
|
19563
|
+
const match = /ytrack version (\S+)/u.exec(version.stdout);
|
|
19564
|
+
const status = run(["auth", "status", "--json", STATUS_FIELDS]);
|
|
19565
|
+
const base = { installed: true, version: match ? match[1] : null };
|
|
19566
|
+
if (status.status === YTRACK_EXIT.auth)
|
|
19567
|
+
return { ...base, auth: "logged_out", hosts: [], error: ytrackDetail(status) || null };
|
|
19568
|
+
let rows;
|
|
19569
|
+
try {
|
|
19570
|
+
rows = JSON.parse(status.stdout);
|
|
19571
|
+
} catch {
|
|
19572
|
+
return { ...base, auth: "error", hosts: [], error: ytrackDetail(status) || "no JSON" };
|
|
19573
|
+
}
|
|
19574
|
+
const hosts = (Array.isArray(rows) ? rows : [rows]).filter((row) => typeof row === "object" && row !== null).map((row) => ({
|
|
19575
|
+
host: String(row.host ?? ""),
|
|
19576
|
+
active: row.active === true,
|
|
19577
|
+
login: typeof row.login === "string" && row.login ? row.login : null,
|
|
19578
|
+
state: String(row.state ?? "error"),
|
|
19579
|
+
tokenSource: typeof row.tokenSource === "string" && row.tokenSource ? row.tokenSource : null,
|
|
19580
|
+
error: typeof row.error === "string" && row.error ? row.error : null
|
|
19581
|
+
}));
|
|
19582
|
+
const active = hosts.find((row) => row.active) ?? hosts[0];
|
|
19583
|
+
return { ...base, auth: rowAuth(active), hosts, error: null };
|
|
19584
|
+
}
|
|
19585
|
+
var rowAuth = (row) => !row ? "logged_out" : row.state === "ok" ? "ok" : row.state === "rejected" ? "rejected" : row.state === "no_token" ? "logged_out" : "error";
|
|
19586
|
+
var ytrackHostName = (urlOrHost) => urlOrHost.trim().replace(/^[a-z][a-z0-9+.-]*:\/\//iu, "").split("/")[0].toLowerCase();
|
|
19587
|
+
var youTrackHostKey = (input) => {
|
|
19588
|
+
const text = input.trim();
|
|
19589
|
+
if (!text || /\s/u.test(text))
|
|
19590
|
+
return null;
|
|
19591
|
+
let url;
|
|
19592
|
+
try {
|
|
19593
|
+
url = new URL(text.includes("://") ? text : `https://${text}`);
|
|
19594
|
+
} catch {
|
|
19595
|
+
return null;
|
|
19596
|
+
}
|
|
19597
|
+
if (!/^https?:$/u.test(url.protocol) || !url.hostname || url.username || url.password)
|
|
19598
|
+
return null;
|
|
19599
|
+
const service = url.pathname.replace(/\/+$/u, "").replace(/\/api$/u, "").replace(/\/+$/u, "");
|
|
19600
|
+
return `${url.host.toLowerCase()}${service}`;
|
|
19601
|
+
};
|
|
19602
|
+
var youTrackHostAllowed = (allowed, host) => {
|
|
19603
|
+
const key = host ? youTrackHostKey(host) : null;
|
|
19604
|
+
return key !== null && allowed.some((entry) => youTrackHostKey(entry) === key);
|
|
19605
|
+
};
|
|
19606
|
+
function ytrackHostAuth(status, host) {
|
|
19607
|
+
if (!host) {
|
|
19608
|
+
const active = status.hosts.find((row) => row.active) ?? status.hosts[0];
|
|
19609
|
+
return {
|
|
19610
|
+
auth: status.auth,
|
|
19611
|
+
login: active?.login ?? null,
|
|
19612
|
+
error: active?.error ?? status.error
|
|
19613
|
+
};
|
|
19614
|
+
}
|
|
19615
|
+
const name = ytrackHostName(host);
|
|
19616
|
+
const row = status.hosts.find((candidate) => ytrackHostName(candidate.host) === name);
|
|
19617
|
+
return {
|
|
19618
|
+
auth: status.auth === "error" && !row ? "error" : rowAuth(row),
|
|
19619
|
+
login: row?.login ?? null,
|
|
19620
|
+
error: row?.error ?? status.error
|
|
19621
|
+
};
|
|
19622
|
+
}
|
|
19623
|
+
var YTRACK_INSTALL = "install ytrack (https://github.com/BrainerVirus/youtrack-cli: install.sh, or install.ps1 on Windows)";
|
|
19624
|
+
var ytrackLogin = (host) => `ytrack auth login${host ? ` --host ${ytrackHostName(host)}` : ""}`;
|
|
19625
|
+
var ytrackMissingUnblock = (host) => `${YTRACK_INSTALL}, then ${ytrackLogin(host)}`;
|
|
19626
|
+
var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only through ytrack";
|
|
19627
|
+
function ytrackReadiness(run, host) {
|
|
19628
|
+
const status = ytrackStatus(run);
|
|
19629
|
+
if (!status.installed)
|
|
19630
|
+
return {
|
|
19631
|
+
ok: false,
|
|
19632
|
+
reason: "missing",
|
|
19633
|
+
error: YTRACK_MISSING,
|
|
19634
|
+
unblock: ytrackMissingUnblock(host)
|
|
19635
|
+
};
|
|
19636
|
+
const auth = ytrackHostAuth(status, host);
|
|
19637
|
+
const where = host ? ytrackHostName(host) : "the active host";
|
|
19638
|
+
if (auth.auth === "ok")
|
|
19639
|
+
return { ok: true, version: status.version, login: auth.login };
|
|
19640
|
+
return {
|
|
19641
|
+
ok: false,
|
|
19642
|
+
reason: auth.auth,
|
|
19643
|
+
error: auth.auth === "logged_out" ? `ytrack is not logged in to ${where}` : auth.auth === "rejected" ? `${where} rejected ytrack's stored token` : `could not read ytrack's login for ${where}${auth.error ? ` (${auth.error})` : ""}`,
|
|
19644
|
+
unblock: ytrackLogin(host)
|
|
19645
|
+
};
|
|
19646
|
+
}
|
|
19647
|
+
|
|
19483
19648
|
// packages/workit-core/src/autonomy.ts
|
|
19484
19649
|
var accountHomeDir = () => {
|
|
19485
19650
|
const home = grantsHome.resolve();
|
|
@@ -19487,7 +19652,7 @@ var accountHomeDir = () => {
|
|
|
19487
19652
|
};
|
|
19488
19653
|
var deniedFile = (dir) => {
|
|
19489
19654
|
for (const name of ["workspaces.json", SEAL_FILE]) {
|
|
19490
|
-
const file =
|
|
19655
|
+
const file = path28.join(dir, name);
|
|
19491
19656
|
try {
|
|
19492
19657
|
closeSync2(openSync2(file, "r"));
|
|
19493
19658
|
} catch (error) {
|
|
@@ -19509,7 +19674,7 @@ var accountUnread = () => {
|
|
|
19509
19674
|
if (dir === null)
|
|
19510
19675
|
return NO_ACCOUNT;
|
|
19511
19676
|
const file = deniedFile(dir);
|
|
19512
|
-
return file === null ? null : `the account's ${
|
|
19677
|
+
return file === null ? null : `the account's ${path28.basename(file)} cannot be read (permission denied), so it reads as no workspace entries: no grants, no models, the D4 defaults apply`;
|
|
19513
19678
|
};
|
|
19514
19679
|
var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
|
|
19515
19680
|
var fileSource = (dir = accountDir()) => ({
|
|
@@ -19528,26 +19693,40 @@ var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own
|
|
|
19528
19693
|
var NO_SEAL_UNBLOCK = `ask the user to review and seal the grants, in their own terminal: ${SEAL_COMMAND}`;
|
|
19529
19694
|
var NO_SEAL_NOTE = `workspaces.json has no seal yet (${SEAL_COMMAND} has never run), so grants, endpoint, verification and youtrack.writes stay at or below the D4 defaults; ${NO_SEAL_UNBLOCK}`;
|
|
19530
19695
|
var sealNote = (seal = sealOf()) => seal.state === "broken" ? `workspaces.json does not match its seal (${seal.reason}), so grants, endpoint, verification and youtrack.writes are the stricter of their current and last sealed values; ${SEAL_UNBLOCK}` : null;
|
|
19531
|
-
var
|
|
19696
|
+
var ASK = { mode: "ask" };
|
|
19697
|
+
var youtrackOf = (entry) => entry?.youtrack;
|
|
19698
|
+
var autoHostsOf = (entry) => {
|
|
19699
|
+
const hosts = youtrackOf(entry)?.autoHosts;
|
|
19700
|
+
return Array.isArray(hosts) ? hosts.filter((host) => typeof host === "string") : null;
|
|
19701
|
+
};
|
|
19702
|
+
var youTrackWritesPolicy = (cwd) => {
|
|
19532
19703
|
try {
|
|
19533
19704
|
const dir = accountDir();
|
|
19534
19705
|
if (dir === null || redirected(dir) || evalWorld(cwd))
|
|
19535
|
-
return
|
|
19706
|
+
return ASK;
|
|
19536
19707
|
if (checkSeal(dir).state !== "valid")
|
|
19537
|
-
return
|
|
19538
|
-
const auto = (entry) => entry?.
|
|
19708
|
+
return ASK;
|
|
19709
|
+
const auto = (entry) => youtrackOf(entry)?.writes === "auto";
|
|
19539
19710
|
const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
19540
|
-
|
|
19541
|
-
|
|
19542
|
-
|
|
19711
|
+
const named = resolveWorkspaceFrom(cwd, dir, name);
|
|
19712
|
+
const folder = name ? resolveWorkspaceFrom(cwd, dir) : named;
|
|
19713
|
+
if (!auto(named) || !auto(folder))
|
|
19714
|
+
return ASK;
|
|
19715
|
+
const [a, b] = [autoHostsOf(named), autoHostsOf(folder)];
|
|
19716
|
+
const base = youtrackOf(named)?.baseUrl;
|
|
19717
|
+
return {
|
|
19718
|
+
mode: "auto",
|
|
19719
|
+
hosts: a === null ? b : b === null ? a : a.filter((host) => youTrackHostAllowed(b, host)),
|
|
19720
|
+
baseUrl: typeof base === "string" && base.trim() ? base.trim() : null
|
|
19721
|
+
};
|
|
19543
19722
|
} catch {
|
|
19544
|
-
return
|
|
19723
|
+
return ASK;
|
|
19545
19724
|
}
|
|
19546
19725
|
};
|
|
19547
|
-
var redirected = (dir) =>
|
|
19726
|
+
var redirected = (dir) => path28.resolve(resolveConfigDir()) !== path28.resolve(dir);
|
|
19548
19727
|
var shownGrantsDir = () => {
|
|
19549
19728
|
const world = evalWorld(process.cwd());
|
|
19550
|
-
return world ?
|
|
19729
|
+
return world ? path28.join(world, "config") : accountDir();
|
|
19551
19730
|
};
|
|
19552
19731
|
var benchWorld = (cwd) => {
|
|
19553
19732
|
const entry = evalWorldEntry(cwd);
|
|
@@ -19571,10 +19750,10 @@ var grantsOverride = () => {
|
|
|
19571
19750
|
const shown = shownGrantsDir();
|
|
19572
19751
|
if (shown === null)
|
|
19573
19752
|
return accountUnread() ?? NO_ACCOUNT;
|
|
19574
|
-
const configured =
|
|
19575
|
-
return configured ===
|
|
19753
|
+
const configured = path28.resolve(resolveConfigDir());
|
|
19754
|
+
return configured === path28.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path28.join(grantsDir(), "workspaces.json")}, and under a redirect they never exceed the D4 defaults`;
|
|
19576
19755
|
};
|
|
19577
|
-
var redirectUnblock = () => `ask the user: grants above the D4 defaults apply only without a config redirect (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), and are read from ${
|
|
19756
|
+
var redirectUnblock = () => `ask the user: grants above the D4 defaults apply only without a config redirect (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), and are read from ${path28.join(grantsDir(), "workspaces.json")}`;
|
|
19578
19757
|
var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
|
|
19579
19758
|
var DEFAULT_GRANTS = Object.freeze({
|
|
19580
19759
|
push: true,
|
|
@@ -19982,8 +20161,8 @@ var packageTagShapes = (packages) => packages.map((entry) => `${entry.tagNamespa
|
|
|
19982
20161
|
|
|
19983
20162
|
// packages/workit-core/src/hooks/session-marker.ts
|
|
19984
20163
|
import { createHash as createHash16 } from "node:crypto";
|
|
19985
|
-
import
|
|
19986
|
-
import
|
|
20164
|
+
import fs20 from "node:fs";
|
|
20165
|
+
import path29 from "node:path";
|
|
19987
20166
|
var sessionMarkerFile = (input, session, store) => {
|
|
19988
20167
|
let dir = store;
|
|
19989
20168
|
if (dir === undefined) {
|
|
@@ -19993,7 +20172,7 @@ var sessionMarkerFile = (input, session, store) => {
|
|
|
19993
20172
|
dir = location.dir;
|
|
19994
20173
|
}
|
|
19995
20174
|
const name = createHash16("sha256").update(`${input.host}\x00${session}`).digest("hex").slice(0, 32);
|
|
19996
|
-
return
|
|
20175
|
+
return path29.join(dir, "hooks", `skills-${name}.json`);
|
|
19997
20176
|
};
|
|
19998
20177
|
var list2 = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
19999
20178
|
var EMPTY = {
|
|
@@ -20006,7 +20185,7 @@ var EMPTY = {
|
|
|
20006
20185
|
};
|
|
20007
20186
|
var readRaw = (file) => {
|
|
20008
20187
|
try {
|
|
20009
|
-
return
|
|
20188
|
+
return fs20.readFileSync(file, "utf8");
|
|
20010
20189
|
} catch {
|
|
20011
20190
|
return "";
|
|
20012
20191
|
}
|
|
@@ -20028,13 +20207,13 @@ var parseMarker = (text) => {
|
|
|
20028
20207
|
};
|
|
20029
20208
|
var readSessionMarker = (file) => parseMarker(readRaw(file));
|
|
20030
20209
|
var writeAtomic = (file, marker) => {
|
|
20031
|
-
|
|
20210
|
+
fs20.mkdirSync(path29.dirname(file), { recursive: true });
|
|
20032
20211
|
const temp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
20033
20212
|
try {
|
|
20034
|
-
|
|
20035
|
-
|
|
20213
|
+
fs20.writeFileSync(temp, JSON.stringify(marker));
|
|
20214
|
+
fs20.renameSync(temp, file);
|
|
20036
20215
|
} catch (error) {
|
|
20037
|
-
|
|
20216
|
+
fs20.rmSync(temp, { force: true });
|
|
20038
20217
|
throw error;
|
|
20039
20218
|
}
|
|
20040
20219
|
};
|
|
@@ -20591,17 +20770,17 @@ var GIT_VALUE_OPTIONS = new Set([
|
|
|
20591
20770
|
]);
|
|
20592
20771
|
var GIT_CONFIG_OPTIONS = new Set(["-c", "--config-env", "--git-dir"]);
|
|
20593
20772
|
var GIT_CONFIG_ENV = /^(?:GIT_(?:CONFIG\w*|DIR|COMMON_DIR|WORK_TREE|SSH|SSH_COMMAND|PROXY_COMMAND|EXEC_PATH)|GH_HOST|GH_REPO|GITLAB_HOST|GL_HOST)$/;
|
|
20594
|
-
var
|
|
20773
|
+
var ASSIGNMENT2 = /^([A-Za-z_]\w*)=([\s\S]*)$/;
|
|
20595
20774
|
var MAX_DEPTH = 4;
|
|
20596
20775
|
var MAX_EXPANSIONS = 16;
|
|
20597
|
-
var isAbsolute = (value) =>
|
|
20776
|
+
var isAbsolute = (value) => path30.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
|
|
20598
20777
|
var HERE = /^(?:\$PWD|\$\{PWD\}|\$\(\s*pwd\s*\)|`pwd`|\$\(\s*git\s+rev-parse\s+--show-toplevel\s*\))(?=$|[\\/])/;
|
|
20599
20778
|
var joinDir = (base, raw) => {
|
|
20600
20779
|
const next = raw.replace(HERE, ".");
|
|
20601
20780
|
if (base === undefined || /[$`*?]/.test(next) || next === "-")
|
|
20602
20781
|
return;
|
|
20603
|
-
const expanded = next === "~" || next.startsWith("~/") ?
|
|
20604
|
-
return base === null || isAbsolute(expanded) ? expanded :
|
|
20782
|
+
const expanded = next === "~" || next.startsWith("~/") ? path30.join(os6.homedir(), next.slice(1)) : next;
|
|
20783
|
+
return base === null || isAbsolute(expanded) ? expanded : path30.join(base, expanded);
|
|
20605
20784
|
};
|
|
20606
20785
|
var rebase = (base, inner) => inner === null ? base : inner === undefined ? undefined : joinDir(base, inner);
|
|
20607
20786
|
var cdTarget = (words) => {
|
|
@@ -20618,7 +20797,7 @@ var stripPrefixes = (input) => {
|
|
|
20618
20797
|
const first = words[0];
|
|
20619
20798
|
if (first === undefined)
|
|
20620
20799
|
return { words, env };
|
|
20621
|
-
const assignment =
|
|
20800
|
+
const assignment = ASSIGNMENT2.exec(first);
|
|
20622
20801
|
if (assignment) {
|
|
20623
20802
|
if (GIT_CONFIG_ENV.test(assignment[1]))
|
|
20624
20803
|
env[assignment[1]] = assignment[2];
|
|
@@ -20677,10 +20856,10 @@ var assignments = (words, vars) => {
|
|
|
20677
20856
|
while (rest[0]?.startsWith("-"))
|
|
20678
20857
|
rest = rest.slice(1);
|
|
20679
20858
|
}
|
|
20680
|
-
if (rest.length === 0 || !rest.every((word) =>
|
|
20859
|
+
if (rest.length === 0 || !rest.every((word) => ASSIGNMENT2.test(word)))
|
|
20681
20860
|
return null;
|
|
20682
20861
|
return rest.map((word) => {
|
|
20683
|
-
const [, name, value] =
|
|
20862
|
+
const [, name, value] = ASSIGNMENT2.exec(word);
|
|
20684
20863
|
return [name, expandWord(value, vars)];
|
|
20685
20864
|
});
|
|
20686
20865
|
};
|
|
@@ -20868,7 +21047,7 @@ var splitString = (line) => {
|
|
|
20868
21047
|
return line.slice(index).join(" ").slice(15);
|
|
20869
21048
|
if (/^-S./.test(word))
|
|
20870
21049
|
return [word.slice(2), ...line.slice(index + 1)].join(" ");
|
|
20871
|
-
if (!word.startsWith("-") && !
|
|
21050
|
+
if (!word.startsWith("-") && !ASSIGNMENT2.test(word))
|
|
20872
21051
|
return null;
|
|
20873
21052
|
}
|
|
20874
21053
|
return null;
|
|
@@ -21502,7 +21681,7 @@ var repoAt = (dir) => {
|
|
|
21502
21681
|
return { location, dir, branch: resolveTaskKey(dir, location).branch };
|
|
21503
21682
|
};
|
|
21504
21683
|
var isWorkitWorkspace = (repo) => {
|
|
21505
|
-
if (
|
|
21684
|
+
if (fs21.existsSync(repo.location.dir))
|
|
21506
21685
|
return true;
|
|
21507
21686
|
try {
|
|
21508
21687
|
return resolveRuntimeWorkspaceVcs(repo.location.top ?? repo.dir) !== null;
|
|
@@ -21523,17 +21702,17 @@ var headSha2 = (repo) => {
|
|
|
21523
21702
|
if (!git || git.reftable)
|
|
21524
21703
|
return null;
|
|
21525
21704
|
try {
|
|
21526
|
-
const head =
|
|
21705
|
+
const head = fs21.readFileSync(path30.join(git.gitDir, "HEAD"), "utf8").trim();
|
|
21527
21706
|
if (/^[0-9a-f]{40,64}$/.test(head))
|
|
21528
21707
|
return head;
|
|
21529
21708
|
const ref = /^ref: (refs\/.+)$/.exec(head)?.[1];
|
|
21530
21709
|
if (!ref)
|
|
21531
21710
|
return null;
|
|
21532
|
-
const common =
|
|
21711
|
+
const common = path30.dirname(repo.location.dir);
|
|
21533
21712
|
try {
|
|
21534
|
-
return
|
|
21713
|
+
return fs21.readFileSync(path30.join(common, ref), "utf8").trim() || null;
|
|
21535
21714
|
} catch {}
|
|
21536
|
-
const packed =
|
|
21715
|
+
const packed = fs21.readFileSync(path30.join(common, "packed-refs"), "utf8");
|
|
21537
21716
|
return new RegExp(`^([0-9a-f]{40,64}) ${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`, "m").exec(packed)?.[1] ?? null;
|
|
21538
21717
|
} catch {
|
|
21539
21718
|
return null;
|
|
@@ -21545,7 +21724,7 @@ var gitConfig = (dir, invocation, cache) => {
|
|
|
21545
21724
|
if (cached)
|
|
21546
21725
|
return cached;
|
|
21547
21726
|
const config = new Map;
|
|
21548
|
-
const listed =
|
|
21727
|
+
const listed = spawnSync17("git", [...invocation.config ?? [], "config", "-z", "--list"], {
|
|
21549
21728
|
cwd: dir,
|
|
21550
21729
|
encoding: "utf8",
|
|
21551
21730
|
timeout: 3000,
|
|
@@ -21626,8 +21805,8 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
|
|
|
21626
21805
|
const sub = invocation.args[0];
|
|
21627
21806
|
if (invocation.tool !== "git" || invocation.dir === undefined || !sub || sub.startsWith("-") || GIT_COMMANDS.has(sub) || depth >= MAX_DEPTH)
|
|
21628
21807
|
return [invocation];
|
|
21629
|
-
const dir =
|
|
21630
|
-
if (!
|
|
21808
|
+
const dir = path30.resolve(root, invocation.dir ?? ".");
|
|
21809
|
+
if (!fs21.existsSync(dir))
|
|
21631
21810
|
return [invocation];
|
|
21632
21811
|
const config = gitConfig(dir, invocation, cache);
|
|
21633
21812
|
const alias = configValue(config, `alias.${sub.toLowerCase()}`);
|
|
@@ -21649,11 +21828,11 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
|
|
|
21649
21828
|
var normalizedUrl = (url, dir) => {
|
|
21650
21829
|
const trimmed = url.trim();
|
|
21651
21830
|
if (/^file:\/\//i.test(trimmed))
|
|
21652
|
-
return
|
|
21831
|
+
return path30.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
|
|
21653
21832
|
const scheme = /^[a-z][a-z0-9+.-]*:\/\//i.exec(trimmed);
|
|
21654
21833
|
const scp = !scheme && /^(?:[^@/\\]+@)?[^/\\:]{2,}:/.test(trimmed);
|
|
21655
21834
|
if (!scheme && !scp)
|
|
21656
|
-
return
|
|
21835
|
+
return path30.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
|
|
21657
21836
|
const value = scheme ? trimmed.slice(scheme[0].length).replace(/^[^@/]*@/, "").replace(/^([^/:]+):\d+(?=\/)/, "$1") : trimmed.replace(/^[^@/]*@/, "").replace(":", "/");
|
|
21658
21837
|
return value.toLowerCase().replace(/\/{2,}/g, "/").replace(/^www\./, "").replace(/\/+$/, "").replace(/\.git$/, "");
|
|
21659
21838
|
};
|
|
@@ -21718,7 +21897,7 @@ var refFacts = (repo, remote) => {
|
|
|
21718
21897
|
tags: new Set,
|
|
21719
21898
|
remoteHeads: new Set
|
|
21720
21899
|
};
|
|
21721
|
-
const listed =
|
|
21900
|
+
const listed = spawnSync17("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/tags", `refs/remotes/${remote}`], { cwd: repo.dir, encoding: "utf8", timeout: 5000 });
|
|
21722
21901
|
const remotePrefix = `refs/remotes/${remote}/`;
|
|
21723
21902
|
for (const ref of (listed.stdout ?? "").split(`
|
|
21724
21903
|
`)) {
|
|
@@ -21735,7 +21914,7 @@ var globBranches = (repo, glob) => {
|
|
|
21735
21914
|
const source = glob.source.startsWith("refs/") ? glob.source : `refs/heads/${glob.source}`;
|
|
21736
21915
|
const [sourcePrefix, sourceSuffix = ""] = source.split("*");
|
|
21737
21916
|
const [destinationPrefix, destinationSuffix = ""] = glob.destination.split("*");
|
|
21738
|
-
const listed =
|
|
21917
|
+
const listed = spawnSync17("git", [
|
|
21739
21918
|
"for-each-ref",
|
|
21740
21919
|
"--format=%(refname)",
|
|
21741
21920
|
sourcePrefix.slice(0, sourcePrefix.lastIndexOf("/") + 1)
|
|
@@ -21817,7 +21996,7 @@ var tagRefusal = (action, facts, dir) => {
|
|
|
21817
21996
|
return `workit: raw ${quote(`git push${action.allTags ? " --tags" : ""}`)} of ${tags.length ? `tag ${tags.join(", ")}` : "tags"} bypasses the release grant. Push a release tag with ${quote(`workit git push --release ${named}`)} (${shapes.join(", ")} tags whose commit the production branch already has; a tag never moves), under the ${quote("release")} grant (if refused, ask the user to run ${quote("workit grant set <workspace> release=true")}).${create}`;
|
|
21818
21997
|
};
|
|
21819
21998
|
var remoteHeads = (repo, remote) => {
|
|
21820
|
-
const listed =
|
|
21999
|
+
const listed = spawnSync17("git", ["ls-remote", "--heads", remote], {
|
|
21821
22000
|
cwd: repo.dir,
|
|
21822
22001
|
encoding: "utf8",
|
|
21823
22002
|
timeout: 3000,
|
|
@@ -21886,7 +22065,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
|
|
|
21886
22065
|
const out = [];
|
|
21887
22066
|
const repos = new Map;
|
|
21888
22067
|
const repoFor = (relative) => {
|
|
21889
|
-
const dir =
|
|
22068
|
+
const dir = path30.resolve(cwd, relative ?? ".");
|
|
21890
22069
|
if (!repos.has(dir)) {
|
|
21891
22070
|
const repo = repoAt(dir);
|
|
21892
22071
|
const workit = repo !== null && isWorkitWorkspace(repo);
|
|
@@ -21907,7 +22086,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
|
|
|
21907
22086
|
const action = rawAction(invocation);
|
|
21908
22087
|
const at = !action ? null : repoFor(invocation.dir) ?? (all && invocation.tool !== "git" && explicitRepo(invocation.tool === "gh", "repo" in action && action.repo || "", invocation.env ?? {}) ? {
|
|
21909
22088
|
repo: {
|
|
21910
|
-
dir:
|
|
22089
|
+
dir: path30.resolve(cwd, invocation.dir ?? "."),
|
|
21911
22090
|
branch: null
|
|
21912
22091
|
},
|
|
21913
22092
|
workit: false
|
|
@@ -21980,13 +22159,13 @@ var messageOf = (segment, index) => {
|
|
|
21980
22159
|
};
|
|
21981
22160
|
var sameGitDir = (a, b, platform = process.platform) => {
|
|
21982
22161
|
if (platform !== "win32")
|
|
21983
|
-
return
|
|
21984
|
-
const fold = (value) =>
|
|
22162
|
+
return path30.posix.resolve(a) === path30.posix.resolve(b);
|
|
22163
|
+
const fold = (value) => path30.win32.resolve(value).toLowerCase();
|
|
21985
22164
|
return fold(a) === fold(b);
|
|
21986
22165
|
};
|
|
21987
22166
|
var cdCommitCall = (input, command, target, repo) => {
|
|
21988
22167
|
const { top, git, dir: store } = repo.location;
|
|
21989
|
-
if (!top || !git || sameGitDir(git.gitDir,
|
|
22168
|
+
if (!top || !git || sameGitDir(git.gitDir, path30.dirname(store)) || repoAt(input.cwd)?.location.top === top)
|
|
21990
22169
|
return null;
|
|
21991
22170
|
const bare = command.replaceAll(/'[^']*'|"(?:[^"\\]|\\.)*"/gu, "").replaceAll("&&", "");
|
|
21992
22171
|
if (/[;|&<>`$()\n\\]/u.test(bare))
|
|
@@ -21995,7 +22174,7 @@ var cdCommitCall = (input, command, target, repo) => {
|
|
|
21995
22174
|
const commit = rest.at(-1);
|
|
21996
22175
|
if (cd?.words[0] !== "cd" || cd.words.length !== 2 || cd.expands?.length || !commit)
|
|
21997
22176
|
return null;
|
|
21998
|
-
if (
|
|
22177
|
+
if (path30.resolve(input.cwd, cd.words[1]) !== target)
|
|
21999
22178
|
return null;
|
|
22000
22179
|
if (rest.some((each) => each.redirects.length || each.stdin?.length || each.group))
|
|
22001
22180
|
return null;
|
|
@@ -22038,7 +22217,7 @@ var cdCommitCall = (input, command, target, repo) => {
|
|
|
22038
22217
|
if (!messages.length)
|
|
22039
22218
|
return null;
|
|
22040
22219
|
if (!all) {
|
|
22041
|
-
const staged =
|
|
22220
|
+
const staged = spawnSync17("git", ["diff", "--cached", "--quiet"], {
|
|
22042
22221
|
cwd: target,
|
|
22043
22222
|
timeout: 5000
|
|
22044
22223
|
});
|
|
@@ -22062,7 +22241,7 @@ var commitRefusal = (input, command, dialect, { action, repo, invocation, workit
|
|
|
22062
22241
|
} catch {}
|
|
22063
22242
|
if (guarded && !switches)
|
|
22064
22243
|
return `workit: raw ${quote("git commit")} on ${repo.branch}, a protected branch. Branch first: ${quote("workit git branch --kind feature --slug <slug>")} (uncommitted changes come along), then ${quote("workit git commit -m '<msg>' -- <paths>")}.`;
|
|
22065
|
-
const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command,
|
|
22244
|
+
const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path30.resolve(input.cwd, invocation.dir), repo);
|
|
22066
22245
|
return call && `workit: no ${quote("cd … &&")} chain; run ${quote(call)}.`;
|
|
22067
22246
|
};
|
|
22068
22247
|
function rawGitPre(input, command, options = {}) {
|
|
@@ -22160,9 +22339,9 @@ var grantRefusal = (action, repo, invocation, cache) => {
|
|
|
22160
22339
|
return null;
|
|
22161
22340
|
};
|
|
22162
22341
|
var localTag = (repo, name) => {
|
|
22163
|
-
const common =
|
|
22342
|
+
const common = path30.dirname(repo.location.dir);
|
|
22164
22343
|
try {
|
|
22165
|
-
return
|
|
22344
|
+
return fs21.existsSync(path30.join(common, "refs/tags", name)) || fs21.readFileSync(path30.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
|
|
22166
22345
|
`);
|
|
22167
22346
|
} catch {
|
|
22168
22347
|
return false;
|
|
@@ -22181,7 +22360,7 @@ var analysisDenial = (error) => ({
|
|
|
22181
22360
|
unblock: SPLIT_IT
|
|
22182
22361
|
});
|
|
22183
22362
|
var MARKER_TTL_SECONDS = 3600;
|
|
22184
|
-
var markerFile = (repo, session, key) =>
|
|
22363
|
+
var markerFile = (repo, session, key) => path30.join(repo.location.dir, "hooks", `commit-${createHash17("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
|
|
22185
22364
|
var callKey = (toolUseId, command) => toolUseId ?? `cmd:${createHash17("sha256").update(command).digest("hex")}`;
|
|
22186
22365
|
function noteRawCommit(input, command, key) {
|
|
22187
22366
|
try {
|
|
@@ -22192,14 +22371,14 @@ function noteRawCommit(input, command, key) {
|
|
|
22192
22371
|
if (action.kind !== "commit")
|
|
22193
22372
|
continue;
|
|
22194
22373
|
const file = markerFile(repo, input.session.id, key);
|
|
22195
|
-
|
|
22196
|
-
|
|
22374
|
+
fs21.mkdirSync(path30.dirname(file), { recursive: true });
|
|
22375
|
+
fs21.writeFileSync(file, `${JSON.stringify({ head: headSha2(repo), at })}
|
|
22197
22376
|
`);
|
|
22198
22377
|
}
|
|
22199
22378
|
} catch {}
|
|
22200
22379
|
}
|
|
22201
22380
|
var headCommit = (dir) => {
|
|
22202
|
-
const run =
|
|
22381
|
+
const run = spawnSync17("git", [
|
|
22203
22382
|
"log",
|
|
22204
22383
|
"-1",
|
|
22205
22384
|
"--format=%H%x1f%ct%x1f%s%x1f%(trailers:key=Workit-Session,valueonly,separator=%x2c)"
|
|
@@ -22226,11 +22405,11 @@ var headCommit = (dir) => {
|
|
|
22226
22405
|
var settle2 = (input, repo, file) => {
|
|
22227
22406
|
let marker;
|
|
22228
22407
|
try {
|
|
22229
|
-
marker = JSON.parse(
|
|
22408
|
+
marker = JSON.parse(fs21.readFileSync(file, "utf8"));
|
|
22230
22409
|
} catch {
|
|
22231
22410
|
return;
|
|
22232
22411
|
}
|
|
22233
|
-
|
|
22412
|
+
fs21.rmSync(file, { force: true });
|
|
22234
22413
|
const session = input.session.id;
|
|
22235
22414
|
const now = Date.now() / 1000;
|
|
22236
22415
|
if (typeof marker.at !== "number" || now - marker.at > MARKER_TTL_SECONDS)
|
|
@@ -22411,7 +22590,7 @@ var targetsOf = (invocations) => invocations.flatMap((invocation) => invocation.
|
|
|
22411
22590
|
branch,
|
|
22412
22591
|
dir: invocation.dir
|
|
22413
22592
|
})) : []);
|
|
22414
|
-
var localBranchExists = (dir, branch) =>
|
|
22593
|
+
var localBranchExists = (dir, branch) => spawnSync18("git", ["show-ref", "--verify", "--quiet", `refs/heads/${branch}`], {
|
|
22415
22594
|
cwd: dir,
|
|
22416
22595
|
stdio: "ignore",
|
|
22417
22596
|
timeout: 5000
|
|
@@ -22421,7 +22600,7 @@ var judgedDir = (root, dir) => {
|
|
|
22421
22600
|
return null;
|
|
22422
22601
|
if (dir === null)
|
|
22423
22602
|
return root;
|
|
22424
|
-
const resolved =
|
|
22603
|
+
const resolved = path31.resolve(root, dir);
|
|
22425
22604
|
return existsSync12(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
|
|
22426
22605
|
};
|
|
22427
22606
|
var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
|
|
@@ -24417,9 +24596,9 @@ class WorkitCore {
|
|
|
24417
24596
|
}
|
|
24418
24597
|
}
|
|
24419
24598
|
// packages/workit-core/src/core/repo-context.ts
|
|
24420
|
-
import { spawnSync as
|
|
24599
|
+
import { spawnSync as spawnSync19 } from "node:child_process";
|
|
24421
24600
|
import { existsSync as existsSync13, readFileSync as readFileSync11, readdirSync as readdirSync4 } from "node:fs";
|
|
24422
|
-
import
|
|
24601
|
+
import path32 from "node:path";
|
|
24423
24602
|
var isSafeContextRange = (value) => value.length <= 4096 && (() => {
|
|
24424
24603
|
try {
|
|
24425
24604
|
gitRevisionParts(value);
|
|
@@ -24446,7 +24625,7 @@ var invalidRange = (cwd) => ({
|
|
|
24446
24625
|
cwd
|
|
24447
24626
|
});
|
|
24448
24627
|
var runGit = (cwd, args) => {
|
|
24449
|
-
const result =
|
|
24628
|
+
const result = spawnSync19("git", args, { cwd, encoding: "utf8" });
|
|
24450
24629
|
return {
|
|
24451
24630
|
stdout: (result.stdout ?? "").trimEnd(),
|
|
24452
24631
|
stderr: (result.stderr ?? "").trimEnd(),
|
|
@@ -24563,13 +24742,13 @@ var findPrTemplate = (cwd) => {
|
|
|
24563
24742
|
for (const rel of PR_TEMPLATE_FILES) {
|
|
24564
24743
|
const parts = rel.split("/");
|
|
24565
24744
|
const base = parts[parts.length - 1];
|
|
24566
|
-
const dir = parts.length > 1 ?
|
|
24745
|
+
const dir = parts.length > 1 ? path32.join(cwd, ...parts.slice(0, -1)) : cwd;
|
|
24567
24746
|
const actual = probeCaseInsensitive(dir, base);
|
|
24568
24747
|
if (actual)
|
|
24569
24748
|
return [...parts.slice(0, -1), actual].join("/");
|
|
24570
24749
|
}
|
|
24571
24750
|
for (const rel of PR_TEMPLATE_DIRS) {
|
|
24572
|
-
const only = singleMarkdown(
|
|
24751
|
+
const only = singleMarkdown(path32.join(cwd, ...rel.split("/")));
|
|
24573
24752
|
if (only)
|
|
24574
24753
|
return `${rel}/${only}`;
|
|
24575
24754
|
}
|
|
@@ -24599,7 +24778,7 @@ var diffStatForRange = (cwd, range) => {
|
|
|
24599
24778
|
return runGit(cwd, ["diff", "--stat", "--"]).stdout;
|
|
24600
24779
|
};
|
|
24601
24780
|
var packageScripts = (cwd, keys) => {
|
|
24602
|
-
const pkgPath =
|
|
24781
|
+
const pkgPath = path32.join(cwd, "package.json");
|
|
24603
24782
|
if (!existsSync13(pkgPath))
|
|
24604
24783
|
return [];
|
|
24605
24784
|
try {
|
|
@@ -24625,9 +24804,9 @@ var documentationFiles = (cwd) => {
|
|
|
24625
24804
|
if (entry.isDirectory()) {
|
|
24626
24805
|
if (excluded.has(entry.name))
|
|
24627
24806
|
continue;
|
|
24628
|
-
walk(
|
|
24807
|
+
walk(path32.join(dir, entry.name), depth + 1);
|
|
24629
24808
|
} else if (entry.isFile() && (entry.name === "README.md" || entry.name.endsWith(".md"))) {
|
|
24630
|
-
matches.push("./" +
|
|
24809
|
+
matches.push("./" + path32.relative(cwd, path32.join(dir, entry.name)).replaceAll("\\", "/"));
|
|
24631
24810
|
}
|
|
24632
24811
|
}
|
|
24633
24812
|
};
|
|
@@ -24643,7 +24822,7 @@ var readTrimmed2 = (file, maxLines) => {
|
|
|
24643
24822
|
`);
|
|
24644
24823
|
};
|
|
24645
24824
|
function prReadyContext(root, range) {
|
|
24646
|
-
const cwd =
|
|
24825
|
+
const cwd = path32.resolve(repoRoot(root));
|
|
24647
24826
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
24648
24827
|
return invalidRange(cwd);
|
|
24649
24828
|
let stdout = "";
|
|
@@ -24701,7 +24880,7 @@ ${status.stderr}` : "");
|
|
|
24701
24880
|
stdout += `template_path: ${template}
|
|
24702
24881
|
|
|
24703
24882
|
`;
|
|
24704
|
-
stdout += readTrimmed2(
|
|
24883
|
+
stdout += readTrimmed2(path32.join(cwd, template), 220);
|
|
24705
24884
|
} else {
|
|
24706
24885
|
stdout += `template_path: none
|
|
24707
24886
|
|
|
@@ -24711,7 +24890,7 @@ ${status.stderr}` : "");
|
|
|
24711
24890
|
stdout += `
|
|
24712
24891
|
`;
|
|
24713
24892
|
stdout += printSection("Recent Validation Signals");
|
|
24714
|
-
if (existsSync13(
|
|
24893
|
+
if (existsSync13(path32.join(cwd, "package.json"))) {
|
|
24715
24894
|
stdout += `package.json detected. Common scripts:
|
|
24716
24895
|
`;
|
|
24717
24896
|
const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
|
|
@@ -24720,7 +24899,7 @@ ${status.stderr}` : "");
|
|
|
24720
24899
|
`) + `
|
|
24721
24900
|
`;
|
|
24722
24901
|
}
|
|
24723
|
-
if (existsSync13(
|
|
24902
|
+
if (existsSync13(path32.join(cwd, "Cargo.toml")) || existsSync13(path32.join(cwd, "src-tauri/Cargo.toml"))) {
|
|
24724
24903
|
stdout += `Rust project detected.
|
|
24725
24904
|
`;
|
|
24726
24905
|
}
|
|
@@ -24753,7 +24932,7 @@ var CHANGELOG_RULES = `- Use an [Unreleased] section.
|
|
|
24753
24932
|
- Apply with the host-native editor, preserving the repository changelog conventions.
|
|
24754
24933
|
- If Unreleased already has duplicate category headings, normalize_only first.`;
|
|
24755
24934
|
function changelogContext(root, range) {
|
|
24756
|
-
const cwd =
|
|
24935
|
+
const cwd = path32.resolve(repoRoot(root));
|
|
24757
24936
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
24758
24937
|
return invalidRange(cwd);
|
|
24759
24938
|
const resolvedRange = rangeArgOrDefault(range, cwd);
|
|
@@ -24771,7 +24950,7 @@ function changelogContext(root, range) {
|
|
|
24771
24950
|
stdout += CHANGELOG_RULES + `
|
|
24772
24951
|
`;
|
|
24773
24952
|
stdout += printSection("Existing CHANGELOG.md");
|
|
24774
|
-
const changelogPath =
|
|
24953
|
+
const changelogPath = path32.join(cwd, "CHANGELOG.md");
|
|
24775
24954
|
if (existsSync13(changelogPath)) {
|
|
24776
24955
|
stdout += readTrimmed2(changelogPath, 260) + `
|
|
24777
24956
|
`;
|
|
@@ -24791,7 +24970,7 @@ function changelogContext(root, range) {
|
|
|
24791
24970
|
return { stdout, stderr: "", exitCode: 0, cwd };
|
|
24792
24971
|
}
|
|
24793
24972
|
function docsRefreshContext(root, range) {
|
|
24794
|
-
const cwd =
|
|
24973
|
+
const cwd = path32.resolve(repoRoot(root));
|
|
24795
24974
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
24796
24975
|
return invalidRange(cwd);
|
|
24797
24976
|
const resolvedRange = rangeArgOrDefault(range, cwd);
|
|
@@ -24813,7 +24992,7 @@ function docsRefreshContext(root, range) {
|
|
|
24813
24992
|
`) + `
|
|
24814
24993
|
`;
|
|
24815
24994
|
stdout += printSection("README Preview");
|
|
24816
|
-
const readme =
|
|
24995
|
+
const readme = path32.join(cwd, "README.md");
|
|
24817
24996
|
if (existsSync13(readme)) {
|
|
24818
24997
|
stdout += readTrimmed2(readme, 220) + `
|
|
24819
24998
|
`;
|
|
@@ -24822,7 +25001,7 @@ function docsRefreshContext(root, range) {
|
|
|
24822
25001
|
`;
|
|
24823
25002
|
}
|
|
24824
25003
|
stdout += printSection("Package Scripts");
|
|
24825
|
-
const pkgPath =
|
|
25004
|
+
const pkgPath = path32.join(cwd, "package.json");
|
|
24826
25005
|
if (existsSync13(pkgPath)) {
|
|
24827
25006
|
try {
|
|
24828
25007
|
const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
|
|
@@ -24836,7 +25015,7 @@ function docsRefreshContext(root, range) {
|
|
|
24836
25015
|
return { stdout, stderr: "", exitCode: 0, cwd };
|
|
24837
25016
|
}
|
|
24838
25017
|
function releaseNotesContext(root, rangeOrTag) {
|
|
24839
|
-
const cwd =
|
|
25018
|
+
const cwd = path32.resolve(repoRoot(root));
|
|
24840
25019
|
if (!rangeOrTag) {
|
|
24841
25020
|
return {
|
|
24842
25021
|
stdout: "",
|
|
@@ -24879,7 +25058,7 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
24879
25058
|
`;
|
|
24880
25059
|
stdout += printSection("Existing Release Files");
|
|
24881
25060
|
for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
|
|
24882
|
-
if (existsSync13(
|
|
25061
|
+
if (existsSync13(path32.join(cwd, rel)))
|
|
24883
25062
|
stdout += rel + `
|
|
24884
25063
|
`;
|
|
24885
25064
|
}
|
|
@@ -24907,12 +25086,12 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
24907
25086
|
}
|
|
24908
25087
|
|
|
24909
25088
|
// packages/workit-core/src/core/tracker-issues.ts
|
|
24910
|
-
import { spawnSync as
|
|
25089
|
+
import { spawnSync as spawnSync21 } from "node:child_process";
|
|
24911
25090
|
|
|
24912
25091
|
// packages/workit-core/src/core/pr-create.ts
|
|
24913
|
-
import
|
|
24914
|
-
import
|
|
24915
|
-
import { spawnSync as
|
|
25092
|
+
import fs22 from "node:fs";
|
|
25093
|
+
import path33 from "node:path";
|
|
25094
|
+
import { spawnSync as spawnSync20 } from "node:child_process";
|
|
24916
25095
|
import { pathToFileURL } from "node:url";
|
|
24917
25096
|
// packages/workit-core/src/forge/pr-body.ts
|
|
24918
25097
|
function parseGhIssue(value) {
|
|
@@ -24932,13 +25111,13 @@ var LOCAL = bounded(20000);
|
|
|
24932
25111
|
var NETWORK = bounded(60000);
|
|
24933
25112
|
function whichOnPath(tool) {
|
|
24934
25113
|
const names = process.platform === "win32" ? [tool, `${tool}.exe`, `${tool}.cmd`] : [tool];
|
|
24935
|
-
for (const dir of (process.env.PATH ?? "").split(
|
|
25114
|
+
for (const dir of (process.env.PATH ?? "").split(path33.delimiter)) {
|
|
24936
25115
|
if (!dir)
|
|
24937
25116
|
continue;
|
|
24938
25117
|
for (const name of names) {
|
|
24939
|
-
const candidate =
|
|
25118
|
+
const candidate = path33.join(dir, name);
|
|
24940
25119
|
try {
|
|
24941
|
-
|
|
25120
|
+
fs22.accessSync(candidate, fs22.constants.X_OK);
|
|
24942
25121
|
return candidate;
|
|
24943
25122
|
} catch {}
|
|
24944
25123
|
}
|
|
@@ -24947,7 +25126,7 @@ function whichOnPath(tool) {
|
|
|
24947
25126
|
}
|
|
24948
25127
|
var hostingCliAvailable = (provider) => whichOnPath(provider === "gitlab" ? "glab" : "gh") !== null;
|
|
24949
25128
|
var pushRemote = (cwd) => {
|
|
24950
|
-
const result =
|
|
25129
|
+
const result = spawnSync20("git", ["remote", "get-url", "--push", "--all", "origin"], {
|
|
24951
25130
|
cwd,
|
|
24952
25131
|
...LOCAL
|
|
24953
25132
|
});
|
|
@@ -24958,7 +25137,7 @@ var pushRemote = (cwd) => {
|
|
|
24958
25137
|
};
|
|
24959
25138
|
var safePushUrl = (remote) => {
|
|
24960
25139
|
const raw = remote.trim();
|
|
24961
|
-
if (
|
|
25140
|
+
if (path33.isAbsolute(raw))
|
|
24962
25141
|
return pathToFileURL(raw).href;
|
|
24963
25142
|
if (!raw.includes("://")) {
|
|
24964
25143
|
const scp = /^(?:([^@\s]+)@)?([^:]+):(.+)$/u.exec(raw);
|
|
@@ -24983,7 +25162,7 @@ var pushTargetIsStable = (cwd, remote) => {
|
|
|
24983
25162
|
const target = safePushUrl(remote);
|
|
24984
25163
|
if (!target)
|
|
24985
25164
|
return false;
|
|
24986
|
-
const result =
|
|
25165
|
+
const result = spawnSync20("git", ["config", "--get-regexp", "^url\\..*\\.(insteadof|pushinsteadof)$"], { cwd, ...LOCAL });
|
|
24987
25166
|
if (result.status !== 0 && result.status !== 1)
|
|
24988
25167
|
return false;
|
|
24989
25168
|
const prefixes = (result.stdout ?? "").split(/\r?\n/u).map((line) => line.trim().slice(line.trim().indexOf(" ") + 1)).filter(Boolean);
|
|
@@ -25011,7 +25190,7 @@ var defaultCli = (bin, available) => {
|
|
|
25011
25190
|
if (!available)
|
|
25012
25191
|
return null;
|
|
25013
25192
|
return (args, root) => {
|
|
25014
|
-
const out =
|
|
25193
|
+
const out = spawnSync21(bin, args, {
|
|
25015
25194
|
cwd: root,
|
|
25016
25195
|
encoding: "utf8",
|
|
25017
25196
|
env: { ...process.env, PATH: process.env.PATH ?? "" }
|
|
@@ -25100,149 +25279,6 @@ var PLUGIN_ROOT = packageRoot();
|
|
|
25100
25279
|
var ASSET_ROOT = assetRoot();
|
|
25101
25280
|
var resolveWorkspaceRoot = (explicit) => explicit || process.cwd();
|
|
25102
25281
|
|
|
25103
|
-
// packages/workit-core/src/core/youtrack-ytrack.ts
|
|
25104
|
-
import { spawnSync as spawnSync21 } from "node:child_process";
|
|
25105
|
-
|
|
25106
|
-
// packages/workit-core/src/forge/exec.ts
|
|
25107
|
-
import fs22 from "node:fs";
|
|
25108
|
-
import path33 from "node:path";
|
|
25109
|
-
|
|
25110
|
-
// packages/workit-core/src/forge/redact.ts
|
|
25111
|
-
var KEY = String.raw`[A-Za-z0-9_.-]*?(?:token|secret|password|passwd|pwd|api[_-]?key|access[_-]?key|account[_-]?key|private[_-]?key|client[_-]?secret|credentials?|authorization|cookie|signature)[A-Za-z0-9_.-]*`;
|
|
25112
|
-
var ASSIGNMENT2 = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*["']?)((?:bearer|basic|token|digest)\s+)?([^\s"',;&]+)`, "giu");
|
|
25113
|
-
var QUOTED_ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*)(["'])([^"'\n]*[^\s"'][^"'\n]*)\2`, "giu");
|
|
25114
|
-
var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\u0007`, "gu");
|
|
25115
|
-
|
|
25116
|
-
// packages/workit-core/src/forge/types.ts
|
|
25117
|
-
var success2 = (data) => ({ ok: true, data });
|
|
25118
|
-
var failure3 = (code, error, unblock) => ({ ok: false, code, error, ...unblock ? { unblock } : {} });
|
|
25119
|
-
|
|
25120
|
-
// packages/workit-core/src/forge/exec.ts
|
|
25121
|
-
var MAX_BUFFER2 = 64 * 1024 * 1024;
|
|
25122
|
-
function findExecutable(bin, env) {
|
|
25123
|
-
const dirs = (env.PATH ?? env.Path ?? "").split(path33.delimiter).filter(Boolean);
|
|
25124
|
-
const exts = process.platform === "win32" ? [".exe"] : [""];
|
|
25125
|
-
for (const dir of dirs)
|
|
25126
|
-
for (const ext of exts) {
|
|
25127
|
-
const candidate = path33.join(dir, `${bin}${ext}`);
|
|
25128
|
-
try {
|
|
25129
|
-
const stat = fs22.statSync(candidate);
|
|
25130
|
-
if (stat.isFile())
|
|
25131
|
-
return candidate;
|
|
25132
|
-
} catch {}
|
|
25133
|
-
}
|
|
25134
|
-
return null;
|
|
25135
|
-
}
|
|
25136
|
-
|
|
25137
|
-
// packages/workit-core/src/core/youtrack-ytrack.ts
|
|
25138
|
-
var TIMEOUT_MS = 60000;
|
|
25139
|
-
var YTRACK_EXIT = { ok: 0, failed: 1, cancelled: 2, auth: 4 };
|
|
25140
|
-
var findYtrack = (env) => env.WORKIT_NO_YTRACK === "1" ? null : findExecutable("ytrack", env);
|
|
25141
|
-
var YTRACK_QUIET_ENV = {
|
|
25142
|
-
YTRACK_NO_UPDATE_NOTIFIER: "1",
|
|
25143
|
-
YTRACK_NO_AUTO_UPGRADE: "1"
|
|
25144
|
-
};
|
|
25145
|
-
function ytrackRunner(env, host, timeoutMs = TIMEOUT_MS) {
|
|
25146
|
-
return (args, input) => {
|
|
25147
|
-
const exe = findYtrack(env);
|
|
25148
|
-
if (!exe)
|
|
25149
|
-
return { status: null, stdout: "", stderr: "", missing: true };
|
|
25150
|
-
const result = spawnSync21(exe, args, {
|
|
25151
|
-
encoding: "utf8",
|
|
25152
|
-
env: {
|
|
25153
|
-
...env,
|
|
25154
|
-
NO_COLOR: "1",
|
|
25155
|
-
...YTRACK_QUIET_ENV,
|
|
25156
|
-
...host ? { YTRACK_HOST: host } : {}
|
|
25157
|
-
},
|
|
25158
|
-
timeout: timeoutMs,
|
|
25159
|
-
killSignal: "SIGKILL",
|
|
25160
|
-
windowsHide: true,
|
|
25161
|
-
...input === undefined ? { stdio: ["ignore", "pipe", "pipe"] } : { input, stdio: ["pipe", "pipe", "pipe"] }
|
|
25162
|
-
});
|
|
25163
|
-
const error = result.error;
|
|
25164
|
-
if (error?.code === "ENOENT")
|
|
25165
|
-
return { status: null, stdout: "", stderr: "", missing: true };
|
|
25166
|
-
return {
|
|
25167
|
-
status: result.status,
|
|
25168
|
-
stdout: result.stdout ?? "",
|
|
25169
|
-
stderr: result.stderr || (error ? error.message : "")
|
|
25170
|
-
};
|
|
25171
|
-
};
|
|
25172
|
-
}
|
|
25173
|
-
var ytrackDetail = (out) => out.stderr.trim().split(`
|
|
25174
|
-
`).slice(-3).join(" ").slice(0, 300);
|
|
25175
|
-
var STATUS_FIELDS = "host,active,login,state,tokenSource,error";
|
|
25176
|
-
function ytrackStatus(run) {
|
|
25177
|
-
const version = run(["version"]);
|
|
25178
|
-
if (version.missing)
|
|
25179
|
-
return { installed: false };
|
|
25180
|
-
const match = /ytrack version (\S+)/u.exec(version.stdout);
|
|
25181
|
-
const status = run(["auth", "status", "--json", STATUS_FIELDS]);
|
|
25182
|
-
const base = { installed: true, version: match ? match[1] : null };
|
|
25183
|
-
if (status.status === YTRACK_EXIT.auth)
|
|
25184
|
-
return { ...base, auth: "logged_out", hosts: [], error: ytrackDetail(status) || null };
|
|
25185
|
-
let rows;
|
|
25186
|
-
try {
|
|
25187
|
-
rows = JSON.parse(status.stdout);
|
|
25188
|
-
} catch {
|
|
25189
|
-
return { ...base, auth: "error", hosts: [], error: ytrackDetail(status) || "no JSON" };
|
|
25190
|
-
}
|
|
25191
|
-
const hosts = (Array.isArray(rows) ? rows : [rows]).filter((row) => typeof row === "object" && row !== null).map((row) => ({
|
|
25192
|
-
host: String(row.host ?? ""),
|
|
25193
|
-
active: row.active === true,
|
|
25194
|
-
login: typeof row.login === "string" && row.login ? row.login : null,
|
|
25195
|
-
state: String(row.state ?? "error"),
|
|
25196
|
-
tokenSource: typeof row.tokenSource === "string" && row.tokenSource ? row.tokenSource : null,
|
|
25197
|
-
error: typeof row.error === "string" && row.error ? row.error : null
|
|
25198
|
-
}));
|
|
25199
|
-
const active = hosts.find((row) => row.active) ?? hosts[0];
|
|
25200
|
-
return { ...base, auth: rowAuth(active), hosts, error: null };
|
|
25201
|
-
}
|
|
25202
|
-
var rowAuth = (row) => !row ? "logged_out" : row.state === "ok" ? "ok" : row.state === "rejected" ? "rejected" : row.state === "no_token" ? "logged_out" : "error";
|
|
25203
|
-
var ytrackHostName = (urlOrHost) => urlOrHost.trim().replace(/^[a-z][a-z0-9+.-]*:\/\//iu, "").split("/")[0].toLowerCase();
|
|
25204
|
-
function ytrackHostAuth(status, host) {
|
|
25205
|
-
if (!host) {
|
|
25206
|
-
const active = status.hosts.find((row) => row.active) ?? status.hosts[0];
|
|
25207
|
-
return {
|
|
25208
|
-
auth: status.auth,
|
|
25209
|
-
login: active?.login ?? null,
|
|
25210
|
-
error: active?.error ?? status.error
|
|
25211
|
-
};
|
|
25212
|
-
}
|
|
25213
|
-
const name = ytrackHostName(host);
|
|
25214
|
-
const row = status.hosts.find((candidate) => ytrackHostName(candidate.host) === name);
|
|
25215
|
-
return {
|
|
25216
|
-
auth: status.auth === "error" && !row ? "error" : rowAuth(row),
|
|
25217
|
-
login: row?.login ?? null,
|
|
25218
|
-
error: row?.error ?? status.error
|
|
25219
|
-
};
|
|
25220
|
-
}
|
|
25221
|
-
var YTRACK_INSTALL = "install ytrack (https://github.com/BrainerVirus/youtrack-cli: install.sh, or install.ps1 on Windows)";
|
|
25222
|
-
var ytrackLogin = (host) => `ytrack auth login${host ? ` --host ${ytrackHostName(host)}` : ""}`;
|
|
25223
|
-
var ytrackMissingUnblock = (host) => `${YTRACK_INSTALL}, then ${ytrackLogin(host)}`;
|
|
25224
|
-
var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only through ytrack";
|
|
25225
|
-
function ytrackReadiness(run, host) {
|
|
25226
|
-
const status = ytrackStatus(run);
|
|
25227
|
-
if (!status.installed)
|
|
25228
|
-
return {
|
|
25229
|
-
ok: false,
|
|
25230
|
-
reason: "missing",
|
|
25231
|
-
error: YTRACK_MISSING,
|
|
25232
|
-
unblock: ytrackMissingUnblock(host)
|
|
25233
|
-
};
|
|
25234
|
-
const auth = ytrackHostAuth(status, host);
|
|
25235
|
-
const where = host ? ytrackHostName(host) : "the active host";
|
|
25236
|
-
if (auth.auth === "ok")
|
|
25237
|
-
return { ok: true, version: status.version, login: auth.login };
|
|
25238
|
-
return {
|
|
25239
|
-
ok: false,
|
|
25240
|
-
reason: auth.auth,
|
|
25241
|
-
error: auth.auth === "logged_out" ? `ytrack is not logged in to ${where}` : auth.auth === "rejected" ? `${where} rejected ytrack's stored token` : `could not read ytrack's login for ${where}${auth.error ? ` (${auth.error})` : ""}`,
|
|
25242
|
-
unblock: ytrackLogin(host)
|
|
25243
|
-
};
|
|
25244
|
-
}
|
|
25245
|
-
|
|
25246
25282
|
// packages/workit-core/src/core/youtrack.ts
|
|
25247
25283
|
var ISSUE_RE = /^[A-Z][A-Z0-9_]*-\d+$/;
|
|
25248
25284
|
var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path34.join(resolveConfigDir(), "youtrack.json");
|
|
@@ -30444,6 +30480,29 @@ var judge = (args, words) => {
|
|
|
30444
30480
|
return mapIssueWrite("attach", args);
|
|
30445
30481
|
return /^(?:edit|update|delete|rm)$/.test(verb) ? UNCOVERED : null;
|
|
30446
30482
|
};
|
|
30483
|
+
var hostsOf = (args) => {
|
|
30484
|
+
const end = args.indexOf("--");
|
|
30485
|
+
const hosts = [];
|
|
30486
|
+
const bare = [];
|
|
30487
|
+
let literal = true;
|
|
30488
|
+
let named = false;
|
|
30489
|
+
for (let at = 0;at < args.length; at++) {
|
|
30490
|
+
const arg = args[at];
|
|
30491
|
+
if (end >= 0 && at >= end || !/^--host(?:=|$)/.test(arg)) {
|
|
30492
|
+
bare.push(arg);
|
|
30493
|
+
continue;
|
|
30494
|
+
}
|
|
30495
|
+
named ||= standsAlone(args, at);
|
|
30496
|
+
const value = arg === "--host" ? args[++at] : arg.slice("--host=".length);
|
|
30497
|
+
if (value === undefined || !value.trim() || EXPANDS.test(value))
|
|
30498
|
+
literal = false;
|
|
30499
|
+
else
|
|
30500
|
+
hosts.push(value);
|
|
30501
|
+
}
|
|
30502
|
+
if (!literal)
|
|
30503
|
+
return { hosts: null, bare };
|
|
30504
|
+
return named ? { hosts, bare } : { hosts: [], bare: [...args] };
|
|
30505
|
+
};
|
|
30447
30506
|
var SHELLS3 = /^(?:sh|bash|zsh|dash|ksh|ash|mksh|yash|fish)$/;
|
|
30448
30507
|
var MAX_DEPTH2 = 4;
|
|
30449
30508
|
var READ = new Map;
|
|
@@ -30451,10 +30510,19 @@ var NOT_PLAIN = gap("a ytrack call that is not a plain command of its own (a wra
|
|
|
30451
30510
|
var timeOnly = (effect) => effect?.minutes !== undefined && Object.keys(effect).every((key) => /^(?:issue|minutes|text|date)$/u.test(key));
|
|
30452
30511
|
var ungrant = (write) => write.workit ? {
|
|
30453
30512
|
command: write.command,
|
|
30513
|
+
hosts: write.hosts,
|
|
30514
|
+
bare: write.bare,
|
|
30515
|
+
plain: write.plain,
|
|
30454
30516
|
...NOT_PLAIN,
|
|
30455
30517
|
...timeOnly(write.effect) ? { hint: write.workit } : {}
|
|
30456
30518
|
} : write;
|
|
30457
|
-
var hinted = (write) => write.hint ? {
|
|
30519
|
+
var hinted = (write) => write.hint ? {
|
|
30520
|
+
command: write.command,
|
|
30521
|
+
hosts: write.hosts,
|
|
30522
|
+
bare: write.bare,
|
|
30523
|
+
plain: false,
|
|
30524
|
+
workit: write.hint
|
|
30525
|
+
} : write;
|
|
30458
30526
|
var ytrackArgs = (line, found, depth, names, plain) => {
|
|
30459
30527
|
const inner = (script) => void found.push(...ytrackWrites(script, "posix", depth + 1, plain));
|
|
30460
30528
|
const tail = workitCheckTail(line);
|
|
@@ -30489,7 +30557,12 @@ var ytrackArgs = (line, found, depth, names, plain) => {
|
|
|
30489
30557
|
const argv = [...alias ?? [], ...line.slice(at + 1)];
|
|
30490
30558
|
const write = classify2(argv);
|
|
30491
30559
|
if (write) {
|
|
30492
|
-
const one = {
|
|
30560
|
+
const one = {
|
|
30561
|
+
command: ["ytrack", ...argv].map(quote2).join(" "),
|
|
30562
|
+
...write,
|
|
30563
|
+
...hostsOf(argv),
|
|
30564
|
+
plain
|
|
30565
|
+
};
|
|
30493
30566
|
found.push(plain ? one : ungrant(one));
|
|
30494
30567
|
}
|
|
30495
30568
|
return true;
|
|
@@ -30566,7 +30639,15 @@ var chained = (first, chain, depth) => {
|
|
|
30566
30639
|
const effect = combine(effects);
|
|
30567
30640
|
if (!effect)
|
|
30568
30641
|
return null;
|
|
30569
|
-
|
|
30642
|
+
const hosts = found.map((write) => write.hosts);
|
|
30643
|
+
return [
|
|
30644
|
+
{
|
|
30645
|
+
command: found.map((write) => write.command).join(" && "),
|
|
30646
|
+
...mapped(effect),
|
|
30647
|
+
hosts: hosts.includes(null) ? null : hosts.some((list) => !list?.length) ? [] : hosts.flatMap((list) => list ?? []),
|
|
30648
|
+
plain: true
|
|
30649
|
+
}
|
|
30650
|
+
];
|
|
30570
30651
|
};
|
|
30571
30652
|
var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
|
|
30572
30653
|
if (!namesYtrack(command))
|
|
@@ -30595,6 +30676,32 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
|
|
|
30595
30676
|
READ.delete(READ.keys().next().value);
|
|
30596
30677
|
return found;
|
|
30597
30678
|
};
|
|
30679
|
+
var RELOCATES = /(?<![$\w])YTRACK_CONFIG_DIR\b/;
|
|
30680
|
+
var reachesOnly = (allowed, write) => write.plain && !!write.hosts?.length && write.hosts.every((host) => youTrackHostAllowed(allowed, host));
|
|
30681
|
+
var scopedGate = (allowed, command, writes) => {
|
|
30682
|
+
const scope = `youtrack.autoHosts (${allowed.join(", ")})`;
|
|
30683
|
+
if (RELOCATES.test(command))
|
|
30684
|
+
return {
|
|
30685
|
+
kind: "deny",
|
|
30686
|
+
reason: `This command sets YTRACK_CONFIG_DIR, where ytrack reads its hosts, so a --host may reach another instance: ${scope} lets a YouTrack write through only with ytrack's own config. Run the ytrack call without it.`,
|
|
30687
|
+
unblock: null
|
|
30688
|
+
};
|
|
30689
|
+
const first = allowed.map(youTrackHostKey).find(Boolean);
|
|
30690
|
+
if (!first)
|
|
30691
|
+
return null;
|
|
30692
|
+
const unnamed = writes.filter((write) => !reachesOnly(allowed, write) && (!write.hosts?.length || write.hosts.every((host) => youTrackHostAllowed(allowed, host))));
|
|
30693
|
+
if (!unnamed.length)
|
|
30694
|
+
return null;
|
|
30695
|
+
const why = (write) => write.hosts === null ? "its --host is no literal host" : !write.hosts.length ? "it names no --host" : "it is not a plain command of its own";
|
|
30696
|
+
const bare = unnamed.find((write) => write.bare)?.bare;
|
|
30697
|
+
const retry = bare ? ["ytrack", "--host", first, ...bare].map(quote2).join(" ") : null;
|
|
30698
|
+
return {
|
|
30699
|
+
kind: "deny",
|
|
30700
|
+
reason: `${scope} posts to YouTrack unasked only from a plain ytrack call that names an allowed host with --host: ${unnamed.map((write) => `\`${write.command}\` (${why(write)})`).join(", ")}. Name the host, as its own plain call.${retry ? `
|
|
30701
|
+
Retry as: ${retry}` : ""}`,
|
|
30702
|
+
unblock: retry
|
|
30703
|
+
};
|
|
30704
|
+
};
|
|
30598
30705
|
var ytrackGate = (cwd, command, dialect, ask) => {
|
|
30599
30706
|
if (namesTicket(command))
|
|
30600
30707
|
return { kind: "deny", reason: TICKET_DENY, unblock: null };
|
|
@@ -30607,7 +30714,8 @@ var ytrackGate = (cwd, command, dialect, ask) => {
|
|
|
30607
30714
|
}
|
|
30608
30715
|
writes = [...merged.values()];
|
|
30609
30716
|
} catch {
|
|
30610
|
-
|
|
30717
|
+
const policy = youTrackWritesPolicy(cwd);
|
|
30718
|
+
if (policy.mode === "auto" && policy.hosts === null)
|
|
30611
30719
|
return null;
|
|
30612
30720
|
return {
|
|
30613
30721
|
kind: "deny",
|
|
@@ -30615,7 +30723,19 @@ var ytrackGate = (cwd, command, dialect, ask) => {
|
|
|
30615
30723
|
unblock: null
|
|
30616
30724
|
};
|
|
30617
30725
|
}
|
|
30618
|
-
if (!writes.length
|
|
30726
|
+
if (!writes.length && !RELOCATES.test(command))
|
|
30727
|
+
return null;
|
|
30728
|
+
const policy = youTrackWritesPolicy(cwd);
|
|
30729
|
+
if (policy.mode === "auto") {
|
|
30730
|
+
const hosts = policy.hosts;
|
|
30731
|
+
if (hosts === null)
|
|
30732
|
+
return null;
|
|
30733
|
+
const scoped = scopedGate(hosts, command, writes);
|
|
30734
|
+
if (scoped)
|
|
30735
|
+
return scoped;
|
|
30736
|
+
writes = writes.filter((write) => !reachesOnly(hosts, write));
|
|
30737
|
+
}
|
|
30738
|
+
if (!writes.length)
|
|
30619
30739
|
return null;
|
|
30620
30740
|
const calls = writes.flatMap((write) => write.workit ? [`\`${write.workit}\``] : []);
|
|
30621
30741
|
const bare = writes.filter((write) => !write.workit).map((write) => `\`${write.command}\` (${write.gap ? `Workit cannot carry ${write.gap} into a workit youtrack call` : "no workit youtrack verb covers it"})`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/opencode",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.1",
|
|
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.0.18",
|
|
44
|
-
"@workit-dev/core": "^2.
|
|
44
|
+
"@workit-dev/core": "^2.21.1"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=24"
|