@workit-dev/pi 2.22.1 → 2.22.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/dist/worker.js +390 -92
- package/dist/workit.js +1259 -983
- package/package.json +1 -1
package/dist/worker.js
CHANGED
|
@@ -6707,6 +6707,8 @@ var ENVELOPE = new Set([
|
|
|
6707
6707
|
]);
|
|
6708
6708
|
var NOT_FLAT = new Set(["schemaVersion", "action", "workspaceId"]);
|
|
6709
6709
|
// packages/workit-core/src/core/workit-paths.mjs
|
|
6710
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
6711
|
+
import { existsSync, lstatSync, mkdirSync, realpathSync, renameSync, writeFileSync } from "node:fs";
|
|
6710
6712
|
import os from "node:os";
|
|
6711
6713
|
import path from "node:path";
|
|
6712
6714
|
var WORKIT_DIR_OVERRIDES = {
|
|
@@ -6757,6 +6759,17 @@ var workitDir = (kind, env = process.env, platform = process.platform) => {
|
|
|
6757
6759
|
};
|
|
6758
6760
|
var configDir = (env, platform) => workitDir("config", env, platform);
|
|
6759
6761
|
var stateDir = (env, platform) => workitDir("state", env, platform);
|
|
6762
|
+
var folderSlug = (dir, platform = process.platform) => {
|
|
6763
|
+
let canonical = dir;
|
|
6764
|
+
try {
|
|
6765
|
+
canonical = realpathSync.native(dir);
|
|
6766
|
+
} catch {}
|
|
6767
|
+
if (platform === "win32")
|
|
6768
|
+
canonical = canonical.toLowerCase();
|
|
6769
|
+
const base = path.basename(canonical).replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 40) || "root";
|
|
6770
|
+
return `${base}-${createHash2("sha256").update(canonical).digest("hex").slice(0, 12)}`;
|
|
6771
|
+
};
|
|
6772
|
+
var folderStoreDir = (dir, env, platform) => path.join(stateDir(env, platform), "folders", folderSlug(dir, platform));
|
|
6760
6773
|
|
|
6761
6774
|
// packages/workit-core/src/core/config.ts
|
|
6762
6775
|
var PRESETS = {
|
|
@@ -6792,11 +6805,11 @@ var COMMIT_PRESETS = [
|
|
|
6792
6805
|
|
|
6793
6806
|
// packages/workit-core/src/core/workspaces.ts
|
|
6794
6807
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
6795
|
-
import { existsSync as
|
|
6808
|
+
import { existsSync as existsSync3, lstatSync as lstatSync3, readFileSync as readFileSync3, realpathSync as realpathSync4 } from "node:fs";
|
|
6796
6809
|
import path6 from "node:path";
|
|
6797
6810
|
|
|
6798
6811
|
// packages/workit-core/src/core/remotes.ts
|
|
6799
|
-
import { lstatSync, readFileSync as readFileSync2, realpathSync as
|
|
6812
|
+
import { lstatSync as lstatSync2, readFileSync as readFileSync2, realpathSync as realpathSync3, statSync } from "node:fs";
|
|
6800
6813
|
import path5 from "node:path";
|
|
6801
6814
|
|
|
6802
6815
|
// packages/workit-core/src/git/rev.ts
|
|
@@ -7134,7 +7147,7 @@ function resolveSshHost(alias, sshConfig) {
|
|
|
7134
7147
|
|
|
7135
7148
|
// packages/workit-core/src/core/account-home.ts
|
|
7136
7149
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
7137
|
-
import { existsSync, readFileSync, readlinkSync, realpathSync } from "node:fs";
|
|
7150
|
+
import { existsSync as existsSync2, readFileSync, readlinkSync, realpathSync as realpathSync2 } from "node:fs";
|
|
7138
7151
|
import os3 from "node:os";
|
|
7139
7152
|
var WINDOWS = "C:\\Windows";
|
|
7140
7153
|
var SYSTEM32 = `${WINDOWS}\\System32\\`;
|
|
@@ -7225,7 +7238,7 @@ var canonical2 = (real) => {
|
|
|
7225
7238
|
};
|
|
7226
7239
|
var isRepoDir = (dir) => ["HEAD", "objects", "refs"].every((name) => {
|
|
7227
7240
|
try {
|
|
7228
|
-
|
|
7241
|
+
lstatSync2(`${dir}/${name}`);
|
|
7229
7242
|
return true;
|
|
7230
7243
|
} catch {
|
|
7231
7244
|
return false;
|
|
@@ -7234,7 +7247,7 @@ var isRepoDir = (dir) => ["HEAD", "objects", "refs"].every((name) => {
|
|
|
7234
7247
|
var gitDirAt = (at, depth = 0) => {
|
|
7235
7248
|
let real;
|
|
7236
7249
|
try {
|
|
7237
|
-
real =
|
|
7250
|
+
real = realpathSync3.native(at);
|
|
7238
7251
|
} catch {
|
|
7239
7252
|
return null;
|
|
7240
7253
|
}
|
|
@@ -7253,7 +7266,7 @@ var gitDirAt = (at, depth = 0) => {
|
|
|
7253
7266
|
common = readFileSync2(`${real}/commondir`, "utf8").trim();
|
|
7254
7267
|
} catch {}
|
|
7255
7268
|
if (common !== undefined) {
|
|
7256
|
-
|
|
7269
|
+
lstatSync2(`${real}/HEAD`);
|
|
7257
7270
|
return gitDirAt(path5.isAbsolute(common) ? common : `${real}/${common}`, depth + 1);
|
|
7258
7271
|
}
|
|
7259
7272
|
if (!isRepoDir(real))
|
|
@@ -7262,11 +7275,11 @@ var gitDirAt = (at, depth = 0) => {
|
|
|
7262
7275
|
for (const name of ["refs", "objects", "config", "packed-refs"]) {
|
|
7263
7276
|
const item = `${real}/${name}`;
|
|
7264
7277
|
try {
|
|
7265
|
-
|
|
7278
|
+
lstatSync2(item);
|
|
7266
7279
|
} catch {
|
|
7267
7280
|
continue;
|
|
7268
7281
|
}
|
|
7269
|
-
const resolved =
|
|
7282
|
+
const resolved = realpathSync3.native(item);
|
|
7270
7283
|
const rel = path5.relative(real, resolved);
|
|
7271
7284
|
if (rel && !rel.startsWith("..") && !path5.isAbsolute(rel))
|
|
7272
7285
|
continue;
|
|
@@ -7574,8 +7587,8 @@ var probeCheckout = (cwd) => {
|
|
|
7574
7587
|
if (cached !== undefined)
|
|
7575
7588
|
return cached;
|
|
7576
7589
|
let dir = path6.resolve(cwd);
|
|
7577
|
-
while (!
|
|
7578
|
-
if (["HEAD", "objects", "refs"].every((name) =>
|
|
7590
|
+
while (!existsSync3(path6.join(dir, ".git"))) {
|
|
7591
|
+
if (["HEAD", "objects", "refs"].every((name) => existsSync3(path6.join(dir, name)))) {
|
|
7579
7592
|
const real = realpathOf(dir);
|
|
7580
7593
|
const owner = ownInternals(real) === true ? gitDirOwner(real) : null;
|
|
7581
7594
|
if (owner === null)
|
|
@@ -7642,7 +7655,7 @@ var probeCheckout = (cwd) => {
|
|
|
7642
7655
|
};
|
|
7643
7656
|
var ownGitDir = (dotGit, real) => {
|
|
7644
7657
|
try {
|
|
7645
|
-
return
|
|
7658
|
+
return lstatSync3(dotGit).isDirectory() && realpathOf(dotGit) === real;
|
|
7646
7659
|
} catch {
|
|
7647
7660
|
return false;
|
|
7648
7661
|
}
|
|
@@ -7653,13 +7666,13 @@ var ownInternals = (real) => {
|
|
|
7653
7666
|
for (const name of INTERNALS) {
|
|
7654
7667
|
const at = path6.join(real, name);
|
|
7655
7668
|
try {
|
|
7656
|
-
|
|
7669
|
+
lstatSync3(at);
|
|
7657
7670
|
} catch {
|
|
7658
7671
|
continue;
|
|
7659
7672
|
}
|
|
7660
7673
|
let resolved;
|
|
7661
7674
|
try {
|
|
7662
|
-
resolved = (
|
|
7675
|
+
resolved = (realpathSync4.native ?? realpathSync4)(at);
|
|
7663
7676
|
} catch {
|
|
7664
7677
|
return false;
|
|
7665
7678
|
}
|
|
@@ -7702,7 +7715,7 @@ var matchingEntries = (cwd, entries) => {
|
|
|
7702
7715
|
return main ? match(main) : direct;
|
|
7703
7716
|
};
|
|
7704
7717
|
var realpathOf = (p) => {
|
|
7705
|
-
const real =
|
|
7718
|
+
const real = realpathSync4.native ?? realpathSync4;
|
|
7706
7719
|
try {
|
|
7707
7720
|
return real(p);
|
|
7708
7721
|
} catch {
|
|
@@ -7880,8 +7893,288 @@ var homePattern = new RegExp(`${escapeRegExp(os4.homedir())}(?=[/\\\\]|$)|\\$HOM
|
|
|
7880
7893
|
|
|
7881
7894
|
// packages/workit-core/src/store/paths.ts
|
|
7882
7895
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
7896
|
+
import fs5 from "node:fs";
|
|
7897
|
+
import path8 from "node:path";
|
|
7898
|
+
|
|
7899
|
+
// packages/workit-core/src/store/folder-store.ts
|
|
7883
7900
|
import fs4 from "node:fs";
|
|
7901
|
+
import os5 from "node:os";
|
|
7884
7902
|
import path7 from "node:path";
|
|
7903
|
+
var FOLDER_CONFIG = new Set(["checks.json", "risk-paths"]);
|
|
7904
|
+
var MOVED_POINTER = "MOVED-TO-STATE.txt";
|
|
7905
|
+
var V2_LEFTOVERS = new Set(["recovery", "index.json"]);
|
|
7906
|
+
var isV2TaskStub = (rel) => /^tasks[/\\][^/\\]+\.json$/u.test(rel);
|
|
7907
|
+
var MARKER = "workspace.json";
|
|
7908
|
+
var v2Workspace = (workit) => {
|
|
7909
|
+
let bytes;
|
|
7910
|
+
try {
|
|
7911
|
+
bytes = fs4.readFileSync(path7.join(workit, MARKER), "utf8");
|
|
7912
|
+
} catch {
|
|
7913
|
+
return null;
|
|
7914
|
+
}
|
|
7915
|
+
try {
|
|
7916
|
+
const value = JSON.parse(bytes);
|
|
7917
|
+
return value?.store?.format !== "workit-store";
|
|
7918
|
+
} catch {
|
|
7919
|
+
return true;
|
|
7920
|
+
}
|
|
7921
|
+
};
|
|
7922
|
+
var generatedIgnore = (file) => {
|
|
7923
|
+
try {
|
|
7924
|
+
return /^\*\n(!risk-paths\n)?$/u.test(fs4.readFileSync(file, "utf8"));
|
|
7925
|
+
} catch {
|
|
7926
|
+
return false;
|
|
7927
|
+
}
|
|
7928
|
+
};
|
|
7929
|
+
var exists = (file) => {
|
|
7930
|
+
try {
|
|
7931
|
+
fs4.lstatSync(file);
|
|
7932
|
+
return true;
|
|
7933
|
+
} catch {
|
|
7934
|
+
return false;
|
|
7935
|
+
}
|
|
7936
|
+
};
|
|
7937
|
+
var isDir = (file) => {
|
|
7938
|
+
try {
|
|
7939
|
+
return fs4.lstatSync(file).isDirectory();
|
|
7940
|
+
} catch {
|
|
7941
|
+
return false;
|
|
7942
|
+
}
|
|
7943
|
+
};
|
|
7944
|
+
var onlyStubs = (tasks) => {
|
|
7945
|
+
try {
|
|
7946
|
+
return fs4.readdirSync(tasks).every((entry) => isV2TaskStub(`tasks/${entry}`));
|
|
7947
|
+
} catch {
|
|
7948
|
+
return false;
|
|
7949
|
+
}
|
|
7950
|
+
};
|
|
7951
|
+
var strayEntries = (workit) => {
|
|
7952
|
+
if (!isDir(workit))
|
|
7953
|
+
return [];
|
|
7954
|
+
let names;
|
|
7955
|
+
try {
|
|
7956
|
+
names = fs4.readdirSync(workit);
|
|
7957
|
+
} catch {
|
|
7958
|
+
return [];
|
|
7959
|
+
}
|
|
7960
|
+
return names.filter((name) => !FOLDER_CONFIG.has(name) && !V2_LEFTOVERS.has(name) && name !== MOVED_POINTER && name !== MARKER && !(name === ".gitignore" && generatedIgnore(path7.join(workit, name))) && !(name === "tasks" && onlyStubs(path7.join(workit, name))));
|
|
7961
|
+
};
|
|
7962
|
+
var folderStoreIo = {
|
|
7963
|
+
rename: (from, to) => fs4.renameSync(from, to),
|
|
7964
|
+
copyFile: (from, to) => fs4.copyFileSync(from, to, fs4.constants.COPYFILE_EXCL)
|
|
7965
|
+
};
|
|
7966
|
+
var tempSeq = 0;
|
|
7967
|
+
var tempBeside = (file) => path7.join(path7.dirname(file), `.${path7.basename(file)}.workit-move-${process.pid}-${tempSeq += 1}`);
|
|
7968
|
+
var copyInto = (from, to) => {
|
|
7969
|
+
const stat = fs4.lstatSync(from);
|
|
7970
|
+
if (stat.isDirectory()) {
|
|
7971
|
+
fs4.mkdirSync(to, { recursive: true });
|
|
7972
|
+
for (const name of fs4.readdirSync(from))
|
|
7973
|
+
copyInto(path7.join(from, name), path7.join(to, name));
|
|
7974
|
+
return;
|
|
7975
|
+
}
|
|
7976
|
+
if (exists(to))
|
|
7977
|
+
throw new Error(`${to} appeared during the move`);
|
|
7978
|
+
const temp = tempBeside(to);
|
|
7979
|
+
try {
|
|
7980
|
+
if (stat.isSymbolicLink())
|
|
7981
|
+
fs4.symlinkSync(fs4.readlinkSync(from), temp);
|
|
7982
|
+
else
|
|
7983
|
+
folderStoreIo.copyFile(from, temp);
|
|
7984
|
+
folderStoreIo.rename(temp, to);
|
|
7985
|
+
} catch (error) {
|
|
7986
|
+
fs4.rmSync(temp, { force: true });
|
|
7987
|
+
throw error;
|
|
7988
|
+
}
|
|
7989
|
+
};
|
|
7990
|
+
var sameFile = (left, right) => {
|
|
7991
|
+
try {
|
|
7992
|
+
const [a, b] = [fs4.lstatSync(left), fs4.lstatSync(right)];
|
|
7993
|
+
if (!a.isFile() || !b.isFile() || a.size !== b.size)
|
|
7994
|
+
return false;
|
|
7995
|
+
return fs4.readFileSync(left).equals(fs4.readFileSync(right));
|
|
7996
|
+
} catch {
|
|
7997
|
+
return false;
|
|
7998
|
+
}
|
|
7999
|
+
};
|
|
8000
|
+
var merge2 = (from, to, rel, moved) => {
|
|
8001
|
+
if (isV2TaskStub(rel))
|
|
8002
|
+
return [];
|
|
8003
|
+
if (!exists(to)) {
|
|
8004
|
+
try {
|
|
8005
|
+
folderStoreIo.rename(from, to);
|
|
8006
|
+
} catch {
|
|
8007
|
+
try {
|
|
8008
|
+
copyInto(from, to);
|
|
8009
|
+
fs4.rmSync(from, { recursive: true, force: true });
|
|
8010
|
+
} catch {
|
|
8011
|
+
return exists(from) ? [rel] : [];
|
|
8012
|
+
}
|
|
8013
|
+
}
|
|
8014
|
+
moved.push(rel);
|
|
8015
|
+
return [];
|
|
8016
|
+
}
|
|
8017
|
+
if (sameFile(from, to)) {
|
|
8018
|
+
fs4.rmSync(from, { force: true });
|
|
8019
|
+
moved.push(rel);
|
|
8020
|
+
return [];
|
|
8021
|
+
}
|
|
8022
|
+
if (!isDir(from) || !isDir(to))
|
|
8023
|
+
return [rel];
|
|
8024
|
+
const kept = fs4.readdirSync(from).flatMap((name) => merge2(path7.join(from, name), path7.join(to, name), `${rel}/${name}`, moved));
|
|
8025
|
+
try {
|
|
8026
|
+
if (fs4.readdirSync(from).length === 0)
|
|
8027
|
+
fs4.rmdirSync(from);
|
|
8028
|
+
} catch {}
|
|
8029
|
+
return kept;
|
|
8030
|
+
};
|
|
8031
|
+
var LOCK_STALE_MS = 1e4;
|
|
8032
|
+
var LOCK_WAIT_MS = 250;
|
|
8033
|
+
var pause = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
8034
|
+
var staleLock = (lock) => {
|
|
8035
|
+
try {
|
|
8036
|
+
const stat = fs4.statSync(lock);
|
|
8037
|
+
if (Date.now() - stat.mtimeMs > LOCK_STALE_MS)
|
|
8038
|
+
return true;
|
|
8039
|
+
const pid = Number(fs4.readFileSync(lock, "utf8").trim());
|
|
8040
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
8041
|
+
return false;
|
|
8042
|
+
try {
|
|
8043
|
+
process.kill(pid, 0);
|
|
8044
|
+
return false;
|
|
8045
|
+
} catch (error) {
|
|
8046
|
+
return error.code === "ESRCH";
|
|
8047
|
+
}
|
|
8048
|
+
} catch {
|
|
8049
|
+
return false;
|
|
8050
|
+
}
|
|
8051
|
+
};
|
|
8052
|
+
var takeMoveLock = (target) => {
|
|
8053
|
+
const lock = `${target}.lock`;
|
|
8054
|
+
const deadline = Date.now() + LOCK_WAIT_MS;
|
|
8055
|
+
for (;; ) {
|
|
8056
|
+
try {
|
|
8057
|
+
const fd = fs4.openSync(lock, "wx", 384);
|
|
8058
|
+
fs4.writeSync(fd, `${process.pid}
|
|
8059
|
+
`);
|
|
8060
|
+
fs4.closeSync(fd);
|
|
8061
|
+
return () => fs4.rmSync(lock, { force: true });
|
|
8062
|
+
} catch (error) {
|
|
8063
|
+
if (error.code !== "EEXIST")
|
|
8064
|
+
return null;
|
|
8065
|
+
}
|
|
8066
|
+
if (staleLock(lock)) {
|
|
8067
|
+
fs4.rmSync(lock, { force: true });
|
|
8068
|
+
continue;
|
|
8069
|
+
}
|
|
8070
|
+
if (Date.now() >= deadline)
|
|
8071
|
+
return null;
|
|
8072
|
+
pause(25);
|
|
8073
|
+
}
|
|
8074
|
+
};
|
|
8075
|
+
var canonical3 = (dir) => {
|
|
8076
|
+
try {
|
|
8077
|
+
return fs4.realpathSync.native(dir);
|
|
8078
|
+
} catch {
|
|
8079
|
+
return path7.resolve(dir);
|
|
8080
|
+
}
|
|
8081
|
+
};
|
|
8082
|
+
var below = (parent, child) => {
|
|
8083
|
+
const rel = path7.relative(parent, child);
|
|
8084
|
+
return rel !== "" && !rel.startsWith("..") && !path7.isAbsolute(rel);
|
|
8085
|
+
};
|
|
8086
|
+
var TEST_RUN_REFUSALS = "folder-store-refusals.log";
|
|
8087
|
+
var testRunFolderRefusal = (folder, hasStray, env = process.env, tempDir = os5.tmpdir()) => {
|
|
8088
|
+
if (env.WORKIT_TEST_RUN === undefined || !hasStray)
|
|
8089
|
+
return null;
|
|
8090
|
+
const real = canonical3(folder);
|
|
8091
|
+
const tmp = canonical3(tempDir);
|
|
8092
|
+
if (below(tmp, real))
|
|
8093
|
+
return null;
|
|
8094
|
+
return `workit test run (WORKIT_TEST_RUN): refusing to move ${path7.join(real, ".workit")} into the run's throwaway state dir; a test must work in a fresh dir inside ${tmp}, never the temp dir itself, a parent of it or a folder outside it (#892)`;
|
|
8095
|
+
};
|
|
8096
|
+
function migrateFolderStore(folder, target, note = (line) => process.stderr.write(`${line}
|
|
8097
|
+
`)) {
|
|
8098
|
+
const workit = path7.join(folder, ".workit");
|
|
8099
|
+
const names = strayEntries(workit);
|
|
8100
|
+
const refusal = testRunFolderRefusal(folder, names.length > 0);
|
|
8101
|
+
if (refusal) {
|
|
8102
|
+
const run = process.env.WORKIT_TEST_RUN ?? "";
|
|
8103
|
+
if (path7.isAbsolute(run))
|
|
8104
|
+
try {
|
|
8105
|
+
fs4.appendFileSync(path7.join(run, TEST_RUN_REFUSALS), `${refusal}
|
|
8106
|
+
`);
|
|
8107
|
+
} catch {}
|
|
8108
|
+
throw new Error(refusal);
|
|
8109
|
+
}
|
|
8110
|
+
if (names.length === 0 || v2Workspace(workit) === true)
|
|
8111
|
+
return null;
|
|
8112
|
+
try {
|
|
8113
|
+
fs4.mkdirSync(path7.dirname(target), { recursive: true });
|
|
8114
|
+
} catch {
|
|
8115
|
+
return null;
|
|
8116
|
+
}
|
|
8117
|
+
const release = takeMoveLock(target);
|
|
8118
|
+
if (!release)
|
|
8119
|
+
return null;
|
|
8120
|
+
try {
|
|
8121
|
+
return moveLocked(workit, target, note);
|
|
8122
|
+
} finally {
|
|
8123
|
+
release();
|
|
8124
|
+
}
|
|
8125
|
+
}
|
|
8126
|
+
function moveLocked(workit, target, note) {
|
|
8127
|
+
const names = strayEntries(workit);
|
|
8128
|
+
if (names.length === 0 || v2Workspace(workit) === true)
|
|
8129
|
+
return null;
|
|
8130
|
+
try {
|
|
8131
|
+
fs4.mkdirSync(target, { recursive: true });
|
|
8132
|
+
} catch {
|
|
8133
|
+
return null;
|
|
8134
|
+
}
|
|
8135
|
+
const result = { from: workit, to: target, moved: [], kept: [] };
|
|
8136
|
+
for (const name of names) {
|
|
8137
|
+
result.kept.push(...merge2(path7.join(workit, name), path7.join(target, name), name, result.moved));
|
|
8138
|
+
}
|
|
8139
|
+
const left = (() => {
|
|
8140
|
+
try {
|
|
8141
|
+
return fs4.readdirSync(workit);
|
|
8142
|
+
} catch {
|
|
8143
|
+
return [];
|
|
8144
|
+
}
|
|
8145
|
+
})();
|
|
8146
|
+
const v2Left = left.some((name) => V2_LEFTOVERS.has(name) || name === "tasks" && isDir(path7.join(workit, name)));
|
|
8147
|
+
if (!v2Left && result.kept.length === 0) {
|
|
8148
|
+
fs4.rmSync(path7.join(workit, MARKER), { force: true });
|
|
8149
|
+
if (generatedIgnore(path7.join(workit, ".gitignore")))
|
|
8150
|
+
fs4.rmSync(path7.join(workit, ".gitignore"), { force: true });
|
|
8151
|
+
}
|
|
8152
|
+
const pointer = path7.join(workit, MOVED_POINTER);
|
|
8153
|
+
let wrote = false;
|
|
8154
|
+
if (result.kept.length > 0) {
|
|
8155
|
+
const text = `Workit keeps this folder's state in ${target}.
|
|
8156
|
+
Not moved, because the store there already has them or the move failed: ${result.kept.join(", ")}.
|
|
8157
|
+
Merge them by hand (cp -Rn ${workit}/. ${target}/), then delete them here.
|
|
8158
|
+
`;
|
|
8159
|
+
try {
|
|
8160
|
+
if (!exists(pointer) || fs4.readFileSync(pointer, "utf8") !== text) {
|
|
8161
|
+
fs4.writeFileSync(pointer, text);
|
|
8162
|
+
wrote = true;
|
|
8163
|
+
}
|
|
8164
|
+
} catch {}
|
|
8165
|
+
} else {
|
|
8166
|
+
fs4.rmSync(pointer, { force: true });
|
|
8167
|
+
try {
|
|
8168
|
+
if (fs4.readdirSync(workit).length === 0)
|
|
8169
|
+
fs4.rmdirSync(workit);
|
|
8170
|
+
} catch {}
|
|
8171
|
+
}
|
|
8172
|
+
if (result.moved.length > 0 || wrote)
|
|
8173
|
+
note(result.kept.length > 0 ? `workit: moved ${workit} to ${target}; ${result.kept.length} path${result.kept.length === 1 ? "" : "s"} left in place, see ${pointer}` : `workit: moved ${workit} to ${target} (outside a git repository Workit keeps its state there)`);
|
|
8174
|
+
return result;
|
|
8175
|
+
}
|
|
8176
|
+
|
|
8177
|
+
// packages/workit-core/src/store/paths.ts
|
|
7885
8178
|
var NOT_A_REPO = /not a git repository \(or any (of the parent directories|parent up to)/u;
|
|
7886
8179
|
var gitRun = (cwd, args) => {
|
|
7887
8180
|
const run = spawnSync5("git", args, {
|
|
@@ -7908,7 +8201,7 @@ var gitRun = (cwd, args) => {
|
|
|
7908
8201
|
};
|
|
7909
8202
|
var real = (file) => {
|
|
7910
8203
|
try {
|
|
7911
|
-
return
|
|
8204
|
+
return fs5.realpathSync.native(file);
|
|
7912
8205
|
} catch {
|
|
7913
8206
|
return file;
|
|
7914
8207
|
}
|
|
@@ -7922,14 +8215,14 @@ var DISCOVERY_ENV = [
|
|
|
7922
8215
|
];
|
|
7923
8216
|
var isGitDir = (dir) => {
|
|
7924
8217
|
try {
|
|
7925
|
-
return
|
|
8218
|
+
return fs5.statSync(path8.join(dir, "HEAD")).isFile() && fs5.statSync(path8.join(dir, "objects")).isDirectory() && fs5.statSync(path8.join(dir, "refs")).isDirectory();
|
|
7926
8219
|
} catch {
|
|
7927
8220
|
return false;
|
|
7928
8221
|
}
|
|
7929
8222
|
};
|
|
7930
8223
|
var reftableRefs = (common) => {
|
|
7931
8224
|
try {
|
|
7932
|
-
return /^\s*refstorage\s*=\s*reftable\s*$/imu.test(
|
|
8225
|
+
return /^\s*refstorage\s*=\s*reftable\s*$/imu.test(fs5.readFileSync(path8.join(common, "config"), "utf8"));
|
|
7933
8226
|
} catch {
|
|
7934
8227
|
return false;
|
|
7935
8228
|
}
|
|
@@ -7942,17 +8235,17 @@ function fastGit(root) {
|
|
|
7942
8235
|
for (;; ) {
|
|
7943
8236
|
let stat;
|
|
7944
8237
|
try {
|
|
7945
|
-
stat =
|
|
8238
|
+
stat = fs5.statSync(dir);
|
|
7946
8239
|
} catch {
|
|
7947
8240
|
return null;
|
|
7948
8241
|
}
|
|
7949
8242
|
if (device !== null && stat.dev !== device)
|
|
7950
8243
|
return { kind: "none" };
|
|
7951
8244
|
device = stat.dev;
|
|
7952
|
-
const dotGit =
|
|
8245
|
+
const dotGit = path8.join(dir, ".git");
|
|
7953
8246
|
let entry = null;
|
|
7954
8247
|
try {
|
|
7955
|
-
entry =
|
|
8248
|
+
entry = fs5.statSync(dotGit);
|
|
7956
8249
|
} catch {}
|
|
7957
8250
|
let gitDir = null;
|
|
7958
8251
|
let top = null;
|
|
@@ -7963,26 +8256,26 @@ function fastGit(root) {
|
|
|
7963
8256
|
else if (entry.isFile()) {
|
|
7964
8257
|
let text = "";
|
|
7965
8258
|
try {
|
|
7966
|
-
text =
|
|
8259
|
+
text = fs5.readFileSync(dotGit, "utf8");
|
|
7967
8260
|
} catch {
|
|
7968
8261
|
return null;
|
|
7969
8262
|
}
|
|
7970
8263
|
const match = /^gitdir: (.+)$/mu.exec(text);
|
|
7971
8264
|
if (!match)
|
|
7972
8265
|
return null;
|
|
7973
|
-
gitDir =
|
|
8266
|
+
gitDir = path8.resolve(dir, match[1].trim());
|
|
7974
8267
|
} else
|
|
7975
8268
|
return null;
|
|
7976
|
-
if (!
|
|
8269
|
+
if (!fs5.existsSync(path8.join(gitDir, "HEAD")))
|
|
7977
8270
|
return null;
|
|
7978
8271
|
} else if (isGitDir(dir))
|
|
7979
8272
|
gitDir = dir;
|
|
7980
8273
|
if (gitDir) {
|
|
7981
8274
|
let common = gitDir;
|
|
7982
8275
|
try {
|
|
7983
|
-
common =
|
|
8276
|
+
common = path8.resolve(gitDir, fs5.readFileSync(path8.join(gitDir, "commondir"), "utf8").trim());
|
|
7984
8277
|
} catch {}
|
|
7985
|
-
if (!
|
|
8278
|
+
if (!fs5.existsSync(path8.join(common, "objects")))
|
|
7986
8279
|
return null;
|
|
7987
8280
|
return {
|
|
7988
8281
|
kind: "repo",
|
|
@@ -7992,28 +8285,33 @@ function fastGit(root) {
|
|
|
7992
8285
|
reftable: reftableRefs(common)
|
|
7993
8286
|
};
|
|
7994
8287
|
}
|
|
7995
|
-
const parent =
|
|
8288
|
+
const parent = path8.dirname(dir);
|
|
7996
8289
|
if (parent === dir)
|
|
7997
8290
|
return { kind: "none" };
|
|
7998
8291
|
dir = parent;
|
|
7999
8292
|
}
|
|
8000
8293
|
}
|
|
8294
|
+
var outsideGit = (root) => {
|
|
8295
|
+
const dir = folderStoreDir(root);
|
|
8296
|
+
migrateFolderStore(root, dir);
|
|
8297
|
+
return { dir, shared: false, top: null };
|
|
8298
|
+
};
|
|
8001
8299
|
function resolveStore(root) {
|
|
8002
|
-
root =
|
|
8300
|
+
root = path8.resolve(root);
|
|
8003
8301
|
let stat = null;
|
|
8004
8302
|
try {
|
|
8005
|
-
stat =
|
|
8303
|
+
stat = fs5.statSync(root);
|
|
8006
8304
|
} catch {}
|
|
8007
8305
|
if (!stat)
|
|
8008
8306
|
return new Error(`cannot locate the workit store: ${root} does not exist (removed while workit ran?); nothing is recorded under a missing directory`);
|
|
8009
8307
|
if (!stat.isDirectory())
|
|
8010
|
-
return { dir:
|
|
8308
|
+
return { dir: path8.join(root, ".workit"), shared: false, top: null };
|
|
8011
8309
|
const fast = fastGit(root);
|
|
8012
8310
|
if (fast?.kind === "none")
|
|
8013
|
-
return
|
|
8311
|
+
return outsideGit(root);
|
|
8014
8312
|
if (fast?.kind === "repo")
|
|
8015
8313
|
return {
|
|
8016
|
-
dir:
|
|
8314
|
+
dir: path8.join(fast.common, "workit"),
|
|
8017
8315
|
shared: true,
|
|
8018
8316
|
top: fast.top,
|
|
8019
8317
|
git: { gitDir: fast.gitDir, top: fast.top, reftable: fast.reftable }
|
|
@@ -8023,13 +8321,13 @@ function resolveStore(root) {
|
|
|
8023
8321
|
if (run.ok && common) {
|
|
8024
8322
|
const top = gitRun(root, ["rev-parse", "--path-format=absolute", "--show-toplevel"]);
|
|
8025
8323
|
return {
|
|
8026
|
-
dir:
|
|
8324
|
+
dir: path8.join(real(path8.resolve(root, common)), "workit"),
|
|
8027
8325
|
shared: true,
|
|
8028
8326
|
top: top.ok && top.stdout.trim() ? real(top.stdout.trim()) : null
|
|
8029
8327
|
};
|
|
8030
8328
|
}
|
|
8031
8329
|
if (run.missing || !run.ok && NOT_A_REPO.test(run.stderr))
|
|
8032
|
-
return
|
|
8330
|
+
return outsideGit(root);
|
|
8033
8331
|
return new Error(`cannot locate the workit store: git rev-parse failed (${run.stderr.trim().split(`
|
|
8034
8332
|
`)[0] || "no output"}); fix the repository (git status should work here)`);
|
|
8035
8333
|
}
|
|
@@ -8076,27 +8374,27 @@ var KNOWN_TYPES = new Set([
|
|
|
8076
8374
|
var SLOT = Symbol.for("workit.migrationReporter");
|
|
8077
8375
|
|
|
8078
8376
|
// packages/workit-core/src/core/package-root.ts
|
|
8079
|
-
import { existsSync as
|
|
8080
|
-
import
|
|
8377
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
8378
|
+
import path9 from "node:path";
|
|
8081
8379
|
import { fileURLToPath } from "node:url";
|
|
8082
8380
|
var packageRoot = () => {
|
|
8083
|
-
let dir =
|
|
8381
|
+
let dir = path9.dirname(fileURLToPath(import.meta.url));
|
|
8084
8382
|
while (true) {
|
|
8085
|
-
const parent =
|
|
8086
|
-
if (
|
|
8383
|
+
const parent = path9.dirname(dir);
|
|
8384
|
+
if (existsSync4(path9.join(dir, "package.json")) || parent === dir)
|
|
8087
8385
|
return dir;
|
|
8088
8386
|
dir = parent;
|
|
8089
8387
|
}
|
|
8090
8388
|
};
|
|
8091
8389
|
var assetRoot = () => {
|
|
8092
8390
|
const root = packageRoot();
|
|
8093
|
-
const assets =
|
|
8094
|
-
return
|
|
8391
|
+
const assets = path9.join(root, "assets");
|
|
8392
|
+
return existsSync4(assets) ? assets : root;
|
|
8095
8393
|
};
|
|
8096
8394
|
|
|
8097
8395
|
// packages/workit-core/src/core/store-lock.ts
|
|
8098
8396
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
8099
|
-
import
|
|
8397
|
+
import fs6 from "node:fs";
|
|
8100
8398
|
var metadataLockSchema = object({
|
|
8101
8399
|
pid: number2().int().nonnegative().safe(),
|
|
8102
8400
|
processStart: string2().nullable(),
|
|
@@ -8113,7 +8411,7 @@ var parseProcStatStart = (stat) => {
|
|
|
8113
8411
|
};
|
|
8114
8412
|
var readProcStat = (pid) => {
|
|
8115
8413
|
try {
|
|
8116
|
-
return
|
|
8414
|
+
return fs6.readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
8117
8415
|
} catch {
|
|
8118
8416
|
return null;
|
|
8119
8417
|
}
|
|
@@ -8208,9 +8506,9 @@ var PYTHON_RUNNERS = new Set(["uv", "poetry", "pipenv", "pdm", "hatch", "rye"]);
|
|
|
8208
8506
|
|
|
8209
8507
|
// packages/workit-core/src/ledger.ts
|
|
8210
8508
|
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
8211
|
-
import { createHash as
|
|
8212
|
-
import
|
|
8213
|
-
import
|
|
8509
|
+
import { createHash as createHash4, randomBytes } from "node:crypto";
|
|
8510
|
+
import fs8 from "node:fs";
|
|
8511
|
+
import path11 from "node:path";
|
|
8214
8512
|
|
|
8215
8513
|
// packages/workit-core/src/core/policy/dep-bump.ts
|
|
8216
8514
|
var MANIFESTS = new Set(["package.json", "go.mod", "Cargo.toml", "pyproject.toml"]);
|
|
@@ -8325,46 +8623,46 @@ var REGULAR = new Set(["100644", "100755"]);
|
|
|
8325
8623
|
var TEST_ONLY_KINDS = new Set(["doc", "cosmetic", "generated"]);
|
|
8326
8624
|
|
|
8327
8625
|
// packages/workit-core/src/hooks/standing-signal.ts
|
|
8328
|
-
import { createHash as
|
|
8329
|
-
import
|
|
8330
|
-
import
|
|
8626
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
8627
|
+
import fs7 from "node:fs";
|
|
8628
|
+
import path10 from "node:path";
|
|
8331
8629
|
var gitStoreDir = (cwd) => {
|
|
8332
8630
|
try {
|
|
8333
|
-
for (let dir =
|
|
8334
|
-
const dotGit =
|
|
8335
|
-
if (
|
|
8631
|
+
for (let dir = path10.resolve(cwd);; dir = path10.dirname(dir)) {
|
|
8632
|
+
const dotGit = path10.join(dir, ".git");
|
|
8633
|
+
if (fs7.existsSync(dotGit)) {
|
|
8336
8634
|
let gitDir = dotGit;
|
|
8337
|
-
if (
|
|
8338
|
-
const target = /^gitdir:\s*(.+)$/mu.exec(
|
|
8635
|
+
if (fs7.statSync(dotGit).isFile()) {
|
|
8636
|
+
const target = /^gitdir:\s*(.+)$/mu.exec(fs7.readFileSync(dotGit, "utf8"))?.[1]?.trim();
|
|
8339
8637
|
if (!target)
|
|
8340
8638
|
return null;
|
|
8341
|
-
gitDir =
|
|
8342
|
-
const common =
|
|
8343
|
-
if (
|
|
8344
|
-
gitDir =
|
|
8639
|
+
gitDir = path10.resolve(dir, target);
|
|
8640
|
+
const common = path10.join(gitDir, "commondir");
|
|
8641
|
+
if (fs7.existsSync(common))
|
|
8642
|
+
gitDir = path10.resolve(gitDir, fs7.readFileSync(common, "utf8").trim());
|
|
8345
8643
|
}
|
|
8346
|
-
return
|
|
8644
|
+
return path10.join(gitDir, "workit");
|
|
8347
8645
|
}
|
|
8348
|
-
if (
|
|
8646
|
+
if (path10.dirname(dir) === dir)
|
|
8349
8647
|
return null;
|
|
8350
8648
|
}
|
|
8351
8649
|
} catch {
|
|
8352
8650
|
return null;
|
|
8353
8651
|
}
|
|
8354
8652
|
};
|
|
8355
|
-
var standingRevFile = (store) =>
|
|
8356
|
-
var standingSeenFile = (store, session, agentId) =>
|
|
8653
|
+
var standingRevFile = (store) => path10.join(store, "standing", "rev");
|
|
8654
|
+
var standingSeenFile = (store, session, agentId) => path10.join(store, "standing", "seen", `${createHash3("sha256").update(`${session}\x00${agentId ?? ""}`).digest("hex").slice(0, 32)}.json`);
|
|
8357
8655
|
var readStandingRev = (store) => {
|
|
8358
8656
|
try {
|
|
8359
|
-
return
|
|
8657
|
+
return fs7.readFileSync(standingRevFile(store), "utf8").trim() || null;
|
|
8360
8658
|
} catch {
|
|
8361
8659
|
return null;
|
|
8362
8660
|
}
|
|
8363
8661
|
};
|
|
8364
8662
|
var writeStandingSeen = (file, seen) => {
|
|
8365
8663
|
try {
|
|
8366
|
-
|
|
8367
|
-
|
|
8664
|
+
fs7.mkdirSync(path10.dirname(file), { recursive: true });
|
|
8665
|
+
fs7.writeFileSync(file, JSON.stringify(seen));
|
|
8368
8666
|
} catch {}
|
|
8369
8667
|
};
|
|
8370
8668
|
|
|
@@ -8415,14 +8713,14 @@ var git2 = (cwd, args) => {
|
|
|
8415
8713
|
};
|
|
8416
8714
|
var safeRef = (value) => value.length > 0 && !value.startsWith("-");
|
|
8417
8715
|
function storeRoot(cwd) {
|
|
8418
|
-
const location = resolveStore(
|
|
8716
|
+
const location = resolveStore(path11.resolve(cwd));
|
|
8419
8717
|
if (location instanceof Error)
|
|
8420
8718
|
return err("unavailable", location.message.replace(/; fix the repository.*$/u, ""), / does not exist /u.test(location.message) ? "run workit from a directory that exists" : "fix the repository (git status should work here) or run from a non-git directory");
|
|
8421
8719
|
return { ok: true, value: { root: location.dir, shared: location.shared } };
|
|
8422
8720
|
}
|
|
8423
8721
|
function ledgerPath(cwd) {
|
|
8424
8722
|
const root = storeRoot(cwd);
|
|
8425
|
-
return root.ok ? { ok: true, value:
|
|
8723
|
+
return root.ok ? { ok: true, value: path11.join(root.value.root, "ledger", "ledger.jsonl") } : root;
|
|
8426
8724
|
}
|
|
8427
8725
|
var NETWORK_FS_TYPES = new Set([
|
|
8428
8726
|
26985,
|
|
@@ -8436,7 +8734,7 @@ var NETWORK_FS_TYPES = new Set([
|
|
|
8436
8734
|
1196443219,
|
|
8437
8735
|
198183888
|
|
8438
8736
|
]);
|
|
8439
|
-
var sha2562 = (text) =>
|
|
8737
|
+
var sha2562 = (text) => createHash4("sha256").update(text).digest("hex");
|
|
8440
8738
|
var chainHash = (prevHash, body) => sha2562(`${prevHash ?? ""}
|
|
8441
8739
|
${body}`);
|
|
8442
8740
|
var TAIL_BYTES = 64 * 1024;
|
|
@@ -8471,8 +8769,8 @@ function readLedgerAt(cwd, file, options) {
|
|
|
8471
8769
|
let text = "";
|
|
8472
8770
|
let stat = null;
|
|
8473
8771
|
try {
|
|
8474
|
-
stat =
|
|
8475
|
-
text =
|
|
8772
|
+
stat = fs8.statSync(file);
|
|
8773
|
+
text = fs8.readFileSync(file, "utf8");
|
|
8476
8774
|
} catch (error) {
|
|
8477
8775
|
if (error.code === "ENOENT")
|
|
8478
8776
|
return {
|
|
@@ -8706,8 +9004,8 @@ var OBSERVED_ONLY = new Set([
|
|
|
8706
9004
|
]);
|
|
8707
9005
|
|
|
8708
9006
|
// packages/workit-core/src/core/model-fallback.ts
|
|
8709
|
-
import { mkdirSync, readFileSync as readFileSync4, renameSync, writeFileSync } from "node:fs";
|
|
8710
|
-
import
|
|
9007
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
9008
|
+
import path12 from "node:path";
|
|
8711
9009
|
var LIMITS_FILE = "model-limits.json";
|
|
8712
9010
|
var DEFAULT_LIMIT_WINDOW_MS = 5 * 3600000;
|
|
8713
9011
|
var KEEP_MS = 9 * 86400000;
|
|
@@ -8730,7 +9028,7 @@ var providerOf = (model, host) => {
|
|
|
8730
9028
|
return null;
|
|
8731
9029
|
};
|
|
8732
9030
|
var empty = () => ({ exhausted: {}, seen: {}, redispatched: {} });
|
|
8733
|
-
var storePath = (stateDir) =>
|
|
9031
|
+
var storePath = (stateDir) => path12.join(stateDir ?? resolveStateDir(), LIMITS_FILE);
|
|
8734
9032
|
var readStore = (stateDir) => {
|
|
8735
9033
|
try {
|
|
8736
9034
|
const parsed = JSON.parse(readFileSync4(storePath(stateDir), "utf8"));
|
|
@@ -9196,12 +9494,12 @@ var contextReadSchema = object({
|
|
|
9196
9494
|
cwd: string2().min(1).optional()
|
|
9197
9495
|
}).strict();
|
|
9198
9496
|
// packages/workit-core/src/hooks/budget-signal.ts
|
|
9199
|
-
import { createHash as
|
|
9200
|
-
import
|
|
9201
|
-
import
|
|
9202
|
-
var hash = (text) =>
|
|
9203
|
-
var budgetDir = (store) =>
|
|
9204
|
-
var agentBase = (store, session, agentId) =>
|
|
9497
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
9498
|
+
import fs9 from "node:fs";
|
|
9499
|
+
import path13 from "node:path";
|
|
9500
|
+
var hash = (text) => createHash5("sha256").update(text).digest("hex").slice(0, 32);
|
|
9501
|
+
var budgetDir = (store) => path13.join(store, "budget");
|
|
9502
|
+
var agentBase = (store, session, agentId) => path13.join(budgetDir(store), hash(`${session}\x00${agentId ?? ""}`));
|
|
9205
9503
|
var spawnBudget = (prompt) => {
|
|
9206
9504
|
const found = /^TIMEBOX:[^\n]*?\b(\d+)\s+tool calls\b/mu.exec(prompt);
|
|
9207
9505
|
const n = found ? Number(found[1]) : NaN;
|
|
@@ -9209,16 +9507,16 @@ var spawnBudget = (prompt) => {
|
|
|
9209
9507
|
};
|
|
9210
9508
|
var startBudget = (store, session, agentId, n) => {
|
|
9211
9509
|
const dir = budgetDir(store);
|
|
9212
|
-
|
|
9510
|
+
fs9.mkdirSync(dir, { recursive: true });
|
|
9213
9511
|
const cutoff = Date.now() - 604800000;
|
|
9214
|
-
for (const name of
|
|
9512
|
+
for (const name of fs9.readdirSync(dir))
|
|
9215
9513
|
try {
|
|
9216
|
-
if (
|
|
9217
|
-
|
|
9514
|
+
if (fs9.statSync(path13.join(dir, name)).mtimeMs < cutoff)
|
|
9515
|
+
fs9.rmSync(path13.join(dir, name));
|
|
9218
9516
|
} catch {}
|
|
9219
9517
|
const base = agentBase(store, session, agentId);
|
|
9220
|
-
|
|
9221
|
-
|
|
9518
|
+
fs9.writeFileSync(`${base}.json`, JSON.stringify({ limit: n, told: 0 }));
|
|
9519
|
+
fs9.rmSync(`${base}.calls`, { force: true });
|
|
9222
9520
|
};
|
|
9223
9521
|
var bindBudget = (cwd, session, agentId, prompt) => {
|
|
9224
9522
|
try {
|
|
@@ -9235,8 +9533,8 @@ var bindBudget = (cwd, session, agentId, prompt) => {
|
|
|
9235
9533
|
var CODEX_GATED = new Set(["bash", "unifiedexec", "shell", "applypatch", "edit", "write"]);
|
|
9236
9534
|
|
|
9237
9535
|
// packages/workit-core/src/hooks/standing.ts
|
|
9238
|
-
import
|
|
9239
|
-
import
|
|
9536
|
+
import fs10 from "node:fs";
|
|
9537
|
+
import path15 from "node:path";
|
|
9240
9538
|
|
|
9241
9539
|
// packages/workit-core/src/approvals/store.ts
|
|
9242
9540
|
var REQUEST_TTL_MS = 30 * 60000;
|
|
@@ -9745,7 +10043,7 @@ var PI_DESCRIPTOR = {
|
|
|
9745
10043
|
};
|
|
9746
10044
|
|
|
9747
10045
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
9748
|
-
import
|
|
10046
|
+
import path14 from "node:path";
|
|
9749
10047
|
|
|
9750
10048
|
// packages/workit-core/src/core/live-session.ts
|
|
9751
10049
|
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
@@ -9787,7 +10085,7 @@ var PLACEHOLDERS = new WeakMap;
|
|
|
9787
10085
|
var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
|
|
9788
10086
|
var PUSHD2 = new Set(["pushd", "push-location"]);
|
|
9789
10087
|
var POPD2 = new Set(["popd", "pop-location"]);
|
|
9790
|
-
var UNKNOWN_DIR =
|
|
10088
|
+
var UNKNOWN_DIR = path14.resolve(path14.parse(process.cwd()).root, ".workit-unknown-dir");
|
|
9791
10089
|
var DECLARERS = new Set(["export", "declare", "typeset", "local", "readonly"]);
|
|
9792
10090
|
var REBINDS_ANY = new Set([
|
|
9793
10091
|
"source",
|
|
@@ -9841,7 +10139,7 @@ var OPENS = new Set(["if", "for", "while", "until", "{"]);
|
|
|
9841
10139
|
var CLOSES = new Set(["fi", "done", "}"]);
|
|
9842
10140
|
var UNFOLLOWED = new Set(["case", "esac", "select", "function"]);
|
|
9843
10141
|
var TRANSPARENT = new Set(["builtin", "command", "time", "!"]);
|
|
9844
|
-
var UNKNOWN_VAR =
|
|
10142
|
+
var UNKNOWN_VAR = path14.resolve(path14.parse(process.cwd()).root, ".workit-unknown-var");
|
|
9845
10143
|
|
|
9846
10144
|
// packages/workit-core/src/hooks/worktree-confine.ts
|
|
9847
10145
|
var CASE_INSENSITIVE2 = process.platform === "darwin" || process.platform === "win32";
|
|
@@ -9870,17 +10168,17 @@ var workitRole = (descriptor, agentType) => {
|
|
|
9870
10168
|
|
|
9871
10169
|
// packages/workit-core/src/hooks/standing.ts
|
|
9872
10170
|
var readPlans = (store) => {
|
|
9873
|
-
const dir =
|
|
10171
|
+
const dir = path15.join(store, "fanouts");
|
|
9874
10172
|
let names;
|
|
9875
10173
|
try {
|
|
9876
|
-
names =
|
|
10174
|
+
names = fs10.readdirSync(dir).filter((name) => name.endsWith(".json"));
|
|
9877
10175
|
} catch {
|
|
9878
10176
|
return [];
|
|
9879
10177
|
}
|
|
9880
10178
|
const plans = [];
|
|
9881
10179
|
for (const name of names) {
|
|
9882
10180
|
try {
|
|
9883
|
-
const raw = JSON.parse(
|
|
10181
|
+
const raw = JSON.parse(fs10.readFileSync(path15.join(dir, name), "utf8"));
|
|
9884
10182
|
if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
|
|
9885
10183
|
continue;
|
|
9886
10184
|
const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
|