@brainervirus/workit-claude-code 8.45.2 → 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.js +272 -290
- package/package.json +3 -3
package/dist/workit.js
CHANGED
|
@@ -9734,7 +9734,7 @@ var package_default;
|
|
|
9734
9734
|
var init_package = __esm(() => {
|
|
9735
9735
|
package_default = {
|
|
9736
9736
|
name: "@brainervirus/workit-cli",
|
|
9737
|
-
version: "8.45.
|
|
9737
|
+
version: "8.45.3",
|
|
9738
9738
|
private: false,
|
|
9739
9739
|
description: "Workit CLI — setup wizard, doctor, and task control for agentic coding workflows",
|
|
9740
9740
|
keywords: [
|
|
@@ -9772,13 +9772,13 @@ var init_package = __esm(() => {
|
|
|
9772
9772
|
},
|
|
9773
9773
|
dependencies: {
|
|
9774
9774
|
"@babel/parser": "7.29.9",
|
|
9775
|
-
"@brainervirus/workit-cursor": "^8.45.
|
|
9775
|
+
"@brainervirus/workit-cursor": "^8.45.3",
|
|
9776
9776
|
"@inkjs/ui": "2.0.0",
|
|
9777
9777
|
ink: "7.1.1",
|
|
9778
9778
|
react: "19.2.8"
|
|
9779
9779
|
},
|
|
9780
9780
|
devDependencies: {
|
|
9781
|
-
"@brainervirus/workit-core": "^8.45.
|
|
9781
|
+
"@brainervirus/workit-core": "^8.45.3"
|
|
9782
9782
|
},
|
|
9783
9783
|
engines: {
|
|
9784
9784
|
node: ">=24"
|
|
@@ -67857,7 +67857,7 @@ var init_hook_runs = __esm(() => {
|
|
|
67857
67857
|
});
|
|
67858
67858
|
|
|
67859
67859
|
// packages/workit-cli/src/update-settings.ts
|
|
67860
|
-
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";
|
|
67861
67861
|
import os12 from "node:os";
|
|
67862
67862
|
import path39 from "node:path";
|
|
67863
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) => {
|
|
@@ -67904,6 +67904,22 @@ var workitConfigDir = (env) => env.WORKFLOW_TOOLKIT_CONFIG ?? env.WORKFLOW_TOOLK
|
|
|
67904
67904
|
} catch (error) {
|
|
67905
67905
|
return error instanceof Error ? error.message : `cannot write ${file}`;
|
|
67906
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;
|
|
67907
67923
|
};
|
|
67908
67924
|
var init_update_settings = __esm(() => {
|
|
67909
67925
|
init_heavy_words();
|
|
@@ -67941,7 +67957,7 @@ import {
|
|
|
67941
67957
|
readdirSync as readdirSync9,
|
|
67942
67958
|
mkdirSync as mkdirSync8,
|
|
67943
67959
|
readFileSync as readFileSync19,
|
|
67944
|
-
realpathSync as
|
|
67960
|
+
realpathSync as realpathSync10,
|
|
67945
67961
|
rmSync as rmSync3,
|
|
67946
67962
|
statSync as statSync6
|
|
67947
67963
|
} from "node:fs";
|
|
@@ -68164,7 +68180,7 @@ function applyHostPermissions(plan, options = {}) {
|
|
|
68164
68180
|
continue;
|
|
68165
68181
|
}
|
|
68166
68182
|
try {
|
|
68167
|
-
const target = change.before === null ? change.file :
|
|
68183
|
+
const target = change.before === null ? change.file : realpathSync10(change.file);
|
|
68168
68184
|
if (change.before !== null) {
|
|
68169
68185
|
const backups = path40.join(paths.stateDir, "host-permissions-backup");
|
|
68170
68186
|
mkdirSync8(backups, { recursive: true, mode: 448 });
|
|
@@ -71057,7 +71073,7 @@ import {
|
|
|
71057
71073
|
mkdtempSync as mkdtempSync2,
|
|
71058
71074
|
readFileSync as readFileSync21,
|
|
71059
71075
|
readdirSync as readdirSync11,
|
|
71060
|
-
realpathSync as
|
|
71076
|
+
realpathSync as realpathSync11,
|
|
71061
71077
|
renameSync as renameSync6,
|
|
71062
71078
|
rmSync as rmSync5,
|
|
71063
71079
|
statSync as statSync8,
|
|
@@ -71503,7 +71519,7 @@ function applyOpenCode(root, res) {
|
|
|
71503
71519
|
};
|
|
71504
71520
|
}
|
|
71505
71521
|
function copyPluginDir(src, dest) {
|
|
71506
|
-
const realSrc =
|
|
71522
|
+
const realSrc = realpathSync11(src);
|
|
71507
71523
|
const marker = path42.join(dest, ".workit-root");
|
|
71508
71524
|
const destIsLink = existsSync18(dest) && lstatSync8(dest).isSymbolicLink();
|
|
71509
71525
|
const synced = !destIsLink && readFileSafe(marker)?.trim() === realSrc && samePluginContent(realSrc, dest, dest);
|
|
@@ -71942,7 +71958,7 @@ var TOKEN_PLACEHOLDER3 = "YOUR_TOKEN_HERE", YT_OVERRIDES, VCS_OVERRIDES, SETUP_O
|
|
|
71942
71958
|
return (require2.resolve.paths(name) ?? []).map((dir) => path42.join(dir, name));
|
|
71943
71959
|
}, realRoot = (root) => {
|
|
71944
71960
|
try {
|
|
71945
|
-
return
|
|
71961
|
+
return realpathSync11(root);
|
|
71946
71962
|
} catch {
|
|
71947
71963
|
return root;
|
|
71948
71964
|
}
|
|
@@ -73002,7 +73018,7 @@ var init_wizard_state = __esm(() => {
|
|
|
73002
73018
|
});
|
|
73003
73019
|
|
|
73004
73020
|
// packages/workit-cli/src/admin/uninstall.ts
|
|
73005
|
-
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";
|
|
73006
73022
|
import os16 from "node:os";
|
|
73007
73023
|
import path45 from "node:path";
|
|
73008
73024
|
function cleanCursorSettings(settings, pluginDir) {
|
|
@@ -73310,7 +73326,7 @@ var resolveUninstallPaths = (options = {}) => {
|
|
|
73310
73326
|
return false;
|
|
73311
73327
|
}
|
|
73312
73328
|
try {
|
|
73313
|
-
return
|
|
73329
|
+
return realpathSync12(actionPath) === realpathSync12(expected);
|
|
73314
73330
|
} catch {
|
|
73315
73331
|
return true;
|
|
73316
73332
|
}
|
|
@@ -76174,7 +76190,7 @@ function errorText(error) {
|
|
|
76174
76190
|
}
|
|
76175
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}
|
|
76176
76192
|
${result.stderr ?? ""}`.split(/\r?\n/).map((line) => line.trim()).find((line) => /\bError:/.test(line)), failureReason = (command, result) => {
|
|
76177
|
-
const tail = stderrTail(result.stderr);
|
|
76193
|
+
const tail = stderrTail(result.stderr) || stderrTail(result.stdout, 2);
|
|
76178
76194
|
const message = errorLine(result);
|
|
76179
76195
|
const detail = message && !tail.includes(message) ? [message, tail].filter(Boolean) : [tail];
|
|
76180
76196
|
const text = detail.filter(Boolean).join(" | ");
|
|
@@ -76918,8 +76934,6 @@ __export(exports_update_check, {
|
|
|
76918
76934
|
writeUpdatesMode: () => writeUpdatesMode
|
|
76919
76935
|
});
|
|
76920
76936
|
import { spawn as spawn3, spawnSync as spawnSync18 } from "node:child_process";
|
|
76921
|
-
import { readFileSync as readFileSync25 } from "node:fs";
|
|
76922
|
-
import path50 from "node:path";
|
|
76923
76937
|
async function launchUpdateCheck(context, deps) {
|
|
76924
76938
|
if (!interactiveLaunch(context, deps))
|
|
76925
76939
|
return;
|
|
@@ -76977,7 +76991,7 @@ Cancelled.
|
|
|
76977
76991
|
if (outcome.code !== 0 && outcome.failed.length)
|
|
76978
76992
|
deps.write(`${style.warn("Upgrade incomplete:")} ${outcome.failed.map((row) => `${row.host} failed${row.fix ? ` (fix: ${row.fix})` : ""}`).join("; ")}
|
|
76979
76993
|
`);
|
|
76980
|
-
const onDisk = (deps.cliOnDisk ??
|
|
76994
|
+
const onDisk = (deps.cliOnDisk ?? cliVersionOnDisk)();
|
|
76981
76995
|
if (!onDisk || onDisk === installed) {
|
|
76982
76996
|
if (outcome.code !== 0)
|
|
76983
76997
|
deps.write(`${style.warn("Upgrade did not finish;")} running your command with ${installed}.
|
|
@@ -76986,20 +77000,7 @@ Cancelled.
|
|
|
76986
77000
|
}
|
|
76987
77001
|
return (deps.reexec ?? defaultReexec)(context.argv);
|
|
76988
77002
|
}
|
|
76989
|
-
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,
|
|
76990
|
-
const script = process.argv[1];
|
|
76991
|
-
if (!script)
|
|
76992
|
-
return;
|
|
76993
|
-
let dir = path50.dirname(script);
|
|
76994
|
-
for (let depth = 0;depth < 4; depth += 1, dir = path50.dirname(dir)) {
|
|
76995
|
-
try {
|
|
76996
|
-
const found = JSON.parse(readFileSync25(path50.join(dir, "package.json"), "utf8"));
|
|
76997
|
-
if (found.name === CLI_PACKAGE2 && typeof found.version === "string")
|
|
76998
|
-
return found.version;
|
|
76999
|
-
} catch {}
|
|
77000
|
-
}
|
|
77001
|
-
return;
|
|
77002
|
-
}, 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 () => {
|
|
77003
77004
|
const failed = [];
|
|
77004
77005
|
const code = await (await Promise.resolve().then(() => (init_upgrade(), exports_upgrade))).runUpgradeCommand(["--yes"], {
|
|
77005
77006
|
out: process.stderr,
|
|
@@ -77070,12 +77071,12 @@ var init_update_check = __esm(() => {
|
|
|
77070
77071
|
// packages/workit-cli/src/upgrade/probes.ts
|
|
77071
77072
|
import { existsSync as existsSync23, mkdtempSync as mkdtempSync3, rmSync as rmSync8 } from "node:fs";
|
|
77072
77073
|
import os19 from "node:os";
|
|
77073
|
-
import
|
|
77074
|
+
import path50 from "node:path";
|
|
77074
77075
|
var PROBE_TIMEOUT_MS = 20000, probeKey = (command, args) => [command, ...args].join(" "), opencodeScratchEnv = (deps, scratch) => ({
|
|
77075
77076
|
...deps.env,
|
|
77076
|
-
XDG_DATA_HOME:
|
|
77077
|
-
XDG_STATE_HOME:
|
|
77078
|
-
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")
|
|
77079
77080
|
}), registry2 = (name) => ["npm", ["view", name, "version"]], OPENCODE_READY_KEY = "opencode-ready", opencodeReading = (probes) => {
|
|
77080
77081
|
const result = probes?.get(OPENCODE_READY_KEY);
|
|
77081
77082
|
if (!result)
|
|
@@ -77090,7 +77091,7 @@ var PROBE_TIMEOUT_MS = 20000, probeKey = (command, args) => [command, ...args].j
|
|
|
77090
77091
|
const run = asyncRunner(deps, timeoutMs);
|
|
77091
77092
|
const probes = [];
|
|
77092
77093
|
const add = (command, args, runner = run) => probes.push([command, args, runner]);
|
|
77093
|
-
const scratch = mkdtempSync3(
|
|
77094
|
+
const scratch = mkdtempSync3(path50.join(os19.tmpdir(), "workit-upgrade-opencode-"));
|
|
77094
77095
|
try {
|
|
77095
77096
|
if (hosts.includes("opencode") && existsSync23(paths.opencodeConfig)) {
|
|
77096
77097
|
if (!options.check) {
|
|
@@ -77161,8 +77162,8 @@ var init_probes = __esm(() => {
|
|
|
77161
77162
|
});
|
|
77162
77163
|
|
|
77163
77164
|
// packages/workit-cli/src/upgrade/plan.ts
|
|
77164
|
-
import { existsSync as existsSync24, mkdtempSync as mkdtempSync4, rmSync as rmSync9, lstatSync as lstatSync9, readFileSync as
|
|
77165
|
-
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";
|
|
77166
77167
|
import os20 from "node:os";
|
|
77167
77168
|
function previewUpgrade(hosts = HOSTS2, deps = {}, probes) {
|
|
77168
77169
|
const paths = upgradePaths(deps);
|
|
@@ -77186,9 +77187,9 @@ function previewUpgrade(hosts = HOSTS2, deps = {}, probes) {
|
|
|
77186
77187
|
for (const file of [
|
|
77187
77188
|
paths.opencodeConfig,
|
|
77188
77189
|
paths.opencodeConfig + "c",
|
|
77189
|
-
|
|
77190
|
-
|
|
77191
|
-
|
|
77190
|
+
path51.join(home, ".cursor/settings.json"),
|
|
77191
|
+
path51.join(home, ".cursor/mcp.json"),
|
|
77192
|
+
path51.join(paths.cursorRoot, "package.json"),
|
|
77192
77193
|
paths.codexConfig,
|
|
77193
77194
|
paths.piSettings
|
|
77194
77195
|
])
|
|
@@ -77340,7 +77341,7 @@ function previewUpgrade(hosts = HOSTS2, deps = {}, probes) {
|
|
|
77340
77341
|
var codexRegistered = (configFile) => {
|
|
77341
77342
|
let text;
|
|
77342
77343
|
try {
|
|
77343
|
-
text =
|
|
77344
|
+
text = readFileSync25(configFile, "utf8");
|
|
77344
77345
|
} catch {
|
|
77345
77346
|
return false;
|
|
77346
77347
|
}
|
|
@@ -77383,8 +77384,8 @@ var codexRegistered = (configFile) => {
|
|
|
77383
77384
|
result.push(classify("opencode", pin));
|
|
77384
77385
|
});
|
|
77385
77386
|
guard("cursor", () => {
|
|
77386
|
-
const cursor = objectOrNull(
|
|
77387
|
-
const mcp = objectOrNull(
|
|
77387
|
+
const cursor = objectOrNull(path51.join(paths.cursorRoot, "package.json"));
|
|
77388
|
+
const mcp = objectOrNull(path51.join(home, ".cursor/mcp.json"));
|
|
77388
77389
|
const args = mcp?.mcpServers?.workit?.args ?? [];
|
|
77389
77390
|
const arg = args.find((value) => typeof value === "string" && value.startsWith("--package="));
|
|
77390
77391
|
const selector = typeof arg === "string" ? arg.slice(10) : "local";
|
|
@@ -77395,7 +77396,7 @@ var codexRegistered = (configFile) => {
|
|
|
77395
77396
|
});
|
|
77396
77397
|
return;
|
|
77397
77398
|
}
|
|
77398
|
-
const settings = objectOrNull(
|
|
77399
|
+
const settings = objectOrNull(path51.join(home, ".cursor/settings.json"));
|
|
77399
77400
|
const dirs = Array.isArray(settings?.plugin_dirs) ? settings.plugin_dirs : [];
|
|
77400
77401
|
const registered = mcp?.mcpServers?.workit !== undefined || dirs.some((dir) => String(dir).replaceAll("\\", "/").replace(/\/+$/, "").endsWith("local/workit"));
|
|
77401
77402
|
if (registered)
|
|
@@ -77410,7 +77411,7 @@ var codexRegistered = (configFile) => {
|
|
|
77410
77411
|
if (typeof source !== "string")
|
|
77411
77412
|
continue;
|
|
77412
77413
|
const npm = /^(?:npm:)?@brainervirus\/workit-pi(?:@[^/]+)?$/.test(source);
|
|
77413
|
-
const local =
|
|
77414
|
+
const local = path51.isAbsolute(source) && source.replaceAll("\\", "/").endsWith("/packages/workit-pi") && object2(path51.join(source, "package.json"))?.name === "@brainervirus/workit-pi";
|
|
77414
77415
|
if (!npm && !local)
|
|
77415
77416
|
continue;
|
|
77416
77417
|
const found = classify("pi", source);
|
|
@@ -77477,7 +77478,7 @@ var codexRegistered = (configFile) => {
|
|
|
77477
77478
|
const cached = probes?.get(probeKey("opencode", args));
|
|
77478
77479
|
if (cached)
|
|
77479
77480
|
return cached;
|
|
77480
|
-
const scratch = mkdtempSync4(
|
|
77481
|
+
const scratch = mkdtempSync4(path51.join(os20.tmpdir(), "workit-upgrade-opencode-"));
|
|
77481
77482
|
try {
|
|
77482
77483
|
return runner({ ...deps, env: opencodeScratchEnv(deps, scratch) })("opencode", args);
|
|
77483
77484
|
} finally {
|
|
@@ -77488,7 +77489,7 @@ var codexRegistered = (configFile) => {
|
|
|
77488
77489
|
return probes ? (command, args) => probes.get(probeKey(command, args)) ?? run(command, args) : run;
|
|
77489
77490
|
}, planCli = (plan, run) => {
|
|
77490
77491
|
const root = run("npm", ["root", "--global"]);
|
|
77491
|
-
if (root.status !== 0 || !
|
|
77492
|
+
if (root.status !== 0 || !path51.isAbsolute(root.stdout.trim())) {
|
|
77492
77493
|
plan.skipped.push({
|
|
77493
77494
|
host: "cli",
|
|
77494
77495
|
reason: "global npm location could not be verified",
|
|
@@ -77496,9 +77497,9 @@ var codexRegistered = (configFile) => {
|
|
|
77496
77497
|
});
|
|
77497
77498
|
return;
|
|
77498
77499
|
}
|
|
77499
|
-
const packageFile =
|
|
77500
|
+
const packageFile = path51.join(root.stdout.trim(), "@brainervirus/workit-cli/package.json");
|
|
77500
77501
|
const installed = objectOrNull(packageFile);
|
|
77501
|
-
if (installed?.name !== "@brainervirus/workit-cli" || lstatSync9(
|
|
77502
|
+
if (installed?.name !== "@brainervirus/workit-cli" || lstatSync9(path51.dirname(packageFile)).isSymbolicLink()) {
|
|
77502
77503
|
plan.skipped.push({
|
|
77503
77504
|
host: "cli",
|
|
77504
77505
|
reason: "no managed global CLI install (local links preserved); use npx @brainervirus/workit-cli@latest"
|
|
@@ -77538,7 +77539,7 @@ var init_plan = __esm(() => {
|
|
|
77538
77539
|
});
|
|
77539
77540
|
|
|
77540
77541
|
// packages/workit-cli/src/upgrade/check.ts
|
|
77541
|
-
import
|
|
77542
|
+
import path52 from "node:path";
|
|
77542
77543
|
async function runUpdateCheck(json, deps) {
|
|
77543
77544
|
const out = deps.out ?? process.stdout;
|
|
77544
77545
|
const paths = upgradePaths(deps);
|
|
@@ -77659,7 +77660,7 @@ function runSetUpdates(value, deps) {
|
|
|
77659
77660
|
`);
|
|
77660
77661
|
return 1;
|
|
77661
77662
|
}
|
|
77662
|
-
out.write(`updates: ${value} (saved in ${
|
|
77663
|
+
out.write(`updates: ${value} (saved in ${path52.join(configDir, "config.json")})
|
|
77663
77664
|
`);
|
|
77664
77665
|
return 0;
|
|
77665
77666
|
}
|
|
@@ -77759,9 +77760,9 @@ __export(exports_upgrade, {
|
|
|
77759
77760
|
runUpgradeCommand: () => runUpgradeCommand
|
|
77760
77761
|
});
|
|
77761
77762
|
import { spawnSync as spawnSync19 } from "node:child_process";
|
|
77762
|
-
import { mkdtempSync as mkdtempSync5, readFileSync as
|
|
77763
|
+
import { mkdtempSync as mkdtempSync5, readFileSync as readFileSync26, rmSync as rmSync10, writeFileSync as writeFileSync14 } from "node:fs";
|
|
77763
77764
|
import os21 from "node:os";
|
|
77764
|
-
import
|
|
77765
|
+
import path53 from "node:path";
|
|
77765
77766
|
async function runUpgradeCommand(argv, deps = {}) {
|
|
77766
77767
|
const { env } = upgradePaths(deps);
|
|
77767
77768
|
const handBack = env[CONTINUE_ENV] !== undefined ? env[ROWS_ENV] : undefined;
|
|
@@ -77876,10 +77877,10 @@ Nothing changed.
|
|
|
77876
77877
|
json
|
|
77877
77878
|
}));
|
|
77878
77879
|
const handoff = async (cli) => {
|
|
77879
|
-
if (!reexec || (deps.cliOnDisk ??
|
|
77880
|
+
if (!reexec || (deps.cliOnDisk ?? cliVersionOnDisk)() !== plan.cli?.latest)
|
|
77880
77881
|
return;
|
|
77881
|
-
const scratch = mkdtempSync5(
|
|
77882
|
-
const rowsFile =
|
|
77882
|
+
const scratch = mkdtempSync5(path53.join(os21.tmpdir(), "workit-upgrade-"));
|
|
77883
|
+
const rowsFile = path53.join(scratch, "rows.json");
|
|
77883
77884
|
try {
|
|
77884
77885
|
const code = await reexec([
|
|
77885
77886
|
...legacy ? ["--apply", "--confirm"] : ["--yes"],
|
|
@@ -78009,7 +78010,7 @@ var USAGE3 = `Usage: workit upgrade [--hosts=opencode,cursor,codex,pi,claude-cod
|
|
|
78009
78010
|
workit upgrade --set-updates=prompt|auto|off
|
|
78010
78011
|
`, CONTINUE_ENV = "WORKIT_UPGRADE_CONTINUE", ROWS_ENV = "WORKIT_UPGRADE_ROWS", readText5 = (file) => {
|
|
78011
78012
|
try {
|
|
78012
|
-
return
|
|
78013
|
+
return readFileSync26(file, "utf8");
|
|
78013
78014
|
} catch {
|
|
78014
78015
|
return;
|
|
78015
78016
|
}
|
|
@@ -78034,26 +78035,6 @@ var USAGE3 = `Usage: workit upgrade [--hosts=opencode,cursor,codex,pi,claude-cod
|
|
|
78034
78035
|
} catch {
|
|
78035
78036
|
return;
|
|
78036
78037
|
}
|
|
78037
|
-
}, runningCliVersion = () => {
|
|
78038
|
-
const script = process.argv[1];
|
|
78039
|
-
if (!script)
|
|
78040
|
-
return;
|
|
78041
|
-
let dir = path54.dirname(script);
|
|
78042
|
-
for (let depth = 0;depth < 4; depth += 1, dir = path54.dirname(dir)) {
|
|
78043
|
-
const found = cliPackageVersion(readText5(path54.join(dir, "package.json")));
|
|
78044
|
-
if (found)
|
|
78045
|
-
return found;
|
|
78046
|
-
}
|
|
78047
|
-
return;
|
|
78048
|
-
}, cliPackageVersion = (text) => {
|
|
78049
|
-
if (text === undefined)
|
|
78050
|
-
return;
|
|
78051
|
-
try {
|
|
78052
|
-
const found = JSON.parse(text);
|
|
78053
|
-
return found.name === package_default.name && typeof found.version === "string" ? found.version : undefined;
|
|
78054
|
-
} catch {
|
|
78055
|
-
return;
|
|
78056
|
-
}
|
|
78057
78038
|
}, spawnUpgrade = (options) => (argv, extra) => {
|
|
78058
78039
|
if (!options.entry)
|
|
78059
78040
|
return;
|
|
@@ -78076,6 +78057,7 @@ var init_upgrade = __esm(() => {
|
|
|
78076
78057
|
init_host_permissions();
|
|
78077
78058
|
init_progress();
|
|
78078
78059
|
init_style();
|
|
78060
|
+
init_update_settings();
|
|
78079
78061
|
init_apply();
|
|
78080
78062
|
init_check();
|
|
78081
78063
|
init_plan();
|
|
@@ -78110,7 +78092,7 @@ var init_launch = __esm(() => {
|
|
|
78110
78092
|
// packages/workit-core/src/knowledge.ts
|
|
78111
78093
|
import { spawnSync as spawnSync20 } from "node:child_process";
|
|
78112
78094
|
import fs20 from "node:fs";
|
|
78113
|
-
import
|
|
78095
|
+
import path54 from "node:path";
|
|
78114
78096
|
function lintKnowledge(root) {
|
|
78115
78097
|
const seen = new Set;
|
|
78116
78098
|
const unreadable = [];
|
|
@@ -78214,7 +78196,7 @@ var AGENTS_BYTE_BUDGET, STEERING_FILES, NEED_BASED_FILES, STANDARDS_FILE = "CODI
|
|
|
78214
78196
|
const end = lines.indexOf("---", 1);
|
|
78215
78197
|
return end === -1 ? lines : [...lines.slice(0, end + 1).map(() => ""), ...lines.slice(end + 1)];
|
|
78216
78198
|
}, read = (root, file) => {
|
|
78217
|
-
const full =
|
|
78199
|
+
const full = path54.join(root, file);
|
|
78218
78200
|
try {
|
|
78219
78201
|
fs20.lstatSync(full);
|
|
78220
78202
|
} catch {
|
|
@@ -78255,7 +78237,7 @@ var AGENTS_BYTE_BUDGET, STEERING_FILES, NEED_BASED_FILES, STANDARDS_FILE = "CODI
|
|
|
78255
78237
|
}
|
|
78256
78238
|
}, brokenLinks = (root, doc, tracked) => {
|
|
78257
78239
|
const findings = [];
|
|
78258
|
-
const base =
|
|
78240
|
+
const base = path54.dirname(path54.join(root, doc.file));
|
|
78259
78241
|
const missing = (target, line, how) => findings.push({
|
|
78260
78242
|
rule: "broken-link",
|
|
78261
78243
|
file: doc.file,
|
|
@@ -78274,7 +78256,7 @@ var AGENTS_BYTE_BUDGET, STEERING_FILES, NEED_BASED_FILES, STANDARDS_FILE = "CODI
|
|
|
78274
78256
|
const local = localTarget(target);
|
|
78275
78257
|
if (!local)
|
|
78276
78258
|
continue;
|
|
78277
|
-
const resolved = local.startsWith("/") ?
|
|
78259
|
+
const resolved = local.startsWith("/") ? path54.join(root, local) : path54.resolve(base, local);
|
|
78278
78260
|
if (!exists2(resolved))
|
|
78279
78261
|
missing(target, index + 1, "link");
|
|
78280
78262
|
}
|
|
@@ -78284,9 +78266,9 @@ var AGENTS_BYTE_BUDGET, STEERING_FILES, NEED_BASED_FILES, STANDARDS_FILE = "CODI
|
|
|
78284
78266
|
continue;
|
|
78285
78267
|
const relative = /^\.\.?\//.test(candidate);
|
|
78286
78268
|
const first = candidate.split("/")[0];
|
|
78287
|
-
if (!relative && !(tracked ? tracked.has(first) : exists2(
|
|
78269
|
+
if (!relative && !(tracked ? tracked.has(first) : exists2(path54.join(root, first))))
|
|
78288
78270
|
continue;
|
|
78289
|
-
const resolved = relative ?
|
|
78271
|
+
const resolved = relative ? path54.resolve(base, candidate) : path54.join(root, candidate);
|
|
78290
78272
|
if (!exists2(resolved))
|
|
78291
78273
|
missing(span, index + 1, "pointer");
|
|
78292
78274
|
}
|
|
@@ -78656,7 +78638,7 @@ import { spawn as spawn4, spawnSync as spawnSync21 } from "node:child_process";
|
|
|
78656
78638
|
import { createHash as createHash17 } from "node:crypto";
|
|
78657
78639
|
import fs21 from "node:fs";
|
|
78658
78640
|
import os22 from "node:os";
|
|
78659
|
-
import
|
|
78641
|
+
import path55 from "node:path";
|
|
78660
78642
|
import { StringDecoder } from "node:string_decoder";
|
|
78661
78643
|
function tailLines(text, lines = TAIL_LINES) {
|
|
78662
78644
|
const all = text.replace(/\r\n?/gu, `
|
|
@@ -78776,7 +78758,7 @@ function planSpawn(argv, options) {
|
|
|
78776
78758
|
return { file: argv[0], args: [], verbatim: false, shell: true };
|
|
78777
78759
|
if (options.platform !== "win32")
|
|
78778
78760
|
return { file: argv[0], args: argv.slice(1), verbatim: false, shell: false };
|
|
78779
|
-
const win =
|
|
78761
|
+
const win = path55.win32;
|
|
78780
78762
|
const isFile = options.isFile ?? ((file) => {
|
|
78781
78763
|
try {
|
|
78782
78764
|
return fs21.statSync(file).isFile();
|
|
@@ -78938,10 +78920,10 @@ function runCheckCommand(argv, options) {
|
|
|
78938
78920
|
function storeLog(storeRoot, log) {
|
|
78939
78921
|
const digest = logDigest(log);
|
|
78940
78922
|
const ref = `blobs/logs/${digest.slice("sha256:".length)}.log`;
|
|
78941
|
-
const file =
|
|
78923
|
+
const file = path55.join(storeRoot, ref);
|
|
78942
78924
|
try {
|
|
78943
78925
|
if (!fs21.existsSync(file)) {
|
|
78944
|
-
fs21.mkdirSync(
|
|
78926
|
+
fs21.mkdirSync(path55.dirname(file), { recursive: true });
|
|
78945
78927
|
const temp = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
78946
78928
|
fs21.writeFileSync(temp, log, { mode: 384 });
|
|
78947
78929
|
fs21.renameSync(temp, file);
|
|
@@ -78954,7 +78936,7 @@ function storeLog(storeRoot, log) {
|
|
|
78954
78936
|
function pruneCheckLogs(storeRoot, options = {}) {
|
|
78955
78937
|
const limits = { ...LOG_RETENTION, ...options.retention };
|
|
78956
78938
|
const now = options.now ?? Date.now();
|
|
78957
|
-
const dir =
|
|
78939
|
+
const dir = path55.join(storeRoot, "blobs", "logs");
|
|
78958
78940
|
const report = { removed: 0, removedBytes: 0, kept: 0 };
|
|
78959
78941
|
let names;
|
|
78960
78942
|
try {
|
|
@@ -78964,7 +78946,7 @@ function pruneCheckLogs(storeRoot, options = {}) {
|
|
|
78964
78946
|
}
|
|
78965
78947
|
const files = names.flatMap((name) => {
|
|
78966
78948
|
try {
|
|
78967
|
-
const stat = fs21.statSync(
|
|
78949
|
+
const stat = fs21.statSync(path55.join(dir, name));
|
|
78968
78950
|
return stat.isFile() ? [{ name, size: stat.size, mtimeMs: stat.mtimeMs }] : [];
|
|
78969
78951
|
} catch {
|
|
78970
78952
|
return [];
|
|
@@ -78983,7 +78965,7 @@ function pruneCheckLogs(storeRoot, options = {}) {
|
|
|
78983
78965
|
continue;
|
|
78984
78966
|
if (!options.dryRun)
|
|
78985
78967
|
try {
|
|
78986
|
-
fs21.rmSync(
|
|
78968
|
+
fs21.rmSync(path55.join(dir, file.name), { force: true });
|
|
78987
78969
|
} catch {
|
|
78988
78970
|
continue;
|
|
78989
78971
|
}
|
|
@@ -79723,12 +79705,12 @@ var init_workspace = __esm(() => {
|
|
|
79723
79705
|
|
|
79724
79706
|
// packages/workit-core/src/core/heavy-rules.ts
|
|
79725
79707
|
import fs22 from "node:fs";
|
|
79726
|
-
import
|
|
79708
|
+
import path56 from "node:path";
|
|
79727
79709
|
function gitTop(cwd) {
|
|
79728
|
-
for (let dir =
|
|
79729
|
-
if (fs22.existsSync(
|
|
79710
|
+
for (let dir = path56.resolve(cwd);; dir = path56.dirname(dir)) {
|
|
79711
|
+
if (fs22.existsSync(path56.join(dir, ".git")))
|
|
79730
79712
|
return dir;
|
|
79731
|
-
if (
|
|
79713
|
+
if (path56.dirname(dir) === dir)
|
|
79732
79714
|
return null;
|
|
79733
79715
|
}
|
|
79734
79716
|
}
|
|
@@ -79770,18 +79752,18 @@ var init_heavy_rules = () => {};
|
|
|
79770
79752
|
// packages/workit-core/src/core/heavy.ts
|
|
79771
79753
|
import fs23 from "node:fs";
|
|
79772
79754
|
import os23 from "node:os";
|
|
79773
|
-
import
|
|
79755
|
+
import path57 from "node:path";
|
|
79774
79756
|
function stateDir2(env, platform = process.platform) {
|
|
79775
79757
|
if (env.WORKFLOW_TOOLKIT_STATE)
|
|
79776
79758
|
return env.WORKFLOW_TOOLKIT_STATE;
|
|
79777
79759
|
if (env.XDG_STATE_HOME)
|
|
79778
|
-
return
|
|
79760
|
+
return path57.join(env.XDG_STATE_HOME, "workit");
|
|
79779
79761
|
const home = env.HOME || os23.homedir();
|
|
79780
79762
|
if (platform === "darwin")
|
|
79781
|
-
return
|
|
79763
|
+
return path57.join(home, "Library", "Application Support", "workit");
|
|
79782
79764
|
if (platform === "win32")
|
|
79783
|
-
return
|
|
79784
|
-
return
|
|
79765
|
+
return path57.join(env.LOCALAPPDATA ?? path57.join(home, "AppData", "Local"), "workit");
|
|
79766
|
+
return path57.join(home, ".local", "state", "workit");
|
|
79785
79767
|
}
|
|
79786
79768
|
function positional(words, from, values = PM_VALUES) {
|
|
79787
79769
|
let index = from;
|
|
@@ -79921,7 +79903,7 @@ function machinePatterns(env) {
|
|
|
79921
79903
|
return isRecord8(value) ? stringList2(value.patterns) : [];
|
|
79922
79904
|
}
|
|
79923
79905
|
function repoPatterns(cwd) {
|
|
79924
|
-
return repoHeavyCommands(gitTop(cwd) ??
|
|
79906
|
+
return repoHeavyCommands(gitTop(cwd) ?? path57.resolve(cwd));
|
|
79925
79907
|
}
|
|
79926
79908
|
function heavyLines(lines, options) {
|
|
79927
79909
|
const found = [];
|
|
@@ -80000,7 +79982,7 @@ function leaseRewrite(command) {
|
|
|
80000
79982
|
return null;
|
|
80001
79983
|
return `${prefix}workit check --heavy -- ${rest}`;
|
|
80002
79984
|
}
|
|
80003
|
-
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) => {
|
|
80004
79986
|
try {
|
|
80005
79987
|
return JSON.parse(fs23.readFileSync(file, "utf8"));
|
|
80006
79988
|
} catch {
|
|
@@ -80147,7 +80129,7 @@ var init_heavy = __esm(() => {
|
|
|
80147
80129
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
80148
80130
|
import fs24 from "node:fs";
|
|
80149
80131
|
import os24 from "node:os";
|
|
80150
|
-
import
|
|
80132
|
+
import path58 from "node:path";
|
|
80151
80133
|
function memoryValue(value, host) {
|
|
80152
80134
|
const text = typeof value === "number" ? String(value) : typeof value === "string" ? value : "";
|
|
80153
80135
|
const percent = PERCENT.exec(text.trim());
|
|
@@ -80343,7 +80325,7 @@ function tryOnce(options, record, reclaimed) {
|
|
|
80343
80325
|
const text = `${JSON.stringify(record)}
|
|
80344
80326
|
`;
|
|
80345
80327
|
for (let slot = 0;slot < options.slots; slot += 1) {
|
|
80346
|
-
const file =
|
|
80328
|
+
const file = path58.join(options.dir, `slot-${slot}.json`);
|
|
80347
80329
|
for (let attempt = 0;attempt < 2; attempt += 1) {
|
|
80348
80330
|
try {
|
|
80349
80331
|
const fd = fs24.openSync(file, "wx", 384);
|
|
@@ -80388,7 +80370,7 @@ function leaseQueue(dir, probe = {}) {
|
|
|
80388
80370
|
}
|
|
80389
80371
|
const entries = [];
|
|
80390
80372
|
for (const name of names.filter((item) => item.endsWith(".json")).toSorted()) {
|
|
80391
|
-
const file =
|
|
80373
|
+
const file = path58.join(queueDir(dir), name);
|
|
80392
80374
|
const record = parseLease(readText6(file));
|
|
80393
80375
|
if (!record)
|
|
80394
80376
|
continue;
|
|
@@ -80404,9 +80386,9 @@ function leaseQueue(dir, probe = {}) {
|
|
|
80404
80386
|
function waitersAhead(options, own) {
|
|
80405
80387
|
let ahead = 0;
|
|
80406
80388
|
for (const entry of leaseQueue(options.dir, options.probe)) {
|
|
80407
|
-
if (
|
|
80389
|
+
if (path58.basename(entry.file) >= own)
|
|
80408
80390
|
break;
|
|
80409
|
-
if (!TICKET.test(
|
|
80391
|
+
if (!TICKET.test(path58.basename(entry.file)))
|
|
80410
80392
|
continue;
|
|
80411
80393
|
if (entry.stale && reclaim(entry.file, (current) => !current || staleReason(current, options.probe) !== null))
|
|
80412
80394
|
continue;
|
|
@@ -80418,7 +80400,7 @@ function liveHolders(options) {
|
|
|
80418
80400
|
return leaseSlots(options.dir, options.slots, options.probe).filter((slot) => slot.holder && !slot.stale).map((slot) => slot.holder);
|
|
80419
80401
|
}
|
|
80420
80402
|
function writeTicket(file, record) {
|
|
80421
|
-
fs24.mkdirSync(
|
|
80403
|
+
fs24.mkdirSync(path58.dirname(file), { recursive: true, mode: 448 });
|
|
80422
80404
|
fs24.writeFileSync(file, `${JSON.stringify(record)}
|
|
80423
80405
|
`, { mode: 384 });
|
|
80424
80406
|
}
|
|
@@ -80463,7 +80445,7 @@ async function acquireLease(options) {
|
|
|
80463
80445
|
const reclaimed = [];
|
|
80464
80446
|
let waitedOn = [];
|
|
80465
80447
|
const name = ticketName(started, record.id);
|
|
80466
|
-
const ticket =
|
|
80448
|
+
const ticket = path58.join(queueDir(options.dir), name);
|
|
80467
80449
|
const ticketRecord = {
|
|
80468
80450
|
...record,
|
|
80469
80451
|
maxAgeMs: options.waitMs + 60000
|
|
@@ -80584,7 +80566,7 @@ function heldLease(dir, id, options = {}) {
|
|
|
80584
80566
|
for (const name of names) {
|
|
80585
80567
|
if (!/^slot-\d+\.json$/u.test(name))
|
|
80586
80568
|
continue;
|
|
80587
|
-
const lease = parseLease(readText6(
|
|
80569
|
+
const lease = parseLease(readText6(path58.join(dir, name)));
|
|
80588
80570
|
if (lease?.id === id && !staleReason(lease, options.probe) && (options.ancestor ?? isAncestor)(lease.pid))
|
|
80589
80571
|
return lease;
|
|
80590
80572
|
}
|
|
@@ -80639,10 +80621,10 @@ async function runScoped(run, wrapper, sinks) {
|
|
|
80639
80621
|
}
|
|
80640
80622
|
function firstNotice(env, session, key, now = Date.now()) {
|
|
80641
80623
|
const id = (session ?? `ppid-${process.ppid}`).replace(/[^A-Za-z0-9_.-]/gu, "_").slice(0, 120);
|
|
80642
|
-
const dir =
|
|
80624
|
+
const dir = path58.join(stateDir2(env), "notices");
|
|
80643
80625
|
try {
|
|
80644
80626
|
fs24.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
80645
|
-
fs24.writeFileSync(
|
|
80627
|
+
fs24.writeFileSync(path58.join(dir, `${key}-${id}`), `${new Date(now).toISOString()}
|
|
80646
80628
|
`, {
|
|
80647
80629
|
flag: "wx",
|
|
80648
80630
|
mode: 384
|
|
@@ -80652,7 +80634,7 @@ function firstNotice(env, session, key, now = Date.now()) {
|
|
|
80652
80634
|
}
|
|
80653
80635
|
try {
|
|
80654
80636
|
for (const name of fs24.readdirSync(dir)) {
|
|
80655
|
-
const file =
|
|
80637
|
+
const file = path58.join(dir, name);
|
|
80656
80638
|
if (now - fs24.statSync(file).mtimeMs > NOTICE_TTL_MS)
|
|
80657
80639
|
fs24.rmSync(file, { force: true });
|
|
80658
80640
|
}
|
|
@@ -80662,7 +80644,7 @@ function firstNotice(env, session, key, now = Date.now()) {
|
|
|
80662
80644
|
function leaseSlots(dir, slots, probe = {}) {
|
|
80663
80645
|
const states = [];
|
|
80664
80646
|
for (let slot = 0;slot < slots; slot += 1) {
|
|
80665
|
-
const lease = parseLease(readText6(
|
|
80647
|
+
const lease = parseLease(readText6(path58.join(dir, `slot-${slot}.json`)));
|
|
80666
80648
|
states.push({
|
|
80667
80649
|
slot,
|
|
80668
80650
|
holder: lease ? holderOf(lease) : null,
|
|
@@ -80674,7 +80656,7 @@ function leaseSlots(dir, slots, probe = {}) {
|
|
|
80674
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 = () => ({
|
|
80675
80657
|
totalMemBytes: os24.totalmem(),
|
|
80676
80658
|
cpus: Math.max(1, os24.availableParallelism?.() ?? os24.cpus().length)
|
|
80677
|
-
}), 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) => {
|
|
80678
80660
|
try {
|
|
80679
80661
|
return fs24.readFileSync(file, "utf8");
|
|
80680
80662
|
} catch {
|
|
@@ -80705,7 +80687,7 @@ var DEFAULT_HEAVY_CHECKS, DEFAULT_LIGHT_CHECKS, DEFAULT_SLOTS = 1, DEFAULT_WAIT_
|
|
|
80705
80687
|
cwd: lease.cwd,
|
|
80706
80688
|
session: lease.session,
|
|
80707
80689
|
startedAt: lease.startedAt
|
|
80708
|
-
}), 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;
|
|
80709
80691
|
var init_resources = __esm(() => {
|
|
80710
80692
|
init_checks3();
|
|
80711
80693
|
init_heavy();
|
|
@@ -80735,7 +80717,7 @@ __export(exports_check, {
|
|
|
80735
80717
|
workspaceResources: () => workspaceResources
|
|
80736
80718
|
});
|
|
80737
80719
|
import os25 from "node:os";
|
|
80738
|
-
import
|
|
80720
|
+
import path59 from "node:path";
|
|
80739
80721
|
function parse6(argv) {
|
|
80740
80722
|
const split = argv.indexOf("--");
|
|
80741
80723
|
const head = split >= 0 ? argv.slice(0, split) : [...argv];
|
|
@@ -80966,7 +80948,7 @@ ${footer}`;
|
|
|
80966
80948
|
}
|
|
80967
80949
|
async function workspaceResources(io) {
|
|
80968
80950
|
const env = io.env;
|
|
80969
|
-
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");
|
|
80970
80952
|
try {
|
|
80971
80953
|
await Promise.resolve().then(() => init_workspaces());
|
|
80972
80954
|
const workspace = resolveWorkspaceFrom(io.cwd, dir, env.WORKFLOW_WORKSPACE_NAME?.trim() || undefined);
|
|
@@ -81108,7 +81090,7 @@ async function run12(argv, io) {
|
|
|
81108
81090
|
if (options.shell && command.length !== 1)
|
|
81109
81091
|
return emit(io, fail2("invalid_input", '--shell takes the command as one string: workit check --shell -- "<cmd>"'));
|
|
81110
81092
|
}
|
|
81111
|
-
const relCwd = posix(
|
|
81093
|
+
const relCwd = posix(path59.relative(top, runCwd));
|
|
81112
81094
|
const configured = !options.shell && matchesNamedCheck(config, name, command, relCwd);
|
|
81113
81095
|
const shadowed = !configured && name !== null ? config.checks.find((item) => item.name === name) : undefined;
|
|
81114
81096
|
if (shadowed)
|
|
@@ -81173,7 +81155,7 @@ async function run12(argv, io) {
|
|
|
81173
81155
|
const modifiedWorktree = key.tree !== null && treeAfter !== key.tree;
|
|
81174
81156
|
const store = storeRoot(io.cwd);
|
|
81175
81157
|
const blob = store.ok ? storeLog(store.value.root, result.log) : null;
|
|
81176
|
-
const logPath = store.ok && blob ?
|
|
81158
|
+
const logPath = store.ok && blob ? path59.join(store.value.root, blob.ref) : null;
|
|
81177
81159
|
const tail = tailLines(result.log, TAIL_LINES);
|
|
81178
81160
|
const passed = result.exitCode === 0 && !result.timedOut;
|
|
81179
81161
|
const bounded = boundedArgv(command);
|
|
@@ -81288,7 +81270,7 @@ async function run12(argv, io) {
|
|
|
81288
81270
|
return recordError.code === "busy" ? 4 : recordError.code === "invalid_input" ? 2 : 5;
|
|
81289
81271
|
return 0;
|
|
81290
81272
|
}
|
|
81291
|
-
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;
|
|
81292
81274
|
var init_check2 = __esm(() => {
|
|
81293
81275
|
init_check_config();
|
|
81294
81276
|
init_checks3();
|
|
@@ -81319,7 +81301,7 @@ __export(exports_lock, {
|
|
|
81319
81301
|
run: () => run13
|
|
81320
81302
|
});
|
|
81321
81303
|
import fs25 from "node:fs";
|
|
81322
|
-
import
|
|
81304
|
+
import path60 from "node:path";
|
|
81323
81305
|
async function settingsFor(io) {
|
|
81324
81306
|
const workspace = await workspaceResources(io);
|
|
81325
81307
|
const config = loadCheckConfig(io.cwd);
|
|
@@ -81411,7 +81393,7 @@ function readPatterns(file) {
|
|
|
81411
81393
|
return { patterns: [] };
|
|
81412
81394
|
}
|
|
81413
81395
|
function writePatterns(file, value) {
|
|
81414
|
-
fs25.mkdirSync(
|
|
81396
|
+
fs25.mkdirSync(path60.dirname(file), { recursive: true, mode: 448 });
|
|
81415
81397
|
const temp = `${file}.${process.pid}.tmp`;
|
|
81416
81398
|
fs25.writeFileSync(temp, `${JSON.stringify(value, null, 2)}
|
|
81417
81399
|
`, { mode: 384 });
|
|
@@ -81497,9 +81479,9 @@ var exports_models = {};
|
|
|
81497
81479
|
__export(exports_models, {
|
|
81498
81480
|
run: () => run14
|
|
81499
81481
|
});
|
|
81500
|
-
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";
|
|
81501
81483
|
import os26 from "node:os";
|
|
81502
|
-
import
|
|
81484
|
+
import path61 from "node:path";
|
|
81503
81485
|
async function run14(argv, io) {
|
|
81504
81486
|
const [sub, ...args] = argv.filter((arg) => arg !== "--json");
|
|
81505
81487
|
if (sub !== "show")
|
|
@@ -81560,7 +81542,7 @@ var USAGE8 = "workit models show [--role <role>] [--tier <tier>] [--host <host>]
|
|
|
81560
81542
|
const found = new Set;
|
|
81561
81543
|
let text = "";
|
|
81562
81544
|
try {
|
|
81563
|
-
text =
|
|
81545
|
+
text = readFileSync27(file, "utf8");
|
|
81564
81546
|
} catch {
|
|
81565
81547
|
return found;
|
|
81566
81548
|
}
|
|
@@ -81574,24 +81556,24 @@ var USAGE8 = "workit models show [--role <role>] [--tier <tier>] [--host <host>]
|
|
|
81574
81556
|
} catch {}
|
|
81575
81557
|
return found;
|
|
81576
81558
|
}, matches3 = (ran, configured) => ran.toLowerCase().includes(configured.toLowerCase()), usageReport = (cwd, env, days) => {
|
|
81577
|
-
const projects =
|
|
81559
|
+
const projects = path61.join(env.CLAUDE_CONFIG_DIR || path61.join(env.HOME || os26.homedir(), ".claude"), "projects");
|
|
81578
81560
|
const since = Date.now() - days * 86400000;
|
|
81579
81561
|
const types = {};
|
|
81580
81562
|
let agents = 0;
|
|
81581
81563
|
const dirs = (dir) => {
|
|
81582
81564
|
try {
|
|
81583
|
-
return readdirSync13(dir).map((name) =>
|
|
81565
|
+
return readdirSync13(dir).map((name) => path61.join(dir, name));
|
|
81584
81566
|
} catch {
|
|
81585
81567
|
return [];
|
|
81586
81568
|
}
|
|
81587
81569
|
};
|
|
81588
81570
|
for (const project of dirs(projects))
|
|
81589
81571
|
for (const session of dirs(project))
|
|
81590
|
-
for (const meta of dirs(
|
|
81572
|
+
for (const meta of dirs(path61.join(session, "subagents")).filter((f) => f.endsWith(".meta.json"))) {
|
|
81591
81573
|
try {
|
|
81592
81574
|
if (statSync10(meta).mtimeMs < since)
|
|
81593
81575
|
continue;
|
|
81594
|
-
const agentType = JSON.parse(
|
|
81576
|
+
const agentType = JSON.parse(readFileSync27(meta, "utf8")).agentType;
|
|
81595
81577
|
const transcript = meta.replace(/\.meta\.json$/, ".jsonl");
|
|
81596
81578
|
if (typeof agentType !== "string" || !existsSync26(transcript))
|
|
81597
81579
|
continue;
|
|
@@ -81732,8 +81714,8 @@ var success2 = (data) => ({ ok: true, data }), failure3 = (code, error, unblock)
|
|
|
81732
81714
|
|
|
81733
81715
|
// packages/workit-core/src/git/ops.ts
|
|
81734
81716
|
import { spawnSync as spawnSync22 } from "node:child_process";
|
|
81735
|
-
import { copyFileSync as copyFileSync8, existsSync as existsSync27, readdirSync as readdirSync14, readFileSync as
|
|
81736
|
-
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";
|
|
81737
81719
|
function operationInProgress(cwd) {
|
|
81738
81720
|
const markers = [
|
|
81739
81721
|
["rebase-merge", "rebase"],
|
|
@@ -81746,18 +81728,18 @@ function operationInProgress(cwd) {
|
|
|
81746
81728
|
if (!run.ok)
|
|
81747
81729
|
return null;
|
|
81748
81730
|
const found = run.stdout.split(`
|
|
81749
|
-
`).map((line) =>
|
|
81731
|
+
`).map((line) => path62.resolve(cwd, line.trim()));
|
|
81750
81732
|
const conflicted = () => git5(cwd, ["ls-files", "-u"]).stdout.trim() !== "";
|
|
81751
81733
|
for (const [index, [, operation]] of markers.entries()) {
|
|
81752
81734
|
const marker = found[index];
|
|
81753
81735
|
if (!marker || !existsSync27(marker))
|
|
81754
81736
|
continue;
|
|
81755
|
-
if (index === 1 && existsSync27(
|
|
81737
|
+
if (index === 1 && existsSync27(path62.join(marker, "applying")))
|
|
81756
81738
|
return { operation: "am", commitAllowed: false, branch: null };
|
|
81757
|
-
if (index === 0 && existsSync27(
|
|
81739
|
+
if (index === 0 && existsSync27(path62.join(marker, "amend")) && !conflicted()) {
|
|
81758
81740
|
let headName = "";
|
|
81759
81741
|
try {
|
|
81760
|
-
headName =
|
|
81742
|
+
headName = readFileSync28(path62.join(marker, "head-name"), "utf8").trim();
|
|
81761
81743
|
} catch {}
|
|
81762
81744
|
const branch = headName.startsWith("refs/heads/") ? headName.slice("refs/heads/".length) : null;
|
|
81763
81745
|
return { operation, commitAllowed: branch !== null, branch };
|
|
@@ -82022,13 +82004,13 @@ function sweepPrivateIndexes(dir) {
|
|
|
82022
82004
|
const pid = Number(match[1]);
|
|
82023
82005
|
const stale = Date.now() - Number(match[2]) > PRIVATE_INDEX_TTL_MS || pid !== process.pid && !processAlive(pid);
|
|
82024
82006
|
if (stale)
|
|
82025
|
-
rmSync11(
|
|
82007
|
+
rmSync11(path62.join(dir, name), { force: true });
|
|
82026
82008
|
}
|
|
82027
82009
|
}
|
|
82028
82010
|
function pathCommitIndex(cwd, paths, env) {
|
|
82029
|
-
const where = (name) =>
|
|
82011
|
+
const where = (name) => path62.resolve(cwd, git5(cwd, ["rev-parse", "--git-path", name]).stdout.trim());
|
|
82030
82012
|
const file = where(`workit-commit-${process.pid}-${Date.now()}.index`);
|
|
82031
|
-
sweepPrivateIndexes(
|
|
82013
|
+
sweepPrivateIndexes(path62.dirname(file));
|
|
82032
82014
|
try {
|
|
82033
82015
|
copyFileSync8(where("index"), file);
|
|
82034
82016
|
} catch (error) {
|
|
@@ -82149,7 +82131,7 @@ function gitCommit(cwd, input) {
|
|
|
82149
82131
|
const partial = new Set(keptPartial);
|
|
82150
82132
|
const top = git5(cwd, ["rev-parse", "--show-prefix"]).stdout.trim();
|
|
82151
82133
|
const tracked = new Set(nulList(git5(cwd, ["ls-files", "-z", "--", ...paths]).stdout));
|
|
82152
|
-
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}/`))));
|
|
82153
82135
|
if (addable.length) {
|
|
82154
82136
|
const added = git5(cwd, [
|
|
82155
82137
|
"add",
|
|
@@ -82724,12 +82706,12 @@ var init_ops = __esm(() => {
|
|
|
82724
82706
|
|
|
82725
82707
|
// packages/workit-core/src/verdict-cover.ts
|
|
82726
82708
|
import fs26 from "node:fs";
|
|
82727
|
-
import
|
|
82709
|
+
import path63 from "node:path";
|
|
82728
82710
|
function chainsAbove(cwd, branch) {
|
|
82729
82711
|
const root = storeRoot(cwd);
|
|
82730
82712
|
if (!root.ok)
|
|
82731
82713
|
return [];
|
|
82732
|
-
const dir =
|
|
82714
|
+
const dir = path63.join(root.value.root, "stacks");
|
|
82733
82715
|
let names = [];
|
|
82734
82716
|
try {
|
|
82735
82717
|
names = fs26.readdirSync(dir).filter((name) => name.endsWith(".json"));
|
|
@@ -82740,7 +82722,7 @@ function chainsAbove(cwd, branch) {
|
|
|
82740
82722
|
for (const name of names.toSorted()) {
|
|
82741
82723
|
let parsed;
|
|
82742
82724
|
try {
|
|
82743
|
-
parsed = JSON.parse(fs26.readFileSync(
|
|
82725
|
+
parsed = JSON.parse(fs26.readFileSync(path63.join(dir, name), "utf8"));
|
|
82744
82726
|
} catch {
|
|
82745
82727
|
continue;
|
|
82746
82728
|
}
|
|
@@ -82896,10 +82878,10 @@ var init_check_evidence = __esm(() => {
|
|
|
82896
82878
|
|
|
82897
82879
|
// packages/workit-core/src/forge/reruns.ts
|
|
82898
82880
|
import fs27 from "node:fs";
|
|
82899
|
-
import
|
|
82881
|
+
import path64 from "node:path";
|
|
82900
82882
|
function rerunLogPath(cwd) {
|
|
82901
82883
|
const common = gitCommonDir(cwd);
|
|
82902
|
-
return common ?
|
|
82884
|
+
return common ? path64.join(common, "workit", "ci-reruns.jsonl") : null;
|
|
82903
82885
|
}
|
|
82904
82886
|
function rerunCounts(cwd, key) {
|
|
82905
82887
|
const counts = new Map;
|
|
@@ -82934,7 +82916,7 @@ function recordReruns(cwd, rows) {
|
|
|
82934
82916
|
if (!file)
|
|
82935
82917
|
return false;
|
|
82936
82918
|
try {
|
|
82937
|
-
fs27.mkdirSync(
|
|
82919
|
+
fs27.mkdirSync(path64.dirname(file), { recursive: true });
|
|
82938
82920
|
fs27.appendFileSync(file, rows.map((row) => `${JSON.stringify(row)}
|
|
82939
82921
|
`).join(""));
|
|
82940
82922
|
return true;
|
|
@@ -82947,7 +82929,7 @@ function withRerunLock(cwd, fn) {
|
|
|
82947
82929
|
if (!file)
|
|
82948
82930
|
return fn();
|
|
82949
82931
|
const lock = `${file.slice(0, -".jsonl".length)}.lock`;
|
|
82950
|
-
fs27.mkdirSync(
|
|
82932
|
+
fs27.mkdirSync(path64.dirname(lock), { recursive: true });
|
|
82951
82933
|
const until = Date.now() + LOCK_WAIT_MS2;
|
|
82952
82934
|
for (;; ) {
|
|
82953
82935
|
try {
|
|
@@ -83944,7 +83926,7 @@ var init_pr_ops = __esm(() => {
|
|
|
83944
83926
|
import { spawnSync as spawnSync24 } from "node:child_process";
|
|
83945
83927
|
import { createHash as createHash18, randomBytes as randomBytes4 } from "node:crypto";
|
|
83946
83928
|
import fs28 from "node:fs";
|
|
83947
|
-
import
|
|
83929
|
+
import path65 from "node:path";
|
|
83948
83930
|
function worktreeOf(cwd, branch) {
|
|
83949
83931
|
const list = gitRun3(cwd, ["worktree", "list", "--porcelain"]);
|
|
83950
83932
|
if (!list.ok)
|
|
@@ -83993,7 +83975,7 @@ function gitRestack(cwd, input) {
|
|
|
83993
83975
|
error: "no store root"
|
|
83994
83976
|
};
|
|
83995
83977
|
fs28.mkdirSync(scratch, { recursive: true });
|
|
83996
|
-
dir =
|
|
83978
|
+
dir = path65.join(scratch, `${input.branch.replace(/[^A-Za-z0-9._-]+/gu, "_").slice(0, 40)}-${randomBytes4(4).toString("hex")}`);
|
|
83997
83979
|
const added = gitRun3(cwd, ["worktree", "add", "-q", dir, input.branch], GIT_TIMEOUTS.worktree);
|
|
83998
83980
|
if (!added.ok)
|
|
83999
83981
|
return {
|
|
@@ -84049,7 +84031,7 @@ function pruneScratch(cwd) {
|
|
|
84049
84031
|
if (!scratch || !fs28.existsSync(scratch))
|
|
84050
84032
|
return;
|
|
84051
84033
|
for (const name of fs28.readdirSync(scratch)) {
|
|
84052
|
-
const dir =
|
|
84034
|
+
const dir = path65.join(scratch, name);
|
|
84053
84035
|
if (!rebaseInProgress(dir) && !trackedDirt(dir))
|
|
84054
84036
|
gitRun3(cwd, ["worktree", "remove", "--force", dir]);
|
|
84055
84037
|
}
|
|
@@ -84059,7 +84041,7 @@ function stacksDir(cwd) {
|
|
|
84059
84041
|
const root = storeRoot(cwd);
|
|
84060
84042
|
if (!root.ok)
|
|
84061
84043
|
return stackFail(root.code, root.error, root.unblock);
|
|
84062
|
-
return { ok: true, data:
|
|
84044
|
+
return { ok: true, data: path65.join(root.value.root, "stacks") };
|
|
84063
84045
|
}
|
|
84064
84046
|
function parseStack(raw) {
|
|
84065
84047
|
if (!isRecord12(raw) || !Array.isArray(raw.branches))
|
|
@@ -84111,7 +84093,7 @@ function readStack(cwd, name) {
|
|
|
84111
84093
|
const dir = stacksDir(cwd);
|
|
84112
84094
|
if (!dir.ok)
|
|
84113
84095
|
return dir;
|
|
84114
|
-
const file =
|
|
84096
|
+
const file = path65.join(dir.data, fileFor(name));
|
|
84115
84097
|
let text;
|
|
84116
84098
|
try {
|
|
84117
84099
|
text = fs28.readFileSync(file, "utf8");
|
|
@@ -84132,7 +84114,7 @@ function writeStack(cwd, stack, now = new Date) {
|
|
|
84132
84114
|
const dir = stacksDir(cwd);
|
|
84133
84115
|
if (!dir.ok)
|
|
84134
84116
|
return dir;
|
|
84135
|
-
const file =
|
|
84117
|
+
const file = path65.join(dir.data, fileFor(stack.name));
|
|
84136
84118
|
const temp = `${file}.${process.pid}.tmp`;
|
|
84137
84119
|
try {
|
|
84138
84120
|
fs28.mkdirSync(dir.data, { recursive: true });
|
|
@@ -84160,7 +84142,7 @@ function listStacks(cwd) {
|
|
|
84160
84142
|
for (const name of names) {
|
|
84161
84143
|
let parsed = null;
|
|
84162
84144
|
try {
|
|
84163
|
-
parsed = parseStack(JSON.parse(fs28.readFileSync(
|
|
84145
|
+
parsed = parseStack(JSON.parse(fs28.readFileSync(path65.join(dir.data, name), "utf8")));
|
|
84164
84146
|
} catch {
|
|
84165
84147
|
parsed = null;
|
|
84166
84148
|
}
|
|
@@ -84222,7 +84204,7 @@ function takeLock(lock) {
|
|
|
84222
84204
|
host: localLockHost(),
|
|
84223
84205
|
nonce: randomBytes4(8).toString("hex")
|
|
84224
84206
|
};
|
|
84225
|
-
fs28.writeFileSync(
|
|
84207
|
+
fs28.writeFileSync(path65.join(lock, OWNER), JSON.stringify(owner));
|
|
84226
84208
|
return owner;
|
|
84227
84209
|
}
|
|
84228
84210
|
function reapLock(lock, observed) {
|
|
@@ -84259,7 +84241,7 @@ async function withStackLock(cwd, name, fn, waitMs = LOCK_WAIT_MS3) {
|
|
|
84259
84241
|
return dir;
|
|
84260
84242
|
if (!validName(name))
|
|
84261
84243
|
return stackFail("invalid_input", "a stack name must be 1-200 printable characters");
|
|
84262
|
-
const lock =
|
|
84244
|
+
const lock = path65.join(dir.data, `${fileFor(name)}.lock`);
|
|
84263
84245
|
try {
|
|
84264
84246
|
fs28.mkdirSync(dir.data, { recursive: true });
|
|
84265
84247
|
} catch (error) {
|
|
@@ -84289,7 +84271,7 @@ async function withStackLock(cwd, name, fn, waitMs = LOCK_WAIT_MS3) {
|
|
|
84289
84271
|
const touch = () => {
|
|
84290
84272
|
try {
|
|
84291
84273
|
const now = new Date;
|
|
84292
|
-
fs28.utimesSync(
|
|
84274
|
+
fs28.utimesSync(path65.join(lock, OWNER), now, now);
|
|
84293
84275
|
} catch {}
|
|
84294
84276
|
};
|
|
84295
84277
|
const beat = setInterval(touch, HEARTBEAT_MS);
|
|
@@ -85261,7 +85243,7 @@ var STACK_VERSION = 1, stackFail = (code, error, unblock, data) => ({
|
|
|
85261
85243
|
return !status.ok || status.stdout.trim() !== "";
|
|
85262
85244
|
}, scratchDir = (cwd) => {
|
|
85263
85245
|
const dir = stacksDir(cwd);
|
|
85264
|
-
return dir.ok ?
|
|
85246
|
+
return dir.ok ? path65.join(dir.data, "worktrees") : null;
|
|
85265
85247
|
}, firstLine = (run) => (`${run.stderr}
|
|
85266
85248
|
${run.stdout}`.split(`
|
|
85267
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) => {
|
|
@@ -85276,12 +85258,12 @@ ${run.stdout}`.split(`
|
|
|
85276
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) => {
|
|
85277
85259
|
let raw = null;
|
|
85278
85260
|
try {
|
|
85279
|
-
raw = fs28.readFileSync(
|
|
85261
|
+
raw = fs28.readFileSync(path65.join(lock, OWNER), "utf8");
|
|
85280
85262
|
} catch {
|
|
85281
85263
|
raw = null;
|
|
85282
85264
|
}
|
|
85283
85265
|
let age = null;
|
|
85284
|
-
for (const target of [
|
|
85266
|
+
for (const target of [path65.join(lock, OWNER), lock])
|
|
85285
85267
|
try {
|
|
85286
85268
|
age = Date.now() - fs28.statSync(target).mtimeMs;
|
|
85287
85269
|
break;
|
|
@@ -85326,7 +85308,7 @@ var init_stack = __esm(() => {
|
|
|
85326
85308
|
import { spawnSync as spawnSync25 } from "node:child_process";
|
|
85327
85309
|
import { createHash as createHash19 } from "node:crypto";
|
|
85328
85310
|
import fs29 from "node:fs";
|
|
85329
|
-
import
|
|
85311
|
+
import path66 from "node:path";
|
|
85330
85312
|
function expandBraces2(pattern, limit = 64) {
|
|
85331
85313
|
for (let index = 0;index < pattern.length; index += 1) {
|
|
85332
85314
|
if (pattern[index] === "\\") {
|
|
@@ -85572,7 +85554,7 @@ function parsePlan(raw, defaults, name) {
|
|
|
85572
85554
|
id,
|
|
85573
85555
|
branch,
|
|
85574
85556
|
base: optional("base") ?? "",
|
|
85575
|
-
worktree:
|
|
85557
|
+
worktree: path66.resolve(defaults.root, optional("worktree") ?? path66.join(defaults.worktreeRoot, id)),
|
|
85576
85558
|
tier,
|
|
85577
85559
|
reason,
|
|
85578
85560
|
dependsOn: [...new Set(dependsOn ?? [])],
|
|
@@ -85701,12 +85683,12 @@ function regeneratedFiles(root, tracked) {
|
|
|
85701
85683
|
const found = new Map;
|
|
85702
85684
|
let scripts;
|
|
85703
85685
|
try {
|
|
85704
|
-
const manifest = JSON.parse(fs29.readFileSync(
|
|
85686
|
+
const manifest = JSON.parse(fs29.readFileSync(path66.join(root, "package.json"), "utf8"));
|
|
85705
85687
|
scripts = manifest.scripts ?? {};
|
|
85706
85688
|
} catch {
|
|
85707
85689
|
return found;
|
|
85708
85690
|
}
|
|
85709
|
-
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";
|
|
85710
85692
|
const outputs = tracked.filter((file) => !CODE.test(file));
|
|
85711
85693
|
for (const [name, command] of Object.entries(scripts)) {
|
|
85712
85694
|
if (!name.startsWith("write:") || typeof command !== "string")
|
|
@@ -85714,7 +85696,7 @@ function regeneratedFiles(root, tracked) {
|
|
|
85714
85696
|
for (const file of command.match(/[\w./-]+\.[cm]?[jt]s\b/gu) ?? []) {
|
|
85715
85697
|
let source;
|
|
85716
85698
|
try {
|
|
85717
|
-
source = fs29.readFileSync(
|
|
85699
|
+
source = fs29.readFileSync(path66.join(root, file), "utf8");
|
|
85718
85700
|
} catch {
|
|
85719
85701
|
continue;
|
|
85720
85702
|
}
|
|
@@ -85836,11 +85818,11 @@ function defaultTrunk(cwd) {
|
|
|
85836
85818
|
}
|
|
85837
85819
|
function mainCheckout(cwd) {
|
|
85838
85820
|
const common = gitCommonDir(cwd);
|
|
85839
|
-
return common &&
|
|
85821
|
+
return common && path66.basename(common) === ".git" ? path66.dirname(common) : path66.resolve(cwd);
|
|
85840
85822
|
}
|
|
85841
85823
|
function worktreeRoot(cwd) {
|
|
85842
85824
|
const main = mainCheckout(cwd);
|
|
85843
|
-
return
|
|
85825
|
+
return path66.join(path66.dirname(main), `${path66.basename(main)}-wt`);
|
|
85844
85826
|
}
|
|
85845
85827
|
function sliceHash(slice) {
|
|
85846
85828
|
const {
|
|
@@ -85860,7 +85842,7 @@ function fanoutsDir(cwd) {
|
|
|
85860
85842
|
const root = storeRoot(cwd);
|
|
85861
85843
|
if (!root.ok)
|
|
85862
85844
|
return fanoutFail(root.code, root.error, root.unblock);
|
|
85863
|
-
return { ok: true, data:
|
|
85845
|
+
return { ok: true, data: path66.join(root.value.root, "fanouts") };
|
|
85864
85846
|
}
|
|
85865
85847
|
function parseStored(raw) {
|
|
85866
85848
|
if (!isRecord13(raw) || typeof raw.name !== "string" || typeof raw.trunk !== "string")
|
|
@@ -85928,7 +85910,7 @@ function readFanout(cwd, name) {
|
|
|
85928
85910
|
const dir = fanoutsDir(cwd);
|
|
85929
85911
|
if (!dir.ok)
|
|
85930
85912
|
return dir;
|
|
85931
|
-
const file =
|
|
85913
|
+
const file = path66.join(dir.data, stackFileName(name));
|
|
85932
85914
|
let parsed = null;
|
|
85933
85915
|
try {
|
|
85934
85916
|
parsed = parseStored(JSON.parse(fs29.readFileSync(file, "utf8")));
|
|
@@ -85953,7 +85935,7 @@ function listFanouts(cwd) {
|
|
|
85953
85935
|
for (const entry of names) {
|
|
85954
85936
|
let parsed = null;
|
|
85955
85937
|
try {
|
|
85956
|
-
parsed = parseStored(JSON.parse(fs29.readFileSync(
|
|
85938
|
+
parsed = parseStored(JSON.parse(fs29.readFileSync(path66.join(dir.data, entry), "utf8")));
|
|
85957
85939
|
} catch {
|
|
85958
85940
|
parsed = null;
|
|
85959
85941
|
}
|
|
@@ -85992,7 +85974,7 @@ function writeFanout(cwd, plan) {
|
|
|
85992
85974
|
const dir = fanoutsDir(cwd);
|
|
85993
85975
|
if (!dir.ok)
|
|
85994
85976
|
return dir;
|
|
85995
|
-
const file =
|
|
85977
|
+
const file = path66.join(dir.data, stackFileName(plan.name));
|
|
85996
85978
|
const temp = `${file}.${process.pid}.tmp`;
|
|
85997
85979
|
try {
|
|
85998
85980
|
fs29.mkdirSync(dir.data, { recursive: true });
|
|
@@ -86203,13 +86185,13 @@ var init_fanout = __esm(() => {
|
|
|
86203
86185
|
// packages/workit-core/src/forge/exec.ts
|
|
86204
86186
|
import { spawnSync as spawnSync26 } from "node:child_process";
|
|
86205
86187
|
import fs30 from "node:fs";
|
|
86206
|
-
import
|
|
86188
|
+
import path67 from "node:path";
|
|
86207
86189
|
function findExecutable(bin, env) {
|
|
86208
|
-
const dirs = (env.PATH ?? env.Path ?? "").split(
|
|
86190
|
+
const dirs = (env.PATH ?? env.Path ?? "").split(path67.delimiter).filter(Boolean);
|
|
86209
86191
|
const exts = process.platform === "win32" ? [".exe"] : [""];
|
|
86210
86192
|
for (const dir of dirs)
|
|
86211
86193
|
for (const ext of exts) {
|
|
86212
|
-
const candidate =
|
|
86194
|
+
const candidate = path67.join(dir, `${bin}${ext}`);
|
|
86213
86195
|
try {
|
|
86214
86196
|
const stat = fs30.statSync(candidate);
|
|
86215
86197
|
if (stat.isFile())
|
|
@@ -87999,7 +87981,7 @@ var init_live_session = __esm(() => {
|
|
|
87999
87981
|
});
|
|
88000
87982
|
|
|
88001
87983
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
88002
|
-
import
|
|
87984
|
+
import path68 from "node:path";
|
|
88003
87985
|
var CASE_INSENSITIVE, PREFIXES2, SCRIPT_SHELLS, cache3, MUTATING_GIT, DRY_N, MUTATING_WORKIT_GIT, CD2, PUSHD2, POPD2, UNKNOWN_DIR;
|
|
88004
87986
|
var init_write_gate = __esm(() => {
|
|
88005
87987
|
init_task_store();
|
|
@@ -88039,7 +88021,7 @@ var init_write_gate = __esm(() => {
|
|
|
88039
88021
|
CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
|
|
88040
88022
|
PUSHD2 = new Set(["pushd", "push-location"]);
|
|
88041
88023
|
POPD2 = new Set(["popd", "pop-location"]);
|
|
88042
|
-
UNKNOWN_DIR =
|
|
88024
|
+
UNKNOWN_DIR = path68.resolve(path68.parse(process.cwd()).root, ".workit-unknown-dir");
|
|
88043
88025
|
});
|
|
88044
88026
|
|
|
88045
88027
|
// packages/workit-core/src/hooks/worktree-confine.ts
|
|
@@ -88064,20 +88046,20 @@ var init_worktree_confine = __esm(() => {
|
|
|
88064
88046
|
|
|
88065
88047
|
// packages/workit-core/src/worktree-deps.ts
|
|
88066
88048
|
import fs31 from "node:fs";
|
|
88067
|
-
import
|
|
88049
|
+
import path69 from "node:path";
|
|
88068
88050
|
function moduleDirs(main) {
|
|
88069
88051
|
const out = [];
|
|
88070
88052
|
const walk = (relative, depth) => {
|
|
88071
88053
|
let entries;
|
|
88072
88054
|
try {
|
|
88073
|
-
entries = fs31.readdirSync(
|
|
88055
|
+
entries = fs31.readdirSync(path69.join(main, relative), { withFileTypes: true });
|
|
88074
88056
|
} catch {
|
|
88075
88057
|
return;
|
|
88076
88058
|
}
|
|
88077
88059
|
for (const entry of entries) {
|
|
88078
88060
|
if (!entry.isDirectory())
|
|
88079
88061
|
continue;
|
|
88080
|
-
const child =
|
|
88062
|
+
const child = path69.join(relative, entry.name);
|
|
88081
88063
|
if (entry.name === MODULES)
|
|
88082
88064
|
out.push(child);
|
|
88083
88065
|
else if (depth < MAX_DEPTH2 && !entry.name.startsWith("."))
|
|
@@ -88091,8 +88073,8 @@ function linkEntry(main, worktree, source, target) {
|
|
|
88091
88073
|
const stat = fs31.lstatSync(source);
|
|
88092
88074
|
if (stat.isSymbolicLink()) {
|
|
88093
88075
|
const link = fs31.readlinkSync(source);
|
|
88094
|
-
const outside =
|
|
88095
|
-
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;
|
|
88096
88078
|
fs31.symlinkSync(to, target, process.platform === "win32" ? "junction" : undefined);
|
|
88097
88079
|
return;
|
|
88098
88080
|
}
|
|
@@ -88102,8 +88084,8 @@ function mirror(main, worktree, source, target, top) {
|
|
|
88102
88084
|
fs31.mkdirSync(target);
|
|
88103
88085
|
let count = 0;
|
|
88104
88086
|
for (const entry of fs31.readdirSync(source, { withFileTypes: true })) {
|
|
88105
|
-
const from =
|
|
88106
|
-
const to =
|
|
88087
|
+
const from = path69.join(source, entry.name);
|
|
88088
|
+
const to = path69.join(target, entry.name);
|
|
88107
88089
|
if (top && entry.isDirectory() && (entry.name.startsWith("@") || entry.name === ".bin"))
|
|
88108
88090
|
count += mirror(main, worktree, from, to, false);
|
|
88109
88091
|
else {
|
|
@@ -88119,16 +88101,16 @@ function linkWorktreeDependencies(main, worktree) {
|
|
|
88119
88101
|
const dirs = [];
|
|
88120
88102
|
let entries = 0;
|
|
88121
88103
|
for (const relative of moduleDirs(main)) {
|
|
88122
|
-
const target =
|
|
88123
|
-
if (!fs31.existsSync(
|
|
88104
|
+
const target = path69.join(worktree, relative);
|
|
88105
|
+
if (!fs31.existsSync(path69.dirname(target)) || fs31.existsSync(target))
|
|
88124
88106
|
continue;
|
|
88125
|
-
if (!gitRun4(worktree, ["check-ignore", "-q", `${relative.split(
|
|
88126
|
-
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`);
|
|
88127
88109
|
continue;
|
|
88128
88110
|
}
|
|
88129
88111
|
try {
|
|
88130
|
-
entries += mirror(main, worktree,
|
|
88131
|
-
dirs.push(relative.split(
|
|
88112
|
+
entries += mirror(main, worktree, path69.join(main, relative), target, true);
|
|
88113
|
+
dirs.push(relative.split(path69.sep).join("/"));
|
|
88132
88114
|
} catch (error) {
|
|
88133
88115
|
fs31.rmSync(target, { recursive: true, force: true });
|
|
88134
88116
|
notes.push(`could not link ${relative} from ${main} (${error.message}); install dependencies in the worktree yourself`);
|
|
@@ -88141,8 +88123,8 @@ function linkWorktreeDependencies(main, worktree) {
|
|
|
88141
88123
|
return { linked: { from: main, dirs, entries, ms }, notes };
|
|
88142
88124
|
}
|
|
88143
88125
|
var MODULES = "node_modules", MAX_DEPTH2 = 2, within = (child, parent) => {
|
|
88144
|
-
const relative =
|
|
88145
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
88126
|
+
const relative = path69.relative(parent, child);
|
|
88127
|
+
return relative === "" || !relative.startsWith("..") && !path69.isAbsolute(relative);
|
|
88146
88128
|
};
|
|
88147
88129
|
var init_worktree_deps = __esm(() => {
|
|
88148
88130
|
init_fanout();
|
|
@@ -88151,7 +88133,7 @@ var init_worktree_deps = __esm(() => {
|
|
|
88151
88133
|
// packages/workit-core/src/fanout-worktree.ts
|
|
88152
88134
|
import { randomBytes as randomBytes5 } from "node:crypto";
|
|
88153
88135
|
import fs32 from "node:fs";
|
|
88154
|
-
import
|
|
88136
|
+
import path70 from "node:path";
|
|
88155
88137
|
function rowSample(lines) {
|
|
88156
88138
|
const out = [];
|
|
88157
88139
|
let bytes = 0;
|
|
@@ -88211,7 +88193,7 @@ function adminDir(worktree) {
|
|
|
88211
88193
|
const file = dir.stdout.trim();
|
|
88212
88194
|
let token = null;
|
|
88213
88195
|
try {
|
|
88214
|
-
token = fs32.readFileSync(
|
|
88196
|
+
token = fs32.readFileSync(path70.join(file, FANOUT_TOKEN_FILE), "utf8").trim() || null;
|
|
88215
88197
|
} catch {
|
|
88216
88198
|
token = null;
|
|
88217
88199
|
}
|
|
@@ -88219,7 +88201,7 @@ function adminDir(worktree) {
|
|
|
88219
88201
|
const stat = worktreeDeps.stat(file);
|
|
88220
88202
|
return {
|
|
88221
88203
|
path: file,
|
|
88222
|
-
id:
|
|
88204
|
+
id: path70.basename(file),
|
|
88223
88205
|
ino: stat.ino.toString(),
|
|
88224
88206
|
token,
|
|
88225
88207
|
birthMs: stat.birthtimeNs > 0n ? Number(stat.birthtimeMs) : null,
|
|
@@ -88235,7 +88217,7 @@ function markAdminDir(worktree) {
|
|
|
88235
88217
|
return null;
|
|
88236
88218
|
const token = randomBytes5(16).toString("hex");
|
|
88237
88219
|
try {
|
|
88238
|
-
fs32.writeFileSync(
|
|
88220
|
+
fs32.writeFileSync(path70.join(admin.path, FANOUT_TOKEN_FILE), `${token}
|
|
88239
88221
|
`);
|
|
88240
88222
|
} catch {
|
|
88241
88223
|
return null;
|
|
@@ -88250,7 +88232,7 @@ function excludeScratch(cwd) {
|
|
|
88250
88232
|
const common = gitCommonDir(cwd);
|
|
88251
88233
|
if (!common)
|
|
88252
88234
|
return;
|
|
88253
|
-
const file =
|
|
88235
|
+
const file = path70.join(common, "info", "exclude");
|
|
88254
88236
|
let text = "";
|
|
88255
88237
|
try {
|
|
88256
88238
|
text = fs32.readFileSync(file, "utf8");
|
|
@@ -88259,7 +88241,7 @@ function excludeScratch(cwd) {
|
|
|
88259
88241
|
}
|
|
88260
88242
|
if (text.split(/\r?\n/u).includes(EXCLUDE_LINE))
|
|
88261
88243
|
return;
|
|
88262
|
-
fs32.mkdirSync(
|
|
88244
|
+
fs32.mkdirSync(path70.dirname(file), { recursive: true });
|
|
88263
88245
|
fs32.appendFileSync(file, `${text && !text.endsWith(`
|
|
88264
88246
|
`) ? `
|
|
88265
88247
|
` : ""}# workit fanout: per-worker scratch dirs
|
|
@@ -88268,13 +88250,13 @@ ${EXCLUDE_LINE}
|
|
|
88268
88250
|
}
|
|
88269
88251
|
function worktreeDependencies(main, worktree) {
|
|
88270
88252
|
for (const [name, install] of LOCKFILES2) {
|
|
88271
|
-
const ours = readBytes(
|
|
88272
|
-
const theirs = readBytes(
|
|
88253
|
+
const ours = readBytes(path70.join(main, name));
|
|
88254
|
+
const theirs = readBytes(path70.join(worktree, name));
|
|
88273
88255
|
if (ours === null && theirs === null)
|
|
88274
88256
|
continue;
|
|
88275
88257
|
if (ours !== null && theirs !== null && ours.equals(theirs))
|
|
88276
88258
|
continue;
|
|
88277
|
-
if (fs32.existsSync(
|
|
88259
|
+
if (fs32.existsSync(path70.join(worktree, "node_modules")))
|
|
88278
88260
|
break;
|
|
88279
88261
|
const command = install(worktree);
|
|
88280
88262
|
return {
|
|
@@ -88286,7 +88268,7 @@ function worktreeDependencies(main, worktree) {
|
|
|
88286
88268
|
};
|
|
88287
88269
|
}
|
|
88288
88270
|
const stale = staleBunInstall(main);
|
|
88289
|
-
if (stale && !fs32.existsSync(
|
|
88271
|
+
if (stale && !fs32.existsSync(path70.join(worktree, "node_modules"))) {
|
|
88290
88272
|
const command = `bun install --frozen-lockfile --cwd ${worktree}`;
|
|
88291
88273
|
return {
|
|
88292
88274
|
linked: null,
|
|
@@ -88299,9 +88281,9 @@ function worktreeDependencies(main, worktree) {
|
|
|
88299
88281
|
return { ...linkWorktreeDependencies(main, worktree), install: null };
|
|
88300
88282
|
}
|
|
88301
88283
|
function staleBunInstall(main) {
|
|
88302
|
-
if (!fs32.existsSync(
|
|
88284
|
+
if (!fs32.existsSync(path70.join(main, "node_modules")))
|
|
88303
88285
|
return null;
|
|
88304
|
-
const text = readBytes(
|
|
88286
|
+
const text = readBytes(path70.join(main, "bun.lock"))?.toString("utf8");
|
|
88305
88287
|
if (!text)
|
|
88306
88288
|
return null;
|
|
88307
88289
|
let packages;
|
|
@@ -88328,7 +88310,7 @@ function staleBunInstall(main) {
|
|
|
88328
88310
|
const version = spec.slice(at + 1);
|
|
88329
88311
|
if (name !== key || version.includes(":"))
|
|
88330
88312
|
continue;
|
|
88331
|
-
const manifest = readBytes(
|
|
88313
|
+
const manifest = readBytes(path70.join(main, "node_modules", key, "package.json"));
|
|
88332
88314
|
if (!manifest) {
|
|
88333
88315
|
problems.push(`${key} missing`);
|
|
88334
88316
|
continue;
|
|
@@ -88345,7 +88327,7 @@ function staleBunInstall(main) {
|
|
|
88345
88327
|
return problems.length ? problems.join("; ") : null;
|
|
88346
88328
|
}
|
|
88347
88329
|
function ensureScratch(worktree) {
|
|
88348
|
-
const scratch =
|
|
88330
|
+
const scratch = path70.join(worktree, SCRATCH_DIR);
|
|
88349
88331
|
fs32.mkdirSync(scratch, { recursive: true });
|
|
88350
88332
|
return scratch;
|
|
88351
88333
|
}
|
|
@@ -88619,7 +88601,7 @@ function unpushedCount(cwd, branch) {
|
|
|
88619
88601
|
return count.ok ? Number(count.stdout.trim()) : null;
|
|
88620
88602
|
}
|
|
88621
88603
|
function removeScratch(worktree) {
|
|
88622
|
-
const scratch =
|
|
88604
|
+
const scratch = path70.join(worktree, SCRATCH_DIR);
|
|
88623
88605
|
let stat;
|
|
88624
88606
|
try {
|
|
88625
88607
|
stat = fs32.lstatSync(scratch);
|
|
@@ -88635,16 +88617,16 @@ var SLOW, SCRATCH_DIR = ".workit-scratch", EXCLUDE_LINE, DIRTY_ROW_BYTES = 2000,
|
|
|
88635
88617
|
try {
|
|
88636
88618
|
return fs32.realpathSync.native(target);
|
|
88637
88619
|
} catch {
|
|
88638
|
-
return
|
|
88620
|
+
return path70.resolve(target);
|
|
88639
88621
|
}
|
|
88640
88622
|
}, samePath = (a, b) => {
|
|
88641
88623
|
const left = canonical3(a);
|
|
88642
88624
|
const right = canonical3(b);
|
|
88643
88625
|
return process.platform === "win32" || process.platform === "darwin" ? left.toLowerCase() === right.toLowerCase() : left === right;
|
|
88644
88626
|
}, inside3 = (child, parent) => {
|
|
88645
|
-
const relative =
|
|
88646
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
88647
|
-
}, 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) => {
|
|
88648
88630
|
try {
|
|
88649
88631
|
return fs32.readFileSync(file);
|
|
88650
88632
|
} catch {
|
|
@@ -88676,7 +88658,7 @@ var init_fanout_worktree = __esm(() => {
|
|
|
88676
88658
|
|
|
88677
88659
|
// packages/workit-core/src/forge/merge-cleanup.ts
|
|
88678
88660
|
import fs33 from "node:fs";
|
|
88679
|
-
import
|
|
88661
|
+
import path71 from "node:path";
|
|
88680
88662
|
function cleanupMergedBranch(cwd, branch, mergedHead) {
|
|
88681
88663
|
const out = { branchDeleted: false, worktreeRemoved: null, notes: [] };
|
|
88682
88664
|
if (!branch || branch.startsWith("-"))
|
|
@@ -88736,13 +88718,13 @@ var SLOW2, isFanoutWorktree = (worktree) => {
|
|
|
88736
88718
|
if (!dir.ok)
|
|
88737
88719
|
return false;
|
|
88738
88720
|
try {
|
|
88739
|
-
return fs33.readFileSync(
|
|
88721
|
+
return fs33.readFileSync(path71.join(dir.stdout.trim(), FANOUT_TOKEN_FILE), "utf8").trim() !== "";
|
|
88740
88722
|
} catch {
|
|
88741
88723
|
return false;
|
|
88742
88724
|
}
|
|
88743
88725
|
}, inside4 = (child, parent) => {
|
|
88744
|
-
const relative =
|
|
88745
|
-
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);
|
|
88746
88728
|
};
|
|
88747
88729
|
var init_merge_cleanup = __esm(() => {
|
|
88748
88730
|
init_fanout();
|
|
@@ -89023,7 +89005,7 @@ var init_duration = __esm(() => {
|
|
|
89023
89005
|
});
|
|
89024
89006
|
|
|
89025
89007
|
// packages/workit-cli/src/verbs/forge-common.ts
|
|
89026
|
-
import { readFileSync as
|
|
89008
|
+
import { readFileSync as readFileSync29 } from "node:fs";
|
|
89027
89009
|
function parseFlags(argv, spec) {
|
|
89028
89010
|
const parsed = { values: {}, booleans: new Set, lists: {}, positionals: [] };
|
|
89029
89011
|
for (let index = 0;index < argv.length; index += 1) {
|
|
@@ -89181,7 +89163,7 @@ var init_forge_common = __esm(() => {
|
|
|
89181
89163
|
forgeDeps = {
|
|
89182
89164
|
runner: undefined,
|
|
89183
89165
|
npm: undefined,
|
|
89184
|
-
readStdin: () =>
|
|
89166
|
+
readStdin: () => readFileSync29(0, "utf8"),
|
|
89185
89167
|
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
89186
89168
|
now: () => Date.now()
|
|
89187
89169
|
};
|
|
@@ -89193,8 +89175,8 @@ __export(exports_pr, {
|
|
|
89193
89175
|
checkPrTitle: () => checkPrTitle,
|
|
89194
89176
|
run: () => run15
|
|
89195
89177
|
});
|
|
89196
|
-
import { existsSync as existsSync28, readFileSync as
|
|
89197
|
-
import
|
|
89178
|
+
import { existsSync as existsSync28, readFileSync as readFileSync30 } from "node:fs";
|
|
89179
|
+
import path72 from "node:path";
|
|
89198
89180
|
function titleRules(cwd) {
|
|
89199
89181
|
let root;
|
|
89200
89182
|
try {
|
|
@@ -89205,16 +89187,16 @@ function titleRules(cwd) {
|
|
|
89205
89187
|
let text = null;
|
|
89206
89188
|
let name = "";
|
|
89207
89189
|
for (const candidate of COMMITLINT_FILES) {
|
|
89208
|
-
const full =
|
|
89190
|
+
const full = path72.join(root, candidate);
|
|
89209
89191
|
if (!existsSync28(full))
|
|
89210
89192
|
continue;
|
|
89211
|
-
text =
|
|
89193
|
+
text = readFileSync30(full, "utf8");
|
|
89212
89194
|
name = candidate;
|
|
89213
89195
|
break;
|
|
89214
89196
|
}
|
|
89215
89197
|
if (text === null) {
|
|
89216
89198
|
try {
|
|
89217
|
-
const pkg = JSON.parse(
|
|
89199
|
+
const pkg = JSON.parse(readFileSync30(path72.join(root, "package.json"), "utf8"));
|
|
89218
89200
|
if (pkg.commitlint === undefined)
|
|
89219
89201
|
return { rules: null, note: null };
|
|
89220
89202
|
text = JSON.stringify(pkg.commitlint);
|
|
@@ -89311,7 +89293,7 @@ function refuseTitle(io, title, line) {
|
|
|
89311
89293
|
function readBodyFile(io, file) {
|
|
89312
89294
|
try {
|
|
89313
89295
|
return {
|
|
89314
|
-
body: file === "-" ? forgeDeps.readStdin() :
|
|
89296
|
+
body: file === "-" ? forgeDeps.readStdin() : readFileSync30(path72.resolve(io.cwd, file), "utf8")
|
|
89315
89297
|
};
|
|
89316
89298
|
} catch {
|
|
89317
89299
|
return `cannot read --body-file ${file}`;
|
|
@@ -90241,8 +90223,8 @@ var exports_git = {};
|
|
|
90241
90223
|
__export(exports_git, {
|
|
90242
90224
|
run: () => run17
|
|
90243
90225
|
});
|
|
90244
|
-
import { readFileSync as
|
|
90245
|
-
import
|
|
90226
|
+
import { readFileSync as readFileSync31 } from "node:fs";
|
|
90227
|
+
import path73 from "node:path";
|
|
90246
90228
|
function kindHint(cwd, kind) {
|
|
90247
90229
|
let kinds = [...BRANCH_KINDS];
|
|
90248
90230
|
try {
|
|
@@ -90348,7 +90330,7 @@ function commitMessage(parsed, io) {
|
|
|
90348
90330
|
|
|
90349
90331
|
`);
|
|
90350
90332
|
try {
|
|
90351
|
-
return file === "-" ?
|
|
90333
|
+
return file === "-" ? readFileSync31(0, "utf8") : readFileSync31(path73.resolve(io.cwd, file), "utf8");
|
|
90352
90334
|
} catch (error) {
|
|
90353
90335
|
return {
|
|
90354
90336
|
error: `cannot read -F ${file}: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -90406,7 +90388,7 @@ async function commit(argv, io) {
|
|
|
90406
90388
|
}
|
|
90407
90389
|
function readPatch(file, io) {
|
|
90408
90390
|
try {
|
|
90409
|
-
return file === "-" ?
|
|
90391
|
+
return file === "-" ? readFileSync31(0, "utf8") : readFileSync31(path73.resolve(io.cwd, file), "utf8");
|
|
90410
90392
|
} catch (error) {
|
|
90411
90393
|
return {
|
|
90412
90394
|
error: `cannot read --patch ${file}: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -91883,7 +91865,7 @@ var init_stack2 = __esm(() => {
|
|
|
91883
91865
|
// packages/workit-core/src/fanout-brief.ts
|
|
91884
91866
|
import { createHash as createHash20 } from "node:crypto";
|
|
91885
91867
|
import fs35 from "node:fs";
|
|
91886
|
-
import
|
|
91868
|
+
import path74 from "node:path";
|
|
91887
91869
|
function workerSession(lead, slice, attempt) {
|
|
91888
91870
|
const tail = attempt === null ? "" : `+try${attempt}`;
|
|
91889
91871
|
const full = `${lead}-w-${slice}${tail}`;
|
|
@@ -91966,7 +91948,7 @@ function renderBrief(cwd, plan, input) {
|
|
|
91966
91948
|
"STANDING:",
|
|
91967
91949
|
...standing.length ? standing.map((order) => ` - ${order.what}`) : [" - none recorded beyond this brief"],
|
|
91968
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)`,
|
|
91969
|
-
...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`] : [],
|
|
91970
91952
|
...identityLines(identity, minted),
|
|
91971
91953
|
...rules(mode, branch, sliceBase, exists ? planned : null)
|
|
91972
91954
|
];
|
|
@@ -92508,7 +92490,7 @@ __export(exports_fanout, {
|
|
|
92508
92490
|
run: () => run21
|
|
92509
92491
|
});
|
|
92510
92492
|
import fs36 from "node:fs";
|
|
92511
|
-
import
|
|
92493
|
+
import path75 from "node:path";
|
|
92512
92494
|
function forgeFor(io, offline) {
|
|
92513
92495
|
if (offline)
|
|
92514
92496
|
return { forge: null, error: "--offline" };
|
|
@@ -92569,7 +92551,7 @@ function plan2(argv, io) {
|
|
|
92569
92551
|
return usage4(io, "pass --trunk or --track, not both (--track picks the trunk)", PLAN_USAGE2);
|
|
92570
92552
|
if (flags.positionals.length !== 1)
|
|
92571
92553
|
return usage4(io, flags.positionals.length ? `unexpected argument ${flags.positionals[1]}` : "missing <plan.json>", PLAN_USAGE2);
|
|
92572
|
-
const file =
|
|
92554
|
+
const file = path75.resolve(io.cwd, flags.positionals[0]);
|
|
92573
92555
|
let raw;
|
|
92574
92556
|
try {
|
|
92575
92557
|
raw = JSON.parse(fs36.readFileSync(file, "utf8"));
|
|
@@ -108145,7 +108127,7 @@ var init_ast = __esm(() => {
|
|
|
108145
108127
|
|
|
108146
108128
|
// packages/workit-cli/src/test-audit/rules.ts
|
|
108147
108129
|
import { builtinModules } from "node:module";
|
|
108148
|
-
import
|
|
108130
|
+
import path76 from "node:path";
|
|
108149
108131
|
function testCallee(call) {
|
|
108150
108132
|
let callee = call.callee;
|
|
108151
108133
|
if (callee.type === "CallExpression")
|
|
@@ -108638,12 +108620,12 @@ function checkConstantsOnly(ctx, emit) {
|
|
|
108638
108620
|
}
|
|
108639
108621
|
function checkOverMocking(ctx, emit) {
|
|
108640
108622
|
const { program } = ctx.parsed;
|
|
108641
|
-
const unit =
|
|
108623
|
+
const unit = path76.basename(ctx.file).replace(/\.(?:[cm]?[jt]sx?)$/, "").replace(/\.(?:test|spec)$/, "");
|
|
108642
108624
|
const mocked = find2(program, (node) => node.type === "CallExpression" && MODULE_MOCK.test(calleeName(node.callee) ?? "") && node.arguments[0]?.type === "StringLiteral");
|
|
108643
108625
|
const internal = mocked.filter((call) => /^(?:\.|@\/|~\/)/.test(call.arguments[0].value));
|
|
108644
108626
|
for (const call of mocked) {
|
|
108645
108627
|
const spec = call.arguments[0].value;
|
|
108646
|
-
const base =
|
|
108628
|
+
const base = path76.basename(spec.replace(/\/index(?:\.[cm]?[jt]sx?)?$/, "")).replace(/\.(?:[cm]?[jt]sx?)$/, "");
|
|
108647
108629
|
if (base === unit)
|
|
108648
108630
|
emit({
|
|
108649
108631
|
rule: "over-mocking",
|
|
@@ -109032,8 +109014,8 @@ var init_rules = __esm(() => {
|
|
|
109032
109014
|
|
|
109033
109015
|
// packages/workit-cli/src/test-audit/audit.ts
|
|
109034
109016
|
import { spawnSync as spawnSync31 } from "node:child_process";
|
|
109035
|
-
import { existsSync as existsSync29, readdirSync as readdirSync15, readFileSync as
|
|
109036
|
-
import
|
|
109017
|
+
import { existsSync as existsSync29, readdirSync as readdirSync15, readFileSync as readFileSync32, statSync as statSync11 } from "node:fs";
|
|
109018
|
+
import path77 from "node:path";
|
|
109037
109019
|
function git7(cwd, args) {
|
|
109038
109020
|
const run = spawnSync31("git", ["-c", "core.quotepath=off", ...args], {
|
|
109039
109021
|
cwd,
|
|
@@ -109046,7 +109028,7 @@ function walkTests(dir, out) {
|
|
|
109046
109028
|
for (const entry of readdirSync15(dir, { withFileTypes: true })) {
|
|
109047
109029
|
if (entry.name.startsWith(".") && entry.name !== "." && entry.isDirectory())
|
|
109048
109030
|
continue;
|
|
109049
|
-
const full =
|
|
109031
|
+
const full = path77.join(dir, entry.name);
|
|
109050
109032
|
if (entry.isDirectory()) {
|
|
109051
109033
|
if (!SKIP_DIRS.has(entry.name))
|
|
109052
109034
|
walkTests(full, out);
|
|
@@ -109058,7 +109040,7 @@ function expandPaths(cwd, inputs) {
|
|
|
109058
109040
|
const files = [];
|
|
109059
109041
|
const missing = [];
|
|
109060
109042
|
for (const input of inputs.length > 0 ? inputs : ["."]) {
|
|
109061
|
-
const full =
|
|
109043
|
+
const full = path77.resolve(cwd, input);
|
|
109062
109044
|
if (!existsSync29(full))
|
|
109063
109045
|
missing.push(input);
|
|
109064
109046
|
else if (statSync11(full).isDirectory())
|
|
@@ -109095,11 +109077,11 @@ function changedLines(cwd, base) {
|
|
|
109095
109077
|
for (let offset = 0;offset < count; offset += 1)
|
|
109096
109078
|
lines.add(start + offset);
|
|
109097
109079
|
}
|
|
109098
|
-
changed.set(
|
|
109080
|
+
changed.set(path77.join(root, file), lines);
|
|
109099
109081
|
}
|
|
109100
109082
|
const untracked = git7(root, ["ls-files", "--others", "--exclude-standard", "-z"]);
|
|
109101
109083
|
for (const file of untracked.stdout.split("\x00").filter(Boolean))
|
|
109102
|
-
changed.set(
|
|
109084
|
+
changed.set(path77.join(root, file), "all");
|
|
109103
109085
|
return changed;
|
|
109104
109086
|
}
|
|
109105
109087
|
function auditFiles(files, display) {
|
|
@@ -109112,7 +109094,7 @@ function auditFiles(files, display) {
|
|
|
109112
109094
|
const shown = display(file);
|
|
109113
109095
|
let parsed;
|
|
109114
109096
|
try {
|
|
109115
|
-
parsed = parseSource(
|
|
109097
|
+
parsed = parseSource(readFileSync32(file, "utf8"), file);
|
|
109116
109098
|
} catch (error) {
|
|
109117
109099
|
parseErrors.push({
|
|
109118
109100
|
file: shown,
|
|
@@ -109161,7 +109143,7 @@ function auditFiles(files, display) {
|
|
|
109161
109143
|
durationMs: Math.round(performance.now() - started)
|
|
109162
109144
|
};
|
|
109163
109145
|
}
|
|
109164
|
-
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;
|
|
109165
109147
|
var init_audit = __esm(() => {
|
|
109166
109148
|
init_ast();
|
|
109167
109149
|
init_rules();
|
|
@@ -109180,9 +109162,9 @@ import {
|
|
|
109180
109162
|
mkdirSync as mkdirSync13,
|
|
109181
109163
|
mkdtempSync as mkdtempSync6,
|
|
109182
109164
|
readdirSync as readdirSync16,
|
|
109183
|
-
readFileSync as
|
|
109165
|
+
readFileSync as readFileSync33,
|
|
109184
109166
|
readlinkSync as readlinkSync3,
|
|
109185
|
-
realpathSync as
|
|
109167
|
+
realpathSync as realpathSync13,
|
|
109186
109168
|
renameSync as renameSync8,
|
|
109187
109169
|
rmSync as rmSync12,
|
|
109188
109170
|
statSync as statSync12,
|
|
@@ -109191,7 +109173,7 @@ import {
|
|
|
109191
109173
|
copyFileSync as copyFileSync9
|
|
109192
109174
|
} from "node:fs";
|
|
109193
109175
|
import os27 from "node:os";
|
|
109194
|
-
import
|
|
109176
|
+
import path78 from "node:path";
|
|
109195
109177
|
function mutantsFor(source, file, lines) {
|
|
109196
109178
|
const parsed = parseSource(source, file);
|
|
109197
109179
|
const out = [];
|
|
@@ -109264,7 +109246,7 @@ function relatedTests(source, testFiles) {
|
|
|
109264
109246
|
for (const match of text.matchAll(SPECIFIER)) {
|
|
109265
109247
|
const spec = match[1];
|
|
109266
109248
|
if (spec.startsWith(".")) {
|
|
109267
|
-
if (stripExt(
|
|
109249
|
+
if (stripExt(path78.posix.join(path78.posix.dirname(file), spec)) === target)
|
|
109268
109250
|
return true;
|
|
109269
109251
|
} else if (spec.includes("/") && stripExt(spec).split("/").slice(-2).join("/") === tail)
|
|
109270
109252
|
return true;
|
|
@@ -109284,12 +109266,12 @@ function removeStaleCopies(tmp = os27.tmpdir()) {
|
|
|
109284
109266
|
for (const name of names) {
|
|
109285
109267
|
if (!name.startsWith(TEMP_PREFIX))
|
|
109286
109268
|
continue;
|
|
109287
|
-
const dir =
|
|
109269
|
+
const dir = path78.join(tmp, name);
|
|
109288
109270
|
try {
|
|
109289
109271
|
const stat = lstatSync10(dir);
|
|
109290
109272
|
if (!stat.isDirectory() || uid !== undefined && stat.uid !== uid)
|
|
109291
109273
|
continue;
|
|
109292
|
-
const pid = Number(
|
|
109274
|
+
const pid = Number(readFileSync33(path78.join(dir, PID_FILE), "utf8"));
|
|
109293
109275
|
if (Number.isInteger(pid) && pid > 0 && alive(pid))
|
|
109294
109276
|
continue;
|
|
109295
109277
|
} catch (error) {
|
|
@@ -109306,8 +109288,8 @@ function removeStaleCopies(tmp = os27.tmpdir()) {
|
|
|
109306
109288
|
function linkNodeModules(origin, target, repo, copy) {
|
|
109307
109289
|
mkdirSync13(target, { recursive: true });
|
|
109308
109290
|
for (const entry of readdirSync16(origin, { withFileTypes: true })) {
|
|
109309
|
-
const from =
|
|
109310
|
-
const to =
|
|
109291
|
+
const from = path78.join(origin, entry.name);
|
|
109292
|
+
const to = path78.join(target, entry.name);
|
|
109311
109293
|
if (entry.name.startsWith("@") && entry.isDirectory()) {
|
|
109312
109294
|
linkNodeModules(from, to, repo, copy);
|
|
109313
109295
|
continue;
|
|
@@ -109319,13 +109301,13 @@ function linkNodeModules(origin, target, repo, copy) {
|
|
|
109319
109301
|
if (entry.isSymbolicLink()) {
|
|
109320
109302
|
let real;
|
|
109321
109303
|
try {
|
|
109322
|
-
real =
|
|
109304
|
+
real = realpathSync13(from);
|
|
109323
109305
|
} catch {
|
|
109324
109306
|
continue;
|
|
109325
109307
|
}
|
|
109326
|
-
const relative =
|
|
109327
|
-
if (!relative.startsWith("..") && !
|
|
109328
|
-
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");
|
|
109329
109311
|
continue;
|
|
109330
109312
|
}
|
|
109331
109313
|
}
|
|
@@ -109335,13 +109317,13 @@ function linkNodeModules(origin, target, repo, copy) {
|
|
|
109335
109317
|
function copySymlink(repo, tree, from, to) {
|
|
109336
109318
|
let real = null;
|
|
109337
109319
|
try {
|
|
109338
|
-
real =
|
|
109320
|
+
real = realpathSync13(from);
|
|
109339
109321
|
} catch {
|
|
109340
109322
|
real = null;
|
|
109341
109323
|
}
|
|
109342
|
-
const realRepo =
|
|
109324
|
+
const realRepo = realpathSync13(repo);
|
|
109343
109325
|
if (real && inside5(realRepo, real)) {
|
|
109344
|
-
symlinkSync(
|
|
109326
|
+
symlinkSync(path78.relative(path78.dirname(to), path78.join(tree, path78.relative(realRepo, real))), to);
|
|
109345
109327
|
return;
|
|
109346
109328
|
}
|
|
109347
109329
|
if (real && statSync12(real).isFile())
|
|
@@ -109350,10 +109332,10 @@ function copySymlink(repo, tree, from, to) {
|
|
|
109350
109332
|
symlinkSync(readlinkSync3(from), to);
|
|
109351
109333
|
}
|
|
109352
109334
|
function writeInside(copy, file, content) {
|
|
109353
|
-
const target =
|
|
109335
|
+
const target = path78.join(copy, file);
|
|
109354
109336
|
try {
|
|
109355
109337
|
const stat = lstatSync10(target);
|
|
109356
|
-
if (!stat.isFile() || !inside5(
|
|
109338
|
+
if (!stat.isFile() || !inside5(realpathSync13(copy), realpathSync13(path78.dirname(target))))
|
|
109357
109339
|
return false;
|
|
109358
109340
|
} catch {
|
|
109359
109341
|
return false;
|
|
@@ -109364,9 +109346,9 @@ function writeInside(copy, file, content) {
|
|
|
109364
109346
|
return true;
|
|
109365
109347
|
}
|
|
109366
109348
|
function copyWorkingTree(repo) {
|
|
109367
|
-
const dir = mkdtempSync6(
|
|
109368
|
-
writeFileSync15(
|
|
109369
|
-
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");
|
|
109370
109352
|
const head = git7(repo, ["rev-parse", "--verify", "--quiet", "HEAD"]).stdout.trim();
|
|
109371
109353
|
if (head && git7(dir, ["clone", "-q", "--shared", "--no-checkout", repo, tree]).ok) {
|
|
109372
109354
|
const branch = git7(repo, ["symbolic-ref", "--quiet", "--short", "HEAD"]).stdout.trim();
|
|
@@ -109383,29 +109365,29 @@ function copyWorkingTree(repo) {
|
|
|
109383
109365
|
for (const relative of listed) {
|
|
109384
109366
|
if (!relative)
|
|
109385
109367
|
continue;
|
|
109386
|
-
const from =
|
|
109368
|
+
const from = path78.join(repo, relative);
|
|
109387
109369
|
let stat;
|
|
109388
109370
|
try {
|
|
109389
109371
|
stat = lstatSync10(from);
|
|
109390
109372
|
} catch {
|
|
109391
109373
|
continue;
|
|
109392
109374
|
}
|
|
109393
|
-
const to =
|
|
109394
|
-
mkdirSync13(
|
|
109375
|
+
const to = path78.join(tree, relative);
|
|
109376
|
+
mkdirSync13(path78.dirname(to), { recursive: true });
|
|
109395
109377
|
if (stat.isSymbolicLink())
|
|
109396
109378
|
copySymlink(repo, tree, from, to);
|
|
109397
109379
|
else if (stat.isFile())
|
|
109398
109380
|
copyFileSync9(from, to);
|
|
109399
|
-
let parent =
|
|
109381
|
+
let parent = path78.dirname(relative);
|
|
109400
109382
|
while (parent !== "." && !dirs.has(parent)) {
|
|
109401
109383
|
dirs.add(parent);
|
|
109402
|
-
parent =
|
|
109384
|
+
parent = path78.dirname(parent);
|
|
109403
109385
|
}
|
|
109404
109386
|
}
|
|
109405
109387
|
for (const parent of dirs) {
|
|
109406
|
-
const modules =
|
|
109407
|
-
if (existsSync30(modules) && !existsSync30(
|
|
109408
|
-
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);
|
|
109409
109391
|
}
|
|
109410
109392
|
return { dir, tree };
|
|
109411
109393
|
}
|
|
@@ -109444,20 +109426,20 @@ async function runMutation(options) {
|
|
|
109444
109426
|
const tracked = git7(repo, ["ls-files", "-co", "--exclude-standard", "-z"]).stdout.split("\x00").filter(Boolean);
|
|
109445
109427
|
const testFiles = tracked.filter((file) => TEST_FILE.test(file)).map((file) => {
|
|
109446
109428
|
try {
|
|
109447
|
-
return { file, text:
|
|
109429
|
+
return { file, text: readFileSync33(path78.join(repo, file), "utf8") };
|
|
109448
109430
|
} catch {
|
|
109449
109431
|
return { file, text: "" };
|
|
109450
109432
|
}
|
|
109451
109433
|
});
|
|
109452
109434
|
const candidates = [];
|
|
109453
109435
|
for (const [absolute, lines] of [...options.changed].toSorted(([a], [b]) => a.localeCompare(b))) {
|
|
109454
|
-
const relative = toPosix(
|
|
109436
|
+
const relative = toPosix(path78.relative(repo, absolute));
|
|
109455
109437
|
if (!CODE_FILE.test(relative) || TEST_FILE.test(relative) || relative.endsWith(".d.ts"))
|
|
109456
109438
|
continue;
|
|
109457
109439
|
if (NOT_SOURCE.test(relative) || !existsSync30(absolute))
|
|
109458
109440
|
continue;
|
|
109459
109441
|
try {
|
|
109460
|
-
candidates.push(...mutantsFor(
|
|
109442
|
+
candidates.push(...mutantsFor(readFileSync33(absolute, "utf8"), relative, lines));
|
|
109461
109443
|
} catch {}
|
|
109462
109444
|
}
|
|
109463
109445
|
const mutants = candidates.map((mutant, index) => ({ ...mutant, id: index + 1 }));
|
|
@@ -109465,9 +109447,9 @@ async function runMutation(options) {
|
|
|
109465
109447
|
for (const mutant of mutants)
|
|
109466
109448
|
if (!related.has(mutant.file))
|
|
109467
109449
|
related.set(mutant.file, relatedTests(mutant.file, testFiles));
|
|
109468
|
-
const cwdRelative =
|
|
109450
|
+
const cwdRelative = path78.relative(repo, options.cwd);
|
|
109469
109451
|
const asArg = (file) => {
|
|
109470
|
-
const relative = toPosix(
|
|
109452
|
+
const relative = toPosix(path78.relative(cwdRelative, file));
|
|
109471
109453
|
return shellQuote(relative.startsWith(".") ? relative : `./${relative}`);
|
|
109472
109454
|
};
|
|
109473
109455
|
const commandFor = (tests) => options.command.replaceAll("{files}", () => tests.map(asArg).join(" "));
|
|
@@ -109503,7 +109485,7 @@ async function runMutation(options) {
|
|
|
109503
109485
|
return finish3(options, 0, results, counts, started);
|
|
109504
109486
|
removeStaleCopies();
|
|
109505
109487
|
const { dir: copyDir, tree: copy } = copyWorkingTree(repo);
|
|
109506
|
-
const copyCwd =
|
|
109488
|
+
const copyCwd = path78.join(copy, cwdRelative);
|
|
109507
109489
|
let current = null;
|
|
109508
109490
|
const restore = () => {
|
|
109509
109491
|
if (current)
|
|
@@ -109538,7 +109520,7 @@ async function runMutation(options) {
|
|
|
109538
109520
|
record({ ...mutant, status: "skipped", durationMs: 0, tests, reason: "budget" });
|
|
109539
109521
|
continue;
|
|
109540
109522
|
}
|
|
109541
|
-
const original =
|
|
109523
|
+
const original = readFileSync33(path78.join(copy, mutant.file), "utf8");
|
|
109542
109524
|
const mutated = original.slice(0, mutant.start) + mutant.replacement + original.slice(mutant.end);
|
|
109543
109525
|
current = { file: mutant.file, original };
|
|
109544
109526
|
if (!writeInside(copy, mutant.file, mutated)) {
|
|
@@ -109595,8 +109577,8 @@ var NOT_SOURCE, FLIPS, isStringy = (node) => node.type === "StringLiteral" || no
|
|
|
109595
109577
|
return error.code === "EPERM";
|
|
109596
109578
|
}
|
|
109597
109579
|
}, inside5 = (root, file) => {
|
|
109598
|
-
const relative =
|
|
109599
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
109580
|
+
const relative = path78.relative(root, file);
|
|
109581
|
+
return relative === "" || !relative.startsWith("..") && !path78.isAbsolute(relative);
|
|
109600
109582
|
}, active, killTree = (child) => {
|
|
109601
109583
|
try {
|
|
109602
109584
|
if (child.pid && process.platform !== "win32")
|
|
@@ -109645,7 +109627,7 @@ __export(exports_test_audit, {
|
|
|
109645
109627
|
run: () => run23
|
|
109646
109628
|
});
|
|
109647
109629
|
import { existsSync as existsSync31 } from "node:fs";
|
|
109648
|
-
import
|
|
109630
|
+
import path79 from "node:path";
|
|
109649
109631
|
function parse8(argv) {
|
|
109650
109632
|
const options = {
|
|
109651
109633
|
paths: [],
|
|
@@ -109750,8 +109732,8 @@ async function run23(argv, io) {
|
|
|
109750
109732
|
return emit(io, fail2("invalid_input", `${options}
|
|
109751
109733
|
usage: ${USAGE16}`));
|
|
109752
109734
|
const top = git7(io.cwd, ["rev-parse", "--show-toplevel"]);
|
|
109753
|
-
const repo = top.ok ?
|
|
109754
|
-
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);
|
|
109755
109737
|
let base = null;
|
|
109756
109738
|
let changed = null;
|
|
109757
109739
|
if (options.diff || options.mutate) {
|
|
@@ -109889,8 +109871,8 @@ var exports_youtrack = {};
|
|
|
109889
109871
|
__export(exports_youtrack, {
|
|
109890
109872
|
run: () => run25
|
|
109891
109873
|
});
|
|
109892
|
-
import { readFileSync as
|
|
109893
|
-
import
|
|
109874
|
+
import { readFileSync as readFileSync34 } from "node:fs";
|
|
109875
|
+
import path80 from "node:path";
|
|
109894
109876
|
async function run25(argv, io) {
|
|
109895
109877
|
const [sub, ...rest] = argv;
|
|
109896
109878
|
if (sub !== "note" && sub !== "time" && sub !== "meeting")
|
|
@@ -109936,7 +109918,7 @@ async function run25(argv, io) {
|
|
|
109936
109918
|
let markdown = flags.values.markdown ?? "";
|
|
109937
109919
|
if (flags.values.file)
|
|
109938
109920
|
try {
|
|
109939
|
-
markdown =
|
|
109921
|
+
markdown = readFileSync34(path80.resolve(io.cwd, flags.values.file), "utf8");
|
|
109940
109922
|
} catch (error) {
|
|
109941
109923
|
return usage4(io, `cannot read ${flags.values.file}: ${String(error)}`, USAGE18);
|
|
109942
109924
|
}
|
|
@@ -110007,8 +109989,8 @@ var exports_changelog = {};
|
|
|
110007
109989
|
__export(exports_changelog, {
|
|
110008
109990
|
run: () => run26
|
|
110009
109991
|
});
|
|
110010
|
-
import { readFileSync as
|
|
110011
|
-
import
|
|
109992
|
+
import { readFileSync as readFileSync35 } from "node:fs";
|
|
109993
|
+
import path81 from "node:path";
|
|
110012
109994
|
async function run26(argv, io) {
|
|
110013
109995
|
const [sub, ...rest] = argv;
|
|
110014
109996
|
if (sub !== "apply")
|
|
@@ -110054,7 +110036,7 @@ async function run26(argv, io) {
|
|
|
110054
110036
|
]);
|
|
110055
110037
|
}
|
|
110056
110038
|
var USAGE19 = "workit changelog apply (--entries <JSON|@file|-> | --normalize-only) [--path CHANGELOG.md] [--preview]", readEntries = (raw, cwd) => {
|
|
110057
|
-
const text = raw === "-" ?
|
|
110039
|
+
const text = raw === "-" ? readFileSync35(0, "utf8") : raw.startsWith("@") ? readFileSync35(path81.resolve(cwd, raw.slice(1)), "utf8") : raw;
|
|
110058
110040
|
return JSON.parse(text);
|
|
110059
110041
|
};
|
|
110060
110042
|
var init_changelog2 = __esm(() => {
|
|
@@ -110070,7 +110052,7 @@ __export(exports_handoff, {
|
|
|
110070
110052
|
run: () => run27
|
|
110071
110053
|
});
|
|
110072
110054
|
import fs37 from "node:fs";
|
|
110073
|
-
import
|
|
110055
|
+
import path82 from "node:path";
|
|
110074
110056
|
import { parseArgs as parseArgs2 } from "node:util";
|
|
110075
110057
|
function render3(brief) {
|
|
110076
110058
|
const lines = [
|
|
@@ -110110,9 +110092,9 @@ function bounded(brief, cwd) {
|
|
|
110110
110092
|
let file = null;
|
|
110111
110093
|
if (store.ok)
|
|
110112
110094
|
try {
|
|
110113
|
-
const dir =
|
|
110095
|
+
const dir = path82.join(store.value.root, "handoff");
|
|
110114
110096
|
fs37.mkdirSync(dir, { recursive: true });
|
|
110115
|
-
file =
|
|
110097
|
+
file = path82.join(dir, `${(brief.branch ?? "detached").replaceAll(/[^\w.-]+/gu, "-")}.txt`);
|
|
110116
110098
|
fs37.writeFileSync(file, `${[...body, ...tail].join(`
|
|
110117
110099
|
`)}
|
|
110118
110100
|
`, {
|
|
@@ -110187,7 +110169,7 @@ var init_handoff = __esm(() => {
|
|
|
110187
110169
|
});
|
|
110188
110170
|
|
|
110189
110171
|
// packages/workit-cli/src/main.ts
|
|
110190
|
-
import
|
|
110172
|
+
import path83 from "node:path";
|
|
110191
110173
|
|
|
110192
110174
|
// packages/workit-core/src/git/env-redirect.ts
|
|
110193
110175
|
var GIT_REDIRECT_ENV = [
|
|
@@ -111148,7 +111130,7 @@ var defaultIo = (json) => ({
|
|
|
111148
111130
|
});
|
|
111149
111131
|
async function main(argv, overrides = {}, options = {}) {
|
|
111150
111132
|
const parsed = parseGlobals(argv);
|
|
111151
|
-
const cwd =
|
|
111133
|
+
const cwd = path83.resolve(overrides.cwd ?? process.cwd(), parsed.cwd ?? ".");
|
|
111152
111134
|
const io = {
|
|
111153
111135
|
...defaultIo(parsed.json),
|
|
111154
111136
|
terminals: {
|