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