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