@brainervirus/workit-cursor 8.12.0 → 8.12.2
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/.cursor-plugin/plugin.json +1 -1
- package/dist/cursor-session-start.js +306 -212
- package/dist/mcp-server.js +273 -273
- package/dist/workit-hook.js +307 -214
- package/package.json +3 -3
|
@@ -9850,11 +9850,71 @@ var init_vcs_config = __esm(() => {
|
|
|
9850
9850
|
init_release_tracks();
|
|
9851
9851
|
});
|
|
9852
9852
|
|
|
9853
|
+
// packages/workit-core/src/core/logger.ts
|
|
9854
|
+
import os3 from "node:os";
|
|
9855
|
+
import path5 from "node:path";
|
|
9856
|
+
var SENSITIVE_WORDS, STACK_WORDS, escapeRegExp2 = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), resolveStateDir = () => {
|
|
9857
|
+
const override = process.env.WORKFLOW_TOOLKIT_STATE;
|
|
9858
|
+
if (override)
|
|
9859
|
+
return override;
|
|
9860
|
+
const home = os3.homedir();
|
|
9861
|
+
if (process.env.XDG_STATE_HOME)
|
|
9862
|
+
return path5.join(process.env.XDG_STATE_HOME, "workit");
|
|
9863
|
+
switch (os3.platform()) {
|
|
9864
|
+
case "darwin":
|
|
9865
|
+
return path5.join(home, "Library", "Application Support", "workit");
|
|
9866
|
+
case "win32":
|
|
9867
|
+
return path5.join(process.env.LOCALAPPDATA ?? path5.join(home, "AppData", "Local"), "workit");
|
|
9868
|
+
default:
|
|
9869
|
+
return path5.join(process.env.HOME ?? home, ".local", "state", "workit");
|
|
9870
|
+
}
|
|
9871
|
+
}, homePattern;
|
|
9872
|
+
var init_logger = __esm(() => {
|
|
9873
|
+
SENSITIVE_WORDS = new Set([
|
|
9874
|
+
"token",
|
|
9875
|
+
"secret",
|
|
9876
|
+
"password",
|
|
9877
|
+
"passwd",
|
|
9878
|
+
"authorization",
|
|
9879
|
+
"credential",
|
|
9880
|
+
"credentials",
|
|
9881
|
+
"cookie",
|
|
9882
|
+
"api",
|
|
9883
|
+
"apikey",
|
|
9884
|
+
"apitoken",
|
|
9885
|
+
"accesstoken",
|
|
9886
|
+
"clientsecret",
|
|
9887
|
+
"refreshtoken",
|
|
9888
|
+
"key",
|
|
9889
|
+
"bearer",
|
|
9890
|
+
"prompt",
|
|
9891
|
+
"message",
|
|
9892
|
+
"messages",
|
|
9893
|
+
"content",
|
|
9894
|
+
"body",
|
|
9895
|
+
"args",
|
|
9896
|
+
"argument",
|
|
9897
|
+
"result",
|
|
9898
|
+
"results",
|
|
9899
|
+
"output",
|
|
9900
|
+
"issue",
|
|
9901
|
+
"description",
|
|
9902
|
+
"summary",
|
|
9903
|
+
"payload",
|
|
9904
|
+
"script",
|
|
9905
|
+
"command",
|
|
9906
|
+
"text",
|
|
9907
|
+
"query"
|
|
9908
|
+
]);
|
|
9909
|
+
STACK_WORDS = new Set(["stack", "stacktrace", "trace"]);
|
|
9910
|
+
homePattern = new RegExp(`${escapeRegExp2(os3.homedir())}(?=[/\\\\]|$)|\\$HOME(?=[/\\\\]|$)`, "g");
|
|
9911
|
+
});
|
|
9912
|
+
|
|
9853
9913
|
// packages/workit-core/src/store/paths.ts
|
|
9854
9914
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
9855
9915
|
import { createHash as createHash5 } from "node:crypto";
|
|
9856
9916
|
import fs3 from "node:fs";
|
|
9857
|
-
import
|
|
9917
|
+
import path6 from "node:path";
|
|
9858
9918
|
function fastGit(root) {
|
|
9859
9919
|
if (DISCOVERY_ENV.some((name) => process.env[name]))
|
|
9860
9920
|
return null;
|
|
@@ -9870,7 +9930,7 @@ function fastGit(root) {
|
|
|
9870
9930
|
if (device !== null && stat.dev !== device)
|
|
9871
9931
|
return { kind: "none" };
|
|
9872
9932
|
device = stat.dev;
|
|
9873
|
-
const dotGit =
|
|
9933
|
+
const dotGit = path6.join(dir, ".git");
|
|
9874
9934
|
let entry = null;
|
|
9875
9935
|
try {
|
|
9876
9936
|
entry = fs3.statSync(dotGit);
|
|
@@ -9891,19 +9951,19 @@ function fastGit(root) {
|
|
|
9891
9951
|
const match = /^gitdir: (.+)$/mu.exec(text);
|
|
9892
9952
|
if (!match)
|
|
9893
9953
|
return null;
|
|
9894
|
-
gitDir =
|
|
9954
|
+
gitDir = path6.resolve(dir, match[1].trim());
|
|
9895
9955
|
} else
|
|
9896
9956
|
return null;
|
|
9897
|
-
if (!fs3.existsSync(
|
|
9957
|
+
if (!fs3.existsSync(path6.join(gitDir, "HEAD")))
|
|
9898
9958
|
return null;
|
|
9899
9959
|
} else if (isGitDir(dir))
|
|
9900
9960
|
gitDir = dir;
|
|
9901
9961
|
if (gitDir) {
|
|
9902
9962
|
let common = gitDir;
|
|
9903
9963
|
try {
|
|
9904
|
-
common =
|
|
9964
|
+
common = path6.resolve(gitDir, fs3.readFileSync(path6.join(gitDir, "commondir"), "utf8").trim());
|
|
9905
9965
|
} catch {}
|
|
9906
|
-
if (!fs3.existsSync(
|
|
9966
|
+
if (!fs3.existsSync(path6.join(common, "objects")))
|
|
9907
9967
|
return null;
|
|
9908
9968
|
return {
|
|
9909
9969
|
kind: "repo",
|
|
@@ -9913,26 +9973,26 @@ function fastGit(root) {
|
|
|
9913
9973
|
reftable: reftableRefs(common)
|
|
9914
9974
|
};
|
|
9915
9975
|
}
|
|
9916
|
-
const parent =
|
|
9976
|
+
const parent = path6.dirname(dir);
|
|
9917
9977
|
if (parent === dir)
|
|
9918
9978
|
return { kind: "none" };
|
|
9919
9979
|
dir = parent;
|
|
9920
9980
|
}
|
|
9921
9981
|
}
|
|
9922
9982
|
function resolveStore(root) {
|
|
9923
|
-
root =
|
|
9983
|
+
root = path6.resolve(root);
|
|
9924
9984
|
let directory = false;
|
|
9925
9985
|
try {
|
|
9926
9986
|
directory = fs3.statSync(root).isDirectory();
|
|
9927
9987
|
} catch {}
|
|
9928
9988
|
if (!directory)
|
|
9929
|
-
return { dir:
|
|
9989
|
+
return { dir: path6.join(root, ".workit"), shared: false, top: null };
|
|
9930
9990
|
const fast = fastGit(root);
|
|
9931
9991
|
if (fast?.kind === "none")
|
|
9932
|
-
return { dir:
|
|
9992
|
+
return { dir: path6.join(root, ".workit"), shared: false, top: null };
|
|
9933
9993
|
if (fast?.kind === "repo")
|
|
9934
9994
|
return {
|
|
9935
|
-
dir:
|
|
9995
|
+
dir: path6.join(fast.common, "workit"),
|
|
9936
9996
|
shared: true,
|
|
9937
9997
|
top: fast.top,
|
|
9938
9998
|
git: { gitDir: fast.gitDir, top: fast.top, reftable: fast.reftable }
|
|
@@ -9942,13 +10002,13 @@ function resolveStore(root) {
|
|
|
9942
10002
|
if (run.ok && common) {
|
|
9943
10003
|
const top = gitRun(root, ["rev-parse", "--path-format=absolute", "--show-toplevel"]);
|
|
9944
10004
|
return {
|
|
9945
|
-
dir:
|
|
10005
|
+
dir: path6.join(real(path6.resolve(root, common)), "workit"),
|
|
9946
10006
|
shared: true,
|
|
9947
10007
|
top: top.ok && top.stdout.trim() ? real(top.stdout.trim()) : null
|
|
9948
10008
|
};
|
|
9949
10009
|
}
|
|
9950
10010
|
if (run.missing || !run.ok && NOT_A_REPO.test(run.stderr))
|
|
9951
|
-
return { dir:
|
|
10011
|
+
return { dir: path6.join(root, ".workit"), shared: false, top: null };
|
|
9952
10012
|
return new Error(`cannot locate the workit store: git rev-parse failed (${run.stderr.trim().split(`
|
|
9953
10013
|
`)[0] || "no output"}); fix the repository (git status should work here)`);
|
|
9954
10014
|
}
|
|
@@ -9959,7 +10019,7 @@ function resolveTaskKey(root, location) {
|
|
|
9959
10019
|
if (location.git && !location.git.reftable) {
|
|
9960
10020
|
let head = "";
|
|
9961
10021
|
try {
|
|
9962
|
-
head = fs3.readFileSync(
|
|
10022
|
+
head = fs3.readFileSync(path6.join(location.git.gitDir, "HEAD"), "utf8").trim();
|
|
9963
10023
|
} catch {}
|
|
9964
10024
|
const ref = /^ref: refs\/heads\/(.+)$/u.exec(head);
|
|
9965
10025
|
if (ref && ref[1] !== ".invalid")
|
|
@@ -9990,7 +10050,7 @@ function resolveTaskKey(root, location) {
|
|
|
9990
10050
|
return { key: `detached-${shortHash(real(worktree))}`, kind: "detached", branch: null };
|
|
9991
10051
|
}
|
|
9992
10052
|
function checkoutRootOf(root, location) {
|
|
9993
|
-
const resolved =
|
|
10053
|
+
const resolved = path6.resolve(root);
|
|
9994
10054
|
let canonical = resolved;
|
|
9995
10055
|
try {
|
|
9996
10056
|
canonical = fs3.realpathSync(resolved);
|
|
@@ -10021,13 +10081,13 @@ function branchRenames(location) {
|
|
|
10021
10081
|
}
|
|
10022
10082
|
for (const entry of entries)
|
|
10023
10083
|
if (entry.isDirectory())
|
|
10024
|
-
walk(
|
|
10084
|
+
walk(path6.join(dir, entry.name));
|
|
10025
10085
|
else
|
|
10026
|
-
files.push(
|
|
10086
|
+
files.push(path6.join(dir, entry.name));
|
|
10027
10087
|
};
|
|
10028
|
-
walk(
|
|
10088
|
+
walk(path6.join(path6.dirname(location.dir), "logs", "refs", "heads"));
|
|
10029
10089
|
if (location.git)
|
|
10030
|
-
files.push(
|
|
10090
|
+
files.push(path6.join(location.git.gitDir, "logs", "HEAD"));
|
|
10031
10091
|
const seen = new Set;
|
|
10032
10092
|
const renames = [];
|
|
10033
10093
|
for (const file of files) {
|
|
@@ -10088,20 +10148,20 @@ var NOT_A_REPO, gitRun = (cwd, args) => {
|
|
|
10088
10148
|
}
|
|
10089
10149
|
}, DISCOVERY_ENV, isGitDir = (dir) => {
|
|
10090
10150
|
try {
|
|
10091
|
-
return fs3.statSync(
|
|
10151
|
+
return fs3.statSync(path6.join(dir, "HEAD")).isFile() && fs3.statSync(path6.join(dir, "objects")).isDirectory() && fs3.statSync(path6.join(dir, "refs")).isDirectory();
|
|
10092
10152
|
} catch {
|
|
10093
10153
|
return false;
|
|
10094
10154
|
}
|
|
10095
10155
|
}, reftableRefs = (common) => {
|
|
10096
10156
|
try {
|
|
10097
|
-
return /^\s*refstorage\s*=\s*reftable\s*$/imu.test(fs3.readFileSync(
|
|
10157
|
+
return /^\s*refstorage\s*=\s*reftable\s*$/imu.test(fs3.readFileSync(path6.join(common, "config"), "utf8"));
|
|
10098
10158
|
} catch {
|
|
10099
10159
|
return false;
|
|
10100
10160
|
}
|
|
10101
10161
|
}, rebasingBranch = (gitDir) => {
|
|
10102
10162
|
for (const state of ["rebase-merge", "rebase-apply"]) {
|
|
10103
10163
|
try {
|
|
10104
|
-
const ref = fs3.readFileSync(
|
|
10164
|
+
const ref = fs3.readFileSync(path6.join(gitDir, state, "head-name"), "utf8").trim();
|
|
10105
10165
|
const match = /^refs\/heads\/(.+)$/u.exec(ref);
|
|
10106
10166
|
if (match)
|
|
10107
10167
|
return match[1];
|
|
@@ -10112,7 +10172,7 @@ var NOT_A_REPO, gitRun = (cwd, args) => {
|
|
|
10112
10172
|
let canonical = real(root);
|
|
10113
10173
|
if (process.platform === "win32")
|
|
10114
10174
|
canonical = canonical.toLowerCase();
|
|
10115
|
-
const base =
|
|
10175
|
+
const base = path6.basename(canonical).replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 40) || "root";
|
|
10116
10176
|
return `${base}-${shortHash(canonical)}`;
|
|
10117
10177
|
};
|
|
10118
10178
|
var init_paths = __esm(() => {
|
|
@@ -10129,7 +10189,7 @@ var init_paths = __esm(() => {
|
|
|
10129
10189
|
// packages/workit-core/src/host-session.ts
|
|
10130
10190
|
import { createHash as createHash6 } from "node:crypto";
|
|
10131
10191
|
import fs4 from "node:fs";
|
|
10132
|
-
import
|
|
10192
|
+
import path7 from "node:path";
|
|
10133
10193
|
function hostSessionFromEnv(env) {
|
|
10134
10194
|
const value = (key) => env[key]?.trim() || null;
|
|
10135
10195
|
let inner = null;
|
|
@@ -10148,30 +10208,64 @@ function hostSessionFromEnv(env) {
|
|
|
10148
10208
|
}
|
|
10149
10209
|
return inner ? { host: inner.host, session: inner.session } : { host: declared, session: null };
|
|
10150
10210
|
}
|
|
10151
|
-
function
|
|
10211
|
+
function migrateRepoIssued(cwd) {
|
|
10212
|
+
if (cwd === undefined)
|
|
10213
|
+
return;
|
|
10214
|
+
let old;
|
|
10152
10215
|
try {
|
|
10153
|
-
const
|
|
10154
|
-
if (
|
|
10216
|
+
const location = resolveStore(cwd);
|
|
10217
|
+
if (location instanceof Error)
|
|
10155
10218
|
return;
|
|
10156
|
-
|
|
10219
|
+
old = path7.join(location.dir, "hooks", "issued");
|
|
10220
|
+
if (!fs4.existsSync(old))
|
|
10221
|
+
return;
|
|
10222
|
+
} catch {
|
|
10223
|
+
return;
|
|
10224
|
+
}
|
|
10225
|
+
for (const lead of safeList(old)) {
|
|
10226
|
+
try {
|
|
10227
|
+
const from = path7.join(old, lead);
|
|
10228
|
+
if (!fs4.statSync(from).isDirectory())
|
|
10229
|
+
continue;
|
|
10230
|
+
const to = path7.join(userIssuedRoot(), lead);
|
|
10231
|
+
fs4.mkdirSync(to, { recursive: true, mode: 448 });
|
|
10232
|
+
for (const id of fs4.readdirSync(from)) {
|
|
10233
|
+
fs4.copyFileSync(path7.join(from, id), path7.join(to, id));
|
|
10234
|
+
fs4.rmSync(path7.join(from, id), { force: true });
|
|
10235
|
+
}
|
|
10236
|
+
removeIfEmpty(from);
|
|
10237
|
+
} catch {}
|
|
10238
|
+
}
|
|
10239
|
+
removeIfEmpty(old);
|
|
10240
|
+
}
|
|
10241
|
+
function recordIssuedSession(cwd, lead, issued) {
|
|
10242
|
+
try {
|
|
10243
|
+
migrateRepoIssued(cwd);
|
|
10244
|
+
const dir = path7.join(userIssuedRoot(), hash(lead));
|
|
10245
|
+
fs4.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
10157
10246
|
const own = hash(issued);
|
|
10158
|
-
fs4.writeFileSync(
|
|
10247
|
+
fs4.writeFileSync(path7.join(dir, own), ISSUED_SESSIONS_MARKER);
|
|
10159
10248
|
const entries = fs4.readdirSync(dir);
|
|
10160
10249
|
if (entries.length <= ISSUED_PER_LEAD)
|
|
10161
10250
|
return;
|
|
10162
|
-
const byAge = entries.filter((name) => name !== own).map((name) => ({ name, at: fs4.statSync(
|
|
10251
|
+
const byAge = entries.filter((name) => name !== own).map((name) => ({ name, at: fs4.statSync(path7.join(dir, name)).mtimeMs })).toSorted((a, b) => a.at - b.at);
|
|
10163
10252
|
for (const { name } of byAge.slice(0, entries.length - ISSUED_PER_LEAD))
|
|
10164
|
-
fs4.rmSync(
|
|
10253
|
+
fs4.rmSync(path7.join(dir, name), { force: true });
|
|
10165
10254
|
} catch {}
|
|
10166
10255
|
}
|
|
10167
|
-
var HOST_SESSION_VARS, family = (host) => host?.replace(/_(?:cli|desktop)$/, "") ?? null, ISSUED_PER_LEAD = 64, ISSUED_SESSIONS_MARKER = "workit-issued-sessions/
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
}
|
|
10171
|
-
|
|
10172
|
-
|
|
10256
|
+
var HOST_SESSION_VARS, family = (host) => host?.replace(/_(?:cli|desktop)$/, "") ?? null, ISSUED_PER_LEAD = 64, ISSUED_SESSIONS_MARKER = "workit-issued-sessions/2", hash = (value) => createHash6("sha256").update(value).digest("hex").slice(0, 32), userIssuedRoot = () => path7.join(resolveStateDir(), "issued"), safeList = (dir) => {
|
|
10257
|
+
try {
|
|
10258
|
+
return fs4.readdirSync(dir);
|
|
10259
|
+
} catch {
|
|
10260
|
+
return [];
|
|
10261
|
+
}
|
|
10262
|
+
}, removeIfEmpty = (dir) => {
|
|
10263
|
+
try {
|
|
10264
|
+
fs4.rmdirSync(dir);
|
|
10265
|
+
} catch {}
|
|
10173
10266
|
}, OWN_CHILD_SHELL;
|
|
10174
10267
|
var init_host_session = __esm(() => {
|
|
10268
|
+
init_logger();
|
|
10175
10269
|
init_paths();
|
|
10176
10270
|
HOST_SESSION_VARS = [
|
|
10177
10271
|
["OPENCODE_SESSION_ID", () => "opencode"],
|
|
@@ -10188,7 +10282,7 @@ var init_host_session = __esm(() => {
|
|
|
10188
10282
|
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
10189
10283
|
import { createHash as createHash7, randomBytes } from "node:crypto";
|
|
10190
10284
|
import fs5 from "node:fs";
|
|
10191
|
-
import
|
|
10285
|
+
import path8 from "node:path";
|
|
10192
10286
|
function resolveCommit(cwd, ref) {
|
|
10193
10287
|
if (!safeRef(ref))
|
|
10194
10288
|
return null;
|
|
@@ -10254,14 +10348,14 @@ function diffHash(cwd, base, head) {
|
|
|
10254
10348
|
return `sha256:${hash.digest("hex")}`;
|
|
10255
10349
|
}
|
|
10256
10350
|
function storeRoot(cwd) {
|
|
10257
|
-
const location = resolveStore(
|
|
10351
|
+
const location = resolveStore(path8.resolve(cwd));
|
|
10258
10352
|
if (location instanceof Error)
|
|
10259
10353
|
return err("unavailable", location.message.replace(/; fix the repository.*$/u, ""), "fix the repository (git status should work here) or run from a non-git directory");
|
|
10260
10354
|
return { ok: true, value: { root: location.dir, shared: location.shared } };
|
|
10261
10355
|
}
|
|
10262
10356
|
function ledgerPath(cwd) {
|
|
10263
10357
|
const root = storeRoot(cwd);
|
|
10264
|
-
return root.ok ? { ok: true, value:
|
|
10358
|
+
return root.ok ? { ok: true, value: path8.join(root.value.root, "ledger", "ledger.jsonl") } : root;
|
|
10265
10359
|
}
|
|
10266
10360
|
function withLedgerLock(file, fn, waitMs = LOCK_WAIT_MS) {
|
|
10267
10361
|
const lock = `${file}.lock`;
|
|
@@ -10311,8 +10405,8 @@ function appendLine(file, build, options) {
|
|
|
10311
10405
|
}
|
|
10312
10406
|
};
|
|
10313
10407
|
try {
|
|
10314
|
-
fs5.mkdirSync(
|
|
10315
|
-
if (!options.forceLock && !onNetworkFs(
|
|
10408
|
+
fs5.mkdirSync(path8.dirname(file), { recursive: true });
|
|
10409
|
+
if (!options.forceLock && !onNetworkFs(path8.dirname(file)))
|
|
10316
10410
|
return write();
|
|
10317
10411
|
const locked = withLedgerLock(file, write);
|
|
10318
10412
|
return locked ?? err("busy", `ledger lock ${file}.lock is held`, "retry; remove the .lock directory if no workit process is running");
|
|
@@ -10727,12 +10821,12 @@ var LEDGER_VERSION = 1, MAX_LINE_BYTES = 4096, PASSING, FAILING, STRONG_RESULTS,
|
|
|
10727
10821
|
}
|
|
10728
10822
|
}, LOCK_WAIT_MS = 5000, LOCK_STALE_MS = 30000, LOCK_OWNER = "owner", lockToken = (lock) => {
|
|
10729
10823
|
try {
|
|
10730
|
-
return fs5.readFileSync(
|
|
10824
|
+
return fs5.readFileSync(path8.join(lock, LOCK_OWNER), "utf8");
|
|
10731
10825
|
} catch {
|
|
10732
10826
|
return null;
|
|
10733
10827
|
}
|
|
10734
10828
|
}, lockAgeMs = (lock) => {
|
|
10735
|
-
for (const target of [
|
|
10829
|
+
for (const target of [path8.join(lock, LOCK_OWNER), lock]) {
|
|
10736
10830
|
try {
|
|
10737
10831
|
return Date.now() - fs5.statSync(target).mtimeMs;
|
|
10738
10832
|
} catch {}
|
|
@@ -10842,7 +10936,7 @@ var init_ledger = __esm(() => {
|
|
|
10842
10936
|
throw error;
|
|
10843
10937
|
}
|
|
10844
10938
|
const token = `${process.pid}-${randomBytes(8).toString("hex")}`;
|
|
10845
|
-
fs5.writeFileSync(
|
|
10939
|
+
fs5.writeFileSync(path8.join(lock, LOCK_OWNER), token);
|
|
10846
10940
|
return token;
|
|
10847
10941
|
},
|
|
10848
10942
|
release(lock, token) {
|
|
@@ -10895,7 +10989,7 @@ var init_ledger = __esm(() => {
|
|
|
10895
10989
|
|
|
10896
10990
|
// packages/workit-core/src/core/policy/derive.ts
|
|
10897
10991
|
import { existsSync as existsSync2 } from "node:fs";
|
|
10898
|
-
import
|
|
10992
|
+
import path9 from "node:path";
|
|
10899
10993
|
function deriveRequirements(judgment, scope, constraints, verification = "self") {
|
|
10900
10994
|
const out = [];
|
|
10901
10995
|
const base = { scope, dependentAction: null };
|
|
@@ -11047,7 +11141,7 @@ var RULES, derived2 = (spec) => ({
|
|
|
11047
11141
|
decisionIds: []
|
|
11048
11142
|
};
|
|
11049
11143
|
}, planRecorded = (task, root) => {
|
|
11050
|
-
const cited = (latestJudgment(task)?.refs ?? []).find((ref) => ref.kind === "external" || ref.kind === "file" && existsSync2(
|
|
11144
|
+
const cited = (latestJudgment(task)?.refs ?? []).find((ref) => ref.kind === "external" || ref.kind === "file" && existsSync2(path9.resolve(root, ref.path)));
|
|
11051
11145
|
if (cited)
|
|
11052
11146
|
return {
|
|
11053
11147
|
met: true,
|
|
@@ -11643,8 +11737,8 @@ var init_judgment = __esm(() => {
|
|
|
11643
11737
|
var init_safe_write = () => {};
|
|
11644
11738
|
|
|
11645
11739
|
// packages/workit-core/src/autonomy.ts
|
|
11646
|
-
import
|
|
11647
|
-
import
|
|
11740
|
+
import os4 from "node:os";
|
|
11741
|
+
import path10 from "node:path";
|
|
11648
11742
|
function endpointOf(entry) {
|
|
11649
11743
|
const raw = entry?.defaultEndpoint;
|
|
11650
11744
|
if (raw === undefined)
|
|
@@ -11737,13 +11831,13 @@ function resolveAutonomy(cwd) {
|
|
|
11737
11831
|
}
|
|
11738
11832
|
var accountHome = () => {
|
|
11739
11833
|
try {
|
|
11740
|
-
return
|
|
11834
|
+
return os4.userInfo().homedir;
|
|
11741
11835
|
} catch {
|
|
11742
|
-
return
|
|
11836
|
+
return os4.homedir();
|
|
11743
11837
|
}
|
|
11744
|
-
}, grantsHome, grantsDir = () =>
|
|
11745
|
-
const configured =
|
|
11746
|
-
return configured ===
|
|
11838
|
+
}, grantsHome, grantsDir = () => path10.join(grantsHome.resolve(), ".config", "workit"), grantsOverride = () => {
|
|
11839
|
+
const configured = path10.resolve(resolveConfigDir());
|
|
11840
|
+
return configured === path10.resolve(grantsDir()) ? null : `the config directory is redirected to ${configured} (WORKFLOW_TOOLKIT_CONFIG, WORKFLOW_TOOLKIT_CONFIG_DIR or XDG_CONFIG_HOME); grants are read only from ${path10.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply`;
|
|
11747
11841
|
}, GRANT_KINDS, DEFAULT_GRANTS, DEFAULT_ENDPOINTS, DEFAULT_ENDPOINT = "commit", isDefaultEndpoint = (value) => typeof value === "string" && DEFAULT_ENDPOINTS.includes(value), DEFAULT_VERIFICATION = "self", verificationOf = (entry) => entry?.verification === "independent" ? "independent" : "self", isGrantValue = (value) => value === true || value === false || value === "verified", normalized = (kind, value) => value === "verified" && kind !== "merge" ? true : value, fromAutoApprove = (value) => {
|
|
11748
11842
|
if (value === true)
|
|
11749
11843
|
return { push: true, pr: true, merge: "verified" };
|
|
@@ -11883,7 +11977,7 @@ var init_read_open_flags = () => {};
|
|
|
11883
11977
|
// node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.js
|
|
11884
11978
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
11885
11979
|
import fsSync from "node:fs";
|
|
11886
|
-
import
|
|
11980
|
+
import path11 from "node:path";
|
|
11887
11981
|
function parseSidecarLockSnapshot(snapshot, parser) {
|
|
11888
11982
|
return snapshot && { ...snapshot, payload: parseSidecarLockPayload(snapshot.raw, parser) };
|
|
11889
11983
|
}
|
|
@@ -11911,13 +12005,13 @@ ${ownershipToken}
|
|
|
11911
12005
|
return { raw, ownershipToken };
|
|
11912
12006
|
}
|
|
11913
12007
|
function relativeSidecarLockPath(lockRoot, lockPath) {
|
|
11914
|
-
const resolved =
|
|
11915
|
-
const lexicalRelative =
|
|
11916
|
-
const relative = lexicalRelative !== ".." && !lexicalRelative.startsWith(`..${
|
|
11917
|
-
if (!relative || relative === ".." || relative.startsWith(`..${
|
|
12008
|
+
const resolved = path11.resolve(lockPath);
|
|
12009
|
+
const lexicalRelative = path11.relative(lockRoot.rootDir, resolved);
|
|
12010
|
+
const relative = lexicalRelative !== ".." && !lexicalRelative.startsWith(`..${path11.sep}`) && !path11.isAbsolute(lexicalRelative) ? lexicalRelative : path11.relative(lockRoot.rootReal, resolved);
|
|
12011
|
+
if (!relative || relative === ".." || relative.startsWith(`..${path11.sep}`) || path11.isAbsolute(relative)) {
|
|
11918
12012
|
throw new FsSafeError("outside-workspace", "sidecar lock path is outside lockRoot");
|
|
11919
12013
|
}
|
|
11920
|
-
return relative.split(
|
|
12014
|
+
return relative.split(path11.sep).join(path11.posix.sep);
|
|
11921
12015
|
}
|
|
11922
12016
|
function parseSidecarLockPayload(raw, parser) {
|
|
11923
12017
|
if (parser) {
|
|
@@ -12087,7 +12181,7 @@ function sleepSync(ms) {
|
|
|
12087
12181
|
|
|
12088
12182
|
// node_modules/@openclaw/fs-safe/dist/file-lock-sync.js
|
|
12089
12183
|
import fs8 from "node:fs";
|
|
12090
|
-
import
|
|
12184
|
+
import path12 from "node:path";
|
|
12091
12185
|
function getSyncHeldLocks() {
|
|
12092
12186
|
const globalWithState = globalThis;
|
|
12093
12187
|
if (!globalWithState[SYNC_HELD_LOCKS_KEY]) {
|
|
@@ -12165,26 +12259,26 @@ function canonicalLockParentSync(parent) {
|
|
|
12165
12259
|
return process.platform === "win32" ? fs8.realpathSync.native(parent) : fs8.realpathSync(parent);
|
|
12166
12260
|
}
|
|
12167
12261
|
function normalizeTargetPath(targetPath) {
|
|
12168
|
-
const resolved =
|
|
12169
|
-
fs8.mkdirSync(
|
|
12262
|
+
const resolved = path12.resolve(targetPath);
|
|
12263
|
+
fs8.mkdirSync(path12.dirname(resolved), { recursive: true });
|
|
12170
12264
|
try {
|
|
12171
|
-
return
|
|
12265
|
+
return path12.join(canonicalLockParentSync(path12.dirname(resolved)), path12.basename(resolved));
|
|
12172
12266
|
} catch {
|
|
12173
12267
|
return resolved;
|
|
12174
12268
|
}
|
|
12175
12269
|
}
|
|
12176
12270
|
function boundedLockPath(lockPath, lockRoot) {
|
|
12177
|
-
const resolved =
|
|
12271
|
+
const resolved = path12.resolve(lockPath);
|
|
12178
12272
|
if (!lockRoot)
|
|
12179
12273
|
return resolved;
|
|
12180
12274
|
relativeSidecarLockPath(lockRoot, resolved);
|
|
12181
|
-
const parent =
|
|
12275
|
+
const parent = path12.dirname(resolved);
|
|
12182
12276
|
const parentReal = canonicalLockParentSync(parent);
|
|
12183
|
-
const parentRelative =
|
|
12184
|
-
if (parentRelative === ".." || parentRelative.startsWith(`..${
|
|
12277
|
+
const parentRelative = path12.relative(lockRoot.rootReal, parentReal);
|
|
12278
|
+
if (parentRelative === ".." || parentRelative.startsWith(`..${path12.sep}`) || path12.isAbsolute(parentRelative)) {
|
|
12185
12279
|
throw new FsSafeError("outside-workspace", "sidecar lock parent is outside lockRoot");
|
|
12186
12280
|
}
|
|
12187
|
-
return
|
|
12281
|
+
return path12.join(parentReal, path12.basename(resolved));
|
|
12188
12282
|
}
|
|
12189
12283
|
function defaultShouldReclaim(snapshot, staleMs, nowMs) {
|
|
12190
12284
|
const createdAtMs = sidecarLockPayloadCreatedAtMs(snapshot.payload);
|
|
@@ -12401,13 +12495,13 @@ var init_file_lock = __esm(() => {
|
|
|
12401
12495
|
|
|
12402
12496
|
// packages/workit-core/src/core/package-root.ts
|
|
12403
12497
|
import { existsSync as existsSync3 } from "node:fs";
|
|
12404
|
-
import
|
|
12498
|
+
import path13 from "node:path";
|
|
12405
12499
|
import { fileURLToPath } from "node:url";
|
|
12406
12500
|
var packageRoot = () => {
|
|
12407
|
-
let dir =
|
|
12501
|
+
let dir = path13.dirname(fileURLToPath(import.meta.url));
|
|
12408
12502
|
while (true) {
|
|
12409
|
-
const parent =
|
|
12410
|
-
if (existsSync3(
|
|
12503
|
+
const parent = path13.dirname(dir);
|
|
12504
|
+
if (existsSync3(path13.join(dir, "package.json")) || parent === dir)
|
|
12411
12505
|
return dir;
|
|
12412
12506
|
dir = parent;
|
|
12413
12507
|
}
|
|
@@ -12548,7 +12642,7 @@ var init_store_lock = __esm(() => {
|
|
|
12548
12642
|
// packages/workit-core/src/store/event-log.ts
|
|
12549
12643
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
12550
12644
|
import fs10 from "node:fs";
|
|
12551
|
-
import
|
|
12645
|
+
import path14 from "node:path";
|
|
12552
12646
|
function readLog(file, from = 0, expectSeq = null) {
|
|
12553
12647
|
let fd;
|
|
12554
12648
|
try {
|
|
@@ -12621,7 +12715,7 @@ function appendEvent(file, event, validEnd) {
|
|
|
12621
12715
|
fs10.closeSync(fd);
|
|
12622
12716
|
}
|
|
12623
12717
|
if (created)
|
|
12624
|
-
fsyncDirectory(
|
|
12718
|
+
fsyncDirectory(path14.dirname(file));
|
|
12625
12719
|
return validEnd;
|
|
12626
12720
|
}
|
|
12627
12721
|
function replaceFile(file, bytes, durable) {
|
|
@@ -12637,7 +12731,7 @@ function replaceFile(file, bytes, durable) {
|
|
|
12637
12731
|
}
|
|
12638
12732
|
renameWithRetry(temporary, file);
|
|
12639
12733
|
if (durable)
|
|
12640
|
-
fsyncDirectory(
|
|
12734
|
+
fsyncDirectory(path14.dirname(file));
|
|
12641
12735
|
} catch (error) {
|
|
12642
12736
|
try {
|
|
12643
12737
|
fs10.unlinkSync(temporary);
|
|
@@ -12947,7 +13041,7 @@ var init_notes = __esm(() => {
|
|
|
12947
13041
|
// packages/workit-core/src/core/task-store.ts
|
|
12948
13042
|
import { createHash as createHash9, randomUUID as randomUUID3 } from "node:crypto";
|
|
12949
13043
|
import * as fs11 from "node:fs";
|
|
12950
|
-
import
|
|
13044
|
+
import path15 from "node:path";
|
|
12951
13045
|
|
|
12952
13046
|
class TaskStore {
|
|
12953
13047
|
root;
|
|
@@ -12959,7 +13053,7 @@ class TaskStore {
|
|
|
12959
13053
|
migrationChecked = false;
|
|
12960
13054
|
compactDue = new Set;
|
|
12961
13055
|
constructor(root, options = {}) {
|
|
12962
|
-
const resolved =
|
|
13056
|
+
const resolved = path15.resolve(root);
|
|
12963
13057
|
this.origin = fs11.existsSync(resolved) ? fs11.realpathSync(resolved) : resolved;
|
|
12964
13058
|
this.located = resolveStore(this.origin);
|
|
12965
13059
|
this.root = checkoutRootOf(this.origin, this.located);
|
|
@@ -12968,7 +13062,7 @@ class TaskStore {
|
|
|
12968
13062
|
this.migrateOnRead = options.migrateOnRead;
|
|
12969
13063
|
}
|
|
12970
13064
|
location() {
|
|
12971
|
-
if (this.located !== undefined && !(this.located instanceof Error) && !this.located.shared && fs11.existsSync(
|
|
13065
|
+
if (this.located !== undefined && !(this.located instanceof Error) && !this.located.shared && fs11.existsSync(path15.join(this.root, ".git"))) {
|
|
12972
13066
|
this.located = undefined;
|
|
12973
13067
|
this.migrationChecked = false;
|
|
12974
13068
|
}
|
|
@@ -13124,7 +13218,7 @@ class TaskStore {
|
|
|
13124
13218
|
const moved = this.bindLocked(again.data.id, key, input.now);
|
|
13125
13219
|
return moved.ok ? success(moved.data.revision, null, { task: moved.data, created: false, key }) : moved;
|
|
13126
13220
|
}
|
|
13127
|
-
const label = key.kind === "branch" ? `branch ${key.branch}` : key.kind === "detached" ? "a detached HEAD" :
|
|
13221
|
+
const label = key.kind === "branch" ? `branch ${key.branch}` : key.kind === "detached" ? "a detached HEAD" : path15.basename(this.root) || this.root;
|
|
13128
13222
|
const intent = {
|
|
13129
13223
|
objective: input.objective?.trim() || `Work on ${label}`,
|
|
13130
13224
|
scope: { description: `the checkout (${label})`, paths: ["."], exclusions: [] },
|
|
@@ -13184,14 +13278,14 @@ class TaskStore {
|
|
|
13184
13278
|
const branch = key.ok ? key.data.branch : null;
|
|
13185
13279
|
if (!branch || !location.ok)
|
|
13186
13280
|
return success(null, null, null);
|
|
13187
|
-
const common =
|
|
13188
|
-
const heads =
|
|
13189
|
-
const headLog = location.data.git ?
|
|
13281
|
+
const common = path15.dirname(location.data.dir);
|
|
13282
|
+
const heads = path15.join(common, "logs", "refs", "heads");
|
|
13283
|
+
const headLog = location.data.git ? path15.join(location.data.git.gitDir, "logs", "HEAD") : "";
|
|
13190
13284
|
const signatures = [
|
|
13191
|
-
|
|
13285
|
+
path15.join(heads, branch),
|
|
13192
13286
|
headLog,
|
|
13193
13287
|
heads,
|
|
13194
|
-
|
|
13288
|
+
path15.join(common, "packed-refs")
|
|
13195
13289
|
].map((file) => fileSignature(file) ?? "-");
|
|
13196
13290
|
const slot = `${location.data.dir}\x00${headLog}\x00${branch}`;
|
|
13197
13291
|
let resolved = origins.get(slot);
|
|
@@ -13203,7 +13297,7 @@ class TaskStore {
|
|
|
13203
13297
|
aliases.push(rename.from);
|
|
13204
13298
|
const start = branchStart(location.data, branch, aliases);
|
|
13205
13299
|
const slash = start?.indexOf("/") ?? -1;
|
|
13206
|
-
const remote = slash > 0 && !refExists(common, `refs/heads/${start}`) && (refExists(common, `refs/remotes/${start}`) || readText(
|
|
13300
|
+
const remote = slash > 0 && !refExists(common, `refs/heads/${start}`) && (refExists(common, `refs/remotes/${start}`) || readText(path15.join(common, "config")).includes(`[remote "${start.slice(0, slash)}"]`));
|
|
13207
13301
|
const name = start && (remote ? start.slice(slash + 1) : start);
|
|
13208
13302
|
resolved = {
|
|
13209
13303
|
signature: signatures.join("|"),
|
|
@@ -13441,13 +13535,13 @@ class TaskStore {
|
|
|
13441
13535
|
if (!ready.ok)
|
|
13442
13536
|
return ready;
|
|
13443
13537
|
const dirs = this.paths();
|
|
13444
|
-
const recovery =
|
|
13538
|
+
const recovery = path15.join(this.root, ".workit", "recovery");
|
|
13445
13539
|
if (fs11.existsSync(recovery)) {
|
|
13446
13540
|
let files = 0;
|
|
13447
13541
|
let bytes = 0;
|
|
13448
13542
|
try {
|
|
13449
13543
|
for (const name of fs11.readdirSync(recovery)) {
|
|
13450
|
-
const stat = fs11.lstatSync(
|
|
13544
|
+
const stat = fs11.lstatSync(path15.join(recovery, name));
|
|
13451
13545
|
if (!stat.isFile())
|
|
13452
13546
|
continue;
|
|
13453
13547
|
files += 1;
|
|
@@ -13500,7 +13594,7 @@ class TaskStore {
|
|
|
13500
13594
|
if (fs11.existsSync(dirs.blobs))
|
|
13501
13595
|
for (const name of fs11.readdirSync(dirs.blobs)) {
|
|
13502
13596
|
const digest = name.replace(/\.json$/, "");
|
|
13503
|
-
const file =
|
|
13597
|
+
const file = path15.join(dirs.blobs, name);
|
|
13504
13598
|
let stat;
|
|
13505
13599
|
try {
|
|
13506
13600
|
stat = fs11.lstatSync(file);
|
|
@@ -13518,7 +13612,7 @@ class TaskStore {
|
|
|
13518
13612
|
}
|
|
13519
13613
|
return success(null, null, null);
|
|
13520
13614
|
};
|
|
13521
|
-
const swept = dryRun ? sweep() : this.withLock(
|
|
13615
|
+
const swept = dryRun ? sweep() : this.withLock(path15.join(dirs.dir, "gc.lock"), sweep);
|
|
13522
13616
|
if (!swept.ok)
|
|
13523
13617
|
return swept;
|
|
13524
13618
|
const temporaryDirs = [
|
|
@@ -13526,7 +13620,7 @@ class TaskStore {
|
|
|
13526
13620
|
dirs.tasks,
|
|
13527
13621
|
dirs.blobs,
|
|
13528
13622
|
dirs.checkout,
|
|
13529
|
-
...names.map((name) =>
|
|
13623
|
+
...names.map((name) => path15.join(dirs.tasks, name))
|
|
13530
13624
|
];
|
|
13531
13625
|
for (const directory of temporaryDirs) {
|
|
13532
13626
|
if (!fs11.existsSync(directory))
|
|
@@ -13534,7 +13628,7 @@ class TaskStore {
|
|
|
13534
13628
|
for (const name of fs11.readdirSync(directory)) {
|
|
13535
13629
|
if (!name.endsWith(".tmp") && !name.endsWith(".probe"))
|
|
13536
13630
|
continue;
|
|
13537
|
-
const file =
|
|
13631
|
+
const file = path15.join(directory, name);
|
|
13538
13632
|
try {
|
|
13539
13633
|
const stat = fs11.lstatSync(file);
|
|
13540
13634
|
if (!stat.isFile() || nowMs - stat.mtimeMs <= STALE_TEMPORARY_MS)
|
|
@@ -13551,30 +13645,30 @@ class TaskStore {
|
|
|
13551
13645
|
}
|
|
13552
13646
|
paths() {
|
|
13553
13647
|
const location = this.location();
|
|
13554
|
-
const dir = location.ok ? location.data.dir :
|
|
13555
|
-
const checkout =
|
|
13648
|
+
const dir = location.ok ? location.data.dir : path15.join(this.root, ".workit");
|
|
13649
|
+
const checkout = path15.join(dir, "checkouts", checkoutSlug(this.root));
|
|
13556
13650
|
return {
|
|
13557
13651
|
dir,
|
|
13558
13652
|
shared: location.ok ? location.data.shared : false,
|
|
13559
|
-
marker:
|
|
13653
|
+
marker: path15.join(dir, "store.json"),
|
|
13560
13654
|
checkout,
|
|
13561
|
-
workspace:
|
|
13562
|
-
checkoutLock:
|
|
13563
|
-
tasks:
|
|
13564
|
-
index:
|
|
13565
|
-
blobs:
|
|
13566
|
-
legacy:
|
|
13567
|
-
v2:
|
|
13655
|
+
workspace: path15.join(checkout, "workspace.json"),
|
|
13656
|
+
checkoutLock: path15.join(checkout, "metadata.lock"),
|
|
13657
|
+
tasks: path15.join(dir, "tasks"),
|
|
13658
|
+
index: path15.join(dir, "task-index.json"),
|
|
13659
|
+
blobs: path15.join(dir, "blobs", "candidates"),
|
|
13660
|
+
legacy: path15.join(dir, "legacy", checkoutSlug(this.root), "v2"),
|
|
13661
|
+
v2: path15.join(this.root, ".workit")
|
|
13568
13662
|
};
|
|
13569
13663
|
}
|
|
13570
13664
|
eventsPath(taskId) {
|
|
13571
|
-
return
|
|
13665
|
+
return path15.join(this.paths().tasks, taskId, "events.jsonl");
|
|
13572
13666
|
}
|
|
13573
13667
|
snapshotPath(taskId) {
|
|
13574
|
-
return
|
|
13668
|
+
return path15.join(this.paths().tasks, taskId, "snapshot.json");
|
|
13575
13669
|
}
|
|
13576
13670
|
taskLockPath(taskId) {
|
|
13577
|
-
return
|
|
13671
|
+
return path15.join(this.paths().tasks, taskId, "lock");
|
|
13578
13672
|
}
|
|
13579
13673
|
ready(write = false) {
|
|
13580
13674
|
const location = this.location();
|
|
@@ -13613,13 +13707,13 @@ class TaskStore {
|
|
|
13613
13707
|
return {
|
|
13614
13708
|
read: (digest) => {
|
|
13615
13709
|
try {
|
|
13616
|
-
return JSON.parse(fs11.readFileSync(
|
|
13710
|
+
return JSON.parse(fs11.readFileSync(path15.join(dir, `${digest}.json`), "utf8"));
|
|
13617
13711
|
} catch (error) {
|
|
13618
13712
|
throw new LogDamage(`stored candidate ${digest} is missing or unreadable: ${String(error)}`);
|
|
13619
13713
|
}
|
|
13620
13714
|
},
|
|
13621
13715
|
write: (digest, value) => {
|
|
13622
|
-
const file =
|
|
13716
|
+
const file = path15.join(dir, `${digest}.json`);
|
|
13623
13717
|
if (fs11.existsSync(file)) {
|
|
13624
13718
|
const stamp = new Date;
|
|
13625
13719
|
try {
|
|
@@ -13811,7 +13905,7 @@ class TaskStore {
|
|
|
13811
13905
|
}
|
|
13812
13906
|
}
|
|
13813
13907
|
openTask(record, type, key, legacy = null) {
|
|
13814
|
-
const dir =
|
|
13908
|
+
const dir = path15.join(this.paths().tasks, record.id);
|
|
13815
13909
|
fs11.mkdirSync(dir, { recursive: true });
|
|
13816
13910
|
const blobs = this.blobStore();
|
|
13817
13911
|
const bound = key ? { ...key, boundAt: key.boundAt ?? new Date().toISOString() } : null;
|
|
@@ -13904,7 +13998,7 @@ class TaskStore {
|
|
|
13904
13998
|
}
|
|
13905
13999
|
withKeyLock(key, operation) {
|
|
13906
14000
|
const digest = createHash9("sha256").update(key).digest("hex").slice(0, 32);
|
|
13907
|
-
return this.withLock(
|
|
14001
|
+
return this.withLock(path15.join(this.paths().dir, "keys", `${digest}.lock`), operation);
|
|
13908
14002
|
}
|
|
13909
14003
|
bindLocked(taskId, key, timestamp) {
|
|
13910
14004
|
const current = this.readWorkspace();
|
|
@@ -14045,7 +14139,7 @@ class TaskStore {
|
|
|
14045
14139
|
writeWorkspace(record) {
|
|
14046
14140
|
const file = this.paths().workspace;
|
|
14047
14141
|
try {
|
|
14048
|
-
fs11.mkdirSync(
|
|
14142
|
+
fs11.mkdirSync(path15.dirname(file), { recursive: true });
|
|
14049
14143
|
replaceFile(file, `${canonicalJson(record)}
|
|
14050
14144
|
`, true);
|
|
14051
14145
|
return success(null, null, null);
|
|
@@ -14123,23 +14217,23 @@ class TaskStore {
|
|
|
14123
14217
|
return failure2("revision_conflict", "workspace revision does not match; omit expectedWorkspaceRevision to use the current record", { expectedWorkspaceRevision: expected, actualWorkspaceRevision: actual });
|
|
14124
14218
|
}
|
|
14125
14219
|
v2Dirs() {
|
|
14126
|
-
return [...new Set([this.root, this.origin])].map((dir) =>
|
|
14220
|
+
return [...new Set([this.root, this.origin])].map((dir) => path15.join(dir, ".workit"));
|
|
14127
14221
|
}
|
|
14128
14222
|
pendingMigrations() {
|
|
14129
14223
|
return this.v2Dirs().filter((dir) => {
|
|
14130
|
-
const raw = this.readV2Workspace(
|
|
14224
|
+
const raw = this.readV2Workspace(path15.join(dir, "workspace.json"));
|
|
14131
14225
|
return raw !== null && raw !== TOMBSTONE;
|
|
14132
14226
|
});
|
|
14133
14227
|
}
|
|
14134
14228
|
migrateV2(v2) {
|
|
14135
14229
|
const dirs = this.paths();
|
|
14136
|
-
const v2Workspace =
|
|
14137
|
-
const v2Tasks =
|
|
14138
|
-
const legacy =
|
|
14230
|
+
const v2Workspace = path15.join(v2, "workspace.json");
|
|
14231
|
+
const v2Tasks = path15.join(v2, "tasks");
|
|
14232
|
+
const legacy = path15.join(dirs.dir, "legacy", checkoutSlug(path15.dirname(v2)), "v2");
|
|
14139
14233
|
const raw = this.readV2Workspace(v2Workspace);
|
|
14140
14234
|
if (raw === null || raw === TOMBSTONE)
|
|
14141
14235
|
return success(null, null, null);
|
|
14142
|
-
return this.withLock(dirs.checkoutLock, () => this.withLock(
|
|
14236
|
+
return this.withLock(dirs.checkoutLock, () => this.withLock(path15.join(v2, "metadata.lock"), () => {
|
|
14143
14237
|
const workspace = this.readV2Workspace(v2Workspace);
|
|
14144
14238
|
if (workspace === null || workspace === TOMBSTONE)
|
|
14145
14239
|
return success(null, null, null);
|
|
@@ -14148,7 +14242,7 @@ class TaskStore {
|
|
|
14148
14242
|
return failure2("recovery_required", `cannot migrate the 2.x store at ${v2}: ${parsedWorkspace.error}; move it aside to start fresh`, { path: v2Workspace });
|
|
14149
14243
|
let files = [];
|
|
14150
14244
|
try {
|
|
14151
|
-
files = fs11.readdirSync(v2Tasks).filter((name) => name.endsWith(".json") && validId(name.slice(0, -5))).filter((name) => !this.isStub(
|
|
14245
|
+
files = fs11.readdirSync(v2Tasks).filter((name) => name.endsWith(".json") && validId(name.slice(0, -5))).filter((name) => !this.isStub(path15.join(v2Tasks, name)));
|
|
14152
14246
|
} catch {}
|
|
14153
14247
|
const current = this.readWorkspace();
|
|
14154
14248
|
if (!current.ok)
|
|
@@ -14166,21 +14260,21 @@ class TaskStore {
|
|
|
14166
14260
|
let skipped = 0;
|
|
14167
14261
|
const done = new Map;
|
|
14168
14262
|
try {
|
|
14169
|
-
fs11.mkdirSync(
|
|
14263
|
+
fs11.mkdirSync(path15.join(legacy, "tasks"), { recursive: true });
|
|
14170
14264
|
for (const name of ["workspace.json", "index.json"])
|
|
14171
|
-
if (fs11.existsSync(
|
|
14172
|
-
fs11.copyFileSync(
|
|
14265
|
+
if (fs11.existsSync(path15.join(v2, name)))
|
|
14266
|
+
fs11.copyFileSync(path15.join(v2, name), path15.join(legacy, name));
|
|
14173
14267
|
for (const name of files) {
|
|
14174
14268
|
const id = name.slice(0, -5);
|
|
14175
|
-
const file =
|
|
14269
|
+
const file = path15.join(v2Tasks, name);
|
|
14176
14270
|
const bytes = fs11.readFileSync(file, "utf8");
|
|
14177
14271
|
const digest = sha256(bytes);
|
|
14178
|
-
fs11.writeFileSync(
|
|
14272
|
+
fs11.writeFileSync(path15.join(legacy, "tasks", name), bytes);
|
|
14179
14273
|
const parsed = this.parseRecord(bytes, taskRecordSchema, "2.x task");
|
|
14180
14274
|
if (!parsed.ok || parsed.data.id !== id)
|
|
14181
14275
|
return failure2("recovery_required", `cannot migrate 2.x task ${id}: ${parsed.ok ? "file name and record ID differ" : parsed.error}; move ${file} aside to continue`, { path: file });
|
|
14182
14276
|
const record = { ...parsed.data, workspaceId: target.id };
|
|
14183
|
-
const origin = { path:
|
|
14277
|
+
const origin = { path: path15.join(legacy, "tasks", name), digest };
|
|
14184
14278
|
if (!fs11.existsSync(this.eventsPath(id))) {
|
|
14185
14279
|
this.openTask(record, "migrated.from_v2", null, origin);
|
|
14186
14280
|
migrated += 1;
|
|
@@ -14216,7 +14310,7 @@ class TaskStore {
|
|
|
14216
14310
|
try {
|
|
14217
14311
|
let complete = true;
|
|
14218
14312
|
for (const [name, digest] of done) {
|
|
14219
|
-
const file =
|
|
14313
|
+
const file = path15.join(v2Tasks, name);
|
|
14220
14314
|
if (sha256(fs11.readFileSync(file, "utf8")) !== digest) {
|
|
14221
14315
|
complete = false;
|
|
14222
14316
|
continue;
|
|
@@ -14227,7 +14321,7 @@ class TaskStore {
|
|
|
14227
14321
|
return failure2("busy", `the 2.x store at ${v2} changed during migration; retry`, {
|
|
14228
14322
|
path: v2
|
|
14229
14323
|
});
|
|
14230
|
-
fs11.rmSync(
|
|
14324
|
+
fs11.rmSync(path15.join(v2, "index.json"), { force: true });
|
|
14231
14325
|
this.writeTombstone(v2, target.id);
|
|
14232
14326
|
} catch (error) {
|
|
14233
14327
|
return failure2("storage_error", `cannot finish the 2.x migration: ${String(error)}`, {
|
|
@@ -14247,7 +14341,7 @@ class TaskStore {
|
|
|
14247
14341
|
}
|
|
14248
14342
|
adoptLocalStore() {
|
|
14249
14343
|
const dirs = this.paths();
|
|
14250
|
-
const marker =
|
|
14344
|
+
const marker = path15.join(dirs.v2, "store.json");
|
|
14251
14345
|
if (!dirs.shared || !fs11.existsSync(marker))
|
|
14252
14346
|
return success(null, null, null);
|
|
14253
14347
|
return this.withLock(dirs.checkoutLock, () => {
|
|
@@ -14257,7 +14351,7 @@ class TaskStore {
|
|
|
14257
14351
|
try {
|
|
14258
14352
|
const merge = (from, to) => {
|
|
14259
14353
|
if (!fs11.existsSync(to)) {
|
|
14260
|
-
fs11.mkdirSync(
|
|
14354
|
+
fs11.mkdirSync(path15.dirname(to), { recursive: true });
|
|
14261
14355
|
try {
|
|
14262
14356
|
fs11.renameSync(from, to);
|
|
14263
14357
|
} catch {
|
|
@@ -14268,24 +14362,24 @@ class TaskStore {
|
|
|
14268
14362
|
}
|
|
14269
14363
|
if (fs11.lstatSync(from).isDirectory() && fs11.lstatSync(to).isDirectory())
|
|
14270
14364
|
for (const name of fs11.readdirSync(from))
|
|
14271
|
-
merge(
|
|
14365
|
+
merge(path15.join(from, name), path15.join(to, name));
|
|
14272
14366
|
};
|
|
14273
14367
|
for (const sub of ["tasks", "checkouts", "blobs", "legacy"]) {
|
|
14274
|
-
const from =
|
|
14368
|
+
const from = path15.join(dirs.v2, sub);
|
|
14275
14369
|
if (!fs11.existsSync(from))
|
|
14276
14370
|
continue;
|
|
14277
14371
|
if (sub === "tasks") {
|
|
14278
14372
|
for (const name of fs11.readdirSync(from))
|
|
14279
|
-
if (validId(name) && !fs11.existsSync(
|
|
14373
|
+
if (validId(name) && !fs11.existsSync(path15.join(dirs.dir, sub, name)))
|
|
14280
14374
|
tasks += 1;
|
|
14281
14375
|
}
|
|
14282
|
-
merge(from,
|
|
14376
|
+
merge(from, path15.join(dirs.dir, sub));
|
|
14283
14377
|
}
|
|
14284
|
-
const ledger =
|
|
14285
|
-
if (fs11.existsSync(ledger) && !fs11.existsSync(
|
|
14286
|
-
merge(ledger,
|
|
14287
|
-
fs11.rmSync(
|
|
14288
|
-
fs11.renameSync(marker,
|
|
14378
|
+
const ledger = path15.join(dirs.v2, "ledger");
|
|
14379
|
+
if (fs11.existsSync(ledger) && !fs11.existsSync(path15.join(dirs.dir, "ledger")))
|
|
14380
|
+
merge(ledger, path15.join(dirs.dir, "ledger"));
|
|
14381
|
+
fs11.rmSync(path15.join(dirs.v2, "task-index.json"), { force: true });
|
|
14382
|
+
fs11.renameSync(marker, path15.join(dirs.v2, "store.moved.json"));
|
|
14289
14383
|
} catch (error) {
|
|
14290
14384
|
return failure2("storage_error", `cannot move ${dirs.v2} into ${dirs.dir}: ${String(error)}`, {
|
|
14291
14385
|
path: dirs.v2
|
|
@@ -14323,7 +14417,7 @@ class TaskStore {
|
|
|
14323
14417
|
schemaVersion: SCHEMA_VERSION,
|
|
14324
14418
|
id: workspaceId ?? newId(),
|
|
14325
14419
|
revision: newRevision(),
|
|
14326
|
-
root:
|
|
14420
|
+
root: path15.dirname(v2),
|
|
14327
14421
|
runtime: { createdWith: version, updatedWith: version },
|
|
14328
14422
|
writer: null,
|
|
14329
14423
|
store: {
|
|
@@ -14335,11 +14429,11 @@ class TaskStore {
|
|
|
14335
14429
|
critical: ["store"]
|
|
14336
14430
|
};
|
|
14337
14431
|
fs11.mkdirSync(v2, { recursive: true });
|
|
14338
|
-
const ignore =
|
|
14432
|
+
const ignore = path15.join(v2, ".gitignore");
|
|
14339
14433
|
if (!fs11.existsSync(ignore))
|
|
14340
14434
|
fs11.writeFileSync(ignore, `*
|
|
14341
14435
|
`);
|
|
14342
|
-
replaceFile(
|
|
14436
|
+
replaceFile(path15.join(v2, "workspace.json"), `${JSON.stringify(marker, null, 2)}
|
|
14343
14437
|
`, true);
|
|
14344
14438
|
}
|
|
14345
14439
|
stubFor(taskId) {
|
|
@@ -14363,8 +14457,8 @@ class TaskStore {
|
|
|
14363
14457
|
}
|
|
14364
14458
|
writeTombstoneIfMissing() {
|
|
14365
14459
|
try {
|
|
14366
|
-
const v2 =
|
|
14367
|
-
if (fs11.existsSync(
|
|
14460
|
+
const v2 = path15.join(this.root, ".workit");
|
|
14461
|
+
if (fs11.existsSync(path15.join(v2, "workspace.json")))
|
|
14368
14462
|
return;
|
|
14369
14463
|
let id = null;
|
|
14370
14464
|
try {
|
|
@@ -14381,7 +14475,7 @@ class TaskStore {
|
|
|
14381
14475
|
replaceFile(dirs.marker, `${JSON.stringify({ format: "workit-store", version: STORE_FORMAT, createdWith: runtimeVersion() })}
|
|
14382
14476
|
`, false);
|
|
14383
14477
|
if (!dirs.shared) {
|
|
14384
|
-
const ignore =
|
|
14478
|
+
const ignore = path15.join(dirs.dir, ".gitignore");
|
|
14385
14479
|
let current = null;
|
|
14386
14480
|
try {
|
|
14387
14481
|
current = fs11.readFileSync(ignore, "utf8");
|
|
@@ -14441,7 +14535,7 @@ class TaskStore {
|
|
|
14441
14535
|
withLock(lockPath, operation) {
|
|
14442
14536
|
try {
|
|
14443
14537
|
this.initializeStorage();
|
|
14444
|
-
fs11.mkdirSync(
|
|
14538
|
+
fs11.mkdirSync(path15.dirname(lockPath), { recursive: true });
|
|
14445
14539
|
} catch (error) {
|
|
14446
14540
|
return failure2("storage_error", `unable to initialize store: ${String(error)}`, {
|
|
14447
14541
|
path: this.paths().dir
|
|
@@ -14504,7 +14598,7 @@ class TaskStore {
|
|
|
14504
14598
|
if (isTransientWindowsError(error) && !this.lockHolderPresent(lockPath) && !this.lockDirWritable(lockPath))
|
|
14505
14599
|
return failure2("storage_error", `cannot create the workit lock (${code}); no other Workit call holds it`, {
|
|
14506
14600
|
path: lockPath,
|
|
14507
|
-
guidance: `Check permissions and the read-only attribute on ${
|
|
14601
|
+
guidance: `Check permissions and the read-only attribute on ${path15.dirname(lockPath)}.`
|
|
14508
14602
|
});
|
|
14509
14603
|
if (code === "EEXIST" || code === "file_lock_timeout" || code === "file_lock_stale" || isTransientWindowsError(error)) {
|
|
14510
14604
|
let lock = null;
|
|
@@ -14562,7 +14656,7 @@ var MIGRATION_PENDING = "workit migration pending", STORE_FORMAT = 3, STORE_MIN_
|
|
|
14562
14656
|
}, now = () => new Date().toISOString().replace(/\.\d{3}Z$/, "Z"), oldestFirst = (left, right) => left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id), cachedRuntimeVersion = null, runtimeVersion = () => {
|
|
14563
14657
|
if (cachedRuntimeVersion === null) {
|
|
14564
14658
|
try {
|
|
14565
|
-
const pkg = JSON.parse(fs11.readFileSync(
|
|
14659
|
+
const pkg = JSON.parse(fs11.readFileSync(path15.join(packageRoot(), "package.json"), "utf8"));
|
|
14566
14660
|
cachedRuntimeVersion = typeof pkg.version === "string" && pkg.version ? pkg.version : "0.0.0";
|
|
14567
14661
|
} catch {
|
|
14568
14662
|
cachedRuntimeVersion = "0.0.0";
|
|
@@ -14589,7 +14683,7 @@ var MIGRATION_PENDING = "workit migration pending", STORE_FORMAT = 3, STORE_MIN_
|
|
|
14589
14683
|
return "";
|
|
14590
14684
|
}
|
|
14591
14685
|
}, REFLOG_LINE, branchStart = (location, branch, aliases) => {
|
|
14592
|
-
const first = readText(
|
|
14686
|
+
const first = readText(path15.join(path15.dirname(location.dir), "logs", "refs", "heads", branch)).split(`
|
|
14593
14687
|
`, 1)[0];
|
|
14594
14688
|
const created = REFLOG_LINE.exec(first);
|
|
14595
14689
|
const start = created && /^branch: Created from (\S+)$/u.exec(created[3])?.[1];
|
|
@@ -14599,7 +14693,7 @@ var MIGRATION_PENDING = "workit migration pending", STORE_FORMAT = 3, STORE_MIN_
|
|
|
14599
14693
|
return start;
|
|
14600
14694
|
if (!location.git)
|
|
14601
14695
|
return null;
|
|
14602
|
-
for (const line of readText(
|
|
14696
|
+
for (const line of readText(path15.join(location.git.gitDir, "logs", "HEAD")).split(`
|
|
14603
14697
|
`)) {
|
|
14604
14698
|
const entry = REFLOG_LINE.exec(line);
|
|
14605
14699
|
const moved = entry && /^checkout: moving from (\S+) to (\S+)$/u.exec(entry[3]);
|
|
@@ -14608,12 +14702,12 @@ var MIGRATION_PENDING = "workit migration pending", STORE_FORMAT = 3, STORE_MIN_
|
|
|
14608
14702
|
return moved[1];
|
|
14609
14703
|
}
|
|
14610
14704
|
return null;
|
|
14611
|
-
}, refExists = (common, ref) => fs11.existsSync(
|
|
14705
|
+
}, refExists = (common, ref) => fs11.existsSync(path15.join(common, ref)) || readText(path15.join(common, "packed-refs")).includes(` ${ref}
|
|
14612
14706
|
`), origins, sameDirectoryIdentity = (left, right) => {
|
|
14613
|
-
if (!
|
|
14707
|
+
if (!path15.isAbsolute(left) || !path15.isAbsolute(right))
|
|
14614
14708
|
return false;
|
|
14615
|
-
const normalizedLeft =
|
|
14616
|
-
const normalizedRight =
|
|
14709
|
+
const normalizedLeft = path15.resolve(left);
|
|
14710
|
+
const normalizedRight = path15.resolve(right);
|
|
14617
14711
|
try {
|
|
14618
14712
|
const a = fs11.statSync(normalizedLeft, { bigint: true });
|
|
14619
14713
|
const b = fs11.statSync(normalizedRight, { bigint: true });
|
|
@@ -14671,7 +14765,7 @@ var init_workers = __esm(() => {
|
|
|
14671
14765
|
// packages/workit-core/src/check-config.ts
|
|
14672
14766
|
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
14673
14767
|
import fs12 from "node:fs";
|
|
14674
|
-
import
|
|
14768
|
+
import path16 from "node:path";
|
|
14675
14769
|
function splitCommand(command) {
|
|
14676
14770
|
const argv = [];
|
|
14677
14771
|
let current = "";
|
|
@@ -14709,12 +14803,12 @@ function splitCommand(command) {
|
|
|
14709
14803
|
return argv.length ? argv : new Error("empty command");
|
|
14710
14804
|
}
|
|
14711
14805
|
function checkRoot(cwd) {
|
|
14712
|
-
return
|
|
14806
|
+
return path16.resolve(git4(cwd, ["rev-parse", "--show-toplevel"]) ?? cwd);
|
|
14713
14807
|
}
|
|
14714
14808
|
function detectedChecks(root) {
|
|
14715
14809
|
const read = (file) => {
|
|
14716
14810
|
try {
|
|
14717
|
-
return fs12.readFileSync(
|
|
14811
|
+
return fs12.readFileSync(path16.join(root, file), "utf8");
|
|
14718
14812
|
} catch {
|
|
14719
14813
|
return null;
|
|
14720
14814
|
}
|
|
@@ -14752,7 +14846,7 @@ function detectedChecks(root) {
|
|
|
14752
14846
|
}
|
|
14753
14847
|
function loadCheckConfig(cwd) {
|
|
14754
14848
|
const root = checkRoot(cwd);
|
|
14755
|
-
const file =
|
|
14849
|
+
const file = path16.join(root, CHECKS_FILE);
|
|
14756
14850
|
const none = (error = null) => ({
|
|
14757
14851
|
source: error ? CHECKS_FILE : "none",
|
|
14758
14852
|
root,
|
|
@@ -14823,10 +14917,10 @@ function workitAvailable(env = process.env) {
|
|
|
14823
14917
|
return workitOnPath;
|
|
14824
14918
|
const windows = process.platform === "win32";
|
|
14825
14919
|
const exts = windows ? (env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean) : [""];
|
|
14826
|
-
const dirs = (env.PATH ?? env.Path ?? "").split(
|
|
14920
|
+
const dirs = (env.PATH ?? env.Path ?? "").split(path16.delimiter).filter(Boolean);
|
|
14827
14921
|
workitOnPath = dirs.some((dir) => exts.some((ext) => {
|
|
14828
14922
|
try {
|
|
14829
|
-
return fs12.statSync(
|
|
14923
|
+
return fs12.statSync(path16.join(dir, `workit${ext}`)).isFile();
|
|
14830
14924
|
} catch {
|
|
14831
14925
|
return false;
|
|
14832
14926
|
}
|
|
@@ -14847,7 +14941,7 @@ var SCRIPT_CHECKS, CHECKS_FILE = "workit.checks.json", isRecord3 = (value) => ty
|
|
|
14847
14941
|
const value = run.status === 0 ? (run.stdout ?? "").trim() : "";
|
|
14848
14942
|
return value || null;
|
|
14849
14943
|
}, packageManager = (root) => {
|
|
14850
|
-
const has = (file) => fs12.existsSync(
|
|
14944
|
+
const has = (file) => fs12.existsSync(path16.join(root, file));
|
|
14851
14945
|
if (has("bun.lock") || has("bun.lockb"))
|
|
14852
14946
|
return "bun";
|
|
14853
14947
|
if (has("pnpm-lock.yaml"))
|
|
@@ -14873,7 +14967,7 @@ var init_check_config = __esm(() => {
|
|
|
14873
14967
|
import { createHash as createHash10 } from "node:crypto";
|
|
14874
14968
|
import * as fs13 from "node:fs";
|
|
14875
14969
|
import { spawnSync as spawnSync10 } from "node:child_process";
|
|
14876
|
-
import
|
|
14970
|
+
import path17 from "node:path";
|
|
14877
14971
|
function captureCandidate(root, scope, environment = []) {
|
|
14878
14972
|
let checkout;
|
|
14879
14973
|
try {
|
|
@@ -14915,7 +15009,7 @@ function captureCandidate(root, scope, environment = []) {
|
|
|
14915
15009
|
for (const item of [...names].toSorted()) {
|
|
14916
15010
|
if (!scopeMatches(item, normalizedScope))
|
|
14917
15011
|
continue;
|
|
14918
|
-
const target =
|
|
15012
|
+
const target = path17.join(checkout, item);
|
|
14919
15013
|
try {
|
|
14920
15014
|
const stat = fs13.lstatSync(target);
|
|
14921
15015
|
if (stat.isSymbolicLink()) {
|
|
@@ -15288,12 +15382,12 @@ function evaluateClosure(requestedOutcome, view) {
|
|
|
15288
15382
|
requirementIds: evaluations.map((item) => item.requirementId)
|
|
15289
15383
|
});
|
|
15290
15384
|
}
|
|
15291
|
-
var digestBytes = (value) => createHash10("sha256").update(value).digest("hex"), inside = (root, candidate) => candidate === root || candidate.startsWith(`${root}${
|
|
15385
|
+
var digestBytes = (value) => createHash10("sha256").update(value).digest("hex"), inside = (root, candidate) => candidate === root || candidate.startsWith(`${root}${path17.sep}`), relative = (root, candidate) => path17.relative(root, candidate).split(path17.sep).join("/") || ".", canonicalPath = (value) => {
|
|
15292
15386
|
if (typeof value !== "string" || !value)
|
|
15293
15387
|
return null;
|
|
15294
15388
|
if (value.includes("\\") || value.split("/").includes(".."))
|
|
15295
15389
|
return null;
|
|
15296
|
-
const normalized =
|
|
15390
|
+
const normalized = path17.posix.normalize(value);
|
|
15297
15391
|
if (normalized === ".." || normalized.startsWith("../") || normalized.startsWith("/"))
|
|
15298
15392
|
return null;
|
|
15299
15393
|
return normalized === "." ? "." : normalized.replace(/\/$/, "");
|
|
@@ -15335,14 +15429,14 @@ var digestBytes = (value) => createHash10("sha256").update(value).digest("hex"),
|
|
|
15335
15429
|
git: !/not a git repository/i.test(stderr)
|
|
15336
15430
|
};
|
|
15337
15431
|
}
|
|
15338
|
-
const paths = result.stdout ? result.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(
|
|
15432
|
+
const paths = result.stdout ? result.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path17.sep).join("/")) : [];
|
|
15339
15433
|
const stagedDeleted = spawnSync10("git", ["diff", "--cached", "--name-only", "--diff-filter=D", "-z"], { cwd: root, encoding: "buffer" });
|
|
15340
15434
|
if (stagedDeleted.status !== 0) {
|
|
15341
15435
|
const stderr = stagedDeleted.stderr?.toString("utf8") ?? "";
|
|
15342
15436
|
if (!/not a git repository/i.test(stderr))
|
|
15343
15437
|
return { paths, uncertain: true, git: true };
|
|
15344
15438
|
} else if (stagedDeleted.stdout) {
|
|
15345
|
-
paths.push(...stagedDeleted.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(
|
|
15439
|
+
paths.push(...stagedDeleted.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path17.sep).join("/")));
|
|
15346
15440
|
}
|
|
15347
15441
|
return { paths: [...new Set(paths)], uncertain: false, git: true };
|
|
15348
15442
|
}, walk = (root, directory, output) => {
|
|
@@ -15356,7 +15450,7 @@ var digestBytes = (value) => createHash10("sha256").update(value).digest("hex"),
|
|
|
15356
15450
|
for (const name of names) {
|
|
15357
15451
|
if (name === ".git" || name === ".workit")
|
|
15358
15452
|
continue;
|
|
15359
|
-
const target =
|
|
15453
|
+
const target = path17.join(directory, name);
|
|
15360
15454
|
let stat;
|
|
15361
15455
|
try {
|
|
15362
15456
|
stat = fs13.lstatSync(target);
|
|
@@ -15373,12 +15467,12 @@ var digestBytes = (value) => createHash10("sha256").update(value).digest("hex"),
|
|
|
15373
15467
|
}, scopeRoots = (root, scope) => {
|
|
15374
15468
|
const roots = [];
|
|
15375
15469
|
for (const item of scope.paths.length ? scope.paths : ["."]) {
|
|
15376
|
-
const target =
|
|
15470
|
+
const target = path17.resolve(root, item);
|
|
15377
15471
|
if (!inside(root, target))
|
|
15378
15472
|
return failure2("invalid_input", `candidate scope escapes checkout: ${item} — keep one task per repository and coordinate a separate linked task in the other checkout`, { fields: [{ path: "scope.paths", reason: `${item} is outside the checkout` }] });
|
|
15379
15473
|
let ancestor = target;
|
|
15380
15474
|
while (!fs13.existsSync(ancestor) && ancestor !== root)
|
|
15381
|
-
ancestor =
|
|
15475
|
+
ancestor = path17.dirname(ancestor);
|
|
15382
15476
|
try {
|
|
15383
15477
|
if (!inside(root, fs13.realpathSync(ancestor)))
|
|
15384
15478
|
return failure2("invalid_input", `candidate scope escapes checkout through a symlink: ${item} — keep one task per repository and coordinate a separate linked task in the other checkout`, { fields: [{ path: "scope.paths", reason: `${item} resolves outside the checkout` }] });
|
|
@@ -15442,23 +15536,23 @@ var digestBytes = (value) => createHash10("sha256").update(value).digest("hex"),
|
|
|
15442
15536
|
continue;
|
|
15443
15537
|
if (!reference.digest)
|
|
15444
15538
|
return failure2("invalid_input", "document references require a byte digest");
|
|
15445
|
-
const target =
|
|
15446
|
-
if (target !== root && !target.startsWith(`${root}${
|
|
15539
|
+
const target = path17.resolve(root, reference.path);
|
|
15540
|
+
if (target !== root && !target.startsWith(`${root}${path17.sep}`))
|
|
15447
15541
|
return failure2("invalid_input", "document reference escapes checkout; cite it as an external file:// reference instead", {
|
|
15448
15542
|
fields: [
|
|
15449
15543
|
{ path: "contentRefs.path", reason: `${reference.path} is outside the checkout` }
|
|
15450
15544
|
]
|
|
15451
15545
|
});
|
|
15452
15546
|
try {
|
|
15453
|
-
const below =
|
|
15547
|
+
const below = path17.relative(root, target);
|
|
15454
15548
|
let current = root;
|
|
15455
|
-
for (const segment of below.split(
|
|
15549
|
+
for (const segment of below.split(path17.sep)) {
|
|
15456
15550
|
if (!segment)
|
|
15457
15551
|
continue;
|
|
15458
|
-
current =
|
|
15552
|
+
current = path17.join(current, segment);
|
|
15459
15553
|
const stat = fs13.lstatSync(current);
|
|
15460
15554
|
const real = fs13.realpathSync(current);
|
|
15461
|
-
if (real !== root && !real.startsWith(`${root}${
|
|
15555
|
+
if (real !== root && !real.startsWith(`${root}${path17.sep}`))
|
|
15462
15556
|
return failure2("invalid_input", "document reference escapes checkout; cite it as an external file:// reference instead", {
|
|
15463
15557
|
fields: [
|
|
15464
15558
|
{
|
|
@@ -17418,7 +17512,7 @@ var support = (descriptor, axis) => {
|
|
|
17418
17512
|
// packages/workit-core/src/hooks/context.ts
|
|
17419
17513
|
import { createHash as createHash11 } from "node:crypto";
|
|
17420
17514
|
import fs14 from "node:fs";
|
|
17421
|
-
import
|
|
17515
|
+
import path18 from "node:path";
|
|
17422
17516
|
function sessionCompactContext(store, session, context, selection = "session-bound") {
|
|
17423
17517
|
const listed = store.listTaskIndex();
|
|
17424
17518
|
if (!listed.ok)
|
|
@@ -17453,7 +17547,7 @@ function entryCompactContext(store, entry, session, context) {
|
|
|
17453
17547
|
return null;
|
|
17454
17548
|
const freshness = { mode: "signal", current: () => recentSignal(store.root) };
|
|
17455
17549
|
const observed = task?.data.evidence.some(isObservedCheck) ?? false;
|
|
17456
|
-
const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [
|
|
17550
|
+
const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [path18.resolve(store.root, ref.path)] : []));
|
|
17457
17551
|
const observedFiles = filesKey(files);
|
|
17458
17552
|
const compact = new WorkitCore(store, context).compactContext(entry?.id ?? null, freshness, origin && { origin: origin.origin, taskId: origin.entry.id });
|
|
17459
17553
|
if (!compact.ok || !compact.data)
|
|
@@ -17559,13 +17653,13 @@ ${options.addendum}` : ""}
|
|
|
17559
17653
|
if (location instanceof Error)
|
|
17560
17654
|
return null;
|
|
17561
17655
|
const session = [input.host, input.session.id, input.session.agentId ?? ""].join("\x00");
|
|
17562
|
-
return
|
|
17656
|
+
return path18.join(location.dir, "hooks", `turn-${digestOf(session).slice(0, 32)}.json`);
|
|
17563
17657
|
} catch {
|
|
17564
17658
|
return null;
|
|
17565
17659
|
}
|
|
17566
17660
|
}, writeTurnDigest = (file, digest) => {
|
|
17567
17661
|
try {
|
|
17568
|
-
fs14.mkdirSync(
|
|
17662
|
+
fs14.mkdirSync(path18.dirname(file), { recursive: true });
|
|
17569
17663
|
fs14.writeFileSync(file, `${JSON.stringify({ digest })}
|
|
17570
17664
|
`);
|
|
17571
17665
|
} catch {}
|
|
@@ -17578,7 +17672,7 @@ ${options.addendum}` : ""}
|
|
|
17578
17672
|
for (const name of fs14.readdirSync(dir)) {
|
|
17579
17673
|
if (!name.startsWith("turn-"))
|
|
17580
17674
|
continue;
|
|
17581
|
-
const file =
|
|
17675
|
+
const file = path18.join(dir, name);
|
|
17582
17676
|
try {
|
|
17583
17677
|
if (now - fs14.statSync(file).mtimeMs > TURN_TTL_MS)
|
|
17584
17678
|
fs14.rmSync(file, { force: true });
|
|
@@ -17606,7 +17700,7 @@ ${options.addendum}` : ""}
|
|
|
17606
17700
|
const file = turnMarker(input);
|
|
17607
17701
|
if (!file)
|
|
17608
17702
|
return;
|
|
17609
|
-
pruneTurnDigests(
|
|
17703
|
+
pruneTurnDigests(path18.dirname(file), Date.now());
|
|
17610
17704
|
if (text)
|
|
17611
17705
|
writeTurnDigest(file, digestOf(text));
|
|
17612
17706
|
else
|
|
@@ -17837,7 +17931,7 @@ var init_branch = __esm(() => {
|
|
|
17837
17931
|
// packages/workit-core/src/hooks/session-marker.ts
|
|
17838
17932
|
import { createHash as createHash13 } from "node:crypto";
|
|
17839
17933
|
import fs15 from "node:fs";
|
|
17840
|
-
import
|
|
17934
|
+
import path19 from "node:path";
|
|
17841
17935
|
var sessionMarkerFile = (input, session, store) => {
|
|
17842
17936
|
let dir = store;
|
|
17843
17937
|
if (dir === undefined) {
|
|
@@ -17847,7 +17941,7 @@ var sessionMarkerFile = (input, session, store) => {
|
|
|
17847
17941
|
dir = location.dir;
|
|
17848
17942
|
}
|
|
17849
17943
|
const name = createHash13("sha256").update(`${input.host}\x00${session}`).digest("hex").slice(0, 32);
|
|
17850
|
-
return
|
|
17944
|
+
return path19.join(dir, "hooks", `skills-${name}.json`);
|
|
17851
17945
|
}, list2 = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [], readSessionMarker = (file) => {
|
|
17852
17946
|
try {
|
|
17853
17947
|
const value = JSON.parse(fs15.readFileSync(file, "utf8"));
|
|
@@ -17857,7 +17951,7 @@ var sessionMarkerFile = (input, session, store) => {
|
|
|
17857
17951
|
}
|
|
17858
17952
|
}, writeSessionMarker = (file, marker) => {
|
|
17859
17953
|
try {
|
|
17860
|
-
fs15.mkdirSync(
|
|
17954
|
+
fs15.mkdirSync(path19.dirname(file), { recursive: true });
|
|
17861
17955
|
fs15.writeFileSync(file, JSON.stringify(marker));
|
|
17862
17956
|
} catch {}
|
|
17863
17957
|
};
|
|
@@ -17990,8 +18084,8 @@ var closingQuote = (command, start, dialect) => {
|
|
|
17990
18084
|
import { spawnSync as spawnSync11 } from "node:child_process";
|
|
17991
18085
|
import { createHash as createHash14 } from "node:crypto";
|
|
17992
18086
|
import fs16 from "node:fs";
|
|
17993
|
-
import
|
|
17994
|
-
import
|
|
18087
|
+
import os5 from "node:os";
|
|
18088
|
+
import path20 from "node:path";
|
|
17995
18089
|
function rawInvocations(command, dialect = "posix", depth = 0) {
|
|
17996
18090
|
const found = [];
|
|
17997
18091
|
let dir = null;
|
|
@@ -18012,7 +18106,7 @@ function rawInvocations(command, dialect = "posix", depth = 0) {
|
|
|
18012
18106
|
const name = commandName(words[0]);
|
|
18013
18107
|
if (CD.has(name)) {
|
|
18014
18108
|
const target = cdTarget(words);
|
|
18015
|
-
dir = target === null ?
|
|
18109
|
+
dir = target === null ? os5.homedir() : joinDir(dir, target);
|
|
18016
18110
|
continue;
|
|
18017
18111
|
}
|
|
18018
18112
|
if (PUSHD.has(name)) {
|
|
@@ -18150,7 +18244,7 @@ function noteRawCommit(input, command, key) {
|
|
|
18150
18244
|
if (action.kind !== "commit")
|
|
18151
18245
|
continue;
|
|
18152
18246
|
const file = markerFile(repo, input.session.id, key);
|
|
18153
|
-
fs16.mkdirSync(
|
|
18247
|
+
fs16.mkdirSync(path20.dirname(file), { recursive: true });
|
|
18154
18248
|
fs16.writeFileSync(file, `${JSON.stringify({ head: headSha2(repo), at })}
|
|
18155
18249
|
`);
|
|
18156
18250
|
}
|
|
@@ -18177,11 +18271,11 @@ function settlePendingCommit(input) {
|
|
|
18177
18271
|
settle2(input, repo, file);
|
|
18178
18272
|
} catch {}
|
|
18179
18273
|
}
|
|
18180
|
-
var NONE2, SHELLS, PREFIXES2, SCRIPT_FLAG, CD, PUSHD, POPD, GIT_VALUE_OPTIONS, isAbsolute = (value) =>
|
|
18274
|
+
var NONE2, SHELLS, PREFIXES2, SCRIPT_FLAG, CD, PUSHD, POPD, GIT_VALUE_OPTIONS, isAbsolute = (value) => path20.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\"), joinDir = (base, next) => {
|
|
18181
18275
|
if (base === undefined || /[$`*?]/.test(next) || next === "-")
|
|
18182
18276
|
return;
|
|
18183
|
-
const expanded = next === "~" || next.startsWith("~/") ?
|
|
18184
|
-
return base === null || isAbsolute(expanded) ? expanded :
|
|
18277
|
+
const expanded = next === "~" || next.startsWith("~/") ? path20.join(os5.homedir(), next.slice(1)) : next;
|
|
18278
|
+
return base === null || isAbsolute(expanded) ? expanded : path20.join(base, expanded);
|
|
18185
18279
|
}, cdTarget = (words) => {
|
|
18186
18280
|
const args = words.slice(1);
|
|
18187
18281
|
const flag = args.findIndex((word) => /^-(?:literal)?path$/i.test(word));
|
|
@@ -18332,17 +18426,17 @@ var NONE2, SHELLS, PREFIXES2, SCRIPT_FLAG, CD, PUSHD, POPD, GIT_VALUE_OPTIONS, i
|
|
|
18332
18426
|
if (!git || git.reftable)
|
|
18333
18427
|
return null;
|
|
18334
18428
|
try {
|
|
18335
|
-
const head = fs16.readFileSync(
|
|
18429
|
+
const head = fs16.readFileSync(path20.join(git.gitDir, "HEAD"), "utf8").trim();
|
|
18336
18430
|
if (/^[0-9a-f]{40,64}$/.test(head))
|
|
18337
18431
|
return head;
|
|
18338
18432
|
const ref = /^ref: (refs\/.+)$/.exec(head)?.[1];
|
|
18339
18433
|
if (!ref)
|
|
18340
18434
|
return null;
|
|
18341
|
-
const common =
|
|
18435
|
+
const common = path20.dirname(repo.location.dir);
|
|
18342
18436
|
try {
|
|
18343
|
-
return fs16.readFileSync(
|
|
18437
|
+
return fs16.readFileSync(path20.join(common, ref), "utf8").trim() || null;
|
|
18344
18438
|
} catch {}
|
|
18345
|
-
const packed = fs16.readFileSync(
|
|
18439
|
+
const packed = fs16.readFileSync(path20.join(common, "packed-refs"), "utf8");
|
|
18346
18440
|
return new RegExp(`^([0-9a-f]{40,64}) ${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`, "m").exec(packed)?.[1] ?? null;
|
|
18347
18441
|
} catch {
|
|
18348
18442
|
return null;
|
|
@@ -18422,7 +18516,7 @@ var NONE2, SHELLS, PREFIXES2, SCRIPT_FLAG, CD, PUSHD, POPD, GIT_VALUE_OPTIONS, i
|
|
|
18422
18516
|
const action = rawAction(invocation);
|
|
18423
18517
|
if (!action)
|
|
18424
18518
|
continue;
|
|
18425
|
-
const dir =
|
|
18519
|
+
const dir = path20.resolve(cwd, invocation.dir ?? ".");
|
|
18426
18520
|
if (!repos.has(dir)) {
|
|
18427
18521
|
const repo = repoAt(dir);
|
|
18428
18522
|
repos.set(dir, repo && isWorkitWorkspace(repo) ? repo : null);
|
|
@@ -18449,7 +18543,7 @@ var NONE2, SHELLS, PREFIXES2, SCRIPT_FLAG, CD, PUSHD, POPD, GIT_VALUE_OPTIONS, i
|
|
|
18449
18543
|
raw: [...marker.raw, ...fresh.map((kind) => agent + kind)]
|
|
18450
18544
|
});
|
|
18451
18545
|
return fresh.map((kind) => nudges.get(kind));
|
|
18452
|
-
}, deny = (reason) => ({ kind: "deny", reason, unblock: null }), NEXT_COMMAND = "next", MARKER_TTL_SECONDS = 3600, markerFile = (repo, session, key) =>
|
|
18546
|
+
}, deny = (reason) => ({ kind: "deny", reason, unblock: null }), NEXT_COMMAND = "next", MARKER_TTL_SECONDS = 3600, markerFile = (repo, session, key) => path20.join(repo.location.dir, "hooks", `commit-${createHash14("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`), callKey = (toolUseId, command) => toolUseId ?? `cmd:${createHash14("sha256").update(command).digest("hex")}`, headCommit = (dir) => {
|
|
18453
18547
|
const run = spawnSync11("git", [
|
|
18454
18548
|
"log",
|
|
18455
18549
|
"-1",
|
|
@@ -18572,7 +18666,7 @@ var init_raw_git = __esm(() => {
|
|
|
18572
18666
|
// packages/workit-core/src/core/route-intent.ts
|
|
18573
18667
|
import { spawnSync as spawnSync12 } from "node:child_process";
|
|
18574
18668
|
import { existsSync as existsSync6 } from "node:fs";
|
|
18575
|
-
import
|
|
18669
|
+
import path21 from "node:path";
|
|
18576
18670
|
var UNKNOWABLE, SWITCH_CREATE, CHECKOUT_CREATE, WORKTREE_CREATE, BRANCH_NO_CREATE, BRANCH_RENAME, flagValue = (args, flags) => {
|
|
18577
18671
|
for (let index = 1;index < args.length; index++) {
|
|
18578
18672
|
const arg = args[index];
|
|
@@ -18650,7 +18744,7 @@ var UNKNOWABLE, SWITCH_CREATE, CHECKOUT_CREATE, WORKTREE_CREATE, BRANCH_NO_CREAT
|
|
|
18650
18744
|
for (const target of shellBranchTargets(command, dialect)) {
|
|
18651
18745
|
if (target.dir === undefined)
|
|
18652
18746
|
continue;
|
|
18653
|
-
const dir = target.dir === null ? root :
|
|
18747
|
+
const dir = target.dir === null ? root : path21.resolve(root, target.dir);
|
|
18654
18748
|
if (target.dir !== null && (!existsSync6(dir) || !inWorkitWorkspace(dir)))
|
|
18655
18749
|
continue;
|
|
18656
18750
|
if (localBranchExists(dir, target.branch))
|
|
@@ -18685,7 +18779,7 @@ var init_policy = __esm(() => {
|
|
|
18685
18779
|
|
|
18686
18780
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
18687
18781
|
import { realpathSync as realpathSync5 } from "node:fs";
|
|
18688
|
-
import
|
|
18782
|
+
import path22 from "node:path";
|
|
18689
18783
|
function writeGate(cwd, paths) {
|
|
18690
18784
|
try {
|
|
18691
18785
|
const gate = gateFor(cwd);
|
|
@@ -18705,21 +18799,21 @@ function writeGate(cwd, paths) {
|
|
|
18705
18799
|
}
|
|
18706
18800
|
var NONE3, CASE_INSENSITIVE, canonical2 = (file) => {
|
|
18707
18801
|
let rest = "";
|
|
18708
|
-
for (let dir =
|
|
18802
|
+
for (let dir = path22.resolve(file);; dir = path22.dirname(dir)) {
|
|
18709
18803
|
try {
|
|
18710
|
-
return
|
|
18804
|
+
return path22.join(realpathSync5(dir), rest);
|
|
18711
18805
|
} catch {
|
|
18712
|
-
if (
|
|
18713
|
-
return
|
|
18714
|
-
rest = rest ?
|
|
18806
|
+
if (path22.dirname(dir) === dir)
|
|
18807
|
+
return path22.resolve(file);
|
|
18808
|
+
rest = rest ? path22.join(path22.basename(dir), rest) : path22.basename(dir);
|
|
18715
18809
|
}
|
|
18716
18810
|
}
|
|
18717
18811
|
}, exempt = (cwd, root, file, plans) => {
|
|
18718
18812
|
const fold = (value) => CASE_INSENSITIVE ? value.toLowerCase() : value;
|
|
18719
|
-
const relative =
|
|
18720
|
-
if (relative.startsWith("..") ||
|
|
18813
|
+
const relative = path22.relative(fold(canonical2(root)), fold(canonical2(path22.resolve(cwd, file))));
|
|
18814
|
+
if (relative.startsWith("..") || path22.isAbsolute(relative))
|
|
18721
18815
|
return true;
|
|
18722
|
-
const posix = relative.split(
|
|
18816
|
+
const posix = relative.split(path22.sep).join("/");
|
|
18723
18817
|
const segments = posix.split("/");
|
|
18724
18818
|
return /\.mdx?$/i.test(posix) || segments[0] === "docs" || segments.includes("plans") || [...plans].some((plan) => fold(plan) === posix);
|
|
18725
18819
|
}, PREFIXES3, operands = (words) => words.filter((item) => !item.startsWith("-")), editsOf = (input) => {
|
|
@@ -18811,7 +18905,7 @@ var NONE3, CASE_INSENSITIVE, canonical2 = (file) => {
|
|
|
18811
18905
|
if (!unknown && targets.length === 0)
|
|
18812
18906
|
return { writes: false, targets: null };
|
|
18813
18907
|
return { writes: true, targets: unknown ? null : targets };
|
|
18814
|
-
}, cache2, planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(
|
|
18908
|
+
}, cache2, planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path22.resolve(root, file)) ?? "-").join("\x00"), gateFor = (cwd) => {
|
|
18815
18909
|
const store = new TaskStore(cwd);
|
|
18816
18910
|
const listed = store.listTaskIndex();
|
|
18817
18911
|
if (!listed.ok)
|
|
@@ -19235,9 +19329,9 @@ var init_skill_nudge = __esm(() => {
|
|
|
19235
19329
|
|
|
19236
19330
|
// packages/workit-core/src/hooks/hosts/fields.ts
|
|
19237
19331
|
import { existsSync as existsSync7, realpathSync as realpathSync6, statSync as statSync2 } from "node:fs";
|
|
19238
|
-
import
|
|
19332
|
+
import path23 from "node:path";
|
|
19239
19333
|
var isRecord4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), nonEmpty2 = (value) => typeof value === "string" && value.trim() !== "", optionalText = (value) => typeof value === "string" ? value : null, existingDirectory = (value) => {
|
|
19240
|
-
if (!nonEmpty2(value) || !
|
|
19334
|
+
if (!nonEmpty2(value) || !path23.isAbsolute(value) || !existsSync7(value))
|
|
19241
19335
|
return null;
|
|
19242
19336
|
try {
|
|
19243
19337
|
return statSync2(value).isDirectory() ? realpathSync6(value) : null;
|
|
@@ -19978,7 +20072,7 @@ var init_codex = __esm(() => {
|
|
|
19978
20072
|
|
|
19979
20073
|
// packages/workit-core/src/hooks/hosts/cursor.ts
|
|
19980
20074
|
import fs17 from "node:fs";
|
|
19981
|
-
import
|
|
20075
|
+
import path24 from "node:path";
|
|
19982
20076
|
var undocumented, none, CURSOR_DESCRIPTOR, EVENTS3, parseCursorHookInput = (value) => {
|
|
19983
20077
|
if (!isRecord4(value) || !Object.hasOwn(EVENTS3, String(value.hook_event_name)))
|
|
19984
20078
|
return { ok: false, error: "hook_event_name is required" };
|
|
@@ -20059,7 +20153,7 @@ var undocumented, none, CURSOR_DESCRIPTOR, EVENTS3, parseCursorHookInput = (valu
|
|
|
20059
20153
|
};
|
|
20060
20154
|
}
|
|
20061
20155
|
}, TRANSCRIPT_TAIL_BYTES, lastAssistantText = (file) => {
|
|
20062
|
-
if (!file || !
|
|
20156
|
+
if (!file || !path24.isAbsolute(file))
|
|
20063
20157
|
return null;
|
|
20064
20158
|
try {
|
|
20065
20159
|
const size = fs17.statSync(file).size;
|
|
@@ -20095,7 +20189,7 @@ var undocumented, none, CURSOR_DESCRIPTOR, EVENTS3, parseCursorHookInput = (valu
|
|
|
20095
20189
|
} catch {
|
|
20096
20190
|
return null;
|
|
20097
20191
|
}
|
|
20098
|
-
}, within = (root, dir) => dir === root || dir.startsWith(root.endsWith(
|
|
20192
|
+
}, within = (root, dir) => dir === root || dir.startsWith(root.endsWith(path24.sep) ? root : `${root}${path24.sep}`), hookCwd = (input) => {
|
|
20099
20193
|
const cwd = existingDirectory(input.cwd);
|
|
20100
20194
|
if (cwd && input.hook_event_name === "beforeShellExecution")
|
|
20101
20195
|
return cwd;
|