@workit-dev/opencode 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/plugin.js
CHANGED
|
@@ -184,7 +184,7 @@ function define(plugin) {
|
|
|
184
184
|
// packages/workit-core/src/core.ts
|
|
185
185
|
import { spawnSync as spawnSync22 } from "node:child_process";
|
|
186
186
|
import { existsSync as existsSync12, realpathSync as realpathSync8 } from "node:fs";
|
|
187
|
-
import
|
|
187
|
+
import path35 from "node:path";
|
|
188
188
|
|
|
189
189
|
// packages/workit-core/src/core/task-contract.ts
|
|
190
190
|
import { createHash as createHash3, randomUUID } from "node:crypto";
|
|
@@ -11578,6 +11578,22 @@ var retryTransient = (run) => {
|
|
|
11578
11578
|
};
|
|
11579
11579
|
var renameWithRetry = (from, to) => retryTransient(() => fs9.renameSync(from, to));
|
|
11580
11580
|
|
|
11581
|
+
// packages/workit-core/src/core/checkout-leftovers.ts
|
|
11582
|
+
var CHECKOUT_LEFTOVERS = [
|
|
11583
|
+
"workspace.json",
|
|
11584
|
+
"index.json",
|
|
11585
|
+
"tasks",
|
|
11586
|
+
"recovery",
|
|
11587
|
+
"metadata.lock",
|
|
11588
|
+
"store.moved.json",
|
|
11589
|
+
"task-index.json",
|
|
11590
|
+
"checkouts",
|
|
11591
|
+
"blobs",
|
|
11592
|
+
"legacy",
|
|
11593
|
+
"ledger",
|
|
11594
|
+
"keys"
|
|
11595
|
+
];
|
|
11596
|
+
|
|
11581
11597
|
// packages/workit-core/src/store/patch.ts
|
|
11582
11598
|
var isPlainObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11583
11599
|
var equal = (left, right) => {
|
|
@@ -13448,20 +13464,6 @@ var COMPACT_ABOVE = 200;
|
|
|
13448
13464
|
var COMPACT_KEEP = 50;
|
|
13449
13465
|
var AUTO_COMPACT_BYTES = 2 * 1024 * 1024;
|
|
13450
13466
|
var STALE_TEMPORARY_MS = 60 * 60000;
|
|
13451
|
-
var CHECKOUT_LEFTOVERS = [
|
|
13452
|
-
"workspace.json",
|
|
13453
|
-
"index.json",
|
|
13454
|
-
"tasks",
|
|
13455
|
-
"recovery",
|
|
13456
|
-
"metadata.lock",
|
|
13457
|
-
"store.moved.json",
|
|
13458
|
-
"task-index.json",
|
|
13459
|
-
"checkouts",
|
|
13460
|
-
"blobs",
|
|
13461
|
-
"legacy",
|
|
13462
|
-
"ledger",
|
|
13463
|
-
"keys"
|
|
13464
|
-
];
|
|
13465
13467
|
var GENERATED_GITIGNORES = new Set([`*
|
|
13466
13468
|
`, `*
|
|
13467
13469
|
!risk-paths
|
|
@@ -18556,17 +18558,17 @@ var exportDigest = (bundle) => sha256({
|
|
|
18556
18558
|
// packages/workit-core/src/core/route-intent.ts
|
|
18557
18559
|
import { spawnSync as spawnSync17 } from "node:child_process";
|
|
18558
18560
|
import { existsSync as existsSync10 } from "node:fs";
|
|
18559
|
-
import
|
|
18561
|
+
import path30 from "node:path";
|
|
18560
18562
|
|
|
18561
18563
|
// packages/workit-core/src/hooks/raw-git.ts
|
|
18562
18564
|
import { spawnSync as spawnSync16 } from "node:child_process";
|
|
18563
|
-
import { createHash as
|
|
18565
|
+
import { createHash as createHash17 } from "node:crypto";
|
|
18564
18566
|
import fs20 from "node:fs";
|
|
18565
18567
|
import os6 from "node:os";
|
|
18566
|
-
import
|
|
18568
|
+
import path29 from "node:path";
|
|
18567
18569
|
|
|
18568
18570
|
// packages/workit-core/src/autonomy.ts
|
|
18569
|
-
import
|
|
18571
|
+
import path27 from "node:path";
|
|
18570
18572
|
|
|
18571
18573
|
// packages/workit-core/src/core/eval-world.ts
|
|
18572
18574
|
import { existsSync as existsSync9, realpathSync as realpathSync5 } from "node:fs";
|
|
@@ -18598,6 +18600,68 @@ var evalWorldEntry = (cwd) => {
|
|
|
18598
18600
|
}
|
|
18599
18601
|
};
|
|
18600
18602
|
|
|
18603
|
+
// packages/workit-core/src/core/grant-seal.ts
|
|
18604
|
+
import { createHash as createHash15 } from "node:crypto";
|
|
18605
|
+
import { readFileSync as readFileSync10 } from "node:fs";
|
|
18606
|
+
import path26 from "node:path";
|
|
18607
|
+
var SEAL_FILE = "workspaces.json.seal";
|
|
18608
|
+
var SEAL_VERSION = 1;
|
|
18609
|
+
var SEAL_COMMAND = "workit workspace seal";
|
|
18610
|
+
var pick2 = (value, keys) => {
|
|
18611
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
18612
|
+
return;
|
|
18613
|
+
const out = Object.fromEntries(keys.flatMap((key) => {
|
|
18614
|
+
const item = value[key];
|
|
18615
|
+
return item === undefined ? [] : [[key, item]];
|
|
18616
|
+
}));
|
|
18617
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
18618
|
+
};
|
|
18619
|
+
var ENTRY_KEYS = [
|
|
18620
|
+
"name",
|
|
18621
|
+
"glob",
|
|
18622
|
+
"remotes",
|
|
18623
|
+
"vcs",
|
|
18624
|
+
"autonomy",
|
|
18625
|
+
"autoApprove",
|
|
18626
|
+
"defaultEndpoint",
|
|
18627
|
+
"verification",
|
|
18628
|
+
"youtrack"
|
|
18629
|
+
];
|
|
18630
|
+
var sealProjection = (entries) => entries.map((entry) => {
|
|
18631
|
+
const all = pick2(entry, ENTRY_KEYS) ?? {};
|
|
18632
|
+
return pick2({
|
|
18633
|
+
...all,
|
|
18634
|
+
vcs: pick2(all.vcs, ["provider", "account"]),
|
|
18635
|
+
youtrack: pick2(all.youtrack, ["writes"])
|
|
18636
|
+
}, ENTRY_KEYS);
|
|
18637
|
+
});
|
|
18638
|
+
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);
|
|
18639
|
+
var sealDigest = (projection) => createHash15("sha256").update(canonical3(projection)).digest("hex");
|
|
18640
|
+
var broken = (reason, sealed = null) => ({
|
|
18641
|
+
state: "broken",
|
|
18642
|
+
reason,
|
|
18643
|
+
sealed
|
|
18644
|
+
});
|
|
18645
|
+
function checkSeal(dir) {
|
|
18646
|
+
const file = path26.join(dir, SEAL_FILE);
|
|
18647
|
+
let seal;
|
|
18648
|
+
try {
|
|
18649
|
+
seal = JSON.parse(readFileSync10(file, "utf8"));
|
|
18650
|
+
} catch (error) {
|
|
18651
|
+
if (error.code === "ENOENT")
|
|
18652
|
+
return { state: "none" };
|
|
18653
|
+
return broken(`${SEAL_FILE} cannot be read`);
|
|
18654
|
+
}
|
|
18655
|
+
if (seal?.version !== SEAL_VERSION || !Array.isArray(seal.projection) || seal.sha256 !== sealDigest(seal.projection))
|
|
18656
|
+
return broken(`${SEAL_FILE} is malformed`);
|
|
18657
|
+
const sealed = validateWorkspacesDocument({ workspaces: seal.projection }, file);
|
|
18658
|
+
if (sealed.status !== "valid")
|
|
18659
|
+
return broken(`${SEAL_FILE} is malformed`);
|
|
18660
|
+
const current = readWorkspacesResult(dir);
|
|
18661
|
+
const ok = current.status === "valid" || current.status === "missing";
|
|
18662
|
+
return ok && sealDigest(sealProjection(current.entries)) === seal.sha256 ? { state: "valid" } : broken("workspaces.json changed since it was sealed", sealed.entries);
|
|
18663
|
+
}
|
|
18664
|
+
|
|
18601
18665
|
// packages/workit-core/src/autonomy.ts
|
|
18602
18666
|
var grantsHome = { resolve: accountHome };
|
|
18603
18667
|
var accountDir = () => {
|
|
@@ -18607,13 +18671,27 @@ var accountDir = () => {
|
|
|
18607
18671
|
var grantsDir = () => accountDir() ?? resolveConfigDir();
|
|
18608
18672
|
var NO_ACCOUNT = "no OS account record answered (core/account-home.ts), so no grants are read: the D4 defaults apply";
|
|
18609
18673
|
var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
|
|
18610
|
-
var
|
|
18674
|
+
var fileSource = (dir = accountDir()) => ({
|
|
18675
|
+
resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom(cwd, dir, name),
|
|
18676
|
+
entries: () => entriesIn(dir)
|
|
18677
|
+
});
|
|
18678
|
+
var sealedSource = (entries) => ({
|
|
18679
|
+
resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name),
|
|
18680
|
+
entries: () => entries
|
|
18681
|
+
});
|
|
18682
|
+
var sealOf = () => {
|
|
18611
18683
|
const dir = accountDir();
|
|
18612
|
-
return dir === null ?
|
|
18684
|
+
return dir === null ? { state: "none" } : checkSeal(dir);
|
|
18685
|
+
};
|
|
18686
|
+
var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own terminal: ${SEAL_COMMAND}`;
|
|
18687
|
+
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;
|
|
18688
|
+
var youTrackWritesMode = (cwd) => {
|
|
18689
|
+
const youtrack = resolveRuntimeWorkspaceVcs(cwd)?.youtrack;
|
|
18690
|
+
return youtrack && typeof youtrack === "object" && youtrack.writes === "auto" && !sealNote() ? "auto" : "ask";
|
|
18613
18691
|
};
|
|
18614
18692
|
var shownGrantsDir = () => {
|
|
18615
18693
|
const world = evalWorld(process.cwd());
|
|
18616
|
-
return world ?
|
|
18694
|
+
return world ? path27.join(world, "config") : accountDir();
|
|
18617
18695
|
};
|
|
18618
18696
|
var benchWorld = (cwd) => {
|
|
18619
18697
|
const entry = evalWorldEntry(cwd);
|
|
@@ -18637,8 +18715,8 @@ var grantsOverride = () => {
|
|
|
18637
18715
|
const shown = shownGrantsDir();
|
|
18638
18716
|
if (shown === null)
|
|
18639
18717
|
return NO_ACCOUNT;
|
|
18640
|
-
const configured =
|
|
18641
|
-
return configured ===
|
|
18718
|
+
const configured = path27.resolve(resolveConfigDir());
|
|
18719
|
+
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`;
|
|
18642
18720
|
};
|
|
18643
18721
|
var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
|
|
18644
18722
|
var DEFAULT_GRANTS = Object.freeze({
|
|
@@ -18758,13 +18836,13 @@ function autonomyOf(workspace) {
|
|
|
18758
18836
|
verification: verificationOf(workspace)
|
|
18759
18837
|
};
|
|
18760
18838
|
}
|
|
18761
|
-
function capAt(named, where, by, why, main = false) {
|
|
18839
|
+
function capAt(source, named, where, by, why, main = false) {
|
|
18762
18840
|
let folder = null;
|
|
18763
18841
|
let none = "";
|
|
18764
18842
|
try {
|
|
18765
18843
|
if (where instanceof Error)
|
|
18766
18844
|
throw where;
|
|
18767
|
-
folder = autonomyOf(typeof where === "string" ?
|
|
18845
|
+
folder = autonomyOf(typeof where === "string" ? source.resolve(where) : where.entry);
|
|
18768
18846
|
} catch (error) {
|
|
18769
18847
|
none = error.message;
|
|
18770
18848
|
}
|
|
@@ -18807,43 +18885,105 @@ function resolveAutonomy(cwd, target) {
|
|
|
18807
18885
|
const override = world ? null : grantsOverride();
|
|
18808
18886
|
if (override)
|
|
18809
18887
|
return { ...autonomyOf(null), note: override };
|
|
18888
|
+
let resolved;
|
|
18889
|
+
const once = typeof target === "function" ? () => resolved ??= target() : target;
|
|
18890
|
+
const current = resolveWith(fileSource(), cwd, world, once);
|
|
18891
|
+
const seal = sealOf();
|
|
18892
|
+
if (seal.state !== "broken")
|
|
18893
|
+
return current;
|
|
18894
|
+
let sealed = autonomyOf(null);
|
|
18895
|
+
try {
|
|
18896
|
+
if (seal.sealed)
|
|
18897
|
+
sealed = resolveWith(sealedSource(seal.sealed), cwd, world, once);
|
|
18898
|
+
} catch {
|
|
18899
|
+
sealed = null;
|
|
18900
|
+
}
|
|
18901
|
+
return stricter(current, sealed, sealNote(seal));
|
|
18902
|
+
}
|
|
18903
|
+
function resolveWith(source, cwd, world, target) {
|
|
18810
18904
|
const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
18811
|
-
const real =
|
|
18905
|
+
const real = source.resolve(cwd, name);
|
|
18812
18906
|
let autonomy = autonomyOf(real ?? world);
|
|
18813
18907
|
if (!real && world)
|
|
18814
18908
|
autonomy.world = evalWorld(cwd) ?? undefined;
|
|
18815
18909
|
if (name)
|
|
18816
|
-
autonomy = capAt(autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
|
|
18910
|
+
autonomy = capAt(source, autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
|
|
18817
18911
|
const above = checkoutsAbove(cwd);
|
|
18818
18912
|
for (const where of above instanceof Error ? [above] : above)
|
|
18819
|
-
autonomy = capAt(autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
|
|
18820
|
-
return capAtRemotes(autonomy, cwd, target);
|
|
18913
|
+
autonomy = capAt(source, autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
|
|
18914
|
+
return capAtRemotes(source, autonomy, cwd, target);
|
|
18915
|
+
}
|
|
18916
|
+
var needsAccount = (autonomy) => autonomy.configured.length > 0 && !autonomy.accountConfigured;
|
|
18917
|
+
function stricter(current, sealed, note) {
|
|
18918
|
+
const grants = { ...current.grants };
|
|
18919
|
+
const unblocks = { ...current.unblocks };
|
|
18920
|
+
for (const kind of GRANT_KINDS) {
|
|
18921
|
+
const floor = sealed ? sealed.grants[kind] : false;
|
|
18922
|
+
if (!raises(kind, floor, grants[kind]))
|
|
18923
|
+
continue;
|
|
18924
|
+
grants[kind] = floor;
|
|
18925
|
+
unblocks[kind] = SEAL_UNBLOCK;
|
|
18926
|
+
}
|
|
18927
|
+
const configured = GRANT_KINDS.filter((kind) => current.configured.includes(kind) || sealed?.configured.includes(kind));
|
|
18928
|
+
const accountConfigured = !needsAccount(current) && !(sealed && needsAccount(sealed)) && (current.accountConfigured || Boolean(sealed?.accountConfigured));
|
|
18929
|
+
const lower = (a, b) => raisesEndpoint(a, b) ? a : b;
|
|
18930
|
+
const defaultEndpoint = lower(current.defaultEndpoint, sealed?.defaultEndpoint ?? DEFAULT_ENDPOINT);
|
|
18931
|
+
const effective = effectiveEndpoint(defaultEndpoint, {
|
|
18932
|
+
workspace: current.workspace,
|
|
18933
|
+
grants,
|
|
18934
|
+
configured,
|
|
18935
|
+
accountConfigured
|
|
18936
|
+
});
|
|
18937
|
+
const endpoint = lower(lower(effective.endpoint, current.effectiveEndpoint), sealed?.effectiveEndpoint ?? DEFAULT_ENDPOINT);
|
|
18938
|
+
const strict = sealed?.verification ?? "independent";
|
|
18939
|
+
const looser = VERIFICATION_STRICTNESS.indexOf(current.verification) > VERIFICATION_STRICTNESS.indexOf(strict);
|
|
18940
|
+
return {
|
|
18941
|
+
...current,
|
|
18942
|
+
grants,
|
|
18943
|
+
configured,
|
|
18944
|
+
accountConfigured,
|
|
18945
|
+
defaultEndpoint,
|
|
18946
|
+
effectiveEndpoint: endpoint,
|
|
18947
|
+
endpointReason: endpoint === current.effectiveEndpoint ? current.endpointReason : SEAL_UNBLOCK,
|
|
18948
|
+
verification: looser ? strict : current.verification,
|
|
18949
|
+
unblocks,
|
|
18950
|
+
note: current.note ? `${current.note}; ${note}` : note
|
|
18951
|
+
};
|
|
18821
18952
|
}
|
|
18822
|
-
function capAtRemotes(autonomy, cwd, target) {
|
|
18823
|
-
const claiming =
|
|
18953
|
+
function capAtRemotes(source, autonomy, cwd, target) {
|
|
18954
|
+
const claiming = source.entries().filter((entry) => entry.remotes?.length);
|
|
18824
18955
|
if (claiming.length === 0)
|
|
18825
18956
|
return autonomy;
|
|
18826
18957
|
const remotes = target === undefined ? checkoutRemotes(cwd) : typeof target === "function" ? target() : target;
|
|
18827
18958
|
if (remotes instanceof Error)
|
|
18828
|
-
return capAt(autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
|
|
18959
|
+
return capAt(source, autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
|
|
18829
18960
|
let capped = autonomy;
|
|
18830
18961
|
for (const remote of Array.isArray(remotes) ? remotes : remotes.remotes)
|
|
18831
18962
|
for (const entry of claiming) {
|
|
18832
18963
|
const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
|
|
18833
18964
|
if (pattern)
|
|
18834
|
-
capped = capAt(capped, { entry }, `remote ${remote.name} ${remote.url} (workspace ${entry.name} claims ${pattern})`, "a checkout never exceeds the workspace that owns its remote");
|
|
18965
|
+
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");
|
|
18835
18966
|
}
|
|
18836
18967
|
return capped;
|
|
18837
18968
|
}
|
|
18838
|
-
var grantsMatter = (kind) =>
|
|
18839
|
-
|
|
18840
|
-
|
|
18841
|
-
|
|
18842
|
-
|
|
18843
|
-
|
|
18969
|
+
var grantsMatter = (kind) => {
|
|
18970
|
+
if (grantsOverride())
|
|
18971
|
+
return false;
|
|
18972
|
+
const matters = entriesIn(accountDir()).some((entry) => {
|
|
18973
|
+
const autonomy = autonomyOf(entry);
|
|
18974
|
+
return entry.remotes?.length || autonomy.grants[kind] === false || needsAccount(autonomy);
|
|
18975
|
+
});
|
|
18976
|
+
const seal = sealOf();
|
|
18977
|
+
return matters || seal.state === "broken" && (seal.sealed ? seal.sealed.length > 0 : DEFAULT_GRANTS[kind] === false);
|
|
18978
|
+
};
|
|
18979
|
+
var authorityEntries = () => {
|
|
18980
|
+
const seal = sealOf();
|
|
18981
|
+
return [...entriesIn(accountDir()), ...seal.state === "broken" ? seal.sealed ?? [] : []];
|
|
18982
|
+
};
|
|
18983
|
+
function claimsIn(target, entries) {
|
|
18844
18984
|
if (target instanceof Error)
|
|
18845
18985
|
return target;
|
|
18846
|
-
const claiming =
|
|
18986
|
+
const claiming = entries.filter((entry) => entry.remotes?.length);
|
|
18847
18987
|
return target.remotes.flatMap((remote) => claiming.flatMap((entry) => {
|
|
18848
18988
|
const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
|
|
18849
18989
|
return pattern ? [{ url: remote.url, workspace: entry.name, pattern }] : [];
|
|
@@ -18853,7 +18993,8 @@ var suggested = (kind) => kind === "merge" ? "verified" : "true";
|
|
|
18853
18993
|
var accountHint = (workspace) => `set vcs.account for workspace "${workspace ?? "?"}" in ${configFilePath("workspaces.json")}`;
|
|
18854
18994
|
var grantHint = (workspace, kind) => `ask the user to run, in their own terminal: workit grant set ${workspace ?? "<workspace>"} ${kind}=${suggested(kind)}`;
|
|
18855
18995
|
function rawGrantDenial(cwd, kind, target) {
|
|
18856
|
-
const
|
|
18996
|
+
const entries = authorityEntries();
|
|
18997
|
+
const claimed = entries.some((entry) => entry.remotes?.length);
|
|
18857
18998
|
if (!grantsMatter(kind))
|
|
18858
18999
|
return null;
|
|
18859
19000
|
let resolved;
|
|
@@ -18878,14 +19019,10 @@ function rawGrantDenial(cwd, kind, target) {
|
|
|
18878
19019
|
};
|
|
18879
19020
|
if (!claimed || !lazy)
|
|
18880
19021
|
return null;
|
|
18881
|
-
const claims =
|
|
19022
|
+
const claims = claimsIn(lazy(), entries);
|
|
18882
19023
|
if (claims instanceof Error)
|
|
18883
19024
|
return { error: `${kind}: ${claims.message}`, unblock: "name a target workit can resolve" };
|
|
18884
|
-
const
|
|
18885
|
-
const strict = claims.find(({ workspace: name }) => {
|
|
18886
|
-
const entry = entries.find((item) => item.name === name);
|
|
18887
|
-
return entry && autonomyOf(entry).grants[kind] === false;
|
|
18888
|
-
});
|
|
19025
|
+
const strict = claims.find(({ workspace: name }) => entries.some((item) => item.name === name && autonomyOf(item).grants[kind] === false));
|
|
18889
19026
|
return strict ? {
|
|
18890
19027
|
error: `${kind} is not granted for workspace ${strict.workspace}, which claims ${strict.url} (${strict.pattern})`,
|
|
18891
19028
|
unblock: grantHint(strict.workspace, kind)
|
|
@@ -18897,9 +19034,9 @@ var raises = (kind, current, next) => {
|
|
|
18897
19034
|
};
|
|
18898
19035
|
|
|
18899
19036
|
// packages/workit-core/src/hooks/session-marker.ts
|
|
18900
|
-
import { createHash as
|
|
19037
|
+
import { createHash as createHash16 } from "node:crypto";
|
|
18901
19038
|
import fs19 from "node:fs";
|
|
18902
|
-
import
|
|
19039
|
+
import path28 from "node:path";
|
|
18903
19040
|
var sessionMarkerFile = (input, session, store) => {
|
|
18904
19041
|
let dir = store;
|
|
18905
19042
|
if (dir === undefined) {
|
|
@@ -18908,8 +19045,8 @@ var sessionMarkerFile = (input, session, store) => {
|
|
|
18908
19045
|
return null;
|
|
18909
19046
|
dir = location.dir;
|
|
18910
19047
|
}
|
|
18911
|
-
const name =
|
|
18912
|
-
return
|
|
19048
|
+
const name = createHash16("sha256").update(`${input.host}\x00${session}`).digest("hex").slice(0, 32);
|
|
19049
|
+
return path28.join(dir, "hooks", `skills-${name}.json`);
|
|
18913
19050
|
};
|
|
18914
19051
|
var list2 = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
18915
19052
|
var EMPTY = {
|
|
@@ -18944,7 +19081,7 @@ var parseMarker = (text) => {
|
|
|
18944
19081
|
};
|
|
18945
19082
|
var readSessionMarker = (file) => parseMarker(readRaw(file));
|
|
18946
19083
|
var writeAtomic = (file, marker) => {
|
|
18947
|
-
fs19.mkdirSync(
|
|
19084
|
+
fs19.mkdirSync(path28.dirname(file), { recursive: true });
|
|
18948
19085
|
const temp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
18949
19086
|
try {
|
|
18950
19087
|
fs19.writeFileSync(temp, JSON.stringify(marker));
|
|
@@ -19509,14 +19646,14 @@ var GIT_CONFIG_ENV = /^(?:GIT_(?:CONFIG\w*|DIR|COMMON_DIR|WORK_TREE|SSH|SSH_COMM
|
|
|
19509
19646
|
var ASSIGNMENT = /^([A-Za-z_]\w*)=([\s\S]*)$/;
|
|
19510
19647
|
var MAX_DEPTH = 4;
|
|
19511
19648
|
var MAX_EXPANSIONS = 16;
|
|
19512
|
-
var isAbsolute = (value) =>
|
|
19649
|
+
var isAbsolute = (value) => path29.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
|
|
19513
19650
|
var HERE = /^(?:\$PWD|\$\{PWD\}|\$\(\s*pwd\s*\)|`pwd`|\$\(\s*git\s+rev-parse\s+--show-toplevel\s*\))(?=$|[\\/])/;
|
|
19514
19651
|
var joinDir = (base, raw) => {
|
|
19515
19652
|
const next = raw.replace(HERE, ".");
|
|
19516
19653
|
if (base === undefined || /[$`*?]/.test(next) || next === "-")
|
|
19517
19654
|
return;
|
|
19518
|
-
const expanded = next === "~" || next.startsWith("~/") ?
|
|
19519
|
-
return base === null || isAbsolute(expanded) ? expanded :
|
|
19655
|
+
const expanded = next === "~" || next.startsWith("~/") ? path29.join(os6.homedir(), next.slice(1)) : next;
|
|
19656
|
+
return base === null || isAbsolute(expanded) ? expanded : path29.join(base, expanded);
|
|
19520
19657
|
};
|
|
19521
19658
|
var rebase = (base, inner) => inner === null ? base : inner === undefined ? undefined : joinDir(base, inner);
|
|
19522
19659
|
var cdTarget = (words) => {
|
|
@@ -20438,17 +20575,17 @@ var headSha2 = (repo) => {
|
|
|
20438
20575
|
if (!git || git.reftable)
|
|
20439
20576
|
return null;
|
|
20440
20577
|
try {
|
|
20441
|
-
const head = fs20.readFileSync(
|
|
20578
|
+
const head = fs20.readFileSync(path29.join(git.gitDir, "HEAD"), "utf8").trim();
|
|
20442
20579
|
if (/^[0-9a-f]{40,64}$/.test(head))
|
|
20443
20580
|
return head;
|
|
20444
20581
|
const ref = /^ref: (refs\/.+)$/.exec(head)?.[1];
|
|
20445
20582
|
if (!ref)
|
|
20446
20583
|
return null;
|
|
20447
|
-
const common =
|
|
20584
|
+
const common = path29.dirname(repo.location.dir);
|
|
20448
20585
|
try {
|
|
20449
|
-
return fs20.readFileSync(
|
|
20586
|
+
return fs20.readFileSync(path29.join(common, ref), "utf8").trim() || null;
|
|
20450
20587
|
} catch {}
|
|
20451
|
-
const packed = fs20.readFileSync(
|
|
20588
|
+
const packed = fs20.readFileSync(path29.join(common, "packed-refs"), "utf8");
|
|
20452
20589
|
return new RegExp(`^([0-9a-f]{40,64}) ${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`, "m").exec(packed)?.[1] ?? null;
|
|
20453
20590
|
} catch {
|
|
20454
20591
|
return null;
|
|
@@ -20541,7 +20678,7 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
|
|
|
20541
20678
|
const sub = invocation.args[0];
|
|
20542
20679
|
if (invocation.tool !== "git" || invocation.dir === undefined || !sub || sub.startsWith("-") || GIT_COMMANDS.has(sub) || depth >= MAX_DEPTH)
|
|
20543
20680
|
return [invocation];
|
|
20544
|
-
const dir =
|
|
20681
|
+
const dir = path29.resolve(root, invocation.dir ?? ".");
|
|
20545
20682
|
if (!fs20.existsSync(dir))
|
|
20546
20683
|
return [invocation];
|
|
20547
20684
|
const config = gitConfig(dir, invocation, cache);
|
|
@@ -20564,11 +20701,11 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
|
|
|
20564
20701
|
var normalizedUrl = (url, dir) => {
|
|
20565
20702
|
const trimmed = url.trim();
|
|
20566
20703
|
if (/^file:\/\//i.test(trimmed))
|
|
20567
|
-
return
|
|
20704
|
+
return path29.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
|
|
20568
20705
|
const scheme = /^[a-z][a-z0-9+.-]*:\/\//i.exec(trimmed);
|
|
20569
20706
|
const scp = !scheme && /^(?:[^@/\\]+@)?[^/\\:]{2,}:/.test(trimmed);
|
|
20570
20707
|
if (!scheme && !scp)
|
|
20571
|
-
return
|
|
20708
|
+
return path29.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
|
|
20572
20709
|
const value = scheme ? trimmed.slice(scheme[0].length).replace(/^[^@/]*@/, "").replace(/^([^/:]+):\d+(?=\/)/, "$1") : trimmed.replace(/^[^@/]*@/, "").replace(":", "/");
|
|
20573
20710
|
return value.toLowerCase().replace(/\/{2,}/g, "/").replace(/^www\./, "").replace(/\/+$/, "").replace(/\.git$/, "");
|
|
20574
20711
|
};
|
|
@@ -20796,7 +20933,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
|
|
|
20796
20933
|
const out = [];
|
|
20797
20934
|
const repos = new Map;
|
|
20798
20935
|
const repoFor = (relative) => {
|
|
20799
|
-
const dir =
|
|
20936
|
+
const dir = path29.resolve(cwd, relative ?? ".");
|
|
20800
20937
|
if (!repos.has(dir)) {
|
|
20801
20938
|
const repo = repoAt(dir);
|
|
20802
20939
|
const workit = repo !== null && isWorkitWorkspace(repo);
|
|
@@ -20817,7 +20954,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
|
|
|
20817
20954
|
const action = rawAction(invocation);
|
|
20818
20955
|
const at = !action ? null : repoFor(invocation.dir) ?? (all && invocation.tool !== "git" && explicitRepo(invocation.tool === "gh", "repo" in action && action.repo || "", invocation.env ?? {}) ? {
|
|
20819
20956
|
repo: {
|
|
20820
|
-
dir:
|
|
20957
|
+
dir: path29.resolve(cwd, invocation.dir ?? "."),
|
|
20821
20958
|
branch: null
|
|
20822
20959
|
},
|
|
20823
20960
|
workit: false
|
|
@@ -20890,13 +21027,13 @@ var messageOf = (segment, index) => {
|
|
|
20890
21027
|
};
|
|
20891
21028
|
var sameGitDir = (a, b, platform = process.platform) => {
|
|
20892
21029
|
if (platform !== "win32")
|
|
20893
|
-
return
|
|
20894
|
-
const fold = (value) =>
|
|
21030
|
+
return path29.posix.resolve(a) === path29.posix.resolve(b);
|
|
21031
|
+
const fold = (value) => path29.win32.resolve(value).toLowerCase();
|
|
20895
21032
|
return fold(a) === fold(b);
|
|
20896
21033
|
};
|
|
20897
21034
|
var cdCommitCall = (input, command, target, repo) => {
|
|
20898
21035
|
const { top, git, dir: store } = repo.location;
|
|
20899
|
-
if (!top || !git || sameGitDir(git.gitDir,
|
|
21036
|
+
if (!top || !git || sameGitDir(git.gitDir, path29.dirname(store)) || repoAt(input.cwd)?.location.top === top)
|
|
20900
21037
|
return null;
|
|
20901
21038
|
const bare = command.replaceAll(/'[^']*'|"(?:[^"\\]|\\.)*"/gu, "").replaceAll("&&", "");
|
|
20902
21039
|
if (/[;|&<>`$()\n\\]/u.test(bare))
|
|
@@ -20905,7 +21042,7 @@ var cdCommitCall = (input, command, target, repo) => {
|
|
|
20905
21042
|
const commit = rest.at(-1);
|
|
20906
21043
|
if (cd?.words[0] !== "cd" || cd.words.length !== 2 || cd.expands?.length || !commit)
|
|
20907
21044
|
return null;
|
|
20908
|
-
if (
|
|
21045
|
+
if (path29.resolve(input.cwd, cd.words[1]) !== target)
|
|
20909
21046
|
return null;
|
|
20910
21047
|
if (rest.some((each) => each.redirects.length || each.stdin?.length || each.group))
|
|
20911
21048
|
return null;
|
|
@@ -20972,7 +21109,7 @@ var commitRefusal = (input, command, dialect, { action, repo, invocation, workit
|
|
|
20972
21109
|
} catch {}
|
|
20973
21110
|
if (guarded && !switches)
|
|
20974
21111
|
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>")}.`;
|
|
20975
|
-
const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command,
|
|
21112
|
+
const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path29.resolve(input.cwd, invocation.dir), repo);
|
|
20976
21113
|
return call && `workit: no ${quote("cd … &&")} chain; run ${quote(call)}.`;
|
|
20977
21114
|
};
|
|
20978
21115
|
function rawGitPre(input, command, options = {}) {
|
|
@@ -21070,9 +21207,9 @@ var grantRefusal = (action, repo, invocation, cache) => {
|
|
|
21070
21207
|
return null;
|
|
21071
21208
|
};
|
|
21072
21209
|
var localTag = (repo, name) => {
|
|
21073
|
-
const common =
|
|
21210
|
+
const common = path29.dirname(repo.location.dir);
|
|
21074
21211
|
try {
|
|
21075
|
-
return fs20.existsSync(
|
|
21212
|
+
return fs20.existsSync(path29.join(common, "refs/tags", name)) || fs20.readFileSync(path29.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
|
|
21076
21213
|
`);
|
|
21077
21214
|
} catch {
|
|
21078
21215
|
return false;
|
|
@@ -21091,8 +21228,8 @@ var analysisDenial = (error) => ({
|
|
|
21091
21228
|
unblock: SPLIT_IT
|
|
21092
21229
|
});
|
|
21093
21230
|
var MARKER_TTL_SECONDS = 3600;
|
|
21094
|
-
var markerFile = (repo, session, key) =>
|
|
21095
|
-
var callKey = (toolUseId, command) => toolUseId ?? `cmd:${
|
|
21231
|
+
var markerFile = (repo, session, key) => path29.join(repo.location.dir, "hooks", `commit-${createHash17("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
|
|
21232
|
+
var callKey = (toolUseId, command) => toolUseId ?? `cmd:${createHash17("sha256").update(command).digest("hex")}`;
|
|
21096
21233
|
function noteRawCommit(input, command, key) {
|
|
21097
21234
|
try {
|
|
21098
21235
|
if (!input.session.id || !/\bcommit\b/.test(command))
|
|
@@ -21102,7 +21239,7 @@ function noteRawCommit(input, command, key) {
|
|
|
21102
21239
|
if (action.kind !== "commit")
|
|
21103
21240
|
continue;
|
|
21104
21241
|
const file = markerFile(repo, input.session.id, key);
|
|
21105
|
-
fs20.mkdirSync(
|
|
21242
|
+
fs20.mkdirSync(path29.dirname(file), { recursive: true });
|
|
21106
21243
|
fs20.writeFileSync(file, `${JSON.stringify({ head: headSha2(repo), at })}
|
|
21107
21244
|
`);
|
|
21108
21245
|
}
|
|
@@ -21331,7 +21468,7 @@ var judgedDir = (root, dir) => {
|
|
|
21331
21468
|
return null;
|
|
21332
21469
|
if (dir === null)
|
|
21333
21470
|
return root;
|
|
21334
|
-
const resolved =
|
|
21471
|
+
const resolved = path30.resolve(root, dir);
|
|
21335
21472
|
return existsSync10(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
|
|
21336
21473
|
};
|
|
21337
21474
|
var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
|
|
@@ -23328,8 +23465,8 @@ class WorkitCore {
|
|
|
23328
23465
|
}
|
|
23329
23466
|
// packages/workit-core/src/core/repo-context.ts
|
|
23330
23467
|
import { spawnSync as spawnSync18 } from "node:child_process";
|
|
23331
|
-
import { existsSync as existsSync11, readFileSync as
|
|
23332
|
-
import
|
|
23468
|
+
import { existsSync as existsSync11, readFileSync as readFileSync11, readdirSync as readdirSync4 } from "node:fs";
|
|
23469
|
+
import path31 from "node:path";
|
|
23333
23470
|
var isSafeContextRange = (value) => value.length <= 4096 && (() => {
|
|
23334
23471
|
try {
|
|
23335
23472
|
gitRevisionParts(value);
|
|
@@ -23473,13 +23610,13 @@ var findPrTemplate = (cwd) => {
|
|
|
23473
23610
|
for (const rel of PR_TEMPLATE_FILES) {
|
|
23474
23611
|
const parts = rel.split("/");
|
|
23475
23612
|
const base = parts[parts.length - 1];
|
|
23476
|
-
const dir = parts.length > 1 ?
|
|
23613
|
+
const dir = parts.length > 1 ? path31.join(cwd, ...parts.slice(0, -1)) : cwd;
|
|
23477
23614
|
const actual = probeCaseInsensitive(dir, base);
|
|
23478
23615
|
if (actual)
|
|
23479
23616
|
return [...parts.slice(0, -1), actual].join("/");
|
|
23480
23617
|
}
|
|
23481
23618
|
for (const rel of PR_TEMPLATE_DIRS) {
|
|
23482
|
-
const only = singleMarkdown(
|
|
23619
|
+
const only = singleMarkdown(path31.join(cwd, ...rel.split("/")));
|
|
23483
23620
|
if (only)
|
|
23484
23621
|
return `${rel}/${only}`;
|
|
23485
23622
|
}
|
|
@@ -23509,11 +23646,11 @@ var diffStatForRange = (cwd, range) => {
|
|
|
23509
23646
|
return runGit(cwd, ["diff", "--stat", "--"]).stdout;
|
|
23510
23647
|
};
|
|
23511
23648
|
var packageScripts = (cwd, keys) => {
|
|
23512
|
-
const pkgPath =
|
|
23649
|
+
const pkgPath = path31.join(cwd, "package.json");
|
|
23513
23650
|
if (!existsSync11(pkgPath))
|
|
23514
23651
|
return [];
|
|
23515
23652
|
try {
|
|
23516
|
-
const pkg = JSON.parse(
|
|
23653
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
|
|
23517
23654
|
return keys.filter((k) => pkg.scripts && typeof pkg.scripts[k] === "string").map((k) => `${k}: ${pkg.scripts?.[k]}`);
|
|
23518
23655
|
} catch {
|
|
23519
23656
|
return [];
|
|
@@ -23535,9 +23672,9 @@ var documentationFiles = (cwd) => {
|
|
|
23535
23672
|
if (entry.isDirectory()) {
|
|
23536
23673
|
if (excluded.has(entry.name))
|
|
23537
23674
|
continue;
|
|
23538
|
-
walk(
|
|
23675
|
+
walk(path31.join(dir, entry.name), depth + 1);
|
|
23539
23676
|
} else if (entry.isFile() && (entry.name === "README.md" || entry.name.endsWith(".md"))) {
|
|
23540
|
-
matches.push("./" +
|
|
23677
|
+
matches.push("./" + path31.relative(cwd, path31.join(dir, entry.name)).replaceAll("\\", "/"));
|
|
23541
23678
|
}
|
|
23542
23679
|
}
|
|
23543
23680
|
};
|
|
@@ -23547,13 +23684,13 @@ var documentationFiles = (cwd) => {
|
|
|
23547
23684
|
var readTrimmed2 = (file, maxLines) => {
|
|
23548
23685
|
if (!existsSync11(file))
|
|
23549
23686
|
return "";
|
|
23550
|
-
const lines =
|
|
23687
|
+
const lines = readFileSync11(file, "utf8").split(`
|
|
23551
23688
|
`);
|
|
23552
23689
|
return lines.slice(0, maxLines).join(`
|
|
23553
23690
|
`);
|
|
23554
23691
|
};
|
|
23555
23692
|
function prReadyContext(root, range) {
|
|
23556
|
-
const cwd =
|
|
23693
|
+
const cwd = path31.resolve(repoRoot(root));
|
|
23557
23694
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
23558
23695
|
return invalidRange(cwd);
|
|
23559
23696
|
let stdout = "";
|
|
@@ -23611,7 +23748,7 @@ ${status.stderr}` : "");
|
|
|
23611
23748
|
stdout += `template_path: ${template}
|
|
23612
23749
|
|
|
23613
23750
|
`;
|
|
23614
|
-
stdout += readTrimmed2(
|
|
23751
|
+
stdout += readTrimmed2(path31.join(cwd, template), 220);
|
|
23615
23752
|
} else {
|
|
23616
23753
|
stdout += `template_path: none
|
|
23617
23754
|
|
|
@@ -23621,7 +23758,7 @@ ${status.stderr}` : "");
|
|
|
23621
23758
|
stdout += `
|
|
23622
23759
|
`;
|
|
23623
23760
|
stdout += printSection("Recent Validation Signals");
|
|
23624
|
-
if (existsSync11(
|
|
23761
|
+
if (existsSync11(path31.join(cwd, "package.json"))) {
|
|
23625
23762
|
stdout += `package.json detected. Common scripts:
|
|
23626
23763
|
`;
|
|
23627
23764
|
const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
|
|
@@ -23630,7 +23767,7 @@ ${status.stderr}` : "");
|
|
|
23630
23767
|
`) + `
|
|
23631
23768
|
`;
|
|
23632
23769
|
}
|
|
23633
|
-
if (existsSync11(
|
|
23770
|
+
if (existsSync11(path31.join(cwd, "Cargo.toml")) || existsSync11(path31.join(cwd, "src-tauri/Cargo.toml"))) {
|
|
23634
23771
|
stdout += `Rust project detected.
|
|
23635
23772
|
`;
|
|
23636
23773
|
}
|
|
@@ -23663,7 +23800,7 @@ var CHANGELOG_RULES = `- Use an [Unreleased] section.
|
|
|
23663
23800
|
- Apply with the host-native editor, preserving the repository changelog conventions.
|
|
23664
23801
|
- If Unreleased already has duplicate category headings, normalize_only first.`;
|
|
23665
23802
|
function changelogContext(root, range) {
|
|
23666
|
-
const cwd =
|
|
23803
|
+
const cwd = path31.resolve(repoRoot(root));
|
|
23667
23804
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
23668
23805
|
return invalidRange(cwd);
|
|
23669
23806
|
const resolvedRange = rangeArgOrDefault(range, cwd);
|
|
@@ -23681,7 +23818,7 @@ function changelogContext(root, range) {
|
|
|
23681
23818
|
stdout += CHANGELOG_RULES + `
|
|
23682
23819
|
`;
|
|
23683
23820
|
stdout += printSection("Existing CHANGELOG.md");
|
|
23684
|
-
const changelogPath =
|
|
23821
|
+
const changelogPath = path31.join(cwd, "CHANGELOG.md");
|
|
23685
23822
|
if (existsSync11(changelogPath)) {
|
|
23686
23823
|
stdout += readTrimmed2(changelogPath, 260) + `
|
|
23687
23824
|
`;
|
|
@@ -23701,7 +23838,7 @@ function changelogContext(root, range) {
|
|
|
23701
23838
|
return { stdout, stderr: "", exitCode: 0, cwd };
|
|
23702
23839
|
}
|
|
23703
23840
|
function docsRefreshContext(root, range) {
|
|
23704
|
-
const cwd =
|
|
23841
|
+
const cwd = path31.resolve(repoRoot(root));
|
|
23705
23842
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
23706
23843
|
return invalidRange(cwd);
|
|
23707
23844
|
const resolvedRange = rangeArgOrDefault(range, cwd);
|
|
@@ -23723,7 +23860,7 @@ function docsRefreshContext(root, range) {
|
|
|
23723
23860
|
`) + `
|
|
23724
23861
|
`;
|
|
23725
23862
|
stdout += printSection("README Preview");
|
|
23726
|
-
const readme =
|
|
23863
|
+
const readme = path31.join(cwd, "README.md");
|
|
23727
23864
|
if (existsSync11(readme)) {
|
|
23728
23865
|
stdout += readTrimmed2(readme, 220) + `
|
|
23729
23866
|
`;
|
|
@@ -23732,10 +23869,10 @@ function docsRefreshContext(root, range) {
|
|
|
23732
23869
|
`;
|
|
23733
23870
|
}
|
|
23734
23871
|
stdout += printSection("Package Scripts");
|
|
23735
|
-
const pkgPath =
|
|
23872
|
+
const pkgPath = path31.join(cwd, "package.json");
|
|
23736
23873
|
if (existsSync11(pkgPath)) {
|
|
23737
23874
|
try {
|
|
23738
|
-
const pkg = JSON.parse(
|
|
23875
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
|
|
23739
23876
|
stdout += JSON.stringify({ name: pkg.name, version: pkg.version, scripts: pkg.scripts }, null, 2) + `
|
|
23740
23877
|
`;
|
|
23741
23878
|
} catch {}
|
|
@@ -23746,7 +23883,7 @@ function docsRefreshContext(root, range) {
|
|
|
23746
23883
|
return { stdout, stderr: "", exitCode: 0, cwd };
|
|
23747
23884
|
}
|
|
23748
23885
|
function releaseNotesContext(root, rangeOrTag) {
|
|
23749
|
-
const cwd =
|
|
23886
|
+
const cwd = path31.resolve(repoRoot(root));
|
|
23750
23887
|
if (!rangeOrTag) {
|
|
23751
23888
|
return {
|
|
23752
23889
|
stdout: "",
|
|
@@ -23789,7 +23926,7 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
23789
23926
|
`;
|
|
23790
23927
|
stdout += printSection("Existing Release Files");
|
|
23791
23928
|
for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
|
|
23792
|
-
if (existsSync11(
|
|
23929
|
+
if (existsSync11(path31.join(cwd, rel)))
|
|
23793
23930
|
stdout += rel + `
|
|
23794
23931
|
`;
|
|
23795
23932
|
}
|
|
@@ -23821,7 +23958,7 @@ import { spawnSync as spawnSync20 } from "node:child_process";
|
|
|
23821
23958
|
|
|
23822
23959
|
// packages/workit-core/src/core/pr-create.ts
|
|
23823
23960
|
import fs21 from "node:fs";
|
|
23824
|
-
import
|
|
23961
|
+
import path32 from "node:path";
|
|
23825
23962
|
import { spawnSync as spawnSync19 } from "node:child_process";
|
|
23826
23963
|
import { pathToFileURL } from "node:url";
|
|
23827
23964
|
// packages/workit-core/src/forge/pr-body.ts
|
|
@@ -23842,11 +23979,11 @@ var LOCAL = bounded(20000);
|
|
|
23842
23979
|
var NETWORK = bounded(60000);
|
|
23843
23980
|
function whichOnPath(tool) {
|
|
23844
23981
|
const names = process.platform === "win32" ? [tool, `${tool}.exe`, `${tool}.cmd`] : [tool];
|
|
23845
|
-
for (const dir of (process.env.PATH ?? "").split(
|
|
23982
|
+
for (const dir of (process.env.PATH ?? "").split(path32.delimiter)) {
|
|
23846
23983
|
if (!dir)
|
|
23847
23984
|
continue;
|
|
23848
23985
|
for (const name of names) {
|
|
23849
|
-
const candidate =
|
|
23986
|
+
const candidate = path32.join(dir, name);
|
|
23850
23987
|
try {
|
|
23851
23988
|
fs21.accessSync(candidate, fs21.constants.X_OK);
|
|
23852
23989
|
return candidate;
|
|
@@ -23868,7 +24005,7 @@ var pushRemote = (cwd) => {
|
|
|
23868
24005
|
};
|
|
23869
24006
|
var safePushUrl = (remote) => {
|
|
23870
24007
|
const raw = remote.trim();
|
|
23871
|
-
if (
|
|
24008
|
+
if (path32.isAbsolute(raw))
|
|
23872
24009
|
return pathToFileURL(raw).href;
|
|
23873
24010
|
if (!raw.includes("://")) {
|
|
23874
24011
|
const scp = /^(?:([^@\s]+)@)?([^:]+):(.+)$/u.exec(raw);
|
|
@@ -24000,7 +24137,7 @@ var fetchGitLabIssueBody = async (ref, root, deps = {}) => {
|
|
|
24000
24137
|
|
|
24001
24138
|
// packages/workit-core/src/core/youtrack.ts
|
|
24002
24139
|
import fs23 from "node:fs";
|
|
24003
|
-
import
|
|
24140
|
+
import path34 from "node:path";
|
|
24004
24141
|
|
|
24005
24142
|
// packages/workit-core/src/core/templates.ts
|
|
24006
24143
|
var repoRoot2 = assetRoot();
|
|
@@ -24015,7 +24152,7 @@ import { spawnSync as spawnSync21 } from "node:child_process";
|
|
|
24015
24152
|
|
|
24016
24153
|
// packages/workit-core/src/forge/exec.ts
|
|
24017
24154
|
import fs22 from "node:fs";
|
|
24018
|
-
import
|
|
24155
|
+
import path33 from "node:path";
|
|
24019
24156
|
|
|
24020
24157
|
// packages/workit-core/src/forge/redact.ts
|
|
24021
24158
|
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_.-]*`;
|
|
@@ -24030,11 +24167,11 @@ var failure3 = (code, error, unblock) => ({ ok: false, code, error, ...unblock ?
|
|
|
24030
24167
|
// packages/workit-core/src/forge/exec.ts
|
|
24031
24168
|
var MAX_BUFFER2 = 64 * 1024 * 1024;
|
|
24032
24169
|
function findExecutable(bin, env) {
|
|
24033
|
-
const dirs = (env.PATH ?? env.Path ?? "").split(
|
|
24170
|
+
const dirs = (env.PATH ?? env.Path ?? "").split(path33.delimiter).filter(Boolean);
|
|
24034
24171
|
const exts = process.platform === "win32" ? [".exe"] : [""];
|
|
24035
24172
|
for (const dir of dirs)
|
|
24036
24173
|
for (const ext of exts) {
|
|
24037
|
-
const candidate =
|
|
24174
|
+
const candidate = path33.join(dir, `${bin}${ext}`);
|
|
24038
24175
|
try {
|
|
24039
24176
|
const stat = fs22.statSync(candidate);
|
|
24040
24177
|
if (stat.isFile())
|
|
@@ -24146,7 +24283,7 @@ function ytrackReadiness(run, host) {
|
|
|
24146
24283
|
|
|
24147
24284
|
// packages/workit-core/src/core/youtrack.ts
|
|
24148
24285
|
var ISSUE_RE = /^[A-Z][A-Z0-9_]*-\d+$/;
|
|
24149
|
-
var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ??
|
|
24286
|
+
var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path34.join(resolveConfigDir(), "youtrack.json");
|
|
24150
24287
|
var readYouTrackContextConfig = () => {
|
|
24151
24288
|
const cfgPath = youTrackReadOnlyConfigPath();
|
|
24152
24289
|
if (!fs23.existsSync(cfgPath))
|
|
@@ -24521,15 +24658,15 @@ function resolveGitRevision(root, value) {
|
|
|
24521
24658
|
}
|
|
24522
24659
|
function resolveInside(root, candidate) {
|
|
24523
24660
|
const base = realpathSync8(root);
|
|
24524
|
-
const target =
|
|
24525
|
-
if (target !== base && !target.startsWith(base +
|
|
24661
|
+
const target = path35.resolve(base, candidate);
|
|
24662
|
+
if (target !== base && !target.startsWith(base + path35.sep)) {
|
|
24526
24663
|
throw new Error("path must stay inside repository root");
|
|
24527
24664
|
}
|
|
24528
24665
|
let ancestor = target;
|
|
24529
24666
|
while (!existsSync12(ancestor))
|
|
24530
|
-
ancestor =
|
|
24667
|
+
ancestor = path35.dirname(ancestor);
|
|
24531
24668
|
const canonicalAncestor = realpathSync8(ancestor);
|
|
24532
|
-
if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base +
|
|
24669
|
+
if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path35.sep)) {
|
|
24533
24670
|
throw new Error("path must stay inside repository root");
|
|
24534
24671
|
}
|
|
24535
24672
|
return target;
|
|
@@ -24590,7 +24727,7 @@ var capabilitiesFor = (descriptor, observed = {}) => descriptor.capabilities.map
|
|
|
24590
24727
|
};
|
|
24591
24728
|
});
|
|
24592
24729
|
// packages/workit-core/src/hooks/context.ts
|
|
24593
|
-
import
|
|
24730
|
+
import path36 from "node:path";
|
|
24594
24731
|
var MIGRATION_PENDING_NOTE = "workit migration pending — run `workit task status`";
|
|
24595
24732
|
var migrationPending = (result) => !result.ok && result.code === "needs_input" && (result.error ?? "").startsWith(MIGRATION_PENDING);
|
|
24596
24733
|
var boundTo = (entry, session) => entry.sessions.some((item) => item.host === session.host && item.handle === session.handle);
|
|
@@ -24678,7 +24815,7 @@ function entryCompactContext(store, entry, session, context) {
|
|
|
24678
24815
|
current: () => recentSignal(store.root)
|
|
24679
24816
|
};
|
|
24680
24817
|
const observed = task?.data.evidence.some(isObservedCheck) ?? false;
|
|
24681
|
-
const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [
|
|
24818
|
+
const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [path36.resolve(store.root, ref.path)] : []));
|
|
24682
24819
|
const observedFiles = filesKey(files);
|
|
24683
24820
|
const compact = compactContext(store, context, entry?.id ?? null, freshness, origin && { origin: origin.origin, taskId: origin.entry.id });
|
|
24684
24821
|
if (!compact.ok || !compact.data)
|
|
@@ -24779,7 +24916,7 @@ var isAllowedWorkitCommand = (command) => {
|
|
|
24779
24916
|
// packages/workit-core/src/core/heavy-rules.ts
|
|
24780
24917
|
import fs24 from "node:fs";
|
|
24781
24918
|
import os7 from "node:os";
|
|
24782
|
-
import
|
|
24919
|
+
import path37 from "node:path";
|
|
24783
24920
|
var EMPTY2 = () => ({ deny: [], allow: [] });
|
|
24784
24921
|
var readText3 = (file) => {
|
|
24785
24922
|
try {
|
|
@@ -24820,19 +24957,19 @@ function parseJsonc(text) {
|
|
|
24820
24957
|
return JSON.parse(out.replace(/,(\s*[}\]])/gu, "$1"));
|
|
24821
24958
|
}
|
|
24822
24959
|
function gitTop(cwd) {
|
|
24823
|
-
for (let dir =
|
|
24824
|
-
if (fs24.existsSync(
|
|
24960
|
+
for (let dir = path37.resolve(cwd);; dir = path37.dirname(dir)) {
|
|
24961
|
+
if (fs24.existsSync(path37.join(dir, ".git")))
|
|
24825
24962
|
return dir;
|
|
24826
|
-
if (
|
|
24963
|
+
if (path37.dirname(dir) === dir)
|
|
24827
24964
|
return null;
|
|
24828
24965
|
}
|
|
24829
24966
|
}
|
|
24830
24967
|
var projectDirs = (cwd) => {
|
|
24831
24968
|
const top = gitTop(cwd);
|
|
24832
24969
|
const dirs = [];
|
|
24833
|
-
for (let dir =
|
|
24970
|
+
for (let dir = path37.resolve(cwd);; dir = path37.dirname(dir)) {
|
|
24834
24971
|
dirs.push(dir);
|
|
24835
|
-
if (!top || dir === top ||
|
|
24972
|
+
if (!top || dir === top || path37.dirname(dir) === dir)
|
|
24836
24973
|
return dirs;
|
|
24837
24974
|
}
|
|
24838
24975
|
};
|
|
@@ -24844,12 +24981,12 @@ var CLAUDE_MANAGED = {
|
|
|
24844
24981
|
};
|
|
24845
24982
|
function claudeSettingsFiles(cwd, env, platform = process.platform) {
|
|
24846
24983
|
const project = env.CLAUDE_PROJECT_DIR || gitTop(cwd) || cwd;
|
|
24847
|
-
const user = env.CLAUDE_CONFIG_DIR ||
|
|
24984
|
+
const user = env.CLAUDE_CONFIG_DIR || path37.join(homeOf(env), ".claude");
|
|
24848
24985
|
return [
|
|
24849
24986
|
...CLAUDE_MANAGED[platform] ? [CLAUDE_MANAGED[platform]] : [],
|
|
24850
|
-
|
|
24851
|
-
|
|
24852
|
-
|
|
24987
|
+
path37.join(user, "settings.json"),
|
|
24988
|
+
path37.join(project, ".claude", "settings.json"),
|
|
24989
|
+
path37.join(project, ".claude", "settings.local.json")
|
|
24853
24990
|
];
|
|
24854
24991
|
}
|
|
24855
24992
|
var bashPattern = (entry) => {
|
|
@@ -24939,10 +25076,10 @@ var opencodeConfig = (value, rules) => {
|
|
|
24939
25076
|
function opencodeRules(cwd, env = process.env) {
|
|
24940
25077
|
const rules = EMPTY2();
|
|
24941
25078
|
try {
|
|
24942
|
-
const config = env.XDG_CONFIG_HOME ||
|
|
25079
|
+
const config = env.XDG_CONFIG_HOME || path37.join(homeOf(env), ".config");
|
|
24943
25080
|
const files = [
|
|
24944
|
-
...OPENCODE_NAMES.map((name) =>
|
|
24945
|
-
...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [
|
|
25081
|
+
...OPENCODE_NAMES.map((name) => path37.join(config, "opencode", name)),
|
|
25082
|
+
...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [path37.join(dir, name), path37.join(dir, ".opencode", name)])),
|
|
24946
25083
|
...env.OPENCODE_CONFIG ? [env.OPENCODE_CONFIG] : []
|
|
24947
25084
|
];
|
|
24948
25085
|
for (const file of files) {
|
|
@@ -24986,9 +25123,9 @@ var codexRule = (body) => {
|
|
|
24986
25123
|
function codexRules(cwd, env = process.env) {
|
|
24987
25124
|
const rules = EMPTY2();
|
|
24988
25125
|
try {
|
|
24989
|
-
const home = env.CODEX_HOME ||
|
|
25126
|
+
const home = env.CODEX_HOME || path37.join(homeOf(env), ".codex");
|
|
24990
25127
|
const top = gitTop(cwd) ?? cwd;
|
|
24991
|
-
for (const dir of [
|
|
25128
|
+
for (const dir of [path37.join(home, "rules"), path37.join(top, ".codex", "rules")]) {
|
|
24992
25129
|
let files;
|
|
24993
25130
|
try {
|
|
24994
25131
|
files = fs24.readdirSync(dir).filter((name) => name.endsWith(".rules"));
|
|
@@ -24998,7 +25135,7 @@ function codexRules(cwd, env = process.env) {
|
|
|
24998
25135
|
return "unreadable";
|
|
24999
25136
|
}
|
|
25000
25137
|
for (const name of files) {
|
|
25001
|
-
const text = readText3(
|
|
25138
|
+
const text = readText3(path37.join(dir, name)) ?? "";
|
|
25002
25139
|
for (const part of text.split(/\bprefix_rule\s*\(/u).slice(1)) {
|
|
25003
25140
|
const rule = codexRule(part);
|
|
25004
25141
|
if (!rule)
|
|
@@ -25017,8 +25154,8 @@ function cursorRules(cwd, env = process.env) {
|
|
|
25017
25154
|
try {
|
|
25018
25155
|
const top = gitTop(cwd) ?? cwd;
|
|
25019
25156
|
for (const file of [
|
|
25020
|
-
|
|
25021
|
-
|
|
25157
|
+
path37.join(homeOf(env), ".cursor", "cli-config.json"),
|
|
25158
|
+
path37.join(top, ".cursor", "cli.json")
|
|
25022
25159
|
]) {
|
|
25023
25160
|
const text = readText3(file);
|
|
25024
25161
|
if (text === null)
|
|
@@ -25093,10 +25230,10 @@ function wrapAllowed(read, words, command, options = {}) {
|
|
|
25093
25230
|
|
|
25094
25231
|
// packages/workit-core/src/core/heavy.ts
|
|
25095
25232
|
import fs25 from "node:fs";
|
|
25096
|
-
import
|
|
25233
|
+
import path38 from "node:path";
|
|
25097
25234
|
var stateDir2 = (env, platform = process.platform) => stateDir(env, platform);
|
|
25098
25235
|
var HEAVY_COMMANDS_FILE = "heavy-commands.json";
|
|
25099
|
-
var heavyCommandsFile = (env) =>
|
|
25236
|
+
var heavyCommandsFile = (env) => path38.join(stateDir2(env), HEAVY_COMMANDS_FILE);
|
|
25100
25237
|
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;
|
|
25101
25238
|
var INFO_FLAGS = new Set(["--version", "-v", "-V", "--help", "-h", "help", "version"]);
|
|
25102
25239
|
var WATCH_FLAG = /^(?:--watch(?:All)?(?:=.*)?|-w|--serve)$/u;
|
|
@@ -25371,7 +25508,7 @@ function machinePatterns(env) {
|
|
|
25371
25508
|
return isRecord5(value) ? stringList(value.patterns) : [];
|
|
25372
25509
|
}
|
|
25373
25510
|
function repoPatterns(cwd) {
|
|
25374
|
-
return repoHeavyCommands(gitTop(cwd) ??
|
|
25511
|
+
return repoHeavyCommands(gitTop(cwd) ?? path38.resolve(cwd));
|
|
25375
25512
|
}
|
|
25376
25513
|
function heavyLines(lines, options) {
|
|
25377
25514
|
const found = [];
|
|
@@ -25449,12 +25586,12 @@ function heavyPlan(command, options) {
|
|
|
25449
25586
|
}
|
|
25450
25587
|
function workitOnPath2(env = process.env) {
|
|
25451
25588
|
const names = process.platform === "win32" ? ["workit.exe", "workit.cmd", "workit"] : ["workit"];
|
|
25452
|
-
for (const dir of (env.PATH ?? "").split(
|
|
25589
|
+
for (const dir of (env.PATH ?? "").split(path38.delimiter))
|
|
25453
25590
|
for (const name of names) {
|
|
25454
25591
|
if (!dir)
|
|
25455
25592
|
continue;
|
|
25456
25593
|
try {
|
|
25457
|
-
fs25.accessSync(
|
|
25594
|
+
fs25.accessSync(path38.join(dir, name), fs25.constants.X_OK);
|
|
25458
25595
|
return true;
|
|
25459
25596
|
} catch {}
|
|
25460
25597
|
}
|
|
@@ -25472,7 +25609,7 @@ function leaseRewrite(command) {
|
|
|
25472
25609
|
|
|
25473
25610
|
// packages/workit-core/src/core/heavy-words.ts
|
|
25474
25611
|
import fs26 from "node:fs";
|
|
25475
|
-
import
|
|
25612
|
+
import path39 from "node:path";
|
|
25476
25613
|
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(" "));
|
|
25477
25614
|
var wordsOf = (command) => command.split(/[\s;&|()<>`'"]+/u).map((word) => (word.split(/[\\/]/u).at(-1) ?? "").toLowerCase().replace(/\.(?:exe|cmd|bat)$/u, "")).filter(Boolean);
|
|
25478
25615
|
var stateDir3 = (env) => stateDir(env);
|
|
@@ -25485,15 +25622,15 @@ var readJson2 = (file) => {
|
|
|
25485
25622
|
};
|
|
25486
25623
|
var patternWords = (cwd, env) => {
|
|
25487
25624
|
const patterns = [];
|
|
25488
|
-
const machine = readJson2(
|
|
25625
|
+
const machine = readJson2(path39.join(stateDir3(env), "heavy-commands.json"));
|
|
25489
25626
|
if (Array.isArray(machine?.patterns))
|
|
25490
25627
|
patterns.push(...machine.patterns);
|
|
25491
|
-
for (let dir =
|
|
25492
|
-
if (fs26.existsSync(
|
|
25628
|
+
for (let dir = path39.resolve(cwd);; dir = path39.dirname(dir)) {
|
|
25629
|
+
if (fs26.existsSync(path39.join(dir, ".git"))) {
|
|
25493
25630
|
patterns.push(...repoHeavyCommands(dir));
|
|
25494
25631
|
break;
|
|
25495
25632
|
}
|
|
25496
|
-
if (
|
|
25633
|
+
if (path39.dirname(dir) === dir)
|
|
25497
25634
|
break;
|
|
25498
25635
|
}
|
|
25499
25636
|
const words = new Set;
|
|
@@ -25556,16 +25693,16 @@ function heavyGate(cwd, command, options) {
|
|
|
25556
25693
|
}
|
|
25557
25694
|
}
|
|
25558
25695
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
25559
|
-
import { existsSync as existsSync13, readdirSync as readdirSync5, readFileSync as
|
|
25696
|
+
import { existsSync as existsSync13, readdirSync as readdirSync5, readFileSync as readFileSync12, realpathSync as realpathSync9, statSync as statSync5 } from "node:fs";
|
|
25560
25697
|
import os9 from "node:os";
|
|
25561
|
-
import
|
|
25698
|
+
import path41 from "node:path";
|
|
25562
25699
|
|
|
25563
25700
|
// packages/workit-core/src/core/live-session.ts
|
|
25564
25701
|
import { spawnSync as spawnSync23 } from "node:child_process";
|
|
25565
|
-
import { createHash as
|
|
25702
|
+
import { createHash as createHash18 } from "node:crypto";
|
|
25566
25703
|
import fs27 from "node:fs";
|
|
25567
25704
|
import os8 from "node:os";
|
|
25568
|
-
import
|
|
25705
|
+
import path40 from "node:path";
|
|
25569
25706
|
var LIVE_SESSION_TTL_MS = 15 * 60000;
|
|
25570
25707
|
var HEARTBEAT_EVERY_MS = 30000;
|
|
25571
25708
|
var liveProbe = {
|
|
@@ -25639,15 +25776,15 @@ var liveOwner = (input, transport, env = process.env) => {
|
|
|
25639
25776
|
};
|
|
25640
25777
|
};
|
|
25641
25778
|
var checkoutOf = (target) => {
|
|
25642
|
-
let dir =
|
|
25643
|
-
while (!fs27.existsSync(dir) &&
|
|
25644
|
-
dir =
|
|
25779
|
+
let dir = path40.resolve(target);
|
|
25780
|
+
while (!fs27.existsSync(dir) && path40.dirname(dir) !== dir)
|
|
25781
|
+
dir = path40.dirname(dir);
|
|
25645
25782
|
if (fs27.existsSync(dir) && !fs27.statSync(dir).isDirectory())
|
|
25646
|
-
dir =
|
|
25647
|
-
const parts = dir.split(
|
|
25783
|
+
dir = path40.dirname(dir);
|
|
25784
|
+
const parts = dir.split(path40.sep);
|
|
25648
25785
|
const dotGit = parts.lastIndexOf(".git");
|
|
25649
25786
|
if (dotGit > 0)
|
|
25650
|
-
dir = parts.slice(0, dotGit).join(
|
|
25787
|
+
dir = parts.slice(0, dotGit).join(path40.sep) || path40.sep;
|
|
25651
25788
|
const location = resolveStore(dir);
|
|
25652
25789
|
if (location instanceof Error || !location.shared || !location.top)
|
|
25653
25790
|
return null;
|
|
@@ -25657,9 +25794,9 @@ var checkoutOf = (target) => {
|
|
|
25657
25794
|
} catch {}
|
|
25658
25795
|
return top;
|
|
25659
25796
|
};
|
|
25660
|
-
var markerFile2 = (top) =>
|
|
25797
|
+
var markerFile2 = (top) => path40.join(resolveStateDir(), "live-sessions", `${createHash18("sha256").update(checkoutKey(top)).digest("hex").slice(0, 32)}.json`);
|
|
25661
25798
|
var checkoutKey = (top, platform = process.platform) => {
|
|
25662
|
-
let key =
|
|
25799
|
+
let key = path40.resolve(top);
|
|
25663
25800
|
try {
|
|
25664
25801
|
key = fs27.realpathSync.native(key);
|
|
25665
25802
|
} catch {}
|
|
@@ -25754,7 +25891,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
|
|
|
25754
25891
|
checkout,
|
|
25755
25892
|
heartbeatAt: now.toISOString()
|
|
25756
25893
|
};
|
|
25757
|
-
fs27.mkdirSync(
|
|
25894
|
+
fs27.mkdirSync(path40.dirname(file), { recursive: true });
|
|
25758
25895
|
const temp = `${file}.${process.pid}.tmp`;
|
|
25759
25896
|
fs27.writeFileSync(temp, JSON.stringify(marker));
|
|
25760
25897
|
fs27.renameSync(temp, file);
|
|
@@ -25764,24 +25901,24 @@ var claimLiveSession = (target, owner, deps = {}) => {
|
|
|
25764
25901
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
25765
25902
|
var NONE3 = { kind: "none" };
|
|
25766
25903
|
var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
|
|
25767
|
-
var
|
|
25904
|
+
var canonical4 = (file) => {
|
|
25768
25905
|
let rest = "";
|
|
25769
|
-
for (let dir =
|
|
25906
|
+
for (let dir = path41.resolve(file);; dir = path41.dirname(dir)) {
|
|
25770
25907
|
try {
|
|
25771
|
-
return
|
|
25908
|
+
return path41.join(realpathSync9.native(dir), rest);
|
|
25772
25909
|
} catch {
|
|
25773
|
-
if (
|
|
25774
|
-
return
|
|
25775
|
-
rest = rest ?
|
|
25910
|
+
if (path41.dirname(dir) === dir)
|
|
25911
|
+
return path41.resolve(file);
|
|
25912
|
+
rest = rest ? path41.join(path41.basename(dir), rest) : path41.basename(dir);
|
|
25776
25913
|
}
|
|
25777
25914
|
}
|
|
25778
25915
|
};
|
|
25779
25916
|
var exempt = (cwd, root, file, plans) => {
|
|
25780
25917
|
const fold = (value) => CASE_INSENSITIVE ? value.toLowerCase() : value;
|
|
25781
|
-
const relative =
|
|
25782
|
-
if (relative.startsWith("..") ||
|
|
25918
|
+
const relative = path41.relative(fold(canonical4(root)), fold(canonical4(path41.resolve(cwd, file))));
|
|
25919
|
+
if (relative.startsWith("..") || path41.isAbsolute(relative))
|
|
25783
25920
|
return true;
|
|
25784
|
-
const posix = relative.split(
|
|
25921
|
+
const posix = relative.split(path41.sep).join("/");
|
|
25785
25922
|
const segments = posix.split("/");
|
|
25786
25923
|
return /\.mdx?$/i.test(posix) || segments[0] === "docs" || segments.includes("plans") || [...plans].some((plan) => fold(plan) === posix);
|
|
25787
25924
|
};
|
|
@@ -25897,8 +26034,8 @@ var WRAPPERS2 = {
|
|
|
25897
26034
|
bunx: "p"
|
|
25898
26035
|
};
|
|
25899
26036
|
var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php|tsx|ts-node)$/;
|
|
25900
|
-
var isConfigDir = (file) => configDirs().some((dir) =>
|
|
25901
|
-
var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test(
|
|
26037
|
+
var isConfigDir = (file) => configDirs().some((dir) => canonical4(dir) === canonical4(file));
|
|
26038
|
+
var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test(path41.relative(canonical4(resolveStateDir()), canonical4(file)));
|
|
25902
26039
|
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)$/;
|
|
25903
26040
|
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)$/;
|
|
25904
26041
|
var PATH_CALLS = /^(?:join|resolve|normalize|abspath|expanduser|expandvars|Path|PurePath|fspath)$/;
|
|
@@ -26209,10 +26346,10 @@ var linkSources = (args, at) => {
|
|
|
26209
26346
|
const sources = names.filter((name, index) => into >= 0 ? name !== dest : index < names.length - 1 || names.length === 1);
|
|
26210
26347
|
const target = dest === undefined ? null : at(dest);
|
|
26211
26348
|
const symbolic = args.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg));
|
|
26212
|
-
const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync13(target) || /[\\/]$/.test(dest ?? "") ? target :
|
|
26349
|
+
const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync13(target) || /[\\/]$/.test(dest ?? "") ? target : path41.dirname(target);
|
|
26213
26350
|
return sources.flatMap((source) => {
|
|
26214
|
-
if (symbolic && base !== null && !
|
|
26215
|
-
return [
|
|
26351
|
+
if (symbolic && base !== null && !path41.isAbsolute(homeExpanded(source)))
|
|
26352
|
+
return [path41.resolve(base, source)];
|
|
26216
26353
|
const resolved = at(source);
|
|
26217
26354
|
return resolved ? [resolved] : [];
|
|
26218
26355
|
});
|
|
@@ -26241,7 +26378,7 @@ var shellWrites = (command, depth = 0) => {
|
|
|
26241
26378
|
return { writes: true, targets: unknown ? null : targets };
|
|
26242
26379
|
};
|
|
26243
26380
|
var cache3 = new Map;
|
|
26244
|
-
var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(
|
|
26381
|
+
var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path41.resolve(root, file)) ?? "-").join("\x00");
|
|
26245
26382
|
var gateFor = (cwd) => {
|
|
26246
26383
|
const store = new TaskReader(cwd);
|
|
26247
26384
|
const listed = store.listTaskIndex();
|
|
@@ -26321,13 +26458,13 @@ var gitMutationDirs = (cwd, command, dialect) => {
|
|
|
26321
26458
|
return [];
|
|
26322
26459
|
if (sub === "stash" && ["list", "show"].includes(rest[0] ?? ""))
|
|
26323
26460
|
return [];
|
|
26324
|
-
return [
|
|
26461
|
+
return [path41.resolve(cwd, invocation.dir ?? ".")];
|
|
26325
26462
|
});
|
|
26326
26463
|
};
|
|
26327
26464
|
var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
|
|
26328
26465
|
var PUSHD2 = new Set(["pushd", "push-location"]);
|
|
26329
26466
|
var POPD2 = new Set(["popd", "pop-location"]);
|
|
26330
|
-
var UNKNOWN_DIR =
|
|
26467
|
+
var UNKNOWN_DIR = path41.resolve(path41.parse(process.cwd()).root, ".workit-unknown-dir");
|
|
26331
26468
|
var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
|
|
26332
26469
|
const lost = strict ? UNKNOWN_DIR : undefined;
|
|
26333
26470
|
const found = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
|
|
@@ -26337,7 +26474,7 @@ var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
|
|
|
26337
26474
|
return lost;
|
|
26338
26475
|
if (dir === undefined)
|
|
26339
26476
|
return lost;
|
|
26340
|
-
return target === undefined ? os9.homedir() :
|
|
26477
|
+
return target === undefined ? os9.homedir() : path41.resolve(dir, target);
|
|
26341
26478
|
};
|
|
26342
26479
|
var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
|
|
26343
26480
|
var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
|
|
@@ -26472,7 +26609,7 @@ var untrustedVars = (segments) => {
|
|
|
26472
26609
|
}
|
|
26473
26610
|
return { all, names };
|
|
26474
26611
|
};
|
|
26475
|
-
var UNKNOWN_VAR =
|
|
26612
|
+
var UNKNOWN_VAR = path41.resolve(path41.parse(process.cwd()).root, ".workit-unknown-var");
|
|
26476
26613
|
var REFERENCE = /\$\{(\w+)[^}]*\}|\$(\w+)|\$\([^)]*\)?|`[^`]*`?/g;
|
|
26477
26614
|
var unresolvedRefs = (text) => [
|
|
26478
26615
|
...new Set([...text.matchAll(REFERENCE)].map((match) => {
|
|
@@ -26482,7 +26619,7 @@ var unresolvedRefs = (text) => [
|
|
|
26482
26619
|
];
|
|
26483
26620
|
var unknownVarTarget = (text) => {
|
|
26484
26621
|
const refs = unresolvedRefs(text);
|
|
26485
|
-
return
|
|
26622
|
+
return path41.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
|
|
26486
26623
|
};
|
|
26487
26624
|
var applyOperator = (value, operator) => {
|
|
26488
26625
|
if (operator === "")
|
|
@@ -26543,12 +26680,12 @@ var mktempPath = (value, dir) => {
|
|
|
26543
26680
|
if (base === null && (temp || template === undefined))
|
|
26544
26681
|
base = os9.tmpdir();
|
|
26545
26682
|
const name = homeExpanded(template ?? "tmp.XXXXXXXXXX");
|
|
26546
|
-
if (
|
|
26683
|
+
if (path41.isAbsolute(name))
|
|
26547
26684
|
return name;
|
|
26548
26685
|
const from = base === null ? dir : homeExpanded(base);
|
|
26549
|
-
if (from === undefined || !
|
|
26686
|
+
if (from === undefined || !path41.isAbsolute(from) && dir === undefined)
|
|
26550
26687
|
return null;
|
|
26551
|
-
return
|
|
26688
|
+
return path41.resolve(dir ?? from, from, name);
|
|
26552
26689
|
};
|
|
26553
26690
|
var homeExpanded = (file) => {
|
|
26554
26691
|
const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
|
|
@@ -26569,9 +26706,9 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26569
26706
|
const home = homeExpanded(text);
|
|
26570
26707
|
if (strict && unresolvedRefs(home).length > 0)
|
|
26571
26708
|
return [unknownVarTarget(home)];
|
|
26572
|
-
if (
|
|
26709
|
+
if (path41.isAbsolute(home))
|
|
26573
26710
|
return [home];
|
|
26574
|
-
return base === undefined ? [] : [
|
|
26711
|
+
return base === undefined ? [] : [path41.resolve(base, home)];
|
|
26575
26712
|
});
|
|
26576
26713
|
const at = (file) => {
|
|
26577
26714
|
const all = atAll(file);
|
|
@@ -26719,7 +26856,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26719
26856
|
return [made];
|
|
26720
26857
|
try {
|
|
26721
26858
|
const stat = statSync5(script);
|
|
26722
|
-
const text = stat.isFile() && stat.size <= 262144 ?
|
|
26859
|
+
const text = stat.isFile() && stat.size <= 262144 ? readFileSync12(script, "utf8") : "\x00";
|
|
26723
26860
|
return text.includes("\x00") ? [] : [text];
|
|
26724
26861
|
} catch {
|
|
26725
26862
|
return [];
|
|
@@ -26762,7 +26899,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26762
26899
|
index
|
|
26763
26900
|
}));
|
|
26764
26901
|
const homes = /homedir\(|expanduser\(|Path\.home\(|['"]HOME['"]|env\.HOME|\$HOME|~/.test(text);
|
|
26765
|
-
const under = (word) => homes ? [
|
|
26902
|
+
const under = (word) => homes ? [path41.join(homeExpanded("~"), word.replace(/^~/, ""))] : [];
|
|
26766
26903
|
const found = [
|
|
26767
26904
|
...[...text.matchAll(PATHS)].flatMap(({ 0: word, index }) => [...atAll(word), ...under(word)].map((file) => ({ file, index }))),
|
|
26768
26905
|
...joined.flatMap(({ word, index }) => under(word).map((file) => ({ file, index })))
|
|
@@ -26801,7 +26938,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26801
26938
|
for (const file of opaque ?? [])
|
|
26802
26939
|
for (const resolved of atAll(file))
|
|
26803
26940
|
if (!quiet || !isRoot(resolved))
|
|
26804
|
-
targets.push(file === "." ?
|
|
26941
|
+
targets.push(file === "." ? path41.join(resolved, here) : resolved);
|
|
26805
26942
|
const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
|
|
26806
26943
|
const lnArgs = words.slice(ln + 1);
|
|
26807
26944
|
if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)) && (strict !== "registry" || !lnArgs.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg))))
|
|
@@ -26813,7 +26950,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26813
26950
|
const edits = editsOf(body);
|
|
26814
26951
|
if (edits === null) {
|
|
26815
26952
|
if (dir !== undefined)
|
|
26816
|
-
targets.push(
|
|
26953
|
+
targets.push(path41.join(dir, DIR_TARGET));
|
|
26817
26954
|
} else
|
|
26818
26955
|
for (const file of edits)
|
|
26819
26956
|
targets.push(...atAll(file));
|
|
@@ -26821,7 +26958,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26821
26958
|
for (const invocation of workitInvocations(body.map(quoteWord2).join(" "), "posix")) {
|
|
26822
26959
|
const { at: runsIn, args } = workitCwd(dir, invocation, atAll);
|
|
26823
26960
|
if (args[0] === "git" && MUTATING_WORKIT_GIT.has(args[1] ?? "") && !inert(args.slice(2), ""))
|
|
26824
|
-
targets.push(...runsIn.map((runs) =>
|
|
26961
|
+
targets.push(...runsIn.map((runs) => path41.join(runs, DIR_TARGET)));
|
|
26825
26962
|
}
|
|
26826
26963
|
}
|
|
26827
26964
|
return targets;
|
|
@@ -26843,7 +26980,7 @@ var shellMutationTargets = (cwd, command, dialect = "posix", strict = false) =>
|
|
|
26843
26980
|
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]] ?? ""]) : []);
|
|
26844
26981
|
return [
|
|
26845
26982
|
...segmentTargets(cwd, command, dialect, 0, strict, env),
|
|
26846
|
-
...gitMutationDirs(cwd, command, dialect).map((dir) =>
|
|
26983
|
+
...gitMutationDirs(cwd, command, dialect).map((dir) => path41.join(dir, DIR_TARGET))
|
|
26847
26984
|
];
|
|
26848
26985
|
} catch (error) {
|
|
26849
26986
|
if (strict === "registry")
|
|
@@ -26882,7 +27019,7 @@ var liveDeny = ({ marker, checkout, ageMs, file }) => {
|
|
|
26882
27019
|
var guarded = (targets) => {
|
|
26883
27020
|
const seen = new Set;
|
|
26884
27021
|
return targets.filter((target) => {
|
|
26885
|
-
const dir =
|
|
27022
|
+
const dir = path41.dirname(target);
|
|
26886
27023
|
if (seen.has(dir))
|
|
26887
27024
|
return false;
|
|
26888
27025
|
seen.add(dir);
|
|
@@ -26903,15 +27040,16 @@ var claimAll = (owner, targets, deps) => {
|
|
|
26903
27040
|
for (const target of guarded(targets))
|
|
26904
27041
|
claimLiveSession(target, owner, deps);
|
|
26905
27042
|
};
|
|
26906
|
-
var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) =>
|
|
27043
|
+
var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path41.resolve(cwd, file)) : [path41.join(cwd, DIR_TARGET)];
|
|
27044
|
+
var CONFIG_FILES = ["workspaces.json", SEAL_FILE];
|
|
26907
27045
|
var configDirs = () => [resolveConfigDir(), grantsDir()];
|
|
26908
27046
|
var globbed = (cwd, target, state, configs) => {
|
|
26909
27047
|
if (!/[*?[]/.test(target))
|
|
26910
27048
|
return [];
|
|
26911
|
-
const raw =
|
|
27049
|
+
const raw = path41.resolve(cwd, target).split(path41.sep);
|
|
26912
27050
|
const literal = raw.findIndex((part) => /[*?[]/.test(part));
|
|
26913
27051
|
const pattern = [
|
|
26914
|
-
...
|
|
27052
|
+
...canonical4(raw.slice(0, literal).join(path41.sep) || path41.sep).replace(/[\\/]+$/, "").split(path41.sep),
|
|
26915
27053
|
...raw.slice(literal)
|
|
26916
27054
|
];
|
|
26917
27055
|
const segment = (glob, name) => {
|
|
@@ -26922,7 +27060,7 @@ var globbed = (cwd, target, state, configs) => {
|
|
|
26922
27060
|
}
|
|
26923
27061
|
};
|
|
26924
27062
|
const hit = (file, below) => {
|
|
26925
|
-
const parts =
|
|
27063
|
+
const parts = canonical4(file).split(path41.sep);
|
|
26926
27064
|
return (below ? pattern.length >= parts.length : pattern.length === parts.length) && parts.every((part, index) => segment(pattern[index], part));
|
|
26927
27065
|
};
|
|
26928
27066
|
let roots = [];
|
|
@@ -26930,8 +27068,8 @@ var globbed = (cwd, target, state, configs) => {
|
|
|
26930
27068
|
roots = readdirSync5(state).filter((name) => /^(?:issued|approvals$)/.test(name));
|
|
26931
27069
|
} catch {}
|
|
26932
27070
|
return [
|
|
26933
|
-
...roots.map((name) =>
|
|
26934
|
-
...configs.flatMap((dir) => [dir,
|
|
27071
|
+
...roots.map((name) => path41.join(state, name)).filter((root) => hit(root, true)),
|
|
27072
|
+
...configs.flatMap((dir) => [dir, ...CONFIG_FILES.map((name) => path41.join(dir, name))]).filter((file) => hit(file, false))
|
|
26935
27073
|
];
|
|
26936
27074
|
};
|
|
26937
27075
|
var guardedInodes = (state, configs) => {
|
|
@@ -26945,14 +27083,15 @@ var guardedInodes = (state, configs) => {
|
|
|
26945
27083
|
seen.set(`${stat.dev}:${stat.ino}`, registry);
|
|
26946
27084
|
else if (stat?.isDirectory())
|
|
26947
27085
|
for (const name of readdirSync5(file))
|
|
26948
|
-
add(
|
|
27086
|
+
add(path41.join(file, name), registry);
|
|
26949
27087
|
};
|
|
26950
27088
|
try {
|
|
26951
27089
|
for (const dir of configs)
|
|
26952
|
-
|
|
27090
|
+
for (const name of CONFIG_FILES)
|
|
27091
|
+
add(path41.join(dir, name), "grants");
|
|
26953
27092
|
for (const name of readdirSync5(state))
|
|
26954
27093
|
if (/^(?:issued|approvals$)/.test(name))
|
|
26955
|
-
add(
|
|
27094
|
+
add(path41.join(state, name), name === "approvals" ? "approvals" : "issued");
|
|
26956
27095
|
} catch {}
|
|
26957
27096
|
return seen;
|
|
26958
27097
|
};
|
|
@@ -26977,7 +27116,7 @@ var registryTarget = (cwd, targets) => {
|
|
|
26977
27116
|
const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
|
|
26978
27117
|
if (viaGlob)
|
|
26979
27118
|
return { file: target, registry: viaGlob.registry };
|
|
26980
|
-
const registry = hardLinked(
|
|
27119
|
+
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);
|
|
26981
27120
|
if (registry)
|
|
26982
27121
|
return { file: target, registry };
|
|
26983
27122
|
}
|
|
@@ -26985,7 +27124,7 @@ var registryTarget = (cwd, targets) => {
|
|
|
26985
27124
|
};
|
|
26986
27125
|
var partsUnder = (dir, cwd, target, platform, real) => {
|
|
26987
27126
|
const win = platform === "win32";
|
|
26988
|
-
const p = win ?
|
|
27127
|
+
const p = win ? path41.win32 : path41.posix;
|
|
26989
27128
|
const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
|
|
26990
27129
|
const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
|
|
26991
27130
|
const relative = p.relative(fold(real(p.resolve(dir))), fold(real(p.resolve(cwd, named))));
|
|
@@ -26999,7 +27138,7 @@ var underRegistry = (state, cwd, target, platform = process.platform, real = (fi
|
|
|
26999
27138
|
};
|
|
27000
27139
|
var underConfig = (dir, cwd, target, platform = process.platform, real = (file) => file) => {
|
|
27001
27140
|
const parts = partsUnder(dir, cwd, target, platform, real);
|
|
27002
|
-
return parts?.length === 1 && ["",
|
|
27141
|
+
return parts?.length === 1 && ["", ...CONFIG_FILES, DIR_TARGET].includes(parts[0]);
|
|
27003
27142
|
};
|
|
27004
27143
|
var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
27005
27144
|
if (platform !== "win32" || !command.includes("\\"))
|
|
@@ -27019,7 +27158,7 @@ var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
|
27019
27158
|
];
|
|
27020
27159
|
const named = (target) => moved.some((dir) => {
|
|
27021
27160
|
const at = flat(/^(?:[a-z]:)?\//i.test(target) ? target : dir + target).replace(/\/\.?\//g, "/");
|
|
27022
|
-
return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, `${cfg}
|
|
27161
|
+
return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, ...CONFIG_FILES.map((name) => `${cfg}/${name}`)].includes(at)) : at.includes(`${state}/${registry}`);
|
|
27023
27162
|
});
|
|
27024
27163
|
return writes.writes && (writes.targets === null || writes.targets.some(named)) ? registry : null;
|
|
27025
27164
|
};
|
|
@@ -27042,7 +27181,7 @@ var REGISTRY_DENY = {
|
|
|
27042
27181
|
};
|
|
27043
27182
|
var registryDeny = ({ file, registry }) => {
|
|
27044
27183
|
const { label, what, unblock } = REGISTRY_DENY[registry];
|
|
27045
|
-
const named =
|
|
27184
|
+
const named = path41.basename(file).startsWith(".workit-") ? path41.dirname(file) : file;
|
|
27046
27185
|
return {
|
|
27047
27186
|
kind: "deny",
|
|
27048
27187
|
reason: `workit ${label}: ${named} is under ${what}. ${unblock}`,
|
|
@@ -27132,10 +27271,10 @@ import { spawnSync as spawnSync24 } from "node:child_process";
|
|
|
27132
27271
|
|
|
27133
27272
|
// packages/workit-core/src/ci-waiter.ts
|
|
27134
27273
|
import fs28 from "node:fs";
|
|
27135
|
-
import
|
|
27274
|
+
import path42 from "node:path";
|
|
27136
27275
|
var waiterFile = (cwd, pr) => {
|
|
27137
27276
|
const common = gitCommonDir(cwd);
|
|
27138
|
-
return common ?
|
|
27277
|
+
return common ? path42.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
|
|
27139
27278
|
};
|
|
27140
27279
|
var pidAlive2 = (pid) => {
|
|
27141
27280
|
if (!Number.isSafeInteger(pid) || pid <= 0)
|
|
@@ -27646,7 +27785,7 @@ var WRITE_TOOLS = new Set([
|
|
|
27646
27785
|
]);
|
|
27647
27786
|
// packages/workit-core/src/hooks/standing.ts
|
|
27648
27787
|
import fs29 from "node:fs";
|
|
27649
|
-
import
|
|
27788
|
+
import path43 from "node:path";
|
|
27650
27789
|
|
|
27651
27790
|
// packages/workit-core/src/approvals/store.ts
|
|
27652
27791
|
var REQUEST_TTL_MS = 30 * 60000;
|
|
@@ -28156,7 +28295,7 @@ var workitRole = (descriptor, agentType) => {
|
|
|
28156
28295
|
|
|
28157
28296
|
// packages/workit-core/src/hooks/standing.ts
|
|
28158
28297
|
var readPlans = (store) => {
|
|
28159
|
-
const dir =
|
|
28298
|
+
const dir = path43.join(store, "fanouts");
|
|
28160
28299
|
let names;
|
|
28161
28300
|
try {
|
|
28162
28301
|
names = fs29.readdirSync(dir).filter((name) => name.endsWith(".json"));
|
|
@@ -28166,7 +28305,7 @@ var readPlans = (store) => {
|
|
|
28166
28305
|
const plans = [];
|
|
28167
28306
|
for (const name of names) {
|
|
28168
28307
|
try {
|
|
28169
|
-
const raw = JSON.parse(fs29.readFileSync(
|
|
28308
|
+
const raw = JSON.parse(fs29.readFileSync(path43.join(dir, name), "utf8"));
|
|
28170
28309
|
if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
|
|
28171
28310
|
continue;
|
|
28172
28311
|
const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
|
|
@@ -28923,7 +29062,6 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
|
|
|
28923
29062
|
READ.delete(READ.keys().next().value);
|
|
28924
29063
|
return found;
|
|
28925
29064
|
};
|
|
28926
|
-
var writesMode = (cwd) => resolveRuntimeWorkspaceVcs(cwd)?.youtrack?.writes;
|
|
28927
29065
|
var ytrackGate = (cwd, command, dialect, ask) => {
|
|
28928
29066
|
let writes;
|
|
28929
29067
|
try {
|
|
@@ -28934,7 +29072,7 @@ var ytrackGate = (cwd, command, dialect, ask) => {
|
|
|
28934
29072
|
}
|
|
28935
29073
|
writes = [...merged.values()];
|
|
28936
29074
|
} catch {
|
|
28937
|
-
if (
|
|
29075
|
+
if (youTrackWritesMode(cwd) === "auto")
|
|
28938
29076
|
return null;
|
|
28939
29077
|
return {
|
|
28940
29078
|
kind: "deny",
|
|
@@ -28942,7 +29080,7 @@ var ytrackGate = (cwd, command, dialect, ask) => {
|
|
|
28942
29080
|
unblock: null
|
|
28943
29081
|
};
|
|
28944
29082
|
}
|
|
28945
|
-
if (!writes.length ||
|
|
29083
|
+
if (!writes.length || youTrackWritesMode(cwd) === "auto")
|
|
28946
29084
|
return null;
|
|
28947
29085
|
const calls = writes.flatMap((write) => write.workit ? [`\`${write.workit}\``] : []);
|
|
28948
29086
|
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"})`);
|
|
@@ -28979,11 +29117,11 @@ var PROCESS_START = performance.timeOrigin;
|
|
|
28979
29117
|
// packages/workit-core/src/hooks/run.ts
|
|
28980
29118
|
if (false) {}
|
|
28981
29119
|
// packages/workit-opencode/src/shared/init-apply.ts
|
|
28982
|
-
import
|
|
29120
|
+
import path48 from "node:path";
|
|
28983
29121
|
|
|
28984
29122
|
// packages/workit-core/src/core/gitignore.ts
|
|
28985
|
-
import { existsSync as existsSync14, readFileSync as
|
|
28986
|
-
import
|
|
29123
|
+
import { existsSync as existsSync14, readFileSync as readFileSync13, writeFileSync as writeFileSync5 } from "node:fs";
|
|
29124
|
+
import path44 from "node:path";
|
|
28987
29125
|
var GITIGNORE_ENTRIES = [
|
|
28988
29126
|
"# workit: SDD working state (never commit)",
|
|
28989
29127
|
"docs/*/sdd/",
|
|
@@ -29003,8 +29141,8 @@ var GITIGNORE_ENTRIES = [
|
|
|
29003
29141
|
var ensureProjectGitignore = (workspaceRoot, confirmed) => {
|
|
29004
29142
|
if (!confirmed)
|
|
29005
29143
|
return { ok: false, error: "confirmed: true required" };
|
|
29006
|
-
const file =
|
|
29007
|
-
const existing = existsSync14(file) ?
|
|
29144
|
+
const file = path44.join(workspaceRoot, ".gitignore");
|
|
29145
|
+
const existing = existsSync14(file) ? readFileSync13(file, "utf8") : "";
|
|
29008
29146
|
const existingLines = new Set(existing.split(`
|
|
29009
29147
|
`).map((l) => l.trim()).filter(Boolean));
|
|
29010
29148
|
const added = [];
|
|
@@ -29030,26 +29168,26 @@ var ensureProjectGitignore = (workspaceRoot, confirmed) => {
|
|
|
29030
29168
|
};
|
|
29031
29169
|
|
|
29032
29170
|
// packages/workit-core/src/core/hygiene.ts
|
|
29033
|
-
import { existsSync as existsSync15, readFileSync as
|
|
29034
|
-
import
|
|
29171
|
+
import { existsSync as existsSync15, readFileSync as readFileSync14, readdirSync as readdirSync6, writeFileSync as writeFileSync6 } from "node:fs";
|
|
29172
|
+
import path45 from "node:path";
|
|
29035
29173
|
var repoRoot3 = assetRoot();
|
|
29036
|
-
var templatesDir = () =>
|
|
29174
|
+
var templatesDir = () => path45.join(repoRoot3, "templates", "hygiene");
|
|
29037
29175
|
var packageJson = (root) => {
|
|
29038
|
-
if (!existsSync15(
|
|
29176
|
+
if (!existsSync15(path45.join(root, "package.json")))
|
|
29039
29177
|
return null;
|
|
29040
29178
|
try {
|
|
29041
|
-
return JSON.parse(
|
|
29179
|
+
return JSON.parse(readFileSync14(path45.join(root, "package.json"), "utf8"));
|
|
29042
29180
|
} catch {
|
|
29043
29181
|
return null;
|
|
29044
29182
|
}
|
|
29045
29183
|
};
|
|
29046
29184
|
var isOpenSource = (root) => {
|
|
29047
|
-
if (existsSync15(
|
|
29185
|
+
if (existsSync15(path45.join(root, "LICENSE")))
|
|
29048
29186
|
return true;
|
|
29049
29187
|
const pkg = packageJson(root);
|
|
29050
29188
|
if (pkg && !pkg.private)
|
|
29051
29189
|
return true;
|
|
29052
|
-
return
|
|
29190
|
+
return path45.basename(root) === "workit";
|
|
29053
29191
|
};
|
|
29054
29192
|
var licenseHolder = (root) => {
|
|
29055
29193
|
const pkg = packageJson(root);
|
|
@@ -29072,13 +29210,13 @@ var planHygieneFiles = (root, opts = {}) => {
|
|
|
29072
29210
|
files.push("LICENSE", "CONTRIBUTING.md");
|
|
29073
29211
|
const planned = [];
|
|
29074
29212
|
for (const file of files) {
|
|
29075
|
-
if (existsSync15(
|
|
29213
|
+
if (existsSync15(path45.join(root, file)))
|
|
29076
29214
|
continue;
|
|
29077
|
-
const tpl =
|
|
29215
|
+
const tpl = path45.join(templatesDir(), file);
|
|
29078
29216
|
if (!existsSync15(tpl))
|
|
29079
29217
|
continue;
|
|
29080
|
-
const content =
|
|
29081
|
-
planned.push({ path:
|
|
29218
|
+
const content = readFileSync14(tpl, "utf8").replace(/<PROJECT>/g, path45.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
|
|
29219
|
+
planned.push({ path: path45.join(root, file), content });
|
|
29082
29220
|
}
|
|
29083
29221
|
return planned;
|
|
29084
29222
|
};
|
|
@@ -29088,30 +29226,30 @@ var ensureHygieneFiles = (root, opts) => {
|
|
|
29088
29226
|
const created = [];
|
|
29089
29227
|
for (const planned of planHygieneFiles(root, opts)) {
|
|
29090
29228
|
writeFileSync6(planned.path, planned.content, "utf8");
|
|
29091
|
-
created.push(
|
|
29229
|
+
created.push(path45.basename(planned.path));
|
|
29092
29230
|
}
|
|
29093
29231
|
return { ok: true, created };
|
|
29094
29232
|
};
|
|
29095
29233
|
|
|
29096
29234
|
// packages/workit-core/src/core/init.ts
|
|
29097
29235
|
import fs30 from "node:fs";
|
|
29098
|
-
import
|
|
29236
|
+
import path47 from "node:path";
|
|
29099
29237
|
import { spawnSync as spawnSync25 } from "node:child_process";
|
|
29100
29238
|
|
|
29101
29239
|
// packages/workit-core/src/core/workspace-branch-policy.ts
|
|
29102
|
-
import { mkdirSync as mkdirSync5, readFileSync as
|
|
29103
|
-
import
|
|
29240
|
+
import { mkdirSync as mkdirSync5, readFileSync as readFileSync15, renameSync as renameSync4, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "node:fs";
|
|
29241
|
+
import path46 from "node:path";
|
|
29104
29242
|
import { isDeepStrictEqual } from "node:util";
|
|
29105
29243
|
var readFileSafe = (p) => {
|
|
29106
29244
|
try {
|
|
29107
|
-
return
|
|
29245
|
+
return readFileSync15(p, "utf8");
|
|
29108
29246
|
} catch {
|
|
29109
29247
|
return null;
|
|
29110
29248
|
}
|
|
29111
29249
|
};
|
|
29112
29250
|
function applyWorkspaceBranchPolicy(opts) {
|
|
29113
29251
|
const { workspace_root, env = process.env } = opts;
|
|
29114
|
-
const dir =
|
|
29252
|
+
const dir = path46.join(env.WORKIT_CONFIG ?? configDir2());
|
|
29115
29253
|
const {
|
|
29116
29254
|
status,
|
|
29117
29255
|
path: wsPath,
|
|
@@ -29123,7 +29261,7 @@ function applyWorkspaceBranchPolicy(opts) {
|
|
|
29123
29261
|
if (status === "malformed" || status === "invalid")
|
|
29124
29262
|
return { ok: false, error: workspacesError ?? `invalid workspaces.json: ${wsPath}` };
|
|
29125
29263
|
const detection = detectBranchPolicy(workspace_root);
|
|
29126
|
-
const name = String(env.WORKIT_BP_NAME ??
|
|
29264
|
+
const name = String(env.WORKIT_BP_NAME ?? path46.basename(workspace_root));
|
|
29127
29265
|
const integration = env.WORKIT_BP_INTEGRATION ?? detection.integration;
|
|
29128
29266
|
const policy = {
|
|
29129
29267
|
preset: detection.preset,
|
|
@@ -29172,7 +29310,7 @@ function applyWorkspaceBranchPolicy(opts) {
|
|
|
29172
29310
|
ok: false,
|
|
29173
29311
|
error: `workspaces.json changed while applying the branch policy: ${wsPath}`
|
|
29174
29312
|
};
|
|
29175
|
-
mkdirSync5(
|
|
29313
|
+
mkdirSync5(path46.dirname(wsPath), { recursive: true });
|
|
29176
29314
|
const tmp = `${wsPath}.${process.pid}.tmp`;
|
|
29177
29315
|
try {
|
|
29178
29316
|
writeFileSync7(tmp, JSON.stringify({ ...document, workspaces: next }, null, 2) + `
|
|
@@ -29272,7 +29410,7 @@ function initApplyData(action, env = process.env) {
|
|
|
29272
29410
|
fs30.mkdirSync(dir, { recursive: true });
|
|
29273
29411
|
switch (action) {
|
|
29274
29412
|
case "youtrack_json": {
|
|
29275
|
-
const out =
|
|
29413
|
+
const out = path47.join(dir, "youtrack.json");
|
|
29276
29414
|
fs30.writeFileSync(out, JSON.stringify(youtrackJsonContent(), null, 2) + `
|
|
29277
29415
|
`, "utf8");
|
|
29278
29416
|
return { action, ok: true, path: out };
|
|
@@ -29286,10 +29424,10 @@ function initApplyData(action, env = process.env) {
|
|
|
29286
29424
|
};
|
|
29287
29425
|
}
|
|
29288
29426
|
case "youtrack_scaffold": {
|
|
29289
|
-
const jsonOut =
|
|
29427
|
+
const jsonOut = path47.join(dir, "youtrack.json");
|
|
29290
29428
|
fs30.writeFileSync(jsonOut, JSON.stringify(youtrackJsonContent(), null, 2) + `
|
|
29291
29429
|
`, "utf8");
|
|
29292
|
-
const configPath =
|
|
29430
|
+
const configPath = path47.resolve(jsonOut);
|
|
29293
29431
|
const cfg = readJson3(configPath) ?? {};
|
|
29294
29432
|
const base = String(cfg.baseUrl ?? "").replace(/\/+$/, "");
|
|
29295
29433
|
const meeting = String(cfg.meetingIssue ?? "");
|
|
@@ -29325,10 +29463,10 @@ function initApplyData(action, env = process.env) {
|
|
|
29325
29463
|
};
|
|
29326
29464
|
}
|
|
29327
29465
|
case "vcs_scaffold": {
|
|
29328
|
-
const jsonOut =
|
|
29466
|
+
const jsonOut = path47.join(dir, "vcs.json");
|
|
29329
29467
|
fs30.writeFileSync(jsonOut, JSON.stringify(vcsJsonContent(), null, 2) + `
|
|
29330
29468
|
`, "utf8");
|
|
29331
|
-
const configPath =
|
|
29469
|
+
const configPath = path47.resolve(jsonOut);
|
|
29332
29470
|
const prev = process.env.WORKIT_VCS_CONFIG;
|
|
29333
29471
|
process.env.WORKIT_VCS_CONFIG = configPath;
|
|
29334
29472
|
try {
|
|
@@ -29447,7 +29585,7 @@ var executeInitApply = (args, directory, runtime) => {
|
|
|
29447
29585
|
protectedNames: args.branch_policy_protected
|
|
29448
29586
|
}, current);
|
|
29449
29587
|
writeConfig(next);
|
|
29450
|
-
return output(ok({ action: "config", path:
|
|
29588
|
+
return output(ok({ action: "config", path: path48.join(configDir2(), "config.json"), ...next }));
|
|
29451
29589
|
}
|
|
29452
29590
|
const env = Object.fromEntries(Object.entries({
|
|
29453
29591
|
WORKIT_YT_BASE_URL: args.base_url,
|
|
@@ -29464,14 +29602,14 @@ var executeInitApply = (args, directory, runtime) => {
|
|
|
29464
29602
|
|
|
29465
29603
|
// packages/workit-opencode/src/shared/session.ts
|
|
29466
29604
|
import { realpathSync as realpathSync10 } from "node:fs";
|
|
29467
|
-
import
|
|
29605
|
+
import path49 from "node:path";
|
|
29468
29606
|
var sameWorkspace = (expected, observed) => {
|
|
29469
29607
|
if (typeof observed !== "string" || !observed)
|
|
29470
29608
|
return false;
|
|
29471
29609
|
try {
|
|
29472
29610
|
return realpathSync10(expected) === realpathSync10(observed);
|
|
29473
29611
|
} catch {
|
|
29474
|
-
return
|
|
29612
|
+
return path49.resolve(expected) === path49.resolve(observed);
|
|
29475
29613
|
}
|
|
29476
29614
|
};
|
|
29477
29615
|
|
|
@@ -29543,7 +29681,7 @@ var workitFamilyOf = (toolName) => {
|
|
|
29543
29681
|
|
|
29544
29682
|
// packages/workit-opencode/src/tools/context.ts
|
|
29545
29683
|
import { realpathSync as realpathSync11 } from "node:fs";
|
|
29546
|
-
import
|
|
29684
|
+
import path50 from "node:path";
|
|
29547
29685
|
var createContextTool = () => ({
|
|
29548
29686
|
description: "Read Git, pull request, YouTrack, issue, changelog, release, or affected-file context.",
|
|
29549
29687
|
execute: async (args, context) => {
|
|
@@ -29553,7 +29691,7 @@ var createContextTool = () => ({
|
|
|
29553
29691
|
let root;
|
|
29554
29692
|
try {
|
|
29555
29693
|
const cwd = parsed.data.cwd;
|
|
29556
|
-
root = realpathSync11(cwd ?
|
|
29694
|
+
root = realpathSync11(cwd ? path50.resolve(context.directory, cwd) : context.directory);
|
|
29557
29695
|
} catch {
|
|
29558
29696
|
return JSON.stringify(failure2("invalid_input", "context target directory cannot be resolved"), null, 2);
|
|
29559
29697
|
}
|
|
@@ -29584,9 +29722,9 @@ var workerCoordinatorFor = (task, worker) => {
|
|
|
29584
29722
|
|
|
29585
29723
|
// packages/workit-core/src/fanout.ts
|
|
29586
29724
|
import { spawnSync as spawnSync29 } from "node:child_process";
|
|
29587
|
-
import { createHash as
|
|
29725
|
+
import { createHash as createHash20 } from "node:crypto";
|
|
29588
29726
|
import fs32 from "node:fs";
|
|
29589
|
-
import
|
|
29727
|
+
import path53 from "node:path";
|
|
29590
29728
|
|
|
29591
29729
|
// packages/workit-core/src/fanout-landed.ts
|
|
29592
29730
|
import { spawnSync as spawnSync26 } from "node:child_process";
|
|
@@ -29814,14 +29952,14 @@ var NOTICE_TTL_MS = 7 * 86400000;
|
|
|
29814
29952
|
|
|
29815
29953
|
// packages/workit-core/src/stack.ts
|
|
29816
29954
|
import { spawnSync as spawnSync28 } from "node:child_process";
|
|
29817
|
-
import { createHash as
|
|
29955
|
+
import { createHash as createHash19, randomBytes as randomBytes4 } from "node:crypto";
|
|
29818
29956
|
import fs31 from "node:fs";
|
|
29819
|
-
import
|
|
29957
|
+
import path52 from "node:path";
|
|
29820
29958
|
|
|
29821
29959
|
// packages/workit-core/src/git/ops.ts
|
|
29822
29960
|
import { spawnSync as spawnSync27 } from "node:child_process";
|
|
29823
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync16, readdirSync as readdirSync7, readFileSync as
|
|
29824
|
-
import
|
|
29961
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync16, readdirSync as readdirSync7, readFileSync as readFileSync16, rmSync as rmSync4 } from "node:fs";
|
|
29962
|
+
import path51 from "node:path";
|
|
29825
29963
|
var COMMIT_TIMEOUT_MS = 10 * 60000;
|
|
29826
29964
|
var git5 = (cwd, args, options = {}) => {
|
|
29827
29965
|
const result = spawnSync27("git", args, {
|
|
@@ -29854,18 +29992,18 @@ function operationInProgress(cwd) {
|
|
|
29854
29992
|
if (!run.ok)
|
|
29855
29993
|
return null;
|
|
29856
29994
|
const found = run.stdout.split(`
|
|
29857
|
-
`).map((line) =>
|
|
29995
|
+
`).map((line) => path51.resolve(cwd, line.trim()));
|
|
29858
29996
|
const conflicted = () => git5(cwd, ["ls-files", "-u"]).stdout.trim() !== "";
|
|
29859
29997
|
for (const [index, [, operation]] of markers.entries()) {
|
|
29860
29998
|
const marker = found[index];
|
|
29861
29999
|
if (!marker || !existsSync16(marker))
|
|
29862
30000
|
continue;
|
|
29863
|
-
if (index === 1 && existsSync16(
|
|
30001
|
+
if (index === 1 && existsSync16(path51.join(marker, "applying")))
|
|
29864
30002
|
return { operation: "am", commitAllowed: false, branch: null };
|
|
29865
|
-
if (index === 0 && existsSync16(
|
|
30003
|
+
if (index === 0 && existsSync16(path51.join(marker, "amend")) && !conflicted()) {
|
|
29866
30004
|
let headName = "";
|
|
29867
30005
|
try {
|
|
29868
|
-
headName =
|
|
30006
|
+
headName = readFileSync16(path51.join(marker, "head-name"), "utf8").trim();
|
|
29869
30007
|
} catch {}
|
|
29870
30008
|
const branch = headName.startsWith("refs/heads/") ? headName.slice("refs/heads/".length) : null;
|
|
29871
30009
|
return { operation, commitAllowed: branch !== null, branch };
|
|
@@ -29993,7 +30131,7 @@ function rebaseInProgress(dir) {
|
|
|
29993
30131
|
}
|
|
29994
30132
|
var scratchDir = (cwd) => {
|
|
29995
30133
|
const dir = stacksDir(cwd);
|
|
29996
|
-
return dir.ok ?
|
|
30134
|
+
return dir.ok ? path52.join(dir.data, "worktrees") : null;
|
|
29997
30135
|
};
|
|
29998
30136
|
function gitRestack(cwd, input) {
|
|
29999
30137
|
const owner = worktreeOf(cwd, input.branch);
|
|
@@ -30008,7 +30146,7 @@ function gitRestack(cwd, input) {
|
|
|
30008
30146
|
error: "no store root"
|
|
30009
30147
|
};
|
|
30010
30148
|
fs31.mkdirSync(scratch, { recursive: true });
|
|
30011
|
-
dir =
|
|
30149
|
+
dir = path52.join(scratch, `${input.branch.replace(/[^A-Za-z0-9._-]+/gu, "_").slice(0, 40)}-${randomBytes4(4).toString("hex")}`);
|
|
30012
30150
|
const added = gitRun4(cwd, ["worktree", "add", "-q", dir, input.branch], GIT_TIMEOUTS.worktree);
|
|
30013
30151
|
if (!added.ok)
|
|
30014
30152
|
return {
|
|
@@ -30062,12 +30200,12 @@ function gitRestack(cwd, input) {
|
|
|
30062
30200
|
var firstLine = (run) => (`${run.stderr}
|
|
30063
30201
|
${run.stdout}`.split(`
|
|
30064
30202
|
`).find((line) => line.trim()) ?? "git failed").trim().slice(0, 300);
|
|
30065
|
-
var stackFileName = (name) => `${name.replace(/[^A-Za-z0-9._-]+/gu, "_").replace(/^[._]+/u, "").slice(0, 48).toLowerCase()}-${
|
|
30203
|
+
var stackFileName = (name) => `${name.replace(/[^A-Za-z0-9._-]+/gu, "_").replace(/^[._]+/u, "").slice(0, 48).toLowerCase()}-${createHash19("sha256").update(name).digest("hex").slice(0, 12)}.json`;
|
|
30066
30204
|
function stacksDir(cwd) {
|
|
30067
30205
|
const root = storeRoot(cwd);
|
|
30068
30206
|
if (!root.ok)
|
|
30069
30207
|
return stackFail(root.code, root.error, root.unblock);
|
|
30070
|
-
return { ok: true, data:
|
|
30208
|
+
return { ok: true, data: path52.join(root.value.root, "stacks") };
|
|
30071
30209
|
}
|
|
30072
30210
|
var HEARTBEAT_STALE_MS = 2 * 60000;
|
|
30073
30211
|
var SETTLED_BY_RESTACK = new Set(["checks_pending", "behind_base_required"]);
|
|
@@ -30208,13 +30346,13 @@ function sliceHash(slice) {
|
|
|
30208
30346
|
issues: _issues,
|
|
30209
30347
|
...definition
|
|
30210
30348
|
} = slice;
|
|
30211
|
-
return
|
|
30349
|
+
return createHash20("sha256").update(JSON.stringify(definition)).digest("hex").slice(0, 16);
|
|
30212
30350
|
}
|
|
30213
30351
|
function fanoutsDir(cwd) {
|
|
30214
30352
|
const root = storeRoot(cwd);
|
|
30215
30353
|
if (!root.ok)
|
|
30216
30354
|
return fanoutFail(root.code, root.error, root.unblock);
|
|
30217
|
-
return { ok: true, data:
|
|
30355
|
+
return { ok: true, data: path53.join(root.value.root, "fanouts") };
|
|
30218
30356
|
}
|
|
30219
30357
|
function parseStored(raw) {
|
|
30220
30358
|
if (!isRecord7(raw) || typeof raw.name !== "string" || typeof raw.trunk !== "string")
|
|
@@ -30282,7 +30420,7 @@ function readFanout(cwd, name) {
|
|
|
30282
30420
|
const dir = fanoutsDir(cwd);
|
|
30283
30421
|
if (!dir.ok)
|
|
30284
30422
|
return dir;
|
|
30285
|
-
const file =
|
|
30423
|
+
const file = path53.join(dir.data, stackFileName(name));
|
|
30286
30424
|
let parsed = null;
|
|
30287
30425
|
try {
|
|
30288
30426
|
parsed = parseStored(JSON.parse(fs32.readFileSync(file, "utf8")));
|
|
@@ -30307,7 +30445,7 @@ function listFanouts(cwd) {
|
|
|
30307
30445
|
for (const entry of names) {
|
|
30308
30446
|
let parsed = null;
|
|
30309
30447
|
try {
|
|
30310
|
-
parsed = parseStored(JSON.parse(fs32.readFileSync(
|
|
30448
|
+
parsed = parseStored(JSON.parse(fs32.readFileSync(path53.join(dir.data, entry), "utf8")));
|
|
30311
30449
|
} catch {
|
|
30312
30450
|
parsed = null;
|
|
30313
30451
|
}
|
|
@@ -31155,14 +31293,14 @@ var childTaskMissing = (store, input) => {
|
|
|
31155
31293
|
var childDenial = (identity) => `OpenCode child session has no validated Workit worker: as ${identity} it may only inspect the task summary (workit_task action "inspect") or record evidence or findings (workit_evidence/workit_finding action "record") on an existing task; for anything else the lead assigns it a worker with workit_worker before launching it`;
|
|
31156
31294
|
|
|
31157
31295
|
// packages/workit-opencode/src/v2/shell.ts
|
|
31158
|
-
import
|
|
31296
|
+
import path54 from "node:path";
|
|
31159
31297
|
|
|
31160
31298
|
// packages/workit-core/src/hooks/repeat-failure.ts
|
|
31161
|
-
import { createHash as
|
|
31299
|
+
import { createHash as createHash21 } from "node:crypto";
|
|
31162
31300
|
var SAME_CALL_FAILED = "Same call failed twice:";
|
|
31163
31301
|
var MAX_SESSIONS = 256;
|
|
31164
31302
|
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";
|
|
31165
|
-
var hashOf = (call) =>
|
|
31303
|
+
var hashOf = (call) => createHash21("sha256").update(call).digest("hex").slice(0, 32);
|
|
31166
31304
|
var record3 = (memo, sessionId, call, failed, next) => {
|
|
31167
31305
|
const previous = memo.get(sessionId);
|
|
31168
31306
|
memo.delete(sessionId);
|
|
@@ -31218,7 +31356,7 @@ var commandOf = (input) => {
|
|
|
31218
31356
|
};
|
|
31219
31357
|
var hookInput = (root, sessionID, id, shell) => ({
|
|
31220
31358
|
host: "opencode",
|
|
31221
|
-
cwd: shell.workdir ?
|
|
31359
|
+
cwd: shell.workdir ? path54.resolve(root, shell.workdir) : root,
|
|
31222
31360
|
session: { id: sessionID, agentId: null, agentType: null, parentId: null },
|
|
31223
31361
|
permissionMode: null,
|
|
31224
31362
|
transcriptPath: null,
|
|
@@ -31494,38 +31632,38 @@ var createStopControl = (root, port) => {
|
|
|
31494
31632
|
};
|
|
31495
31633
|
|
|
31496
31634
|
// packages/workit-opencode/src/v2/registry.ts
|
|
31497
|
-
import { existsSync as existsSync18, readFileSync as
|
|
31498
|
-
import
|
|
31635
|
+
import { existsSync as existsSync18, readFileSync as readFileSync17 } from "node:fs";
|
|
31636
|
+
import path56 from "node:path";
|
|
31499
31637
|
|
|
31500
31638
|
// packages/workit-opencode/src/shared/assets.ts
|
|
31501
31639
|
import { existsSync as existsSync17, realpathSync as realpathSync12 } from "node:fs";
|
|
31502
|
-
import
|
|
31640
|
+
import path55 from "node:path";
|
|
31503
31641
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
31504
31642
|
var moduleDir = () => {
|
|
31505
31643
|
try {
|
|
31506
|
-
return realpathSync12(
|
|
31644
|
+
return realpathSync12(path55.dirname(fileURLToPath2(import.meta.url)));
|
|
31507
31645
|
} catch {
|
|
31508
|
-
return
|
|
31646
|
+
return path55.dirname(fileURLToPath2(import.meta.url));
|
|
31509
31647
|
}
|
|
31510
31648
|
};
|
|
31511
31649
|
var packageRoot2 = () => {
|
|
31512
31650
|
const dir = moduleDir();
|
|
31513
31651
|
for (const candidate of [
|
|
31514
|
-
|
|
31515
|
-
|
|
31516
|
-
|
|
31652
|
+
path55.resolve(dir, ".."),
|
|
31653
|
+
path55.resolve(dir, "..", ".."),
|
|
31654
|
+
path55.resolve(dir, "..", "..", "..")
|
|
31517
31655
|
]) {
|
|
31518
|
-
if (existsSync17(
|
|
31656
|
+
if (existsSync17(path55.join(candidate, "package.json")))
|
|
31519
31657
|
return candidate;
|
|
31520
31658
|
}
|
|
31521
|
-
return
|
|
31659
|
+
return path55.resolve(dir, "..");
|
|
31522
31660
|
};
|
|
31523
31661
|
var skillsRoot = () => {
|
|
31524
31662
|
const root = packageRoot2();
|
|
31525
|
-
const canonical =
|
|
31526
|
-
if (existsSync17(
|
|
31663
|
+
const canonical = path55.resolve(root, "..", "workit-core", "skills");
|
|
31664
|
+
if (existsSync17(path55.join(root, "src")) && existsSync17(canonical))
|
|
31527
31665
|
return canonical;
|
|
31528
|
-
return
|
|
31666
|
+
return path55.join(root, "assets", "skills");
|
|
31529
31667
|
};
|
|
31530
31668
|
|
|
31531
31669
|
// packages/workit-opencode/src/v2/registry.ts
|
|
@@ -31552,11 +31690,11 @@ var registerSkills = async (ctx) => {
|
|
|
31552
31690
|
if (!existsSync18(skillsDir))
|
|
31553
31691
|
return new Set;
|
|
31554
31692
|
const listed = await ctx.skill.list().catch(() => ({ data: [] }));
|
|
31555
|
-
const own = (skill) => typeof skill.path === "string" &&
|
|
31693
|
+
const own = (skill) => typeof skill.path === "string" && path56.resolve(skill.path).startsWith(skillsDir + path56.sep);
|
|
31556
31694
|
const userSkills = new Set((listed?.data ?? []).filter((skill) => !own(skill)).map((skill) => skill.id));
|
|
31557
31695
|
const packaged = new Map;
|
|
31558
31696
|
for (const id of WORKIT_METHOD_SKILLS) {
|
|
31559
|
-
const file =
|
|
31697
|
+
const file = path56.join(skillsDir, id, "SKILL.md");
|
|
31560
31698
|
if (!userSkills.has(id) && existsSync18(file))
|
|
31561
31699
|
packaged.set(id, file);
|
|
31562
31700
|
}
|
|
@@ -31565,7 +31703,7 @@ var registerSkills = async (ctx) => {
|
|
|
31565
31703
|
for (const [id, file] of packaged) {
|
|
31566
31704
|
if (existing.has(id))
|
|
31567
31705
|
continue;
|
|
31568
|
-
const parsed = parseFrontmatter(
|
|
31706
|
+
const parsed = parseFrontmatter(readFileSync17(file, "utf8"));
|
|
31569
31707
|
editor.add({
|
|
31570
31708
|
id,
|
|
31571
31709
|
name: parsed.name || id,
|
|
@@ -31604,38 +31742,38 @@ var registerCommands = async (ctx, registeredSkills) => {
|
|
|
31604
31742
|
|
|
31605
31743
|
// packages/workit-opencode/src/stale-sources.ts
|
|
31606
31744
|
import { existsSync as existsSync19, readdirSync as readdirSync8 } from "node:fs";
|
|
31607
|
-
import
|
|
31745
|
+
import path57 from "node:path";
|
|
31608
31746
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
31609
31747
|
var typescriptFiles = (directory) => {
|
|
31610
31748
|
if (!existsSync19(directory))
|
|
31611
31749
|
return [];
|
|
31612
31750
|
return readdirSync8(directory, { withFileTypes: true }).flatMap((entry) => {
|
|
31613
|
-
const file =
|
|
31751
|
+
const file = path57.join(directory, entry.name);
|
|
31614
31752
|
return entry.isDirectory() ? typescriptFiles(file) : entry.isFile() && file.endsWith(".ts") ? [file] : [];
|
|
31615
31753
|
});
|
|
31616
31754
|
};
|
|
31617
31755
|
var pluginSourceFiles = [
|
|
31618
31756
|
...new Set([
|
|
31619
31757
|
fileURLToPath3(import.meta.url),
|
|
31620
|
-
...typescriptFiles(
|
|
31621
|
-
|
|
31622
|
-
...typescriptFiles(
|
|
31758
|
+
...typescriptFiles(path57.join(packageRoot2(), "src")),
|
|
31759
|
+
path57.join(packageRoot2(), "..", "workit-core", "src", "core.ts"),
|
|
31760
|
+
...typescriptFiles(path57.join(packageRoot2(), "..", "workit-core", "src", "core"))
|
|
31623
31761
|
])
|
|
31624
31762
|
].filter((file) => existsSync19(file)).toSorted();
|
|
31625
31763
|
|
|
31626
31764
|
// packages/workit-core/src/core/cli-locate.ts
|
|
31627
31765
|
import { closeSync as closeSync2, existsSync as existsSync20, openSync as openSync2, readSync } from "node:fs";
|
|
31628
|
-
import
|
|
31766
|
+
import path58 from "node:path";
|
|
31629
31767
|
var LAUNCHER_MARKER = "workit-owned-launcher";
|
|
31630
31768
|
var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
|
|
31631
31769
|
var installRoot = (env, platform = process.platform) => {
|
|
31632
31770
|
if (env.WORKIT_INSTALL_ROOT)
|
|
31633
31771
|
return env.WORKIT_INSTALL_ROOT;
|
|
31634
31772
|
const data = dataDir(env, platform);
|
|
31635
|
-
return platform === "win32" ?
|
|
31773
|
+
return platform === "win32" ? path58.join(data, "install") : data;
|
|
31636
31774
|
};
|
|
31637
|
-
var ownedLauncherPath = (env, platform = process.platform) =>
|
|
31638
|
-
var ownedCurrentEntry = (env, platform = process.platform) =>
|
|
31775
|
+
var ownedLauncherPath = (env, platform = process.platform) => path58.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
|
|
31776
|
+
var ownedCurrentEntry = (env, platform = process.platform) => path58.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
|
|
31639
31777
|
var head = (file) => {
|
|
31640
31778
|
let fd;
|
|
31641
31779
|
try {
|
|
@@ -31662,7 +31800,7 @@ var locateWorkitCli = (options = {}) => {
|
|
|
31662
31800
|
source: "owned-launcher",
|
|
31663
31801
|
command: launcher,
|
|
31664
31802
|
args: [],
|
|
31665
|
-
binDir:
|
|
31803
|
+
binDir: path58.dirname(launcher)
|
|
31666
31804
|
};
|
|
31667
31805
|
const current = ownedCurrentEntry(env, platform);
|
|
31668
31806
|
if (exists(current))
|
|
@@ -31691,7 +31829,7 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
|
|
|
31691
31829
|
if (located.binDir) {
|
|
31692
31830
|
const key = pathKey(env);
|
|
31693
31831
|
const delimiter = platform === "win32" ? ";" : ":";
|
|
31694
|
-
const same = (dir) => platform === "win32" ?
|
|
31832
|
+
const same = (dir) => platform === "win32" ? path58.win32.normalize(dir).toLowerCase() === path58.win32.normalize(located.binDir).toLowerCase() : path58.posix.normalize(dir) === path58.posix.normalize(located.binDir);
|
|
31695
31833
|
const rest = (env[key] ?? "").split(delimiter).filter((dir) => dir && !same(dir));
|
|
31696
31834
|
patch[key] = [located.binDir, ...rest].join(delimiter);
|
|
31697
31835
|
}
|