@workit-dev/pi 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker.js +4 -0
- package/dist/workit.js +430 -294
- package/package.json +1 -1
package/dist/workit.js
CHANGED
|
@@ -5,7 +5,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
|
5
5
|
// packages/workit-core/src/core.ts
|
|
6
6
|
import { spawnSync as spawnSync22 } from "node:child_process";
|
|
7
7
|
import { existsSync as existsSync12, realpathSync as realpathSync8 } from "node:fs";
|
|
8
|
-
import
|
|
8
|
+
import path35 from "node:path";
|
|
9
9
|
|
|
10
10
|
// packages/workit-core/src/core/task-contract.ts
|
|
11
11
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -18338,17 +18338,17 @@ var exportDigest = (bundle) => sha256({
|
|
|
18338
18338
|
// packages/workit-core/src/core/route-intent.ts
|
|
18339
18339
|
import { spawnSync as spawnSync17 } from "node:child_process";
|
|
18340
18340
|
import { existsSync as existsSync10 } from "node:fs";
|
|
18341
|
-
import
|
|
18341
|
+
import path30 from "node:path";
|
|
18342
18342
|
|
|
18343
18343
|
// packages/workit-core/src/hooks/raw-git.ts
|
|
18344
18344
|
import { spawnSync as spawnSync16 } from "node:child_process";
|
|
18345
|
-
import { createHash as
|
|
18345
|
+
import { createHash as createHash16 } from "node:crypto";
|
|
18346
18346
|
import fs19 from "node:fs";
|
|
18347
18347
|
import os6 from "node:os";
|
|
18348
|
-
import
|
|
18348
|
+
import path29 from "node:path";
|
|
18349
18349
|
|
|
18350
18350
|
// packages/workit-core/src/autonomy.ts
|
|
18351
|
-
import
|
|
18351
|
+
import path27 from "node:path";
|
|
18352
18352
|
|
|
18353
18353
|
// packages/workit-core/src/core/eval-world.ts
|
|
18354
18354
|
import { existsSync as existsSync9, realpathSync as realpathSync5 } from "node:fs";
|
|
@@ -18380,6 +18380,68 @@ var evalWorldEntry = (cwd) => {
|
|
|
18380
18380
|
}
|
|
18381
18381
|
};
|
|
18382
18382
|
|
|
18383
|
+
// packages/workit-core/src/core/grant-seal.ts
|
|
18384
|
+
import { createHash as createHash14 } from "node:crypto";
|
|
18385
|
+
import { readFileSync as readFileSync10 } from "node:fs";
|
|
18386
|
+
import path25 from "node:path";
|
|
18387
|
+
var SEAL_FILE = "workspaces.json.seal";
|
|
18388
|
+
var SEAL_VERSION = 1;
|
|
18389
|
+
var SEAL_COMMAND = "workit workspace seal";
|
|
18390
|
+
var pick2 = (value, keys) => {
|
|
18391
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
18392
|
+
return;
|
|
18393
|
+
const out = Object.fromEntries(keys.flatMap((key) => {
|
|
18394
|
+
const item = value[key];
|
|
18395
|
+
return item === undefined ? [] : [[key, item]];
|
|
18396
|
+
}));
|
|
18397
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
18398
|
+
};
|
|
18399
|
+
var ENTRY_KEYS = [
|
|
18400
|
+
"name",
|
|
18401
|
+
"glob",
|
|
18402
|
+
"remotes",
|
|
18403
|
+
"vcs",
|
|
18404
|
+
"autonomy",
|
|
18405
|
+
"autoApprove",
|
|
18406
|
+
"defaultEndpoint",
|
|
18407
|
+
"verification",
|
|
18408
|
+
"youtrack"
|
|
18409
|
+
];
|
|
18410
|
+
var sealProjection = (entries) => entries.map((entry) => {
|
|
18411
|
+
const all = pick2(entry, ENTRY_KEYS) ?? {};
|
|
18412
|
+
return pick2({
|
|
18413
|
+
...all,
|
|
18414
|
+
vcs: pick2(all.vcs, ["provider", "account"]),
|
|
18415
|
+
youtrack: pick2(all.youtrack, ["writes"])
|
|
18416
|
+
}, ENTRY_KEYS);
|
|
18417
|
+
});
|
|
18418
|
+
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);
|
|
18419
|
+
var sealDigest = (projection) => createHash14("sha256").update(canonical3(projection)).digest("hex");
|
|
18420
|
+
var broken = (reason, sealed = null) => ({
|
|
18421
|
+
state: "broken",
|
|
18422
|
+
reason,
|
|
18423
|
+
sealed
|
|
18424
|
+
});
|
|
18425
|
+
function checkSeal(dir) {
|
|
18426
|
+
const file = path25.join(dir, SEAL_FILE);
|
|
18427
|
+
let seal;
|
|
18428
|
+
try {
|
|
18429
|
+
seal = JSON.parse(readFileSync10(file, "utf8"));
|
|
18430
|
+
} catch (error) {
|
|
18431
|
+
if (error.code === "ENOENT")
|
|
18432
|
+
return { state: "none" };
|
|
18433
|
+
return broken(`${SEAL_FILE} cannot be read`);
|
|
18434
|
+
}
|
|
18435
|
+
if (seal?.version !== SEAL_VERSION || !Array.isArray(seal.projection) || seal.sha256 !== sealDigest(seal.projection))
|
|
18436
|
+
return broken(`${SEAL_FILE} is malformed`);
|
|
18437
|
+
const sealed = validateWorkspacesDocument({ workspaces: seal.projection }, file);
|
|
18438
|
+
if (sealed.status !== "valid")
|
|
18439
|
+
return broken(`${SEAL_FILE} is malformed`);
|
|
18440
|
+
const current = readWorkspacesResult(dir);
|
|
18441
|
+
const ok = current.status === "valid" || current.status === "missing";
|
|
18442
|
+
return ok && sealDigest(sealProjection(current.entries)) === seal.sha256 ? { state: "valid" } : broken("workspaces.json changed since it was sealed", sealed.entries);
|
|
18443
|
+
}
|
|
18444
|
+
|
|
18383
18445
|
// packages/workit-core/src/core/safe-write.ts
|
|
18384
18446
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
18385
18447
|
import {
|
|
@@ -18393,11 +18455,11 @@ import {
|
|
|
18393
18455
|
unlinkSync,
|
|
18394
18456
|
writeFileSync as writeFileSync5
|
|
18395
18457
|
} from "node:fs";
|
|
18396
|
-
import
|
|
18458
|
+
import path26 from "node:path";
|
|
18397
18459
|
function writeFileAtomic(file, content, mode) {
|
|
18398
|
-
const absolute =
|
|
18399
|
-
let parent =
|
|
18400
|
-
const root =
|
|
18460
|
+
const absolute = path26.resolve(file);
|
|
18461
|
+
let parent = path26.dirname(absolute);
|
|
18462
|
+
const root = path26.parse(parent).root;
|
|
18401
18463
|
for (;; ) {
|
|
18402
18464
|
try {
|
|
18403
18465
|
if (lstatSync6(parent).isSymbolicLink())
|
|
@@ -18406,12 +18468,12 @@ function writeFileAtomic(file, content, mode) {
|
|
|
18406
18468
|
if (error.code !== "ENOENT")
|
|
18407
18469
|
throw error;
|
|
18408
18470
|
}
|
|
18409
|
-
const next =
|
|
18471
|
+
const next = path26.dirname(parent);
|
|
18410
18472
|
if (parent === root || next === parent)
|
|
18411
18473
|
break;
|
|
18412
18474
|
parent = next;
|
|
18413
18475
|
}
|
|
18414
|
-
const directory =
|
|
18476
|
+
const directory = path26.dirname(absolute);
|
|
18415
18477
|
mkdirSync5(directory, { recursive: true });
|
|
18416
18478
|
let existing = null;
|
|
18417
18479
|
try {
|
|
@@ -18456,13 +18518,27 @@ var accountDir = () => {
|
|
|
18456
18518
|
var grantsDir = () => accountDir() ?? resolveConfigDir();
|
|
18457
18519
|
var NO_ACCOUNT = "no OS account record answered (core/account-home.ts), so no grants are read: the D4 defaults apply";
|
|
18458
18520
|
var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
|
|
18459
|
-
var
|
|
18521
|
+
var fileSource = (dir = accountDir()) => ({
|
|
18522
|
+
resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom(cwd, dir, name),
|
|
18523
|
+
entries: () => entriesIn(dir)
|
|
18524
|
+
});
|
|
18525
|
+
var sealedSource = (entries) => ({
|
|
18526
|
+
resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name),
|
|
18527
|
+
entries: () => entries
|
|
18528
|
+
});
|
|
18529
|
+
var sealOf = () => {
|
|
18460
18530
|
const dir = accountDir();
|
|
18461
|
-
return dir === null ?
|
|
18531
|
+
return dir === null ? { state: "none" } : checkSeal(dir);
|
|
18532
|
+
};
|
|
18533
|
+
var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own terminal: ${SEAL_COMMAND}`;
|
|
18534
|
+
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;
|
|
18535
|
+
var youTrackWritesMode = (cwd) => {
|
|
18536
|
+
const youtrack = resolveRuntimeWorkspaceVcs(cwd)?.youtrack;
|
|
18537
|
+
return youtrack && typeof youtrack === "object" && youtrack.writes === "auto" && !sealNote() ? "auto" : "ask";
|
|
18462
18538
|
};
|
|
18463
18539
|
var shownGrantsDir = () => {
|
|
18464
18540
|
const world = evalWorld(process.cwd());
|
|
18465
|
-
return world ?
|
|
18541
|
+
return world ? path27.join(world, "config") : accountDir();
|
|
18466
18542
|
};
|
|
18467
18543
|
var benchWorld = (cwd) => {
|
|
18468
18544
|
const entry = evalWorldEntry(cwd);
|
|
@@ -18486,8 +18562,8 @@ var grantsOverride = () => {
|
|
|
18486
18562
|
const shown = shownGrantsDir();
|
|
18487
18563
|
if (shown === null)
|
|
18488
18564
|
return NO_ACCOUNT;
|
|
18489
|
-
const configured =
|
|
18490
|
-
return configured ===
|
|
18565
|
+
const configured = path27.resolve(resolveConfigDir());
|
|
18566
|
+
return configured === path27.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 ${path27.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
|
|
18491
18567
|
};
|
|
18492
18568
|
var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
|
|
18493
18569
|
var DEFAULT_GRANTS = Object.freeze({
|
|
@@ -18607,13 +18683,13 @@ function autonomyOf(workspace) {
|
|
|
18607
18683
|
verification: verificationOf(workspace)
|
|
18608
18684
|
};
|
|
18609
18685
|
}
|
|
18610
|
-
function capAt(named, where, by, why, main = false) {
|
|
18686
|
+
function capAt(source, named, where, by, why, main = false) {
|
|
18611
18687
|
let folder = null;
|
|
18612
18688
|
let none = "";
|
|
18613
18689
|
try {
|
|
18614
18690
|
if (where instanceof Error)
|
|
18615
18691
|
throw where;
|
|
18616
|
-
folder = autonomyOf(typeof where === "string" ?
|
|
18692
|
+
folder = autonomyOf(typeof where === "string" ? source.resolve(where) : where.entry);
|
|
18617
18693
|
} catch (error) {
|
|
18618
18694
|
none = error.message;
|
|
18619
18695
|
}
|
|
@@ -18656,43 +18732,105 @@ function resolveAutonomy(cwd, target) {
|
|
|
18656
18732
|
const override = world ? null : grantsOverride();
|
|
18657
18733
|
if (override)
|
|
18658
18734
|
return { ...autonomyOf(null), note: override };
|
|
18735
|
+
let resolved;
|
|
18736
|
+
const once = typeof target === "function" ? () => resolved ??= target() : target;
|
|
18737
|
+
const current = resolveWith(fileSource(), cwd, world, once);
|
|
18738
|
+
const seal = sealOf();
|
|
18739
|
+
if (seal.state !== "broken")
|
|
18740
|
+
return current;
|
|
18741
|
+
let sealed = autonomyOf(null);
|
|
18742
|
+
try {
|
|
18743
|
+
if (seal.sealed)
|
|
18744
|
+
sealed = resolveWith(sealedSource(seal.sealed), cwd, world, once);
|
|
18745
|
+
} catch {
|
|
18746
|
+
sealed = null;
|
|
18747
|
+
}
|
|
18748
|
+
return stricter(current, sealed, sealNote(seal));
|
|
18749
|
+
}
|
|
18750
|
+
function resolveWith(source, cwd, world, target) {
|
|
18659
18751
|
const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
18660
|
-
const real =
|
|
18752
|
+
const real = source.resolve(cwd, name);
|
|
18661
18753
|
let autonomy = autonomyOf(real ?? world);
|
|
18662
18754
|
if (!real && world)
|
|
18663
18755
|
autonomy.world = evalWorld(cwd) ?? undefined;
|
|
18664
18756
|
if (name)
|
|
18665
|
-
autonomy = capAt(autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
|
|
18757
|
+
autonomy = capAt(source, autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
|
|
18666
18758
|
const above = checkoutsAbove(cwd);
|
|
18667
18759
|
for (const where of above instanceof Error ? [above] : above)
|
|
18668
|
-
autonomy = capAt(autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
|
|
18669
|
-
return capAtRemotes(autonomy, cwd, target);
|
|
18760
|
+
autonomy = capAt(source, autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
|
|
18761
|
+
return capAtRemotes(source, autonomy, cwd, target);
|
|
18670
18762
|
}
|
|
18671
|
-
|
|
18672
|
-
|
|
18763
|
+
var needsAccount = (autonomy) => autonomy.configured.length > 0 && !autonomy.accountConfigured;
|
|
18764
|
+
function stricter(current, sealed, note) {
|
|
18765
|
+
const grants = { ...current.grants };
|
|
18766
|
+
const unblocks = { ...current.unblocks };
|
|
18767
|
+
for (const kind of GRANT_KINDS) {
|
|
18768
|
+
const floor = sealed ? sealed.grants[kind] : false;
|
|
18769
|
+
if (!raises(kind, floor, grants[kind]))
|
|
18770
|
+
continue;
|
|
18771
|
+
grants[kind] = floor;
|
|
18772
|
+
unblocks[kind] = SEAL_UNBLOCK;
|
|
18773
|
+
}
|
|
18774
|
+
const configured = GRANT_KINDS.filter((kind) => current.configured.includes(kind) || sealed?.configured.includes(kind));
|
|
18775
|
+
const accountConfigured = !needsAccount(current) && !(sealed && needsAccount(sealed)) && (current.accountConfigured || Boolean(sealed?.accountConfigured));
|
|
18776
|
+
const lower = (a, b) => raisesEndpoint(a, b) ? a : b;
|
|
18777
|
+
const defaultEndpoint = lower(current.defaultEndpoint, sealed?.defaultEndpoint ?? DEFAULT_ENDPOINT);
|
|
18778
|
+
const effective = effectiveEndpoint(defaultEndpoint, {
|
|
18779
|
+
workspace: current.workspace,
|
|
18780
|
+
grants,
|
|
18781
|
+
configured,
|
|
18782
|
+
accountConfigured
|
|
18783
|
+
});
|
|
18784
|
+
const endpoint = lower(lower(effective.endpoint, current.effectiveEndpoint), sealed?.effectiveEndpoint ?? DEFAULT_ENDPOINT);
|
|
18785
|
+
const strict = sealed?.verification ?? "independent";
|
|
18786
|
+
const looser = VERIFICATION_STRICTNESS.indexOf(current.verification) > VERIFICATION_STRICTNESS.indexOf(strict);
|
|
18787
|
+
return {
|
|
18788
|
+
...current,
|
|
18789
|
+
grants,
|
|
18790
|
+
configured,
|
|
18791
|
+
accountConfigured,
|
|
18792
|
+
defaultEndpoint,
|
|
18793
|
+
effectiveEndpoint: endpoint,
|
|
18794
|
+
endpointReason: endpoint === current.effectiveEndpoint ? current.endpointReason : SEAL_UNBLOCK,
|
|
18795
|
+
verification: looser ? strict : current.verification,
|
|
18796
|
+
unblocks,
|
|
18797
|
+
note: current.note ? `${current.note}; ${note}` : note
|
|
18798
|
+
};
|
|
18799
|
+
}
|
|
18800
|
+
function capAtRemotes(source, autonomy, cwd, target) {
|
|
18801
|
+
const claiming = source.entries().filter((entry) => entry.remotes?.length);
|
|
18673
18802
|
if (claiming.length === 0)
|
|
18674
18803
|
return autonomy;
|
|
18675
18804
|
const remotes = target === undefined ? checkoutRemotes(cwd) : typeof target === "function" ? target() : target;
|
|
18676
18805
|
if (remotes instanceof Error)
|
|
18677
|
-
return capAt(autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
|
|
18806
|
+
return capAt(source, autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
|
|
18678
18807
|
let capped = autonomy;
|
|
18679
18808
|
for (const remote of Array.isArray(remotes) ? remotes : remotes.remotes)
|
|
18680
18809
|
for (const entry of claiming) {
|
|
18681
18810
|
const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
|
|
18682
18811
|
if (pattern)
|
|
18683
|
-
capped = capAt(capped, { entry }, `remote ${remote.name} ${remote.url} (workspace ${entry.name} claims ${pattern})`, "a checkout never exceeds the workspace that owns its remote");
|
|
18812
|
+
capped = capAt(source, capped, { entry }, `remote ${remote.name} ${remote.url} (workspace ${entry.name} claims ${pattern})`, "a checkout never exceeds the workspace that owns its remote");
|
|
18684
18813
|
}
|
|
18685
18814
|
return capped;
|
|
18686
18815
|
}
|
|
18687
|
-
var grantsMatter = (kind) =>
|
|
18688
|
-
|
|
18689
|
-
|
|
18690
|
-
|
|
18691
|
-
|
|
18692
|
-
|
|
18816
|
+
var grantsMatter = (kind) => {
|
|
18817
|
+
if (grantsOverride())
|
|
18818
|
+
return false;
|
|
18819
|
+
const matters = entriesIn(accountDir()).some((entry) => {
|
|
18820
|
+
const autonomy = autonomyOf(entry);
|
|
18821
|
+
return entry.remotes?.length || autonomy.grants[kind] === false || needsAccount(autonomy);
|
|
18822
|
+
});
|
|
18823
|
+
const seal = sealOf();
|
|
18824
|
+
return matters || seal.state === "broken" && (seal.sealed ? seal.sealed.length > 0 : DEFAULT_GRANTS[kind] === false);
|
|
18825
|
+
};
|
|
18826
|
+
var authorityEntries = () => {
|
|
18827
|
+
const seal = sealOf();
|
|
18828
|
+
return [...entriesIn(accountDir()), ...seal.state === "broken" ? seal.sealed ?? [] : []];
|
|
18829
|
+
};
|
|
18830
|
+
function claimsIn(target, entries) {
|
|
18693
18831
|
if (target instanceof Error)
|
|
18694
18832
|
return target;
|
|
18695
|
-
const claiming =
|
|
18833
|
+
const claiming = entries.filter((entry) => entry.remotes?.length);
|
|
18696
18834
|
return target.remotes.flatMap((remote) => claiming.flatMap((entry) => {
|
|
18697
18835
|
const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
|
|
18698
18836
|
return pattern ? [{ url: remote.url, workspace: entry.name, pattern }] : [];
|
|
@@ -18702,7 +18840,8 @@ var suggested = (kind) => kind === "merge" ? "verified" : "true";
|
|
|
18702
18840
|
var accountHint = (workspace) => `set vcs.account for workspace "${workspace ?? "?"}" in ${configFilePath("workspaces.json")}`;
|
|
18703
18841
|
var grantHint = (workspace, kind) => `ask the user to run, in their own terminal: workit grant set ${workspace ?? "<workspace>"} ${kind}=${suggested(kind)}`;
|
|
18704
18842
|
function rawGrantDenial(cwd, kind, target) {
|
|
18705
|
-
const
|
|
18843
|
+
const entries = authorityEntries();
|
|
18844
|
+
const claimed = entries.some((entry) => entry.remotes?.length);
|
|
18706
18845
|
if (!grantsMatter(kind))
|
|
18707
18846
|
return null;
|
|
18708
18847
|
let resolved;
|
|
@@ -18727,14 +18866,10 @@ function rawGrantDenial(cwd, kind, target) {
|
|
|
18727
18866
|
};
|
|
18728
18867
|
if (!claimed || !lazy)
|
|
18729
18868
|
return null;
|
|
18730
|
-
const claims =
|
|
18869
|
+
const claims = claimsIn(lazy(), entries);
|
|
18731
18870
|
if (claims instanceof Error)
|
|
18732
18871
|
return { error: `${kind}: ${claims.message}`, unblock: "name a target workit can resolve" };
|
|
18733
|
-
const
|
|
18734
|
-
const strict = claims.find(({ workspace: name }) => {
|
|
18735
|
-
const entry = entries.find((item) => item.name === name);
|
|
18736
|
-
return entry && autonomyOf(entry).grants[kind] === false;
|
|
18737
|
-
});
|
|
18872
|
+
const strict = claims.find(({ workspace: name }) => entries.some((item) => item.name === name && autonomyOf(item).grants[kind] === false));
|
|
18738
18873
|
return strict ? {
|
|
18739
18874
|
error: `${kind} is not granted for workspace ${strict.workspace}, which claims ${strict.url} (${strict.pattern})`,
|
|
18740
18875
|
unblock: grantHint(strict.workspace, kind)
|
|
@@ -18746,9 +18881,9 @@ var raises = (kind, current, next) => {
|
|
|
18746
18881
|
};
|
|
18747
18882
|
|
|
18748
18883
|
// packages/workit-core/src/hooks/session-marker.ts
|
|
18749
|
-
import { createHash as
|
|
18884
|
+
import { createHash as createHash15 } from "node:crypto";
|
|
18750
18885
|
import fs18 from "node:fs";
|
|
18751
|
-
import
|
|
18886
|
+
import path28 from "node:path";
|
|
18752
18887
|
var sessionMarkerFile = (input, session, store) => {
|
|
18753
18888
|
let dir = store;
|
|
18754
18889
|
if (dir === undefined) {
|
|
@@ -18757,8 +18892,8 @@ var sessionMarkerFile = (input, session, store) => {
|
|
|
18757
18892
|
return null;
|
|
18758
18893
|
dir = location.dir;
|
|
18759
18894
|
}
|
|
18760
|
-
const name =
|
|
18761
|
-
return
|
|
18895
|
+
const name = createHash15("sha256").update(`${input.host}\x00${session}`).digest("hex").slice(0, 32);
|
|
18896
|
+
return path28.join(dir, "hooks", `skills-${name}.json`);
|
|
18762
18897
|
};
|
|
18763
18898
|
var list2 = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
18764
18899
|
var EMPTY = {
|
|
@@ -18793,7 +18928,7 @@ var parseMarker = (text) => {
|
|
|
18793
18928
|
};
|
|
18794
18929
|
var readSessionMarker = (file) => parseMarker(readRaw(file));
|
|
18795
18930
|
var writeAtomic = (file, marker) => {
|
|
18796
|
-
fs18.mkdirSync(
|
|
18931
|
+
fs18.mkdirSync(path28.dirname(file), { recursive: true });
|
|
18797
18932
|
const temp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
18798
18933
|
try {
|
|
18799
18934
|
fs18.writeFileSync(temp, JSON.stringify(marker));
|
|
@@ -19380,14 +19515,14 @@ var GIT_CONFIG_ENV = /^(?:GIT_(?:CONFIG\w*|DIR|COMMON_DIR|WORK_TREE|SSH|SSH_COMM
|
|
|
19380
19515
|
var ASSIGNMENT = /^([A-Za-z_]\w*)=([\s\S]*)$/;
|
|
19381
19516
|
var MAX_DEPTH = 4;
|
|
19382
19517
|
var MAX_EXPANSIONS = 16;
|
|
19383
|
-
var isAbsolute = (value) =>
|
|
19518
|
+
var isAbsolute = (value) => path29.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
|
|
19384
19519
|
var HERE = /^(?:\$PWD|\$\{PWD\}|\$\(\s*pwd\s*\)|`pwd`|\$\(\s*git\s+rev-parse\s+--show-toplevel\s*\))(?=$|[\\/])/;
|
|
19385
19520
|
var joinDir = (base, raw) => {
|
|
19386
19521
|
const next = raw.replace(HERE, ".");
|
|
19387
19522
|
if (base === undefined || /[$`*?]/.test(next) || next === "-")
|
|
19388
19523
|
return;
|
|
19389
|
-
const expanded = next === "~" || next.startsWith("~/") ?
|
|
19390
|
-
return base === null || isAbsolute(expanded) ? expanded :
|
|
19524
|
+
const expanded = next === "~" || next.startsWith("~/") ? path29.join(os6.homedir(), next.slice(1)) : next;
|
|
19525
|
+
return base === null || isAbsolute(expanded) ? expanded : path29.join(base, expanded);
|
|
19391
19526
|
};
|
|
19392
19527
|
var rebase = (base, inner) => inner === null ? base : inner === undefined ? undefined : joinDir(base, inner);
|
|
19393
19528
|
var cdTarget = (words) => {
|
|
@@ -20309,17 +20444,17 @@ var headSha2 = (repo) => {
|
|
|
20309
20444
|
if (!git || git.reftable)
|
|
20310
20445
|
return null;
|
|
20311
20446
|
try {
|
|
20312
|
-
const head = fs19.readFileSync(
|
|
20447
|
+
const head = fs19.readFileSync(path29.join(git.gitDir, "HEAD"), "utf8").trim();
|
|
20313
20448
|
if (/^[0-9a-f]{40,64}$/.test(head))
|
|
20314
20449
|
return head;
|
|
20315
20450
|
const ref = /^ref: (refs\/.+)$/.exec(head)?.[1];
|
|
20316
20451
|
if (!ref)
|
|
20317
20452
|
return null;
|
|
20318
|
-
const common =
|
|
20453
|
+
const common = path29.dirname(repo.location.dir);
|
|
20319
20454
|
try {
|
|
20320
|
-
return fs19.readFileSync(
|
|
20455
|
+
return fs19.readFileSync(path29.join(common, ref), "utf8").trim() || null;
|
|
20321
20456
|
} catch {}
|
|
20322
|
-
const packed = fs19.readFileSync(
|
|
20457
|
+
const packed = fs19.readFileSync(path29.join(common, "packed-refs"), "utf8");
|
|
20323
20458
|
return new RegExp(`^([0-9a-f]{40,64}) ${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`, "m").exec(packed)?.[1] ?? null;
|
|
20324
20459
|
} catch {
|
|
20325
20460
|
return null;
|
|
@@ -20412,7 +20547,7 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
|
|
|
20412
20547
|
const sub = invocation.args[0];
|
|
20413
20548
|
if (invocation.tool !== "git" || invocation.dir === undefined || !sub || sub.startsWith("-") || GIT_COMMANDS.has(sub) || depth >= MAX_DEPTH)
|
|
20414
20549
|
return [invocation];
|
|
20415
|
-
const dir =
|
|
20550
|
+
const dir = path29.resolve(root, invocation.dir ?? ".");
|
|
20416
20551
|
if (!fs19.existsSync(dir))
|
|
20417
20552
|
return [invocation];
|
|
20418
20553
|
const config = gitConfig(dir, invocation, cache);
|
|
@@ -20435,11 +20570,11 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
|
|
|
20435
20570
|
var normalizedUrl = (url, dir) => {
|
|
20436
20571
|
const trimmed = url.trim();
|
|
20437
20572
|
if (/^file:\/\//i.test(trimmed))
|
|
20438
|
-
return
|
|
20573
|
+
return path29.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
|
|
20439
20574
|
const scheme = /^[a-z][a-z0-9+.-]*:\/\//i.exec(trimmed);
|
|
20440
20575
|
const scp = !scheme && /^(?:[^@/\\]+@)?[^/\\:]{2,}:/.test(trimmed);
|
|
20441
20576
|
if (!scheme && !scp)
|
|
20442
|
-
return
|
|
20577
|
+
return path29.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
|
|
20443
20578
|
const value = scheme ? trimmed.slice(scheme[0].length).replace(/^[^@/]*@/, "").replace(/^([^/:]+):\d+(?=\/)/, "$1") : trimmed.replace(/^[^@/]*@/, "").replace(":", "/");
|
|
20444
20579
|
return value.toLowerCase().replace(/\/{2,}/g, "/").replace(/^www\./, "").replace(/\/+$/, "").replace(/\.git$/, "");
|
|
20445
20580
|
};
|
|
@@ -20667,7 +20802,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
|
|
|
20667
20802
|
const out = [];
|
|
20668
20803
|
const repos = new Map;
|
|
20669
20804
|
const repoFor = (relative) => {
|
|
20670
|
-
const dir =
|
|
20805
|
+
const dir = path29.resolve(cwd, relative ?? ".");
|
|
20671
20806
|
if (!repos.has(dir)) {
|
|
20672
20807
|
const repo = repoAt(dir);
|
|
20673
20808
|
const workit = repo !== null && isWorkitWorkspace(repo);
|
|
@@ -20688,7 +20823,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
|
|
|
20688
20823
|
const action = rawAction(invocation);
|
|
20689
20824
|
const at = !action ? null : repoFor(invocation.dir) ?? (all && invocation.tool !== "git" && explicitRepo(invocation.tool === "gh", "repo" in action && action.repo || "", invocation.env ?? {}) ? {
|
|
20690
20825
|
repo: {
|
|
20691
|
-
dir:
|
|
20826
|
+
dir: path29.resolve(cwd, invocation.dir ?? "."),
|
|
20692
20827
|
branch: null
|
|
20693
20828
|
},
|
|
20694
20829
|
workit: false
|
|
@@ -20761,13 +20896,13 @@ var messageOf = (segment, index) => {
|
|
|
20761
20896
|
};
|
|
20762
20897
|
var sameGitDir = (a, b, platform = process.platform) => {
|
|
20763
20898
|
if (platform !== "win32")
|
|
20764
|
-
return
|
|
20765
|
-
const fold = (value) =>
|
|
20899
|
+
return path29.posix.resolve(a) === path29.posix.resolve(b);
|
|
20900
|
+
const fold = (value) => path29.win32.resolve(value).toLowerCase();
|
|
20766
20901
|
return fold(a) === fold(b);
|
|
20767
20902
|
};
|
|
20768
20903
|
var cdCommitCall = (input, command, target, repo) => {
|
|
20769
20904
|
const { top, git, dir: store } = repo.location;
|
|
20770
|
-
if (!top || !git || sameGitDir(git.gitDir,
|
|
20905
|
+
if (!top || !git || sameGitDir(git.gitDir, path29.dirname(store)) || repoAt(input.cwd)?.location.top === top)
|
|
20771
20906
|
return null;
|
|
20772
20907
|
const bare = command.replaceAll(/'[^']*'|"(?:[^"\\]|\\.)*"/gu, "").replaceAll("&&", "");
|
|
20773
20908
|
if (/[;|&<>`$()\n\\]/u.test(bare))
|
|
@@ -20776,7 +20911,7 @@ var cdCommitCall = (input, command, target, repo) => {
|
|
|
20776
20911
|
const commit = rest.at(-1);
|
|
20777
20912
|
if (cd?.words[0] !== "cd" || cd.words.length !== 2 || cd.expands?.length || !commit)
|
|
20778
20913
|
return null;
|
|
20779
|
-
if (
|
|
20914
|
+
if (path29.resolve(input.cwd, cd.words[1]) !== target)
|
|
20780
20915
|
return null;
|
|
20781
20916
|
if (rest.some((each) => each.redirects.length || each.stdin?.length || each.group))
|
|
20782
20917
|
return null;
|
|
@@ -20843,7 +20978,7 @@ var commitRefusal = (input, command, dialect, { action, repo, invocation, workit
|
|
|
20843
20978
|
} catch {}
|
|
20844
20979
|
if (guarded && !switches)
|
|
20845
20980
|
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>")}.`;
|
|
20846
|
-
const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command,
|
|
20981
|
+
const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path29.resolve(input.cwd, invocation.dir), repo);
|
|
20847
20982
|
return call && `workit: no ${quote("cd … &&")} chain; run ${quote(call)}.`;
|
|
20848
20983
|
};
|
|
20849
20984
|
function rawGitPre(input, command, options = {}) {
|
|
@@ -20941,9 +21076,9 @@ var grantRefusal = (action, repo, invocation, cache) => {
|
|
|
20941
21076
|
return null;
|
|
20942
21077
|
};
|
|
20943
21078
|
var localTag = (repo, name) => {
|
|
20944
|
-
const common =
|
|
21079
|
+
const common = path29.dirname(repo.location.dir);
|
|
20945
21080
|
try {
|
|
20946
|
-
return fs19.existsSync(
|
|
21081
|
+
return fs19.existsSync(path29.join(common, "refs/tags", name)) || fs19.readFileSync(path29.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
|
|
20947
21082
|
`);
|
|
20948
21083
|
} catch {
|
|
20949
21084
|
return false;
|
|
@@ -20963,8 +21098,8 @@ var analysisDenial = (error) => ({
|
|
|
20963
21098
|
});
|
|
20964
21099
|
var NEXT_COMMAND = "next";
|
|
20965
21100
|
var MARKER_TTL_SECONDS = 3600;
|
|
20966
|
-
var markerFile = (repo, session, key) =>
|
|
20967
|
-
var callKey = (toolUseId, command) => toolUseId ?? `cmd:${
|
|
21101
|
+
var markerFile = (repo, session, key) => path29.join(repo.location.dir, "hooks", `commit-${createHash16("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
|
|
21102
|
+
var callKey = (toolUseId, command) => toolUseId ?? `cmd:${createHash16("sha256").update(command).digest("hex")}`;
|
|
20968
21103
|
function noteRawCommit(input, command, key) {
|
|
20969
21104
|
try {
|
|
20970
21105
|
if (!input.session.id || !/\bcommit\b/.test(command))
|
|
@@ -20974,7 +21109,7 @@ function noteRawCommit(input, command, key) {
|
|
|
20974
21109
|
if (action.kind !== "commit")
|
|
20975
21110
|
continue;
|
|
20976
21111
|
const file = markerFile(repo, input.session.id, key);
|
|
20977
|
-
fs19.mkdirSync(
|
|
21112
|
+
fs19.mkdirSync(path29.dirname(file), { recursive: true });
|
|
20978
21113
|
fs19.writeFileSync(file, `${JSON.stringify({ head: headSha2(repo), at })}
|
|
20979
21114
|
`);
|
|
20980
21115
|
}
|
|
@@ -21215,7 +21350,7 @@ var judgedDir = (root, dir) => {
|
|
|
21215
21350
|
return null;
|
|
21216
21351
|
if (dir === null)
|
|
21217
21352
|
return root;
|
|
21218
|
-
const resolved =
|
|
21353
|
+
const resolved = path30.resolve(root, dir);
|
|
21219
21354
|
return existsSync10(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
|
|
21220
21355
|
};
|
|
21221
21356
|
var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
|
|
@@ -23212,8 +23347,8 @@ class WorkitCore {
|
|
|
23212
23347
|
}
|
|
23213
23348
|
// packages/workit-core/src/core/repo-context.ts
|
|
23214
23349
|
import { spawnSync as spawnSync18 } from "node:child_process";
|
|
23215
|
-
import { existsSync as existsSync11, readFileSync as
|
|
23216
|
-
import
|
|
23350
|
+
import { existsSync as existsSync11, readFileSync as readFileSync11, readdirSync as readdirSync4 } from "node:fs";
|
|
23351
|
+
import path31 from "node:path";
|
|
23217
23352
|
var isSafeContextRange = (value) => value.length <= 4096 && (() => {
|
|
23218
23353
|
try {
|
|
23219
23354
|
gitRevisionParts(value);
|
|
@@ -23357,13 +23492,13 @@ var findPrTemplate = (cwd) => {
|
|
|
23357
23492
|
for (const rel of PR_TEMPLATE_FILES) {
|
|
23358
23493
|
const parts = rel.split("/");
|
|
23359
23494
|
const base = parts[parts.length - 1];
|
|
23360
|
-
const dir = parts.length > 1 ?
|
|
23495
|
+
const dir = parts.length > 1 ? path31.join(cwd, ...parts.slice(0, -1)) : cwd;
|
|
23361
23496
|
const actual = probeCaseInsensitive(dir, base);
|
|
23362
23497
|
if (actual)
|
|
23363
23498
|
return [...parts.slice(0, -1), actual].join("/");
|
|
23364
23499
|
}
|
|
23365
23500
|
for (const rel of PR_TEMPLATE_DIRS) {
|
|
23366
|
-
const only = singleMarkdown(
|
|
23501
|
+
const only = singleMarkdown(path31.join(cwd, ...rel.split("/")));
|
|
23367
23502
|
if (only)
|
|
23368
23503
|
return `${rel}/${only}`;
|
|
23369
23504
|
}
|
|
@@ -23393,11 +23528,11 @@ var diffStatForRange = (cwd, range) => {
|
|
|
23393
23528
|
return runGit(cwd, ["diff", "--stat", "--"]).stdout;
|
|
23394
23529
|
};
|
|
23395
23530
|
var packageScripts = (cwd, keys) => {
|
|
23396
|
-
const pkgPath =
|
|
23531
|
+
const pkgPath = path31.join(cwd, "package.json");
|
|
23397
23532
|
if (!existsSync11(pkgPath))
|
|
23398
23533
|
return [];
|
|
23399
23534
|
try {
|
|
23400
|
-
const pkg = JSON.parse(
|
|
23535
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
|
|
23401
23536
|
return keys.filter((k) => pkg.scripts && typeof pkg.scripts[k] === "string").map((k) => `${k}: ${pkg.scripts?.[k]}`);
|
|
23402
23537
|
} catch {
|
|
23403
23538
|
return [];
|
|
@@ -23419,9 +23554,9 @@ var documentationFiles = (cwd) => {
|
|
|
23419
23554
|
if (entry.isDirectory()) {
|
|
23420
23555
|
if (excluded.has(entry.name))
|
|
23421
23556
|
continue;
|
|
23422
|
-
walk(
|
|
23557
|
+
walk(path31.join(dir, entry.name), depth + 1);
|
|
23423
23558
|
} else if (entry.isFile() && (entry.name === "README.md" || entry.name.endsWith(".md"))) {
|
|
23424
|
-
matches.push("./" +
|
|
23559
|
+
matches.push("./" + path31.relative(cwd, path31.join(dir, entry.name)).replaceAll("\\", "/"));
|
|
23425
23560
|
}
|
|
23426
23561
|
}
|
|
23427
23562
|
};
|
|
@@ -23431,13 +23566,13 @@ var documentationFiles = (cwd) => {
|
|
|
23431
23566
|
var readTrimmed2 = (file, maxLines) => {
|
|
23432
23567
|
if (!existsSync11(file))
|
|
23433
23568
|
return "";
|
|
23434
|
-
const lines =
|
|
23569
|
+
const lines = readFileSync11(file, "utf8").split(`
|
|
23435
23570
|
`);
|
|
23436
23571
|
return lines.slice(0, maxLines).join(`
|
|
23437
23572
|
`);
|
|
23438
23573
|
};
|
|
23439
23574
|
function prReadyContext(root, range) {
|
|
23440
|
-
const cwd =
|
|
23575
|
+
const cwd = path31.resolve(repoRoot(root));
|
|
23441
23576
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
23442
23577
|
return invalidRange(cwd);
|
|
23443
23578
|
let stdout = "";
|
|
@@ -23495,7 +23630,7 @@ ${status.stderr}` : "");
|
|
|
23495
23630
|
stdout += `template_path: ${template}
|
|
23496
23631
|
|
|
23497
23632
|
`;
|
|
23498
|
-
stdout += readTrimmed2(
|
|
23633
|
+
stdout += readTrimmed2(path31.join(cwd, template), 220);
|
|
23499
23634
|
} else {
|
|
23500
23635
|
stdout += `template_path: none
|
|
23501
23636
|
|
|
@@ -23505,7 +23640,7 @@ ${status.stderr}` : "");
|
|
|
23505
23640
|
stdout += `
|
|
23506
23641
|
`;
|
|
23507
23642
|
stdout += printSection("Recent Validation Signals");
|
|
23508
|
-
if (existsSync11(
|
|
23643
|
+
if (existsSync11(path31.join(cwd, "package.json"))) {
|
|
23509
23644
|
stdout += `package.json detected. Common scripts:
|
|
23510
23645
|
`;
|
|
23511
23646
|
const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
|
|
@@ -23514,7 +23649,7 @@ ${status.stderr}` : "");
|
|
|
23514
23649
|
`) + `
|
|
23515
23650
|
`;
|
|
23516
23651
|
}
|
|
23517
|
-
if (existsSync11(
|
|
23652
|
+
if (existsSync11(path31.join(cwd, "Cargo.toml")) || existsSync11(path31.join(cwd, "src-tauri/Cargo.toml"))) {
|
|
23518
23653
|
stdout += `Rust project detected.
|
|
23519
23654
|
`;
|
|
23520
23655
|
}
|
|
@@ -23547,7 +23682,7 @@ var CHANGELOG_RULES = `- Use an [Unreleased] section.
|
|
|
23547
23682
|
- Apply with the host-native editor, preserving the repository changelog conventions.
|
|
23548
23683
|
- If Unreleased already has duplicate category headings, normalize_only first.`;
|
|
23549
23684
|
function changelogContext(root, range) {
|
|
23550
|
-
const cwd =
|
|
23685
|
+
const cwd = path31.resolve(repoRoot(root));
|
|
23551
23686
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
23552
23687
|
return invalidRange(cwd);
|
|
23553
23688
|
const resolvedRange = rangeArgOrDefault(range, cwd);
|
|
@@ -23565,7 +23700,7 @@ function changelogContext(root, range) {
|
|
|
23565
23700
|
stdout += CHANGELOG_RULES + `
|
|
23566
23701
|
`;
|
|
23567
23702
|
stdout += printSection("Existing CHANGELOG.md");
|
|
23568
|
-
const changelogPath =
|
|
23703
|
+
const changelogPath = path31.join(cwd, "CHANGELOG.md");
|
|
23569
23704
|
if (existsSync11(changelogPath)) {
|
|
23570
23705
|
stdout += readTrimmed2(changelogPath, 260) + `
|
|
23571
23706
|
`;
|
|
@@ -23585,7 +23720,7 @@ function changelogContext(root, range) {
|
|
|
23585
23720
|
return { stdout, stderr: "", exitCode: 0, cwd };
|
|
23586
23721
|
}
|
|
23587
23722
|
function docsRefreshContext(root, range) {
|
|
23588
|
-
const cwd =
|
|
23723
|
+
const cwd = path31.resolve(repoRoot(root));
|
|
23589
23724
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
23590
23725
|
return invalidRange(cwd);
|
|
23591
23726
|
const resolvedRange = rangeArgOrDefault(range, cwd);
|
|
@@ -23607,7 +23742,7 @@ function docsRefreshContext(root, range) {
|
|
|
23607
23742
|
`) + `
|
|
23608
23743
|
`;
|
|
23609
23744
|
stdout += printSection("README Preview");
|
|
23610
|
-
const readme =
|
|
23745
|
+
const readme = path31.join(cwd, "README.md");
|
|
23611
23746
|
if (existsSync11(readme)) {
|
|
23612
23747
|
stdout += readTrimmed2(readme, 220) + `
|
|
23613
23748
|
`;
|
|
@@ -23616,10 +23751,10 @@ function docsRefreshContext(root, range) {
|
|
|
23616
23751
|
`;
|
|
23617
23752
|
}
|
|
23618
23753
|
stdout += printSection("Package Scripts");
|
|
23619
|
-
const pkgPath =
|
|
23754
|
+
const pkgPath = path31.join(cwd, "package.json");
|
|
23620
23755
|
if (existsSync11(pkgPath)) {
|
|
23621
23756
|
try {
|
|
23622
|
-
const pkg = JSON.parse(
|
|
23757
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
|
|
23623
23758
|
stdout += JSON.stringify({ name: pkg.name, version: pkg.version, scripts: pkg.scripts }, null, 2) + `
|
|
23624
23759
|
`;
|
|
23625
23760
|
} catch {}
|
|
@@ -23630,7 +23765,7 @@ function docsRefreshContext(root, range) {
|
|
|
23630
23765
|
return { stdout, stderr: "", exitCode: 0, cwd };
|
|
23631
23766
|
}
|
|
23632
23767
|
function releaseNotesContext(root, rangeOrTag) {
|
|
23633
|
-
const cwd =
|
|
23768
|
+
const cwd = path31.resolve(repoRoot(root));
|
|
23634
23769
|
if (!rangeOrTag) {
|
|
23635
23770
|
return {
|
|
23636
23771
|
stdout: "",
|
|
@@ -23673,7 +23808,7 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
23673
23808
|
`;
|
|
23674
23809
|
stdout += printSection("Existing Release Files");
|
|
23675
23810
|
for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
|
|
23676
|
-
if (existsSync11(
|
|
23811
|
+
if (existsSync11(path31.join(cwd, rel)))
|
|
23677
23812
|
stdout += rel + `
|
|
23678
23813
|
`;
|
|
23679
23814
|
}
|
|
@@ -23705,7 +23840,7 @@ import { spawnSync as spawnSync20 } from "node:child_process";
|
|
|
23705
23840
|
|
|
23706
23841
|
// packages/workit-core/src/core/pr-create.ts
|
|
23707
23842
|
import fs20 from "node:fs";
|
|
23708
|
-
import
|
|
23843
|
+
import path32 from "node:path";
|
|
23709
23844
|
import { spawnSync as spawnSync19 } from "node:child_process";
|
|
23710
23845
|
// packages/workit-core/src/forge/pr-body.ts
|
|
23711
23846
|
function parseGhIssue(value) {
|
|
@@ -23725,11 +23860,11 @@ var LOCAL = bounded(20000);
|
|
|
23725
23860
|
var NETWORK = bounded(60000);
|
|
23726
23861
|
function whichOnPath(tool) {
|
|
23727
23862
|
const names = process.platform === "win32" ? [tool, `${tool}.exe`, `${tool}.cmd`] : [tool];
|
|
23728
|
-
for (const dir of (process.env.PATH ?? "").split(
|
|
23863
|
+
for (const dir of (process.env.PATH ?? "").split(path32.delimiter)) {
|
|
23729
23864
|
if (!dir)
|
|
23730
23865
|
continue;
|
|
23731
23866
|
for (const name of names) {
|
|
23732
|
-
const candidate =
|
|
23867
|
+
const candidate = path32.join(dir, name);
|
|
23733
23868
|
try {
|
|
23734
23869
|
fs20.accessSync(candidate, fs20.constants.X_OK);
|
|
23735
23870
|
return candidate;
|
|
@@ -23850,7 +23985,7 @@ var fetchGitLabIssueBody = async (ref, root, deps = {}) => {
|
|
|
23850
23985
|
|
|
23851
23986
|
// packages/workit-core/src/core/youtrack.ts
|
|
23852
23987
|
import fs22 from "node:fs";
|
|
23853
|
-
import
|
|
23988
|
+
import path34 from "node:path";
|
|
23854
23989
|
|
|
23855
23990
|
// packages/workit-core/src/core/templates.ts
|
|
23856
23991
|
var repoRoot2 = assetRoot();
|
|
@@ -23865,7 +24000,7 @@ import { spawnSync as spawnSync21 } from "node:child_process";
|
|
|
23865
24000
|
|
|
23866
24001
|
// packages/workit-core/src/forge/exec.ts
|
|
23867
24002
|
import fs21 from "node:fs";
|
|
23868
|
-
import
|
|
24003
|
+
import path33 from "node:path";
|
|
23869
24004
|
|
|
23870
24005
|
// packages/workit-core/src/forge/redact.ts
|
|
23871
24006
|
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_.-]*`;
|
|
@@ -23876,11 +24011,11 @@ var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\
|
|
|
23876
24011
|
// packages/workit-core/src/forge/exec.ts
|
|
23877
24012
|
var MAX_BUFFER2 = 64 * 1024 * 1024;
|
|
23878
24013
|
function findExecutable(bin, env) {
|
|
23879
|
-
const dirs = (env.PATH ?? env.Path ?? "").split(
|
|
24014
|
+
const dirs = (env.PATH ?? env.Path ?? "").split(path33.delimiter).filter(Boolean);
|
|
23880
24015
|
const exts = process.platform === "win32" ? [".exe"] : [""];
|
|
23881
24016
|
for (const dir of dirs)
|
|
23882
24017
|
for (const ext of exts) {
|
|
23883
|
-
const candidate =
|
|
24018
|
+
const candidate = path33.join(dir, `${bin}${ext}`);
|
|
23884
24019
|
try {
|
|
23885
24020
|
const stat = fs21.statSync(candidate);
|
|
23886
24021
|
if (stat.isFile())
|
|
@@ -23923,7 +24058,7 @@ var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only throug
|
|
|
23923
24058
|
|
|
23924
24059
|
// packages/workit-core/src/core/youtrack.ts
|
|
23925
24060
|
var ISSUE_RE = /^[A-Z][A-Z0-9_]*-\d+$/;
|
|
23926
|
-
var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ??
|
|
24061
|
+
var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path34.join(resolveConfigDir(), "youtrack.json");
|
|
23927
24062
|
var readYouTrackContextConfig = () => {
|
|
23928
24063
|
const cfgPath = youTrackReadOnlyConfigPath();
|
|
23929
24064
|
if (!fs22.existsSync(cfgPath))
|
|
@@ -24291,15 +24426,15 @@ function resolveGitRevision(root, value) {
|
|
|
24291
24426
|
}
|
|
24292
24427
|
function resolveInside(root, candidate) {
|
|
24293
24428
|
const base = realpathSync8(root);
|
|
24294
|
-
const target =
|
|
24295
|
-
if (target !== base && !target.startsWith(base +
|
|
24429
|
+
const target = path35.resolve(base, candidate);
|
|
24430
|
+
if (target !== base && !target.startsWith(base + path35.sep)) {
|
|
24296
24431
|
throw new Error("path must stay inside repository root");
|
|
24297
24432
|
}
|
|
24298
24433
|
let ancestor = target;
|
|
24299
24434
|
while (!existsSync12(ancestor))
|
|
24300
|
-
ancestor =
|
|
24435
|
+
ancestor = path35.dirname(ancestor);
|
|
24301
24436
|
const canonicalAncestor = realpathSync8(ancestor);
|
|
24302
|
-
if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base +
|
|
24437
|
+
if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path35.sep)) {
|
|
24303
24438
|
throw new Error("path must stay inside repository root");
|
|
24304
24439
|
}
|
|
24305
24440
|
return target;
|
|
@@ -24343,9 +24478,9 @@ var capabilitiesFor = (descriptor, observed = {}) => descriptor.capabilities.map
|
|
|
24343
24478
|
};
|
|
24344
24479
|
});
|
|
24345
24480
|
// packages/workit-core/src/hooks/context.ts
|
|
24346
|
-
import { createHash as
|
|
24481
|
+
import { createHash as createHash17 } from "node:crypto";
|
|
24347
24482
|
import fs23 from "node:fs";
|
|
24348
|
-
import
|
|
24483
|
+
import path36 from "node:path";
|
|
24349
24484
|
var MIGRATION_PENDING_NOTE = "workit migration pending — run `workit task status`";
|
|
24350
24485
|
var migrationPending = (result) => !result.ok && result.code === "needs_input" && (result.error ?? "").startsWith(MIGRATION_PENDING);
|
|
24351
24486
|
var boundTo = (entry, session) => entry.sessions.some((item) => item.host === session.host && item.handle === session.handle);
|
|
@@ -24433,7 +24568,7 @@ function entryCompactContext(store, entry, session, context) {
|
|
|
24433
24568
|
current: () => recentSignal(store.root)
|
|
24434
24569
|
};
|
|
24435
24570
|
const observed = task?.data.evidence.some(isObservedCheck) ?? false;
|
|
24436
|
-
const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [
|
|
24571
|
+
const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [path36.resolve(store.root, ref.path)] : []));
|
|
24437
24572
|
const observedFiles = filesKey(files);
|
|
24438
24573
|
const compact = compactContext(store, context, entry?.id ?? null, freshness, origin && { origin: origin.origin, taskId: origin.entry.id });
|
|
24439
24574
|
if (!compact.ok || !compact.data)
|
|
@@ -24492,17 +24627,17 @@ ${options.addendum}` : ""}
|
|
|
24492
24627
|
</workit-contract>`;
|
|
24493
24628
|
};
|
|
24494
24629
|
var checkoutAt = (cwd) => {
|
|
24495
|
-
for (let dir =
|
|
24496
|
-
const dotGit =
|
|
24630
|
+
for (let dir = path36.resolve(cwd);; dir = path36.dirname(dir)) {
|
|
24631
|
+
const dotGit = path36.join(dir, ".git");
|
|
24497
24632
|
if (fs23.existsSync(dotGit)) {
|
|
24498
|
-
const admin = fs23.statSync(dotGit).isFile() ?
|
|
24499
|
-
const head = fs23.readFileSync(
|
|
24633
|
+
const admin = fs23.statSync(dotGit).isFile() ? path36.resolve(dir, /^gitdir:\s*(.+)$/mu.exec(fs23.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "") : dotGit;
|
|
24634
|
+
const head = fs23.readFileSync(path36.join(admin, "HEAD"), "utf8").trim();
|
|
24500
24635
|
return {
|
|
24501
24636
|
root: dir,
|
|
24502
24637
|
branch: /^ref: refs\/heads\/(.+)$/u.exec(head)?.[1] ?? null
|
|
24503
24638
|
};
|
|
24504
24639
|
}
|
|
24505
|
-
if (
|
|
24640
|
+
if (path36.dirname(dir) === dir)
|
|
24506
24641
|
return null;
|
|
24507
24642
|
}
|
|
24508
24643
|
};
|
|
@@ -24513,7 +24648,7 @@ var whereLine = (cwd) => {
|
|
|
24513
24648
|
return null;
|
|
24514
24649
|
const allowed = branchPolicySnapshotFor(cwd).namePolicy.allowed;
|
|
24515
24650
|
const kinds = allowed.some((pattern) => pattern.source === "^.*$") ? "any" : allowedKinds(allowed).join(", ") || "see `workit help git`";
|
|
24516
|
-
const place = checkout.root ===
|
|
24651
|
+
const place = checkout.root === path36.resolve(cwd) ? "" : ` in ${checkout.root}`;
|
|
24517
24652
|
return `cwd ${cwd}${place} on ${checkout.branch ?? "detached HEAD"}; branch kinds: ${kinds}`;
|
|
24518
24653
|
} catch {
|
|
24519
24654
|
return null;
|
|
@@ -24531,7 +24666,7 @@ var turnContextText = (input, descriptor) => {
|
|
|
24531
24666
|
}
|
|
24532
24667
|
};
|
|
24533
24668
|
var TURN_TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
|
24534
|
-
var digestOf = (text) =>
|
|
24669
|
+
var digestOf = (text) => createHash17("sha256").update(text).digest("hex");
|
|
24535
24670
|
var turnMarker = (input) => {
|
|
24536
24671
|
if (!input.session.id)
|
|
24537
24672
|
return null;
|
|
@@ -24540,14 +24675,14 @@ var turnMarker = (input) => {
|
|
|
24540
24675
|
if (location instanceof Error)
|
|
24541
24676
|
return null;
|
|
24542
24677
|
const session = [input.host, input.session.id, input.session.agentId ?? ""].join("\x00");
|
|
24543
|
-
return
|
|
24678
|
+
return path36.join(location.dir, "hooks", `turn-${digestOf(session).slice(0, 32)}.json`);
|
|
24544
24679
|
} catch {
|
|
24545
24680
|
return null;
|
|
24546
24681
|
}
|
|
24547
24682
|
};
|
|
24548
24683
|
var writeTurnDigest = (file, digest) => {
|
|
24549
24684
|
try {
|
|
24550
|
-
fs23.mkdirSync(
|
|
24685
|
+
fs23.mkdirSync(path36.dirname(file), { recursive: true });
|
|
24551
24686
|
fs23.writeFileSync(file, `${JSON.stringify({ digest })}
|
|
24552
24687
|
`);
|
|
24553
24688
|
} catch {}
|
|
@@ -24562,7 +24697,7 @@ var pruneTurnDigests = (dir, now) => {
|
|
|
24562
24697
|
for (const name of fs23.readdirSync(dir)) {
|
|
24563
24698
|
if (!name.startsWith("turn-"))
|
|
24564
24699
|
continue;
|
|
24565
|
-
const file =
|
|
24700
|
+
const file = path36.join(dir, name);
|
|
24566
24701
|
try {
|
|
24567
24702
|
if (now - fs23.statSync(file).mtimeMs > TURN_TTL_MS)
|
|
24568
24703
|
fs23.rmSync(file, { force: true });
|
|
@@ -24592,7 +24727,7 @@ var seedTurnContext = (input, descriptor, text = turnContextText(input, descript
|
|
|
24592
24727
|
const file = turnMarker(input);
|
|
24593
24728
|
if (!file)
|
|
24594
24729
|
return;
|
|
24595
|
-
pruneTurnDigests(
|
|
24730
|
+
pruneTurnDigests(path36.dirname(file), Date.now());
|
|
24596
24731
|
if (text)
|
|
24597
24732
|
writeTurnDigest(file, digestOf(text));
|
|
24598
24733
|
else
|
|
@@ -24699,7 +24834,7 @@ var userOnlyWorkitCall = (command, dialect = "posix") => {
|
|
|
24699
24834
|
// packages/workit-core/src/core/heavy-rules.ts
|
|
24700
24835
|
import fs24 from "node:fs";
|
|
24701
24836
|
import os7 from "node:os";
|
|
24702
|
-
import
|
|
24837
|
+
import path37 from "node:path";
|
|
24703
24838
|
var EMPTY2 = () => ({ deny: [], allow: [] });
|
|
24704
24839
|
var readText3 = (file) => {
|
|
24705
24840
|
try {
|
|
@@ -24740,19 +24875,19 @@ function parseJsonc(text) {
|
|
|
24740
24875
|
return JSON.parse(out.replace(/,(\s*[}\]])/gu, "$1"));
|
|
24741
24876
|
}
|
|
24742
24877
|
function gitTop(cwd) {
|
|
24743
|
-
for (let dir =
|
|
24744
|
-
if (fs24.existsSync(
|
|
24878
|
+
for (let dir = path37.resolve(cwd);; dir = path37.dirname(dir)) {
|
|
24879
|
+
if (fs24.existsSync(path37.join(dir, ".git")))
|
|
24745
24880
|
return dir;
|
|
24746
|
-
if (
|
|
24881
|
+
if (path37.dirname(dir) === dir)
|
|
24747
24882
|
return null;
|
|
24748
24883
|
}
|
|
24749
24884
|
}
|
|
24750
24885
|
var projectDirs = (cwd) => {
|
|
24751
24886
|
const top = gitTop(cwd);
|
|
24752
24887
|
const dirs = [];
|
|
24753
|
-
for (let dir =
|
|
24888
|
+
for (let dir = path37.resolve(cwd);; dir = path37.dirname(dir)) {
|
|
24754
24889
|
dirs.push(dir);
|
|
24755
|
-
if (!top || dir === top ||
|
|
24890
|
+
if (!top || dir === top || path37.dirname(dir) === dir)
|
|
24756
24891
|
return dirs;
|
|
24757
24892
|
}
|
|
24758
24893
|
};
|
|
@@ -24764,12 +24899,12 @@ var CLAUDE_MANAGED = {
|
|
|
24764
24899
|
};
|
|
24765
24900
|
function claudeSettingsFiles(cwd, env, platform = process.platform) {
|
|
24766
24901
|
const project = env.CLAUDE_PROJECT_DIR || gitTop(cwd) || cwd;
|
|
24767
|
-
const user = env.CLAUDE_CONFIG_DIR ||
|
|
24902
|
+
const user = env.CLAUDE_CONFIG_DIR || path37.join(homeOf(env), ".claude");
|
|
24768
24903
|
return [
|
|
24769
24904
|
...CLAUDE_MANAGED[platform] ? [CLAUDE_MANAGED[platform]] : [],
|
|
24770
|
-
|
|
24771
|
-
|
|
24772
|
-
|
|
24905
|
+
path37.join(user, "settings.json"),
|
|
24906
|
+
path37.join(project, ".claude", "settings.json"),
|
|
24907
|
+
path37.join(project, ".claude", "settings.local.json")
|
|
24773
24908
|
];
|
|
24774
24909
|
}
|
|
24775
24910
|
var bashPattern = (entry) => {
|
|
@@ -24859,10 +24994,10 @@ var opencodeConfig = (value, rules) => {
|
|
|
24859
24994
|
function opencodeRules(cwd, env = process.env) {
|
|
24860
24995
|
const rules = EMPTY2();
|
|
24861
24996
|
try {
|
|
24862
|
-
const config = env.XDG_CONFIG_HOME ||
|
|
24997
|
+
const config = env.XDG_CONFIG_HOME || path37.join(homeOf(env), ".config");
|
|
24863
24998
|
const files = [
|
|
24864
|
-
...OPENCODE_NAMES.map((name) =>
|
|
24865
|
-
...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [
|
|
24999
|
+
...OPENCODE_NAMES.map((name) => path37.join(config, "opencode", name)),
|
|
25000
|
+
...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [path37.join(dir, name), path37.join(dir, ".opencode", name)])),
|
|
24866
25001
|
...env.OPENCODE_CONFIG ? [env.OPENCODE_CONFIG] : []
|
|
24867
25002
|
];
|
|
24868
25003
|
for (const file of files) {
|
|
@@ -24906,9 +25041,9 @@ var codexRule = (body) => {
|
|
|
24906
25041
|
function codexRules(cwd, env = process.env) {
|
|
24907
25042
|
const rules = EMPTY2();
|
|
24908
25043
|
try {
|
|
24909
|
-
const home = env.CODEX_HOME ||
|
|
25044
|
+
const home = env.CODEX_HOME || path37.join(homeOf(env), ".codex");
|
|
24910
25045
|
const top = gitTop(cwd) ?? cwd;
|
|
24911
|
-
for (const dir of [
|
|
25046
|
+
for (const dir of [path37.join(home, "rules"), path37.join(top, ".codex", "rules")]) {
|
|
24912
25047
|
let files;
|
|
24913
25048
|
try {
|
|
24914
25049
|
files = fs24.readdirSync(dir).filter((name) => name.endsWith(".rules"));
|
|
@@ -24918,7 +25053,7 @@ function codexRules(cwd, env = process.env) {
|
|
|
24918
25053
|
return "unreadable";
|
|
24919
25054
|
}
|
|
24920
25055
|
for (const name of files) {
|
|
24921
|
-
const text = readText3(
|
|
25056
|
+
const text = readText3(path37.join(dir, name)) ?? "";
|
|
24922
25057
|
for (const part of text.split(/\bprefix_rule\s*\(/u).slice(1)) {
|
|
24923
25058
|
const rule = codexRule(part);
|
|
24924
25059
|
if (!rule)
|
|
@@ -24937,8 +25072,8 @@ function cursorRules(cwd, env = process.env) {
|
|
|
24937
25072
|
try {
|
|
24938
25073
|
const top = gitTop(cwd) ?? cwd;
|
|
24939
25074
|
for (const file of [
|
|
24940
|
-
|
|
24941
|
-
|
|
25075
|
+
path37.join(homeOf(env), ".cursor", "cli-config.json"),
|
|
25076
|
+
path37.join(top, ".cursor", "cli.json")
|
|
24942
25077
|
]) {
|
|
24943
25078
|
const text = readText3(file);
|
|
24944
25079
|
if (text === null)
|
|
@@ -25013,10 +25148,10 @@ function wrapAllowed(read, words, command, options = {}) {
|
|
|
25013
25148
|
|
|
25014
25149
|
// packages/workit-core/src/core/heavy.ts
|
|
25015
25150
|
import fs25 from "node:fs";
|
|
25016
|
-
import
|
|
25151
|
+
import path38 from "node:path";
|
|
25017
25152
|
var stateDir2 = (env, platform = process.platform) => stateDir(env, platform);
|
|
25018
25153
|
var HEAVY_COMMANDS_FILE = "heavy-commands.json";
|
|
25019
|
-
var heavyCommandsFile = (env) =>
|
|
25154
|
+
var heavyCommandsFile = (env) => path38.join(stateDir2(env), HEAVY_COMMANDS_FILE);
|
|
25020
25155
|
var HEAVY_SCRIPT = /^(?:test|tests|t|tst|unit|integration|e2e|coverage|cov|lint|eslint|typecheck|type-check|types|tsc|check|verify|validate|build|compile|bundle|ci|sonar|cypress|playwright|jest|vitest|mocha|bench|benchmark|all)(?:$|[:_.-])/iu;
|
|
25021
25156
|
var INFO_FLAGS = new Set(["--version", "-v", "-V", "--help", "-h", "help", "version"]);
|
|
25022
25157
|
var WATCH_FLAG = /^(?:--watch(?:All)?(?:=.*)?|-w|--serve)$/u;
|
|
@@ -25291,7 +25426,7 @@ function machinePatterns(env) {
|
|
|
25291
25426
|
return isRecord5(value) ? stringList(value.patterns) : [];
|
|
25292
25427
|
}
|
|
25293
25428
|
function repoPatterns(cwd) {
|
|
25294
|
-
return repoHeavyCommands(gitTop(cwd) ??
|
|
25429
|
+
return repoHeavyCommands(gitTop(cwd) ?? path38.resolve(cwd));
|
|
25295
25430
|
}
|
|
25296
25431
|
function heavyLines(lines, options) {
|
|
25297
25432
|
const found = [];
|
|
@@ -25369,12 +25504,12 @@ function heavyPlan(command, options) {
|
|
|
25369
25504
|
}
|
|
25370
25505
|
function workitOnPath2(env = process.env) {
|
|
25371
25506
|
const names = process.platform === "win32" ? ["workit.exe", "workit.cmd", "workit"] : ["workit"];
|
|
25372
|
-
for (const dir of (env.PATH ?? "").split(
|
|
25507
|
+
for (const dir of (env.PATH ?? "").split(path38.delimiter))
|
|
25373
25508
|
for (const name of names) {
|
|
25374
25509
|
if (!dir)
|
|
25375
25510
|
continue;
|
|
25376
25511
|
try {
|
|
25377
|
-
fs25.accessSync(
|
|
25512
|
+
fs25.accessSync(path38.join(dir, name), fs25.constants.X_OK);
|
|
25378
25513
|
return true;
|
|
25379
25514
|
} catch {}
|
|
25380
25515
|
}
|
|
@@ -25392,7 +25527,7 @@ function leaseRewrite(command) {
|
|
|
25392
25527
|
|
|
25393
25528
|
// packages/workit-core/src/core/heavy-words.ts
|
|
25394
25529
|
import fs26 from "node:fs";
|
|
25395
|
-
import
|
|
25530
|
+
import path39 from "node:path";
|
|
25396
25531
|
var HEAVY_WORDS = new Set(("npm npx pnpm pnpx yarn bun bunx deno corepack make gmake docker podman nerdctl " + "python python3 py uv poetry pdm pipenv hatch rye bundle rake nx " + "jest vitest mocha ava tap karma jasmine nyc c8 tsc vue-tsc svelte-check eslint stylelint " + "tslint webpack webpack-cli rollup parcel tsup vite next nuxt nuxi astro ng react-scripts " + "playwright cypress wdio testcafe turbo lerna sonar-scanner sonarless sonarless-mcp go " + "golangci-lint gotestsum staticcheck cargo mvn mvnw gradle gradlew ant sbt bazel bazelisk " + "buck2 dotnet msbuild pytest py.test tox nox mypy pyright pylint coverage maturin pip pip3 " + "rspec rails phpunit pest phpstan psalm composer mix swift xcodebuild flutter dart pod cmake " + "ninja meson ctest scons docker-compose buildah earthly").split(" "));
|
|
25397
25532
|
var wordsOf = (command) => command.split(/[\s;&|()<>`'"]+/u).map((word) => (word.split(/[\\/]/u).at(-1) ?? "").toLowerCase().replace(/\.(?:exe|cmd|bat)$/u, "")).filter(Boolean);
|
|
25398
25533
|
var stateDir3 = (env) => stateDir(env);
|
|
@@ -25405,15 +25540,15 @@ var readJson2 = (file) => {
|
|
|
25405
25540
|
};
|
|
25406
25541
|
var patternWords = (cwd, env) => {
|
|
25407
25542
|
const patterns = [];
|
|
25408
|
-
const machine = readJson2(
|
|
25543
|
+
const machine = readJson2(path39.join(stateDir3(env), "heavy-commands.json"));
|
|
25409
25544
|
if (Array.isArray(machine?.patterns))
|
|
25410
25545
|
patterns.push(...machine.patterns);
|
|
25411
|
-
for (let dir =
|
|
25412
|
-
if (fs26.existsSync(
|
|
25546
|
+
for (let dir = path39.resolve(cwd);; dir = path39.dirname(dir)) {
|
|
25547
|
+
if (fs26.existsSync(path39.join(dir, ".git"))) {
|
|
25413
25548
|
patterns.push(...repoHeavyCommands(dir));
|
|
25414
25549
|
break;
|
|
25415
25550
|
}
|
|
25416
|
-
if (
|
|
25551
|
+
if (path39.dirname(dir) === dir)
|
|
25417
25552
|
break;
|
|
25418
25553
|
}
|
|
25419
25554
|
const words = new Set;
|
|
@@ -25487,16 +25622,16 @@ var splitDenial = (plan) => ({
|
|
|
25487
25622
|
unblock: plan.unblock
|
|
25488
25623
|
});
|
|
25489
25624
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
25490
|
-
import { existsSync as existsSync13, readdirSync as readdirSync5, readFileSync as
|
|
25625
|
+
import { existsSync as existsSync13, readdirSync as readdirSync5, readFileSync as readFileSync12, realpathSync as realpathSync9, statSync as statSync4 } from "node:fs";
|
|
25491
25626
|
import os9 from "node:os";
|
|
25492
|
-
import
|
|
25627
|
+
import path41 from "node:path";
|
|
25493
25628
|
|
|
25494
25629
|
// packages/workit-core/src/core/live-session.ts
|
|
25495
25630
|
import { spawnSync as spawnSync23 } from "node:child_process";
|
|
25496
|
-
import { createHash as
|
|
25631
|
+
import { createHash as createHash18 } from "node:crypto";
|
|
25497
25632
|
import fs27 from "node:fs";
|
|
25498
25633
|
import os8 from "node:os";
|
|
25499
|
-
import
|
|
25634
|
+
import path40 from "node:path";
|
|
25500
25635
|
var LIVE_SESSION_TTL_MS = 15 * 60000;
|
|
25501
25636
|
var HEARTBEAT_EVERY_MS = 30000;
|
|
25502
25637
|
var liveProbe = {
|
|
@@ -25570,15 +25705,15 @@ var liveOwner = (input, transport, env = process.env) => {
|
|
|
25570
25705
|
};
|
|
25571
25706
|
};
|
|
25572
25707
|
var checkoutOf = (target) => {
|
|
25573
|
-
let dir =
|
|
25574
|
-
while (!fs27.existsSync(dir) &&
|
|
25575
|
-
dir =
|
|
25708
|
+
let dir = path40.resolve(target);
|
|
25709
|
+
while (!fs27.existsSync(dir) && path40.dirname(dir) !== dir)
|
|
25710
|
+
dir = path40.dirname(dir);
|
|
25576
25711
|
if (fs27.existsSync(dir) && !fs27.statSync(dir).isDirectory())
|
|
25577
|
-
dir =
|
|
25578
|
-
const parts = dir.split(
|
|
25712
|
+
dir = path40.dirname(dir);
|
|
25713
|
+
const parts = dir.split(path40.sep);
|
|
25579
25714
|
const dotGit = parts.lastIndexOf(".git");
|
|
25580
25715
|
if (dotGit > 0)
|
|
25581
|
-
dir = parts.slice(0, dotGit).join(
|
|
25716
|
+
dir = parts.slice(0, dotGit).join(path40.sep) || path40.sep;
|
|
25582
25717
|
const location = resolveStore(dir);
|
|
25583
25718
|
if (location instanceof Error || !location.shared || !location.top)
|
|
25584
25719
|
return null;
|
|
@@ -25588,9 +25723,9 @@ var checkoutOf = (target) => {
|
|
|
25588
25723
|
} catch {}
|
|
25589
25724
|
return top;
|
|
25590
25725
|
};
|
|
25591
|
-
var markerFile2 = (top) =>
|
|
25726
|
+
var markerFile2 = (top) => path40.join(resolveStateDir(), "live-sessions", `${createHash18("sha256").update(checkoutKey(top)).digest("hex").slice(0, 32)}.json`);
|
|
25592
25727
|
var checkoutKey = (top, platform = process.platform) => {
|
|
25593
|
-
let key =
|
|
25728
|
+
let key = path40.resolve(top);
|
|
25594
25729
|
try {
|
|
25595
25730
|
key = fs27.realpathSync.native(key);
|
|
25596
25731
|
} catch {}
|
|
@@ -25685,7 +25820,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
|
|
|
25685
25820
|
checkout,
|
|
25686
25821
|
heartbeatAt: now.toISOString()
|
|
25687
25822
|
};
|
|
25688
|
-
fs27.mkdirSync(
|
|
25823
|
+
fs27.mkdirSync(path40.dirname(file), { recursive: true });
|
|
25689
25824
|
const temp = `${file}.${process.pid}.tmp`;
|
|
25690
25825
|
fs27.writeFileSync(temp, JSON.stringify(marker));
|
|
25691
25826
|
fs27.renameSync(temp, file);
|
|
@@ -25695,24 +25830,24 @@ var claimLiveSession = (target, owner, deps = {}) => {
|
|
|
25695
25830
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
25696
25831
|
var NONE3 = { kind: "none" };
|
|
25697
25832
|
var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
|
|
25698
|
-
var
|
|
25833
|
+
var canonical4 = (file) => {
|
|
25699
25834
|
let rest = "";
|
|
25700
|
-
for (let dir =
|
|
25835
|
+
for (let dir = path41.resolve(file);; dir = path41.dirname(dir)) {
|
|
25701
25836
|
try {
|
|
25702
|
-
return
|
|
25837
|
+
return path41.join(realpathSync9.native(dir), rest);
|
|
25703
25838
|
} catch {
|
|
25704
|
-
if (
|
|
25705
|
-
return
|
|
25706
|
-
rest = rest ?
|
|
25839
|
+
if (path41.dirname(dir) === dir)
|
|
25840
|
+
return path41.resolve(file);
|
|
25841
|
+
rest = rest ? path41.join(path41.basename(dir), rest) : path41.basename(dir);
|
|
25707
25842
|
}
|
|
25708
25843
|
}
|
|
25709
25844
|
};
|
|
25710
25845
|
var exempt = (cwd, root, file, plans) => {
|
|
25711
25846
|
const fold = (value) => CASE_INSENSITIVE ? value.toLowerCase() : value;
|
|
25712
|
-
const relative =
|
|
25713
|
-
if (relative.startsWith("..") ||
|
|
25847
|
+
const relative = path41.relative(fold(canonical4(root)), fold(canonical4(path41.resolve(cwd, file))));
|
|
25848
|
+
if (relative.startsWith("..") || path41.isAbsolute(relative))
|
|
25714
25849
|
return true;
|
|
25715
|
-
const posix = relative.split(
|
|
25850
|
+
const posix = relative.split(path41.sep).join("/");
|
|
25716
25851
|
const segments = posix.split("/");
|
|
25717
25852
|
return /\.mdx?$/i.test(posix) || segments[0] === "docs" || segments.includes("plans") || [...plans].some((plan) => fold(plan) === posix);
|
|
25718
25853
|
};
|
|
@@ -25828,8 +25963,8 @@ var WRAPPERS2 = {
|
|
|
25828
25963
|
bunx: "p"
|
|
25829
25964
|
};
|
|
25830
25965
|
var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php|tsx|ts-node)$/;
|
|
25831
|
-
var isConfigDir = (file) => configDirs().some((dir) =>
|
|
25832
|
-
var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test(
|
|
25966
|
+
var isConfigDir = (file) => configDirs().some((dir) => canonical4(dir) === canonical4(file));
|
|
25967
|
+
var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test(path41.relative(canonical4(resolveStateDir()), canonical4(file)));
|
|
25833
25968
|
var READ_CALLS = /^(?:print|log|info|warn|error|debug|puts|readdir(?:Sync)?|listdir|scandir|iterdir|glob|l?stat(?:Sync)?|exists(?:Sync)?|isdir|isfile|is_dir|is_file|access(?:Sync)?|realpath(?:Sync)?|dirname|basename|relative|str|repr|len)$/;
|
|
25834
25969
|
var MUTATING_CALLS = /^(?:renames?(?:Sync)?|move|copy(?:2|file|tree|File)?(?:Sync)?|cp(?:Sync)?|rm(?:tree|dir|Sync|dirSync)?|unlink(?:Sync)?|remove(?:dirs)?|mkdirs?(?:Sync)?|makedirs|mkdtemp(?:Sync)?|(?:sym|hard)?link(?:Sync|_to)?|write\w*|append\w*|truncate(?:Sync)?|ch(?:mod|own)(?:Sync)?|touch|open(?:Sync)?|dump|save|extractall|unpack_archive|put_contents|mv|FileUtils)$/;
|
|
25835
25970
|
var PATH_CALLS = /^(?:join|resolve|normalize|abspath|expanduser|expandvars|Path|PurePath|fspath)$/;
|
|
@@ -26140,10 +26275,10 @@ var linkSources = (args, at) => {
|
|
|
26140
26275
|
const sources = names.filter((name, index) => into >= 0 ? name !== dest : index < names.length - 1 || names.length === 1);
|
|
26141
26276
|
const target = dest === undefined ? null : at(dest);
|
|
26142
26277
|
const symbolic = args.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg));
|
|
26143
|
-
const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync13(target) || /[\\/]$/.test(dest ?? "") ? target :
|
|
26278
|
+
const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync13(target) || /[\\/]$/.test(dest ?? "") ? target : path41.dirname(target);
|
|
26144
26279
|
return sources.flatMap((source) => {
|
|
26145
|
-
if (symbolic && base !== null && !
|
|
26146
|
-
return [
|
|
26280
|
+
if (symbolic && base !== null && !path41.isAbsolute(homeExpanded(source)))
|
|
26281
|
+
return [path41.resolve(base, source)];
|
|
26147
26282
|
const resolved = at(source);
|
|
26148
26283
|
return resolved ? [resolved] : [];
|
|
26149
26284
|
});
|
|
@@ -26172,7 +26307,7 @@ var shellWrites = (command, depth = 0) => {
|
|
|
26172
26307
|
return { writes: true, targets: unknown ? null : targets };
|
|
26173
26308
|
};
|
|
26174
26309
|
var cache3 = new Map;
|
|
26175
|
-
var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(
|
|
26310
|
+
var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path41.resolve(root, file)) ?? "-").join("\x00");
|
|
26176
26311
|
var gateFor = (cwd) => {
|
|
26177
26312
|
const store = new TaskReader(cwd);
|
|
26178
26313
|
const listed = store.listTaskIndex();
|
|
@@ -26252,13 +26387,13 @@ var gitMutationDirs = (cwd, command, dialect) => {
|
|
|
26252
26387
|
return [];
|
|
26253
26388
|
if (sub === "stash" && ["list", "show"].includes(rest[0] ?? ""))
|
|
26254
26389
|
return [];
|
|
26255
|
-
return [
|
|
26390
|
+
return [path41.resolve(cwd, invocation.dir ?? ".")];
|
|
26256
26391
|
});
|
|
26257
26392
|
};
|
|
26258
26393
|
var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
|
|
26259
26394
|
var PUSHD2 = new Set(["pushd", "push-location"]);
|
|
26260
26395
|
var POPD2 = new Set(["popd", "pop-location"]);
|
|
26261
|
-
var UNKNOWN_DIR =
|
|
26396
|
+
var UNKNOWN_DIR = path41.resolve(path41.parse(process.cwd()).root, ".workit-unknown-dir");
|
|
26262
26397
|
var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
|
|
26263
26398
|
const lost = strict ? UNKNOWN_DIR : undefined;
|
|
26264
26399
|
const found = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
|
|
@@ -26268,7 +26403,7 @@ var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
|
|
|
26268
26403
|
return lost;
|
|
26269
26404
|
if (dir === undefined)
|
|
26270
26405
|
return lost;
|
|
26271
|
-
return target === undefined ? os9.homedir() :
|
|
26406
|
+
return target === undefined ? os9.homedir() : path41.resolve(dir, target);
|
|
26272
26407
|
};
|
|
26273
26408
|
var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
|
|
26274
26409
|
var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
|
|
@@ -26403,7 +26538,7 @@ var untrustedVars = (segments) => {
|
|
|
26403
26538
|
}
|
|
26404
26539
|
return { all, names };
|
|
26405
26540
|
};
|
|
26406
|
-
var UNKNOWN_VAR =
|
|
26541
|
+
var UNKNOWN_VAR = path41.resolve(path41.parse(process.cwd()).root, ".workit-unknown-var");
|
|
26407
26542
|
var REFERENCE = /\$\{(\w+)[^}]*\}|\$(\w+)|\$\([^)]*\)?|`[^`]*`?/g;
|
|
26408
26543
|
var unresolvedRefs = (text) => [
|
|
26409
26544
|
...new Set([...text.matchAll(REFERENCE)].map((match) => {
|
|
@@ -26413,7 +26548,7 @@ var unresolvedRefs = (text) => [
|
|
|
26413
26548
|
];
|
|
26414
26549
|
var unknownVarTarget = (text) => {
|
|
26415
26550
|
const refs = unresolvedRefs(text);
|
|
26416
|
-
return
|
|
26551
|
+
return path41.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
|
|
26417
26552
|
};
|
|
26418
26553
|
var applyOperator = (value, operator) => {
|
|
26419
26554
|
if (operator === "")
|
|
@@ -26474,12 +26609,12 @@ var mktempPath = (value, dir) => {
|
|
|
26474
26609
|
if (base === null && (temp || template === undefined))
|
|
26475
26610
|
base = os9.tmpdir();
|
|
26476
26611
|
const name = homeExpanded(template ?? "tmp.XXXXXXXXXX");
|
|
26477
|
-
if (
|
|
26612
|
+
if (path41.isAbsolute(name))
|
|
26478
26613
|
return name;
|
|
26479
26614
|
const from = base === null ? dir : homeExpanded(base);
|
|
26480
|
-
if (from === undefined || !
|
|
26615
|
+
if (from === undefined || !path41.isAbsolute(from) && dir === undefined)
|
|
26481
26616
|
return null;
|
|
26482
|
-
return
|
|
26617
|
+
return path41.resolve(dir ?? from, from, name);
|
|
26483
26618
|
};
|
|
26484
26619
|
var homeExpanded = (file) => {
|
|
26485
26620
|
const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
|
|
@@ -26500,9 +26635,9 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26500
26635
|
const home = homeExpanded(text);
|
|
26501
26636
|
if (strict && unresolvedRefs(home).length > 0)
|
|
26502
26637
|
return [unknownVarTarget(home)];
|
|
26503
|
-
if (
|
|
26638
|
+
if (path41.isAbsolute(home))
|
|
26504
26639
|
return [home];
|
|
26505
|
-
return base === undefined ? [] : [
|
|
26640
|
+
return base === undefined ? [] : [path41.resolve(base, home)];
|
|
26506
26641
|
});
|
|
26507
26642
|
const at = (file) => {
|
|
26508
26643
|
const all = atAll(file);
|
|
@@ -26650,7 +26785,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26650
26785
|
return [made];
|
|
26651
26786
|
try {
|
|
26652
26787
|
const stat = statSync4(script);
|
|
26653
|
-
const text = stat.isFile() && stat.size <= 262144 ?
|
|
26788
|
+
const text = stat.isFile() && stat.size <= 262144 ? readFileSync12(script, "utf8") : "\x00";
|
|
26654
26789
|
return text.includes("\x00") ? [] : [text];
|
|
26655
26790
|
} catch {
|
|
26656
26791
|
return [];
|
|
@@ -26693,7 +26828,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26693
26828
|
index
|
|
26694
26829
|
}));
|
|
26695
26830
|
const homes = /homedir\(|expanduser\(|Path\.home\(|['"]HOME['"]|env\.HOME|\$HOME|~/.test(text);
|
|
26696
|
-
const under = (word) => homes ? [
|
|
26831
|
+
const under = (word) => homes ? [path41.join(homeExpanded("~"), word.replace(/^~/, ""))] : [];
|
|
26697
26832
|
const found = [
|
|
26698
26833
|
...[...text.matchAll(PATHS)].flatMap(({ 0: word, index }) => [...atAll(word), ...under(word)].map((file) => ({ file, index }))),
|
|
26699
26834
|
...joined.flatMap(({ word, index }) => under(word).map((file) => ({ file, index })))
|
|
@@ -26732,7 +26867,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26732
26867
|
for (const file of opaque ?? [])
|
|
26733
26868
|
for (const resolved of atAll(file))
|
|
26734
26869
|
if (!quiet || !isRoot(resolved))
|
|
26735
|
-
targets.push(file === "." ?
|
|
26870
|
+
targets.push(file === "." ? path41.join(resolved, here) : resolved);
|
|
26736
26871
|
const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
|
|
26737
26872
|
const lnArgs = words.slice(ln + 1);
|
|
26738
26873
|
if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)) && (strict !== "registry" || !lnArgs.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg))))
|
|
@@ -26744,7 +26879,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26744
26879
|
const edits = editsOf(body);
|
|
26745
26880
|
if (edits === null) {
|
|
26746
26881
|
if (dir !== undefined)
|
|
26747
|
-
targets.push(
|
|
26882
|
+
targets.push(path41.join(dir, DIR_TARGET));
|
|
26748
26883
|
} else
|
|
26749
26884
|
for (const file of edits)
|
|
26750
26885
|
targets.push(...atAll(file));
|
|
@@ -26752,7 +26887,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26752
26887
|
for (const invocation of workitInvocations(body.map(quoteWord2).join(" "), "posix")) {
|
|
26753
26888
|
const { at: runsIn, args } = workitCwd(dir, invocation, atAll);
|
|
26754
26889
|
if (args[0] === "git" && MUTATING_WORKIT_GIT.has(args[1] ?? "") && !inert(args.slice(2), ""))
|
|
26755
|
-
targets.push(...runsIn.map((runs) =>
|
|
26890
|
+
targets.push(...runsIn.map((runs) => path41.join(runs, DIR_TARGET)));
|
|
26756
26891
|
}
|
|
26757
26892
|
}
|
|
26758
26893
|
return targets;
|
|
@@ -26774,7 +26909,7 @@ var shellMutationTargets = (cwd, command, dialect = "posix", strict = false) =>
|
|
|
26774
26909
|
const env = new Map(strict === "registry" ? [...command.matchAll(/\$\{?([A-Za-z_]\w*)/g)].filter((match) => !/^(?:OLD)?PWD$/.test(match[1])).map((match) => [match[1], process.env[match[1]] ?? ""]) : []);
|
|
26775
26910
|
return [
|
|
26776
26911
|
...segmentTargets(cwd, command, dialect, 0, strict, env),
|
|
26777
|
-
...gitMutationDirs(cwd, command, dialect).map((dir) =>
|
|
26912
|
+
...gitMutationDirs(cwd, command, dialect).map((dir) => path41.join(dir, DIR_TARGET))
|
|
26778
26913
|
];
|
|
26779
26914
|
} catch (error) {
|
|
26780
26915
|
if (strict === "registry")
|
|
@@ -26813,7 +26948,7 @@ var liveDeny = ({ marker, checkout, ageMs, file }) => {
|
|
|
26813
26948
|
var guarded = (targets) => {
|
|
26814
26949
|
const seen = new Set;
|
|
26815
26950
|
return targets.filter((target) => {
|
|
26816
|
-
const dir =
|
|
26951
|
+
const dir = path41.dirname(target);
|
|
26817
26952
|
if (seen.has(dir))
|
|
26818
26953
|
return false;
|
|
26819
26954
|
seen.add(dir);
|
|
@@ -26834,15 +26969,16 @@ var claimAll = (owner, targets, deps) => {
|
|
|
26834
26969
|
for (const target of guarded(targets))
|
|
26835
26970
|
claimLiveSession(target, owner, deps);
|
|
26836
26971
|
};
|
|
26837
|
-
var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) =>
|
|
26972
|
+
var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path41.resolve(cwd, file)) : [path41.join(cwd, DIR_TARGET)];
|
|
26973
|
+
var CONFIG_FILES = ["workspaces.json", SEAL_FILE];
|
|
26838
26974
|
var configDirs = () => [resolveConfigDir(), grantsDir()];
|
|
26839
26975
|
var globbed = (cwd, target, state, configs) => {
|
|
26840
26976
|
if (!/[*?[]/.test(target))
|
|
26841
26977
|
return [];
|
|
26842
|
-
const raw =
|
|
26978
|
+
const raw = path41.resolve(cwd, target).split(path41.sep);
|
|
26843
26979
|
const literal = raw.findIndex((part) => /[*?[]/.test(part));
|
|
26844
26980
|
const pattern = [
|
|
26845
|
-
...
|
|
26981
|
+
...canonical4(raw.slice(0, literal).join(path41.sep) || path41.sep).replace(/[\\/]+$/, "").split(path41.sep),
|
|
26846
26982
|
...raw.slice(literal)
|
|
26847
26983
|
];
|
|
26848
26984
|
const segment = (glob, name) => {
|
|
@@ -26853,7 +26989,7 @@ var globbed = (cwd, target, state, configs) => {
|
|
|
26853
26989
|
}
|
|
26854
26990
|
};
|
|
26855
26991
|
const hit = (file, below) => {
|
|
26856
|
-
const parts =
|
|
26992
|
+
const parts = canonical4(file).split(path41.sep);
|
|
26857
26993
|
return (below ? pattern.length >= parts.length : pattern.length === parts.length) && parts.every((part, index) => segment(pattern[index], part));
|
|
26858
26994
|
};
|
|
26859
26995
|
let roots = [];
|
|
@@ -26861,8 +26997,8 @@ var globbed = (cwd, target, state, configs) => {
|
|
|
26861
26997
|
roots = readdirSync5(state).filter((name) => /^(?:issued|approvals$)/.test(name));
|
|
26862
26998
|
} catch {}
|
|
26863
26999
|
return [
|
|
26864
|
-
...roots.map((name) =>
|
|
26865
|
-
...configs.flatMap((dir) => [dir,
|
|
27000
|
+
...roots.map((name) => path41.join(state, name)).filter((root) => hit(root, true)),
|
|
27001
|
+
...configs.flatMap((dir) => [dir, ...CONFIG_FILES.map((name) => path41.join(dir, name))]).filter((file) => hit(file, false))
|
|
26866
27002
|
];
|
|
26867
27003
|
};
|
|
26868
27004
|
var guardedInodes = (state, configs) => {
|
|
@@ -26876,14 +27012,15 @@ var guardedInodes = (state, configs) => {
|
|
|
26876
27012
|
seen.set(`${stat.dev}:${stat.ino}`, registry);
|
|
26877
27013
|
else if (stat?.isDirectory())
|
|
26878
27014
|
for (const name of readdirSync5(file))
|
|
26879
|
-
add(
|
|
27015
|
+
add(path41.join(file, name), registry);
|
|
26880
27016
|
};
|
|
26881
27017
|
try {
|
|
26882
27018
|
for (const dir of configs)
|
|
26883
|
-
|
|
27019
|
+
for (const name of CONFIG_FILES)
|
|
27020
|
+
add(path41.join(dir, name), "grants");
|
|
26884
27021
|
for (const name of readdirSync5(state))
|
|
26885
27022
|
if (/^(?:issued|approvals$)/.test(name))
|
|
26886
|
-
add(
|
|
27023
|
+
add(path41.join(state, name), name === "approvals" ? "approvals" : "issued");
|
|
26887
27024
|
} catch {}
|
|
26888
27025
|
return seen;
|
|
26889
27026
|
};
|
|
@@ -26908,7 +27045,7 @@ var registryTarget = (cwd, targets) => {
|
|
|
26908
27045
|
const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
|
|
26909
27046
|
if (viaGlob)
|
|
26910
27047
|
return { file: target, registry: viaGlob.registry };
|
|
26911
|
-
const registry = hardLinked(
|
|
27048
|
+
const registry = hardLinked(path41.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical4) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical4)) ? "grants" : null);
|
|
26912
27049
|
if (registry)
|
|
26913
27050
|
return { file: target, registry };
|
|
26914
27051
|
}
|
|
@@ -26916,7 +27053,7 @@ var registryTarget = (cwd, targets) => {
|
|
|
26916
27053
|
};
|
|
26917
27054
|
var partsUnder = (dir, cwd, target, platform, real) => {
|
|
26918
27055
|
const win = platform === "win32";
|
|
26919
|
-
const p = win ?
|
|
27056
|
+
const p = win ? path41.win32 : path41.posix;
|
|
26920
27057
|
const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
|
|
26921
27058
|
const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
|
|
26922
27059
|
const relative = p.relative(fold(real(p.resolve(dir))), fold(real(p.resolve(cwd, named))));
|
|
@@ -26930,7 +27067,7 @@ var underRegistry = (state, cwd, target, platform = process.platform, real = (fi
|
|
|
26930
27067
|
};
|
|
26931
27068
|
var underConfig = (dir, cwd, target, platform = process.platform, real = (file) => file) => {
|
|
26932
27069
|
const parts = partsUnder(dir, cwd, target, platform, real);
|
|
26933
|
-
return parts?.length === 1 && ["",
|
|
27070
|
+
return parts?.length === 1 && ["", ...CONFIG_FILES, DIR_TARGET].includes(parts[0]);
|
|
26934
27071
|
};
|
|
26935
27072
|
var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
26936
27073
|
if (platform !== "win32" || !command.includes("\\"))
|
|
@@ -26950,7 +27087,7 @@ var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
|
26950
27087
|
];
|
|
26951
27088
|
const named = (target) => moved.some((dir) => {
|
|
26952
27089
|
const at = flat(/^(?:[a-z]:)?\//i.test(target) ? target : dir + target).replace(/\/\.?\//g, "/");
|
|
26953
|
-
return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, `${cfg}
|
|
27090
|
+
return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, ...CONFIG_FILES.map((name) => `${cfg}/${name}`)].includes(at)) : at.includes(`${state}/${registry}`);
|
|
26954
27091
|
});
|
|
26955
27092
|
return writes.writes && (writes.targets === null || writes.targets.some(named)) ? registry : null;
|
|
26956
27093
|
};
|
|
@@ -26973,7 +27110,7 @@ var REGISTRY_DENY = {
|
|
|
26973
27110
|
};
|
|
26974
27111
|
var registryDeny = ({ file, registry }) => {
|
|
26975
27112
|
const { label, what, unblock } = REGISTRY_DENY[registry];
|
|
26976
|
-
const named =
|
|
27113
|
+
const named = path41.basename(file).startsWith(".workit-") ? path41.dirname(file) : file;
|
|
26977
27114
|
return {
|
|
26978
27115
|
kind: "deny",
|
|
26979
27116
|
reason: `workit ${label}: ${named} is under ${what}. ${unblock}`,
|
|
@@ -27063,10 +27200,10 @@ import { spawnSync as spawnSync24 } from "node:child_process";
|
|
|
27063
27200
|
|
|
27064
27201
|
// packages/workit-core/src/ci-waiter.ts
|
|
27065
27202
|
import fs28 from "node:fs";
|
|
27066
|
-
import
|
|
27203
|
+
import path42 from "node:path";
|
|
27067
27204
|
var waiterFile = (cwd, pr) => {
|
|
27068
27205
|
const common = gitCommonDir(cwd);
|
|
27069
|
-
return common ?
|
|
27206
|
+
return common ? path42.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
|
|
27070
27207
|
};
|
|
27071
27208
|
var pidAlive2 = (pid) => {
|
|
27072
27209
|
if (!Number.isSafeInteger(pid) || pid <= 0)
|
|
@@ -27605,37 +27742,37 @@ var writePaths = (input) => {
|
|
|
27605
27742
|
};
|
|
27606
27743
|
// packages/workit-core/src/hooks/standing.ts
|
|
27607
27744
|
import fs30 from "node:fs";
|
|
27608
|
-
import
|
|
27745
|
+
import path45 from "node:path";
|
|
27609
27746
|
|
|
27610
27747
|
// packages/workit-core/src/approvals/store.ts
|
|
27611
|
-
import { createHash as
|
|
27612
|
-
import { mkdirSync as mkdirSync6, readdirSync as readdirSync6, readFileSync as
|
|
27613
|
-
import
|
|
27748
|
+
import { createHash as createHash19, randomBytes as randomBytes4 } from "node:crypto";
|
|
27749
|
+
import { mkdirSync as mkdirSync6, readdirSync as readdirSync6, readFileSync as readFileSync13 } from "node:fs";
|
|
27750
|
+
import path43 from "node:path";
|
|
27614
27751
|
var REQUEST_TTL_MS = 30 * 60000;
|
|
27615
27752
|
var GRANT_TTL_MS = 15 * 60000;
|
|
27616
27753
|
var ID_PATTERN = /^ap_[a-z2-7]{8}$/u;
|
|
27617
27754
|
var isApprovalId = (word) => ID_PATTERN.test(word);
|
|
27618
|
-
var approvalHash = (fields) =>
|
|
27755
|
+
var approvalHash = (fields) => createHash19("sha256").update(canonicalJson({
|
|
27619
27756
|
kind: fields.kind,
|
|
27620
27757
|
action: fields.action,
|
|
27621
27758
|
target: fields.target,
|
|
27622
27759
|
effect: fields.effect,
|
|
27623
27760
|
subject: fields.subject
|
|
27624
27761
|
})).digest("hex");
|
|
27625
|
-
var approvalsDir = () =>
|
|
27626
|
-
var dirOf = (part) =>
|
|
27627
|
-
var fileOf = (part, id) =>
|
|
27628
|
-
var askedFile = (session, toolUseId) =>
|
|
27762
|
+
var approvalsDir = () => path43.join(resolveStateDir(), "approvals");
|
|
27763
|
+
var dirOf = (part) => path43.join(approvalsDir(), part);
|
|
27764
|
+
var fileOf = (part, id) => path43.join(dirOf(part), `${id}.json`);
|
|
27765
|
+
var askedFile = (session, toolUseId) => path43.join(dirOf("asked"), `${createHash19("sha256").update(`${session}\x00${toolUseId}`).digest("hex").slice(0, 32)}.json`);
|
|
27629
27766
|
var readJson3 = (file) => {
|
|
27630
27767
|
try {
|
|
27631
|
-
const value = JSON.parse(
|
|
27768
|
+
const value = JSON.parse(readFileSync13(file, "utf8"));
|
|
27632
27769
|
return value !== null && typeof value === "object" ? value : null;
|
|
27633
27770
|
} catch {
|
|
27634
27771
|
return null;
|
|
27635
27772
|
}
|
|
27636
27773
|
};
|
|
27637
27774
|
var write = (file, value) => {
|
|
27638
|
-
mkdirSync6(
|
|
27775
|
+
mkdirSync6(path43.dirname(file), { recursive: true });
|
|
27639
27776
|
writeFileAtomic(file, `${JSON.stringify(value, null, 2)}
|
|
27640
27777
|
`);
|
|
27641
27778
|
};
|
|
@@ -28253,42 +28390,42 @@ function neededChecks(lane, configured) {
|
|
|
28253
28390
|
}
|
|
28254
28391
|
|
|
28255
28392
|
// packages/workit-core/src/hooks/worktree-confine.ts
|
|
28256
|
-
import { createHash as
|
|
28393
|
+
import { createHash as createHash20 } from "node:crypto";
|
|
28257
28394
|
import fs29 from "node:fs";
|
|
28258
|
-
import
|
|
28395
|
+
import path44 from "node:path";
|
|
28259
28396
|
var FANOUT_TOKEN_FILE = "workit-fanout-token";
|
|
28260
28397
|
var NONE5 = { kind: "none" };
|
|
28261
28398
|
var CASE_INSENSITIVE2 = process.platform === "darwin" || process.platform === "win32";
|
|
28262
|
-
var
|
|
28399
|
+
var canonical5 = (file) => {
|
|
28263
28400
|
let rest = "";
|
|
28264
|
-
for (let dir =
|
|
28401
|
+
for (let dir = path44.resolve(file);; dir = path44.dirname(dir)) {
|
|
28265
28402
|
try {
|
|
28266
|
-
return
|
|
28403
|
+
return path44.join(fs29.realpathSync.native(dir), rest);
|
|
28267
28404
|
} catch {
|
|
28268
|
-
if (
|
|
28269
|
-
return
|
|
28270
|
-
rest = rest ?
|
|
28405
|
+
if (path44.dirname(dir) === dir)
|
|
28406
|
+
return path44.resolve(file);
|
|
28407
|
+
rest = rest ? path44.join(path44.basename(dir), rest) : path44.basename(dir);
|
|
28271
28408
|
}
|
|
28272
28409
|
}
|
|
28273
28410
|
};
|
|
28274
28411
|
var within = (child, parent) => {
|
|
28275
28412
|
const fold = (value) => CASE_INSENSITIVE2 ? value.toLowerCase() : value;
|
|
28276
|
-
const relative =
|
|
28277
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
28413
|
+
const relative = path44.relative(fold(parent), fold(child));
|
|
28414
|
+
return relative === "" || !relative.startsWith("..") && !path44.isAbsolute(relative);
|
|
28278
28415
|
};
|
|
28279
28416
|
var checkoutOf2 = (file) => {
|
|
28280
|
-
for (let dir =
|
|
28281
|
-
const dotGit =
|
|
28417
|
+
for (let dir = canonical5(file);; dir = path44.dirname(dir)) {
|
|
28418
|
+
const dotGit = path44.join(dir, ".git");
|
|
28282
28419
|
if (fs29.existsSync(dotGit)) {
|
|
28283
28420
|
if (!fs29.statSync(dotGit).isFile())
|
|
28284
28421
|
return { root: dir, workit: false };
|
|
28285
28422
|
const admin = /^gitdir:\s*(.+)$/mu.exec(fs29.readFileSync(dotGit, "utf8"))?.[1]?.trim();
|
|
28286
28423
|
return {
|
|
28287
28424
|
root: dir,
|
|
28288
|
-
workit: Boolean(admin) && fs29.existsSync(
|
|
28425
|
+
workit: Boolean(admin) && fs29.existsSync(path44.join(path44.resolve(dir, admin), FANOUT_TOKEN_FILE))
|
|
28289
28426
|
};
|
|
28290
28427
|
}
|
|
28291
|
-
if (
|
|
28428
|
+
if (path44.dirname(dir) === dir)
|
|
28292
28429
|
return null;
|
|
28293
28430
|
}
|
|
28294
28431
|
};
|
|
@@ -28300,8 +28437,8 @@ var workitWorktreeOf = (file) => {
|
|
|
28300
28437
|
return null;
|
|
28301
28438
|
}
|
|
28302
28439
|
};
|
|
28303
|
-
var bindingDir = () =>
|
|
28304
|
-
var bindingFile = (session, agentId) =>
|
|
28440
|
+
var bindingDir = () => path44.join(resolveStateDir(), "worktree-bind");
|
|
28441
|
+
var bindingFile = (session, agentId) => path44.join(bindingDir(), `${createHash20("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
|
|
28305
28442
|
var readBinding = (file) => {
|
|
28306
28443
|
try {
|
|
28307
28444
|
const value = JSON.parse(fs29.readFileSync(file, "utf8"));
|
|
@@ -28326,7 +28463,7 @@ var bind = (input, worktree) => {
|
|
|
28326
28463
|
agentId,
|
|
28327
28464
|
at: new Date().toISOString()
|
|
28328
28465
|
};
|
|
28329
|
-
fs29.mkdirSync(
|
|
28466
|
+
fs29.mkdirSync(path44.dirname(file), { recursive: true });
|
|
28330
28467
|
fs29.writeFileSync(file, JSON.stringify(binding));
|
|
28331
28468
|
try {
|
|
28332
28469
|
if (inWorkitWorkspace(input.cwd))
|
|
@@ -28345,31 +28482,31 @@ var hostIsolated = (cwd, agentId) => {
|
|
|
28345
28482
|
const checkout = checkoutOf2(cwd);
|
|
28346
28483
|
if (!checkout)
|
|
28347
28484
|
return false;
|
|
28348
|
-
const dotGit =
|
|
28485
|
+
const dotGit = path44.join(checkout.root, ".git");
|
|
28349
28486
|
if (!fs29.statSync(dotGit).isFile())
|
|
28350
28487
|
return false;
|
|
28351
28488
|
const admin = /^gitdir:\s*(.+)$/mu.exec(fs29.readFileSync(dotGit, "utf8"))?.[1]?.trim();
|
|
28352
28489
|
if (!admin)
|
|
28353
28490
|
return false;
|
|
28354
|
-
const adminDir =
|
|
28355
|
-
const back = fs29.readFileSync(
|
|
28356
|
-
if (
|
|
28491
|
+
const adminDir = path44.resolve(checkout.root, admin);
|
|
28492
|
+
const back = fs29.readFileSync(path44.join(adminDir, "gitdir"), "utf8").trim();
|
|
28493
|
+
if (path44.relative(canonical5(path44.resolve(adminDir, back)), canonical5(dotGit)) !== "")
|
|
28357
28494
|
return false;
|
|
28358
|
-
const common =
|
|
28359
|
-
const gitDir = fs29.existsSync(common) ?
|
|
28360
|
-
const expected =
|
|
28361
|
-
return
|
|
28495
|
+
const common = path44.join(adminDir, "commondir");
|
|
28496
|
+
const gitDir = fs29.existsSync(common) ? path44.resolve(adminDir, fs29.readFileSync(common, "utf8").trim()) : adminDir;
|
|
28497
|
+
const expected = path44.join(path44.dirname(canonical5(gitDir)), ".claude", "worktrees", `agent-${agentId}`);
|
|
28498
|
+
return path44.relative(canonical5(expected), checkout.root) === "";
|
|
28362
28499
|
} catch {
|
|
28363
28500
|
return false;
|
|
28364
28501
|
}
|
|
28365
28502
|
};
|
|
28366
28503
|
var runnerAt = (target) => {
|
|
28367
|
-
const base =
|
|
28504
|
+
const base = path44.basename(target);
|
|
28368
28505
|
return base.startsWith(OPAQUE_TARGET) ? decodeURIComponent(base.slice(OPAQUE_TARGET.length)) : null;
|
|
28369
28506
|
};
|
|
28370
28507
|
var shown = (target) => {
|
|
28371
|
-
const named = /^\.workit-(?:live-target$|runs-)/.test(
|
|
28372
|
-
return
|
|
28508
|
+
const named = /^\.workit-(?:live-target$|runs-)/.test(path44.basename(target)) ? path44.dirname(target) : target;
|
|
28509
|
+
return path44.sep === "\\" ? named.replaceAll("/", "\\") : named;
|
|
28373
28510
|
};
|
|
28374
28511
|
var unboundDeny = (input, target) => {
|
|
28375
28512
|
const unblock = "Work only in the worktree your brief names, which the lead made with `workit fanout worktree create <slice>`: edit files under it and run one verb per call against it (`workit git --cwd <worktree> commit -m … -- <paths>`, `workit check --cwd <worktree> <name>`). If your brief names no worktree, stop and report that to the lead.";
|
|
@@ -28408,7 +28545,7 @@ var literalForm = (command, refs) => {
|
|
|
28408
28545
|
};
|
|
28409
28546
|
var unknownVarDeny = (input, worktree, targets, command) => {
|
|
28410
28547
|
const refs = [
|
|
28411
|
-
...new Set(targets.flatMap((target) =>
|
|
28548
|
+
...new Set(targets.flatMap((target) => path44.relative(UNKNOWN_VAR, path44.resolve(target)).split(path44.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
|
|
28412
28549
|
];
|
|
28413
28550
|
let text = command ?? "";
|
|
28414
28551
|
const first = [];
|
|
@@ -28437,13 +28574,13 @@ function confineImplementer(input, targets, command) {
|
|
|
28437
28574
|
try {
|
|
28438
28575
|
if (!input.session.agentId || hostIsolated(input.cwd, input.session.agentId))
|
|
28439
28576
|
return NONE5;
|
|
28440
|
-
const unresolved = targets.filter((target) => within(
|
|
28577
|
+
const unresolved = targets.filter((target) => within(path44.resolve(target), UNKNOWN_VAR));
|
|
28441
28578
|
if (unresolved.length > 0)
|
|
28442
28579
|
return unknownVarDeny(input, boundWorktree(input), unresolved, command);
|
|
28443
|
-
if (targets.some((target) => within(
|
|
28580
|
+
if (targets.some((target) => within(path44.resolve(target), UNKNOWN_DIR)))
|
|
28444
28581
|
return unknownDirDeny(input, boundWorktree(input));
|
|
28445
|
-
const bindings =
|
|
28446
|
-
const judged = targets.map((named) => ({ named, real:
|
|
28582
|
+
const bindings = canonical5(bindingDir());
|
|
28583
|
+
const judged = targets.map((named) => ({ named, real: canonical5(named) })).filter(({ real }) => within(real, bindings) || checkoutOf2(real) !== null);
|
|
28447
28584
|
if (judged.length === 0)
|
|
28448
28585
|
return NONE5;
|
|
28449
28586
|
let worktree = boundWorktree(input);
|
|
@@ -28457,7 +28594,7 @@ function confineImplementer(input, targets, command) {
|
|
|
28457
28594
|
return unboundDeny(input, judged[0].named);
|
|
28458
28595
|
bind(input, worktree);
|
|
28459
28596
|
}
|
|
28460
|
-
const root =
|
|
28597
|
+
const root = canonical5(worktree);
|
|
28461
28598
|
const outside = judged.find(({ real }) => !within(real, root) || within(real, bindings));
|
|
28462
28599
|
return outside ? outsideDeny(input, worktree, outside.named) : NONE5;
|
|
28463
28600
|
} catch {
|
|
@@ -28550,16 +28687,16 @@ var RUNS = /^(?:sh|bash|zsh|dash|ksh|mksh|ash|python[\d.]*|node|bun|deno|ruby|pe
|
|
|
28550
28687
|
var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/;
|
|
28551
28688
|
var VALUED = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
|
|
28552
28689
|
var commonDir = (root) => {
|
|
28553
|
-
const dotGit =
|
|
28690
|
+
const dotGit = path44.join(root, ".git");
|
|
28554
28691
|
if (!fs29.statSync(dotGit).isFile())
|
|
28555
|
-
return
|
|
28556
|
-
const admin =
|
|
28557
|
-
const common =
|
|
28558
|
-
return
|
|
28692
|
+
return canonical5(dotGit);
|
|
28693
|
+
const admin = path44.resolve(root, /^gitdir:\s*(.+)$/mu.exec(fs29.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "");
|
|
28694
|
+
const common = path44.join(admin, "commondir");
|
|
28695
|
+
return canonical5(fs29.existsSync(common) ? path44.resolve(admin, fs29.readFileSync(common, "utf8").trim()) : admin);
|
|
28559
28696
|
};
|
|
28560
28697
|
var inScratch = (real, repo) => {
|
|
28561
28698
|
const checkout = checkoutOf2(real);
|
|
28562
|
-
return checkout !== null && within(real,
|
|
28699
|
+
return checkout !== null && within(real, path44.join(checkout.root, SCRATCH)) && (repo === null || commonDir(checkout.root) === repo);
|
|
28563
28700
|
};
|
|
28564
28701
|
var JUDGE_VERBS = {
|
|
28565
28702
|
check: true,
|
|
@@ -28588,7 +28725,7 @@ var judgeVerbRefused = (args) => {
|
|
|
28588
28725
|
var CLI_RUNNERS = /^(?:npx|bunx|pnpx|npm|pnpm|yarn|bun|node|nodejs|deno|tsx|ts-node)$/;
|
|
28589
28726
|
var CLI_ENTRY = /(?:^|[=\\/])(?:workit(?:\.(?:exe|cmd|[cm]?js))?|@workit-dev\/cli(?:@\S*)?)$|(?:workit-cli|@workit-dev[\\/]cli)[\\/](?:src[\\/](?:index|main)|dist[\\/]index)\.[cm]?[jt]sx?$/;
|
|
28590
28727
|
var workitCalls = (command, depth = 0, aliases = new Map) => depth > 4 ? [] : commandLines(command).flatMap((words) => {
|
|
28591
|
-
const name =
|
|
28728
|
+
const name = path44.basename(words[0] ?? "").toLowerCase();
|
|
28592
28729
|
if (name === "alias")
|
|
28593
28730
|
return words.flatMap((word) => {
|
|
28594
28731
|
const set = /^([\w-]+)=(.*)$/s.exec(word);
|
|
@@ -28618,11 +28755,11 @@ var judgeRefusal = (command, fed, depth = 0) => {
|
|
|
28618
28755
|
return why;
|
|
28619
28756
|
}
|
|
28620
28757
|
const { words } = segment;
|
|
28621
|
-
const runs = (word = "") => RUNS.test(
|
|
28758
|
+
const runs = (word = "") => RUNS.test(path44.basename(word).toLowerCase());
|
|
28622
28759
|
let at = 0;
|
|
28623
28760
|
while (at < words.length && (LEADS.test(words[at]) || /^-\w$/.test(words[at - 1] ?? "") && !runs(words[at])))
|
|
28624
28761
|
at++;
|
|
28625
|
-
const name =
|
|
28762
|
+
const name = path44.basename(words[at] ?? "").toLowerCase();
|
|
28626
28763
|
const args = words.slice(at + 1);
|
|
28627
28764
|
const unseen = `\`${words.join(" ").slice(0, 80)}\` runs a script Workit cannot read (piped, on stdin, a process substitution or eval): write the case to a file in ${SCRATCH} and dispatch it from a test instead`;
|
|
28628
28765
|
if (/^(?:cd|chdir|pushd|popd)$/.test(name))
|
|
@@ -28701,8 +28838,8 @@ var judgeDeny = (input, what, target) => {
|
|
|
28701
28838
|
const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
|
|
28702
28839
|
const root = checkoutOf2(input.cwd)?.root;
|
|
28703
28840
|
const candidate = target ? checkoutOf2(target)?.root : undefined;
|
|
28704
|
-
const also = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? ` or ${
|
|
28705
|
-
const scratch = root ? `${
|
|
28841
|
+
const also = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? ` or ${path44.join(candidate, SCRATCH)}` : "";
|
|
28842
|
+
const scratch = root ? `${path44.join(root, SCRATCH)}${also}` : `${SCRATCH}/ at the root of the checkout you judge`;
|
|
28706
28843
|
const unblock = `Write only under ${scratch} (mkdir -p it): put a generated case in a file there with a quoted heredoc (<<'EOF') and never run it in the shell. Reads, \`workit check\` and \`workit ledger verdict|finding\` stay allowed; a change the candidate needs is a finding, not an edit.`;
|
|
28707
28844
|
return {
|
|
28708
28845
|
kind: "deny",
|
|
@@ -28717,10 +28854,10 @@ function confineJudge(input, targets) {
|
|
|
28717
28854
|
const judged = checkoutOf2(input.cwd);
|
|
28718
28855
|
const repo = judged ? commonDir(judged.root) : null;
|
|
28719
28856
|
for (const target of targets) {
|
|
28720
|
-
const resolved =
|
|
28857
|
+
const resolved = path44.resolve(target);
|
|
28721
28858
|
if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
|
|
28722
28859
|
return judgeDeny(input, "it writes to a path Workit cannot resolve (a variable, a command substitution or `cd -`): spell the path out");
|
|
28723
|
-
if (inScratch(
|
|
28860
|
+
if (inScratch(canonical5(target), repo))
|
|
28724
28861
|
continue;
|
|
28725
28862
|
const runner = runnerAt(target);
|
|
28726
28863
|
return judgeDeny(input, runner === null ? `${shown(target)} is outside it` : `\`${runner}\` runs in ${shown(target)}, outside it`, target);
|
|
@@ -28748,7 +28885,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
|
|
|
28748
28885
|
let git = [];
|
|
28749
28886
|
try {
|
|
28750
28887
|
git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args)) ? [
|
|
28751
|
-
|
|
28888
|
+
path44.join(dir === undefined ? UNKNOWN_DIR : path44.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
|
|
28752
28889
|
] : []);
|
|
28753
28890
|
} catch {}
|
|
28754
28891
|
return confineJudge(input, [
|
|
@@ -28793,7 +28930,7 @@ var judgeChecksLine = (cwd) => {
|
|
|
28793
28930
|
|
|
28794
28931
|
// packages/workit-core/src/hooks/standing.ts
|
|
28795
28932
|
var readPlans = (store) => {
|
|
28796
|
-
const dir =
|
|
28933
|
+
const dir = path45.join(store, "fanouts");
|
|
28797
28934
|
let names;
|
|
28798
28935
|
try {
|
|
28799
28936
|
names = fs30.readdirSync(dir).filter((name) => name.endsWith(".json"));
|
|
@@ -28803,7 +28940,7 @@ var readPlans = (store) => {
|
|
|
28803
28940
|
const plans = [];
|
|
28804
28941
|
for (const name of names) {
|
|
28805
28942
|
try {
|
|
28806
|
-
const raw = JSON.parse(fs30.readFileSync(
|
|
28943
|
+
const raw = JSON.parse(fs30.readFileSync(path45.join(dir, name), "utf8"));
|
|
28807
28944
|
if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
|
|
28808
28945
|
continue;
|
|
28809
28946
|
const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
|
|
@@ -29014,7 +29151,7 @@ var cdWorkitSplit = (command) => {
|
|
|
29014
29151
|
// packages/workit-core/src/hooks/model-limit.ts
|
|
29015
29152
|
import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync7, readSync, statSync as statSync5 } from "node:fs";
|
|
29016
29153
|
import os10 from "node:os";
|
|
29017
|
-
import
|
|
29154
|
+
import path46 from "node:path";
|
|
29018
29155
|
var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
|
|
29019
29156
|
var WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
|
|
29020
29157
|
var TIME_WORD = String.raw`(?:\d|(?:in|at|on|later|tomorrow|soon)\b|(?:${[...WEEKDAYS, ...MONTHS].join("|")})[a-z]*\b)`;
|
|
@@ -29212,17 +29349,17 @@ var firstPrompt = (file) => {
|
|
|
29212
29349
|
var claudeProjectSlug = (cwd) => cwd.replace(/[^A-Za-z0-9]/gu, "-");
|
|
29213
29350
|
var listDir = (dir) => {
|
|
29214
29351
|
try {
|
|
29215
|
-
return readdirSync7(dir).map((name) =>
|
|
29352
|
+
return readdirSync7(dir).map((name) => path46.join(dir, name));
|
|
29216
29353
|
} catch {
|
|
29217
29354
|
return [];
|
|
29218
29355
|
}
|
|
29219
29356
|
};
|
|
29220
29357
|
var SCAN_MS = 30 * 60000;
|
|
29221
29358
|
var scanClaudeTranscripts = (cwd, env, now = new Date) => {
|
|
29222
|
-
const projects =
|
|
29223
|
-
const project =
|
|
29359
|
+
const projects = path46.join(env.CLAUDE_CONFIG_DIR || path46.join(env.HOME || os10.homedir(), ".claude"), "projects");
|
|
29360
|
+
const project = path46.join(projects, claudeProjectSlug(cwd));
|
|
29224
29361
|
const notes = [];
|
|
29225
|
-
const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(
|
|
29362
|
+
const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path46.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
|
|
29226
29363
|
for (const { file, worker } of files)
|
|
29227
29364
|
try {
|
|
29228
29365
|
const stat = statSync5(file);
|
|
@@ -29237,7 +29374,7 @@ var scanClaudeTranscripts = (cwd, env, now = new Date) => {
|
|
|
29237
29374
|
if (!seen)
|
|
29238
29375
|
continue;
|
|
29239
29376
|
notes.push(worker ? redispatchNote(seen, {
|
|
29240
|
-
label: `worker ${
|
|
29377
|
+
label: `worker ${path46.basename(file, ".jsonl")}`,
|
|
29241
29378
|
prompt: firstPrompt(file)
|
|
29242
29379
|
}, now) : `Workit: this session hit a usage limit (${seen.reason}); ${seen.key} is marked exhausted until ${shortTime(seen.until)}. Claude Code runs only Anthropic models: Workit cannot switch this session, so continue on another host or after the reset.`);
|
|
29243
29380
|
} catch {}
|
|
@@ -29801,7 +29938,6 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
|
|
|
29801
29938
|
READ.delete(READ.keys().next().value);
|
|
29802
29939
|
return found;
|
|
29803
29940
|
};
|
|
29804
|
-
var writesMode = (cwd) => resolveRuntimeWorkspaceVcs(cwd)?.youtrack?.writes;
|
|
29805
29941
|
var ytrackGate = (cwd, command, dialect, ask) => {
|
|
29806
29942
|
let writes;
|
|
29807
29943
|
try {
|
|
@@ -29812,7 +29948,7 @@ var ytrackGate = (cwd, command, dialect, ask) => {
|
|
|
29812
29948
|
}
|
|
29813
29949
|
writes = [...merged.values()];
|
|
29814
29950
|
} catch {
|
|
29815
|
-
if (
|
|
29951
|
+
if (youTrackWritesMode(cwd) === "auto")
|
|
29816
29952
|
return null;
|
|
29817
29953
|
return {
|
|
29818
29954
|
kind: "deny",
|
|
@@ -29820,7 +29956,7 @@ var ytrackGate = (cwd, command, dialect, ask) => {
|
|
|
29820
29956
|
unblock: null
|
|
29821
29957
|
};
|
|
29822
29958
|
}
|
|
29823
|
-
if (!writes.length ||
|
|
29959
|
+
if (!writes.length || youTrackWritesMode(cwd) === "auto")
|
|
29824
29960
|
return null;
|
|
29825
29961
|
const calls = writes.flatMap((write) => write.workit ? [`\`${write.workit}\``] : []);
|
|
29826
29962
|
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"})`);
|
|
@@ -30127,12 +30263,12 @@ var modelKey = (model) => {
|
|
|
30127
30263
|
};
|
|
30128
30264
|
|
|
30129
30265
|
// packages/workit-core/src/hooks/budget-signal.ts
|
|
30130
|
-
import { createHash as
|
|
30266
|
+
import { createHash as createHash21 } from "node:crypto";
|
|
30131
30267
|
import fs31 from "node:fs";
|
|
30132
|
-
import
|
|
30133
|
-
var hash2 = (text) =>
|
|
30134
|
-
var budgetDir = (store) =>
|
|
30135
|
-
var agentBase = (store, session, agentId) =>
|
|
30268
|
+
import path47 from "node:path";
|
|
30269
|
+
var hash2 = (text) => createHash21("sha256").update(text).digest("hex").slice(0, 32);
|
|
30270
|
+
var budgetDir = (store) => path47.join(store, "budget");
|
|
30271
|
+
var agentBase = (store, session, agentId) => path47.join(budgetDir(store), hash2(`${session}\x00${agentId ?? ""}`));
|
|
30136
30272
|
var spawnBudget = (prompt) => {
|
|
30137
30273
|
const found = /^TIMEBOX:[^\n]*?\b(\d+)\s+tool calls\b/mu.exec(prompt);
|
|
30138
30274
|
const n = found ? Number(found[1]) : NaN;
|
|
@@ -30152,8 +30288,8 @@ var startBudget = (store, session, agentId, n) => {
|
|
|
30152
30288
|
const cutoff = Date.now() - 604800000;
|
|
30153
30289
|
for (const name of fs31.readdirSync(dir))
|
|
30154
30290
|
try {
|
|
30155
|
-
if (fs31.statSync(
|
|
30156
|
-
fs31.rmSync(
|
|
30291
|
+
if (fs31.statSync(path47.join(dir, name)).mtimeMs < cutoff)
|
|
30292
|
+
fs31.rmSync(path47.join(dir, name));
|
|
30157
30293
|
} catch {}
|
|
30158
30294
|
const base = agentBase(store, session, agentId);
|
|
30159
30295
|
fs31.writeFileSync(`${base}.json`, JSON.stringify({ limit: n, told: 0 }));
|
|
@@ -30292,11 +30428,11 @@ var unfinishedTaskOffer2 = (ctx) => {
|
|
|
30292
30428
|
};
|
|
30293
30429
|
|
|
30294
30430
|
// packages/workit-core/src/hooks/repeat-failure.ts
|
|
30295
|
-
import { createHash as
|
|
30431
|
+
import { createHash as createHash22 } from "node:crypto";
|
|
30296
30432
|
var SAME_CALL_FAILED = "Same call failed twice:";
|
|
30297
30433
|
var MAX_SESSIONS = 256;
|
|
30298
30434
|
var stable = (value) => JSON.stringify(value, (_key, entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? Object.fromEntries(Object.entries(entry).toSorted(([a], [b]) => a.localeCompare(b))) : entry) ?? "null";
|
|
30299
|
-
var hashOf = (call) =>
|
|
30435
|
+
var hashOf = (call) => createHash22("sha256").update(call).digest("hex").slice(0, 32);
|
|
30300
30436
|
var record2 = (memo, sessionId, call, failed, next) => {
|
|
30301
30437
|
const previous = memo.get(sessionId);
|
|
30302
30438
|
memo.delete(sessionId);
|
|
@@ -30567,14 +30703,14 @@ var observeToolResult = (event, ctx) => {
|
|
|
30567
30703
|
var skillPromptNudge = (prompt, ctx) => process.env.WORKIT_PI_WORKER_SESSION ? null : promptNudge(hookInput(ctx, { kind: "context.turn", prompt }), prompt);
|
|
30568
30704
|
|
|
30569
30705
|
// packages/workit-pi/src/launches.ts
|
|
30570
|
-
import { mkdirSync as mkdirSync7, readFileSync as
|
|
30706
|
+
import { mkdirSync as mkdirSync7, readFileSync as readFileSync14, readdirSync as readdirSync8, rmSync as rmSync3, writeFileSync as writeFileSync6 } from "node:fs";
|
|
30571
30707
|
import os11 from "node:os";
|
|
30572
|
-
import
|
|
30708
|
+
import path48 from "node:path";
|
|
30573
30709
|
var launchDir = (root) => {
|
|
30574
30710
|
const location = resolveStore(root);
|
|
30575
|
-
return location instanceof Error ? null :
|
|
30711
|
+
return location instanceof Error ? null : path48.join(location.dir, "pi-launches");
|
|
30576
30712
|
};
|
|
30577
|
-
var fileFor = (dir, workerId) =>
|
|
30713
|
+
var fileFor = (dir, workerId) => path48.join(dir, `${workerId.replace(/[^A-Za-z0-9-]/g, "_")}.json`);
|
|
30578
30714
|
var recordLaunch = (root, attempt) => {
|
|
30579
30715
|
const dir = launchDir(root);
|
|
30580
30716
|
if (!dir)
|
|
@@ -30620,7 +30756,7 @@ var abandonedLaunches = (root) => {
|
|
|
30620
30756
|
const found = [];
|
|
30621
30757
|
for (const name of names) {
|
|
30622
30758
|
try {
|
|
30623
|
-
const attempt = JSON.parse(
|
|
30759
|
+
const attempt = JSON.parse(readFileSync14(path48.join(dir, name), "utf8"));
|
|
30624
30760
|
if (typeof attempt.workerId === "string" && typeof attempt.session === "string") {
|
|
30625
30761
|
if (!alive(attempt))
|
|
30626
30762
|
found.push(attempt);
|
|
@@ -30633,17 +30769,17 @@ var cancelHint = (workerId) => `cancel it first: workit_worker {"action":"cancel
|
|
|
30633
30769
|
|
|
30634
30770
|
// packages/workit-core/src/core/cli-locate.ts
|
|
30635
30771
|
import { closeSync as closeSync4, existsSync as existsSync14, openSync as openSync4, readSync as readSync2 } from "node:fs";
|
|
30636
|
-
import
|
|
30772
|
+
import path49 from "node:path";
|
|
30637
30773
|
var LAUNCHER_MARKER = "workit-owned-launcher";
|
|
30638
30774
|
var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
|
|
30639
30775
|
var installRoot = (env, platform = process.platform) => {
|
|
30640
30776
|
if (env.WORKIT_INSTALL_ROOT)
|
|
30641
30777
|
return env.WORKIT_INSTALL_ROOT;
|
|
30642
30778
|
const data = dataDir(env, platform);
|
|
30643
|
-
return platform === "win32" ?
|
|
30779
|
+
return platform === "win32" ? path49.join(data, "install") : data;
|
|
30644
30780
|
};
|
|
30645
|
-
var ownedLauncherPath = (env, platform = process.platform) =>
|
|
30646
|
-
var ownedCurrentEntry = (env, platform = process.platform) =>
|
|
30781
|
+
var ownedLauncherPath = (env, platform = process.platform) => path49.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
|
|
30782
|
+
var ownedCurrentEntry = (env, platform = process.platform) => path49.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
|
|
30647
30783
|
var head = (file) => {
|
|
30648
30784
|
let fd;
|
|
30649
30785
|
try {
|
|
@@ -30670,7 +30806,7 @@ var locateWorkitCli = (options = {}) => {
|
|
|
30670
30806
|
source: "owned-launcher",
|
|
30671
30807
|
command: launcher,
|
|
30672
30808
|
args: [],
|
|
30673
|
-
binDir:
|
|
30809
|
+
binDir: path49.dirname(launcher)
|
|
30674
30810
|
};
|
|
30675
30811
|
const current = ownedCurrentEntry(env, platform);
|
|
30676
30812
|
if (exists(current))
|
|
@@ -30699,7 +30835,7 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
|
|
|
30699
30835
|
if (located.binDir) {
|
|
30700
30836
|
const key = pathKey(env);
|
|
30701
30837
|
const delimiter = platform === "win32" ? ";" : ":";
|
|
30702
|
-
const same = (dir) => platform === "win32" ?
|
|
30838
|
+
const same = (dir) => platform === "win32" ? path49.win32.normalize(dir).toLowerCase() === path49.win32.normalize(located.binDir).toLowerCase() : path49.posix.normalize(dir) === path49.posix.normalize(located.binDir);
|
|
30703
30839
|
const rest = (env[key] ?? "").split(delimiter).filter((dir) => dir && !same(dir));
|
|
30704
30840
|
patch[key] = [located.binDir, ...rest].join(delimiter);
|
|
30705
30841
|
}
|