@workit-dev/pi 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/worker.js +13 -10
- package/dist/workit.js +300 -174
- package/package.json +1 -1
package/dist/worker.js
CHANGED
|
@@ -7421,7 +7421,8 @@ var workspaceConfigSchema = object({
|
|
|
7421
7421
|
youtrack: object({
|
|
7422
7422
|
baseUrl: nonBlank.optional().describe("This workspace's YouTrack URL."),
|
|
7423
7423
|
link_issues: boolean2().optional().describe("Legacy alias of `issues: { provider: youtrack, link: true }`."),
|
|
7424
|
-
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.")
|
|
7424
|
+
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."),
|
|
7425
|
+
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`).")
|
|
7425
7426
|
}).passthrough().optional().describe("YouTrack settings for this workspace."),
|
|
7426
7427
|
issues: object({
|
|
7427
7428
|
provider: _enum(["github", "gitlab", "youtrack"]).optional().describe("The issue tracker PRs link to."),
|
|
@@ -8929,6 +8930,17 @@ Skills: load the skill, never act from memory.
|
|
|
8929
8930
|
// packages/workit-core/src/core/grant-seal.ts
|
|
8930
8931
|
var SEAL_COMMAND = "workit workspace seal";
|
|
8931
8932
|
|
|
8933
|
+
// packages/workit-core/src/forge/redact.ts
|
|
8934
|
+
var NAME = "[A-Za-z0-9_.-]";
|
|
8935
|
+
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}+`;
|
|
8936
|
+
var ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*["']?)((?:bearer|basic|token|digest)\s+)?([^\s"',;&]+)`, "giu");
|
|
8937
|
+
var QUOTED_ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*)(["'])([^"'\n]*[^\s"'][^"'\n]*)\2`, "giu");
|
|
8938
|
+
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");
|
|
8939
|
+
var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*\u0007`, "gu");
|
|
8940
|
+
|
|
8941
|
+
// packages/workit-core/src/forge/exec.ts
|
|
8942
|
+
var MAX_BUFFER2 = 64 * 1024 * 1024;
|
|
8943
|
+
|
|
8932
8944
|
// packages/workit-core/src/autonomy.ts
|
|
8933
8945
|
var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own terminal: ${SEAL_COMMAND}`;
|
|
8934
8946
|
var NO_SEAL_UNBLOCK = `ask the user to review and seal the grants, in their own terminal: ${SEAL_COMMAND}`;
|
|
@@ -9123,15 +9135,6 @@ var repoRoot = assetRoot();
|
|
|
9123
9135
|
var PLUGIN_ROOT = packageRoot();
|
|
9124
9136
|
var ASSET_ROOT = assetRoot();
|
|
9125
9137
|
|
|
9126
|
-
// packages/workit-core/src/forge/redact.ts
|
|
9127
|
-
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_.-]*`;
|
|
9128
|
-
var ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*["']?)((?:bearer|basic|token|digest)\s+)?([^\s"',;&]+)`, "giu");
|
|
9129
|
-
var QUOTED_ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*)(["'])([^"'\n]*[^\s"'][^"'\n]*)\2`, "giu");
|
|
9130
|
-
var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\u0007`, "gu");
|
|
9131
|
-
|
|
9132
|
-
// packages/workit-core/src/forge/exec.ts
|
|
9133
|
-
var MAX_BUFFER2 = 64 * 1024 * 1024;
|
|
9134
|
-
|
|
9135
9138
|
// packages/workit-core/src/core/context-read.ts
|
|
9136
9139
|
var contextReadSchema = object({
|
|
9137
9140
|
kind: _enum([
|
package/dist/workit.js
CHANGED
|
@@ -9185,7 +9185,8 @@ var workspaceConfigSchema = object({
|
|
|
9185
9185
|
youtrack: object({
|
|
9186
9186
|
baseUrl: nonBlank.optional().describe("This workspace's YouTrack URL."),
|
|
9187
9187
|
link_issues: boolean2().optional().describe("Legacy alias of `issues: { provider: youtrack, link: true }`."),
|
|
9188
|
-
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.")
|
|
9188
|
+
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."),
|
|
9189
|
+
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`).")
|
|
9189
9190
|
}).passthrough().optional().describe("YouTrack settings for this workspace."),
|
|
9190
9191
|
issues: object({
|
|
9191
9192
|
provider: _enum(["github", "gitlab", "youtrack"]).optional().describe("The issue tracker PRs link to."),
|
|
@@ -19150,20 +19151,20 @@ var exportDigest = (bundle) => sha256({
|
|
|
19150
19151
|
task: bundle.task
|
|
19151
19152
|
});
|
|
19152
19153
|
// packages/workit-core/src/core/route-intent.ts
|
|
19153
|
-
import { spawnSync as
|
|
19154
|
+
import { spawnSync as spawnSync18 } from "node:child_process";
|
|
19154
19155
|
import { existsSync as existsSync12 } from "node:fs";
|
|
19155
|
-
import
|
|
19156
|
+
import path31 from "node:path";
|
|
19156
19157
|
|
|
19157
19158
|
// packages/workit-core/src/hooks/raw-git.ts
|
|
19158
|
-
import { spawnSync as
|
|
19159
|
+
import { spawnSync as spawnSync17 } from "node:child_process";
|
|
19159
19160
|
import { createHash as createHash16 } from "node:crypto";
|
|
19160
|
-
import
|
|
19161
|
+
import fs20 from "node:fs";
|
|
19161
19162
|
import os6 from "node:os";
|
|
19162
|
-
import
|
|
19163
|
+
import path30 from "node:path";
|
|
19163
19164
|
|
|
19164
19165
|
// packages/workit-core/src/autonomy.ts
|
|
19165
19166
|
import { closeSync as closeSync3, copyFileSync as copyFileSync2, existsSync as existsSync11, openSync as openSync3 } from "node:fs";
|
|
19166
|
-
import
|
|
19167
|
+
import path28 from "node:path";
|
|
19167
19168
|
|
|
19168
19169
|
// packages/workit-core/src/core/eval-world.ts
|
|
19169
19170
|
import { existsSync as existsSync10, realpathSync as realpathSync6 } from "node:fs";
|
|
@@ -19297,7 +19298,7 @@ var sealProjection = (entries) => entries.map((entry) => {
|
|
|
19297
19298
|
return pick2({
|
|
19298
19299
|
...all,
|
|
19299
19300
|
vcs: pick2(all.vcs, IDENTITY_KEYS),
|
|
19300
|
-
youtrack: pick2(all.youtrack, ["writes"])
|
|
19301
|
+
youtrack: pick2(all.youtrack, ["writes", "autoHosts"])
|
|
19301
19302
|
}, ENTRY_KEYS);
|
|
19302
19303
|
});
|
|
19303
19304
|
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);
|
|
@@ -19327,6 +19328,97 @@ function checkSeal(dir) {
|
|
|
19327
19328
|
return ok && sealDigest(sealProjection(current.entries)) === seal.sha256 ? { state: "valid" } : broken("workspaces.json changed since it was sealed", sealed.entries);
|
|
19328
19329
|
}
|
|
19329
19330
|
|
|
19331
|
+
// packages/workit-core/src/core/youtrack-ytrack.ts
|
|
19332
|
+
import { spawnSync as spawnSync16 } from "node:child_process";
|
|
19333
|
+
|
|
19334
|
+
// packages/workit-core/src/forge/exec.ts
|
|
19335
|
+
import fs18 from "node:fs";
|
|
19336
|
+
import path27 from "node:path";
|
|
19337
|
+
|
|
19338
|
+
// packages/workit-core/src/forge/redact.ts
|
|
19339
|
+
var NAME = "[A-Za-z0-9_.-]";
|
|
19340
|
+
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}+`;
|
|
19341
|
+
var ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*["']?)((?:bearer|basic|token|digest)\s+)?([^\s"',;&]+)`, "giu");
|
|
19342
|
+
var QUOTED_ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*)(["'])([^"'\n]*[^\s"'][^"'\n]*)\2`, "giu");
|
|
19343
|
+
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");
|
|
19344
|
+
var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*\u0007`, "gu");
|
|
19345
|
+
|
|
19346
|
+
// packages/workit-core/src/forge/exec.ts
|
|
19347
|
+
var MAX_BUFFER2 = 64 * 1024 * 1024;
|
|
19348
|
+
function findExecutable(bin, env) {
|
|
19349
|
+
const dirs = (env.PATH ?? env.Path ?? "").split(path27.delimiter).filter(Boolean);
|
|
19350
|
+
const exts = process.platform === "win32" ? [".exe"] : [""];
|
|
19351
|
+
for (const dir of dirs)
|
|
19352
|
+
for (const ext of exts) {
|
|
19353
|
+
const candidate = path27.join(dir, `${bin}${ext}`);
|
|
19354
|
+
try {
|
|
19355
|
+
const stat = fs18.statSync(candidate);
|
|
19356
|
+
if (stat.isFile())
|
|
19357
|
+
return candidate;
|
|
19358
|
+
} catch {}
|
|
19359
|
+
}
|
|
19360
|
+
return null;
|
|
19361
|
+
}
|
|
19362
|
+
|
|
19363
|
+
// packages/workit-core/src/core/youtrack-ytrack.ts
|
|
19364
|
+
var TIMEOUT_MS = 60000;
|
|
19365
|
+
var YTRACK_EXIT = { ok: 0, failed: 1, cancelled: 2, auth: 4 };
|
|
19366
|
+
var findYtrack = (env) => env.WORKIT_NO_YTRACK === "1" ? null : findExecutable("ytrack", env);
|
|
19367
|
+
var YTRACK_QUIET_ENV = {
|
|
19368
|
+
YTRACK_NO_UPDATE_NOTIFIER: "1",
|
|
19369
|
+
YTRACK_NO_AUTO_UPGRADE: "1"
|
|
19370
|
+
};
|
|
19371
|
+
function ytrackRunner(env, host, timeoutMs = TIMEOUT_MS) {
|
|
19372
|
+
return (args, input) => {
|
|
19373
|
+
const exe = findYtrack(env);
|
|
19374
|
+
if (!exe)
|
|
19375
|
+
return { status: null, stdout: "", stderr: "", missing: true };
|
|
19376
|
+
const result = spawnSync16(exe, args, {
|
|
19377
|
+
encoding: "utf8",
|
|
19378
|
+
env: {
|
|
19379
|
+
...env,
|
|
19380
|
+
NO_COLOR: "1",
|
|
19381
|
+
...YTRACK_QUIET_ENV,
|
|
19382
|
+
...host ? { YTRACK_HOST: host } : {}
|
|
19383
|
+
},
|
|
19384
|
+
timeout: timeoutMs,
|
|
19385
|
+
killSignal: "SIGKILL",
|
|
19386
|
+
windowsHide: true,
|
|
19387
|
+
...input === undefined ? { stdio: ["ignore", "pipe", "pipe"] } : { input, stdio: ["pipe", "pipe", "pipe"] }
|
|
19388
|
+
});
|
|
19389
|
+
const error = result.error;
|
|
19390
|
+
if (error?.code === "ENOENT")
|
|
19391
|
+
return { status: null, stdout: "", stderr: "", missing: true };
|
|
19392
|
+
return {
|
|
19393
|
+
status: result.status,
|
|
19394
|
+
stdout: result.stdout ?? "",
|
|
19395
|
+
stderr: result.stderr || (error ? error.message : "")
|
|
19396
|
+
};
|
|
19397
|
+
};
|
|
19398
|
+
}
|
|
19399
|
+
var ytrackDetail = (out) => out.stderr.trim().split(`
|
|
19400
|
+
`).slice(-3).join(" ").slice(0, 300);
|
|
19401
|
+
var youTrackHostKey = (input) => {
|
|
19402
|
+
const text = input.trim();
|
|
19403
|
+
if (!text || /\s/u.test(text))
|
|
19404
|
+
return null;
|
|
19405
|
+
let url;
|
|
19406
|
+
try {
|
|
19407
|
+
url = new URL(text.includes("://") ? text : `https://${text}`);
|
|
19408
|
+
} catch {
|
|
19409
|
+
return null;
|
|
19410
|
+
}
|
|
19411
|
+
if (!/^https?:$/u.test(url.protocol) || !url.hostname || url.username || url.password)
|
|
19412
|
+
return null;
|
|
19413
|
+
const service = url.pathname.replace(/\/+$/u, "").replace(/\/api$/u, "").replace(/\/+$/u, "");
|
|
19414
|
+
return `${url.host.toLowerCase()}${service}`;
|
|
19415
|
+
};
|
|
19416
|
+
var youTrackHostAllowed = (allowed, host) => {
|
|
19417
|
+
const key = host ? youTrackHostKey(host) : null;
|
|
19418
|
+
return key !== null && allowed.some((entry) => youTrackHostKey(entry) === key);
|
|
19419
|
+
};
|
|
19420
|
+
var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only through ytrack";
|
|
19421
|
+
|
|
19330
19422
|
// packages/workit-core/src/autonomy.ts
|
|
19331
19423
|
var accountHomeDir = () => {
|
|
19332
19424
|
const home = grantsHome.resolve();
|
|
@@ -19334,7 +19426,7 @@ var accountHomeDir = () => {
|
|
|
19334
19426
|
};
|
|
19335
19427
|
var deniedFile = (dir) => {
|
|
19336
19428
|
for (const name of ["workspaces.json", SEAL_FILE]) {
|
|
19337
|
-
const file =
|
|
19429
|
+
const file = path28.join(dir, name);
|
|
19338
19430
|
try {
|
|
19339
19431
|
closeSync3(openSync3(file, "r"));
|
|
19340
19432
|
} catch (error) {
|
|
@@ -19356,7 +19448,7 @@ var accountUnread = () => {
|
|
|
19356
19448
|
if (dir === null)
|
|
19357
19449
|
return NO_ACCOUNT;
|
|
19358
19450
|
const file = deniedFile(dir);
|
|
19359
|
-
return file === null ? null : `the account's ${
|
|
19451
|
+
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`;
|
|
19360
19452
|
};
|
|
19361
19453
|
var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
|
|
19362
19454
|
var fileSource = (dir = accountDir()) => ({
|
|
@@ -19375,26 +19467,46 @@ var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own
|
|
|
19375
19467
|
var NO_SEAL_UNBLOCK = `ask the user to review and seal the grants, in their own terminal: ${SEAL_COMMAND}`;
|
|
19376
19468
|
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}`;
|
|
19377
19469
|
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;
|
|
19378
|
-
var
|
|
19470
|
+
var ASK = { mode: "ask" };
|
|
19471
|
+
var youtrackOf = (entry) => entry?.youtrack;
|
|
19472
|
+
var autoHostsOf = (entry) => {
|
|
19473
|
+
const hosts = youtrackOf(entry)?.autoHosts;
|
|
19474
|
+
return Array.isArray(hosts) ? hosts.filter((host) => typeof host === "string") : null;
|
|
19475
|
+
};
|
|
19476
|
+
var youTrackWritesPolicy = (cwd) => {
|
|
19379
19477
|
try {
|
|
19380
19478
|
const dir = accountDir();
|
|
19381
19479
|
if (dir === null || redirected(dir) || evalWorld(cwd))
|
|
19382
|
-
return
|
|
19480
|
+
return ASK;
|
|
19383
19481
|
if (checkSeal(dir).state !== "valid")
|
|
19384
|
-
return
|
|
19385
|
-
const auto = (entry) => entry?.
|
|
19482
|
+
return ASK;
|
|
19483
|
+
const auto = (entry) => youtrackOf(entry)?.writes === "auto";
|
|
19386
19484
|
const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
19387
|
-
|
|
19388
|
-
|
|
19389
|
-
|
|
19485
|
+
const named = resolveWorkspaceFrom(cwd, dir, name);
|
|
19486
|
+
const folder = name ? resolveWorkspaceFrom(cwd, dir) : named;
|
|
19487
|
+
if (!auto(named) || !auto(folder))
|
|
19488
|
+
return ASK;
|
|
19489
|
+
const [a, b] = [autoHostsOf(named), autoHostsOf(folder)];
|
|
19490
|
+
const base = youtrackOf(named)?.baseUrl;
|
|
19491
|
+
return {
|
|
19492
|
+
mode: "auto",
|
|
19493
|
+
hosts: a === null ? b : b === null ? a : a.filter((host) => youTrackHostAllowed(b, host)),
|
|
19494
|
+
baseUrl: typeof base === "string" && base.trim() ? base.trim() : null
|
|
19495
|
+
};
|
|
19390
19496
|
} catch {
|
|
19391
|
-
return
|
|
19497
|
+
return ASK;
|
|
19392
19498
|
}
|
|
19393
19499
|
};
|
|
19394
|
-
var
|
|
19500
|
+
var youTrackWritesMode = (cwd, host) => {
|
|
19501
|
+
const policy = youTrackWritesPolicy(cwd);
|
|
19502
|
+
if (policy.mode === "ask" || policy.hosts === null)
|
|
19503
|
+
return policy.mode;
|
|
19504
|
+
return youTrackHostAllowed(policy.hosts, host === undefined ? policy.baseUrl : host) ? "auto" : "ask";
|
|
19505
|
+
};
|
|
19506
|
+
var redirected = (dir) => path28.resolve(resolveConfigDir()) !== path28.resolve(dir);
|
|
19395
19507
|
var shownGrantsDir = () => {
|
|
19396
19508
|
const world = evalWorld(process.cwd());
|
|
19397
|
-
return world ?
|
|
19509
|
+
return world ? path28.join(world, "config") : accountDir();
|
|
19398
19510
|
};
|
|
19399
19511
|
var benchWorld = (cwd) => {
|
|
19400
19512
|
const entry = evalWorldEntry(cwd);
|
|
@@ -19418,10 +19530,10 @@ var grantsOverride = () => {
|
|
|
19418
19530
|
const shown = shownGrantsDir();
|
|
19419
19531
|
if (shown === null)
|
|
19420
19532
|
return accountUnread() ?? NO_ACCOUNT;
|
|
19421
|
-
const configured =
|
|
19422
|
-
return configured ===
|
|
19533
|
+
const configured = path28.resolve(resolveConfigDir());
|
|
19534
|
+
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`;
|
|
19423
19535
|
};
|
|
19424
|
-
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 ${
|
|
19536
|
+
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")}`;
|
|
19425
19537
|
var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
|
|
19426
19538
|
var DEFAULT_GRANTS = Object.freeze({
|
|
19427
19539
|
push: true,
|
|
@@ -19829,8 +19941,8 @@ var packageTagShapes = (packages) => packages.map((entry) => `${entry.tagNamespa
|
|
|
19829
19941
|
|
|
19830
19942
|
// packages/workit-core/src/hooks/session-marker.ts
|
|
19831
19943
|
import { createHash as createHash15 } from "node:crypto";
|
|
19832
|
-
import
|
|
19833
|
-
import
|
|
19944
|
+
import fs19 from "node:fs";
|
|
19945
|
+
import path29 from "node:path";
|
|
19834
19946
|
var sessionMarkerFile = (input, session, store) => {
|
|
19835
19947
|
let dir = store;
|
|
19836
19948
|
if (dir === undefined) {
|
|
@@ -19840,7 +19952,7 @@ var sessionMarkerFile = (input, session, store) => {
|
|
|
19840
19952
|
dir = location.dir;
|
|
19841
19953
|
}
|
|
19842
19954
|
const name = createHash15("sha256").update(`${input.host}\x00${session}`).digest("hex").slice(0, 32);
|
|
19843
|
-
return
|
|
19955
|
+
return path29.join(dir, "hooks", `skills-${name}.json`);
|
|
19844
19956
|
};
|
|
19845
19957
|
var list2 = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
19846
19958
|
var EMPTY = {
|
|
@@ -19853,7 +19965,7 @@ var EMPTY = {
|
|
|
19853
19965
|
};
|
|
19854
19966
|
var readRaw = (file) => {
|
|
19855
19967
|
try {
|
|
19856
|
-
return
|
|
19968
|
+
return fs19.readFileSync(file, "utf8");
|
|
19857
19969
|
} catch {
|
|
19858
19970
|
return "";
|
|
19859
19971
|
}
|
|
@@ -19875,13 +19987,13 @@ var parseMarker = (text) => {
|
|
|
19875
19987
|
};
|
|
19876
19988
|
var readSessionMarker = (file) => parseMarker(readRaw(file));
|
|
19877
19989
|
var writeAtomic = (file, marker) => {
|
|
19878
|
-
|
|
19990
|
+
fs19.mkdirSync(path29.dirname(file), { recursive: true });
|
|
19879
19991
|
const temp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
19880
19992
|
try {
|
|
19881
|
-
|
|
19882
|
-
|
|
19993
|
+
fs19.writeFileSync(temp, JSON.stringify(marker));
|
|
19994
|
+
fs19.renameSync(temp, file);
|
|
19883
19995
|
} catch (error) {
|
|
19884
|
-
|
|
19996
|
+
fs19.rmSync(temp, { force: true });
|
|
19885
19997
|
throw error;
|
|
19886
19998
|
}
|
|
19887
19999
|
};
|
|
@@ -20460,17 +20572,17 @@ var GIT_VALUE_OPTIONS = new Set([
|
|
|
20460
20572
|
]);
|
|
20461
20573
|
var GIT_CONFIG_OPTIONS = new Set(["-c", "--config-env", "--git-dir"]);
|
|
20462
20574
|
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)$/;
|
|
20463
|
-
var
|
|
20575
|
+
var ASSIGNMENT2 = /^([A-Za-z_]\w*)=([\s\S]*)$/;
|
|
20464
20576
|
var MAX_DEPTH = 4;
|
|
20465
20577
|
var MAX_EXPANSIONS = 16;
|
|
20466
|
-
var isAbsolute = (value) =>
|
|
20578
|
+
var isAbsolute = (value) => path30.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
|
|
20467
20579
|
var HERE = /^(?:\$PWD|\$\{PWD\}|\$\(\s*pwd\s*\)|`pwd`|\$\(\s*git\s+rev-parse\s+--show-toplevel\s*\))(?=$|[\\/])/;
|
|
20468
20580
|
var joinDir = (base, raw) => {
|
|
20469
20581
|
const next = raw.replace(HERE, ".");
|
|
20470
20582
|
if (base === undefined || /[$`*?]/.test(next) || next === "-")
|
|
20471
20583
|
return;
|
|
20472
|
-
const expanded = next === "~" || next.startsWith("~/") ?
|
|
20473
|
-
return base === null || isAbsolute(expanded) ? expanded :
|
|
20584
|
+
const expanded = next === "~" || next.startsWith("~/") ? path30.join(os6.homedir(), next.slice(1)) : next;
|
|
20585
|
+
return base === null || isAbsolute(expanded) ? expanded : path30.join(base, expanded);
|
|
20474
20586
|
};
|
|
20475
20587
|
var rebase = (base, inner) => inner === null ? base : inner === undefined ? undefined : joinDir(base, inner);
|
|
20476
20588
|
var cdTarget = (words) => {
|
|
@@ -20487,7 +20599,7 @@ var stripPrefixes = (input) => {
|
|
|
20487
20599
|
const first = words[0];
|
|
20488
20600
|
if (first === undefined)
|
|
20489
20601
|
return { words, env };
|
|
20490
|
-
const assignment =
|
|
20602
|
+
const assignment = ASSIGNMENT2.exec(first);
|
|
20491
20603
|
if (assignment) {
|
|
20492
20604
|
if (GIT_CONFIG_ENV.test(assignment[1]))
|
|
20493
20605
|
env[assignment[1]] = assignment[2];
|
|
@@ -20546,10 +20658,10 @@ var assignments = (words, vars) => {
|
|
|
20546
20658
|
while (rest[0]?.startsWith("-"))
|
|
20547
20659
|
rest = rest.slice(1);
|
|
20548
20660
|
}
|
|
20549
|
-
if (rest.length === 0 || !rest.every((word) =>
|
|
20661
|
+
if (rest.length === 0 || !rest.every((word) => ASSIGNMENT2.test(word)))
|
|
20550
20662
|
return null;
|
|
20551
20663
|
return rest.map((word) => {
|
|
20552
|
-
const [, name, value] =
|
|
20664
|
+
const [, name, value] = ASSIGNMENT2.exec(word);
|
|
20553
20665
|
return [name, expandWord(value, vars)];
|
|
20554
20666
|
});
|
|
20555
20667
|
};
|
|
@@ -20737,7 +20849,7 @@ var splitString = (line) => {
|
|
|
20737
20849
|
return line.slice(index).join(" ").slice(15);
|
|
20738
20850
|
if (/^-S./.test(word))
|
|
20739
20851
|
return [word.slice(2), ...line.slice(index + 1)].join(" ");
|
|
20740
|
-
if (!word.startsWith("-") && !
|
|
20852
|
+
if (!word.startsWith("-") && !ASSIGNMENT2.test(word))
|
|
20741
20853
|
return null;
|
|
20742
20854
|
}
|
|
20743
20855
|
return null;
|
|
@@ -21371,7 +21483,7 @@ var repoAt = (dir) => {
|
|
|
21371
21483
|
return { location, dir, branch: resolveTaskKey(dir, location).branch };
|
|
21372
21484
|
};
|
|
21373
21485
|
var isWorkitWorkspace = (repo) => {
|
|
21374
|
-
if (
|
|
21486
|
+
if (fs20.existsSync(repo.location.dir))
|
|
21375
21487
|
return true;
|
|
21376
21488
|
try {
|
|
21377
21489
|
return resolveRuntimeWorkspaceVcs(repo.location.top ?? repo.dir) !== null;
|
|
@@ -21392,17 +21504,17 @@ var headSha2 = (repo) => {
|
|
|
21392
21504
|
if (!git || git.reftable)
|
|
21393
21505
|
return null;
|
|
21394
21506
|
try {
|
|
21395
|
-
const head =
|
|
21507
|
+
const head = fs20.readFileSync(path30.join(git.gitDir, "HEAD"), "utf8").trim();
|
|
21396
21508
|
if (/^[0-9a-f]{40,64}$/.test(head))
|
|
21397
21509
|
return head;
|
|
21398
21510
|
const ref = /^ref: (refs\/.+)$/.exec(head)?.[1];
|
|
21399
21511
|
if (!ref)
|
|
21400
21512
|
return null;
|
|
21401
|
-
const common =
|
|
21513
|
+
const common = path30.dirname(repo.location.dir);
|
|
21402
21514
|
try {
|
|
21403
|
-
return
|
|
21515
|
+
return fs20.readFileSync(path30.join(common, ref), "utf8").trim() || null;
|
|
21404
21516
|
} catch {}
|
|
21405
|
-
const packed =
|
|
21517
|
+
const packed = fs20.readFileSync(path30.join(common, "packed-refs"), "utf8");
|
|
21406
21518
|
return new RegExp(`^([0-9a-f]{40,64}) ${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`, "m").exec(packed)?.[1] ?? null;
|
|
21407
21519
|
} catch {
|
|
21408
21520
|
return null;
|
|
@@ -21414,7 +21526,7 @@ var gitConfig = (dir, invocation, cache) => {
|
|
|
21414
21526
|
if (cached)
|
|
21415
21527
|
return cached;
|
|
21416
21528
|
const config = new Map;
|
|
21417
|
-
const listed =
|
|
21529
|
+
const listed = spawnSync17("git", [...invocation.config ?? [], "config", "-z", "--list"], {
|
|
21418
21530
|
cwd: dir,
|
|
21419
21531
|
encoding: "utf8",
|
|
21420
21532
|
timeout: 3000,
|
|
@@ -21495,8 +21607,8 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
|
|
|
21495
21607
|
const sub = invocation.args[0];
|
|
21496
21608
|
if (invocation.tool !== "git" || invocation.dir === undefined || !sub || sub.startsWith("-") || GIT_COMMANDS.has(sub) || depth >= MAX_DEPTH)
|
|
21497
21609
|
return [invocation];
|
|
21498
|
-
const dir =
|
|
21499
|
-
if (!
|
|
21610
|
+
const dir = path30.resolve(root, invocation.dir ?? ".");
|
|
21611
|
+
if (!fs20.existsSync(dir))
|
|
21500
21612
|
return [invocation];
|
|
21501
21613
|
const config = gitConfig(dir, invocation, cache);
|
|
21502
21614
|
const alias = configValue(config, `alias.${sub.toLowerCase()}`);
|
|
@@ -21518,11 +21630,11 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
|
|
|
21518
21630
|
var normalizedUrl = (url, dir) => {
|
|
21519
21631
|
const trimmed = url.trim();
|
|
21520
21632
|
if (/^file:\/\//i.test(trimmed))
|
|
21521
|
-
return
|
|
21633
|
+
return path30.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
|
|
21522
21634
|
const scheme = /^[a-z][a-z0-9+.-]*:\/\//i.exec(trimmed);
|
|
21523
21635
|
const scp = !scheme && /^(?:[^@/\\]+@)?[^/\\:]{2,}:/.test(trimmed);
|
|
21524
21636
|
if (!scheme && !scp)
|
|
21525
|
-
return
|
|
21637
|
+
return path30.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
|
|
21526
21638
|
const value = scheme ? trimmed.slice(scheme[0].length).replace(/^[^@/]*@/, "").replace(/^([^/:]+):\d+(?=\/)/, "$1") : trimmed.replace(/^[^@/]*@/, "").replace(":", "/");
|
|
21527
21639
|
return value.toLowerCase().replace(/\/{2,}/g, "/").replace(/^www\./, "").replace(/\/+$/, "").replace(/\.git$/, "");
|
|
21528
21640
|
};
|
|
@@ -21587,7 +21699,7 @@ var refFacts = (repo, remote) => {
|
|
|
21587
21699
|
tags: new Set,
|
|
21588
21700
|
remoteHeads: new Set
|
|
21589
21701
|
};
|
|
21590
|
-
const listed =
|
|
21702
|
+
const listed = spawnSync17("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/tags", `refs/remotes/${remote}`], { cwd: repo.dir, encoding: "utf8", timeout: 5000 });
|
|
21591
21703
|
const remotePrefix = `refs/remotes/${remote}/`;
|
|
21592
21704
|
for (const ref of (listed.stdout ?? "").split(`
|
|
21593
21705
|
`)) {
|
|
@@ -21604,7 +21716,7 @@ var globBranches = (repo, glob) => {
|
|
|
21604
21716
|
const source = glob.source.startsWith("refs/") ? glob.source : `refs/heads/${glob.source}`;
|
|
21605
21717
|
const [sourcePrefix, sourceSuffix = ""] = source.split("*");
|
|
21606
21718
|
const [destinationPrefix, destinationSuffix = ""] = glob.destination.split("*");
|
|
21607
|
-
const listed =
|
|
21719
|
+
const listed = spawnSync17("git", [
|
|
21608
21720
|
"for-each-ref",
|
|
21609
21721
|
"--format=%(refname)",
|
|
21610
21722
|
sourcePrefix.slice(0, sourcePrefix.lastIndexOf("/") + 1)
|
|
@@ -21686,7 +21798,7 @@ var tagRefusal = (action, facts, dir) => {
|
|
|
21686
21798
|
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}`;
|
|
21687
21799
|
};
|
|
21688
21800
|
var remoteHeads = (repo, remote) => {
|
|
21689
|
-
const listed =
|
|
21801
|
+
const listed = spawnSync17("git", ["ls-remote", "--heads", remote], {
|
|
21690
21802
|
cwd: repo.dir,
|
|
21691
21803
|
encoding: "utf8",
|
|
21692
21804
|
timeout: 3000,
|
|
@@ -21755,7 +21867,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
|
|
|
21755
21867
|
const out = [];
|
|
21756
21868
|
const repos = new Map;
|
|
21757
21869
|
const repoFor = (relative) => {
|
|
21758
|
-
const dir =
|
|
21870
|
+
const dir = path30.resolve(cwd, relative ?? ".");
|
|
21759
21871
|
if (!repos.has(dir)) {
|
|
21760
21872
|
const repo = repoAt(dir);
|
|
21761
21873
|
const workit = repo !== null && isWorkitWorkspace(repo);
|
|
@@ -21776,7 +21888,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
|
|
|
21776
21888
|
const action = rawAction(invocation);
|
|
21777
21889
|
const at = !action ? null : repoFor(invocation.dir) ?? (all && invocation.tool !== "git" && explicitRepo(invocation.tool === "gh", "repo" in action && action.repo || "", invocation.env ?? {}) ? {
|
|
21778
21890
|
repo: {
|
|
21779
|
-
dir:
|
|
21891
|
+
dir: path30.resolve(cwd, invocation.dir ?? "."),
|
|
21780
21892
|
branch: null
|
|
21781
21893
|
},
|
|
21782
21894
|
workit: false
|
|
@@ -21849,13 +21961,13 @@ var messageOf = (segment, index) => {
|
|
|
21849
21961
|
};
|
|
21850
21962
|
var sameGitDir = (a, b, platform = process.platform) => {
|
|
21851
21963
|
if (platform !== "win32")
|
|
21852
|
-
return
|
|
21853
|
-
const fold = (value) =>
|
|
21964
|
+
return path30.posix.resolve(a) === path30.posix.resolve(b);
|
|
21965
|
+
const fold = (value) => path30.win32.resolve(value).toLowerCase();
|
|
21854
21966
|
return fold(a) === fold(b);
|
|
21855
21967
|
};
|
|
21856
21968
|
var cdCommitCall = (input, command, target, repo) => {
|
|
21857
21969
|
const { top, git, dir: store } = repo.location;
|
|
21858
|
-
if (!top || !git || sameGitDir(git.gitDir,
|
|
21970
|
+
if (!top || !git || sameGitDir(git.gitDir, path30.dirname(store)) || repoAt(input.cwd)?.location.top === top)
|
|
21859
21971
|
return null;
|
|
21860
21972
|
const bare = command.replaceAll(/'[^']*'|"(?:[^"\\]|\\.)*"/gu, "").replaceAll("&&", "");
|
|
21861
21973
|
if (/[;|&<>`$()\n\\]/u.test(bare))
|
|
@@ -21864,7 +21976,7 @@ var cdCommitCall = (input, command, target, repo) => {
|
|
|
21864
21976
|
const commit = rest.at(-1);
|
|
21865
21977
|
if (cd?.words[0] !== "cd" || cd.words.length !== 2 || cd.expands?.length || !commit)
|
|
21866
21978
|
return null;
|
|
21867
|
-
if (
|
|
21979
|
+
if (path30.resolve(input.cwd, cd.words[1]) !== target)
|
|
21868
21980
|
return null;
|
|
21869
21981
|
if (rest.some((each) => each.redirects.length || each.stdin?.length || each.group))
|
|
21870
21982
|
return null;
|
|
@@ -21907,7 +22019,7 @@ var cdCommitCall = (input, command, target, repo) => {
|
|
|
21907
22019
|
if (!messages.length)
|
|
21908
22020
|
return null;
|
|
21909
22021
|
if (!all) {
|
|
21910
|
-
const staged =
|
|
22022
|
+
const staged = spawnSync17("git", ["diff", "--cached", "--quiet"], {
|
|
21911
22023
|
cwd: target,
|
|
21912
22024
|
timeout: 5000
|
|
21913
22025
|
});
|
|
@@ -21931,7 +22043,7 @@ var commitRefusal = (input, command, dialect, { action, repo, invocation, workit
|
|
|
21931
22043
|
} catch {}
|
|
21932
22044
|
if (guarded && !switches)
|
|
21933
22045
|
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>")}.`;
|
|
21934
|
-
const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command,
|
|
22046
|
+
const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path30.resolve(input.cwd, invocation.dir), repo);
|
|
21935
22047
|
return call && `workit: no ${quote("cd … &&")} chain; run ${quote(call)}.`;
|
|
21936
22048
|
};
|
|
21937
22049
|
function rawGitPre(input, command, options = {}) {
|
|
@@ -22029,9 +22141,9 @@ var grantRefusal = (action, repo, invocation, cache) => {
|
|
|
22029
22141
|
return null;
|
|
22030
22142
|
};
|
|
22031
22143
|
var localTag = (repo, name) => {
|
|
22032
|
-
const common =
|
|
22144
|
+
const common = path30.dirname(repo.location.dir);
|
|
22033
22145
|
try {
|
|
22034
|
-
return
|
|
22146
|
+
return fs20.existsSync(path30.join(common, "refs/tags", name)) || fs20.readFileSync(path30.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
|
|
22035
22147
|
`);
|
|
22036
22148
|
} catch {
|
|
22037
22149
|
return false;
|
|
@@ -22051,7 +22163,7 @@ var analysisDenial = (error) => ({
|
|
|
22051
22163
|
});
|
|
22052
22164
|
var NEXT_COMMAND = "next";
|
|
22053
22165
|
var MARKER_TTL_SECONDS = 3600;
|
|
22054
|
-
var markerFile = (repo, session, key) =>
|
|
22166
|
+
var markerFile = (repo, session, key) => path30.join(repo.location.dir, "hooks", `commit-${createHash16("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
|
|
22055
22167
|
var callKey = (toolUseId, command) => toolUseId ?? `cmd:${createHash16("sha256").update(command).digest("hex")}`;
|
|
22056
22168
|
function noteRawCommit(input, command, key) {
|
|
22057
22169
|
try {
|
|
@@ -22062,14 +22174,14 @@ function noteRawCommit(input, command, key) {
|
|
|
22062
22174
|
if (action.kind !== "commit")
|
|
22063
22175
|
continue;
|
|
22064
22176
|
const file = markerFile(repo, input.session.id, key);
|
|
22065
|
-
|
|
22066
|
-
|
|
22177
|
+
fs20.mkdirSync(path30.dirname(file), { recursive: true });
|
|
22178
|
+
fs20.writeFileSync(file, `${JSON.stringify({ head: headSha2(repo), at })}
|
|
22067
22179
|
`);
|
|
22068
22180
|
}
|
|
22069
22181
|
} catch {}
|
|
22070
22182
|
}
|
|
22071
22183
|
var headCommit = (dir) => {
|
|
22072
|
-
const run =
|
|
22184
|
+
const run = spawnSync17("git", [
|
|
22073
22185
|
"log",
|
|
22074
22186
|
"-1",
|
|
22075
22187
|
"--format=%H%x1f%ct%x1f%s%x1f%(trailers:key=Workit-Session,valueonly,separator=%x2c)"
|
|
@@ -22096,11 +22208,11 @@ var headCommit = (dir) => {
|
|
|
22096
22208
|
var settle2 = (input, repo, file) => {
|
|
22097
22209
|
let marker;
|
|
22098
22210
|
try {
|
|
22099
|
-
marker = JSON.parse(
|
|
22211
|
+
marker = JSON.parse(fs20.readFileSync(file, "utf8"));
|
|
22100
22212
|
} catch {
|
|
22101
22213
|
return;
|
|
22102
22214
|
}
|
|
22103
|
-
|
|
22215
|
+
fs20.rmSync(file, { force: true });
|
|
22104
22216
|
const session = input.session.id;
|
|
22105
22217
|
const now = Date.now() / 1000;
|
|
22106
22218
|
if (typeof marker.at !== "number" || now - marker.at > MARKER_TTL_SECONDS)
|
|
@@ -22149,7 +22261,7 @@ function settlePendingCommit(input) {
|
|
|
22149
22261
|
if (!repo)
|
|
22150
22262
|
return;
|
|
22151
22263
|
const file = markerFile(repo, input.session.id, NEXT_COMMAND);
|
|
22152
|
-
if (
|
|
22264
|
+
if (fs20.existsSync(file))
|
|
22153
22265
|
settle2(input, repo, file);
|
|
22154
22266
|
} catch {}
|
|
22155
22267
|
}
|
|
@@ -22293,7 +22405,7 @@ var targetsOf = (invocations) => invocations.flatMap((invocation) => invocation.
|
|
|
22293
22405
|
branch,
|
|
22294
22406
|
dir: invocation.dir
|
|
22295
22407
|
})) : []);
|
|
22296
|
-
var localBranchExists = (dir, branch) =>
|
|
22408
|
+
var localBranchExists = (dir, branch) => spawnSync18("git", ["show-ref", "--verify", "--quiet", `refs/heads/${branch}`], {
|
|
22297
22409
|
cwd: dir,
|
|
22298
22410
|
stdio: "ignore",
|
|
22299
22411
|
timeout: 5000
|
|
@@ -22303,7 +22415,7 @@ var judgedDir = (root, dir) => {
|
|
|
22303
22415
|
return null;
|
|
22304
22416
|
if (dir === null)
|
|
22305
22417
|
return root;
|
|
22306
|
-
const resolved =
|
|
22418
|
+
const resolved = path31.resolve(root, dir);
|
|
22307
22419
|
return existsSync12(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
|
|
22308
22420
|
};
|
|
22309
22421
|
var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
|
|
@@ -24299,9 +24411,9 @@ class WorkitCore {
|
|
|
24299
24411
|
}
|
|
24300
24412
|
}
|
|
24301
24413
|
// packages/workit-core/src/core/repo-context.ts
|
|
24302
|
-
import { spawnSync as
|
|
24414
|
+
import { spawnSync as spawnSync19 } from "node:child_process";
|
|
24303
24415
|
import { existsSync as existsSync13, readFileSync as readFileSync11, readdirSync as readdirSync4 } from "node:fs";
|
|
24304
|
-
import
|
|
24416
|
+
import path32 from "node:path";
|
|
24305
24417
|
var isSafeContextRange = (value) => value.length <= 4096 && (() => {
|
|
24306
24418
|
try {
|
|
24307
24419
|
gitRevisionParts(value);
|
|
@@ -24328,7 +24440,7 @@ var invalidRange = (cwd) => ({
|
|
|
24328
24440
|
cwd
|
|
24329
24441
|
});
|
|
24330
24442
|
var runGit = (cwd, args) => {
|
|
24331
|
-
const result =
|
|
24443
|
+
const result = spawnSync19("git", args, { cwd, encoding: "utf8" });
|
|
24332
24444
|
return {
|
|
24333
24445
|
stdout: (result.stdout ?? "").trimEnd(),
|
|
24334
24446
|
stderr: (result.stderr ?? "").trimEnd(),
|
|
@@ -24445,13 +24557,13 @@ var findPrTemplate = (cwd) => {
|
|
|
24445
24557
|
for (const rel of PR_TEMPLATE_FILES) {
|
|
24446
24558
|
const parts = rel.split("/");
|
|
24447
24559
|
const base = parts[parts.length - 1];
|
|
24448
|
-
const dir = parts.length > 1 ?
|
|
24560
|
+
const dir = parts.length > 1 ? path32.join(cwd, ...parts.slice(0, -1)) : cwd;
|
|
24449
24561
|
const actual = probeCaseInsensitive(dir, base);
|
|
24450
24562
|
if (actual)
|
|
24451
24563
|
return [...parts.slice(0, -1), actual].join("/");
|
|
24452
24564
|
}
|
|
24453
24565
|
for (const rel of PR_TEMPLATE_DIRS) {
|
|
24454
|
-
const only = singleMarkdown(
|
|
24566
|
+
const only = singleMarkdown(path32.join(cwd, ...rel.split("/")));
|
|
24455
24567
|
if (only)
|
|
24456
24568
|
return `${rel}/${only}`;
|
|
24457
24569
|
}
|
|
@@ -24481,7 +24593,7 @@ var diffStatForRange = (cwd, range) => {
|
|
|
24481
24593
|
return runGit(cwd, ["diff", "--stat", "--"]).stdout;
|
|
24482
24594
|
};
|
|
24483
24595
|
var packageScripts = (cwd, keys) => {
|
|
24484
|
-
const pkgPath =
|
|
24596
|
+
const pkgPath = path32.join(cwd, "package.json");
|
|
24485
24597
|
if (!existsSync13(pkgPath))
|
|
24486
24598
|
return [];
|
|
24487
24599
|
try {
|
|
@@ -24507,9 +24619,9 @@ var documentationFiles = (cwd) => {
|
|
|
24507
24619
|
if (entry.isDirectory()) {
|
|
24508
24620
|
if (excluded.has(entry.name))
|
|
24509
24621
|
continue;
|
|
24510
|
-
walk(
|
|
24622
|
+
walk(path32.join(dir, entry.name), depth + 1);
|
|
24511
24623
|
} else if (entry.isFile() && (entry.name === "README.md" || entry.name.endsWith(".md"))) {
|
|
24512
|
-
matches.push("./" +
|
|
24624
|
+
matches.push("./" + path32.relative(cwd, path32.join(dir, entry.name)).replaceAll("\\", "/"));
|
|
24513
24625
|
}
|
|
24514
24626
|
}
|
|
24515
24627
|
};
|
|
@@ -24525,7 +24637,7 @@ var readTrimmed2 = (file, maxLines) => {
|
|
|
24525
24637
|
`);
|
|
24526
24638
|
};
|
|
24527
24639
|
function prReadyContext(root, range) {
|
|
24528
|
-
const cwd =
|
|
24640
|
+
const cwd = path32.resolve(repoRoot(root));
|
|
24529
24641
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
24530
24642
|
return invalidRange(cwd);
|
|
24531
24643
|
let stdout = "";
|
|
@@ -24583,7 +24695,7 @@ ${status.stderr}` : "");
|
|
|
24583
24695
|
stdout += `template_path: ${template}
|
|
24584
24696
|
|
|
24585
24697
|
`;
|
|
24586
|
-
stdout += readTrimmed2(
|
|
24698
|
+
stdout += readTrimmed2(path32.join(cwd, template), 220);
|
|
24587
24699
|
} else {
|
|
24588
24700
|
stdout += `template_path: none
|
|
24589
24701
|
|
|
@@ -24593,7 +24705,7 @@ ${status.stderr}` : "");
|
|
|
24593
24705
|
stdout += `
|
|
24594
24706
|
`;
|
|
24595
24707
|
stdout += printSection("Recent Validation Signals");
|
|
24596
|
-
if (existsSync13(
|
|
24708
|
+
if (existsSync13(path32.join(cwd, "package.json"))) {
|
|
24597
24709
|
stdout += `package.json detected. Common scripts:
|
|
24598
24710
|
`;
|
|
24599
24711
|
const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
|
|
@@ -24602,7 +24714,7 @@ ${status.stderr}` : "");
|
|
|
24602
24714
|
`) + `
|
|
24603
24715
|
`;
|
|
24604
24716
|
}
|
|
24605
|
-
if (existsSync13(
|
|
24717
|
+
if (existsSync13(path32.join(cwd, "Cargo.toml")) || existsSync13(path32.join(cwd, "src-tauri/Cargo.toml"))) {
|
|
24606
24718
|
stdout += `Rust project detected.
|
|
24607
24719
|
`;
|
|
24608
24720
|
}
|
|
@@ -24635,7 +24747,7 @@ var CHANGELOG_RULES = `- Use an [Unreleased] section.
|
|
|
24635
24747
|
- Apply with the host-native editor, preserving the repository changelog conventions.
|
|
24636
24748
|
- If Unreleased already has duplicate category headings, normalize_only first.`;
|
|
24637
24749
|
function changelogContext(root, range) {
|
|
24638
|
-
const cwd =
|
|
24750
|
+
const cwd = path32.resolve(repoRoot(root));
|
|
24639
24751
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
24640
24752
|
return invalidRange(cwd);
|
|
24641
24753
|
const resolvedRange = rangeArgOrDefault(range, cwd);
|
|
@@ -24653,7 +24765,7 @@ function changelogContext(root, range) {
|
|
|
24653
24765
|
stdout += CHANGELOG_RULES + `
|
|
24654
24766
|
`;
|
|
24655
24767
|
stdout += printSection("Existing CHANGELOG.md");
|
|
24656
|
-
const changelogPath =
|
|
24768
|
+
const changelogPath = path32.join(cwd, "CHANGELOG.md");
|
|
24657
24769
|
if (existsSync13(changelogPath)) {
|
|
24658
24770
|
stdout += readTrimmed2(changelogPath, 260) + `
|
|
24659
24771
|
`;
|
|
@@ -24673,7 +24785,7 @@ function changelogContext(root, range) {
|
|
|
24673
24785
|
return { stdout, stderr: "", exitCode: 0, cwd };
|
|
24674
24786
|
}
|
|
24675
24787
|
function docsRefreshContext(root, range) {
|
|
24676
|
-
const cwd =
|
|
24788
|
+
const cwd = path32.resolve(repoRoot(root));
|
|
24677
24789
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
24678
24790
|
return invalidRange(cwd);
|
|
24679
24791
|
const resolvedRange = rangeArgOrDefault(range, cwd);
|
|
@@ -24695,7 +24807,7 @@ function docsRefreshContext(root, range) {
|
|
|
24695
24807
|
`) + `
|
|
24696
24808
|
`;
|
|
24697
24809
|
stdout += printSection("README Preview");
|
|
24698
|
-
const readme =
|
|
24810
|
+
const readme = path32.join(cwd, "README.md");
|
|
24699
24811
|
if (existsSync13(readme)) {
|
|
24700
24812
|
stdout += readTrimmed2(readme, 220) + `
|
|
24701
24813
|
`;
|
|
@@ -24704,7 +24816,7 @@ function docsRefreshContext(root, range) {
|
|
|
24704
24816
|
`;
|
|
24705
24817
|
}
|
|
24706
24818
|
stdout += printSection("Package Scripts");
|
|
24707
|
-
const pkgPath =
|
|
24819
|
+
const pkgPath = path32.join(cwd, "package.json");
|
|
24708
24820
|
if (existsSync13(pkgPath)) {
|
|
24709
24821
|
try {
|
|
24710
24822
|
const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
|
|
@@ -24718,7 +24830,7 @@ function docsRefreshContext(root, range) {
|
|
|
24718
24830
|
return { stdout, stderr: "", exitCode: 0, cwd };
|
|
24719
24831
|
}
|
|
24720
24832
|
function releaseNotesContext(root, rangeOrTag) {
|
|
24721
|
-
const cwd =
|
|
24833
|
+
const cwd = path32.resolve(repoRoot(root));
|
|
24722
24834
|
if (!rangeOrTag) {
|
|
24723
24835
|
return {
|
|
24724
24836
|
stdout: "",
|
|
@@ -24761,7 +24873,7 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
24761
24873
|
`;
|
|
24762
24874
|
stdout += printSection("Existing Release Files");
|
|
24763
24875
|
for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
|
|
24764
|
-
if (existsSync13(
|
|
24876
|
+
if (existsSync13(path32.join(cwd, rel)))
|
|
24765
24877
|
stdout += rel + `
|
|
24766
24878
|
`;
|
|
24767
24879
|
}
|
|
@@ -24789,12 +24901,12 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
24789
24901
|
}
|
|
24790
24902
|
|
|
24791
24903
|
// packages/workit-core/src/core/tracker-issues.ts
|
|
24792
|
-
import { spawnSync as
|
|
24904
|
+
import { spawnSync as spawnSync21 } from "node:child_process";
|
|
24793
24905
|
|
|
24794
24906
|
// packages/workit-core/src/core/pr-create.ts
|
|
24795
|
-
import
|
|
24796
|
-
import
|
|
24797
|
-
import { spawnSync as
|
|
24907
|
+
import fs21 from "node:fs";
|
|
24908
|
+
import path33 from "node:path";
|
|
24909
|
+
import { spawnSync as spawnSync20 } from "node:child_process";
|
|
24798
24910
|
// packages/workit-core/src/forge/pr-body.ts
|
|
24799
24911
|
function parseGhIssue(value) {
|
|
24800
24912
|
const m = /issues\/(\d+)/.exec(value);
|
|
@@ -24813,13 +24925,13 @@ var LOCAL = bounded(20000);
|
|
|
24813
24925
|
var NETWORK = bounded(60000);
|
|
24814
24926
|
function whichOnPath(tool) {
|
|
24815
24927
|
const names = process.platform === "win32" ? [tool, `${tool}.exe`, `${tool}.cmd`] : [tool];
|
|
24816
|
-
for (const dir of (process.env.PATH ?? "").split(
|
|
24928
|
+
for (const dir of (process.env.PATH ?? "").split(path33.delimiter)) {
|
|
24817
24929
|
if (!dir)
|
|
24818
24930
|
continue;
|
|
24819
24931
|
for (const name of names) {
|
|
24820
|
-
const candidate =
|
|
24932
|
+
const candidate = path33.join(dir, name);
|
|
24821
24933
|
try {
|
|
24822
|
-
|
|
24934
|
+
fs21.accessSync(candidate, fs21.constants.X_OK);
|
|
24823
24935
|
return candidate;
|
|
24824
24936
|
} catch {}
|
|
24825
24937
|
}
|
|
@@ -24828,7 +24940,7 @@ function whichOnPath(tool) {
|
|
|
24828
24940
|
}
|
|
24829
24941
|
var hostingCliAvailable = (provider) => whichOnPath(provider === "gitlab" ? "glab" : "gh") !== null;
|
|
24830
24942
|
var pushRemote = (cwd) => {
|
|
24831
|
-
const result =
|
|
24943
|
+
const result = spawnSync20("git", ["remote", "get-url", "--push", "--all", "origin"], {
|
|
24832
24944
|
cwd,
|
|
24833
24945
|
...LOCAL
|
|
24834
24946
|
});
|
|
@@ -24859,7 +24971,7 @@ var defaultCli = (bin, available) => {
|
|
|
24859
24971
|
if (!available)
|
|
24860
24972
|
return null;
|
|
24861
24973
|
return (args, root) => {
|
|
24862
|
-
const out =
|
|
24974
|
+
const out = spawnSync21(bin, args, {
|
|
24863
24975
|
cwd: root,
|
|
24864
24976
|
encoding: "utf8",
|
|
24865
24977
|
env: { ...process.env, PATH: process.env.PATH ?? "" }
|
|
@@ -24948,76 +25060,6 @@ var PLUGIN_ROOT = packageRoot();
|
|
|
24948
25060
|
var ASSET_ROOT = assetRoot();
|
|
24949
25061
|
var resolveWorkspaceRoot = (explicit) => explicit || process.cwd();
|
|
24950
25062
|
|
|
24951
|
-
// packages/workit-core/src/core/youtrack-ytrack.ts
|
|
24952
|
-
import { spawnSync as spawnSync21 } from "node:child_process";
|
|
24953
|
-
|
|
24954
|
-
// packages/workit-core/src/forge/exec.ts
|
|
24955
|
-
import fs21 from "node:fs";
|
|
24956
|
-
import path33 from "node:path";
|
|
24957
|
-
|
|
24958
|
-
// packages/workit-core/src/forge/redact.ts
|
|
24959
|
-
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_.-]*`;
|
|
24960
|
-
var ASSIGNMENT2 = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*["']?)((?:bearer|basic|token|digest)\s+)?([^\s"',;&]+)`, "giu");
|
|
24961
|
-
var QUOTED_ASSIGNMENT = new RegExp(String.raw`(?<![A-Za-z0-9])(["']?${KEY}["']?\s*[:=]\s*)(["'])([^"'\n]*[^\s"'][^"'\n]*)\2`, "giu");
|
|
24962
|
-
var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\u0007`, "gu");
|
|
24963
|
-
|
|
24964
|
-
// packages/workit-core/src/forge/exec.ts
|
|
24965
|
-
var MAX_BUFFER2 = 64 * 1024 * 1024;
|
|
24966
|
-
function findExecutable(bin, env) {
|
|
24967
|
-
const dirs = (env.PATH ?? env.Path ?? "").split(path33.delimiter).filter(Boolean);
|
|
24968
|
-
const exts = process.platform === "win32" ? [".exe"] : [""];
|
|
24969
|
-
for (const dir of dirs)
|
|
24970
|
-
for (const ext of exts) {
|
|
24971
|
-
const candidate = path33.join(dir, `${bin}${ext}`);
|
|
24972
|
-
try {
|
|
24973
|
-
const stat = fs21.statSync(candidate);
|
|
24974
|
-
if (stat.isFile())
|
|
24975
|
-
return candidate;
|
|
24976
|
-
} catch {}
|
|
24977
|
-
}
|
|
24978
|
-
return null;
|
|
24979
|
-
}
|
|
24980
|
-
|
|
24981
|
-
// packages/workit-core/src/core/youtrack-ytrack.ts
|
|
24982
|
-
var TIMEOUT_MS = 60000;
|
|
24983
|
-
var YTRACK_EXIT = { ok: 0, failed: 1, cancelled: 2, auth: 4 };
|
|
24984
|
-
var findYtrack = (env) => env.WORKIT_NO_YTRACK === "1" ? null : findExecutable("ytrack", env);
|
|
24985
|
-
var YTRACK_QUIET_ENV = {
|
|
24986
|
-
YTRACK_NO_UPDATE_NOTIFIER: "1",
|
|
24987
|
-
YTRACK_NO_AUTO_UPGRADE: "1"
|
|
24988
|
-
};
|
|
24989
|
-
function ytrackRunner(env, host, timeoutMs = TIMEOUT_MS) {
|
|
24990
|
-
return (args, input) => {
|
|
24991
|
-
const exe = findYtrack(env);
|
|
24992
|
-
if (!exe)
|
|
24993
|
-
return { status: null, stdout: "", stderr: "", missing: true };
|
|
24994
|
-
const result = spawnSync21(exe, args, {
|
|
24995
|
-
encoding: "utf8",
|
|
24996
|
-
env: {
|
|
24997
|
-
...env,
|
|
24998
|
-
NO_COLOR: "1",
|
|
24999
|
-
...YTRACK_QUIET_ENV,
|
|
25000
|
-
...host ? { YTRACK_HOST: host } : {}
|
|
25001
|
-
},
|
|
25002
|
-
timeout: timeoutMs,
|
|
25003
|
-
killSignal: "SIGKILL",
|
|
25004
|
-
windowsHide: true,
|
|
25005
|
-
...input === undefined ? { stdio: ["ignore", "pipe", "pipe"] } : { input, stdio: ["pipe", "pipe", "pipe"] }
|
|
25006
|
-
});
|
|
25007
|
-
const error = result.error;
|
|
25008
|
-
if (error?.code === "ENOENT")
|
|
25009
|
-
return { status: null, stdout: "", stderr: "", missing: true };
|
|
25010
|
-
return {
|
|
25011
|
-
status: result.status,
|
|
25012
|
-
stdout: result.stdout ?? "",
|
|
25013
|
-
stderr: result.stderr || (error ? error.message : "")
|
|
25014
|
-
};
|
|
25015
|
-
};
|
|
25016
|
-
}
|
|
25017
|
-
var ytrackDetail = (out) => out.stderr.trim().split(`
|
|
25018
|
-
`).slice(-3).join(" ").slice(0, 300);
|
|
25019
|
-
var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only through ytrack";
|
|
25020
|
-
|
|
25021
25063
|
// packages/workit-core/src/core/youtrack.ts
|
|
25022
25064
|
var ISSUE_RE = /^[A-Z][A-Z0-9_]*-\d+$/;
|
|
25023
25065
|
var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path34.join(resolveConfigDir(), "youtrack.json");
|
|
@@ -31987,6 +32029,29 @@ var judge = (args, words) => {
|
|
|
31987
32029
|
return mapIssueWrite("attach", args);
|
|
31988
32030
|
return /^(?:edit|update|delete|rm)$/.test(verb) ? UNCOVERED : null;
|
|
31989
32031
|
};
|
|
32032
|
+
var hostsOf = (args) => {
|
|
32033
|
+
const end = args.indexOf("--");
|
|
32034
|
+
const hosts = [];
|
|
32035
|
+
const bare = [];
|
|
32036
|
+
let literal = true;
|
|
32037
|
+
let named = false;
|
|
32038
|
+
for (let at = 0;at < args.length; at++) {
|
|
32039
|
+
const arg = args[at];
|
|
32040
|
+
if (end >= 0 && at >= end || !/^--host(?:=|$)/.test(arg)) {
|
|
32041
|
+
bare.push(arg);
|
|
32042
|
+
continue;
|
|
32043
|
+
}
|
|
32044
|
+
named ||= standsAlone(args, at);
|
|
32045
|
+
const value = arg === "--host" ? args[++at] : arg.slice("--host=".length);
|
|
32046
|
+
if (value === undefined || !value.trim() || EXPANDS.test(value))
|
|
32047
|
+
literal = false;
|
|
32048
|
+
else
|
|
32049
|
+
hosts.push(value);
|
|
32050
|
+
}
|
|
32051
|
+
if (!literal)
|
|
32052
|
+
return { hosts: null, bare };
|
|
32053
|
+
return named ? { hosts, bare } : { hosts: [], bare: [...args] };
|
|
32054
|
+
};
|
|
31990
32055
|
var SHELLS3 = /^(?:sh|bash|zsh|dash|ksh|ash|mksh|yash|fish)$/;
|
|
31991
32056
|
var MAX_DEPTH2 = 4;
|
|
31992
32057
|
var READ = new Map;
|
|
@@ -31994,10 +32059,19 @@ var NOT_PLAIN = gap("a ytrack call that is not a plain command of its own (a wra
|
|
|
31994
32059
|
var timeOnly = (effect) => effect?.minutes !== undefined && Object.keys(effect).every((key) => /^(?:issue|minutes|text|date)$/u.test(key));
|
|
31995
32060
|
var ungrant = (write) => write.workit ? {
|
|
31996
32061
|
command: write.command,
|
|
32062
|
+
hosts: write.hosts,
|
|
32063
|
+
bare: write.bare,
|
|
32064
|
+
plain: write.plain,
|
|
31997
32065
|
...NOT_PLAIN,
|
|
31998
32066
|
...timeOnly(write.effect) ? { hint: write.workit } : {}
|
|
31999
32067
|
} : write;
|
|
32000
|
-
var hinted = (write) => write.hint ? {
|
|
32068
|
+
var hinted = (write) => write.hint ? {
|
|
32069
|
+
command: write.command,
|
|
32070
|
+
hosts: write.hosts,
|
|
32071
|
+
bare: write.bare,
|
|
32072
|
+
plain: false,
|
|
32073
|
+
workit: write.hint
|
|
32074
|
+
} : write;
|
|
32001
32075
|
var ytrackArgs = (line, found, depth, names, plain) => {
|
|
32002
32076
|
const inner = (script) => void found.push(...ytrackWrites(script, "posix", depth + 1, plain));
|
|
32003
32077
|
const tail = workitCheckTail(line);
|
|
@@ -32032,7 +32106,12 @@ var ytrackArgs = (line, found, depth, names, plain) => {
|
|
|
32032
32106
|
const argv = [...alias ?? [], ...line.slice(at + 1)];
|
|
32033
32107
|
const write = classify2(argv);
|
|
32034
32108
|
if (write) {
|
|
32035
|
-
const one = {
|
|
32109
|
+
const one = {
|
|
32110
|
+
command: ["ytrack", ...argv].map(quote3).join(" "),
|
|
32111
|
+
...write,
|
|
32112
|
+
...hostsOf(argv),
|
|
32113
|
+
plain
|
|
32114
|
+
};
|
|
32036
32115
|
found.push(plain ? one : ungrant(one));
|
|
32037
32116
|
}
|
|
32038
32117
|
return true;
|
|
@@ -32109,7 +32188,15 @@ var chained = (first, chain, depth) => {
|
|
|
32109
32188
|
const effect = combine(effects);
|
|
32110
32189
|
if (!effect)
|
|
32111
32190
|
return null;
|
|
32112
|
-
|
|
32191
|
+
const hosts = found.map((write) => write.hosts);
|
|
32192
|
+
return [
|
|
32193
|
+
{
|
|
32194
|
+
command: found.map((write) => write.command).join(" && "),
|
|
32195
|
+
...mapped(effect),
|
|
32196
|
+
hosts: hosts.includes(null) ? null : hosts.some((list) => !list?.length) ? [] : hosts.flatMap((list) => list ?? []),
|
|
32197
|
+
plain: true
|
|
32198
|
+
}
|
|
32199
|
+
];
|
|
32113
32200
|
};
|
|
32114
32201
|
var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
|
|
32115
32202
|
if (!namesYtrack(command))
|
|
@@ -32138,6 +32225,32 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
|
|
|
32138
32225
|
READ.delete(READ.keys().next().value);
|
|
32139
32226
|
return found;
|
|
32140
32227
|
};
|
|
32228
|
+
var RELOCATES = /(?<![$\w])YTRACK_CONFIG_DIR\b/;
|
|
32229
|
+
var reachesOnly = (allowed, write) => write.plain && !!write.hosts?.length && write.hosts.every((host) => youTrackHostAllowed(allowed, host));
|
|
32230
|
+
var scopedGate = (allowed, command, writes) => {
|
|
32231
|
+
const scope = `youtrack.autoHosts (${allowed.join(", ")})`;
|
|
32232
|
+
if (RELOCATES.test(command))
|
|
32233
|
+
return {
|
|
32234
|
+
kind: "deny",
|
|
32235
|
+
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.`,
|
|
32236
|
+
unblock: null
|
|
32237
|
+
};
|
|
32238
|
+
const first = allowed.map(youTrackHostKey).find(Boolean);
|
|
32239
|
+
if (!first)
|
|
32240
|
+
return null;
|
|
32241
|
+
const unnamed = writes.filter((write) => !reachesOnly(allowed, write) && (!write.hosts?.length || write.hosts.every((host) => youTrackHostAllowed(allowed, host))));
|
|
32242
|
+
if (!unnamed.length)
|
|
32243
|
+
return null;
|
|
32244
|
+
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";
|
|
32245
|
+
const bare = unnamed.find((write) => write.bare)?.bare;
|
|
32246
|
+
const retry = bare ? ["ytrack", "--host", first, ...bare].map(quote3).join(" ") : null;
|
|
32247
|
+
return {
|
|
32248
|
+
kind: "deny",
|
|
32249
|
+
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 ? `
|
|
32250
|
+
Retry as: ${retry}` : ""}`,
|
|
32251
|
+
unblock: retry
|
|
32252
|
+
};
|
|
32253
|
+
};
|
|
32141
32254
|
var ytrackGate = (cwd, command, dialect, ask) => {
|
|
32142
32255
|
if (namesTicket(command))
|
|
32143
32256
|
return { kind: "deny", reason: TICKET_DENY, unblock: null };
|
|
@@ -32150,7 +32263,8 @@ var ytrackGate = (cwd, command, dialect, ask) => {
|
|
|
32150
32263
|
}
|
|
32151
32264
|
writes = [...merged.values()];
|
|
32152
32265
|
} catch {
|
|
32153
|
-
|
|
32266
|
+
const policy = youTrackWritesPolicy(cwd);
|
|
32267
|
+
if (policy.mode === "auto" && policy.hosts === null)
|
|
32154
32268
|
return null;
|
|
32155
32269
|
return {
|
|
32156
32270
|
kind: "deny",
|
|
@@ -32158,7 +32272,19 @@ var ytrackGate = (cwd, command, dialect, ask) => {
|
|
|
32158
32272
|
unblock: null
|
|
32159
32273
|
};
|
|
32160
32274
|
}
|
|
32161
|
-
if (!writes.length
|
|
32275
|
+
if (!writes.length && !RELOCATES.test(command))
|
|
32276
|
+
return null;
|
|
32277
|
+
const policy = youTrackWritesPolicy(cwd);
|
|
32278
|
+
if (policy.mode === "auto") {
|
|
32279
|
+
const hosts = policy.hosts;
|
|
32280
|
+
if (hosts === null)
|
|
32281
|
+
return null;
|
|
32282
|
+
const scoped = scopedGate(hosts, command, writes);
|
|
32283
|
+
if (scoped)
|
|
32284
|
+
return scoped;
|
|
32285
|
+
writes = writes.filter((write) => !reachesOnly(hosts, write));
|
|
32286
|
+
}
|
|
32287
|
+
if (!writes.length)
|
|
32162
32288
|
return null;
|
|
32163
32289
|
const calls = writes.flatMap((write) => write.workit ? [`\`${write.workit}\``] : []);
|
|
32164
32290
|
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"})`);
|