@brainervirus/workit-claude-code 8.45.1 → 8.45.3
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/.claude-plugin/plugin.json +1 -1
- package/dist/workit-hook.js +110 -109
- package/dist/workit.js +366 -338
- package/package.json +3 -3
package/dist/workit.js
CHANGED
|
@@ -7145,30 +7145,58 @@ var FORGE_SCHEMES, SSH_SCHEMES, SSH_443, WINDOWS_DRIVE, SCP_LIKE, accountHome =
|
|
|
7145
7145
|
}, caseless, canonical = (real) => {
|
|
7146
7146
|
const slashed = real.replaceAll("\\", "/").replace(/\/+$/u, "").replace(/\/\.git$/u, "");
|
|
7147
7147
|
return `file:${caseless ? slashed.toLowerCase() : slashed}`;
|
|
7148
|
-
},
|
|
7148
|
+
}, isRepoDir = (dir) => ["HEAD", "objects", "refs"].every((name) => {
|
|
7149
|
+
try {
|
|
7150
|
+
lstatSync(`${dir}/${name}`);
|
|
7151
|
+
return true;
|
|
7152
|
+
} catch {
|
|
7153
|
+
return false;
|
|
7154
|
+
}
|
|
7155
|
+
}), gitDirAt = (at, depth = 0) => {
|
|
7149
7156
|
let real;
|
|
7150
7157
|
try {
|
|
7151
7158
|
real = realpathSync.native(at);
|
|
7152
7159
|
} catch {
|
|
7153
7160
|
return null;
|
|
7154
7161
|
}
|
|
7162
|
+
if (depth > 8)
|
|
7163
|
+
return null;
|
|
7155
7164
|
try {
|
|
7156
7165
|
if (statSync(real).isFile()) {
|
|
7157
7166
|
const pointer = /^gitdir:\s*(.+?)\s*$/mu.exec(readFileSync2(real, "utf8"))?.[1];
|
|
7158
7167
|
if (!pointer)
|
|
7159
7168
|
return null;
|
|
7160
7169
|
const target = path3.isAbsolute(pointer) ? pointer : `${path3.dirname(real)}/${pointer}`;
|
|
7161
|
-
return gitDirAt(target);
|
|
7170
|
+
return gitDirAt(target, depth + 1);
|
|
7162
7171
|
}
|
|
7163
|
-
|
|
7172
|
+
let common;
|
|
7173
|
+
try {
|
|
7174
|
+
common = readFileSync2(`${real}/commondir`, "utf8").trim();
|
|
7175
|
+
} catch {}
|
|
7176
|
+
if (common !== undefined) {
|
|
7177
|
+
lstatSync(`${real}/HEAD`);
|
|
7178
|
+
return gitDirAt(path3.isAbsolute(common) ? common : `${real}/${common}`, depth + 1);
|
|
7179
|
+
}
|
|
7180
|
+
if (!isRepoDir(real))
|
|
7181
|
+
return null;
|
|
7182
|
+
let lender = null;
|
|
7183
|
+
for (const name of ["refs", "objects", "config", "packed-refs"]) {
|
|
7184
|
+
const item = `${real}/${name}`;
|
|
7164
7185
|
try {
|
|
7165
|
-
lstatSync(
|
|
7166
|
-
return true;
|
|
7186
|
+
lstatSync(item);
|
|
7167
7187
|
} catch {
|
|
7168
|
-
|
|
7188
|
+
continue;
|
|
7169
7189
|
}
|
|
7170
|
-
|
|
7171
|
-
|
|
7190
|
+
const resolved = realpathSync.native(item);
|
|
7191
|
+
const rel = path3.relative(real, resolved);
|
|
7192
|
+
if (rel && !rel.startsWith("..") && !path3.isAbsolute(rel))
|
|
7193
|
+
continue;
|
|
7194
|
+
const owner = path3.basename(resolved) === name ? gitDirAt(path3.dirname(resolved), depth + 1) : null;
|
|
7195
|
+
if (owner === null || lender !== null && lender !== owner)
|
|
7196
|
+
return null;
|
|
7197
|
+
lender = owner;
|
|
7198
|
+
}
|
|
7199
|
+
return lender ?? real;
|
|
7172
7200
|
} catch {
|
|
7173
7201
|
return null;
|
|
7174
7202
|
}
|
|
@@ -7218,7 +7246,7 @@ var FORGE_SCHEMES, SSH_SCHEMES, SSH_443, WINDOWS_DRIVE, SCP_LIKE, accountHome =
|
|
|
7218
7246
|
return null;
|
|
7219
7247
|
}
|
|
7220
7248
|
}
|
|
7221
|
-
if (path3.isAbsolute(value) || WINDOWS_DRIVE.test(value))
|
|
7249
|
+
if (path3.isAbsolute(value) || WINDOWS_DRIVE.test(value) || process.platform === "win32" && /^[A-Za-z]:/u.test(value))
|
|
7222
7250
|
return fileKey(value, strict);
|
|
7223
7251
|
const scp = SCP_LIKE.exec(value);
|
|
7224
7252
|
if (scp)
|
|
@@ -7289,14 +7317,17 @@ var FORGE_SCHEMES, SSH_SCHEMES, SSH_443, WINDOWS_DRIVE, SCP_LIKE, accountHome =
|
|
|
7289
7317
|
const file = realOrSelf(origin.slice("file:".length));
|
|
7290
7318
|
const home = userGitSeam.home();
|
|
7291
7319
|
return [path3.join(home, ".gitconfig"), path3.join(home, ".config", "git", "config")].map(realOrSelf).includes(file);
|
|
7292
|
-
}, escapeRegex2 = (value) => value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"), transportOverride = (git, remote) => {
|
|
7293
|
-
const env = TRANSPORT_ENV.find((name) =>
|
|
7320
|
+
}, escapeRegex2 = (value) => value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"), transportOverride = (git, remote, vars) => {
|
|
7321
|
+
const env = TRANSPORT_ENV.find((name) => vars[name]);
|
|
7294
7322
|
if (env)
|
|
7295
7323
|
return env;
|
|
7296
|
-
const execPath =
|
|
7324
|
+
const execPath = vars.GIT_EXEC_PATH;
|
|
7297
7325
|
if (execPath) {
|
|
7298
|
-
const { GIT_EXEC_PATH: _set, ...rest } =
|
|
7299
|
-
const own = spawnSync3("git", ["--exec-path"], {
|
|
7326
|
+
const { GIT_EXEC_PATH: _set, ...rest } = vars;
|
|
7327
|
+
const own = spawnSync3("git", ["--exec-path"], {
|
|
7328
|
+
env: rest,
|
|
7329
|
+
encoding: "utf8"
|
|
7330
|
+
});
|
|
7300
7331
|
if (own.status !== 0 || realOrSelf(own.stdout.trim()) !== realOrSelf(execPath))
|
|
7301
7332
|
return "GIT_EXEC_PATH";
|
|
7302
7333
|
}
|
|
@@ -7322,18 +7353,24 @@ var FORGE_SCHEMES, SSH_SCHEMES, SSH_443, WINDOWS_DRIVE, SCP_LIKE, accountHome =
|
|
|
7322
7353
|
return `${key} (${scope} ${origin})`;
|
|
7323
7354
|
}
|
|
7324
7355
|
return null;
|
|
7325
|
-
}, pushTarget = (cwd, remote) => {
|
|
7326
|
-
const env = { ...process.env };
|
|
7356
|
+
}, pushTarget = (cwd, remote, replay = {}) => {
|
|
7357
|
+
const env = { ...process.env, ...replay.env };
|
|
7327
7358
|
for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
|
|
7328
7359
|
delete env[name];
|
|
7329
7360
|
if (!remote || remote.startsWith("-"))
|
|
7330
7361
|
return Error(`push remote ${JSON.stringify(remote)} cannot be resolved`);
|
|
7331
|
-
const git = (args) => spawnSync3("git",
|
|
7332
|
-
|
|
7362
|
+
const git = (args) => spawnSync3("git", [...replay.config ?? [], ...args], {
|
|
7363
|
+
cwd,
|
|
7364
|
+
env,
|
|
7365
|
+
encoding: "utf8",
|
|
7366
|
+
timeout: 5000,
|
|
7367
|
+
windowsHide: true
|
|
7368
|
+
});
|
|
7369
|
+
const override = transportOverride(git, remote, env);
|
|
7333
7370
|
if (override)
|
|
7334
7371
|
return Error(`${override} decides what the push to ${remote} reaches, not its URL, so its target is unknown`);
|
|
7335
7372
|
const run = git(["remote", "get-url", "--push", "--all", remote]);
|
|
7336
|
-
const urls = run.status === 0 ? run.stdout.split(/\r?\n/u).map((url) => url.trim()) : [];
|
|
7373
|
+
const urls = run.status === 0 ? run.stdout.split(/\r?\n/u).map((url) => url.trim()) : run.status === 2 ? [remote] : [];
|
|
7337
7374
|
if (!urls.some(Boolean))
|
|
7338
7375
|
return Error(`git could not resolve the push URLs of remote ${remote} in ${cwd}`);
|
|
7339
7376
|
let top;
|
|
@@ -7367,7 +7404,9 @@ var init_remotes = __esm(() => {
|
|
|
7367
7404
|
};
|
|
7368
7405
|
WINDOWS_DRIVE = /^[A-Za-z]:[\\/]/u;
|
|
7369
7406
|
SCP_LIKE = /^(?:[^@/\\]+@)?([^/\\:]+):(.+)$/u;
|
|
7370
|
-
sshSeam = {
|
|
7407
|
+
sshSeam = {
|
|
7408
|
+
read: () => readSshConfig(accountHome())
|
|
7409
|
+
};
|
|
7371
7410
|
caseless = process.platform === "win32" || process.platform === "darwin";
|
|
7372
7411
|
TRANSPORT_ENV = ["GIT_SSH", "GIT_SSH_COMMAND", "GIT_PROXY_COMMAND"];
|
|
7373
7412
|
userGitSeam = { home: accountHome };
|
|
@@ -9695,7 +9734,7 @@ var package_default;
|
|
|
9695
9734
|
var init_package = __esm(() => {
|
|
9696
9735
|
package_default = {
|
|
9697
9736
|
name: "@brainervirus/workit-cli",
|
|
9698
|
-
version: "8.45.
|
|
9737
|
+
version: "8.45.3",
|
|
9699
9738
|
private: false,
|
|
9700
9739
|
description: "Workit CLI — setup wizard, doctor, and task control for agentic coding workflows",
|
|
9701
9740
|
keywords: [
|
|
@@ -9733,13 +9772,13 @@ var init_package = __esm(() => {
|
|
|
9733
9772
|
},
|
|
9734
9773
|
dependencies: {
|
|
9735
9774
|
"@babel/parser": "7.29.9",
|
|
9736
|
-
"@brainervirus/workit-cursor": "^8.45.
|
|
9775
|
+
"@brainervirus/workit-cursor": "^8.45.3",
|
|
9737
9776
|
"@inkjs/ui": "2.0.0",
|
|
9738
9777
|
ink: "7.1.1",
|
|
9739
9778
|
react: "19.2.8"
|
|
9740
9779
|
},
|
|
9741
9780
|
devDependencies: {
|
|
9742
|
-
"@brainervirus/workit-core": "^8.45.
|
|
9781
|
+
"@brainervirus/workit-core": "^8.45.3"
|
|
9743
9782
|
},
|
|
9744
9783
|
engines: {
|
|
9745
9784
|
node: ">=24"
|
|
@@ -10260,18 +10299,6 @@ function targetClaims(target, dir = grantsDir()) {
|
|
|
10260
10299
|
return pattern ? [{ url: remote.url, workspace: entry.name, pattern }] : [];
|
|
10261
10300
|
}));
|
|
10262
10301
|
}
|
|
10263
|
-
function remoteClaims(cwd, dir = grantsDir()) {
|
|
10264
|
-
const claiming = loadWorkspacesFrom(dir).filter((entry) => entry.remotes?.length);
|
|
10265
|
-
if (claiming.length === 0)
|
|
10266
|
-
return [];
|
|
10267
|
-
const remotes = checkoutRemotes(cwd);
|
|
10268
|
-
if (remotes instanceof Error)
|
|
10269
|
-
return remotes;
|
|
10270
|
-
return remotes.flatMap((remote) => claiming.flatMap((entry) => {
|
|
10271
|
-
const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
|
|
10272
|
-
return pattern ? [{ remote: remote.name, url: remote.url, workspace: entry.name, pattern }] : [];
|
|
10273
|
-
}));
|
|
10274
|
-
}
|
|
10275
10302
|
function remoteFindings(cwd, dir = grantsDir()) {
|
|
10276
10303
|
let own = null;
|
|
10277
10304
|
try {
|
|
@@ -10279,15 +10306,20 @@ function remoteFindings(cwd, dir = grantsDir()) {
|
|
|
10279
10306
|
} catch {
|
|
10280
10307
|
return { warnings: [], notes: [] };
|
|
10281
10308
|
}
|
|
10282
|
-
const
|
|
10283
|
-
if (
|
|
10284
|
-
return { warnings: [
|
|
10285
|
-
const
|
|
10309
|
+
const unclaimed = own !== null && !own.remotes?.length;
|
|
10310
|
+
if (!unclaimed && !remotesClaimed(dir))
|
|
10311
|
+
return { warnings: [], notes: [] };
|
|
10312
|
+
const remotes = checkoutRemotes(cwd);
|
|
10313
|
+
if (remotes instanceof Error && remotesClaimed(dir))
|
|
10314
|
+
return { warnings: [`${remotes.message}: grants here are capped at nothing`], notes: [] };
|
|
10315
|
+
const listed = remotes instanceof Error ? [] : remotes;
|
|
10316
|
+
const others = claimsOf(listed, dir).filter((claim) => claim.workspace !== own?.name);
|
|
10317
|
+
const warnings = others.map((claim) => `remote ${claim.remote} ${claim.url} is claimed by workspace ${claim.workspace} (${claim.pattern}): an action that targets it never exceeds ${claim.workspace}'s grants`);
|
|
10286
10318
|
const notes = [];
|
|
10287
|
-
if (own &&
|
|
10288
|
-
const
|
|
10289
|
-
const
|
|
10290
|
-
notes.push(`workspace ${own.name} claims no remotes, so a folder outside it whose origin is ${
|
|
10319
|
+
if (own && unclaimed) {
|
|
10320
|
+
const free = listed.filter((remote) => !others.some((claim) => claim.url === remote.url));
|
|
10321
|
+
const suggest = free.find((remote) => remote.name === "origin") ?? free[0];
|
|
10322
|
+
notes.push(`workspace ${own.name} claims no remotes, so a folder outside it whose origin is ${suggest ? suggest.url : "one of its remotes"} keeps that folder's grants; to claim it, the user runs in their own terminal: workit workspace set ${own.name} remotes=${suggest ? suggest.url : "<url>"}`);
|
|
10291
10323
|
}
|
|
10292
10324
|
return { warnings, notes };
|
|
10293
10325
|
}
|
|
@@ -10477,7 +10509,13 @@ var accountHome2 = () => {
|
|
|
10477
10509
|
else if (item === "merge")
|
|
10478
10510
|
grants.merge = "verified";
|
|
10479
10511
|
return Object.keys(grants).length > 0 ? grants : null;
|
|
10480
|
-
}, remotesClaimed = (dir = grantsDir()) => loadWorkspacesFrom(dir).some((entry) => entry.remotes?.length),
|
|
10512
|
+
}, remotesClaimed = (dir = grantsDir()) => loadWorkspacesFrom(dir).some((entry) => entry.remotes?.length), claimsOf = (remotes, dir) => {
|
|
10513
|
+
const claiming = loadWorkspacesFrom(dir).filter((entry) => entry.remotes?.length);
|
|
10514
|
+
return remotes.flatMap((remote) => claiming.flatMap((entry) => {
|
|
10515
|
+
const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
|
|
10516
|
+
return pattern ? [{ remote: remote.name, url: remote.url, workspace: entry.name, pattern }] : [];
|
|
10517
|
+
}));
|
|
10518
|
+
}, accountOf = (entry) => entry?.vcs?.account, suggested = (kind) => kind === "merge" ? "verified" : "true", accountHint = (workspace) => `set vcs.account for workspace "${workspace ?? "?"}" in ~/.config/workit/workspaces.json`, grantHint = (workspace, kind) => `ask the user to run, in their own terminal: workit grant set ${workspace ?? "<workspace>"} ${kind}=${suggested(kind)}`, raises = (kind, current, next) => {
|
|
10481
10519
|
const rank = (value) => value === true ? 2 : value === "verified" ? 1 : 0;
|
|
10482
10520
|
return rank(normalized(kind, next)) > rank(normalized(kind, current));
|
|
10483
10521
|
};
|
|
@@ -18728,9 +18766,9 @@ var init_shell_words = __esm(() => {
|
|
|
18728
18766
|
// packages/workit-core/src/hooks/raw-git.ts
|
|
18729
18767
|
import os6 from "node:os";
|
|
18730
18768
|
import path24 from "node:path";
|
|
18731
|
-
function rawInvocations(command, dialect = "posix", depth = 0) {
|
|
18769
|
+
function rawInvocations(command, dialect = "posix", depth = 0, inherited = {}) {
|
|
18732
18770
|
if (depth > 0)
|
|
18733
|
-
return walk2(command, dialect, depth);
|
|
18771
|
+
return walk2(command, dialect, depth, undefined, inherited);
|
|
18734
18772
|
const key = `${dialect}\x00${command}`;
|
|
18735
18773
|
const cached = RECENT.get(key);
|
|
18736
18774
|
if (cached)
|
|
@@ -18755,18 +18793,20 @@ function commandLines(command, dialect = "posix") {
|
|
|
18755
18793
|
}
|
|
18756
18794
|
return lines;
|
|
18757
18795
|
}
|
|
18758
|
-
function walk2(command, dialect, depth, seen) {
|
|
18796
|
+
function walk2(command, dialect, depth, seen, inherited = {}) {
|
|
18759
18797
|
const found = [];
|
|
18760
18798
|
let dir = null;
|
|
18761
18799
|
const groups = [];
|
|
18762
18800
|
let stack = [];
|
|
18763
18801
|
const vars = new Map;
|
|
18764
|
-
const exported = {};
|
|
18802
|
+
const exported = { ...inherited };
|
|
18803
|
+
let prefix = {};
|
|
18765
18804
|
const sessionConfig = [];
|
|
18766
18805
|
const nested = (script, inner) => {
|
|
18767
18806
|
if (!script || depth >= MAX_DEPTH)
|
|
18768
18807
|
return;
|
|
18769
|
-
const
|
|
18808
|
+
const env = { ...exported, ...prefix };
|
|
18809
|
+
const inside = seen ? walk2(script, inner, depth + 1, seen, env) : rawInvocations(script, inner, depth + 1, env);
|
|
18770
18810
|
for (const invocation of inside)
|
|
18771
18811
|
found.push({ ...invocation, dir: rebase(dir, invocation.dir) });
|
|
18772
18812
|
};
|
|
@@ -18776,6 +18816,7 @@ function walk2(command, dialect, depth, seen) {
|
|
|
18776
18816
|
if (split !== null)
|
|
18777
18817
|
return nested(split, "posix");
|
|
18778
18818
|
const { words, env } = stripPrefixes(line);
|
|
18819
|
+
prefix = env;
|
|
18779
18820
|
const name = commandName(words[0]);
|
|
18780
18821
|
if (!name)
|
|
18781
18822
|
return;
|
|
@@ -18836,6 +18877,7 @@ function walk2(command, dialect, depth, seen) {
|
|
|
18836
18877
|
tool: name,
|
|
18837
18878
|
dir,
|
|
18838
18879
|
args: words.slice(1),
|
|
18880
|
+
...Object.keys({ ...exported, ...env }).length ? { env: { ...exported, ...env } } : {},
|
|
18839
18881
|
...stdin === undefined ? {} : { stdin }
|
|
18840
18882
|
});
|
|
18841
18883
|
else if (name === "git") {
|
|
@@ -19250,7 +19292,9 @@ var SHELLS, POWERSHELLS, EVALS, WRAPPERS, WRAPPER_VALUES, KEYWORDS, DECLARATIONS
|
|
|
19250
19292
|
}, RECENT, LAUNCHERS, WORKIT_PACKAGE, PACKAGE_RUNNERS, OUTPUT_FILTERS, WORKIT_GLOBAL, PUSH_VALUE_OPTIONS, VALUE_OPTIONS, API_VALUES, API_FIELDS, GIT_COMMANDS;
|
|
19251
19293
|
var init_raw_git = __esm(() => {
|
|
19252
19294
|
init_branch();
|
|
19295
|
+
init_autonomy();
|
|
19253
19296
|
init_branch_policy();
|
|
19297
|
+
init_remotes();
|
|
19254
19298
|
init_workspaces();
|
|
19255
19299
|
init_ledger();
|
|
19256
19300
|
init_paths();
|
|
@@ -19260,7 +19304,9 @@ var init_raw_git = __esm(() => {
|
|
|
19260
19304
|
POWERSHELLS = new Set(["pwsh", "powershell"]);
|
|
19261
19305
|
EVALS = new Set(["eval", "iex", "invoke-expression"]);
|
|
19262
19306
|
WRAPPERS = {
|
|
19263
|
-
sudo: {
|
|
19307
|
+
sudo: {
|
|
19308
|
+
values: "-u -g -h -p -C -D -R -T -r -t -U --user --group --host --prompt --chdir"
|
|
19309
|
+
},
|
|
19264
19310
|
doas: { values: "-u -C" },
|
|
19265
19311
|
command: { values: "" },
|
|
19266
19312
|
builtin: { values: "" },
|
|
@@ -19299,7 +19345,7 @@ var init_raw_git = __esm(() => {
|
|
|
19299
19345
|
"--super-prefix"
|
|
19300
19346
|
]);
|
|
19301
19347
|
GIT_CONFIG_OPTIONS = new Set(["-c", "--config-env", "--git-dir"]);
|
|
19302
|
-
GIT_CONFIG_ENV = /^GIT_(?:CONFIG\w*|DIR|COMMON_DIR|WORK_TREE)$/;
|
|
19348
|
+
GIT_CONFIG_ENV = /^(?:GIT_(?:CONFIG\w*|DIR|COMMON_DIR|WORK_TREE|SSH|SSH_COMMAND|PROXY_COMMAND|EXEC_PATH)|GH_HOST|GH_REPO|GITLAB_HOST|GL_HOST)$/;
|
|
19303
19349
|
ASSIGNMENT = /^([A-Za-z_]\w*)=([\s\S]*)$/;
|
|
19304
19350
|
HERE = /^(?:\$PWD|\$\{PWD\}|\$\(\s*pwd\s*\)|`pwd`|\$\(\s*git\s+rev-parse\s+--show-toplevel\s*\))(?=$|[\\/])/;
|
|
19305
19351
|
VARIABLE = /\$(?:\{(\w+)\}|(\w+))/g;
|
|
@@ -67811,7 +67857,7 @@ var init_hook_runs = __esm(() => {
|
|
|
67811
67857
|
});
|
|
67812
67858
|
|
|
67813
67859
|
// packages/workit-cli/src/update-settings.ts
|
|
67814
|
-
import { mkdirSync as mkdirSync7, readFileSync as readFileSync18, renameSync as renameSync4, writeFileSync as writeFileSync9 } from "node:fs";
|
|
67860
|
+
import { mkdirSync as mkdirSync7, readFileSync as readFileSync18, realpathSync as realpathSync9, renameSync as renameSync4, writeFileSync as writeFileSync9 } from "node:fs";
|
|
67815
67861
|
import os12 from "node:os";
|
|
67816
67862
|
import path39 from "node:path";
|
|
67817
67863
|
var workitConfigDir = (env) => env.WORKFLOW_TOOLKIT_CONFIG ?? env.WORKFLOW_TOOLKIT_CONFIG_DIR ?? path39.join(env.XDG_CONFIG_HOME || path39.join(env.HOME ?? os12.homedir(), ".config"), "workit"), cacheFile = (env, dir = stateDir(env)) => path39.join(dir, "update-check.json"), readUpdateCache = (env, dir) => {
|
|
@@ -67858,6 +67904,22 @@ var workitConfigDir = (env) => env.WORKFLOW_TOOLKIT_CONFIG ?? env.WORKFLOW_TOOLK
|
|
|
67858
67904
|
} catch (error) {
|
|
67859
67905
|
return error instanceof Error ? error.message : `cannot write ${file}`;
|
|
67860
67906
|
}
|
|
67907
|
+
}, cliVersionOnDisk = (script = process.argv[1]) => {
|
|
67908
|
+
if (!script)
|
|
67909
|
+
return;
|
|
67910
|
+
let real = script;
|
|
67911
|
+
try {
|
|
67912
|
+
real = realpathSync9(script);
|
|
67913
|
+
} catch {}
|
|
67914
|
+
let dir = path39.dirname(real);
|
|
67915
|
+
for (let depth = 0;depth < 4; depth += 1, dir = path39.dirname(dir)) {
|
|
67916
|
+
try {
|
|
67917
|
+
const found = JSON.parse(readFileSync18(path39.join(dir, "package.json"), "utf8"));
|
|
67918
|
+
if (found.name === "@brainervirus/workit-cli" && typeof found.version === "string")
|
|
67919
|
+
return found.version;
|
|
67920
|
+
} catch {}
|
|
67921
|
+
}
|
|
67922
|
+
return;
|
|
67861
67923
|
};
|
|
67862
67924
|
var init_update_settings = __esm(() => {
|
|
67863
67925
|
init_heavy_words();
|
|
@@ -67895,7 +67957,7 @@ import {
|
|
|
67895
67957
|
readdirSync as readdirSync9,
|
|
67896
67958
|
mkdirSync as mkdirSync8,
|
|
67897
67959
|
readFileSync as readFileSync19,
|
|
67898
|
-
realpathSync as
|
|
67960
|
+
realpathSync as realpathSync10,
|
|
67899
67961
|
rmSync as rmSync3,
|
|
67900
67962
|
statSync as statSync6
|
|
67901
67963
|
} from "node:fs";
|
|
@@ -68118,7 +68180,7 @@ function applyHostPermissions(plan, options = {}) {
|
|
|
68118
68180
|
continue;
|
|
68119
68181
|
}
|
|
68120
68182
|
try {
|
|
68121
|
-
const target = change.before === null ? change.file :
|
|
68183
|
+
const target = change.before === null ? change.file : realpathSync10(change.file);
|
|
68122
68184
|
if (change.before !== null) {
|
|
68123
68185
|
const backups = path40.join(paths.stateDir, "host-permissions-backup");
|
|
68124
68186
|
mkdirSync8(backups, { recursive: true, mode: 448 });
|
|
@@ -71011,7 +71073,7 @@ import {
|
|
|
71011
71073
|
mkdtempSync as mkdtempSync2,
|
|
71012
71074
|
readFileSync as readFileSync21,
|
|
71013
71075
|
readdirSync as readdirSync11,
|
|
71014
|
-
realpathSync as
|
|
71076
|
+
realpathSync as realpathSync11,
|
|
71015
71077
|
renameSync as renameSync6,
|
|
71016
71078
|
rmSync as rmSync5,
|
|
71017
71079
|
statSync as statSync8,
|
|
@@ -71457,7 +71519,7 @@ function applyOpenCode(root, res) {
|
|
|
71457
71519
|
};
|
|
71458
71520
|
}
|
|
71459
71521
|
function copyPluginDir(src, dest) {
|
|
71460
|
-
const realSrc =
|
|
71522
|
+
const realSrc = realpathSync11(src);
|
|
71461
71523
|
const marker = path42.join(dest, ".workit-root");
|
|
71462
71524
|
const destIsLink = existsSync18(dest) && lstatSync8(dest).isSymbolicLink();
|
|
71463
71525
|
const synced = !destIsLink && readFileSafe(marker)?.trim() === realSrc && samePluginContent(realSrc, dest, dest);
|
|
@@ -71896,7 +71958,7 @@ var TOKEN_PLACEHOLDER3 = "YOUR_TOKEN_HERE", YT_OVERRIDES, VCS_OVERRIDES, SETUP_O
|
|
|
71896
71958
|
return (require2.resolve.paths(name) ?? []).map((dir) => path42.join(dir, name));
|
|
71897
71959
|
}, realRoot = (root) => {
|
|
71898
71960
|
try {
|
|
71899
|
-
return
|
|
71961
|
+
return realpathSync11(root);
|
|
71900
71962
|
} catch {
|
|
71901
71963
|
return root;
|
|
71902
71964
|
}
|
|
@@ -72956,7 +73018,7 @@ var init_wizard_state = __esm(() => {
|
|
|
72956
73018
|
});
|
|
72957
73019
|
|
|
72958
73020
|
// packages/workit-cli/src/admin/uninstall.ts
|
|
72959
|
-
import { existsSync as existsSync20, readFileSync as readFileSync23, realpathSync as
|
|
73021
|
+
import { existsSync as existsSync20, readFileSync as readFileSync23, realpathSync as realpathSync12, rmSync as rmSync7, writeFileSync as writeFileSync13 } from "node:fs";
|
|
72960
73022
|
import os16 from "node:os";
|
|
72961
73023
|
import path45 from "node:path";
|
|
72962
73024
|
function cleanCursorSettings(settings, pluginDir) {
|
|
@@ -73264,7 +73326,7 @@ var resolveUninstallPaths = (options = {}) => {
|
|
|
73264
73326
|
return false;
|
|
73265
73327
|
}
|
|
73266
73328
|
try {
|
|
73267
|
-
return
|
|
73329
|
+
return realpathSync12(actionPath) === realpathSync12(expected);
|
|
73268
73330
|
} catch {
|
|
73269
73331
|
return true;
|
|
73270
73332
|
}
|
|
@@ -76128,7 +76190,7 @@ function errorText(error) {
|
|
|
76128
76190
|
}
|
|
76129
76191
|
var LAUNCH_HOSTS, HOSTS2, LIVE_HOSTS, OPENCODE_PACKAGE = "@brainervirus/workit-opencode", OPENCODE_UPDATE, CODEX_MARKETPLACE = "workflow-toolkit", CLI_FIX = "npm install --global @brainervirus/workit-cli@latest", stderrTail = (text, lines = 5) => (text ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).slice(-lines).join(" | "), errorLine = (result) => `${result.stdout}
|
|
76130
76192
|
${result.stderr ?? ""}`.split(/\r?\n/).map((line) => line.trim()).find((line) => /\bError:/.test(line)), failureReason = (command, result) => {
|
|
76131
|
-
const tail = stderrTail(result.stderr);
|
|
76193
|
+
const tail = stderrTail(result.stderr) || stderrTail(result.stdout, 2);
|
|
76132
76194
|
const message = errorLine(result);
|
|
76133
76195
|
const detail = message && !tail.includes(message) ? [message, tail].filter(Boolean) : [tail];
|
|
76134
76196
|
const text = detail.filter(Boolean).join(" | ");
|
|
@@ -76872,8 +76934,6 @@ __export(exports_update_check, {
|
|
|
76872
76934
|
writeUpdatesMode: () => writeUpdatesMode
|
|
76873
76935
|
});
|
|
76874
76936
|
import { spawn as spawn3, spawnSync as spawnSync18 } from "node:child_process";
|
|
76875
|
-
import { readFileSync as readFileSync25 } from "node:fs";
|
|
76876
|
-
import path50 from "node:path";
|
|
76877
76937
|
async function launchUpdateCheck(context, deps) {
|
|
76878
76938
|
if (!interactiveLaunch(context, deps))
|
|
76879
76939
|
return;
|
|
@@ -76931,7 +76991,7 @@ Cancelled.
|
|
|
76931
76991
|
if (outcome.code !== 0 && outcome.failed.length)
|
|
76932
76992
|
deps.write(`${style.warn("Upgrade incomplete:")} ${outcome.failed.map((row) => `${row.host} failed${row.fix ? ` (fix: ${row.fix})` : ""}`).join("; ")}
|
|
76933
76993
|
`);
|
|
76934
|
-
const onDisk = (deps.cliOnDisk ??
|
|
76994
|
+
const onDisk = (deps.cliOnDisk ?? cliVersionOnDisk)();
|
|
76935
76995
|
if (!onDisk || onDisk === installed) {
|
|
76936
76996
|
if (outcome.code !== 0)
|
|
76937
76997
|
deps.write(`${style.warn("Upgrade did not finish;")} running your command with ${installed}.
|
|
@@ -76940,20 +77000,7 @@ Cancelled.
|
|
|
76940
77000
|
}
|
|
76941
77001
|
return (deps.reexec ?? defaultReexec)(context.argv);
|
|
76942
77002
|
}
|
|
76943
|
-
var CLI_PACKAGE2 = "@brainervirus/workit-cli", UPDATE_TTL_MS, QUIET_ENV = "WORKIT_UPDATE_CHECK", REFRESH_ENV = "WORKIT_UPDATE_REFRESH", AGENT_VARIABLES, AGENT_PREFIXES, PROFILE_VARIABLES, agentHostMarker = (env) => Object.keys(env).find((key) => env[key] !== undefined && !PROFILE_VARIABLES.has(key) && (AGENT_VARIABLES.has(key) || AGENT_PREFIXES.some((prefix) => key.startsWith(prefix)))), SILENT_COMMANDS, interactiveLaunch = (context, deps) => !SILENT_COMMANDS.has(context.command) && deps.env[QUIET_ENV] !== "0" && deps.stdin.isTTY === true && deps.stdout.isTTY === true && deps.stderr.isTTY === true && terminalMode({ stream: deps.stderr, env: deps.env, json: context.json }) !== "off" && agentHostMarker(deps.env) === undefined, CANCELLED_EXIT2 = 130,
|
|
76944
|
-
const script = process.argv[1];
|
|
76945
|
-
if (!script)
|
|
76946
|
-
return;
|
|
76947
|
-
let dir = path50.dirname(script);
|
|
76948
|
-
for (let depth = 0;depth < 4; depth += 1, dir = path50.dirname(dir)) {
|
|
76949
|
-
try {
|
|
76950
|
-
const found = JSON.parse(readFileSync25(path50.join(dir, "package.json"), "utf8"));
|
|
76951
|
-
if (found.name === CLI_PACKAGE2 && typeof found.version === "string")
|
|
76952
|
-
return found.version;
|
|
76953
|
-
} catch {}
|
|
76954
|
-
}
|
|
76955
|
-
return;
|
|
76956
|
-
}, defaultAsk = async (question) => (await Promise.resolve().then(() => (init_prompt(), exports_prompt))).askLine(question, process.stderr), defaultUpgrade = async () => {
|
|
77003
|
+
var CLI_PACKAGE2 = "@brainervirus/workit-cli", UPDATE_TTL_MS, QUIET_ENV = "WORKIT_UPDATE_CHECK", REFRESH_ENV = "WORKIT_UPDATE_REFRESH", AGENT_VARIABLES, AGENT_PREFIXES, PROFILE_VARIABLES, agentHostMarker = (env) => Object.keys(env).find((key) => env[key] !== undefined && !PROFILE_VARIABLES.has(key) && (AGENT_VARIABLES.has(key) || AGENT_PREFIXES.some((prefix) => key.startsWith(prefix)))), SILENT_COMMANDS, interactiveLaunch = (context, deps) => !SILENT_COMMANDS.has(context.command) && deps.env[QUIET_ENV] !== "0" && deps.stdin.isTTY === true && deps.stdout.isTTY === true && deps.stderr.isTTY === true && terminalMode({ stream: deps.stderr, env: deps.env, json: context.json }) !== "off" && agentHostMarker(deps.env) === undefined, CANCELLED_EXIT2 = 130, defaultAsk = async (question) => (await Promise.resolve().then(() => (init_prompt(), exports_prompt))).askLine(question, process.stderr), defaultUpgrade = async () => {
|
|
76957
77004
|
const failed = [];
|
|
76958
77005
|
const code = await (await Promise.resolve().then(() => (init_upgrade(), exports_upgrade))).runUpgradeCommand(["--yes"], {
|
|
76959
77006
|
out: process.stderr,
|
|
@@ -77024,12 +77071,12 @@ var init_update_check = __esm(() => {
|
|
|
77024
77071
|
// packages/workit-cli/src/upgrade/probes.ts
|
|
77025
77072
|
import { existsSync as existsSync23, mkdtempSync as mkdtempSync3, rmSync as rmSync8 } from "node:fs";
|
|
77026
77073
|
import os19 from "node:os";
|
|
77027
|
-
import
|
|
77074
|
+
import path50 from "node:path";
|
|
77028
77075
|
var PROBE_TIMEOUT_MS = 20000, probeKey = (command, args) => [command, ...args].join(" "), opencodeScratchEnv = (deps, scratch) => ({
|
|
77029
77076
|
...deps.env,
|
|
77030
|
-
XDG_DATA_HOME:
|
|
77031
|
-
XDG_STATE_HOME:
|
|
77032
|
-
XDG_CACHE_HOME:
|
|
77077
|
+
XDG_DATA_HOME: path50.join(scratch, "data"),
|
|
77078
|
+
XDG_STATE_HOME: path50.join(scratch, "state"),
|
|
77079
|
+
XDG_CACHE_HOME: path50.join(scratch, "cache")
|
|
77033
77080
|
}), registry2 = (name) => ["npm", ["view", name, "version"]], OPENCODE_READY_KEY = "opencode-ready", opencodeReading = (probes) => {
|
|
77034
77081
|
const result = probes?.get(OPENCODE_READY_KEY);
|
|
77035
77082
|
if (!result)
|
|
@@ -77044,7 +77091,7 @@ var PROBE_TIMEOUT_MS = 20000, probeKey = (command, args) => [command, ...args].j
|
|
|
77044
77091
|
const run = asyncRunner(deps, timeoutMs);
|
|
77045
77092
|
const probes = [];
|
|
77046
77093
|
const add = (command, args, runner = run) => probes.push([command, args, runner]);
|
|
77047
|
-
const scratch = mkdtempSync3(
|
|
77094
|
+
const scratch = mkdtempSync3(path50.join(os19.tmpdir(), "workit-upgrade-opencode-"));
|
|
77048
77095
|
try {
|
|
77049
77096
|
if (hosts.includes("opencode") && existsSync23(paths.opencodeConfig)) {
|
|
77050
77097
|
if (!options.check) {
|
|
@@ -77115,8 +77162,8 @@ var init_probes = __esm(() => {
|
|
|
77115
77162
|
});
|
|
77116
77163
|
|
|
77117
77164
|
// packages/workit-cli/src/upgrade/plan.ts
|
|
77118
|
-
import { existsSync as existsSync24, mkdtempSync as mkdtempSync4, rmSync as rmSync9, lstatSync as lstatSync9, readFileSync as
|
|
77119
|
-
import
|
|
77165
|
+
import { existsSync as existsSync24, mkdtempSync as mkdtempSync4, rmSync as rmSync9, lstatSync as lstatSync9, readFileSync as readFileSync25 } from "node:fs";
|
|
77166
|
+
import path51 from "node:path";
|
|
77120
77167
|
import os20 from "node:os";
|
|
77121
77168
|
function previewUpgrade(hosts = HOSTS2, deps = {}, probes) {
|
|
77122
77169
|
const paths = upgradePaths(deps);
|
|
@@ -77140,9 +77187,9 @@ function previewUpgrade(hosts = HOSTS2, deps = {}, probes) {
|
|
|
77140
77187
|
for (const file of [
|
|
77141
77188
|
paths.opencodeConfig,
|
|
77142
77189
|
paths.opencodeConfig + "c",
|
|
77143
|
-
|
|
77144
|
-
|
|
77145
|
-
|
|
77190
|
+
path51.join(home, ".cursor/settings.json"),
|
|
77191
|
+
path51.join(home, ".cursor/mcp.json"),
|
|
77192
|
+
path51.join(paths.cursorRoot, "package.json"),
|
|
77146
77193
|
paths.codexConfig,
|
|
77147
77194
|
paths.piSettings
|
|
77148
77195
|
])
|
|
@@ -77294,7 +77341,7 @@ function previewUpgrade(hosts = HOSTS2, deps = {}, probes) {
|
|
|
77294
77341
|
var codexRegistered = (configFile) => {
|
|
77295
77342
|
let text;
|
|
77296
77343
|
try {
|
|
77297
|
-
text =
|
|
77344
|
+
text = readFileSync25(configFile, "utf8");
|
|
77298
77345
|
} catch {
|
|
77299
77346
|
return false;
|
|
77300
77347
|
}
|
|
@@ -77337,8 +77384,8 @@ var codexRegistered = (configFile) => {
|
|
|
77337
77384
|
result.push(classify("opencode", pin));
|
|
77338
77385
|
});
|
|
77339
77386
|
guard("cursor", () => {
|
|
77340
|
-
const cursor = objectOrNull(
|
|
77341
|
-
const mcp = objectOrNull(
|
|
77387
|
+
const cursor = objectOrNull(path51.join(paths.cursorRoot, "package.json"));
|
|
77388
|
+
const mcp = objectOrNull(path51.join(home, ".cursor/mcp.json"));
|
|
77342
77389
|
const args = mcp?.mcpServers?.workit?.args ?? [];
|
|
77343
77390
|
const arg = args.find((value) => typeof value === "string" && value.startsWith("--package="));
|
|
77344
77391
|
const selector = typeof arg === "string" ? arg.slice(10) : "local";
|
|
@@ -77349,7 +77396,7 @@ var codexRegistered = (configFile) => {
|
|
|
77349
77396
|
});
|
|
77350
77397
|
return;
|
|
77351
77398
|
}
|
|
77352
|
-
const settings = objectOrNull(
|
|
77399
|
+
const settings = objectOrNull(path51.join(home, ".cursor/settings.json"));
|
|
77353
77400
|
const dirs = Array.isArray(settings?.plugin_dirs) ? settings.plugin_dirs : [];
|
|
77354
77401
|
const registered = mcp?.mcpServers?.workit !== undefined || dirs.some((dir) => String(dir).replaceAll("\\", "/").replace(/\/+$/, "").endsWith("local/workit"));
|
|
77355
77402
|
if (registered)
|
|
@@ -77364,7 +77411,7 @@ var codexRegistered = (configFile) => {
|
|
|
77364
77411
|
if (typeof source !== "string")
|
|
77365
77412
|
continue;
|
|
77366
77413
|
const npm = /^(?:npm:)?@brainervirus\/workit-pi(?:@[^/]+)?$/.test(source);
|
|
77367
|
-
const local =
|
|
77414
|
+
const local = path51.isAbsolute(source) && source.replaceAll("\\", "/").endsWith("/packages/workit-pi") && object2(path51.join(source, "package.json"))?.name === "@brainervirus/workit-pi";
|
|
77368
77415
|
if (!npm && !local)
|
|
77369
77416
|
continue;
|
|
77370
77417
|
const found = classify("pi", source);
|
|
@@ -77431,7 +77478,7 @@ var codexRegistered = (configFile) => {
|
|
|
77431
77478
|
const cached = probes?.get(probeKey("opencode", args));
|
|
77432
77479
|
if (cached)
|
|
77433
77480
|
return cached;
|
|
77434
|
-
const scratch = mkdtempSync4(
|
|
77481
|
+
const scratch = mkdtempSync4(path51.join(os20.tmpdir(), "workit-upgrade-opencode-"));
|
|
77435
77482
|
try {
|
|
77436
77483
|
return runner({ ...deps, env: opencodeScratchEnv(deps, scratch) })("opencode", args);
|
|
77437
77484
|
} finally {
|
|
@@ -77442,7 +77489,7 @@ var codexRegistered = (configFile) => {
|
|
|
77442
77489
|
return probes ? (command, args) => probes.get(probeKey(command, args)) ?? run(command, args) : run;
|
|
77443
77490
|
}, planCli = (plan, run) => {
|
|
77444
77491
|
const root = run("npm", ["root", "--global"]);
|
|
77445
|
-
if (root.status !== 0 || !
|
|
77492
|
+
if (root.status !== 0 || !path51.isAbsolute(root.stdout.trim())) {
|
|
77446
77493
|
plan.skipped.push({
|
|
77447
77494
|
host: "cli",
|
|
77448
77495
|
reason: "global npm location could not be verified",
|
|
@@ -77450,9 +77497,9 @@ var codexRegistered = (configFile) => {
|
|
|
77450
77497
|
});
|
|
77451
77498
|
return;
|
|
77452
77499
|
}
|
|
77453
|
-
const packageFile =
|
|
77500
|
+
const packageFile = path51.join(root.stdout.trim(), "@brainervirus/workit-cli/package.json");
|
|
77454
77501
|
const installed = objectOrNull(packageFile);
|
|
77455
|
-
if (installed?.name !== "@brainervirus/workit-cli" || lstatSync9(
|
|
77502
|
+
if (installed?.name !== "@brainervirus/workit-cli" || lstatSync9(path51.dirname(packageFile)).isSymbolicLink()) {
|
|
77456
77503
|
plan.skipped.push({
|
|
77457
77504
|
host: "cli",
|
|
77458
77505
|
reason: "no managed global CLI install (local links preserved); use npx @brainervirus/workit-cli@latest"
|
|
@@ -77492,7 +77539,7 @@ var init_plan = __esm(() => {
|
|
|
77492
77539
|
});
|
|
77493
77540
|
|
|
77494
77541
|
// packages/workit-cli/src/upgrade/check.ts
|
|
77495
|
-
import
|
|
77542
|
+
import path52 from "node:path";
|
|
77496
77543
|
async function runUpdateCheck(json, deps) {
|
|
77497
77544
|
const out = deps.out ?? process.stdout;
|
|
77498
77545
|
const paths = upgradePaths(deps);
|
|
@@ -77613,7 +77660,7 @@ function runSetUpdates(value, deps) {
|
|
|
77613
77660
|
`);
|
|
77614
77661
|
return 1;
|
|
77615
77662
|
}
|
|
77616
|
-
out.write(`updates: ${value} (saved in ${
|
|
77663
|
+
out.write(`updates: ${value} (saved in ${path52.join(configDir, "config.json")})
|
|
77617
77664
|
`);
|
|
77618
77665
|
return 0;
|
|
77619
77666
|
}
|
|
@@ -77713,9 +77760,9 @@ __export(exports_upgrade, {
|
|
|
77713
77760
|
runUpgradeCommand: () => runUpgradeCommand
|
|
77714
77761
|
});
|
|
77715
77762
|
import { spawnSync as spawnSync19 } from "node:child_process";
|
|
77716
|
-
import { mkdtempSync as mkdtempSync5, readFileSync as
|
|
77763
|
+
import { mkdtempSync as mkdtempSync5, readFileSync as readFileSync26, rmSync as rmSync10, writeFileSync as writeFileSync14 } from "node:fs";
|
|
77717
77764
|
import os21 from "node:os";
|
|
77718
|
-
import
|
|
77765
|
+
import path53 from "node:path";
|
|
77719
77766
|
async function runUpgradeCommand(argv, deps = {}) {
|
|
77720
77767
|
const { env } = upgradePaths(deps);
|
|
77721
77768
|
const handBack = env[CONTINUE_ENV] !== undefined ? env[ROWS_ENV] : undefined;
|
|
@@ -77830,10 +77877,10 @@ Nothing changed.
|
|
|
77830
77877
|
json
|
|
77831
77878
|
}));
|
|
77832
77879
|
const handoff = async (cli) => {
|
|
77833
|
-
if (!reexec || (deps.cliOnDisk ??
|
|
77880
|
+
if (!reexec || (deps.cliOnDisk ?? cliVersionOnDisk)() !== plan.cli?.latest)
|
|
77834
77881
|
return;
|
|
77835
|
-
const scratch = mkdtempSync5(
|
|
77836
|
-
const rowsFile =
|
|
77882
|
+
const scratch = mkdtempSync5(path53.join(os21.tmpdir(), "workit-upgrade-"));
|
|
77883
|
+
const rowsFile = path53.join(scratch, "rows.json");
|
|
77837
77884
|
try {
|
|
77838
77885
|
const code = await reexec([
|
|
77839
77886
|
...legacy ? ["--apply", "--confirm"] : ["--yes"],
|
|
@@ -77963,7 +78010,7 @@ var USAGE3 = `Usage: workit upgrade [--hosts=opencode,cursor,codex,pi,claude-cod
|
|
|
77963
78010
|
workit upgrade --set-updates=prompt|auto|off
|
|
77964
78011
|
`, CONTINUE_ENV = "WORKIT_UPGRADE_CONTINUE", ROWS_ENV = "WORKIT_UPGRADE_ROWS", readText5 = (file) => {
|
|
77965
78012
|
try {
|
|
77966
|
-
return
|
|
78013
|
+
return readFileSync26(file, "utf8");
|
|
77967
78014
|
} catch {
|
|
77968
78015
|
return;
|
|
77969
78016
|
}
|
|
@@ -77988,26 +78035,6 @@ var USAGE3 = `Usage: workit upgrade [--hosts=opencode,cursor,codex,pi,claude-cod
|
|
|
77988
78035
|
} catch {
|
|
77989
78036
|
return;
|
|
77990
78037
|
}
|
|
77991
|
-
}, runningCliVersion = () => {
|
|
77992
|
-
const script = process.argv[1];
|
|
77993
|
-
if (!script)
|
|
77994
|
-
return;
|
|
77995
|
-
let dir = path54.dirname(script);
|
|
77996
|
-
for (let depth = 0;depth < 4; depth += 1, dir = path54.dirname(dir)) {
|
|
77997
|
-
const found = cliPackageVersion(readText5(path54.join(dir, "package.json")));
|
|
77998
|
-
if (found)
|
|
77999
|
-
return found;
|
|
78000
|
-
}
|
|
78001
|
-
return;
|
|
78002
|
-
}, cliPackageVersion = (text) => {
|
|
78003
|
-
if (text === undefined)
|
|
78004
|
-
return;
|
|
78005
|
-
try {
|
|
78006
|
-
const found = JSON.parse(text);
|
|
78007
|
-
return found.name === package_default.name && typeof found.version === "string" ? found.version : undefined;
|
|
78008
|
-
} catch {
|
|
78009
|
-
return;
|
|
78010
|
-
}
|
|
78011
78038
|
}, spawnUpgrade = (options) => (argv, extra) => {
|
|
78012
78039
|
if (!options.entry)
|
|
78013
78040
|
return;
|
|
@@ -78030,6 +78057,7 @@ var init_upgrade = __esm(() => {
|
|
|
78030
78057
|
init_host_permissions();
|
|
78031
78058
|
init_progress();
|
|
78032
78059
|
init_style();
|
|
78060
|
+
init_update_settings();
|
|
78033
78061
|
init_apply();
|
|
78034
78062
|
init_check();
|
|
78035
78063
|
init_plan();
|
|
@@ -78064,7 +78092,7 @@ var init_launch = __esm(() => {
|
|
|
78064
78092
|
// packages/workit-core/src/knowledge.ts
|
|
78065
78093
|
import { spawnSync as spawnSync20 } from "node:child_process";
|
|
78066
78094
|
import fs20 from "node:fs";
|
|
78067
|
-
import
|
|
78095
|
+
import path54 from "node:path";
|
|
78068
78096
|
function lintKnowledge(root) {
|
|
78069
78097
|
const seen = new Set;
|
|
78070
78098
|
const unreadable = [];
|
|
@@ -78168,7 +78196,7 @@ var AGENTS_BYTE_BUDGET, STEERING_FILES, NEED_BASED_FILES, STANDARDS_FILE = "CODI
|
|
|
78168
78196
|
const end = lines.indexOf("---", 1);
|
|
78169
78197
|
return end === -1 ? lines : [...lines.slice(0, end + 1).map(() => ""), ...lines.slice(end + 1)];
|
|
78170
78198
|
}, read = (root, file) => {
|
|
78171
|
-
const full =
|
|
78199
|
+
const full = path54.join(root, file);
|
|
78172
78200
|
try {
|
|
78173
78201
|
fs20.lstatSync(full);
|
|
78174
78202
|
} catch {
|
|
@@ -78209,7 +78237,7 @@ var AGENTS_BYTE_BUDGET, STEERING_FILES, NEED_BASED_FILES, STANDARDS_FILE = "CODI
|
|
|
78209
78237
|
}
|
|
78210
78238
|
}, brokenLinks = (root, doc, tracked) => {
|
|
78211
78239
|
const findings = [];
|
|
78212
|
-
const base =
|
|
78240
|
+
const base = path54.dirname(path54.join(root, doc.file));
|
|
78213
78241
|
const missing = (target, line, how) => findings.push({
|
|
78214
78242
|
rule: "broken-link",
|
|
78215
78243
|
file: doc.file,
|
|
@@ -78228,7 +78256,7 @@ var AGENTS_BYTE_BUDGET, STEERING_FILES, NEED_BASED_FILES, STANDARDS_FILE = "CODI
|
|
|
78228
78256
|
const local = localTarget(target);
|
|
78229
78257
|
if (!local)
|
|
78230
78258
|
continue;
|
|
78231
|
-
const resolved = local.startsWith("/") ?
|
|
78259
|
+
const resolved = local.startsWith("/") ? path54.join(root, local) : path54.resolve(base, local);
|
|
78232
78260
|
if (!exists2(resolved))
|
|
78233
78261
|
missing(target, index + 1, "link");
|
|
78234
78262
|
}
|
|
@@ -78238,9 +78266,9 @@ var AGENTS_BYTE_BUDGET, STEERING_FILES, NEED_BASED_FILES, STANDARDS_FILE = "CODI
|
|
|
78238
78266
|
continue;
|
|
78239
78267
|
const relative = /^\.\.?\//.test(candidate);
|
|
78240
78268
|
const first = candidate.split("/")[0];
|
|
78241
|
-
if (!relative && !(tracked ? tracked.has(first) : exists2(
|
|
78269
|
+
if (!relative && !(tracked ? tracked.has(first) : exists2(path54.join(root, first))))
|
|
78242
78270
|
continue;
|
|
78243
|
-
const resolved = relative ?
|
|
78271
|
+
const resolved = relative ? path54.resolve(base, candidate) : path54.join(root, candidate);
|
|
78244
78272
|
if (!exists2(resolved))
|
|
78245
78273
|
missing(span, index + 1, "pointer");
|
|
78246
78274
|
}
|
|
@@ -78610,7 +78638,7 @@ import { spawn as spawn4, spawnSync as spawnSync21 } from "node:child_process";
|
|
|
78610
78638
|
import { createHash as createHash17 } from "node:crypto";
|
|
78611
78639
|
import fs21 from "node:fs";
|
|
78612
78640
|
import os22 from "node:os";
|
|
78613
|
-
import
|
|
78641
|
+
import path55 from "node:path";
|
|
78614
78642
|
import { StringDecoder } from "node:string_decoder";
|
|
78615
78643
|
function tailLines(text, lines = TAIL_LINES) {
|
|
78616
78644
|
const all = text.replace(/\r\n?/gu, `
|
|
@@ -78730,7 +78758,7 @@ function planSpawn(argv, options) {
|
|
|
78730
78758
|
return { file: argv[0], args: [], verbatim: false, shell: true };
|
|
78731
78759
|
if (options.platform !== "win32")
|
|
78732
78760
|
return { file: argv[0], args: argv.slice(1), verbatim: false, shell: false };
|
|
78733
|
-
const win =
|
|
78761
|
+
const win = path55.win32;
|
|
78734
78762
|
const isFile = options.isFile ?? ((file) => {
|
|
78735
78763
|
try {
|
|
78736
78764
|
return fs21.statSync(file).isFile();
|
|
@@ -78892,10 +78920,10 @@ function runCheckCommand(argv, options) {
|
|
|
78892
78920
|
function storeLog(storeRoot, log) {
|
|
78893
78921
|
const digest = logDigest(log);
|
|
78894
78922
|
const ref = `blobs/logs/${digest.slice("sha256:".length)}.log`;
|
|
78895
|
-
const file =
|
|
78923
|
+
const file = path55.join(storeRoot, ref);
|
|
78896
78924
|
try {
|
|
78897
78925
|
if (!fs21.existsSync(file)) {
|
|
78898
|
-
fs21.mkdirSync(
|
|
78926
|
+
fs21.mkdirSync(path55.dirname(file), { recursive: true });
|
|
78899
78927
|
const temp = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
78900
78928
|
fs21.writeFileSync(temp, log, { mode: 384 });
|
|
78901
78929
|
fs21.renameSync(temp, file);
|
|
@@ -78908,7 +78936,7 @@ function storeLog(storeRoot, log) {
|
|
|
78908
78936
|
function pruneCheckLogs(storeRoot, options = {}) {
|
|
78909
78937
|
const limits = { ...LOG_RETENTION, ...options.retention };
|
|
78910
78938
|
const now = options.now ?? Date.now();
|
|
78911
|
-
const dir =
|
|
78939
|
+
const dir = path55.join(storeRoot, "blobs", "logs");
|
|
78912
78940
|
const report = { removed: 0, removedBytes: 0, kept: 0 };
|
|
78913
78941
|
let names;
|
|
78914
78942
|
try {
|
|
@@ -78918,7 +78946,7 @@ function pruneCheckLogs(storeRoot, options = {}) {
|
|
|
78918
78946
|
}
|
|
78919
78947
|
const files = names.flatMap((name) => {
|
|
78920
78948
|
try {
|
|
78921
|
-
const stat = fs21.statSync(
|
|
78949
|
+
const stat = fs21.statSync(path55.join(dir, name));
|
|
78922
78950
|
return stat.isFile() ? [{ name, size: stat.size, mtimeMs: stat.mtimeMs }] : [];
|
|
78923
78951
|
} catch {
|
|
78924
78952
|
return [];
|
|
@@ -78937,7 +78965,7 @@ function pruneCheckLogs(storeRoot, options = {}) {
|
|
|
78937
78965
|
continue;
|
|
78938
78966
|
if (!options.dryRun)
|
|
78939
78967
|
try {
|
|
78940
|
-
fs21.rmSync(
|
|
78968
|
+
fs21.rmSync(path55.join(dir, file.name), { force: true });
|
|
78941
78969
|
} catch {
|
|
78942
78970
|
continue;
|
|
78943
78971
|
}
|
|
@@ -79677,12 +79705,12 @@ var init_workspace = __esm(() => {
|
|
|
79677
79705
|
|
|
79678
79706
|
// packages/workit-core/src/core/heavy-rules.ts
|
|
79679
79707
|
import fs22 from "node:fs";
|
|
79680
|
-
import
|
|
79708
|
+
import path56 from "node:path";
|
|
79681
79709
|
function gitTop(cwd) {
|
|
79682
|
-
for (let dir =
|
|
79683
|
-
if (fs22.existsSync(
|
|
79710
|
+
for (let dir = path56.resolve(cwd);; dir = path56.dirname(dir)) {
|
|
79711
|
+
if (fs22.existsSync(path56.join(dir, ".git")))
|
|
79684
79712
|
return dir;
|
|
79685
|
-
if (
|
|
79713
|
+
if (path56.dirname(dir) === dir)
|
|
79686
79714
|
return null;
|
|
79687
79715
|
}
|
|
79688
79716
|
}
|
|
@@ -79724,18 +79752,18 @@ var init_heavy_rules = () => {};
|
|
|
79724
79752
|
// packages/workit-core/src/core/heavy.ts
|
|
79725
79753
|
import fs23 from "node:fs";
|
|
79726
79754
|
import os23 from "node:os";
|
|
79727
|
-
import
|
|
79755
|
+
import path57 from "node:path";
|
|
79728
79756
|
function stateDir2(env, platform = process.platform) {
|
|
79729
79757
|
if (env.WORKFLOW_TOOLKIT_STATE)
|
|
79730
79758
|
return env.WORKFLOW_TOOLKIT_STATE;
|
|
79731
79759
|
if (env.XDG_STATE_HOME)
|
|
79732
|
-
return
|
|
79760
|
+
return path57.join(env.XDG_STATE_HOME, "workit");
|
|
79733
79761
|
const home = env.HOME || os23.homedir();
|
|
79734
79762
|
if (platform === "darwin")
|
|
79735
|
-
return
|
|
79763
|
+
return path57.join(home, "Library", "Application Support", "workit");
|
|
79736
79764
|
if (platform === "win32")
|
|
79737
|
-
return
|
|
79738
|
-
return
|
|
79765
|
+
return path57.join(env.LOCALAPPDATA ?? path57.join(home, "AppData", "Local"), "workit");
|
|
79766
|
+
return path57.join(home, ".local", "state", "workit");
|
|
79739
79767
|
}
|
|
79740
79768
|
function positional(words, from, values = PM_VALUES) {
|
|
79741
79769
|
let index = from;
|
|
@@ -79875,7 +79903,7 @@ function machinePatterns(env) {
|
|
|
79875
79903
|
return isRecord8(value) ? stringList2(value.patterns) : [];
|
|
79876
79904
|
}
|
|
79877
79905
|
function repoPatterns(cwd) {
|
|
79878
|
-
return repoHeavyCommands(gitTop(cwd) ??
|
|
79906
|
+
return repoHeavyCommands(gitTop(cwd) ?? path57.resolve(cwd));
|
|
79879
79907
|
}
|
|
79880
79908
|
function heavyLines(lines, options) {
|
|
79881
79909
|
const found = [];
|
|
@@ -79954,7 +79982,7 @@ function leaseRewrite(command) {
|
|
|
79954
79982
|
return null;
|
|
79955
79983
|
return `${prefix}workit check --heavy -- ${rest}`;
|
|
79956
79984
|
}
|
|
79957
|
-
var HEAVY_COMMANDS_FILE = "heavy-commands.json", heavyCommandsFile = (env) =>
|
|
79985
|
+
var HEAVY_COMMANDS_FILE = "heavy-commands.json", heavyCommandsFile = (env) => path57.join(stateDir2(env), HEAVY_COMMANDS_FILE), HEAVY_SCRIPT, INFO_FLAGS, WATCH_FLAG, WATCH_SCRIPT, sub = (...names) => new Set(names), TOOLS, PM_VALUES, baseName2 = (word) => (word?.split(/[\\/]/u).at(-1) ?? "").toLowerCase().replace(/\.(?:exe|cmd|bat|ps1)$/u, ""), WORKIT, PYTHONS, NPM_INSTALL, NPM_RUN, NPM_TEST, EXEC, globWord = (word) => new RegExp(`^${word.replace(/[.+?^${}()|[\]\\]/gu, "\\$&").replaceAll("*", ".*")}$`, "u"), matches2 = (matchers, words) => matchers.length <= words.length && matchers.every((matcher, index) => index === 0 ? matcher.test(words[0]) || matcher.test(baseName2(words[0])) : matcher.test(words[index])), readJson2 = (file) => {
|
|
79958
79986
|
try {
|
|
79959
79987
|
return JSON.parse(fs23.readFileSync(file, "utf8"));
|
|
79960
79988
|
} catch {
|
|
@@ -80101,7 +80129,7 @@ var init_heavy = __esm(() => {
|
|
|
80101
80129
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
80102
80130
|
import fs24 from "node:fs";
|
|
80103
80131
|
import os24 from "node:os";
|
|
80104
|
-
import
|
|
80132
|
+
import path58 from "node:path";
|
|
80105
80133
|
function memoryValue(value, host) {
|
|
80106
80134
|
const text = typeof value === "number" ? String(value) : typeof value === "string" ? value : "";
|
|
80107
80135
|
const percent = PERCENT.exec(text.trim());
|
|
@@ -80297,7 +80325,7 @@ function tryOnce(options, record, reclaimed) {
|
|
|
80297
80325
|
const text = `${JSON.stringify(record)}
|
|
80298
80326
|
`;
|
|
80299
80327
|
for (let slot = 0;slot < options.slots; slot += 1) {
|
|
80300
|
-
const file =
|
|
80328
|
+
const file = path58.join(options.dir, `slot-${slot}.json`);
|
|
80301
80329
|
for (let attempt = 0;attempt < 2; attempt += 1) {
|
|
80302
80330
|
try {
|
|
80303
80331
|
const fd = fs24.openSync(file, "wx", 384);
|
|
@@ -80342,7 +80370,7 @@ function leaseQueue(dir, probe = {}) {
|
|
|
80342
80370
|
}
|
|
80343
80371
|
const entries = [];
|
|
80344
80372
|
for (const name of names.filter((item) => item.endsWith(".json")).toSorted()) {
|
|
80345
|
-
const file =
|
|
80373
|
+
const file = path58.join(queueDir(dir), name);
|
|
80346
80374
|
const record = parseLease(readText6(file));
|
|
80347
80375
|
if (!record)
|
|
80348
80376
|
continue;
|
|
@@ -80358,9 +80386,9 @@ function leaseQueue(dir, probe = {}) {
|
|
|
80358
80386
|
function waitersAhead(options, own) {
|
|
80359
80387
|
let ahead = 0;
|
|
80360
80388
|
for (const entry of leaseQueue(options.dir, options.probe)) {
|
|
80361
|
-
if (
|
|
80389
|
+
if (path58.basename(entry.file) >= own)
|
|
80362
80390
|
break;
|
|
80363
|
-
if (!TICKET.test(
|
|
80391
|
+
if (!TICKET.test(path58.basename(entry.file)))
|
|
80364
80392
|
continue;
|
|
80365
80393
|
if (entry.stale && reclaim(entry.file, (current) => !current || staleReason(current, options.probe) !== null))
|
|
80366
80394
|
continue;
|
|
@@ -80372,7 +80400,7 @@ function liveHolders(options) {
|
|
|
80372
80400
|
return leaseSlots(options.dir, options.slots, options.probe).filter((slot) => slot.holder && !slot.stale).map((slot) => slot.holder);
|
|
80373
80401
|
}
|
|
80374
80402
|
function writeTicket(file, record) {
|
|
80375
|
-
fs24.mkdirSync(
|
|
80403
|
+
fs24.mkdirSync(path58.dirname(file), { recursive: true, mode: 448 });
|
|
80376
80404
|
fs24.writeFileSync(file, `${JSON.stringify(record)}
|
|
80377
80405
|
`, { mode: 384 });
|
|
80378
80406
|
}
|
|
@@ -80417,7 +80445,7 @@ async function acquireLease(options) {
|
|
|
80417
80445
|
const reclaimed = [];
|
|
80418
80446
|
let waitedOn = [];
|
|
80419
80447
|
const name = ticketName(started, record.id);
|
|
80420
|
-
const ticket =
|
|
80448
|
+
const ticket = path58.join(queueDir(options.dir), name);
|
|
80421
80449
|
const ticketRecord = {
|
|
80422
80450
|
...record,
|
|
80423
80451
|
maxAgeMs: options.waitMs + 60000
|
|
@@ -80538,7 +80566,7 @@ function heldLease(dir, id, options = {}) {
|
|
|
80538
80566
|
for (const name of names) {
|
|
80539
80567
|
if (!/^slot-\d+\.json$/u.test(name))
|
|
80540
80568
|
continue;
|
|
80541
|
-
const lease = parseLease(readText6(
|
|
80569
|
+
const lease = parseLease(readText6(path58.join(dir, name)));
|
|
80542
80570
|
if (lease?.id === id && !staleReason(lease, options.probe) && (options.ancestor ?? isAncestor)(lease.pid))
|
|
80543
80571
|
return lease;
|
|
80544
80572
|
}
|
|
@@ -80593,10 +80621,10 @@ async function runScoped(run, wrapper, sinks) {
|
|
|
80593
80621
|
}
|
|
80594
80622
|
function firstNotice(env, session, key, now = Date.now()) {
|
|
80595
80623
|
const id = (session ?? `ppid-${process.ppid}`).replace(/[^A-Za-z0-9_.-]/gu, "_").slice(0, 120);
|
|
80596
|
-
const dir =
|
|
80624
|
+
const dir = path58.join(stateDir2(env), "notices");
|
|
80597
80625
|
try {
|
|
80598
80626
|
fs24.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
80599
|
-
fs24.writeFileSync(
|
|
80627
|
+
fs24.writeFileSync(path58.join(dir, `${key}-${id}`), `${new Date(now).toISOString()}
|
|
80600
80628
|
`, {
|
|
80601
80629
|
flag: "wx",
|
|
80602
80630
|
mode: 384
|
|
@@ -80606,7 +80634,7 @@ function firstNotice(env, session, key, now = Date.now()) {
|
|
|
80606
80634
|
}
|
|
80607
80635
|
try {
|
|
80608
80636
|
for (const name of fs24.readdirSync(dir)) {
|
|
80609
|
-
const file =
|
|
80637
|
+
const file = path58.join(dir, name);
|
|
80610
80638
|
if (now - fs24.statSync(file).mtimeMs > NOTICE_TTL_MS)
|
|
80611
80639
|
fs24.rmSync(file, { force: true });
|
|
80612
80640
|
}
|
|
@@ -80616,7 +80644,7 @@ function firstNotice(env, session, key, now = Date.now()) {
|
|
|
80616
80644
|
function leaseSlots(dir, slots, probe = {}) {
|
|
80617
80645
|
const states = [];
|
|
80618
80646
|
for (let slot = 0;slot < slots; slot += 1) {
|
|
80619
|
-
const lease = parseLease(readText6(
|
|
80647
|
+
const lease = parseLease(readText6(path58.join(dir, `slot-${slot}.json`)));
|
|
80620
80648
|
states.push({
|
|
80621
80649
|
slot,
|
|
80622
80650
|
holder: lease ? holderOf(lease) : null,
|
|
@@ -80628,7 +80656,7 @@ function leaseSlots(dir, slots, probe = {}) {
|
|
|
80628
80656
|
var DEFAULT_HEAVY_CHECKS, DEFAULT_LIGHT_CHECKS, DEFAULT_SLOTS = 1, DEFAULT_WAIT_S = 1800, DEFAULT_MEMORY_SHARE = 0.4, DEFAULT_CPU_SHARE = 0.7, MAX_SLOTS = 64, UNREADABLE_TTL_MS = 30000, GUARD_TTL_MS = 30000, hostShape = () => ({
|
|
80629
80657
|
totalMemBytes: os24.totalmem(),
|
|
80630
80658
|
cpus: Math.max(1, os24.availableParallelism?.() ?? os24.cpus().length)
|
|
80631
|
-
}), isRecord9 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), SIZE, PERCENT, UNITS, leaseDir = (env) =>
|
|
80659
|
+
}), isRecord9 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), SIZE, PERCENT, UNITS, leaseDir = (env) => path58.join(stateDir2(env), "leases"), readText6 = (file) => {
|
|
80632
80660
|
try {
|
|
80633
80661
|
return fs24.readFileSync(file, "utf8");
|
|
80634
80662
|
} catch {
|
|
@@ -80659,7 +80687,7 @@ var DEFAULT_HEAVY_CHECKS, DEFAULT_LIGHT_CHECKS, DEFAULT_SLOTS = 1, DEFAULT_WAIT_
|
|
|
80659
80687
|
cwd: lease.cwd,
|
|
80660
80688
|
session: lease.session,
|
|
80661
80689
|
startedAt: lease.startedAt
|
|
80662
|
-
}), realClock, queueDir = (dir) =>
|
|
80690
|
+
}), realClock, queueDir = (dir) => path58.join(dir, "queue"), TICKET, ticketName = (now, id) => `${String(now).padStart(15, "0")}-${String(process.hrtime.bigint() % 10n ** 16n).padStart(16, "0")}-${id}.json`, SCOPE_START_FAILURE, NOTICE_TTL_MS;
|
|
80663
80691
|
var init_resources = __esm(() => {
|
|
80664
80692
|
init_checks3();
|
|
80665
80693
|
init_heavy();
|
|
@@ -80689,7 +80717,7 @@ __export(exports_check, {
|
|
|
80689
80717
|
workspaceResources: () => workspaceResources
|
|
80690
80718
|
});
|
|
80691
80719
|
import os25 from "node:os";
|
|
80692
|
-
import
|
|
80720
|
+
import path59 from "node:path";
|
|
80693
80721
|
function parse6(argv) {
|
|
80694
80722
|
const split = argv.indexOf("--");
|
|
80695
80723
|
const head = split >= 0 ? argv.slice(0, split) : [...argv];
|
|
@@ -80920,7 +80948,7 @@ ${footer}`;
|
|
|
80920
80948
|
}
|
|
80921
80949
|
async function workspaceResources(io) {
|
|
80922
80950
|
const env = io.env;
|
|
80923
|
-
const dir = env.WORKFLOW_TOOLKIT_CONFIG ?? env.WORKFLOW_TOOLKIT_CONFIG_DIR ??
|
|
80951
|
+
const dir = env.WORKFLOW_TOOLKIT_CONFIG ?? env.WORKFLOW_TOOLKIT_CONFIG_DIR ?? path59.join(env.XDG_CONFIG_HOME || path59.join(env.HOME || os25.homedir(), ".config"), "workit");
|
|
80924
80952
|
try {
|
|
80925
80953
|
await Promise.resolve().then(() => init_workspaces());
|
|
80926
80954
|
const workspace = resolveWorkspaceFrom(io.cwd, dir, env.WORKFLOW_WORKSPACE_NAME?.trim() || undefined);
|
|
@@ -81062,7 +81090,7 @@ async function run12(argv, io) {
|
|
|
81062
81090
|
if (options.shell && command.length !== 1)
|
|
81063
81091
|
return emit(io, fail2("invalid_input", '--shell takes the command as one string: workit check --shell -- "<cmd>"'));
|
|
81064
81092
|
}
|
|
81065
|
-
const relCwd = posix(
|
|
81093
|
+
const relCwd = posix(path59.relative(top, runCwd));
|
|
81066
81094
|
const configured = !options.shell && matchesNamedCheck(config, name, command, relCwd);
|
|
81067
81095
|
const shadowed = !configured && name !== null ? config.checks.find((item) => item.name === name) : undefined;
|
|
81068
81096
|
if (shadowed)
|
|
@@ -81127,7 +81155,7 @@ async function run12(argv, io) {
|
|
|
81127
81155
|
const modifiedWorktree = key.tree !== null && treeAfter !== key.tree;
|
|
81128
81156
|
const store = storeRoot(io.cwd);
|
|
81129
81157
|
const blob = store.ok ? storeLog(store.value.root, result.log) : null;
|
|
81130
|
-
const logPath = store.ok && blob ?
|
|
81158
|
+
const logPath = store.ok && blob ? path59.join(store.value.root, blob.ref) : null;
|
|
81131
81159
|
const tail = tailLines(result.log, TAIL_LINES);
|
|
81132
81160
|
const passed = result.exitCode === 0 && !result.timedOut;
|
|
81133
81161
|
const bounded = boundedArgv(command);
|
|
@@ -81242,7 +81270,7 @@ async function run12(argv, io) {
|
|
|
81242
81270
|
return recordError.code === "busy" ? 4 : recordError.code === "invalid_input" ? 2 : 5;
|
|
81243
81271
|
return 0;
|
|
81244
81272
|
}
|
|
81245
|
-
var USAGE6 = 'workit check <name> [--full] [--wait <dur> | --no-wait] [--no-lease --reason "<why>"] | workit check [--name <n>] [--shell] [--heavy] [--full] [--wait <dur> | --no-wait] [--timeout <s>] [--task <id>] [--json] -- <cmd…>', OUTPUT_LINES = 60, MAX_UNVERIFIED_RUN_MS, RECORD_TAIL_LINES = 20, RECORD_TAIL_CHARS = 200, posix = (value) => value.split(
|
|
81273
|
+
var USAGE6 = 'workit check <name> [--full] [--wait <dur> | --no-wait] [--no-lease --reason "<why>"] | workit check [--name <n>] [--shell] [--heavy] [--full] [--wait <dur> | --no-wait] [--timeout <s>] [--task <id>] [--json] -- <cmd…>', OUTPUT_LINES = 60, MAX_UNVERIFIED_RUN_MS, RECORD_TAIL_LINES = 20, RECORD_TAIL_CHARS = 200, posix = (value) => value.split(path59.sep).join("/") || ".", ENGINE_CODES2, FINGERPRINT_VARS, ANSI_COLOR, WARNING_LINE, NO_WARNINGS, STDERR_TAIL_LINES = 10, STDERR_KEEP_CHARS = 65536, FAILURE_LINE, MAX_FAILURE_LINES = 15;
|
|
81246
81274
|
var init_check2 = __esm(() => {
|
|
81247
81275
|
init_check_config();
|
|
81248
81276
|
init_checks3();
|
|
@@ -81273,7 +81301,7 @@ __export(exports_lock, {
|
|
|
81273
81301
|
run: () => run13
|
|
81274
81302
|
});
|
|
81275
81303
|
import fs25 from "node:fs";
|
|
81276
|
-
import
|
|
81304
|
+
import path60 from "node:path";
|
|
81277
81305
|
async function settingsFor(io) {
|
|
81278
81306
|
const workspace = await workspaceResources(io);
|
|
81279
81307
|
const config = loadCheckConfig(io.cwd);
|
|
@@ -81365,7 +81393,7 @@ function readPatterns(file) {
|
|
|
81365
81393
|
return { patterns: [] };
|
|
81366
81394
|
}
|
|
81367
81395
|
function writePatterns(file, value) {
|
|
81368
|
-
fs25.mkdirSync(
|
|
81396
|
+
fs25.mkdirSync(path60.dirname(file), { recursive: true, mode: 448 });
|
|
81369
81397
|
const temp = `${file}.${process.pid}.tmp`;
|
|
81370
81398
|
fs25.writeFileSync(temp, `${JSON.stringify(value, null, 2)}
|
|
81371
81399
|
`, { mode: 384 });
|
|
@@ -81451,9 +81479,9 @@ var exports_models = {};
|
|
|
81451
81479
|
__export(exports_models, {
|
|
81452
81480
|
run: () => run14
|
|
81453
81481
|
});
|
|
81454
|
-
import { existsSync as existsSync26, readdirSync as readdirSync13, readFileSync as
|
|
81482
|
+
import { existsSync as existsSync26, readdirSync as readdirSync13, readFileSync as readFileSync27, statSync as statSync10 } from "node:fs";
|
|
81455
81483
|
import os26 from "node:os";
|
|
81456
|
-
import
|
|
81484
|
+
import path61 from "node:path";
|
|
81457
81485
|
async function run14(argv, io) {
|
|
81458
81486
|
const [sub, ...args] = argv.filter((arg) => arg !== "--json");
|
|
81459
81487
|
if (sub !== "show")
|
|
@@ -81514,7 +81542,7 @@ var USAGE8 = "workit models show [--role <role>] [--tier <tier>] [--host <host>]
|
|
|
81514
81542
|
const found = new Set;
|
|
81515
81543
|
let text = "";
|
|
81516
81544
|
try {
|
|
81517
|
-
text =
|
|
81545
|
+
text = readFileSync27(file, "utf8");
|
|
81518
81546
|
} catch {
|
|
81519
81547
|
return found;
|
|
81520
81548
|
}
|
|
@@ -81528,24 +81556,24 @@ var USAGE8 = "workit models show [--role <role>] [--tier <tier>] [--host <host>]
|
|
|
81528
81556
|
} catch {}
|
|
81529
81557
|
return found;
|
|
81530
81558
|
}, matches3 = (ran, configured) => ran.toLowerCase().includes(configured.toLowerCase()), usageReport = (cwd, env, days) => {
|
|
81531
|
-
const projects =
|
|
81559
|
+
const projects = path61.join(env.CLAUDE_CONFIG_DIR || path61.join(env.HOME || os26.homedir(), ".claude"), "projects");
|
|
81532
81560
|
const since = Date.now() - days * 86400000;
|
|
81533
81561
|
const types = {};
|
|
81534
81562
|
let agents = 0;
|
|
81535
81563
|
const dirs = (dir) => {
|
|
81536
81564
|
try {
|
|
81537
|
-
return readdirSync13(dir).map((name) =>
|
|
81565
|
+
return readdirSync13(dir).map((name) => path61.join(dir, name));
|
|
81538
81566
|
} catch {
|
|
81539
81567
|
return [];
|
|
81540
81568
|
}
|
|
81541
81569
|
};
|
|
81542
81570
|
for (const project of dirs(projects))
|
|
81543
81571
|
for (const session of dirs(project))
|
|
81544
|
-
for (const meta of dirs(
|
|
81572
|
+
for (const meta of dirs(path61.join(session, "subagents")).filter((f) => f.endsWith(".meta.json"))) {
|
|
81545
81573
|
try {
|
|
81546
81574
|
if (statSync10(meta).mtimeMs < since)
|
|
81547
81575
|
continue;
|
|
81548
|
-
const agentType = JSON.parse(
|
|
81576
|
+
const agentType = JSON.parse(readFileSync27(meta, "utf8")).agentType;
|
|
81549
81577
|
const transcript = meta.replace(/\.meta\.json$/, ".jsonl");
|
|
81550
81578
|
if (typeof agentType !== "string" || !existsSync26(transcript))
|
|
81551
81579
|
continue;
|
|
@@ -81686,8 +81714,8 @@ var success2 = (data) => ({ ok: true, data }), failure3 = (code, error, unblock)
|
|
|
81686
81714
|
|
|
81687
81715
|
// packages/workit-core/src/git/ops.ts
|
|
81688
81716
|
import { spawnSync as spawnSync22 } from "node:child_process";
|
|
81689
|
-
import { copyFileSync as copyFileSync8, existsSync as existsSync27, readdirSync as readdirSync14, readFileSync as
|
|
81690
|
-
import
|
|
81717
|
+
import { copyFileSync as copyFileSync8, existsSync as existsSync27, readdirSync as readdirSync14, readFileSync as readFileSync28, rmSync as rmSync11 } from "node:fs";
|
|
81718
|
+
import path62 from "node:path";
|
|
81691
81719
|
function operationInProgress(cwd) {
|
|
81692
81720
|
const markers = [
|
|
81693
81721
|
["rebase-merge", "rebase"],
|
|
@@ -81700,18 +81728,18 @@ function operationInProgress(cwd) {
|
|
|
81700
81728
|
if (!run.ok)
|
|
81701
81729
|
return null;
|
|
81702
81730
|
const found = run.stdout.split(`
|
|
81703
|
-
`).map((line) =>
|
|
81731
|
+
`).map((line) => path62.resolve(cwd, line.trim()));
|
|
81704
81732
|
const conflicted = () => git5(cwd, ["ls-files", "-u"]).stdout.trim() !== "";
|
|
81705
81733
|
for (const [index, [, operation]] of markers.entries()) {
|
|
81706
81734
|
const marker = found[index];
|
|
81707
81735
|
if (!marker || !existsSync27(marker))
|
|
81708
81736
|
continue;
|
|
81709
|
-
if (index === 1 && existsSync27(
|
|
81737
|
+
if (index === 1 && existsSync27(path62.join(marker, "applying")))
|
|
81710
81738
|
return { operation: "am", commitAllowed: false, branch: null };
|
|
81711
|
-
if (index === 0 && existsSync27(
|
|
81739
|
+
if (index === 0 && existsSync27(path62.join(marker, "amend")) && !conflicted()) {
|
|
81712
81740
|
let headName = "";
|
|
81713
81741
|
try {
|
|
81714
|
-
headName =
|
|
81742
|
+
headName = readFileSync28(path62.join(marker, "head-name"), "utf8").trim();
|
|
81715
81743
|
} catch {}
|
|
81716
81744
|
const branch = headName.startsWith("refs/heads/") ? headName.slice("refs/heads/".length) : null;
|
|
81717
81745
|
return { operation, commitAllowed: branch !== null, branch };
|
|
@@ -81976,13 +82004,13 @@ function sweepPrivateIndexes(dir) {
|
|
|
81976
82004
|
const pid = Number(match[1]);
|
|
81977
82005
|
const stale = Date.now() - Number(match[2]) > PRIVATE_INDEX_TTL_MS || pid !== process.pid && !processAlive(pid);
|
|
81978
82006
|
if (stale)
|
|
81979
|
-
rmSync11(
|
|
82007
|
+
rmSync11(path62.join(dir, name), { force: true });
|
|
81980
82008
|
}
|
|
81981
82009
|
}
|
|
81982
82010
|
function pathCommitIndex(cwd, paths, env) {
|
|
81983
|
-
const where = (name) =>
|
|
82011
|
+
const where = (name) => path62.resolve(cwd, git5(cwd, ["rev-parse", "--git-path", name]).stdout.trim());
|
|
81984
82012
|
const file = where(`workit-commit-${process.pid}-${Date.now()}.index`);
|
|
81985
|
-
sweepPrivateIndexes(
|
|
82013
|
+
sweepPrivateIndexes(path62.dirname(file));
|
|
81986
82014
|
try {
|
|
81987
82015
|
copyFileSync8(where("index"), file);
|
|
81988
82016
|
} catch (error) {
|
|
@@ -82103,7 +82131,7 @@ function gitCommit(cwd, input) {
|
|
|
82103
82131
|
const partial = new Set(keptPartial);
|
|
82104
82132
|
const top = git5(cwd, ["rev-parse", "--show-prefix"]).stdout.trim();
|
|
82105
82133
|
const tracked = new Set(nulList(git5(cwd, ["ls-files", "-z", "--", ...paths]).stdout));
|
|
82106
|
-
const addable = paths.filter((value) => !partial.has(
|
|
82134
|
+
const addable = paths.filter((value) => !partial.has(path62.posix.normalize(`${top}${value.replaceAll("\\", "/")}`)) && (existsSync27(path62.resolve(cwd, value)) || [...tracked].some((file) => file === value || file.startsWith(`${value}/`))));
|
|
82107
82135
|
if (addable.length) {
|
|
82108
82136
|
const added = git5(cwd, [
|
|
82109
82137
|
"add",
|
|
@@ -82678,12 +82706,12 @@ var init_ops = __esm(() => {
|
|
|
82678
82706
|
|
|
82679
82707
|
// packages/workit-core/src/verdict-cover.ts
|
|
82680
82708
|
import fs26 from "node:fs";
|
|
82681
|
-
import
|
|
82709
|
+
import path63 from "node:path";
|
|
82682
82710
|
function chainsAbove(cwd, branch) {
|
|
82683
82711
|
const root = storeRoot(cwd);
|
|
82684
82712
|
if (!root.ok)
|
|
82685
82713
|
return [];
|
|
82686
|
-
const dir =
|
|
82714
|
+
const dir = path63.join(root.value.root, "stacks");
|
|
82687
82715
|
let names = [];
|
|
82688
82716
|
try {
|
|
82689
82717
|
names = fs26.readdirSync(dir).filter((name) => name.endsWith(".json"));
|
|
@@ -82694,7 +82722,7 @@ function chainsAbove(cwd, branch) {
|
|
|
82694
82722
|
for (const name of names.toSorted()) {
|
|
82695
82723
|
let parsed;
|
|
82696
82724
|
try {
|
|
82697
|
-
parsed = JSON.parse(fs26.readFileSync(
|
|
82725
|
+
parsed = JSON.parse(fs26.readFileSync(path63.join(dir, name), "utf8"));
|
|
82698
82726
|
} catch {
|
|
82699
82727
|
continue;
|
|
82700
82728
|
}
|
|
@@ -82850,10 +82878,10 @@ var init_check_evidence = __esm(() => {
|
|
|
82850
82878
|
|
|
82851
82879
|
// packages/workit-core/src/forge/reruns.ts
|
|
82852
82880
|
import fs27 from "node:fs";
|
|
82853
|
-
import
|
|
82881
|
+
import path64 from "node:path";
|
|
82854
82882
|
function rerunLogPath(cwd) {
|
|
82855
82883
|
const common = gitCommonDir(cwd);
|
|
82856
|
-
return common ?
|
|
82884
|
+
return common ? path64.join(common, "workit", "ci-reruns.jsonl") : null;
|
|
82857
82885
|
}
|
|
82858
82886
|
function rerunCounts(cwd, key) {
|
|
82859
82887
|
const counts = new Map;
|
|
@@ -82888,7 +82916,7 @@ function recordReruns(cwd, rows) {
|
|
|
82888
82916
|
if (!file)
|
|
82889
82917
|
return false;
|
|
82890
82918
|
try {
|
|
82891
|
-
fs27.mkdirSync(
|
|
82919
|
+
fs27.mkdirSync(path64.dirname(file), { recursive: true });
|
|
82892
82920
|
fs27.appendFileSync(file, rows.map((row) => `${JSON.stringify(row)}
|
|
82893
82921
|
`).join(""));
|
|
82894
82922
|
return true;
|
|
@@ -82901,7 +82929,7 @@ function withRerunLock(cwd, fn) {
|
|
|
82901
82929
|
if (!file)
|
|
82902
82930
|
return fn();
|
|
82903
82931
|
const lock = `${file.slice(0, -".jsonl".length)}.lock`;
|
|
82904
|
-
fs27.mkdirSync(
|
|
82932
|
+
fs27.mkdirSync(path64.dirname(lock), { recursive: true });
|
|
82905
82933
|
const until = Date.now() + LOCK_WAIT_MS2;
|
|
82906
82934
|
for (;; ) {
|
|
82907
82935
|
try {
|
|
@@ -83898,7 +83926,7 @@ var init_pr_ops = __esm(() => {
|
|
|
83898
83926
|
import { spawnSync as spawnSync24 } from "node:child_process";
|
|
83899
83927
|
import { createHash as createHash18, randomBytes as randomBytes4 } from "node:crypto";
|
|
83900
83928
|
import fs28 from "node:fs";
|
|
83901
|
-
import
|
|
83929
|
+
import path65 from "node:path";
|
|
83902
83930
|
function worktreeOf(cwd, branch) {
|
|
83903
83931
|
const list = gitRun3(cwd, ["worktree", "list", "--porcelain"]);
|
|
83904
83932
|
if (!list.ok)
|
|
@@ -83947,7 +83975,7 @@ function gitRestack(cwd, input) {
|
|
|
83947
83975
|
error: "no store root"
|
|
83948
83976
|
};
|
|
83949
83977
|
fs28.mkdirSync(scratch, { recursive: true });
|
|
83950
|
-
dir =
|
|
83978
|
+
dir = path65.join(scratch, `${input.branch.replace(/[^A-Za-z0-9._-]+/gu, "_").slice(0, 40)}-${randomBytes4(4).toString("hex")}`);
|
|
83951
83979
|
const added = gitRun3(cwd, ["worktree", "add", "-q", dir, input.branch], GIT_TIMEOUTS.worktree);
|
|
83952
83980
|
if (!added.ok)
|
|
83953
83981
|
return {
|
|
@@ -84003,7 +84031,7 @@ function pruneScratch(cwd) {
|
|
|
84003
84031
|
if (!scratch || !fs28.existsSync(scratch))
|
|
84004
84032
|
return;
|
|
84005
84033
|
for (const name of fs28.readdirSync(scratch)) {
|
|
84006
|
-
const dir =
|
|
84034
|
+
const dir = path65.join(scratch, name);
|
|
84007
84035
|
if (!rebaseInProgress(dir) && !trackedDirt(dir))
|
|
84008
84036
|
gitRun3(cwd, ["worktree", "remove", "--force", dir]);
|
|
84009
84037
|
}
|
|
@@ -84013,7 +84041,7 @@ function stacksDir(cwd) {
|
|
|
84013
84041
|
const root = storeRoot(cwd);
|
|
84014
84042
|
if (!root.ok)
|
|
84015
84043
|
return stackFail(root.code, root.error, root.unblock);
|
|
84016
|
-
return { ok: true, data:
|
|
84044
|
+
return { ok: true, data: path65.join(root.value.root, "stacks") };
|
|
84017
84045
|
}
|
|
84018
84046
|
function parseStack(raw) {
|
|
84019
84047
|
if (!isRecord12(raw) || !Array.isArray(raw.branches))
|
|
@@ -84065,7 +84093,7 @@ function readStack(cwd, name) {
|
|
|
84065
84093
|
const dir = stacksDir(cwd);
|
|
84066
84094
|
if (!dir.ok)
|
|
84067
84095
|
return dir;
|
|
84068
|
-
const file =
|
|
84096
|
+
const file = path65.join(dir.data, fileFor(name));
|
|
84069
84097
|
let text;
|
|
84070
84098
|
try {
|
|
84071
84099
|
text = fs28.readFileSync(file, "utf8");
|
|
@@ -84086,7 +84114,7 @@ function writeStack(cwd, stack, now = new Date) {
|
|
|
84086
84114
|
const dir = stacksDir(cwd);
|
|
84087
84115
|
if (!dir.ok)
|
|
84088
84116
|
return dir;
|
|
84089
|
-
const file =
|
|
84117
|
+
const file = path65.join(dir.data, fileFor(stack.name));
|
|
84090
84118
|
const temp = `${file}.${process.pid}.tmp`;
|
|
84091
84119
|
try {
|
|
84092
84120
|
fs28.mkdirSync(dir.data, { recursive: true });
|
|
@@ -84114,7 +84142,7 @@ function listStacks(cwd) {
|
|
|
84114
84142
|
for (const name of names) {
|
|
84115
84143
|
let parsed = null;
|
|
84116
84144
|
try {
|
|
84117
|
-
parsed = parseStack(JSON.parse(fs28.readFileSync(
|
|
84145
|
+
parsed = parseStack(JSON.parse(fs28.readFileSync(path65.join(dir.data, name), "utf8")));
|
|
84118
84146
|
} catch {
|
|
84119
84147
|
parsed = null;
|
|
84120
84148
|
}
|
|
@@ -84176,7 +84204,7 @@ function takeLock(lock) {
|
|
|
84176
84204
|
host: localLockHost(),
|
|
84177
84205
|
nonce: randomBytes4(8).toString("hex")
|
|
84178
84206
|
};
|
|
84179
|
-
fs28.writeFileSync(
|
|
84207
|
+
fs28.writeFileSync(path65.join(lock, OWNER), JSON.stringify(owner));
|
|
84180
84208
|
return owner;
|
|
84181
84209
|
}
|
|
84182
84210
|
function reapLock(lock, observed) {
|
|
@@ -84213,7 +84241,7 @@ async function withStackLock(cwd, name, fn, waitMs = LOCK_WAIT_MS3) {
|
|
|
84213
84241
|
return dir;
|
|
84214
84242
|
if (!validName(name))
|
|
84215
84243
|
return stackFail("invalid_input", "a stack name must be 1-200 printable characters");
|
|
84216
|
-
const lock =
|
|
84244
|
+
const lock = path65.join(dir.data, `${fileFor(name)}.lock`);
|
|
84217
84245
|
try {
|
|
84218
84246
|
fs28.mkdirSync(dir.data, { recursive: true });
|
|
84219
84247
|
} catch (error) {
|
|
@@ -84243,7 +84271,7 @@ async function withStackLock(cwd, name, fn, waitMs = LOCK_WAIT_MS3) {
|
|
|
84243
84271
|
const touch = () => {
|
|
84244
84272
|
try {
|
|
84245
84273
|
const now = new Date;
|
|
84246
|
-
fs28.utimesSync(
|
|
84274
|
+
fs28.utimesSync(path65.join(lock, OWNER), now, now);
|
|
84247
84275
|
} catch {}
|
|
84248
84276
|
};
|
|
84249
84277
|
const beat = setInterval(touch, HEARTBEAT_MS);
|
|
@@ -85215,7 +85243,7 @@ var STACK_VERSION = 1, stackFail = (code, error, unblock, data) => ({
|
|
|
85215
85243
|
return !status.ok || status.stdout.trim() !== "";
|
|
85216
85244
|
}, scratchDir = (cwd) => {
|
|
85217
85245
|
const dir = stacksDir(cwd);
|
|
85218
|
-
return dir.ok ?
|
|
85246
|
+
return dir.ok ? path65.join(dir.data, "worktrees") : null;
|
|
85219
85247
|
}, firstLine = (run) => (`${run.stderr}
|
|
85220
85248
|
${run.stdout}`.split(`
|
|
85221
85249
|
`).find((line) => line.trim()) ?? "git failed").trim().slice(0, 300), stackFileName = (name) => `${name.replace(/[^A-Za-z0-9._-]+/gu, "_").replace(/^[._]+/u, "").slice(0, 48).toLowerCase()}-${createHash18("sha256").update(name).digest("hex").slice(0, 12)}.json`, fileFor, validName = (name) => {
|
|
@@ -85230,12 +85258,12 @@ ${run.stdout}`.split(`
|
|
|
85230
85258
|
}, isRecord12 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), str3 = (value) => typeof value === "string" && value ? value : null, LOCK_WAIT_MS3 = 2000, HEARTBEAT_MS = 20000, HEARTBEAT_STALE_MS, OWNERLESS_STALE_MS = 30000, OWNER = "owner", readOwner = (lock) => {
|
|
85231
85259
|
let raw = null;
|
|
85232
85260
|
try {
|
|
85233
|
-
raw = fs28.readFileSync(
|
|
85261
|
+
raw = fs28.readFileSync(path65.join(lock, OWNER), "utf8");
|
|
85234
85262
|
} catch {
|
|
85235
85263
|
raw = null;
|
|
85236
85264
|
}
|
|
85237
85265
|
let age = null;
|
|
85238
|
-
for (const target of [
|
|
85266
|
+
for (const target of [path65.join(lock, OWNER), lock])
|
|
85239
85267
|
try {
|
|
85240
85268
|
age = Date.now() - fs28.statSync(target).mtimeMs;
|
|
85241
85269
|
break;
|
|
@@ -85280,7 +85308,7 @@ var init_stack = __esm(() => {
|
|
|
85280
85308
|
import { spawnSync as spawnSync25 } from "node:child_process";
|
|
85281
85309
|
import { createHash as createHash19 } from "node:crypto";
|
|
85282
85310
|
import fs29 from "node:fs";
|
|
85283
|
-
import
|
|
85311
|
+
import path66 from "node:path";
|
|
85284
85312
|
function expandBraces2(pattern, limit = 64) {
|
|
85285
85313
|
for (let index = 0;index < pattern.length; index += 1) {
|
|
85286
85314
|
if (pattern[index] === "\\") {
|
|
@@ -85526,7 +85554,7 @@ function parsePlan(raw, defaults, name) {
|
|
|
85526
85554
|
id,
|
|
85527
85555
|
branch,
|
|
85528
85556
|
base: optional("base") ?? "",
|
|
85529
|
-
worktree:
|
|
85557
|
+
worktree: path66.resolve(defaults.root, optional("worktree") ?? path66.join(defaults.worktreeRoot, id)),
|
|
85530
85558
|
tier,
|
|
85531
85559
|
reason,
|
|
85532
85560
|
dependsOn: [...new Set(dependsOn ?? [])],
|
|
@@ -85655,12 +85683,12 @@ function regeneratedFiles(root, tracked) {
|
|
|
85655
85683
|
const found = new Map;
|
|
85656
85684
|
let scripts;
|
|
85657
85685
|
try {
|
|
85658
|
-
const manifest = JSON.parse(fs29.readFileSync(
|
|
85686
|
+
const manifest = JSON.parse(fs29.readFileSync(path66.join(root, "package.json"), "utf8"));
|
|
85659
85687
|
scripts = manifest.scripts ?? {};
|
|
85660
85688
|
} catch {
|
|
85661
85689
|
return found;
|
|
85662
85690
|
}
|
|
85663
|
-
const runner = fs29.existsSync(
|
|
85691
|
+
const runner = fs29.existsSync(path66.join(root, "bun.lock")) ? "bun run" : fs29.existsSync(path66.join(root, "pnpm-lock.yaml")) ? "pnpm run" : fs29.existsSync(path66.join(root, "yarn.lock")) ? "yarn run" : "npm run";
|
|
85664
85692
|
const outputs = tracked.filter((file) => !CODE.test(file));
|
|
85665
85693
|
for (const [name, command] of Object.entries(scripts)) {
|
|
85666
85694
|
if (!name.startsWith("write:") || typeof command !== "string")
|
|
@@ -85668,7 +85696,7 @@ function regeneratedFiles(root, tracked) {
|
|
|
85668
85696
|
for (const file of command.match(/[\w./-]+\.[cm]?[jt]s\b/gu) ?? []) {
|
|
85669
85697
|
let source;
|
|
85670
85698
|
try {
|
|
85671
|
-
source = fs29.readFileSync(
|
|
85699
|
+
source = fs29.readFileSync(path66.join(root, file), "utf8");
|
|
85672
85700
|
} catch {
|
|
85673
85701
|
continue;
|
|
85674
85702
|
}
|
|
@@ -85790,11 +85818,11 @@ function defaultTrunk(cwd) {
|
|
|
85790
85818
|
}
|
|
85791
85819
|
function mainCheckout(cwd) {
|
|
85792
85820
|
const common = gitCommonDir(cwd);
|
|
85793
|
-
return common &&
|
|
85821
|
+
return common && path66.basename(common) === ".git" ? path66.dirname(common) : path66.resolve(cwd);
|
|
85794
85822
|
}
|
|
85795
85823
|
function worktreeRoot(cwd) {
|
|
85796
85824
|
const main = mainCheckout(cwd);
|
|
85797
|
-
return
|
|
85825
|
+
return path66.join(path66.dirname(main), `${path66.basename(main)}-wt`);
|
|
85798
85826
|
}
|
|
85799
85827
|
function sliceHash(slice) {
|
|
85800
85828
|
const {
|
|
@@ -85814,7 +85842,7 @@ function fanoutsDir(cwd) {
|
|
|
85814
85842
|
const root = storeRoot(cwd);
|
|
85815
85843
|
if (!root.ok)
|
|
85816
85844
|
return fanoutFail(root.code, root.error, root.unblock);
|
|
85817
|
-
return { ok: true, data:
|
|
85845
|
+
return { ok: true, data: path66.join(root.value.root, "fanouts") };
|
|
85818
85846
|
}
|
|
85819
85847
|
function parseStored(raw) {
|
|
85820
85848
|
if (!isRecord13(raw) || typeof raw.name !== "string" || typeof raw.trunk !== "string")
|
|
@@ -85882,7 +85910,7 @@ function readFanout(cwd, name) {
|
|
|
85882
85910
|
const dir = fanoutsDir(cwd);
|
|
85883
85911
|
if (!dir.ok)
|
|
85884
85912
|
return dir;
|
|
85885
|
-
const file =
|
|
85913
|
+
const file = path66.join(dir.data, stackFileName(name));
|
|
85886
85914
|
let parsed = null;
|
|
85887
85915
|
try {
|
|
85888
85916
|
parsed = parseStored(JSON.parse(fs29.readFileSync(file, "utf8")));
|
|
@@ -85907,7 +85935,7 @@ function listFanouts(cwd) {
|
|
|
85907
85935
|
for (const entry of names) {
|
|
85908
85936
|
let parsed = null;
|
|
85909
85937
|
try {
|
|
85910
|
-
parsed = parseStored(JSON.parse(fs29.readFileSync(
|
|
85938
|
+
parsed = parseStored(JSON.parse(fs29.readFileSync(path66.join(dir.data, entry), "utf8")));
|
|
85911
85939
|
} catch {
|
|
85912
85940
|
parsed = null;
|
|
85913
85941
|
}
|
|
@@ -85946,7 +85974,7 @@ function writeFanout(cwd, plan) {
|
|
|
85946
85974
|
const dir = fanoutsDir(cwd);
|
|
85947
85975
|
if (!dir.ok)
|
|
85948
85976
|
return dir;
|
|
85949
|
-
const file =
|
|
85977
|
+
const file = path66.join(dir.data, stackFileName(plan.name));
|
|
85950
85978
|
const temp = `${file}.${process.pid}.tmp`;
|
|
85951
85979
|
try {
|
|
85952
85980
|
fs29.mkdirSync(dir.data, { recursive: true });
|
|
@@ -86157,13 +86185,13 @@ var init_fanout = __esm(() => {
|
|
|
86157
86185
|
// packages/workit-core/src/forge/exec.ts
|
|
86158
86186
|
import { spawnSync as spawnSync26 } from "node:child_process";
|
|
86159
86187
|
import fs30 from "node:fs";
|
|
86160
|
-
import
|
|
86188
|
+
import path67 from "node:path";
|
|
86161
86189
|
function findExecutable(bin, env) {
|
|
86162
|
-
const dirs = (env.PATH ?? env.Path ?? "").split(
|
|
86190
|
+
const dirs = (env.PATH ?? env.Path ?? "").split(path67.delimiter).filter(Boolean);
|
|
86163
86191
|
const exts = process.platform === "win32" ? [".exe"] : [""];
|
|
86164
86192
|
for (const dir of dirs)
|
|
86165
86193
|
for (const ext of exts) {
|
|
86166
|
-
const candidate =
|
|
86194
|
+
const candidate = path67.join(dir, `${bin}${ext}`);
|
|
86167
86195
|
try {
|
|
86168
86196
|
const stat = fs30.statSync(candidate);
|
|
86169
86197
|
if (stat.isFile())
|
|
@@ -87953,7 +87981,7 @@ var init_live_session = __esm(() => {
|
|
|
87953
87981
|
});
|
|
87954
87982
|
|
|
87955
87983
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
87956
|
-
import
|
|
87984
|
+
import path68 from "node:path";
|
|
87957
87985
|
var CASE_INSENSITIVE, PREFIXES2, SCRIPT_SHELLS, cache3, MUTATING_GIT, DRY_N, MUTATING_WORKIT_GIT, CD2, PUSHD2, POPD2, UNKNOWN_DIR;
|
|
87958
87986
|
var init_write_gate = __esm(() => {
|
|
87959
87987
|
init_task_store();
|
|
@@ -87993,7 +88021,7 @@ var init_write_gate = __esm(() => {
|
|
|
87993
88021
|
CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
|
|
87994
88022
|
PUSHD2 = new Set(["pushd", "push-location"]);
|
|
87995
88023
|
POPD2 = new Set(["popd", "pop-location"]);
|
|
87996
|
-
UNKNOWN_DIR =
|
|
88024
|
+
UNKNOWN_DIR = path68.resolve(path68.parse(process.cwd()).root, ".workit-unknown-dir");
|
|
87997
88025
|
});
|
|
87998
88026
|
|
|
87999
88027
|
// packages/workit-core/src/hooks/worktree-confine.ts
|
|
@@ -88018,20 +88046,20 @@ var init_worktree_confine = __esm(() => {
|
|
|
88018
88046
|
|
|
88019
88047
|
// packages/workit-core/src/worktree-deps.ts
|
|
88020
88048
|
import fs31 from "node:fs";
|
|
88021
|
-
import
|
|
88049
|
+
import path69 from "node:path";
|
|
88022
88050
|
function moduleDirs(main) {
|
|
88023
88051
|
const out = [];
|
|
88024
88052
|
const walk = (relative, depth) => {
|
|
88025
88053
|
let entries;
|
|
88026
88054
|
try {
|
|
88027
|
-
entries = fs31.readdirSync(
|
|
88055
|
+
entries = fs31.readdirSync(path69.join(main, relative), { withFileTypes: true });
|
|
88028
88056
|
} catch {
|
|
88029
88057
|
return;
|
|
88030
88058
|
}
|
|
88031
88059
|
for (const entry of entries) {
|
|
88032
88060
|
if (!entry.isDirectory())
|
|
88033
88061
|
continue;
|
|
88034
|
-
const child =
|
|
88062
|
+
const child = path69.join(relative, entry.name);
|
|
88035
88063
|
if (entry.name === MODULES)
|
|
88036
88064
|
out.push(child);
|
|
88037
88065
|
else if (depth < MAX_DEPTH2 && !entry.name.startsWith("."))
|
|
@@ -88045,8 +88073,8 @@ function linkEntry(main, worktree, source, target) {
|
|
|
88045
88073
|
const stat = fs31.lstatSync(source);
|
|
88046
88074
|
if (stat.isSymbolicLink()) {
|
|
88047
88075
|
const link = fs31.readlinkSync(source);
|
|
88048
|
-
const outside =
|
|
88049
|
-
const to = outside ?
|
|
88076
|
+
const outside = path69.isAbsolute(link) && within(link, main) && !path69.relative(main, link).split(path69.sep).includes(MODULES);
|
|
88077
|
+
const to = outside ? path69.join(worktree, path69.relative(main, link)) : link;
|
|
88050
88078
|
fs31.symlinkSync(to, target, process.platform === "win32" ? "junction" : undefined);
|
|
88051
88079
|
return;
|
|
88052
88080
|
}
|
|
@@ -88056,8 +88084,8 @@ function mirror(main, worktree, source, target, top) {
|
|
|
88056
88084
|
fs31.mkdirSync(target);
|
|
88057
88085
|
let count = 0;
|
|
88058
88086
|
for (const entry of fs31.readdirSync(source, { withFileTypes: true })) {
|
|
88059
|
-
const from =
|
|
88060
|
-
const to =
|
|
88087
|
+
const from = path69.join(source, entry.name);
|
|
88088
|
+
const to = path69.join(target, entry.name);
|
|
88061
88089
|
if (top && entry.isDirectory() && (entry.name.startsWith("@") || entry.name === ".bin"))
|
|
88062
88090
|
count += mirror(main, worktree, from, to, false);
|
|
88063
88091
|
else {
|
|
@@ -88073,16 +88101,16 @@ function linkWorktreeDependencies(main, worktree) {
|
|
|
88073
88101
|
const dirs = [];
|
|
88074
88102
|
let entries = 0;
|
|
88075
88103
|
for (const relative of moduleDirs(main)) {
|
|
88076
|
-
const target =
|
|
88077
|
-
if (!fs31.existsSync(
|
|
88104
|
+
const target = path69.join(worktree, relative);
|
|
88105
|
+
if (!fs31.existsSync(path69.dirname(target)) || fs31.existsSync(target))
|
|
88078
88106
|
continue;
|
|
88079
|
-
if (!gitRun4(worktree, ["check-ignore", "-q", `${relative.split(
|
|
88080
|
-
notes.push(`${relative.split(
|
|
88107
|
+
if (!gitRun4(worktree, ["check-ignore", "-q", `${relative.split(path69.sep).join("/")}/`]).ok) {
|
|
88108
|
+
notes.push(`${relative.split(path69.sep).join("/")} is not ignored by git, so it was not linked from ${main}; install dependencies in the worktree yourself`);
|
|
88081
88109
|
continue;
|
|
88082
88110
|
}
|
|
88083
88111
|
try {
|
|
88084
|
-
entries += mirror(main, worktree,
|
|
88085
|
-
dirs.push(relative.split(
|
|
88112
|
+
entries += mirror(main, worktree, path69.join(main, relative), target, true);
|
|
88113
|
+
dirs.push(relative.split(path69.sep).join("/"));
|
|
88086
88114
|
} catch (error) {
|
|
88087
88115
|
fs31.rmSync(target, { recursive: true, force: true });
|
|
88088
88116
|
notes.push(`could not link ${relative} from ${main} (${error.message}); install dependencies in the worktree yourself`);
|
|
@@ -88095,8 +88123,8 @@ function linkWorktreeDependencies(main, worktree) {
|
|
|
88095
88123
|
return { linked: { from: main, dirs, entries, ms }, notes };
|
|
88096
88124
|
}
|
|
88097
88125
|
var MODULES = "node_modules", MAX_DEPTH2 = 2, within = (child, parent) => {
|
|
88098
|
-
const relative =
|
|
88099
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
88126
|
+
const relative = path69.relative(parent, child);
|
|
88127
|
+
return relative === "" || !relative.startsWith("..") && !path69.isAbsolute(relative);
|
|
88100
88128
|
};
|
|
88101
88129
|
var init_worktree_deps = __esm(() => {
|
|
88102
88130
|
init_fanout();
|
|
@@ -88105,7 +88133,7 @@ var init_worktree_deps = __esm(() => {
|
|
|
88105
88133
|
// packages/workit-core/src/fanout-worktree.ts
|
|
88106
88134
|
import { randomBytes as randomBytes5 } from "node:crypto";
|
|
88107
88135
|
import fs32 from "node:fs";
|
|
88108
|
-
import
|
|
88136
|
+
import path70 from "node:path";
|
|
88109
88137
|
function rowSample(lines) {
|
|
88110
88138
|
const out = [];
|
|
88111
88139
|
let bytes = 0;
|
|
@@ -88165,7 +88193,7 @@ function adminDir(worktree) {
|
|
|
88165
88193
|
const file = dir.stdout.trim();
|
|
88166
88194
|
let token = null;
|
|
88167
88195
|
try {
|
|
88168
|
-
token = fs32.readFileSync(
|
|
88196
|
+
token = fs32.readFileSync(path70.join(file, FANOUT_TOKEN_FILE), "utf8").trim() || null;
|
|
88169
88197
|
} catch {
|
|
88170
88198
|
token = null;
|
|
88171
88199
|
}
|
|
@@ -88173,7 +88201,7 @@ function adminDir(worktree) {
|
|
|
88173
88201
|
const stat = worktreeDeps.stat(file);
|
|
88174
88202
|
return {
|
|
88175
88203
|
path: file,
|
|
88176
|
-
id:
|
|
88204
|
+
id: path70.basename(file),
|
|
88177
88205
|
ino: stat.ino.toString(),
|
|
88178
88206
|
token,
|
|
88179
88207
|
birthMs: stat.birthtimeNs > 0n ? Number(stat.birthtimeMs) : null,
|
|
@@ -88189,7 +88217,7 @@ function markAdminDir(worktree) {
|
|
|
88189
88217
|
return null;
|
|
88190
88218
|
const token = randomBytes5(16).toString("hex");
|
|
88191
88219
|
try {
|
|
88192
|
-
fs32.writeFileSync(
|
|
88220
|
+
fs32.writeFileSync(path70.join(admin.path, FANOUT_TOKEN_FILE), `${token}
|
|
88193
88221
|
`);
|
|
88194
88222
|
} catch {
|
|
88195
88223
|
return null;
|
|
@@ -88204,7 +88232,7 @@ function excludeScratch(cwd) {
|
|
|
88204
88232
|
const common = gitCommonDir(cwd);
|
|
88205
88233
|
if (!common)
|
|
88206
88234
|
return;
|
|
88207
|
-
const file =
|
|
88235
|
+
const file = path70.join(common, "info", "exclude");
|
|
88208
88236
|
let text = "";
|
|
88209
88237
|
try {
|
|
88210
88238
|
text = fs32.readFileSync(file, "utf8");
|
|
@@ -88213,7 +88241,7 @@ function excludeScratch(cwd) {
|
|
|
88213
88241
|
}
|
|
88214
88242
|
if (text.split(/\r?\n/u).includes(EXCLUDE_LINE))
|
|
88215
88243
|
return;
|
|
88216
|
-
fs32.mkdirSync(
|
|
88244
|
+
fs32.mkdirSync(path70.dirname(file), { recursive: true });
|
|
88217
88245
|
fs32.appendFileSync(file, `${text && !text.endsWith(`
|
|
88218
88246
|
`) ? `
|
|
88219
88247
|
` : ""}# workit fanout: per-worker scratch dirs
|
|
@@ -88222,13 +88250,13 @@ ${EXCLUDE_LINE}
|
|
|
88222
88250
|
}
|
|
88223
88251
|
function worktreeDependencies(main, worktree) {
|
|
88224
88252
|
for (const [name, install] of LOCKFILES2) {
|
|
88225
|
-
const ours = readBytes(
|
|
88226
|
-
const theirs = readBytes(
|
|
88253
|
+
const ours = readBytes(path70.join(main, name));
|
|
88254
|
+
const theirs = readBytes(path70.join(worktree, name));
|
|
88227
88255
|
if (ours === null && theirs === null)
|
|
88228
88256
|
continue;
|
|
88229
88257
|
if (ours !== null && theirs !== null && ours.equals(theirs))
|
|
88230
88258
|
continue;
|
|
88231
|
-
if (fs32.existsSync(
|
|
88259
|
+
if (fs32.existsSync(path70.join(worktree, "node_modules")))
|
|
88232
88260
|
break;
|
|
88233
88261
|
const command = install(worktree);
|
|
88234
88262
|
return {
|
|
@@ -88240,7 +88268,7 @@ function worktreeDependencies(main, worktree) {
|
|
|
88240
88268
|
};
|
|
88241
88269
|
}
|
|
88242
88270
|
const stale = staleBunInstall(main);
|
|
88243
|
-
if (stale && !fs32.existsSync(
|
|
88271
|
+
if (stale && !fs32.existsSync(path70.join(worktree, "node_modules"))) {
|
|
88244
88272
|
const command = `bun install --frozen-lockfile --cwd ${worktree}`;
|
|
88245
88273
|
return {
|
|
88246
88274
|
linked: null,
|
|
@@ -88253,9 +88281,9 @@ function worktreeDependencies(main, worktree) {
|
|
|
88253
88281
|
return { ...linkWorktreeDependencies(main, worktree), install: null };
|
|
88254
88282
|
}
|
|
88255
88283
|
function staleBunInstall(main) {
|
|
88256
|
-
if (!fs32.existsSync(
|
|
88284
|
+
if (!fs32.existsSync(path70.join(main, "node_modules")))
|
|
88257
88285
|
return null;
|
|
88258
|
-
const text = readBytes(
|
|
88286
|
+
const text = readBytes(path70.join(main, "bun.lock"))?.toString("utf8");
|
|
88259
88287
|
if (!text)
|
|
88260
88288
|
return null;
|
|
88261
88289
|
let packages;
|
|
@@ -88282,7 +88310,7 @@ function staleBunInstall(main) {
|
|
|
88282
88310
|
const version = spec.slice(at + 1);
|
|
88283
88311
|
if (name !== key || version.includes(":"))
|
|
88284
88312
|
continue;
|
|
88285
|
-
const manifest = readBytes(
|
|
88313
|
+
const manifest = readBytes(path70.join(main, "node_modules", key, "package.json"));
|
|
88286
88314
|
if (!manifest) {
|
|
88287
88315
|
problems.push(`${key} missing`);
|
|
88288
88316
|
continue;
|
|
@@ -88299,7 +88327,7 @@ function staleBunInstall(main) {
|
|
|
88299
88327
|
return problems.length ? problems.join("; ") : null;
|
|
88300
88328
|
}
|
|
88301
88329
|
function ensureScratch(worktree) {
|
|
88302
|
-
const scratch =
|
|
88330
|
+
const scratch = path70.join(worktree, SCRATCH_DIR);
|
|
88303
88331
|
fs32.mkdirSync(scratch, { recursive: true });
|
|
88304
88332
|
return scratch;
|
|
88305
88333
|
}
|
|
@@ -88573,7 +88601,7 @@ function unpushedCount(cwd, branch) {
|
|
|
88573
88601
|
return count.ok ? Number(count.stdout.trim()) : null;
|
|
88574
88602
|
}
|
|
88575
88603
|
function removeScratch(worktree) {
|
|
88576
|
-
const scratch =
|
|
88604
|
+
const scratch = path70.join(worktree, SCRATCH_DIR);
|
|
88577
88605
|
let stat;
|
|
88578
88606
|
try {
|
|
88579
88607
|
stat = fs32.lstatSync(scratch);
|
|
@@ -88589,16 +88617,16 @@ var SLOW, SCRATCH_DIR = ".workit-scratch", EXCLUDE_LINE, DIRTY_ROW_BYTES = 2000,
|
|
|
88589
88617
|
try {
|
|
88590
88618
|
return fs32.realpathSync.native(target);
|
|
88591
88619
|
} catch {
|
|
88592
|
-
return
|
|
88620
|
+
return path70.resolve(target);
|
|
88593
88621
|
}
|
|
88594
88622
|
}, samePath = (a, b) => {
|
|
88595
88623
|
const left = canonical3(a);
|
|
88596
88624
|
const right = canonical3(b);
|
|
88597
88625
|
return process.platform === "win32" || process.platform === "darwin" ? left.toLowerCase() === right.toLowerCase() : left === right;
|
|
88598
88626
|
}, inside3 = (child, parent) => {
|
|
88599
|
-
const relative =
|
|
88600
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
88601
|
-
}, slicePath = (cwd, slice) =>
|
|
88627
|
+
const relative = path70.relative(canonical3(parent), canonical3(child));
|
|
88628
|
+
return relative === "" || !relative.startsWith("..") && !path70.isAbsolute(relative);
|
|
88629
|
+
}, slicePath = (cwd, slice) => path70.isAbsolute(slice.worktree) ? slice.worktree : path70.resolve(mainCheckout(cwd), slice.worktree), CLOCK_SLACK_MS = 2000, worktreeDeps, LOCKFILES2, readBytes = (file) => {
|
|
88602
88630
|
try {
|
|
88603
88631
|
return fs32.readFileSync(file);
|
|
88604
88632
|
} catch {
|
|
@@ -88630,7 +88658,7 @@ var init_fanout_worktree = __esm(() => {
|
|
|
88630
88658
|
|
|
88631
88659
|
// packages/workit-core/src/forge/merge-cleanup.ts
|
|
88632
88660
|
import fs33 from "node:fs";
|
|
88633
|
-
import
|
|
88661
|
+
import path71 from "node:path";
|
|
88634
88662
|
function cleanupMergedBranch(cwd, branch, mergedHead) {
|
|
88635
88663
|
const out = { branchDeleted: false, worktreeRemoved: null, notes: [] };
|
|
88636
88664
|
if (!branch || branch.startsWith("-"))
|
|
@@ -88690,13 +88718,13 @@ var SLOW2, isFanoutWorktree = (worktree) => {
|
|
|
88690
88718
|
if (!dir.ok)
|
|
88691
88719
|
return false;
|
|
88692
88720
|
try {
|
|
88693
|
-
return fs33.readFileSync(
|
|
88721
|
+
return fs33.readFileSync(path71.join(dir.stdout.trim(), FANOUT_TOKEN_FILE), "utf8").trim() !== "";
|
|
88694
88722
|
} catch {
|
|
88695
88723
|
return false;
|
|
88696
88724
|
}
|
|
88697
88725
|
}, inside4 = (child, parent) => {
|
|
88698
|
-
const relative =
|
|
88699
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
88726
|
+
const relative = path71.relative(fs33.realpathSync.native(parent), fs33.realpathSync.native(child));
|
|
88727
|
+
return relative === "" || !relative.startsWith("..") && !path71.isAbsolute(relative);
|
|
88700
88728
|
};
|
|
88701
88729
|
var init_merge_cleanup = __esm(() => {
|
|
88702
88730
|
init_fanout();
|
|
@@ -88977,7 +89005,7 @@ var init_duration = __esm(() => {
|
|
|
88977
89005
|
});
|
|
88978
89006
|
|
|
88979
89007
|
// packages/workit-cli/src/verbs/forge-common.ts
|
|
88980
|
-
import { readFileSync as
|
|
89008
|
+
import { readFileSync as readFileSync29 } from "node:fs";
|
|
88981
89009
|
function parseFlags(argv, spec) {
|
|
88982
89010
|
const parsed = { values: {}, booleans: new Set, lists: {}, positionals: [] };
|
|
88983
89011
|
for (let index = 0;index < argv.length; index += 1) {
|
|
@@ -89135,7 +89163,7 @@ var init_forge_common = __esm(() => {
|
|
|
89135
89163
|
forgeDeps = {
|
|
89136
89164
|
runner: undefined,
|
|
89137
89165
|
npm: undefined,
|
|
89138
|
-
readStdin: () =>
|
|
89166
|
+
readStdin: () => readFileSync29(0, "utf8"),
|
|
89139
89167
|
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
89140
89168
|
now: () => Date.now()
|
|
89141
89169
|
};
|
|
@@ -89147,8 +89175,8 @@ __export(exports_pr, {
|
|
|
89147
89175
|
checkPrTitle: () => checkPrTitle,
|
|
89148
89176
|
run: () => run15
|
|
89149
89177
|
});
|
|
89150
|
-
import { existsSync as existsSync28, readFileSync as
|
|
89151
|
-
import
|
|
89178
|
+
import { existsSync as existsSync28, readFileSync as readFileSync30 } from "node:fs";
|
|
89179
|
+
import path72 from "node:path";
|
|
89152
89180
|
function titleRules(cwd) {
|
|
89153
89181
|
let root;
|
|
89154
89182
|
try {
|
|
@@ -89159,16 +89187,16 @@ function titleRules(cwd) {
|
|
|
89159
89187
|
let text = null;
|
|
89160
89188
|
let name = "";
|
|
89161
89189
|
for (const candidate of COMMITLINT_FILES) {
|
|
89162
|
-
const full =
|
|
89190
|
+
const full = path72.join(root, candidate);
|
|
89163
89191
|
if (!existsSync28(full))
|
|
89164
89192
|
continue;
|
|
89165
|
-
text =
|
|
89193
|
+
text = readFileSync30(full, "utf8");
|
|
89166
89194
|
name = candidate;
|
|
89167
89195
|
break;
|
|
89168
89196
|
}
|
|
89169
89197
|
if (text === null) {
|
|
89170
89198
|
try {
|
|
89171
|
-
const pkg = JSON.parse(
|
|
89199
|
+
const pkg = JSON.parse(readFileSync30(path72.join(root, "package.json"), "utf8"));
|
|
89172
89200
|
if (pkg.commitlint === undefined)
|
|
89173
89201
|
return { rules: null, note: null };
|
|
89174
89202
|
text = JSON.stringify(pkg.commitlint);
|
|
@@ -89265,7 +89293,7 @@ function refuseTitle(io, title, line) {
|
|
|
89265
89293
|
function readBodyFile(io, file) {
|
|
89266
89294
|
try {
|
|
89267
89295
|
return {
|
|
89268
|
-
body: file === "-" ? forgeDeps.readStdin() :
|
|
89296
|
+
body: file === "-" ? forgeDeps.readStdin() : readFileSync30(path72.resolve(io.cwd, file), "utf8")
|
|
89269
89297
|
};
|
|
89270
89298
|
} catch {
|
|
89271
89299
|
return `cannot read --body-file ${file}`;
|
|
@@ -90195,8 +90223,8 @@ var exports_git = {};
|
|
|
90195
90223
|
__export(exports_git, {
|
|
90196
90224
|
run: () => run17
|
|
90197
90225
|
});
|
|
90198
|
-
import { readFileSync as
|
|
90199
|
-
import
|
|
90226
|
+
import { readFileSync as readFileSync31 } from "node:fs";
|
|
90227
|
+
import path73 from "node:path";
|
|
90200
90228
|
function kindHint(cwd, kind) {
|
|
90201
90229
|
let kinds = [...BRANCH_KINDS];
|
|
90202
90230
|
try {
|
|
@@ -90302,7 +90330,7 @@ function commitMessage(parsed, io) {
|
|
|
90302
90330
|
|
|
90303
90331
|
`);
|
|
90304
90332
|
try {
|
|
90305
|
-
return file === "-" ?
|
|
90333
|
+
return file === "-" ? readFileSync31(0, "utf8") : readFileSync31(path73.resolve(io.cwd, file), "utf8");
|
|
90306
90334
|
} catch (error) {
|
|
90307
90335
|
return {
|
|
90308
90336
|
error: `cannot read -F ${file}: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -90360,7 +90388,7 @@ async function commit(argv, io) {
|
|
|
90360
90388
|
}
|
|
90361
90389
|
function readPatch(file, io) {
|
|
90362
90390
|
try {
|
|
90363
|
-
return file === "-" ?
|
|
90391
|
+
return file === "-" ? readFileSync31(0, "utf8") : readFileSync31(path73.resolve(io.cwd, file), "utf8");
|
|
90364
90392
|
} catch (error) {
|
|
90365
90393
|
return {
|
|
90366
90394
|
error: `cannot read --patch ${file}: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -91837,7 +91865,7 @@ var init_stack2 = __esm(() => {
|
|
|
91837
91865
|
// packages/workit-core/src/fanout-brief.ts
|
|
91838
91866
|
import { createHash as createHash20 } from "node:crypto";
|
|
91839
91867
|
import fs35 from "node:fs";
|
|
91840
|
-
import
|
|
91868
|
+
import path74 from "node:path";
|
|
91841
91869
|
function workerSession(lead, slice, attempt) {
|
|
91842
91870
|
const tail = attempt === null ? "" : `+try${attempt}`;
|
|
91843
91871
|
const full = `${lead}-w-${slice}${tail}`;
|
|
@@ -91920,7 +91948,7 @@ function renderBrief(cwd, plan, input) {
|
|
|
91920
91948
|
"STANDING:",
|
|
91921
91949
|
...standing.length ? standing.map((order) => ` - ${order.what}`) : [" - none recorded beyond this brief"],
|
|
91922
91950
|
exists ? `WORKTREE: ${planned} (made by \`workit fanout worktree create ${slice.id}\`; yours alone)` : `WORKTREE: ${planned} (not made yet: the lead runs \`workit fanout worktree create ${slice.id}\` before spawning, then renders this brief again)`,
|
|
91923
|
-
...exists && typeof made?.install === "string" && !fs35.existsSync(
|
|
91951
|
+
...exists && typeof made?.install === "string" && !fs35.existsSync(path74.join(planned, "node_modules")) ? [`INSTALL: \`${made.install}\` first: the main checkout's node_modules was not linked here`] : [],
|
|
91924
91952
|
...identityLines(identity, minted),
|
|
91925
91953
|
...rules(mode, branch, sliceBase, exists ? planned : null)
|
|
91926
91954
|
];
|
|
@@ -92462,7 +92490,7 @@ __export(exports_fanout, {
|
|
|
92462
92490
|
run: () => run21
|
|
92463
92491
|
});
|
|
92464
92492
|
import fs36 from "node:fs";
|
|
92465
|
-
import
|
|
92493
|
+
import path75 from "node:path";
|
|
92466
92494
|
function forgeFor(io, offline) {
|
|
92467
92495
|
if (offline)
|
|
92468
92496
|
return { forge: null, error: "--offline" };
|
|
@@ -92523,7 +92551,7 @@ function plan2(argv, io) {
|
|
|
92523
92551
|
return usage4(io, "pass --trunk or --track, not both (--track picks the trunk)", PLAN_USAGE2);
|
|
92524
92552
|
if (flags.positionals.length !== 1)
|
|
92525
92553
|
return usage4(io, flags.positionals.length ? `unexpected argument ${flags.positionals[1]}` : "missing <plan.json>", PLAN_USAGE2);
|
|
92526
|
-
const file =
|
|
92554
|
+
const file = path75.resolve(io.cwd, flags.positionals[0]);
|
|
92527
92555
|
let raw;
|
|
92528
92556
|
try {
|
|
92529
92557
|
raw = JSON.parse(fs36.readFileSync(file, "utf8"));
|
|
@@ -108099,7 +108127,7 @@ var init_ast = __esm(() => {
|
|
|
108099
108127
|
|
|
108100
108128
|
// packages/workit-cli/src/test-audit/rules.ts
|
|
108101
108129
|
import { builtinModules } from "node:module";
|
|
108102
|
-
import
|
|
108130
|
+
import path76 from "node:path";
|
|
108103
108131
|
function testCallee(call) {
|
|
108104
108132
|
let callee = call.callee;
|
|
108105
108133
|
if (callee.type === "CallExpression")
|
|
@@ -108592,12 +108620,12 @@ function checkConstantsOnly(ctx, emit) {
|
|
|
108592
108620
|
}
|
|
108593
108621
|
function checkOverMocking(ctx, emit) {
|
|
108594
108622
|
const { program } = ctx.parsed;
|
|
108595
|
-
const unit =
|
|
108623
|
+
const unit = path76.basename(ctx.file).replace(/\.(?:[cm]?[jt]sx?)$/, "").replace(/\.(?:test|spec)$/, "");
|
|
108596
108624
|
const mocked = find2(program, (node) => node.type === "CallExpression" && MODULE_MOCK.test(calleeName(node.callee) ?? "") && node.arguments[0]?.type === "StringLiteral");
|
|
108597
108625
|
const internal = mocked.filter((call) => /^(?:\.|@\/|~\/)/.test(call.arguments[0].value));
|
|
108598
108626
|
for (const call of mocked) {
|
|
108599
108627
|
const spec = call.arguments[0].value;
|
|
108600
|
-
const base =
|
|
108628
|
+
const base = path76.basename(spec.replace(/\/index(?:\.[cm]?[jt]sx?)?$/, "")).replace(/\.(?:[cm]?[jt]sx?)$/, "");
|
|
108601
108629
|
if (base === unit)
|
|
108602
108630
|
emit({
|
|
108603
108631
|
rule: "over-mocking",
|
|
@@ -108986,8 +109014,8 @@ var init_rules = __esm(() => {
|
|
|
108986
109014
|
|
|
108987
109015
|
// packages/workit-cli/src/test-audit/audit.ts
|
|
108988
109016
|
import { spawnSync as spawnSync31 } from "node:child_process";
|
|
108989
|
-
import { existsSync as existsSync29, readdirSync as readdirSync15, readFileSync as
|
|
108990
|
-
import
|
|
109017
|
+
import { existsSync as existsSync29, readdirSync as readdirSync15, readFileSync as readFileSync32, statSync as statSync11 } from "node:fs";
|
|
109018
|
+
import path77 from "node:path";
|
|
108991
109019
|
function git7(cwd, args) {
|
|
108992
109020
|
const run = spawnSync31("git", ["-c", "core.quotepath=off", ...args], {
|
|
108993
109021
|
cwd,
|
|
@@ -109000,7 +109028,7 @@ function walkTests(dir, out) {
|
|
|
109000
109028
|
for (const entry of readdirSync15(dir, { withFileTypes: true })) {
|
|
109001
109029
|
if (entry.name.startsWith(".") && entry.name !== "." && entry.isDirectory())
|
|
109002
109030
|
continue;
|
|
109003
|
-
const full =
|
|
109031
|
+
const full = path77.join(dir, entry.name);
|
|
109004
109032
|
if (entry.isDirectory()) {
|
|
109005
109033
|
if (!SKIP_DIRS.has(entry.name))
|
|
109006
109034
|
walkTests(full, out);
|
|
@@ -109012,7 +109040,7 @@ function expandPaths(cwd, inputs) {
|
|
|
109012
109040
|
const files = [];
|
|
109013
109041
|
const missing = [];
|
|
109014
109042
|
for (const input of inputs.length > 0 ? inputs : ["."]) {
|
|
109015
|
-
const full =
|
|
109043
|
+
const full = path77.resolve(cwd, input);
|
|
109016
109044
|
if (!existsSync29(full))
|
|
109017
109045
|
missing.push(input);
|
|
109018
109046
|
else if (statSync11(full).isDirectory())
|
|
@@ -109049,11 +109077,11 @@ function changedLines(cwd, base) {
|
|
|
109049
109077
|
for (let offset = 0;offset < count; offset += 1)
|
|
109050
109078
|
lines.add(start + offset);
|
|
109051
109079
|
}
|
|
109052
|
-
changed.set(
|
|
109080
|
+
changed.set(path77.join(root, file), lines);
|
|
109053
109081
|
}
|
|
109054
109082
|
const untracked = git7(root, ["ls-files", "--others", "--exclude-standard", "-z"]);
|
|
109055
109083
|
for (const file of untracked.stdout.split("\x00").filter(Boolean))
|
|
109056
|
-
changed.set(
|
|
109084
|
+
changed.set(path77.join(root, file), "all");
|
|
109057
109085
|
return changed;
|
|
109058
109086
|
}
|
|
109059
109087
|
function auditFiles(files, display) {
|
|
@@ -109066,7 +109094,7 @@ function auditFiles(files, display) {
|
|
|
109066
109094
|
const shown = display(file);
|
|
109067
109095
|
let parsed;
|
|
109068
109096
|
try {
|
|
109069
|
-
parsed = parseSource(
|
|
109097
|
+
parsed = parseSource(readFileSync32(file, "utf8"), file);
|
|
109070
109098
|
} catch (error) {
|
|
109071
109099
|
parseErrors.push({
|
|
109072
109100
|
file: shown,
|
|
@@ -109115,7 +109143,7 @@ function auditFiles(files, display) {
|
|
|
109115
109143
|
durationMs: Math.round(performance.now() - started)
|
|
109116
109144
|
};
|
|
109117
109145
|
}
|
|
109118
|
-
var TEST_FILE, CODE_FILE, SKIP_DIRS, toPosix = (file) => file.split(
|
|
109146
|
+
var TEST_FILE, CODE_FILE, SKIP_DIRS, toPosix = (file) => file.split(path77.sep).join("/"), SEVERITY_ORDER, ruleIds;
|
|
109119
109147
|
var init_audit = __esm(() => {
|
|
109120
109148
|
init_ast();
|
|
109121
109149
|
init_rules();
|
|
@@ -109134,9 +109162,9 @@ import {
|
|
|
109134
109162
|
mkdirSync as mkdirSync13,
|
|
109135
109163
|
mkdtempSync as mkdtempSync6,
|
|
109136
109164
|
readdirSync as readdirSync16,
|
|
109137
|
-
readFileSync as
|
|
109165
|
+
readFileSync as readFileSync33,
|
|
109138
109166
|
readlinkSync as readlinkSync3,
|
|
109139
|
-
realpathSync as
|
|
109167
|
+
realpathSync as realpathSync13,
|
|
109140
109168
|
renameSync as renameSync8,
|
|
109141
109169
|
rmSync as rmSync12,
|
|
109142
109170
|
statSync as statSync12,
|
|
@@ -109145,7 +109173,7 @@ import {
|
|
|
109145
109173
|
copyFileSync as copyFileSync9
|
|
109146
109174
|
} from "node:fs";
|
|
109147
109175
|
import os27 from "node:os";
|
|
109148
|
-
import
|
|
109176
|
+
import path78 from "node:path";
|
|
109149
109177
|
function mutantsFor(source, file, lines) {
|
|
109150
109178
|
const parsed = parseSource(source, file);
|
|
109151
109179
|
const out = [];
|
|
@@ -109218,7 +109246,7 @@ function relatedTests(source, testFiles) {
|
|
|
109218
109246
|
for (const match of text.matchAll(SPECIFIER)) {
|
|
109219
109247
|
const spec = match[1];
|
|
109220
109248
|
if (spec.startsWith(".")) {
|
|
109221
|
-
if (stripExt(
|
|
109249
|
+
if (stripExt(path78.posix.join(path78.posix.dirname(file), spec)) === target)
|
|
109222
109250
|
return true;
|
|
109223
109251
|
} else if (spec.includes("/") && stripExt(spec).split("/").slice(-2).join("/") === tail)
|
|
109224
109252
|
return true;
|
|
@@ -109238,12 +109266,12 @@ function removeStaleCopies(tmp = os27.tmpdir()) {
|
|
|
109238
109266
|
for (const name of names) {
|
|
109239
109267
|
if (!name.startsWith(TEMP_PREFIX))
|
|
109240
109268
|
continue;
|
|
109241
|
-
const dir =
|
|
109269
|
+
const dir = path78.join(tmp, name);
|
|
109242
109270
|
try {
|
|
109243
109271
|
const stat = lstatSync10(dir);
|
|
109244
109272
|
if (!stat.isDirectory() || uid !== undefined && stat.uid !== uid)
|
|
109245
109273
|
continue;
|
|
109246
|
-
const pid = Number(
|
|
109274
|
+
const pid = Number(readFileSync33(path78.join(dir, PID_FILE), "utf8"));
|
|
109247
109275
|
if (Number.isInteger(pid) && pid > 0 && alive(pid))
|
|
109248
109276
|
continue;
|
|
109249
109277
|
} catch (error) {
|
|
@@ -109260,8 +109288,8 @@ function removeStaleCopies(tmp = os27.tmpdir()) {
|
|
|
109260
109288
|
function linkNodeModules(origin, target, repo, copy) {
|
|
109261
109289
|
mkdirSync13(target, { recursive: true });
|
|
109262
109290
|
for (const entry of readdirSync16(origin, { withFileTypes: true })) {
|
|
109263
|
-
const from =
|
|
109264
|
-
const to =
|
|
109291
|
+
const from = path78.join(origin, entry.name);
|
|
109292
|
+
const to = path78.join(target, entry.name);
|
|
109265
109293
|
if (entry.name.startsWith("@") && entry.isDirectory()) {
|
|
109266
109294
|
linkNodeModules(from, to, repo, copy);
|
|
109267
109295
|
continue;
|
|
@@ -109273,13 +109301,13 @@ function linkNodeModules(origin, target, repo, copy) {
|
|
|
109273
109301
|
if (entry.isSymbolicLink()) {
|
|
109274
109302
|
let real;
|
|
109275
109303
|
try {
|
|
109276
|
-
real =
|
|
109304
|
+
real = realpathSync13(from);
|
|
109277
109305
|
} catch {
|
|
109278
109306
|
continue;
|
|
109279
109307
|
}
|
|
109280
|
-
const relative =
|
|
109281
|
-
if (!relative.startsWith("..") && !
|
|
109282
|
-
symlinkSync(
|
|
109308
|
+
const relative = path78.relative(repo, real);
|
|
109309
|
+
if (!relative.startsWith("..") && !path78.isAbsolute(relative) && !relative.split(path78.sep).includes("node_modules")) {
|
|
109310
|
+
symlinkSync(path78.join(copy, relative), to, "junction");
|
|
109283
109311
|
continue;
|
|
109284
109312
|
}
|
|
109285
109313
|
}
|
|
@@ -109289,13 +109317,13 @@ function linkNodeModules(origin, target, repo, copy) {
|
|
|
109289
109317
|
function copySymlink(repo, tree, from, to) {
|
|
109290
109318
|
let real = null;
|
|
109291
109319
|
try {
|
|
109292
|
-
real =
|
|
109320
|
+
real = realpathSync13(from);
|
|
109293
109321
|
} catch {
|
|
109294
109322
|
real = null;
|
|
109295
109323
|
}
|
|
109296
|
-
const realRepo =
|
|
109324
|
+
const realRepo = realpathSync13(repo);
|
|
109297
109325
|
if (real && inside5(realRepo, real)) {
|
|
109298
|
-
symlinkSync(
|
|
109326
|
+
symlinkSync(path78.relative(path78.dirname(to), path78.join(tree, path78.relative(realRepo, real))), to);
|
|
109299
109327
|
return;
|
|
109300
109328
|
}
|
|
109301
109329
|
if (real && statSync12(real).isFile())
|
|
@@ -109304,10 +109332,10 @@ function copySymlink(repo, tree, from, to) {
|
|
|
109304
109332
|
symlinkSync(readlinkSync3(from), to);
|
|
109305
109333
|
}
|
|
109306
109334
|
function writeInside(copy, file, content) {
|
|
109307
|
-
const target =
|
|
109335
|
+
const target = path78.join(copy, file);
|
|
109308
109336
|
try {
|
|
109309
109337
|
const stat = lstatSync10(target);
|
|
109310
|
-
if (!stat.isFile() || !inside5(
|
|
109338
|
+
if (!stat.isFile() || !inside5(realpathSync13(copy), realpathSync13(path78.dirname(target))))
|
|
109311
109339
|
return false;
|
|
109312
109340
|
} catch {
|
|
109313
109341
|
return false;
|
|
@@ -109318,9 +109346,9 @@ function writeInside(copy, file, content) {
|
|
|
109318
109346
|
return true;
|
|
109319
109347
|
}
|
|
109320
109348
|
function copyWorkingTree(repo) {
|
|
109321
|
-
const dir = mkdtempSync6(
|
|
109322
|
-
writeFileSync15(
|
|
109323
|
-
const tree =
|
|
109349
|
+
const dir = mkdtempSync6(path78.join(os27.tmpdir(), TEMP_PREFIX));
|
|
109350
|
+
writeFileSync15(path78.join(dir, PID_FILE), String(process.pid));
|
|
109351
|
+
const tree = path78.join(dir, "tree");
|
|
109324
109352
|
const head = git7(repo, ["rev-parse", "--verify", "--quiet", "HEAD"]).stdout.trim();
|
|
109325
109353
|
if (head && git7(dir, ["clone", "-q", "--shared", "--no-checkout", repo, tree]).ok) {
|
|
109326
109354
|
const branch = git7(repo, ["symbolic-ref", "--quiet", "--short", "HEAD"]).stdout.trim();
|
|
@@ -109337,29 +109365,29 @@ function copyWorkingTree(repo) {
|
|
|
109337
109365
|
for (const relative of listed) {
|
|
109338
109366
|
if (!relative)
|
|
109339
109367
|
continue;
|
|
109340
|
-
const from =
|
|
109368
|
+
const from = path78.join(repo, relative);
|
|
109341
109369
|
let stat;
|
|
109342
109370
|
try {
|
|
109343
109371
|
stat = lstatSync10(from);
|
|
109344
109372
|
} catch {
|
|
109345
109373
|
continue;
|
|
109346
109374
|
}
|
|
109347
|
-
const to =
|
|
109348
|
-
mkdirSync13(
|
|
109375
|
+
const to = path78.join(tree, relative);
|
|
109376
|
+
mkdirSync13(path78.dirname(to), { recursive: true });
|
|
109349
109377
|
if (stat.isSymbolicLink())
|
|
109350
109378
|
copySymlink(repo, tree, from, to);
|
|
109351
109379
|
else if (stat.isFile())
|
|
109352
109380
|
copyFileSync9(from, to);
|
|
109353
|
-
let parent =
|
|
109381
|
+
let parent = path78.dirname(relative);
|
|
109354
109382
|
while (parent !== "." && !dirs.has(parent)) {
|
|
109355
109383
|
dirs.add(parent);
|
|
109356
|
-
parent =
|
|
109384
|
+
parent = path78.dirname(parent);
|
|
109357
109385
|
}
|
|
109358
109386
|
}
|
|
109359
109387
|
for (const parent of dirs) {
|
|
109360
|
-
const modules =
|
|
109361
|
-
if (existsSync30(modules) && !existsSync30(
|
|
109362
|
-
linkNodeModules(modules,
|
|
109388
|
+
const modules = path78.join(repo, parent, "node_modules");
|
|
109389
|
+
if (existsSync30(modules) && !existsSync30(path78.join(tree, parent, "node_modules")))
|
|
109390
|
+
linkNodeModules(modules, path78.join(tree, parent, "node_modules"), repo, tree);
|
|
109363
109391
|
}
|
|
109364
109392
|
return { dir, tree };
|
|
109365
109393
|
}
|
|
@@ -109398,20 +109426,20 @@ async function runMutation(options) {
|
|
|
109398
109426
|
const tracked = git7(repo, ["ls-files", "-co", "--exclude-standard", "-z"]).stdout.split("\x00").filter(Boolean);
|
|
109399
109427
|
const testFiles = tracked.filter((file) => TEST_FILE.test(file)).map((file) => {
|
|
109400
109428
|
try {
|
|
109401
|
-
return { file, text:
|
|
109429
|
+
return { file, text: readFileSync33(path78.join(repo, file), "utf8") };
|
|
109402
109430
|
} catch {
|
|
109403
109431
|
return { file, text: "" };
|
|
109404
109432
|
}
|
|
109405
109433
|
});
|
|
109406
109434
|
const candidates = [];
|
|
109407
109435
|
for (const [absolute, lines] of [...options.changed].toSorted(([a], [b]) => a.localeCompare(b))) {
|
|
109408
|
-
const relative = toPosix(
|
|
109436
|
+
const relative = toPosix(path78.relative(repo, absolute));
|
|
109409
109437
|
if (!CODE_FILE.test(relative) || TEST_FILE.test(relative) || relative.endsWith(".d.ts"))
|
|
109410
109438
|
continue;
|
|
109411
109439
|
if (NOT_SOURCE.test(relative) || !existsSync30(absolute))
|
|
109412
109440
|
continue;
|
|
109413
109441
|
try {
|
|
109414
|
-
candidates.push(...mutantsFor(
|
|
109442
|
+
candidates.push(...mutantsFor(readFileSync33(absolute, "utf8"), relative, lines));
|
|
109415
109443
|
} catch {}
|
|
109416
109444
|
}
|
|
109417
109445
|
const mutants = candidates.map((mutant, index) => ({ ...mutant, id: index + 1 }));
|
|
@@ -109419,9 +109447,9 @@ async function runMutation(options) {
|
|
|
109419
109447
|
for (const mutant of mutants)
|
|
109420
109448
|
if (!related.has(mutant.file))
|
|
109421
109449
|
related.set(mutant.file, relatedTests(mutant.file, testFiles));
|
|
109422
|
-
const cwdRelative =
|
|
109450
|
+
const cwdRelative = path78.relative(repo, options.cwd);
|
|
109423
109451
|
const asArg = (file) => {
|
|
109424
|
-
const relative = toPosix(
|
|
109452
|
+
const relative = toPosix(path78.relative(cwdRelative, file));
|
|
109425
109453
|
return shellQuote(relative.startsWith(".") ? relative : `./${relative}`);
|
|
109426
109454
|
};
|
|
109427
109455
|
const commandFor = (tests) => options.command.replaceAll("{files}", () => tests.map(asArg).join(" "));
|
|
@@ -109457,7 +109485,7 @@ async function runMutation(options) {
|
|
|
109457
109485
|
return finish3(options, 0, results, counts, started);
|
|
109458
109486
|
removeStaleCopies();
|
|
109459
109487
|
const { dir: copyDir, tree: copy } = copyWorkingTree(repo);
|
|
109460
|
-
const copyCwd =
|
|
109488
|
+
const copyCwd = path78.join(copy, cwdRelative);
|
|
109461
109489
|
let current = null;
|
|
109462
109490
|
const restore = () => {
|
|
109463
109491
|
if (current)
|
|
@@ -109492,7 +109520,7 @@ async function runMutation(options) {
|
|
|
109492
109520
|
record({ ...mutant, status: "skipped", durationMs: 0, tests, reason: "budget" });
|
|
109493
109521
|
continue;
|
|
109494
109522
|
}
|
|
109495
|
-
const original =
|
|
109523
|
+
const original = readFileSync33(path78.join(copy, mutant.file), "utf8");
|
|
109496
109524
|
const mutated = original.slice(0, mutant.start) + mutant.replacement + original.slice(mutant.end);
|
|
109497
109525
|
current = { file: mutant.file, original };
|
|
109498
109526
|
if (!writeInside(copy, mutant.file, mutated)) {
|
|
@@ -109549,8 +109577,8 @@ var NOT_SOURCE, FLIPS, isStringy = (node) => node.type === "StringLiteral" || no
|
|
|
109549
109577
|
return error.code === "EPERM";
|
|
109550
109578
|
}
|
|
109551
109579
|
}, inside5 = (root, file) => {
|
|
109552
|
-
const relative =
|
|
109553
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
109580
|
+
const relative = path78.relative(root, file);
|
|
109581
|
+
return relative === "" || !relative.startsWith("..") && !path78.isAbsolute(relative);
|
|
109554
109582
|
}, active, killTree = (child) => {
|
|
109555
109583
|
try {
|
|
109556
109584
|
if (child.pid && process.platform !== "win32")
|
|
@@ -109599,7 +109627,7 @@ __export(exports_test_audit, {
|
|
|
109599
109627
|
run: () => run23
|
|
109600
109628
|
});
|
|
109601
109629
|
import { existsSync as existsSync31 } from "node:fs";
|
|
109602
|
-
import
|
|
109630
|
+
import path79 from "node:path";
|
|
109603
109631
|
function parse8(argv) {
|
|
109604
109632
|
const options = {
|
|
109605
109633
|
paths: [],
|
|
@@ -109704,8 +109732,8 @@ async function run23(argv, io) {
|
|
|
109704
109732
|
return emit(io, fail2("invalid_input", `${options}
|
|
109705
109733
|
usage: ${USAGE16}`));
|
|
109706
109734
|
const top = git7(io.cwd, ["rev-parse", "--show-toplevel"]);
|
|
109707
|
-
const repo = top.ok ?
|
|
109708
|
-
const display = (file) => toPosix(
|
|
109735
|
+
const repo = top.ok ? path79.resolve(top.stdout.trim()) : null;
|
|
109736
|
+
const display = (file) => toPosix(path79.relative(io.cwd, file) || file);
|
|
109709
109737
|
let base = null;
|
|
109710
109738
|
let changed = null;
|
|
109711
109739
|
if (options.diff || options.mutate) {
|
|
@@ -109843,8 +109871,8 @@ var exports_youtrack = {};
|
|
|
109843
109871
|
__export(exports_youtrack, {
|
|
109844
109872
|
run: () => run25
|
|
109845
109873
|
});
|
|
109846
|
-
import { readFileSync as
|
|
109847
|
-
import
|
|
109874
|
+
import { readFileSync as readFileSync34 } from "node:fs";
|
|
109875
|
+
import path80 from "node:path";
|
|
109848
109876
|
async function run25(argv, io) {
|
|
109849
109877
|
const [sub, ...rest] = argv;
|
|
109850
109878
|
if (sub !== "note" && sub !== "time" && sub !== "meeting")
|
|
@@ -109890,7 +109918,7 @@ async function run25(argv, io) {
|
|
|
109890
109918
|
let markdown = flags.values.markdown ?? "";
|
|
109891
109919
|
if (flags.values.file)
|
|
109892
109920
|
try {
|
|
109893
|
-
markdown =
|
|
109921
|
+
markdown = readFileSync34(path80.resolve(io.cwd, flags.values.file), "utf8");
|
|
109894
109922
|
} catch (error) {
|
|
109895
109923
|
return usage4(io, `cannot read ${flags.values.file}: ${String(error)}`, USAGE18);
|
|
109896
109924
|
}
|
|
@@ -109961,8 +109989,8 @@ var exports_changelog = {};
|
|
|
109961
109989
|
__export(exports_changelog, {
|
|
109962
109990
|
run: () => run26
|
|
109963
109991
|
});
|
|
109964
|
-
import { readFileSync as
|
|
109965
|
-
import
|
|
109992
|
+
import { readFileSync as readFileSync35 } from "node:fs";
|
|
109993
|
+
import path81 from "node:path";
|
|
109966
109994
|
async function run26(argv, io) {
|
|
109967
109995
|
const [sub, ...rest] = argv;
|
|
109968
109996
|
if (sub !== "apply")
|
|
@@ -110008,7 +110036,7 @@ async function run26(argv, io) {
|
|
|
110008
110036
|
]);
|
|
110009
110037
|
}
|
|
110010
110038
|
var USAGE19 = "workit changelog apply (--entries <JSON|@file|-> | --normalize-only) [--path CHANGELOG.md] [--preview]", readEntries = (raw, cwd) => {
|
|
110011
|
-
const text = raw === "-" ?
|
|
110039
|
+
const text = raw === "-" ? readFileSync35(0, "utf8") : raw.startsWith("@") ? readFileSync35(path81.resolve(cwd, raw.slice(1)), "utf8") : raw;
|
|
110012
110040
|
return JSON.parse(text);
|
|
110013
110041
|
};
|
|
110014
110042
|
var init_changelog2 = __esm(() => {
|
|
@@ -110024,7 +110052,7 @@ __export(exports_handoff, {
|
|
|
110024
110052
|
run: () => run27
|
|
110025
110053
|
});
|
|
110026
110054
|
import fs37 from "node:fs";
|
|
110027
|
-
import
|
|
110055
|
+
import path82 from "node:path";
|
|
110028
110056
|
import { parseArgs as parseArgs2 } from "node:util";
|
|
110029
110057
|
function render3(brief) {
|
|
110030
110058
|
const lines = [
|
|
@@ -110064,9 +110092,9 @@ function bounded(brief, cwd) {
|
|
|
110064
110092
|
let file = null;
|
|
110065
110093
|
if (store.ok)
|
|
110066
110094
|
try {
|
|
110067
|
-
const dir =
|
|
110095
|
+
const dir = path82.join(store.value.root, "handoff");
|
|
110068
110096
|
fs37.mkdirSync(dir, { recursive: true });
|
|
110069
|
-
file =
|
|
110097
|
+
file = path82.join(dir, `${(brief.branch ?? "detached").replaceAll(/[^\w.-]+/gu, "-")}.txt`);
|
|
110070
110098
|
fs37.writeFileSync(file, `${[...body, ...tail].join(`
|
|
110071
110099
|
`)}
|
|
110072
110100
|
`, {
|
|
@@ -110141,7 +110169,7 @@ var init_handoff = __esm(() => {
|
|
|
110141
110169
|
});
|
|
110142
110170
|
|
|
110143
110171
|
// packages/workit-cli/src/main.ts
|
|
110144
|
-
import
|
|
110172
|
+
import path83 from "node:path";
|
|
110145
110173
|
|
|
110146
110174
|
// packages/workit-core/src/git/env-redirect.ts
|
|
110147
110175
|
var GIT_REDIRECT_ENV = [
|
|
@@ -111102,7 +111130,7 @@ var defaultIo = (json) => ({
|
|
|
111102
111130
|
});
|
|
111103
111131
|
async function main(argv, overrides = {}, options = {}) {
|
|
111104
111132
|
const parsed = parseGlobals(argv);
|
|
111105
|
-
const cwd =
|
|
111133
|
+
const cwd = path83.resolve(overrides.cwd ?? process.cwd(), parsed.cwd ?? ".");
|
|
111106
111134
|
const io = {
|
|
111107
111135
|
...defaultIo(parsed.json),
|
|
111108
111136
|
terminals: {
|