@brainervirus/workit-claude-code 8.45.2 → 8.45.4
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 +297 -326
- 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.4",
|
|
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.4",
|
|
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.4"
|
|
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 });
|
|
@@ -70673,7 +70689,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
70673
70689
|
status: "info",
|
|
70674
70690
|
detail: "could not list running codex processes (ps) — skipping"
|
|
70675
70691
|
};
|
|
70676
|
-
const stale = running.filter((proc) => startedBefore(proc, latest.at));
|
|
70692
|
+
const stale = running.filter((proc) => !/\bapp-server\b/.test(proc.args) && startedBefore(proc, latest.at));
|
|
70677
70693
|
if (stale.length === 0)
|
|
70678
70694
|
return {
|
|
70679
70695
|
id,
|
|
@@ -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(" | ");
|
|
@@ -76391,7 +76407,7 @@ var pluginApiArgs = (home) => [
|
|
|
76391
76407
|
"plugin.list",
|
|
76392
76408
|
"-H",
|
|
76393
76409
|
`x-opencode-directory:${home}`
|
|
76394
|
-
], PLUGIN_LIST, OPENCODE_READY_TIMEOUT_MS = 20000, READY_INTERVAL_MS = 500, OPENCODE_NOT_READY, isWorkitTarget = (target) => typeof target === "string" && /^(?:npm:)?@brainervirus\/workit-opencode(?:@[^/\s]+)?$/.test(target), lacksApi = (result) => result.status !== 0 && !result.timedOut && /\b(?:unknown|unrecognized|unsupported) (?:command|operation|argument)|\bno such (?:command|operation)/i.test(`${result.stdout}
|
|
76410
|
+
], PLUGIN_LIST, OPENCODE_READY_TIMEOUT_MS = 20000, READY_INTERVAL_MS = 500, OPENCODE_STALE = "update ran, but OpenCode still lists", OPENCODE_NOT_READY, isWorkitTarget = (target) => typeof target === "string" && /^(?:npm:)?@brainervirus\/workit-opencode(?:@[^/\s]+)?$/.test(target), lacksApi = (result) => result.status !== 0 && !result.timedOut && /\b(?:unknown|unrecognized|unsupported) (?:command|operation|argument)|\bno such (?:command|operation)/i.test(`${result.stdout}
|
|
76395
76411
|
${result.stderr ?? ""}`), parsePluginApi = (result) => {
|
|
76396
76412
|
if (result.status !== 0)
|
|
76397
76413
|
return null;
|
|
@@ -76427,7 +76443,22 @@ ${result.stderr ?? ""}`), parsePluginApi = (result) => {
|
|
|
76427
76443
|
return { via: "list", listed: true, version };
|
|
76428
76444
|
}
|
|
76429
76445
|
return { via: "list", listed: false };
|
|
76430
|
-
}, readOpencodePlugin = async (run, home) => parsePluginApi(await run("opencode", pluginApiArgs(home), { cwd: home })) ?? parsePluginList(await run("opencode", PLUGIN_LIST, { cwd: home })),
|
|
76446
|
+
}, readOpencodePlugin = async (run, home) => parsePluginApi(await run("opencode", pluginApiArgs(home), { cwd: home })) ?? parsePluginList(await run("opencode", PLUGIN_LIST, { cwd: home })), waitForOpencodeVersion = async (run, home, target, options = {}) => {
|
|
76447
|
+
const timeoutMs = options.timeoutMs ?? OPENCODE_READY_TIMEOUT_MS;
|
|
76448
|
+
const intervalMs = options.intervalMs ?? READY_INTERVAL_MS;
|
|
76449
|
+
const now = options.now ?? Date.now;
|
|
76450
|
+
const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
76451
|
+
const deadline = now() + timeoutMs;
|
|
76452
|
+
let version = (await readOpencodePlugin(run, home)).version;
|
|
76453
|
+
if (target === undefined)
|
|
76454
|
+
return version;
|
|
76455
|
+
const reached = (found) => found !== undefined && versionAtLeast(found, target);
|
|
76456
|
+
while (!reached(version) && now() < deadline) {
|
|
76457
|
+
await sleep(intervalMs);
|
|
76458
|
+
version = (await readOpencodePlugin(run, home)).version ?? version;
|
|
76459
|
+
}
|
|
76460
|
+
return version;
|
|
76461
|
+
}, waitForOpencodePlugin = async (run, home, options = {}) => {
|
|
76431
76462
|
const timeoutMs = options.timeoutMs ?? OPENCODE_READY_TIMEOUT_MS;
|
|
76432
76463
|
const intervalMs = options.intervalMs ?? READY_INTERVAL_MS;
|
|
76433
76464
|
const now = options.now ?? Date.now;
|
|
@@ -76595,18 +76626,6 @@ async function applyUpgrade(plan, deps = {}, options = {}) {
|
|
|
76595
76626
|
continue;
|
|
76596
76627
|
}
|
|
76597
76628
|
}
|
|
76598
|
-
const daemons = running.filter((proc) => proc.host === "codex" && proc.kind === "daemon");
|
|
76599
|
-
const stopDaemon = entry.host === "codex" && daemons.length > 0;
|
|
76600
|
-
const stopped = stopDaemon ? await progress.run("Stopping the Codex app-server daemon", () => runAsync("codex", ["app-server", "daemon", "stop"]), (result) => result.status === 0 ? "done" : "failed") : null;
|
|
76601
|
-
if (stopped && stopped.status !== 0) {
|
|
76602
|
-
hosts.push({
|
|
76603
|
-
host: "codex",
|
|
76604
|
-
status: "failed",
|
|
76605
|
-
reason: `could not stop the Codex app-server daemon (${daemons.map(describe2).join("; ")})${stderrTail(stopped.stderr) ? `: ${stderrTail(stopped.stderr)}` : ""}`,
|
|
76606
|
-
fix: "codex app-server daemon stop && workit upgrade --hosts=codex"
|
|
76607
|
-
});
|
|
76608
|
-
continue;
|
|
76609
|
-
}
|
|
76610
76629
|
let outcome;
|
|
76611
76630
|
try {
|
|
76612
76631
|
outcome = await applyEntry(entry, {
|
|
@@ -76624,10 +76643,10 @@ async function applyUpgrade(plan, deps = {}, options = {}) {
|
|
|
76624
76643
|
reason: `${outcome.reason}; ${agents.note}`,
|
|
76625
76644
|
fix: agents.fix
|
|
76626
76645
|
};
|
|
76627
|
-
else
|
|
76646
|
+
else
|
|
76628
76647
|
outcome = {
|
|
76629
76648
|
...outcome,
|
|
76630
|
-
reason: `${outcome.reason}
|
|
76649
|
+
reason: `${outcome.reason}${agents.note ? `; ${agents.note}` : ""}; new Codex threads load it`
|
|
76631
76650
|
};
|
|
76632
76651
|
}
|
|
76633
76652
|
} catch (error) {
|
|
@@ -76638,21 +76657,9 @@ async function applyUpgrade(plan, deps = {}, options = {}) {
|
|
|
76638
76657
|
fix: entry.fix
|
|
76639
76658
|
};
|
|
76640
76659
|
}
|
|
76641
|
-
if (stopDaemon) {
|
|
76642
|
-
const started = (await progress.run("Restarting the Codex app-server daemon", () => runAsync("codex", ["app-server", "daemon", "start"]), (result) => result.status === 0 ? "done" : "failed")).status === 0;
|
|
76643
|
-
outcome = started ? {
|
|
76644
|
-
...outcome,
|
|
76645
|
-
reason: `${outcome.reason}; app-server daemon stopped and started again`
|
|
76646
|
-
} : {
|
|
76647
|
-
...outcome,
|
|
76648
|
-
status: "failed",
|
|
76649
|
-
reason: `${outcome.reason}; the app-server daemon did not start again`,
|
|
76650
|
-
fix: "codex app-server daemon start"
|
|
76651
|
-
};
|
|
76652
|
-
}
|
|
76653
76660
|
if (entry.host === "opencode") {
|
|
76654
76661
|
const servers = running.filter((proc) => proc.host === "opencode" && proc.kind === "daemon");
|
|
76655
|
-
if (servers.length && outcome.
|
|
76662
|
+
if (servers.length && outcome.reason.startsWith(OPENCODE_STALE))
|
|
76656
76663
|
outcome = {
|
|
76657
76664
|
...outcome,
|
|
76658
76665
|
reason: `${outcome.reason}; restart opencode serve (${servers.map(describe2).join("; ")}) to load it`
|
|
@@ -76704,11 +76711,9 @@ var briefDetail = (detail) => {
|
|
|
76704
76711
|
}
|
|
76705
76712
|
const newest = versions.reduce((best, version) => best && versionAtLeast(best, version) ? best : version, null);
|
|
76706
76713
|
return newest ? path49.join(dir, newest) : null;
|
|
76707
|
-
},
|
|
76714
|
+
}, opencodeOutcome = async (before, target, runAsync, home, ready) => {
|
|
76708
76715
|
const below = (version) => target !== undefined && (version === undefined || !versionAtLeast(version, target));
|
|
76709
|
-
|
|
76710
|
-
if (below(after))
|
|
76711
|
-
after = await opencodeVersion(runAsync, home) ?? after;
|
|
76716
|
+
const after = await waitForOpencodeVersion(runAsync, home, target, ready);
|
|
76712
76717
|
const live = "OpenCode V2 loads it live";
|
|
76713
76718
|
if (before && target && versionAtLeast(before, target))
|
|
76714
76719
|
return { host: "opencode", status: "current", reason: `already current (${before})` };
|
|
@@ -76716,7 +76721,7 @@ var briefDetail = (detail) => {
|
|
|
76716
76721
|
return {
|
|
76717
76722
|
host: "opencode",
|
|
76718
76723
|
status: "updated",
|
|
76719
|
-
reason:
|
|
76724
|
+
reason: `${OPENCODE_STALE} ${after} (published ${target}); the doctor below checks its package cache`
|
|
76720
76725
|
};
|
|
76721
76726
|
if (before && after && after !== before)
|
|
76722
76727
|
return { host: "opencode", status: "updated", reason: `${before} -> ${after}; ${live}` };
|
|
@@ -76821,7 +76826,7 @@ ${result.stderr}`;
|
|
|
76821
76826
|
return fail(failureReason(command, result));
|
|
76822
76827
|
}
|
|
76823
76828
|
if (entry.host === "opencode")
|
|
76824
|
-
return opencodeOutcome(before, entry.published, runAsync, home);
|
|
76829
|
+
return opencodeOutcome(before, entry.published, runAsync, home, context.opencodeReady);
|
|
76825
76830
|
if (entry.host === "claude-code") {
|
|
76826
76831
|
const after = claudeWorkitInstalls(home, env, null).find((install) => install.id === entry.selector)?.version;
|
|
76827
76832
|
return after && after === entry.installedVersion ? {
|
|
@@ -76918,8 +76923,6 @@ __export(exports_update_check, {
|
|
|
76918
76923
|
writeUpdatesMode: () => writeUpdatesMode
|
|
76919
76924
|
});
|
|
76920
76925
|
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
76926
|
async function launchUpdateCheck(context, deps) {
|
|
76924
76927
|
if (!interactiveLaunch(context, deps))
|
|
76925
76928
|
return;
|
|
@@ -76977,7 +76980,7 @@ Cancelled.
|
|
|
76977
76980
|
if (outcome.code !== 0 && outcome.failed.length)
|
|
76978
76981
|
deps.write(`${style.warn("Upgrade incomplete:")} ${outcome.failed.map((row) => `${row.host} failed${row.fix ? ` (fix: ${row.fix})` : ""}`).join("; ")}
|
|
76979
76982
|
`);
|
|
76980
|
-
const onDisk = (deps.cliOnDisk ??
|
|
76983
|
+
const onDisk = (deps.cliOnDisk ?? cliVersionOnDisk)();
|
|
76981
76984
|
if (!onDisk || onDisk === installed) {
|
|
76982
76985
|
if (outcome.code !== 0)
|
|
76983
76986
|
deps.write(`${style.warn("Upgrade did not finish;")} running your command with ${installed}.
|
|
@@ -76986,20 +76989,7 @@ Cancelled.
|
|
|
76986
76989
|
}
|
|
76987
76990
|
return (deps.reexec ?? defaultReexec)(context.argv);
|
|
76988
76991
|
}
|
|
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 () => {
|
|
76992
|
+
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
76993
|
const failed = [];
|
|
77004
76994
|
const code = await (await Promise.resolve().then(() => (init_upgrade(), exports_upgrade))).runUpgradeCommand(["--yes"], {
|
|
77005
76995
|
out: process.stderr,
|
|
@@ -77070,12 +77060,12 @@ var init_update_check = __esm(() => {
|
|
|
77070
77060
|
// packages/workit-cli/src/upgrade/probes.ts
|
|
77071
77061
|
import { existsSync as existsSync23, mkdtempSync as mkdtempSync3, rmSync as rmSync8 } from "node:fs";
|
|
77072
77062
|
import os19 from "node:os";
|
|
77073
|
-
import
|
|
77063
|
+
import path50 from "node:path";
|
|
77074
77064
|
var PROBE_TIMEOUT_MS = 20000, probeKey = (command, args) => [command, ...args].join(" "), opencodeScratchEnv = (deps, scratch) => ({
|
|
77075
77065
|
...deps.env,
|
|
77076
|
-
XDG_DATA_HOME:
|
|
77077
|
-
XDG_STATE_HOME:
|
|
77078
|
-
XDG_CACHE_HOME:
|
|
77066
|
+
XDG_DATA_HOME: path50.join(scratch, "data"),
|
|
77067
|
+
XDG_STATE_HOME: path50.join(scratch, "state"),
|
|
77068
|
+
XDG_CACHE_HOME: path50.join(scratch, "cache")
|
|
77079
77069
|
}), registry2 = (name) => ["npm", ["view", name, "version"]], OPENCODE_READY_KEY = "opencode-ready", opencodeReading = (probes) => {
|
|
77080
77070
|
const result = probes?.get(OPENCODE_READY_KEY);
|
|
77081
77071
|
if (!result)
|
|
@@ -77090,7 +77080,7 @@ var PROBE_TIMEOUT_MS = 20000, probeKey = (command, args) => [command, ...args].j
|
|
|
77090
77080
|
const run = asyncRunner(deps, timeoutMs);
|
|
77091
77081
|
const probes = [];
|
|
77092
77082
|
const add = (command, args, runner = run) => probes.push([command, args, runner]);
|
|
77093
|
-
const scratch = mkdtempSync3(
|
|
77083
|
+
const scratch = mkdtempSync3(path50.join(os19.tmpdir(), "workit-upgrade-opencode-"));
|
|
77094
77084
|
try {
|
|
77095
77085
|
if (hosts.includes("opencode") && existsSync23(paths.opencodeConfig)) {
|
|
77096
77086
|
if (!options.check) {
|
|
@@ -77161,8 +77151,8 @@ var init_probes = __esm(() => {
|
|
|
77161
77151
|
});
|
|
77162
77152
|
|
|
77163
77153
|
// 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
|
|
77154
|
+
import { existsSync as existsSync24, mkdtempSync as mkdtempSync4, rmSync as rmSync9, lstatSync as lstatSync9, readFileSync as readFileSync25 } from "node:fs";
|
|
77155
|
+
import path51 from "node:path";
|
|
77166
77156
|
import os20 from "node:os";
|
|
77167
77157
|
function previewUpgrade(hosts = HOSTS2, deps = {}, probes) {
|
|
77168
77158
|
const paths = upgradePaths(deps);
|
|
@@ -77186,9 +77176,9 @@ function previewUpgrade(hosts = HOSTS2, deps = {}, probes) {
|
|
|
77186
77176
|
for (const file of [
|
|
77187
77177
|
paths.opencodeConfig,
|
|
77188
77178
|
paths.opencodeConfig + "c",
|
|
77189
|
-
|
|
77190
|
-
|
|
77191
|
-
|
|
77179
|
+
path51.join(home, ".cursor/settings.json"),
|
|
77180
|
+
path51.join(home, ".cursor/mcp.json"),
|
|
77181
|
+
path51.join(paths.cursorRoot, "package.json"),
|
|
77192
77182
|
paths.codexConfig,
|
|
77193
77183
|
paths.piSettings
|
|
77194
77184
|
])
|
|
@@ -77340,7 +77330,7 @@ function previewUpgrade(hosts = HOSTS2, deps = {}, probes) {
|
|
|
77340
77330
|
var codexRegistered = (configFile) => {
|
|
77341
77331
|
let text;
|
|
77342
77332
|
try {
|
|
77343
|
-
text =
|
|
77333
|
+
text = readFileSync25(configFile, "utf8");
|
|
77344
77334
|
} catch {
|
|
77345
77335
|
return false;
|
|
77346
77336
|
}
|
|
@@ -77383,8 +77373,8 @@ var codexRegistered = (configFile) => {
|
|
|
77383
77373
|
result.push(classify("opencode", pin));
|
|
77384
77374
|
});
|
|
77385
77375
|
guard("cursor", () => {
|
|
77386
|
-
const cursor = objectOrNull(
|
|
77387
|
-
const mcp = objectOrNull(
|
|
77376
|
+
const cursor = objectOrNull(path51.join(paths.cursorRoot, "package.json"));
|
|
77377
|
+
const mcp = objectOrNull(path51.join(home, ".cursor/mcp.json"));
|
|
77388
77378
|
const args = mcp?.mcpServers?.workit?.args ?? [];
|
|
77389
77379
|
const arg = args.find((value) => typeof value === "string" && value.startsWith("--package="));
|
|
77390
77380
|
const selector = typeof arg === "string" ? arg.slice(10) : "local";
|
|
@@ -77395,7 +77385,7 @@ var codexRegistered = (configFile) => {
|
|
|
77395
77385
|
});
|
|
77396
77386
|
return;
|
|
77397
77387
|
}
|
|
77398
|
-
const settings = objectOrNull(
|
|
77388
|
+
const settings = objectOrNull(path51.join(home, ".cursor/settings.json"));
|
|
77399
77389
|
const dirs = Array.isArray(settings?.plugin_dirs) ? settings.plugin_dirs : [];
|
|
77400
77390
|
const registered = mcp?.mcpServers?.workit !== undefined || dirs.some((dir) => String(dir).replaceAll("\\", "/").replace(/\/+$/, "").endsWith("local/workit"));
|
|
77401
77391
|
if (registered)
|
|
@@ -77410,7 +77400,7 @@ var codexRegistered = (configFile) => {
|
|
|
77410
77400
|
if (typeof source !== "string")
|
|
77411
77401
|
continue;
|
|
77412
77402
|
const npm = /^(?:npm:)?@brainervirus\/workit-pi(?:@[^/]+)?$/.test(source);
|
|
77413
|
-
const local =
|
|
77403
|
+
const local = path51.isAbsolute(source) && source.replaceAll("\\", "/").endsWith("/packages/workit-pi") && object2(path51.join(source, "package.json"))?.name === "@brainervirus/workit-pi";
|
|
77414
77404
|
if (!npm && !local)
|
|
77415
77405
|
continue;
|
|
77416
77406
|
const found = classify("pi", source);
|
|
@@ -77477,7 +77467,7 @@ var codexRegistered = (configFile) => {
|
|
|
77477
77467
|
const cached = probes?.get(probeKey("opencode", args));
|
|
77478
77468
|
if (cached)
|
|
77479
77469
|
return cached;
|
|
77480
|
-
const scratch = mkdtempSync4(
|
|
77470
|
+
const scratch = mkdtempSync4(path51.join(os20.tmpdir(), "workit-upgrade-opencode-"));
|
|
77481
77471
|
try {
|
|
77482
77472
|
return runner({ ...deps, env: opencodeScratchEnv(deps, scratch) })("opencode", args);
|
|
77483
77473
|
} finally {
|
|
@@ -77488,7 +77478,7 @@ var codexRegistered = (configFile) => {
|
|
|
77488
77478
|
return probes ? (command, args) => probes.get(probeKey(command, args)) ?? run(command, args) : run;
|
|
77489
77479
|
}, planCli = (plan, run) => {
|
|
77490
77480
|
const root = run("npm", ["root", "--global"]);
|
|
77491
|
-
if (root.status !== 0 || !
|
|
77481
|
+
if (root.status !== 0 || !path51.isAbsolute(root.stdout.trim())) {
|
|
77492
77482
|
plan.skipped.push({
|
|
77493
77483
|
host: "cli",
|
|
77494
77484
|
reason: "global npm location could not be verified",
|
|
@@ -77496,9 +77486,9 @@ var codexRegistered = (configFile) => {
|
|
|
77496
77486
|
});
|
|
77497
77487
|
return;
|
|
77498
77488
|
}
|
|
77499
|
-
const packageFile =
|
|
77489
|
+
const packageFile = path51.join(root.stdout.trim(), "@brainervirus/workit-cli/package.json");
|
|
77500
77490
|
const installed = objectOrNull(packageFile);
|
|
77501
|
-
if (installed?.name !== "@brainervirus/workit-cli" || lstatSync9(
|
|
77491
|
+
if (installed?.name !== "@brainervirus/workit-cli" || lstatSync9(path51.dirname(packageFile)).isSymbolicLink()) {
|
|
77502
77492
|
plan.skipped.push({
|
|
77503
77493
|
host: "cli",
|
|
77504
77494
|
reason: "no managed global CLI install (local links preserved); use npx @brainervirus/workit-cli@latest"
|
|
@@ -77538,7 +77528,7 @@ var init_plan = __esm(() => {
|
|
|
77538
77528
|
});
|
|
77539
77529
|
|
|
77540
77530
|
// packages/workit-cli/src/upgrade/check.ts
|
|
77541
|
-
import
|
|
77531
|
+
import path52 from "node:path";
|
|
77542
77532
|
async function runUpdateCheck(json, deps) {
|
|
77543
77533
|
const out = deps.out ?? process.stdout;
|
|
77544
77534
|
const paths = upgradePaths(deps);
|
|
@@ -77659,7 +77649,7 @@ function runSetUpdates(value, deps) {
|
|
|
77659
77649
|
`);
|
|
77660
77650
|
return 1;
|
|
77661
77651
|
}
|
|
77662
|
-
out.write(`updates: ${value} (saved in ${
|
|
77652
|
+
out.write(`updates: ${value} (saved in ${path52.join(configDir, "config.json")})
|
|
77663
77653
|
`);
|
|
77664
77654
|
return 0;
|
|
77665
77655
|
}
|
|
@@ -77759,9 +77749,9 @@ __export(exports_upgrade, {
|
|
|
77759
77749
|
runUpgradeCommand: () => runUpgradeCommand
|
|
77760
77750
|
});
|
|
77761
77751
|
import { spawnSync as spawnSync19 } from "node:child_process";
|
|
77762
|
-
import { mkdtempSync as mkdtempSync5, readFileSync as
|
|
77752
|
+
import { mkdtempSync as mkdtempSync5, readFileSync as readFileSync26, rmSync as rmSync10, writeFileSync as writeFileSync14 } from "node:fs";
|
|
77763
77753
|
import os21 from "node:os";
|
|
77764
|
-
import
|
|
77754
|
+
import path53 from "node:path";
|
|
77765
77755
|
async function runUpgradeCommand(argv, deps = {}) {
|
|
77766
77756
|
const { env } = upgradePaths(deps);
|
|
77767
77757
|
const handBack = env[CONTINUE_ENV] !== undefined ? env[ROWS_ENV] : undefined;
|
|
@@ -77876,10 +77866,10 @@ Nothing changed.
|
|
|
77876
77866
|
json
|
|
77877
77867
|
}));
|
|
77878
77868
|
const handoff = async (cli) => {
|
|
77879
|
-
if (!reexec || (deps.cliOnDisk ??
|
|
77869
|
+
if (!reexec || (deps.cliOnDisk ?? cliVersionOnDisk)() !== plan.cli?.latest)
|
|
77880
77870
|
return;
|
|
77881
|
-
const scratch = mkdtempSync5(
|
|
77882
|
-
const rowsFile =
|
|
77871
|
+
const scratch = mkdtempSync5(path53.join(os21.tmpdir(), "workit-upgrade-"));
|
|
77872
|
+
const rowsFile = path53.join(scratch, "rows.json");
|
|
77883
77873
|
try {
|
|
77884
77874
|
const code = await reexec([
|
|
77885
77875
|
...legacy ? ["--apply", "--confirm"] : ["--yes"],
|
|
@@ -78009,7 +77999,7 @@ var USAGE3 = `Usage: workit upgrade [--hosts=opencode,cursor,codex,pi,claude-cod
|
|
|
78009
77999
|
workit upgrade --set-updates=prompt|auto|off
|
|
78010
78000
|
`, CONTINUE_ENV = "WORKIT_UPGRADE_CONTINUE", ROWS_ENV = "WORKIT_UPGRADE_ROWS", readText5 = (file) => {
|
|
78011
78001
|
try {
|
|
78012
|
-
return
|
|
78002
|
+
return readFileSync26(file, "utf8");
|
|
78013
78003
|
} catch {
|
|
78014
78004
|
return;
|
|
78015
78005
|
}
|
|
@@ -78034,26 +78024,6 @@ var USAGE3 = `Usage: workit upgrade [--hosts=opencode,cursor,codex,pi,claude-cod
|
|
|
78034
78024
|
} catch {
|
|
78035
78025
|
return;
|
|
78036
78026
|
}
|
|
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
78027
|
}, spawnUpgrade = (options) => (argv, extra) => {
|
|
78058
78028
|
if (!options.entry)
|
|
78059
78029
|
return;
|
|
@@ -78076,6 +78046,7 @@ var init_upgrade = __esm(() => {
|
|
|
78076
78046
|
init_host_permissions();
|
|
78077
78047
|
init_progress();
|
|
78078
78048
|
init_style();
|
|
78049
|
+
init_update_settings();
|
|
78079
78050
|
init_apply();
|
|
78080
78051
|
init_check();
|
|
78081
78052
|
init_plan();
|
|
@@ -78110,7 +78081,7 @@ var init_launch = __esm(() => {
|
|
|
78110
78081
|
// packages/workit-core/src/knowledge.ts
|
|
78111
78082
|
import { spawnSync as spawnSync20 } from "node:child_process";
|
|
78112
78083
|
import fs20 from "node:fs";
|
|
78113
|
-
import
|
|
78084
|
+
import path54 from "node:path";
|
|
78114
78085
|
function lintKnowledge(root) {
|
|
78115
78086
|
const seen = new Set;
|
|
78116
78087
|
const unreadable = [];
|
|
@@ -78214,7 +78185,7 @@ var AGENTS_BYTE_BUDGET, STEERING_FILES, NEED_BASED_FILES, STANDARDS_FILE = "CODI
|
|
|
78214
78185
|
const end = lines.indexOf("---", 1);
|
|
78215
78186
|
return end === -1 ? lines : [...lines.slice(0, end + 1).map(() => ""), ...lines.slice(end + 1)];
|
|
78216
78187
|
}, read = (root, file) => {
|
|
78217
|
-
const full =
|
|
78188
|
+
const full = path54.join(root, file);
|
|
78218
78189
|
try {
|
|
78219
78190
|
fs20.lstatSync(full);
|
|
78220
78191
|
} catch {
|
|
@@ -78255,7 +78226,7 @@ var AGENTS_BYTE_BUDGET, STEERING_FILES, NEED_BASED_FILES, STANDARDS_FILE = "CODI
|
|
|
78255
78226
|
}
|
|
78256
78227
|
}, brokenLinks = (root, doc, tracked) => {
|
|
78257
78228
|
const findings = [];
|
|
78258
|
-
const base =
|
|
78229
|
+
const base = path54.dirname(path54.join(root, doc.file));
|
|
78259
78230
|
const missing = (target, line, how) => findings.push({
|
|
78260
78231
|
rule: "broken-link",
|
|
78261
78232
|
file: doc.file,
|
|
@@ -78274,7 +78245,7 @@ var AGENTS_BYTE_BUDGET, STEERING_FILES, NEED_BASED_FILES, STANDARDS_FILE = "CODI
|
|
|
78274
78245
|
const local = localTarget(target);
|
|
78275
78246
|
if (!local)
|
|
78276
78247
|
continue;
|
|
78277
|
-
const resolved = local.startsWith("/") ?
|
|
78248
|
+
const resolved = local.startsWith("/") ? path54.join(root, local) : path54.resolve(base, local);
|
|
78278
78249
|
if (!exists2(resolved))
|
|
78279
78250
|
missing(target, index + 1, "link");
|
|
78280
78251
|
}
|
|
@@ -78284,9 +78255,9 @@ var AGENTS_BYTE_BUDGET, STEERING_FILES, NEED_BASED_FILES, STANDARDS_FILE = "CODI
|
|
|
78284
78255
|
continue;
|
|
78285
78256
|
const relative = /^\.\.?\//.test(candidate);
|
|
78286
78257
|
const first = candidate.split("/")[0];
|
|
78287
|
-
if (!relative && !(tracked ? tracked.has(first) : exists2(
|
|
78258
|
+
if (!relative && !(tracked ? tracked.has(first) : exists2(path54.join(root, first))))
|
|
78288
78259
|
continue;
|
|
78289
|
-
const resolved = relative ?
|
|
78260
|
+
const resolved = relative ? path54.resolve(base, candidate) : path54.join(root, candidate);
|
|
78290
78261
|
if (!exists2(resolved))
|
|
78291
78262
|
missing(span, index + 1, "pointer");
|
|
78292
78263
|
}
|
|
@@ -78656,7 +78627,7 @@ import { spawn as spawn4, spawnSync as spawnSync21 } from "node:child_process";
|
|
|
78656
78627
|
import { createHash as createHash17 } from "node:crypto";
|
|
78657
78628
|
import fs21 from "node:fs";
|
|
78658
78629
|
import os22 from "node:os";
|
|
78659
|
-
import
|
|
78630
|
+
import path55 from "node:path";
|
|
78660
78631
|
import { StringDecoder } from "node:string_decoder";
|
|
78661
78632
|
function tailLines(text, lines = TAIL_LINES) {
|
|
78662
78633
|
const all = text.replace(/\r\n?/gu, `
|
|
@@ -78776,7 +78747,7 @@ function planSpawn(argv, options) {
|
|
|
78776
78747
|
return { file: argv[0], args: [], verbatim: false, shell: true };
|
|
78777
78748
|
if (options.platform !== "win32")
|
|
78778
78749
|
return { file: argv[0], args: argv.slice(1), verbatim: false, shell: false };
|
|
78779
|
-
const win =
|
|
78750
|
+
const win = path55.win32;
|
|
78780
78751
|
const isFile = options.isFile ?? ((file) => {
|
|
78781
78752
|
try {
|
|
78782
78753
|
return fs21.statSync(file).isFile();
|
|
@@ -78938,10 +78909,10 @@ function runCheckCommand(argv, options) {
|
|
|
78938
78909
|
function storeLog(storeRoot, log) {
|
|
78939
78910
|
const digest = logDigest(log);
|
|
78940
78911
|
const ref = `blobs/logs/${digest.slice("sha256:".length)}.log`;
|
|
78941
|
-
const file =
|
|
78912
|
+
const file = path55.join(storeRoot, ref);
|
|
78942
78913
|
try {
|
|
78943
78914
|
if (!fs21.existsSync(file)) {
|
|
78944
|
-
fs21.mkdirSync(
|
|
78915
|
+
fs21.mkdirSync(path55.dirname(file), { recursive: true });
|
|
78945
78916
|
const temp = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
78946
78917
|
fs21.writeFileSync(temp, log, { mode: 384 });
|
|
78947
78918
|
fs21.renameSync(temp, file);
|
|
@@ -78954,7 +78925,7 @@ function storeLog(storeRoot, log) {
|
|
|
78954
78925
|
function pruneCheckLogs(storeRoot, options = {}) {
|
|
78955
78926
|
const limits = { ...LOG_RETENTION, ...options.retention };
|
|
78956
78927
|
const now = options.now ?? Date.now();
|
|
78957
|
-
const dir =
|
|
78928
|
+
const dir = path55.join(storeRoot, "blobs", "logs");
|
|
78958
78929
|
const report = { removed: 0, removedBytes: 0, kept: 0 };
|
|
78959
78930
|
let names;
|
|
78960
78931
|
try {
|
|
@@ -78964,7 +78935,7 @@ function pruneCheckLogs(storeRoot, options = {}) {
|
|
|
78964
78935
|
}
|
|
78965
78936
|
const files = names.flatMap((name) => {
|
|
78966
78937
|
try {
|
|
78967
|
-
const stat = fs21.statSync(
|
|
78938
|
+
const stat = fs21.statSync(path55.join(dir, name));
|
|
78968
78939
|
return stat.isFile() ? [{ name, size: stat.size, mtimeMs: stat.mtimeMs }] : [];
|
|
78969
78940
|
} catch {
|
|
78970
78941
|
return [];
|
|
@@ -78983,7 +78954,7 @@ function pruneCheckLogs(storeRoot, options = {}) {
|
|
|
78983
78954
|
continue;
|
|
78984
78955
|
if (!options.dryRun)
|
|
78985
78956
|
try {
|
|
78986
|
-
fs21.rmSync(
|
|
78957
|
+
fs21.rmSync(path55.join(dir, file.name), { force: true });
|
|
78987
78958
|
} catch {
|
|
78988
78959
|
continue;
|
|
78989
78960
|
}
|
|
@@ -79723,12 +79694,12 @@ var init_workspace = __esm(() => {
|
|
|
79723
79694
|
|
|
79724
79695
|
// packages/workit-core/src/core/heavy-rules.ts
|
|
79725
79696
|
import fs22 from "node:fs";
|
|
79726
|
-
import
|
|
79697
|
+
import path56 from "node:path";
|
|
79727
79698
|
function gitTop(cwd) {
|
|
79728
|
-
for (let dir =
|
|
79729
|
-
if (fs22.existsSync(
|
|
79699
|
+
for (let dir = path56.resolve(cwd);; dir = path56.dirname(dir)) {
|
|
79700
|
+
if (fs22.existsSync(path56.join(dir, ".git")))
|
|
79730
79701
|
return dir;
|
|
79731
|
-
if (
|
|
79702
|
+
if (path56.dirname(dir) === dir)
|
|
79732
79703
|
return null;
|
|
79733
79704
|
}
|
|
79734
79705
|
}
|
|
@@ -79770,18 +79741,18 @@ var init_heavy_rules = () => {};
|
|
|
79770
79741
|
// packages/workit-core/src/core/heavy.ts
|
|
79771
79742
|
import fs23 from "node:fs";
|
|
79772
79743
|
import os23 from "node:os";
|
|
79773
|
-
import
|
|
79744
|
+
import path57 from "node:path";
|
|
79774
79745
|
function stateDir2(env, platform = process.platform) {
|
|
79775
79746
|
if (env.WORKFLOW_TOOLKIT_STATE)
|
|
79776
79747
|
return env.WORKFLOW_TOOLKIT_STATE;
|
|
79777
79748
|
if (env.XDG_STATE_HOME)
|
|
79778
|
-
return
|
|
79749
|
+
return path57.join(env.XDG_STATE_HOME, "workit");
|
|
79779
79750
|
const home = env.HOME || os23.homedir();
|
|
79780
79751
|
if (platform === "darwin")
|
|
79781
|
-
return
|
|
79752
|
+
return path57.join(home, "Library", "Application Support", "workit");
|
|
79782
79753
|
if (platform === "win32")
|
|
79783
|
-
return
|
|
79784
|
-
return
|
|
79754
|
+
return path57.join(env.LOCALAPPDATA ?? path57.join(home, "AppData", "Local"), "workit");
|
|
79755
|
+
return path57.join(home, ".local", "state", "workit");
|
|
79785
79756
|
}
|
|
79786
79757
|
function positional(words, from, values = PM_VALUES) {
|
|
79787
79758
|
let index = from;
|
|
@@ -79921,7 +79892,7 @@ function machinePatterns(env) {
|
|
|
79921
79892
|
return isRecord8(value) ? stringList2(value.patterns) : [];
|
|
79922
79893
|
}
|
|
79923
79894
|
function repoPatterns(cwd) {
|
|
79924
|
-
return repoHeavyCommands(gitTop(cwd) ??
|
|
79895
|
+
return repoHeavyCommands(gitTop(cwd) ?? path57.resolve(cwd));
|
|
79925
79896
|
}
|
|
79926
79897
|
function heavyLines(lines, options) {
|
|
79927
79898
|
const found = [];
|
|
@@ -80000,7 +79971,7 @@ function leaseRewrite(command) {
|
|
|
80000
79971
|
return null;
|
|
80001
79972
|
return `${prefix}workit check --heavy -- ${rest}`;
|
|
80002
79973
|
}
|
|
80003
|
-
var HEAVY_COMMANDS_FILE = "heavy-commands.json", heavyCommandsFile = (env) =>
|
|
79974
|
+
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
79975
|
try {
|
|
80005
79976
|
return JSON.parse(fs23.readFileSync(file, "utf8"));
|
|
80006
79977
|
} catch {
|
|
@@ -80147,7 +80118,7 @@ var init_heavy = __esm(() => {
|
|
|
80147
80118
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
80148
80119
|
import fs24 from "node:fs";
|
|
80149
80120
|
import os24 from "node:os";
|
|
80150
|
-
import
|
|
80121
|
+
import path58 from "node:path";
|
|
80151
80122
|
function memoryValue(value, host) {
|
|
80152
80123
|
const text = typeof value === "number" ? String(value) : typeof value === "string" ? value : "";
|
|
80153
80124
|
const percent = PERCENT.exec(text.trim());
|
|
@@ -80343,7 +80314,7 @@ function tryOnce(options, record, reclaimed) {
|
|
|
80343
80314
|
const text = `${JSON.stringify(record)}
|
|
80344
80315
|
`;
|
|
80345
80316
|
for (let slot = 0;slot < options.slots; slot += 1) {
|
|
80346
|
-
const file =
|
|
80317
|
+
const file = path58.join(options.dir, `slot-${slot}.json`);
|
|
80347
80318
|
for (let attempt = 0;attempt < 2; attempt += 1) {
|
|
80348
80319
|
try {
|
|
80349
80320
|
const fd = fs24.openSync(file, "wx", 384);
|
|
@@ -80388,7 +80359,7 @@ function leaseQueue(dir, probe = {}) {
|
|
|
80388
80359
|
}
|
|
80389
80360
|
const entries = [];
|
|
80390
80361
|
for (const name of names.filter((item) => item.endsWith(".json")).toSorted()) {
|
|
80391
|
-
const file =
|
|
80362
|
+
const file = path58.join(queueDir(dir), name);
|
|
80392
80363
|
const record = parseLease(readText6(file));
|
|
80393
80364
|
if (!record)
|
|
80394
80365
|
continue;
|
|
@@ -80404,9 +80375,9 @@ function leaseQueue(dir, probe = {}) {
|
|
|
80404
80375
|
function waitersAhead(options, own) {
|
|
80405
80376
|
let ahead = 0;
|
|
80406
80377
|
for (const entry of leaseQueue(options.dir, options.probe)) {
|
|
80407
|
-
if (
|
|
80378
|
+
if (path58.basename(entry.file) >= own)
|
|
80408
80379
|
break;
|
|
80409
|
-
if (!TICKET.test(
|
|
80380
|
+
if (!TICKET.test(path58.basename(entry.file)))
|
|
80410
80381
|
continue;
|
|
80411
80382
|
if (entry.stale && reclaim(entry.file, (current) => !current || staleReason(current, options.probe) !== null))
|
|
80412
80383
|
continue;
|
|
@@ -80418,7 +80389,7 @@ function liveHolders(options) {
|
|
|
80418
80389
|
return leaseSlots(options.dir, options.slots, options.probe).filter((slot) => slot.holder && !slot.stale).map((slot) => slot.holder);
|
|
80419
80390
|
}
|
|
80420
80391
|
function writeTicket(file, record) {
|
|
80421
|
-
fs24.mkdirSync(
|
|
80392
|
+
fs24.mkdirSync(path58.dirname(file), { recursive: true, mode: 448 });
|
|
80422
80393
|
fs24.writeFileSync(file, `${JSON.stringify(record)}
|
|
80423
80394
|
`, { mode: 384 });
|
|
80424
80395
|
}
|
|
@@ -80463,7 +80434,7 @@ async function acquireLease(options) {
|
|
|
80463
80434
|
const reclaimed = [];
|
|
80464
80435
|
let waitedOn = [];
|
|
80465
80436
|
const name = ticketName(started, record.id);
|
|
80466
|
-
const ticket =
|
|
80437
|
+
const ticket = path58.join(queueDir(options.dir), name);
|
|
80467
80438
|
const ticketRecord = {
|
|
80468
80439
|
...record,
|
|
80469
80440
|
maxAgeMs: options.waitMs + 60000
|
|
@@ -80584,7 +80555,7 @@ function heldLease(dir, id, options = {}) {
|
|
|
80584
80555
|
for (const name of names) {
|
|
80585
80556
|
if (!/^slot-\d+\.json$/u.test(name))
|
|
80586
80557
|
continue;
|
|
80587
|
-
const lease = parseLease(readText6(
|
|
80558
|
+
const lease = parseLease(readText6(path58.join(dir, name)));
|
|
80588
80559
|
if (lease?.id === id && !staleReason(lease, options.probe) && (options.ancestor ?? isAncestor)(lease.pid))
|
|
80589
80560
|
return lease;
|
|
80590
80561
|
}
|
|
@@ -80639,10 +80610,10 @@ async function runScoped(run, wrapper, sinks) {
|
|
|
80639
80610
|
}
|
|
80640
80611
|
function firstNotice(env, session, key, now = Date.now()) {
|
|
80641
80612
|
const id = (session ?? `ppid-${process.ppid}`).replace(/[^A-Za-z0-9_.-]/gu, "_").slice(0, 120);
|
|
80642
|
-
const dir =
|
|
80613
|
+
const dir = path58.join(stateDir2(env), "notices");
|
|
80643
80614
|
try {
|
|
80644
80615
|
fs24.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
80645
|
-
fs24.writeFileSync(
|
|
80616
|
+
fs24.writeFileSync(path58.join(dir, `${key}-${id}`), `${new Date(now).toISOString()}
|
|
80646
80617
|
`, {
|
|
80647
80618
|
flag: "wx",
|
|
80648
80619
|
mode: 384
|
|
@@ -80652,7 +80623,7 @@ function firstNotice(env, session, key, now = Date.now()) {
|
|
|
80652
80623
|
}
|
|
80653
80624
|
try {
|
|
80654
80625
|
for (const name of fs24.readdirSync(dir)) {
|
|
80655
|
-
const file =
|
|
80626
|
+
const file = path58.join(dir, name);
|
|
80656
80627
|
if (now - fs24.statSync(file).mtimeMs > NOTICE_TTL_MS)
|
|
80657
80628
|
fs24.rmSync(file, { force: true });
|
|
80658
80629
|
}
|
|
@@ -80662,7 +80633,7 @@ function firstNotice(env, session, key, now = Date.now()) {
|
|
|
80662
80633
|
function leaseSlots(dir, slots, probe = {}) {
|
|
80663
80634
|
const states = [];
|
|
80664
80635
|
for (let slot = 0;slot < slots; slot += 1) {
|
|
80665
|
-
const lease = parseLease(readText6(
|
|
80636
|
+
const lease = parseLease(readText6(path58.join(dir, `slot-${slot}.json`)));
|
|
80666
80637
|
states.push({
|
|
80667
80638
|
slot,
|
|
80668
80639
|
holder: lease ? holderOf(lease) : null,
|
|
@@ -80674,7 +80645,7 @@ function leaseSlots(dir, slots, probe = {}) {
|
|
|
80674
80645
|
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
80646
|
totalMemBytes: os24.totalmem(),
|
|
80676
80647
|
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) =>
|
|
80648
|
+
}), isRecord9 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), SIZE, PERCENT, UNITS, leaseDir = (env) => path58.join(stateDir2(env), "leases"), readText6 = (file) => {
|
|
80678
80649
|
try {
|
|
80679
80650
|
return fs24.readFileSync(file, "utf8");
|
|
80680
80651
|
} catch {
|
|
@@ -80705,7 +80676,7 @@ var DEFAULT_HEAVY_CHECKS, DEFAULT_LIGHT_CHECKS, DEFAULT_SLOTS = 1, DEFAULT_WAIT_
|
|
|
80705
80676
|
cwd: lease.cwd,
|
|
80706
80677
|
session: lease.session,
|
|
80707
80678
|
startedAt: lease.startedAt
|
|
80708
|
-
}), realClock, queueDir = (dir) =>
|
|
80679
|
+
}), 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
80680
|
var init_resources = __esm(() => {
|
|
80710
80681
|
init_checks3();
|
|
80711
80682
|
init_heavy();
|
|
@@ -80735,7 +80706,7 @@ __export(exports_check, {
|
|
|
80735
80706
|
workspaceResources: () => workspaceResources
|
|
80736
80707
|
});
|
|
80737
80708
|
import os25 from "node:os";
|
|
80738
|
-
import
|
|
80709
|
+
import path59 from "node:path";
|
|
80739
80710
|
function parse6(argv) {
|
|
80740
80711
|
const split = argv.indexOf("--");
|
|
80741
80712
|
const head = split >= 0 ? argv.slice(0, split) : [...argv];
|
|
@@ -80966,7 +80937,7 @@ ${footer}`;
|
|
|
80966
80937
|
}
|
|
80967
80938
|
async function workspaceResources(io) {
|
|
80968
80939
|
const env = io.env;
|
|
80969
|
-
const dir = env.WORKFLOW_TOOLKIT_CONFIG ?? env.WORKFLOW_TOOLKIT_CONFIG_DIR ??
|
|
80940
|
+
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
80941
|
try {
|
|
80971
80942
|
await Promise.resolve().then(() => init_workspaces());
|
|
80972
80943
|
const workspace = resolveWorkspaceFrom(io.cwd, dir, env.WORKFLOW_WORKSPACE_NAME?.trim() || undefined);
|
|
@@ -81108,7 +81079,7 @@ async function run12(argv, io) {
|
|
|
81108
81079
|
if (options.shell && command.length !== 1)
|
|
81109
81080
|
return emit(io, fail2("invalid_input", '--shell takes the command as one string: workit check --shell -- "<cmd>"'));
|
|
81110
81081
|
}
|
|
81111
|
-
const relCwd = posix(
|
|
81082
|
+
const relCwd = posix(path59.relative(top, runCwd));
|
|
81112
81083
|
const configured = !options.shell && matchesNamedCheck(config, name, command, relCwd);
|
|
81113
81084
|
const shadowed = !configured && name !== null ? config.checks.find((item) => item.name === name) : undefined;
|
|
81114
81085
|
if (shadowed)
|
|
@@ -81173,7 +81144,7 @@ async function run12(argv, io) {
|
|
|
81173
81144
|
const modifiedWorktree = key.tree !== null && treeAfter !== key.tree;
|
|
81174
81145
|
const store = storeRoot(io.cwd);
|
|
81175
81146
|
const blob = store.ok ? storeLog(store.value.root, result.log) : null;
|
|
81176
|
-
const logPath = store.ok && blob ?
|
|
81147
|
+
const logPath = store.ok && blob ? path59.join(store.value.root, blob.ref) : null;
|
|
81177
81148
|
const tail = tailLines(result.log, TAIL_LINES);
|
|
81178
81149
|
const passed = result.exitCode === 0 && !result.timedOut;
|
|
81179
81150
|
const bounded = boundedArgv(command);
|
|
@@ -81288,7 +81259,7 @@ async function run12(argv, io) {
|
|
|
81288
81259
|
return recordError.code === "busy" ? 4 : recordError.code === "invalid_input" ? 2 : 5;
|
|
81289
81260
|
return 0;
|
|
81290
81261
|
}
|
|
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(
|
|
81262
|
+
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
81263
|
var init_check2 = __esm(() => {
|
|
81293
81264
|
init_check_config();
|
|
81294
81265
|
init_checks3();
|
|
@@ -81319,7 +81290,7 @@ __export(exports_lock, {
|
|
|
81319
81290
|
run: () => run13
|
|
81320
81291
|
});
|
|
81321
81292
|
import fs25 from "node:fs";
|
|
81322
|
-
import
|
|
81293
|
+
import path60 from "node:path";
|
|
81323
81294
|
async function settingsFor(io) {
|
|
81324
81295
|
const workspace = await workspaceResources(io);
|
|
81325
81296
|
const config = loadCheckConfig(io.cwd);
|
|
@@ -81411,7 +81382,7 @@ function readPatterns(file) {
|
|
|
81411
81382
|
return { patterns: [] };
|
|
81412
81383
|
}
|
|
81413
81384
|
function writePatterns(file, value) {
|
|
81414
|
-
fs25.mkdirSync(
|
|
81385
|
+
fs25.mkdirSync(path60.dirname(file), { recursive: true, mode: 448 });
|
|
81415
81386
|
const temp = `${file}.${process.pid}.tmp`;
|
|
81416
81387
|
fs25.writeFileSync(temp, `${JSON.stringify(value, null, 2)}
|
|
81417
81388
|
`, { mode: 384 });
|
|
@@ -81497,9 +81468,9 @@ var exports_models = {};
|
|
|
81497
81468
|
__export(exports_models, {
|
|
81498
81469
|
run: () => run14
|
|
81499
81470
|
});
|
|
81500
|
-
import { existsSync as existsSync26, readdirSync as readdirSync13, readFileSync as
|
|
81471
|
+
import { existsSync as existsSync26, readdirSync as readdirSync13, readFileSync as readFileSync27, statSync as statSync10 } from "node:fs";
|
|
81501
81472
|
import os26 from "node:os";
|
|
81502
|
-
import
|
|
81473
|
+
import path61 from "node:path";
|
|
81503
81474
|
async function run14(argv, io) {
|
|
81504
81475
|
const [sub, ...args] = argv.filter((arg) => arg !== "--json");
|
|
81505
81476
|
if (sub !== "show")
|
|
@@ -81560,7 +81531,7 @@ var USAGE8 = "workit models show [--role <role>] [--tier <tier>] [--host <host>]
|
|
|
81560
81531
|
const found = new Set;
|
|
81561
81532
|
let text = "";
|
|
81562
81533
|
try {
|
|
81563
|
-
text =
|
|
81534
|
+
text = readFileSync27(file, "utf8");
|
|
81564
81535
|
} catch {
|
|
81565
81536
|
return found;
|
|
81566
81537
|
}
|
|
@@ -81574,24 +81545,24 @@ var USAGE8 = "workit models show [--role <role>] [--tier <tier>] [--host <host>]
|
|
|
81574
81545
|
} catch {}
|
|
81575
81546
|
return found;
|
|
81576
81547
|
}, matches3 = (ran, configured) => ran.toLowerCase().includes(configured.toLowerCase()), usageReport = (cwd, env, days) => {
|
|
81577
|
-
const projects =
|
|
81548
|
+
const projects = path61.join(env.CLAUDE_CONFIG_DIR || path61.join(env.HOME || os26.homedir(), ".claude"), "projects");
|
|
81578
81549
|
const since = Date.now() - days * 86400000;
|
|
81579
81550
|
const types = {};
|
|
81580
81551
|
let agents = 0;
|
|
81581
81552
|
const dirs = (dir) => {
|
|
81582
81553
|
try {
|
|
81583
|
-
return readdirSync13(dir).map((name) =>
|
|
81554
|
+
return readdirSync13(dir).map((name) => path61.join(dir, name));
|
|
81584
81555
|
} catch {
|
|
81585
81556
|
return [];
|
|
81586
81557
|
}
|
|
81587
81558
|
};
|
|
81588
81559
|
for (const project of dirs(projects))
|
|
81589
81560
|
for (const session of dirs(project))
|
|
81590
|
-
for (const meta of dirs(
|
|
81561
|
+
for (const meta of dirs(path61.join(session, "subagents")).filter((f) => f.endsWith(".meta.json"))) {
|
|
81591
81562
|
try {
|
|
81592
81563
|
if (statSync10(meta).mtimeMs < since)
|
|
81593
81564
|
continue;
|
|
81594
|
-
const agentType = JSON.parse(
|
|
81565
|
+
const agentType = JSON.parse(readFileSync27(meta, "utf8")).agentType;
|
|
81595
81566
|
const transcript = meta.replace(/\.meta\.json$/, ".jsonl");
|
|
81596
81567
|
if (typeof agentType !== "string" || !existsSync26(transcript))
|
|
81597
81568
|
continue;
|
|
@@ -81732,8 +81703,8 @@ var success2 = (data) => ({ ok: true, data }), failure3 = (code, error, unblock)
|
|
|
81732
81703
|
|
|
81733
81704
|
// packages/workit-core/src/git/ops.ts
|
|
81734
81705
|
import { spawnSync as spawnSync22 } from "node:child_process";
|
|
81735
|
-
import { copyFileSync as copyFileSync8, existsSync as existsSync27, readdirSync as readdirSync14, readFileSync as
|
|
81736
|
-
import
|
|
81706
|
+
import { copyFileSync as copyFileSync8, existsSync as existsSync27, readdirSync as readdirSync14, readFileSync as readFileSync28, rmSync as rmSync11 } from "node:fs";
|
|
81707
|
+
import path62 from "node:path";
|
|
81737
81708
|
function operationInProgress(cwd) {
|
|
81738
81709
|
const markers = [
|
|
81739
81710
|
["rebase-merge", "rebase"],
|
|
@@ -81746,18 +81717,18 @@ function operationInProgress(cwd) {
|
|
|
81746
81717
|
if (!run.ok)
|
|
81747
81718
|
return null;
|
|
81748
81719
|
const found = run.stdout.split(`
|
|
81749
|
-
`).map((line) =>
|
|
81720
|
+
`).map((line) => path62.resolve(cwd, line.trim()));
|
|
81750
81721
|
const conflicted = () => git5(cwd, ["ls-files", "-u"]).stdout.trim() !== "";
|
|
81751
81722
|
for (const [index, [, operation]] of markers.entries()) {
|
|
81752
81723
|
const marker = found[index];
|
|
81753
81724
|
if (!marker || !existsSync27(marker))
|
|
81754
81725
|
continue;
|
|
81755
|
-
if (index === 1 && existsSync27(
|
|
81726
|
+
if (index === 1 && existsSync27(path62.join(marker, "applying")))
|
|
81756
81727
|
return { operation: "am", commitAllowed: false, branch: null };
|
|
81757
|
-
if (index === 0 && existsSync27(
|
|
81728
|
+
if (index === 0 && existsSync27(path62.join(marker, "amend")) && !conflicted()) {
|
|
81758
81729
|
let headName = "";
|
|
81759
81730
|
try {
|
|
81760
|
-
headName =
|
|
81731
|
+
headName = readFileSync28(path62.join(marker, "head-name"), "utf8").trim();
|
|
81761
81732
|
} catch {}
|
|
81762
81733
|
const branch = headName.startsWith("refs/heads/") ? headName.slice("refs/heads/".length) : null;
|
|
81763
81734
|
return { operation, commitAllowed: branch !== null, branch };
|
|
@@ -82022,13 +81993,13 @@ function sweepPrivateIndexes(dir) {
|
|
|
82022
81993
|
const pid = Number(match[1]);
|
|
82023
81994
|
const stale = Date.now() - Number(match[2]) > PRIVATE_INDEX_TTL_MS || pid !== process.pid && !processAlive(pid);
|
|
82024
81995
|
if (stale)
|
|
82025
|
-
rmSync11(
|
|
81996
|
+
rmSync11(path62.join(dir, name), { force: true });
|
|
82026
81997
|
}
|
|
82027
81998
|
}
|
|
82028
81999
|
function pathCommitIndex(cwd, paths, env) {
|
|
82029
|
-
const where = (name) =>
|
|
82000
|
+
const where = (name) => path62.resolve(cwd, git5(cwd, ["rev-parse", "--git-path", name]).stdout.trim());
|
|
82030
82001
|
const file = where(`workit-commit-${process.pid}-${Date.now()}.index`);
|
|
82031
|
-
sweepPrivateIndexes(
|
|
82002
|
+
sweepPrivateIndexes(path62.dirname(file));
|
|
82032
82003
|
try {
|
|
82033
82004
|
copyFileSync8(where("index"), file);
|
|
82034
82005
|
} catch (error) {
|
|
@@ -82149,7 +82120,7 @@ function gitCommit(cwd, input) {
|
|
|
82149
82120
|
const partial = new Set(keptPartial);
|
|
82150
82121
|
const top = git5(cwd, ["rev-parse", "--show-prefix"]).stdout.trim();
|
|
82151
82122
|
const tracked = new Set(nulList(git5(cwd, ["ls-files", "-z", "--", ...paths]).stdout));
|
|
82152
|
-
const addable = paths.filter((value) => !partial.has(
|
|
82123
|
+
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
82124
|
if (addable.length) {
|
|
82154
82125
|
const added = git5(cwd, [
|
|
82155
82126
|
"add",
|
|
@@ -82724,12 +82695,12 @@ var init_ops = __esm(() => {
|
|
|
82724
82695
|
|
|
82725
82696
|
// packages/workit-core/src/verdict-cover.ts
|
|
82726
82697
|
import fs26 from "node:fs";
|
|
82727
|
-
import
|
|
82698
|
+
import path63 from "node:path";
|
|
82728
82699
|
function chainsAbove(cwd, branch) {
|
|
82729
82700
|
const root = storeRoot(cwd);
|
|
82730
82701
|
if (!root.ok)
|
|
82731
82702
|
return [];
|
|
82732
|
-
const dir =
|
|
82703
|
+
const dir = path63.join(root.value.root, "stacks");
|
|
82733
82704
|
let names = [];
|
|
82734
82705
|
try {
|
|
82735
82706
|
names = fs26.readdirSync(dir).filter((name) => name.endsWith(".json"));
|
|
@@ -82740,7 +82711,7 @@ function chainsAbove(cwd, branch) {
|
|
|
82740
82711
|
for (const name of names.toSorted()) {
|
|
82741
82712
|
let parsed;
|
|
82742
82713
|
try {
|
|
82743
|
-
parsed = JSON.parse(fs26.readFileSync(
|
|
82714
|
+
parsed = JSON.parse(fs26.readFileSync(path63.join(dir, name), "utf8"));
|
|
82744
82715
|
} catch {
|
|
82745
82716
|
continue;
|
|
82746
82717
|
}
|
|
@@ -82896,10 +82867,10 @@ var init_check_evidence = __esm(() => {
|
|
|
82896
82867
|
|
|
82897
82868
|
// packages/workit-core/src/forge/reruns.ts
|
|
82898
82869
|
import fs27 from "node:fs";
|
|
82899
|
-
import
|
|
82870
|
+
import path64 from "node:path";
|
|
82900
82871
|
function rerunLogPath(cwd) {
|
|
82901
82872
|
const common = gitCommonDir(cwd);
|
|
82902
|
-
return common ?
|
|
82873
|
+
return common ? path64.join(common, "workit", "ci-reruns.jsonl") : null;
|
|
82903
82874
|
}
|
|
82904
82875
|
function rerunCounts(cwd, key) {
|
|
82905
82876
|
const counts = new Map;
|
|
@@ -82934,7 +82905,7 @@ function recordReruns(cwd, rows) {
|
|
|
82934
82905
|
if (!file)
|
|
82935
82906
|
return false;
|
|
82936
82907
|
try {
|
|
82937
|
-
fs27.mkdirSync(
|
|
82908
|
+
fs27.mkdirSync(path64.dirname(file), { recursive: true });
|
|
82938
82909
|
fs27.appendFileSync(file, rows.map((row) => `${JSON.stringify(row)}
|
|
82939
82910
|
`).join(""));
|
|
82940
82911
|
return true;
|
|
@@ -82947,7 +82918,7 @@ function withRerunLock(cwd, fn) {
|
|
|
82947
82918
|
if (!file)
|
|
82948
82919
|
return fn();
|
|
82949
82920
|
const lock = `${file.slice(0, -".jsonl".length)}.lock`;
|
|
82950
|
-
fs27.mkdirSync(
|
|
82921
|
+
fs27.mkdirSync(path64.dirname(lock), { recursive: true });
|
|
82951
82922
|
const until = Date.now() + LOCK_WAIT_MS2;
|
|
82952
82923
|
for (;; ) {
|
|
82953
82924
|
try {
|
|
@@ -83944,7 +83915,7 @@ var init_pr_ops = __esm(() => {
|
|
|
83944
83915
|
import { spawnSync as spawnSync24 } from "node:child_process";
|
|
83945
83916
|
import { createHash as createHash18, randomBytes as randomBytes4 } from "node:crypto";
|
|
83946
83917
|
import fs28 from "node:fs";
|
|
83947
|
-
import
|
|
83918
|
+
import path65 from "node:path";
|
|
83948
83919
|
function worktreeOf(cwd, branch) {
|
|
83949
83920
|
const list = gitRun3(cwd, ["worktree", "list", "--porcelain"]);
|
|
83950
83921
|
if (!list.ok)
|
|
@@ -83993,7 +83964,7 @@ function gitRestack(cwd, input) {
|
|
|
83993
83964
|
error: "no store root"
|
|
83994
83965
|
};
|
|
83995
83966
|
fs28.mkdirSync(scratch, { recursive: true });
|
|
83996
|
-
dir =
|
|
83967
|
+
dir = path65.join(scratch, `${input.branch.replace(/[^A-Za-z0-9._-]+/gu, "_").slice(0, 40)}-${randomBytes4(4).toString("hex")}`);
|
|
83997
83968
|
const added = gitRun3(cwd, ["worktree", "add", "-q", dir, input.branch], GIT_TIMEOUTS.worktree);
|
|
83998
83969
|
if (!added.ok)
|
|
83999
83970
|
return {
|
|
@@ -84049,7 +84020,7 @@ function pruneScratch(cwd) {
|
|
|
84049
84020
|
if (!scratch || !fs28.existsSync(scratch))
|
|
84050
84021
|
return;
|
|
84051
84022
|
for (const name of fs28.readdirSync(scratch)) {
|
|
84052
|
-
const dir =
|
|
84023
|
+
const dir = path65.join(scratch, name);
|
|
84053
84024
|
if (!rebaseInProgress(dir) && !trackedDirt(dir))
|
|
84054
84025
|
gitRun3(cwd, ["worktree", "remove", "--force", dir]);
|
|
84055
84026
|
}
|
|
@@ -84059,7 +84030,7 @@ function stacksDir(cwd) {
|
|
|
84059
84030
|
const root = storeRoot(cwd);
|
|
84060
84031
|
if (!root.ok)
|
|
84061
84032
|
return stackFail(root.code, root.error, root.unblock);
|
|
84062
|
-
return { ok: true, data:
|
|
84033
|
+
return { ok: true, data: path65.join(root.value.root, "stacks") };
|
|
84063
84034
|
}
|
|
84064
84035
|
function parseStack(raw) {
|
|
84065
84036
|
if (!isRecord12(raw) || !Array.isArray(raw.branches))
|
|
@@ -84111,7 +84082,7 @@ function readStack(cwd, name) {
|
|
|
84111
84082
|
const dir = stacksDir(cwd);
|
|
84112
84083
|
if (!dir.ok)
|
|
84113
84084
|
return dir;
|
|
84114
|
-
const file =
|
|
84085
|
+
const file = path65.join(dir.data, fileFor(name));
|
|
84115
84086
|
let text;
|
|
84116
84087
|
try {
|
|
84117
84088
|
text = fs28.readFileSync(file, "utf8");
|
|
@@ -84132,7 +84103,7 @@ function writeStack(cwd, stack, now = new Date) {
|
|
|
84132
84103
|
const dir = stacksDir(cwd);
|
|
84133
84104
|
if (!dir.ok)
|
|
84134
84105
|
return dir;
|
|
84135
|
-
const file =
|
|
84106
|
+
const file = path65.join(dir.data, fileFor(stack.name));
|
|
84136
84107
|
const temp = `${file}.${process.pid}.tmp`;
|
|
84137
84108
|
try {
|
|
84138
84109
|
fs28.mkdirSync(dir.data, { recursive: true });
|
|
@@ -84160,7 +84131,7 @@ function listStacks(cwd) {
|
|
|
84160
84131
|
for (const name of names) {
|
|
84161
84132
|
let parsed = null;
|
|
84162
84133
|
try {
|
|
84163
|
-
parsed = parseStack(JSON.parse(fs28.readFileSync(
|
|
84134
|
+
parsed = parseStack(JSON.parse(fs28.readFileSync(path65.join(dir.data, name), "utf8")));
|
|
84164
84135
|
} catch {
|
|
84165
84136
|
parsed = null;
|
|
84166
84137
|
}
|
|
@@ -84222,7 +84193,7 @@ function takeLock(lock) {
|
|
|
84222
84193
|
host: localLockHost(),
|
|
84223
84194
|
nonce: randomBytes4(8).toString("hex")
|
|
84224
84195
|
};
|
|
84225
|
-
fs28.writeFileSync(
|
|
84196
|
+
fs28.writeFileSync(path65.join(lock, OWNER), JSON.stringify(owner));
|
|
84226
84197
|
return owner;
|
|
84227
84198
|
}
|
|
84228
84199
|
function reapLock(lock, observed) {
|
|
@@ -84259,7 +84230,7 @@ async function withStackLock(cwd, name, fn, waitMs = LOCK_WAIT_MS3) {
|
|
|
84259
84230
|
return dir;
|
|
84260
84231
|
if (!validName(name))
|
|
84261
84232
|
return stackFail("invalid_input", "a stack name must be 1-200 printable characters");
|
|
84262
|
-
const lock =
|
|
84233
|
+
const lock = path65.join(dir.data, `${fileFor(name)}.lock`);
|
|
84263
84234
|
try {
|
|
84264
84235
|
fs28.mkdirSync(dir.data, { recursive: true });
|
|
84265
84236
|
} catch (error) {
|
|
@@ -84289,7 +84260,7 @@ async function withStackLock(cwd, name, fn, waitMs = LOCK_WAIT_MS3) {
|
|
|
84289
84260
|
const touch = () => {
|
|
84290
84261
|
try {
|
|
84291
84262
|
const now = new Date;
|
|
84292
|
-
fs28.utimesSync(
|
|
84263
|
+
fs28.utimesSync(path65.join(lock, OWNER), now, now);
|
|
84293
84264
|
} catch {}
|
|
84294
84265
|
};
|
|
84295
84266
|
const beat = setInterval(touch, HEARTBEAT_MS);
|
|
@@ -85261,7 +85232,7 @@ var STACK_VERSION = 1, stackFail = (code, error, unblock, data) => ({
|
|
|
85261
85232
|
return !status.ok || status.stdout.trim() !== "";
|
|
85262
85233
|
}, scratchDir = (cwd) => {
|
|
85263
85234
|
const dir = stacksDir(cwd);
|
|
85264
|
-
return dir.ok ?
|
|
85235
|
+
return dir.ok ? path65.join(dir.data, "worktrees") : null;
|
|
85265
85236
|
}, firstLine = (run) => (`${run.stderr}
|
|
85266
85237
|
${run.stdout}`.split(`
|
|
85267
85238
|
`).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 +85247,12 @@ ${run.stdout}`.split(`
|
|
|
85276
85247
|
}, 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
85248
|
let raw = null;
|
|
85278
85249
|
try {
|
|
85279
|
-
raw = fs28.readFileSync(
|
|
85250
|
+
raw = fs28.readFileSync(path65.join(lock, OWNER), "utf8");
|
|
85280
85251
|
} catch {
|
|
85281
85252
|
raw = null;
|
|
85282
85253
|
}
|
|
85283
85254
|
let age = null;
|
|
85284
|
-
for (const target of [
|
|
85255
|
+
for (const target of [path65.join(lock, OWNER), lock])
|
|
85285
85256
|
try {
|
|
85286
85257
|
age = Date.now() - fs28.statSync(target).mtimeMs;
|
|
85287
85258
|
break;
|
|
@@ -85326,7 +85297,7 @@ var init_stack = __esm(() => {
|
|
|
85326
85297
|
import { spawnSync as spawnSync25 } from "node:child_process";
|
|
85327
85298
|
import { createHash as createHash19 } from "node:crypto";
|
|
85328
85299
|
import fs29 from "node:fs";
|
|
85329
|
-
import
|
|
85300
|
+
import path66 from "node:path";
|
|
85330
85301
|
function expandBraces2(pattern, limit = 64) {
|
|
85331
85302
|
for (let index = 0;index < pattern.length; index += 1) {
|
|
85332
85303
|
if (pattern[index] === "\\") {
|
|
@@ -85572,7 +85543,7 @@ function parsePlan(raw, defaults, name) {
|
|
|
85572
85543
|
id,
|
|
85573
85544
|
branch,
|
|
85574
85545
|
base: optional("base") ?? "",
|
|
85575
|
-
worktree:
|
|
85546
|
+
worktree: path66.resolve(defaults.root, optional("worktree") ?? path66.join(defaults.worktreeRoot, id)),
|
|
85576
85547
|
tier,
|
|
85577
85548
|
reason,
|
|
85578
85549
|
dependsOn: [...new Set(dependsOn ?? [])],
|
|
@@ -85701,12 +85672,12 @@ function regeneratedFiles(root, tracked) {
|
|
|
85701
85672
|
const found = new Map;
|
|
85702
85673
|
let scripts;
|
|
85703
85674
|
try {
|
|
85704
|
-
const manifest = JSON.parse(fs29.readFileSync(
|
|
85675
|
+
const manifest = JSON.parse(fs29.readFileSync(path66.join(root, "package.json"), "utf8"));
|
|
85705
85676
|
scripts = manifest.scripts ?? {};
|
|
85706
85677
|
} catch {
|
|
85707
85678
|
return found;
|
|
85708
85679
|
}
|
|
85709
|
-
const runner = fs29.existsSync(
|
|
85680
|
+
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
85681
|
const outputs = tracked.filter((file) => !CODE.test(file));
|
|
85711
85682
|
for (const [name, command] of Object.entries(scripts)) {
|
|
85712
85683
|
if (!name.startsWith("write:") || typeof command !== "string")
|
|
@@ -85714,7 +85685,7 @@ function regeneratedFiles(root, tracked) {
|
|
|
85714
85685
|
for (const file of command.match(/[\w./-]+\.[cm]?[jt]s\b/gu) ?? []) {
|
|
85715
85686
|
let source;
|
|
85716
85687
|
try {
|
|
85717
|
-
source = fs29.readFileSync(
|
|
85688
|
+
source = fs29.readFileSync(path66.join(root, file), "utf8");
|
|
85718
85689
|
} catch {
|
|
85719
85690
|
continue;
|
|
85720
85691
|
}
|
|
@@ -85836,11 +85807,11 @@ function defaultTrunk(cwd) {
|
|
|
85836
85807
|
}
|
|
85837
85808
|
function mainCheckout(cwd) {
|
|
85838
85809
|
const common = gitCommonDir(cwd);
|
|
85839
|
-
return common &&
|
|
85810
|
+
return common && path66.basename(common) === ".git" ? path66.dirname(common) : path66.resolve(cwd);
|
|
85840
85811
|
}
|
|
85841
85812
|
function worktreeRoot(cwd) {
|
|
85842
85813
|
const main = mainCheckout(cwd);
|
|
85843
|
-
return
|
|
85814
|
+
return path66.join(path66.dirname(main), `${path66.basename(main)}-wt`);
|
|
85844
85815
|
}
|
|
85845
85816
|
function sliceHash(slice) {
|
|
85846
85817
|
const {
|
|
@@ -85860,7 +85831,7 @@ function fanoutsDir(cwd) {
|
|
|
85860
85831
|
const root = storeRoot(cwd);
|
|
85861
85832
|
if (!root.ok)
|
|
85862
85833
|
return fanoutFail(root.code, root.error, root.unblock);
|
|
85863
|
-
return { ok: true, data:
|
|
85834
|
+
return { ok: true, data: path66.join(root.value.root, "fanouts") };
|
|
85864
85835
|
}
|
|
85865
85836
|
function parseStored(raw) {
|
|
85866
85837
|
if (!isRecord13(raw) || typeof raw.name !== "string" || typeof raw.trunk !== "string")
|
|
@@ -85928,7 +85899,7 @@ function readFanout(cwd, name) {
|
|
|
85928
85899
|
const dir = fanoutsDir(cwd);
|
|
85929
85900
|
if (!dir.ok)
|
|
85930
85901
|
return dir;
|
|
85931
|
-
const file =
|
|
85902
|
+
const file = path66.join(dir.data, stackFileName(name));
|
|
85932
85903
|
let parsed = null;
|
|
85933
85904
|
try {
|
|
85934
85905
|
parsed = parseStored(JSON.parse(fs29.readFileSync(file, "utf8")));
|
|
@@ -85953,7 +85924,7 @@ function listFanouts(cwd) {
|
|
|
85953
85924
|
for (const entry of names) {
|
|
85954
85925
|
let parsed = null;
|
|
85955
85926
|
try {
|
|
85956
|
-
parsed = parseStored(JSON.parse(fs29.readFileSync(
|
|
85927
|
+
parsed = parseStored(JSON.parse(fs29.readFileSync(path66.join(dir.data, entry), "utf8")));
|
|
85957
85928
|
} catch {
|
|
85958
85929
|
parsed = null;
|
|
85959
85930
|
}
|
|
@@ -85992,7 +85963,7 @@ function writeFanout(cwd, plan) {
|
|
|
85992
85963
|
const dir = fanoutsDir(cwd);
|
|
85993
85964
|
if (!dir.ok)
|
|
85994
85965
|
return dir;
|
|
85995
|
-
const file =
|
|
85966
|
+
const file = path66.join(dir.data, stackFileName(plan.name));
|
|
85996
85967
|
const temp = `${file}.${process.pid}.tmp`;
|
|
85997
85968
|
try {
|
|
85998
85969
|
fs29.mkdirSync(dir.data, { recursive: true });
|
|
@@ -86203,13 +86174,13 @@ var init_fanout = __esm(() => {
|
|
|
86203
86174
|
// packages/workit-core/src/forge/exec.ts
|
|
86204
86175
|
import { spawnSync as spawnSync26 } from "node:child_process";
|
|
86205
86176
|
import fs30 from "node:fs";
|
|
86206
|
-
import
|
|
86177
|
+
import path67 from "node:path";
|
|
86207
86178
|
function findExecutable(bin, env) {
|
|
86208
|
-
const dirs = (env.PATH ?? env.Path ?? "").split(
|
|
86179
|
+
const dirs = (env.PATH ?? env.Path ?? "").split(path67.delimiter).filter(Boolean);
|
|
86209
86180
|
const exts = process.platform === "win32" ? [".exe"] : [""];
|
|
86210
86181
|
for (const dir of dirs)
|
|
86211
86182
|
for (const ext of exts) {
|
|
86212
|
-
const candidate =
|
|
86183
|
+
const candidate = path67.join(dir, `${bin}${ext}`);
|
|
86213
86184
|
try {
|
|
86214
86185
|
const stat = fs30.statSync(candidate);
|
|
86215
86186
|
if (stat.isFile())
|
|
@@ -87999,7 +87970,7 @@ var init_live_session = __esm(() => {
|
|
|
87999
87970
|
});
|
|
88000
87971
|
|
|
88001
87972
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
88002
|
-
import
|
|
87973
|
+
import path68 from "node:path";
|
|
88003
87974
|
var CASE_INSENSITIVE, PREFIXES2, SCRIPT_SHELLS, cache3, MUTATING_GIT, DRY_N, MUTATING_WORKIT_GIT, CD2, PUSHD2, POPD2, UNKNOWN_DIR;
|
|
88004
87975
|
var init_write_gate = __esm(() => {
|
|
88005
87976
|
init_task_store();
|
|
@@ -88039,7 +88010,7 @@ var init_write_gate = __esm(() => {
|
|
|
88039
88010
|
CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
|
|
88040
88011
|
PUSHD2 = new Set(["pushd", "push-location"]);
|
|
88041
88012
|
POPD2 = new Set(["popd", "pop-location"]);
|
|
88042
|
-
UNKNOWN_DIR =
|
|
88013
|
+
UNKNOWN_DIR = path68.resolve(path68.parse(process.cwd()).root, ".workit-unknown-dir");
|
|
88043
88014
|
});
|
|
88044
88015
|
|
|
88045
88016
|
// packages/workit-core/src/hooks/worktree-confine.ts
|
|
@@ -88064,20 +88035,20 @@ var init_worktree_confine = __esm(() => {
|
|
|
88064
88035
|
|
|
88065
88036
|
// packages/workit-core/src/worktree-deps.ts
|
|
88066
88037
|
import fs31 from "node:fs";
|
|
88067
|
-
import
|
|
88038
|
+
import path69 from "node:path";
|
|
88068
88039
|
function moduleDirs(main) {
|
|
88069
88040
|
const out = [];
|
|
88070
88041
|
const walk = (relative, depth) => {
|
|
88071
88042
|
let entries;
|
|
88072
88043
|
try {
|
|
88073
|
-
entries = fs31.readdirSync(
|
|
88044
|
+
entries = fs31.readdirSync(path69.join(main, relative), { withFileTypes: true });
|
|
88074
88045
|
} catch {
|
|
88075
88046
|
return;
|
|
88076
88047
|
}
|
|
88077
88048
|
for (const entry of entries) {
|
|
88078
88049
|
if (!entry.isDirectory())
|
|
88079
88050
|
continue;
|
|
88080
|
-
const child =
|
|
88051
|
+
const child = path69.join(relative, entry.name);
|
|
88081
88052
|
if (entry.name === MODULES)
|
|
88082
88053
|
out.push(child);
|
|
88083
88054
|
else if (depth < MAX_DEPTH2 && !entry.name.startsWith("."))
|
|
@@ -88091,8 +88062,8 @@ function linkEntry(main, worktree, source, target) {
|
|
|
88091
88062
|
const stat = fs31.lstatSync(source);
|
|
88092
88063
|
if (stat.isSymbolicLink()) {
|
|
88093
88064
|
const link = fs31.readlinkSync(source);
|
|
88094
|
-
const outside =
|
|
88095
|
-
const to = outside ?
|
|
88065
|
+
const outside = path69.isAbsolute(link) && within(link, main) && !path69.relative(main, link).split(path69.sep).includes(MODULES);
|
|
88066
|
+
const to = outside ? path69.join(worktree, path69.relative(main, link)) : link;
|
|
88096
88067
|
fs31.symlinkSync(to, target, process.platform === "win32" ? "junction" : undefined);
|
|
88097
88068
|
return;
|
|
88098
88069
|
}
|
|
@@ -88102,8 +88073,8 @@ function mirror(main, worktree, source, target, top) {
|
|
|
88102
88073
|
fs31.mkdirSync(target);
|
|
88103
88074
|
let count = 0;
|
|
88104
88075
|
for (const entry of fs31.readdirSync(source, { withFileTypes: true })) {
|
|
88105
|
-
const from =
|
|
88106
|
-
const to =
|
|
88076
|
+
const from = path69.join(source, entry.name);
|
|
88077
|
+
const to = path69.join(target, entry.name);
|
|
88107
88078
|
if (top && entry.isDirectory() && (entry.name.startsWith("@") || entry.name === ".bin"))
|
|
88108
88079
|
count += mirror(main, worktree, from, to, false);
|
|
88109
88080
|
else {
|
|
@@ -88119,16 +88090,16 @@ function linkWorktreeDependencies(main, worktree) {
|
|
|
88119
88090
|
const dirs = [];
|
|
88120
88091
|
let entries = 0;
|
|
88121
88092
|
for (const relative of moduleDirs(main)) {
|
|
88122
|
-
const target =
|
|
88123
|
-
if (!fs31.existsSync(
|
|
88093
|
+
const target = path69.join(worktree, relative);
|
|
88094
|
+
if (!fs31.existsSync(path69.dirname(target)) || fs31.existsSync(target))
|
|
88124
88095
|
continue;
|
|
88125
|
-
if (!gitRun4(worktree, ["check-ignore", "-q", `${relative.split(
|
|
88126
|
-
notes.push(`${relative.split(
|
|
88096
|
+
if (!gitRun4(worktree, ["check-ignore", "-q", `${relative.split(path69.sep).join("/")}/`]).ok) {
|
|
88097
|
+
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
88098
|
continue;
|
|
88128
88099
|
}
|
|
88129
88100
|
try {
|
|
88130
|
-
entries += mirror(main, worktree,
|
|
88131
|
-
dirs.push(relative.split(
|
|
88101
|
+
entries += mirror(main, worktree, path69.join(main, relative), target, true);
|
|
88102
|
+
dirs.push(relative.split(path69.sep).join("/"));
|
|
88132
88103
|
} catch (error) {
|
|
88133
88104
|
fs31.rmSync(target, { recursive: true, force: true });
|
|
88134
88105
|
notes.push(`could not link ${relative} from ${main} (${error.message}); install dependencies in the worktree yourself`);
|
|
@@ -88141,8 +88112,8 @@ function linkWorktreeDependencies(main, worktree) {
|
|
|
88141
88112
|
return { linked: { from: main, dirs, entries, ms }, notes };
|
|
88142
88113
|
}
|
|
88143
88114
|
var MODULES = "node_modules", MAX_DEPTH2 = 2, within = (child, parent) => {
|
|
88144
|
-
const relative =
|
|
88145
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
88115
|
+
const relative = path69.relative(parent, child);
|
|
88116
|
+
return relative === "" || !relative.startsWith("..") && !path69.isAbsolute(relative);
|
|
88146
88117
|
};
|
|
88147
88118
|
var init_worktree_deps = __esm(() => {
|
|
88148
88119
|
init_fanout();
|
|
@@ -88151,7 +88122,7 @@ var init_worktree_deps = __esm(() => {
|
|
|
88151
88122
|
// packages/workit-core/src/fanout-worktree.ts
|
|
88152
88123
|
import { randomBytes as randomBytes5 } from "node:crypto";
|
|
88153
88124
|
import fs32 from "node:fs";
|
|
88154
|
-
import
|
|
88125
|
+
import path70 from "node:path";
|
|
88155
88126
|
function rowSample(lines) {
|
|
88156
88127
|
const out = [];
|
|
88157
88128
|
let bytes = 0;
|
|
@@ -88211,7 +88182,7 @@ function adminDir(worktree) {
|
|
|
88211
88182
|
const file = dir.stdout.trim();
|
|
88212
88183
|
let token = null;
|
|
88213
88184
|
try {
|
|
88214
|
-
token = fs32.readFileSync(
|
|
88185
|
+
token = fs32.readFileSync(path70.join(file, FANOUT_TOKEN_FILE), "utf8").trim() || null;
|
|
88215
88186
|
} catch {
|
|
88216
88187
|
token = null;
|
|
88217
88188
|
}
|
|
@@ -88219,7 +88190,7 @@ function adminDir(worktree) {
|
|
|
88219
88190
|
const stat = worktreeDeps.stat(file);
|
|
88220
88191
|
return {
|
|
88221
88192
|
path: file,
|
|
88222
|
-
id:
|
|
88193
|
+
id: path70.basename(file),
|
|
88223
88194
|
ino: stat.ino.toString(),
|
|
88224
88195
|
token,
|
|
88225
88196
|
birthMs: stat.birthtimeNs > 0n ? Number(stat.birthtimeMs) : null,
|
|
@@ -88235,7 +88206,7 @@ function markAdminDir(worktree) {
|
|
|
88235
88206
|
return null;
|
|
88236
88207
|
const token = randomBytes5(16).toString("hex");
|
|
88237
88208
|
try {
|
|
88238
|
-
fs32.writeFileSync(
|
|
88209
|
+
fs32.writeFileSync(path70.join(admin.path, FANOUT_TOKEN_FILE), `${token}
|
|
88239
88210
|
`);
|
|
88240
88211
|
} catch {
|
|
88241
88212
|
return null;
|
|
@@ -88250,7 +88221,7 @@ function excludeScratch(cwd) {
|
|
|
88250
88221
|
const common = gitCommonDir(cwd);
|
|
88251
88222
|
if (!common)
|
|
88252
88223
|
return;
|
|
88253
|
-
const file =
|
|
88224
|
+
const file = path70.join(common, "info", "exclude");
|
|
88254
88225
|
let text = "";
|
|
88255
88226
|
try {
|
|
88256
88227
|
text = fs32.readFileSync(file, "utf8");
|
|
@@ -88259,7 +88230,7 @@ function excludeScratch(cwd) {
|
|
|
88259
88230
|
}
|
|
88260
88231
|
if (text.split(/\r?\n/u).includes(EXCLUDE_LINE))
|
|
88261
88232
|
return;
|
|
88262
|
-
fs32.mkdirSync(
|
|
88233
|
+
fs32.mkdirSync(path70.dirname(file), { recursive: true });
|
|
88263
88234
|
fs32.appendFileSync(file, `${text && !text.endsWith(`
|
|
88264
88235
|
`) ? `
|
|
88265
88236
|
` : ""}# workit fanout: per-worker scratch dirs
|
|
@@ -88268,13 +88239,13 @@ ${EXCLUDE_LINE}
|
|
|
88268
88239
|
}
|
|
88269
88240
|
function worktreeDependencies(main, worktree) {
|
|
88270
88241
|
for (const [name, install] of LOCKFILES2) {
|
|
88271
|
-
const ours = readBytes(
|
|
88272
|
-
const theirs = readBytes(
|
|
88242
|
+
const ours = readBytes(path70.join(main, name));
|
|
88243
|
+
const theirs = readBytes(path70.join(worktree, name));
|
|
88273
88244
|
if (ours === null && theirs === null)
|
|
88274
88245
|
continue;
|
|
88275
88246
|
if (ours !== null && theirs !== null && ours.equals(theirs))
|
|
88276
88247
|
continue;
|
|
88277
|
-
if (fs32.existsSync(
|
|
88248
|
+
if (fs32.existsSync(path70.join(worktree, "node_modules")))
|
|
88278
88249
|
break;
|
|
88279
88250
|
const command = install(worktree);
|
|
88280
88251
|
return {
|
|
@@ -88286,7 +88257,7 @@ function worktreeDependencies(main, worktree) {
|
|
|
88286
88257
|
};
|
|
88287
88258
|
}
|
|
88288
88259
|
const stale = staleBunInstall(main);
|
|
88289
|
-
if (stale && !fs32.existsSync(
|
|
88260
|
+
if (stale && !fs32.existsSync(path70.join(worktree, "node_modules"))) {
|
|
88290
88261
|
const command = `bun install --frozen-lockfile --cwd ${worktree}`;
|
|
88291
88262
|
return {
|
|
88292
88263
|
linked: null,
|
|
@@ -88299,9 +88270,9 @@ function worktreeDependencies(main, worktree) {
|
|
|
88299
88270
|
return { ...linkWorktreeDependencies(main, worktree), install: null };
|
|
88300
88271
|
}
|
|
88301
88272
|
function staleBunInstall(main) {
|
|
88302
|
-
if (!fs32.existsSync(
|
|
88273
|
+
if (!fs32.existsSync(path70.join(main, "node_modules")))
|
|
88303
88274
|
return null;
|
|
88304
|
-
const text = readBytes(
|
|
88275
|
+
const text = readBytes(path70.join(main, "bun.lock"))?.toString("utf8");
|
|
88305
88276
|
if (!text)
|
|
88306
88277
|
return null;
|
|
88307
88278
|
let packages;
|
|
@@ -88328,7 +88299,7 @@ function staleBunInstall(main) {
|
|
|
88328
88299
|
const version = spec.slice(at + 1);
|
|
88329
88300
|
if (name !== key || version.includes(":"))
|
|
88330
88301
|
continue;
|
|
88331
|
-
const manifest = readBytes(
|
|
88302
|
+
const manifest = readBytes(path70.join(main, "node_modules", key, "package.json"));
|
|
88332
88303
|
if (!manifest) {
|
|
88333
88304
|
problems.push(`${key} missing`);
|
|
88334
88305
|
continue;
|
|
@@ -88345,7 +88316,7 @@ function staleBunInstall(main) {
|
|
|
88345
88316
|
return problems.length ? problems.join("; ") : null;
|
|
88346
88317
|
}
|
|
88347
88318
|
function ensureScratch(worktree) {
|
|
88348
|
-
const scratch =
|
|
88319
|
+
const scratch = path70.join(worktree, SCRATCH_DIR);
|
|
88349
88320
|
fs32.mkdirSync(scratch, { recursive: true });
|
|
88350
88321
|
return scratch;
|
|
88351
88322
|
}
|
|
@@ -88619,7 +88590,7 @@ function unpushedCount(cwd, branch) {
|
|
|
88619
88590
|
return count.ok ? Number(count.stdout.trim()) : null;
|
|
88620
88591
|
}
|
|
88621
88592
|
function removeScratch(worktree) {
|
|
88622
|
-
const scratch =
|
|
88593
|
+
const scratch = path70.join(worktree, SCRATCH_DIR);
|
|
88623
88594
|
let stat;
|
|
88624
88595
|
try {
|
|
88625
88596
|
stat = fs32.lstatSync(scratch);
|
|
@@ -88635,16 +88606,16 @@ var SLOW, SCRATCH_DIR = ".workit-scratch", EXCLUDE_LINE, DIRTY_ROW_BYTES = 2000,
|
|
|
88635
88606
|
try {
|
|
88636
88607
|
return fs32.realpathSync.native(target);
|
|
88637
88608
|
} catch {
|
|
88638
|
-
return
|
|
88609
|
+
return path70.resolve(target);
|
|
88639
88610
|
}
|
|
88640
88611
|
}, samePath = (a, b) => {
|
|
88641
88612
|
const left = canonical3(a);
|
|
88642
88613
|
const right = canonical3(b);
|
|
88643
88614
|
return process.platform === "win32" || process.platform === "darwin" ? left.toLowerCase() === right.toLowerCase() : left === right;
|
|
88644
88615
|
}, inside3 = (child, parent) => {
|
|
88645
|
-
const relative =
|
|
88646
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
88647
|
-
}, slicePath = (cwd, slice) =>
|
|
88616
|
+
const relative = path70.relative(canonical3(parent), canonical3(child));
|
|
88617
|
+
return relative === "" || !relative.startsWith("..") && !path70.isAbsolute(relative);
|
|
88618
|
+
}, slicePath = (cwd, slice) => path70.isAbsolute(slice.worktree) ? slice.worktree : path70.resolve(mainCheckout(cwd), slice.worktree), CLOCK_SLACK_MS = 2000, worktreeDeps, LOCKFILES2, readBytes = (file) => {
|
|
88648
88619
|
try {
|
|
88649
88620
|
return fs32.readFileSync(file);
|
|
88650
88621
|
} catch {
|
|
@@ -88676,7 +88647,7 @@ var init_fanout_worktree = __esm(() => {
|
|
|
88676
88647
|
|
|
88677
88648
|
// packages/workit-core/src/forge/merge-cleanup.ts
|
|
88678
88649
|
import fs33 from "node:fs";
|
|
88679
|
-
import
|
|
88650
|
+
import path71 from "node:path";
|
|
88680
88651
|
function cleanupMergedBranch(cwd, branch, mergedHead) {
|
|
88681
88652
|
const out = { branchDeleted: false, worktreeRemoved: null, notes: [] };
|
|
88682
88653
|
if (!branch || branch.startsWith("-"))
|
|
@@ -88736,13 +88707,13 @@ var SLOW2, isFanoutWorktree = (worktree) => {
|
|
|
88736
88707
|
if (!dir.ok)
|
|
88737
88708
|
return false;
|
|
88738
88709
|
try {
|
|
88739
|
-
return fs33.readFileSync(
|
|
88710
|
+
return fs33.readFileSync(path71.join(dir.stdout.trim(), FANOUT_TOKEN_FILE), "utf8").trim() !== "";
|
|
88740
88711
|
} catch {
|
|
88741
88712
|
return false;
|
|
88742
88713
|
}
|
|
88743
88714
|
}, inside4 = (child, parent) => {
|
|
88744
|
-
const relative =
|
|
88745
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
88715
|
+
const relative = path71.relative(fs33.realpathSync.native(parent), fs33.realpathSync.native(child));
|
|
88716
|
+
return relative === "" || !relative.startsWith("..") && !path71.isAbsolute(relative);
|
|
88746
88717
|
};
|
|
88747
88718
|
var init_merge_cleanup = __esm(() => {
|
|
88748
88719
|
init_fanout();
|
|
@@ -89023,7 +88994,7 @@ var init_duration = __esm(() => {
|
|
|
89023
88994
|
});
|
|
89024
88995
|
|
|
89025
88996
|
// packages/workit-cli/src/verbs/forge-common.ts
|
|
89026
|
-
import { readFileSync as
|
|
88997
|
+
import { readFileSync as readFileSync29 } from "node:fs";
|
|
89027
88998
|
function parseFlags(argv, spec) {
|
|
89028
88999
|
const parsed = { values: {}, booleans: new Set, lists: {}, positionals: [] };
|
|
89029
89000
|
for (let index = 0;index < argv.length; index += 1) {
|
|
@@ -89181,7 +89152,7 @@ var init_forge_common = __esm(() => {
|
|
|
89181
89152
|
forgeDeps = {
|
|
89182
89153
|
runner: undefined,
|
|
89183
89154
|
npm: undefined,
|
|
89184
|
-
readStdin: () =>
|
|
89155
|
+
readStdin: () => readFileSync29(0, "utf8"),
|
|
89185
89156
|
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
89186
89157
|
now: () => Date.now()
|
|
89187
89158
|
};
|
|
@@ -89193,8 +89164,8 @@ __export(exports_pr, {
|
|
|
89193
89164
|
checkPrTitle: () => checkPrTitle,
|
|
89194
89165
|
run: () => run15
|
|
89195
89166
|
});
|
|
89196
|
-
import { existsSync as existsSync28, readFileSync as
|
|
89197
|
-
import
|
|
89167
|
+
import { existsSync as existsSync28, readFileSync as readFileSync30 } from "node:fs";
|
|
89168
|
+
import path72 from "node:path";
|
|
89198
89169
|
function titleRules(cwd) {
|
|
89199
89170
|
let root;
|
|
89200
89171
|
try {
|
|
@@ -89205,16 +89176,16 @@ function titleRules(cwd) {
|
|
|
89205
89176
|
let text = null;
|
|
89206
89177
|
let name = "";
|
|
89207
89178
|
for (const candidate of COMMITLINT_FILES) {
|
|
89208
|
-
const full =
|
|
89179
|
+
const full = path72.join(root, candidate);
|
|
89209
89180
|
if (!existsSync28(full))
|
|
89210
89181
|
continue;
|
|
89211
|
-
text =
|
|
89182
|
+
text = readFileSync30(full, "utf8");
|
|
89212
89183
|
name = candidate;
|
|
89213
89184
|
break;
|
|
89214
89185
|
}
|
|
89215
89186
|
if (text === null) {
|
|
89216
89187
|
try {
|
|
89217
|
-
const pkg = JSON.parse(
|
|
89188
|
+
const pkg = JSON.parse(readFileSync30(path72.join(root, "package.json"), "utf8"));
|
|
89218
89189
|
if (pkg.commitlint === undefined)
|
|
89219
89190
|
return { rules: null, note: null };
|
|
89220
89191
|
text = JSON.stringify(pkg.commitlint);
|
|
@@ -89311,7 +89282,7 @@ function refuseTitle(io, title, line) {
|
|
|
89311
89282
|
function readBodyFile(io, file) {
|
|
89312
89283
|
try {
|
|
89313
89284
|
return {
|
|
89314
|
-
body: file === "-" ? forgeDeps.readStdin() :
|
|
89285
|
+
body: file === "-" ? forgeDeps.readStdin() : readFileSync30(path72.resolve(io.cwd, file), "utf8")
|
|
89315
89286
|
};
|
|
89316
89287
|
} catch {
|
|
89317
89288
|
return `cannot read --body-file ${file}`;
|
|
@@ -90241,8 +90212,8 @@ var exports_git = {};
|
|
|
90241
90212
|
__export(exports_git, {
|
|
90242
90213
|
run: () => run17
|
|
90243
90214
|
});
|
|
90244
|
-
import { readFileSync as
|
|
90245
|
-
import
|
|
90215
|
+
import { readFileSync as readFileSync31 } from "node:fs";
|
|
90216
|
+
import path73 from "node:path";
|
|
90246
90217
|
function kindHint(cwd, kind) {
|
|
90247
90218
|
let kinds = [...BRANCH_KINDS];
|
|
90248
90219
|
try {
|
|
@@ -90348,7 +90319,7 @@ function commitMessage(parsed, io) {
|
|
|
90348
90319
|
|
|
90349
90320
|
`);
|
|
90350
90321
|
try {
|
|
90351
|
-
return file === "-" ?
|
|
90322
|
+
return file === "-" ? readFileSync31(0, "utf8") : readFileSync31(path73.resolve(io.cwd, file), "utf8");
|
|
90352
90323
|
} catch (error) {
|
|
90353
90324
|
return {
|
|
90354
90325
|
error: `cannot read -F ${file}: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -90406,7 +90377,7 @@ async function commit(argv, io) {
|
|
|
90406
90377
|
}
|
|
90407
90378
|
function readPatch(file, io) {
|
|
90408
90379
|
try {
|
|
90409
|
-
return file === "-" ?
|
|
90380
|
+
return file === "-" ? readFileSync31(0, "utf8") : readFileSync31(path73.resolve(io.cwd, file), "utf8");
|
|
90410
90381
|
} catch (error) {
|
|
90411
90382
|
return {
|
|
90412
90383
|
error: `cannot read --patch ${file}: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -91883,7 +91854,7 @@ var init_stack2 = __esm(() => {
|
|
|
91883
91854
|
// packages/workit-core/src/fanout-brief.ts
|
|
91884
91855
|
import { createHash as createHash20 } from "node:crypto";
|
|
91885
91856
|
import fs35 from "node:fs";
|
|
91886
|
-
import
|
|
91857
|
+
import path74 from "node:path";
|
|
91887
91858
|
function workerSession(lead, slice, attempt) {
|
|
91888
91859
|
const tail = attempt === null ? "" : `+try${attempt}`;
|
|
91889
91860
|
const full = `${lead}-w-${slice}${tail}`;
|
|
@@ -91966,7 +91937,7 @@ function renderBrief(cwd, plan, input) {
|
|
|
91966
91937
|
"STANDING:",
|
|
91967
91938
|
...standing.length ? standing.map((order) => ` - ${order.what}`) : [" - none recorded beyond this brief"],
|
|
91968
91939
|
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(
|
|
91940
|
+
...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
91941
|
...identityLines(identity, minted),
|
|
91971
91942
|
...rules(mode, branch, sliceBase, exists ? planned : null)
|
|
91972
91943
|
];
|
|
@@ -92508,7 +92479,7 @@ __export(exports_fanout, {
|
|
|
92508
92479
|
run: () => run21
|
|
92509
92480
|
});
|
|
92510
92481
|
import fs36 from "node:fs";
|
|
92511
|
-
import
|
|
92482
|
+
import path75 from "node:path";
|
|
92512
92483
|
function forgeFor(io, offline) {
|
|
92513
92484
|
if (offline)
|
|
92514
92485
|
return { forge: null, error: "--offline" };
|
|
@@ -92569,7 +92540,7 @@ function plan2(argv, io) {
|
|
|
92569
92540
|
return usage4(io, "pass --trunk or --track, not both (--track picks the trunk)", PLAN_USAGE2);
|
|
92570
92541
|
if (flags.positionals.length !== 1)
|
|
92571
92542
|
return usage4(io, flags.positionals.length ? `unexpected argument ${flags.positionals[1]}` : "missing <plan.json>", PLAN_USAGE2);
|
|
92572
|
-
const file =
|
|
92543
|
+
const file = path75.resolve(io.cwd, flags.positionals[0]);
|
|
92573
92544
|
let raw;
|
|
92574
92545
|
try {
|
|
92575
92546
|
raw = JSON.parse(fs36.readFileSync(file, "utf8"));
|
|
@@ -108145,7 +108116,7 @@ var init_ast = __esm(() => {
|
|
|
108145
108116
|
|
|
108146
108117
|
// packages/workit-cli/src/test-audit/rules.ts
|
|
108147
108118
|
import { builtinModules } from "node:module";
|
|
108148
|
-
import
|
|
108119
|
+
import path76 from "node:path";
|
|
108149
108120
|
function testCallee(call) {
|
|
108150
108121
|
let callee = call.callee;
|
|
108151
108122
|
if (callee.type === "CallExpression")
|
|
@@ -108638,12 +108609,12 @@ function checkConstantsOnly(ctx, emit) {
|
|
|
108638
108609
|
}
|
|
108639
108610
|
function checkOverMocking(ctx, emit) {
|
|
108640
108611
|
const { program } = ctx.parsed;
|
|
108641
|
-
const unit =
|
|
108612
|
+
const unit = path76.basename(ctx.file).replace(/\.(?:[cm]?[jt]sx?)$/, "").replace(/\.(?:test|spec)$/, "");
|
|
108642
108613
|
const mocked = find2(program, (node) => node.type === "CallExpression" && MODULE_MOCK.test(calleeName(node.callee) ?? "") && node.arguments[0]?.type === "StringLiteral");
|
|
108643
108614
|
const internal = mocked.filter((call) => /^(?:\.|@\/|~\/)/.test(call.arguments[0].value));
|
|
108644
108615
|
for (const call of mocked) {
|
|
108645
108616
|
const spec = call.arguments[0].value;
|
|
108646
|
-
const base =
|
|
108617
|
+
const base = path76.basename(spec.replace(/\/index(?:\.[cm]?[jt]sx?)?$/, "")).replace(/\.(?:[cm]?[jt]sx?)$/, "");
|
|
108647
108618
|
if (base === unit)
|
|
108648
108619
|
emit({
|
|
108649
108620
|
rule: "over-mocking",
|
|
@@ -109032,8 +109003,8 @@ var init_rules = __esm(() => {
|
|
|
109032
109003
|
|
|
109033
109004
|
// packages/workit-cli/src/test-audit/audit.ts
|
|
109034
109005
|
import { spawnSync as spawnSync31 } from "node:child_process";
|
|
109035
|
-
import { existsSync as existsSync29, readdirSync as readdirSync15, readFileSync as
|
|
109036
|
-
import
|
|
109006
|
+
import { existsSync as existsSync29, readdirSync as readdirSync15, readFileSync as readFileSync32, statSync as statSync11 } from "node:fs";
|
|
109007
|
+
import path77 from "node:path";
|
|
109037
109008
|
function git7(cwd, args) {
|
|
109038
109009
|
const run = spawnSync31("git", ["-c", "core.quotepath=off", ...args], {
|
|
109039
109010
|
cwd,
|
|
@@ -109046,7 +109017,7 @@ function walkTests(dir, out) {
|
|
|
109046
109017
|
for (const entry of readdirSync15(dir, { withFileTypes: true })) {
|
|
109047
109018
|
if (entry.name.startsWith(".") && entry.name !== "." && entry.isDirectory())
|
|
109048
109019
|
continue;
|
|
109049
|
-
const full =
|
|
109020
|
+
const full = path77.join(dir, entry.name);
|
|
109050
109021
|
if (entry.isDirectory()) {
|
|
109051
109022
|
if (!SKIP_DIRS.has(entry.name))
|
|
109052
109023
|
walkTests(full, out);
|
|
@@ -109058,7 +109029,7 @@ function expandPaths(cwd, inputs) {
|
|
|
109058
109029
|
const files = [];
|
|
109059
109030
|
const missing = [];
|
|
109060
109031
|
for (const input of inputs.length > 0 ? inputs : ["."]) {
|
|
109061
|
-
const full =
|
|
109032
|
+
const full = path77.resolve(cwd, input);
|
|
109062
109033
|
if (!existsSync29(full))
|
|
109063
109034
|
missing.push(input);
|
|
109064
109035
|
else if (statSync11(full).isDirectory())
|
|
@@ -109095,11 +109066,11 @@ function changedLines(cwd, base) {
|
|
|
109095
109066
|
for (let offset = 0;offset < count; offset += 1)
|
|
109096
109067
|
lines.add(start + offset);
|
|
109097
109068
|
}
|
|
109098
|
-
changed.set(
|
|
109069
|
+
changed.set(path77.join(root, file), lines);
|
|
109099
109070
|
}
|
|
109100
109071
|
const untracked = git7(root, ["ls-files", "--others", "--exclude-standard", "-z"]);
|
|
109101
109072
|
for (const file of untracked.stdout.split("\x00").filter(Boolean))
|
|
109102
|
-
changed.set(
|
|
109073
|
+
changed.set(path77.join(root, file), "all");
|
|
109103
109074
|
return changed;
|
|
109104
109075
|
}
|
|
109105
109076
|
function auditFiles(files, display) {
|
|
@@ -109112,7 +109083,7 @@ function auditFiles(files, display) {
|
|
|
109112
109083
|
const shown = display(file);
|
|
109113
109084
|
let parsed;
|
|
109114
109085
|
try {
|
|
109115
|
-
parsed = parseSource(
|
|
109086
|
+
parsed = parseSource(readFileSync32(file, "utf8"), file);
|
|
109116
109087
|
} catch (error) {
|
|
109117
109088
|
parseErrors.push({
|
|
109118
109089
|
file: shown,
|
|
@@ -109161,7 +109132,7 @@ function auditFiles(files, display) {
|
|
|
109161
109132
|
durationMs: Math.round(performance.now() - started)
|
|
109162
109133
|
};
|
|
109163
109134
|
}
|
|
109164
|
-
var TEST_FILE, CODE_FILE, SKIP_DIRS, toPosix = (file) => file.split(
|
|
109135
|
+
var TEST_FILE, CODE_FILE, SKIP_DIRS, toPosix = (file) => file.split(path77.sep).join("/"), SEVERITY_ORDER, ruleIds;
|
|
109165
109136
|
var init_audit = __esm(() => {
|
|
109166
109137
|
init_ast();
|
|
109167
109138
|
init_rules();
|
|
@@ -109180,9 +109151,9 @@ import {
|
|
|
109180
109151
|
mkdirSync as mkdirSync13,
|
|
109181
109152
|
mkdtempSync as mkdtempSync6,
|
|
109182
109153
|
readdirSync as readdirSync16,
|
|
109183
|
-
readFileSync as
|
|
109154
|
+
readFileSync as readFileSync33,
|
|
109184
109155
|
readlinkSync as readlinkSync3,
|
|
109185
|
-
realpathSync as
|
|
109156
|
+
realpathSync as realpathSync13,
|
|
109186
109157
|
renameSync as renameSync8,
|
|
109187
109158
|
rmSync as rmSync12,
|
|
109188
109159
|
statSync as statSync12,
|
|
@@ -109191,7 +109162,7 @@ import {
|
|
|
109191
109162
|
copyFileSync as copyFileSync9
|
|
109192
109163
|
} from "node:fs";
|
|
109193
109164
|
import os27 from "node:os";
|
|
109194
|
-
import
|
|
109165
|
+
import path78 from "node:path";
|
|
109195
109166
|
function mutantsFor(source, file, lines) {
|
|
109196
109167
|
const parsed = parseSource(source, file);
|
|
109197
109168
|
const out = [];
|
|
@@ -109264,7 +109235,7 @@ function relatedTests(source, testFiles) {
|
|
|
109264
109235
|
for (const match of text.matchAll(SPECIFIER)) {
|
|
109265
109236
|
const spec = match[1];
|
|
109266
109237
|
if (spec.startsWith(".")) {
|
|
109267
|
-
if (stripExt(
|
|
109238
|
+
if (stripExt(path78.posix.join(path78.posix.dirname(file), spec)) === target)
|
|
109268
109239
|
return true;
|
|
109269
109240
|
} else if (spec.includes("/") && stripExt(spec).split("/").slice(-2).join("/") === tail)
|
|
109270
109241
|
return true;
|
|
@@ -109284,12 +109255,12 @@ function removeStaleCopies(tmp = os27.tmpdir()) {
|
|
|
109284
109255
|
for (const name of names) {
|
|
109285
109256
|
if (!name.startsWith(TEMP_PREFIX))
|
|
109286
109257
|
continue;
|
|
109287
|
-
const dir =
|
|
109258
|
+
const dir = path78.join(tmp, name);
|
|
109288
109259
|
try {
|
|
109289
109260
|
const stat = lstatSync10(dir);
|
|
109290
109261
|
if (!stat.isDirectory() || uid !== undefined && stat.uid !== uid)
|
|
109291
109262
|
continue;
|
|
109292
|
-
const pid = Number(
|
|
109263
|
+
const pid = Number(readFileSync33(path78.join(dir, PID_FILE), "utf8"));
|
|
109293
109264
|
if (Number.isInteger(pid) && pid > 0 && alive(pid))
|
|
109294
109265
|
continue;
|
|
109295
109266
|
} catch (error) {
|
|
@@ -109306,8 +109277,8 @@ function removeStaleCopies(tmp = os27.tmpdir()) {
|
|
|
109306
109277
|
function linkNodeModules(origin, target, repo, copy) {
|
|
109307
109278
|
mkdirSync13(target, { recursive: true });
|
|
109308
109279
|
for (const entry of readdirSync16(origin, { withFileTypes: true })) {
|
|
109309
|
-
const from =
|
|
109310
|
-
const to =
|
|
109280
|
+
const from = path78.join(origin, entry.name);
|
|
109281
|
+
const to = path78.join(target, entry.name);
|
|
109311
109282
|
if (entry.name.startsWith("@") && entry.isDirectory()) {
|
|
109312
109283
|
linkNodeModules(from, to, repo, copy);
|
|
109313
109284
|
continue;
|
|
@@ -109319,13 +109290,13 @@ function linkNodeModules(origin, target, repo, copy) {
|
|
|
109319
109290
|
if (entry.isSymbolicLink()) {
|
|
109320
109291
|
let real;
|
|
109321
109292
|
try {
|
|
109322
|
-
real =
|
|
109293
|
+
real = realpathSync13(from);
|
|
109323
109294
|
} catch {
|
|
109324
109295
|
continue;
|
|
109325
109296
|
}
|
|
109326
|
-
const relative =
|
|
109327
|
-
if (!relative.startsWith("..") && !
|
|
109328
|
-
symlinkSync(
|
|
109297
|
+
const relative = path78.relative(repo, real);
|
|
109298
|
+
if (!relative.startsWith("..") && !path78.isAbsolute(relative) && !relative.split(path78.sep).includes("node_modules")) {
|
|
109299
|
+
symlinkSync(path78.join(copy, relative), to, "junction");
|
|
109329
109300
|
continue;
|
|
109330
109301
|
}
|
|
109331
109302
|
}
|
|
@@ -109335,13 +109306,13 @@ function linkNodeModules(origin, target, repo, copy) {
|
|
|
109335
109306
|
function copySymlink(repo, tree, from, to) {
|
|
109336
109307
|
let real = null;
|
|
109337
109308
|
try {
|
|
109338
|
-
real =
|
|
109309
|
+
real = realpathSync13(from);
|
|
109339
109310
|
} catch {
|
|
109340
109311
|
real = null;
|
|
109341
109312
|
}
|
|
109342
|
-
const realRepo =
|
|
109313
|
+
const realRepo = realpathSync13(repo);
|
|
109343
109314
|
if (real && inside5(realRepo, real)) {
|
|
109344
|
-
symlinkSync(
|
|
109315
|
+
symlinkSync(path78.relative(path78.dirname(to), path78.join(tree, path78.relative(realRepo, real))), to);
|
|
109345
109316
|
return;
|
|
109346
109317
|
}
|
|
109347
109318
|
if (real && statSync12(real).isFile())
|
|
@@ -109350,10 +109321,10 @@ function copySymlink(repo, tree, from, to) {
|
|
|
109350
109321
|
symlinkSync(readlinkSync3(from), to);
|
|
109351
109322
|
}
|
|
109352
109323
|
function writeInside(copy, file, content) {
|
|
109353
|
-
const target =
|
|
109324
|
+
const target = path78.join(copy, file);
|
|
109354
109325
|
try {
|
|
109355
109326
|
const stat = lstatSync10(target);
|
|
109356
|
-
if (!stat.isFile() || !inside5(
|
|
109327
|
+
if (!stat.isFile() || !inside5(realpathSync13(copy), realpathSync13(path78.dirname(target))))
|
|
109357
109328
|
return false;
|
|
109358
109329
|
} catch {
|
|
109359
109330
|
return false;
|
|
@@ -109364,9 +109335,9 @@ function writeInside(copy, file, content) {
|
|
|
109364
109335
|
return true;
|
|
109365
109336
|
}
|
|
109366
109337
|
function copyWorkingTree(repo) {
|
|
109367
|
-
const dir = mkdtempSync6(
|
|
109368
|
-
writeFileSync15(
|
|
109369
|
-
const tree =
|
|
109338
|
+
const dir = mkdtempSync6(path78.join(os27.tmpdir(), TEMP_PREFIX));
|
|
109339
|
+
writeFileSync15(path78.join(dir, PID_FILE), String(process.pid));
|
|
109340
|
+
const tree = path78.join(dir, "tree");
|
|
109370
109341
|
const head = git7(repo, ["rev-parse", "--verify", "--quiet", "HEAD"]).stdout.trim();
|
|
109371
109342
|
if (head && git7(dir, ["clone", "-q", "--shared", "--no-checkout", repo, tree]).ok) {
|
|
109372
109343
|
const branch = git7(repo, ["symbolic-ref", "--quiet", "--short", "HEAD"]).stdout.trim();
|
|
@@ -109383,29 +109354,29 @@ function copyWorkingTree(repo) {
|
|
|
109383
109354
|
for (const relative of listed) {
|
|
109384
109355
|
if (!relative)
|
|
109385
109356
|
continue;
|
|
109386
|
-
const from =
|
|
109357
|
+
const from = path78.join(repo, relative);
|
|
109387
109358
|
let stat;
|
|
109388
109359
|
try {
|
|
109389
109360
|
stat = lstatSync10(from);
|
|
109390
109361
|
} catch {
|
|
109391
109362
|
continue;
|
|
109392
109363
|
}
|
|
109393
|
-
const to =
|
|
109394
|
-
mkdirSync13(
|
|
109364
|
+
const to = path78.join(tree, relative);
|
|
109365
|
+
mkdirSync13(path78.dirname(to), { recursive: true });
|
|
109395
109366
|
if (stat.isSymbolicLink())
|
|
109396
109367
|
copySymlink(repo, tree, from, to);
|
|
109397
109368
|
else if (stat.isFile())
|
|
109398
109369
|
copyFileSync9(from, to);
|
|
109399
|
-
let parent =
|
|
109370
|
+
let parent = path78.dirname(relative);
|
|
109400
109371
|
while (parent !== "." && !dirs.has(parent)) {
|
|
109401
109372
|
dirs.add(parent);
|
|
109402
|
-
parent =
|
|
109373
|
+
parent = path78.dirname(parent);
|
|
109403
109374
|
}
|
|
109404
109375
|
}
|
|
109405
109376
|
for (const parent of dirs) {
|
|
109406
|
-
const modules =
|
|
109407
|
-
if (existsSync30(modules) && !existsSync30(
|
|
109408
|
-
linkNodeModules(modules,
|
|
109377
|
+
const modules = path78.join(repo, parent, "node_modules");
|
|
109378
|
+
if (existsSync30(modules) && !existsSync30(path78.join(tree, parent, "node_modules")))
|
|
109379
|
+
linkNodeModules(modules, path78.join(tree, parent, "node_modules"), repo, tree);
|
|
109409
109380
|
}
|
|
109410
109381
|
return { dir, tree };
|
|
109411
109382
|
}
|
|
@@ -109444,20 +109415,20 @@ async function runMutation(options) {
|
|
|
109444
109415
|
const tracked = git7(repo, ["ls-files", "-co", "--exclude-standard", "-z"]).stdout.split("\x00").filter(Boolean);
|
|
109445
109416
|
const testFiles = tracked.filter((file) => TEST_FILE.test(file)).map((file) => {
|
|
109446
109417
|
try {
|
|
109447
|
-
return { file, text:
|
|
109418
|
+
return { file, text: readFileSync33(path78.join(repo, file), "utf8") };
|
|
109448
109419
|
} catch {
|
|
109449
109420
|
return { file, text: "" };
|
|
109450
109421
|
}
|
|
109451
109422
|
});
|
|
109452
109423
|
const candidates = [];
|
|
109453
109424
|
for (const [absolute, lines] of [...options.changed].toSorted(([a], [b]) => a.localeCompare(b))) {
|
|
109454
|
-
const relative = toPosix(
|
|
109425
|
+
const relative = toPosix(path78.relative(repo, absolute));
|
|
109455
109426
|
if (!CODE_FILE.test(relative) || TEST_FILE.test(relative) || relative.endsWith(".d.ts"))
|
|
109456
109427
|
continue;
|
|
109457
109428
|
if (NOT_SOURCE.test(relative) || !existsSync30(absolute))
|
|
109458
109429
|
continue;
|
|
109459
109430
|
try {
|
|
109460
|
-
candidates.push(...mutantsFor(
|
|
109431
|
+
candidates.push(...mutantsFor(readFileSync33(absolute, "utf8"), relative, lines));
|
|
109461
109432
|
} catch {}
|
|
109462
109433
|
}
|
|
109463
109434
|
const mutants = candidates.map((mutant, index) => ({ ...mutant, id: index + 1 }));
|
|
@@ -109465,9 +109436,9 @@ async function runMutation(options) {
|
|
|
109465
109436
|
for (const mutant of mutants)
|
|
109466
109437
|
if (!related.has(mutant.file))
|
|
109467
109438
|
related.set(mutant.file, relatedTests(mutant.file, testFiles));
|
|
109468
|
-
const cwdRelative =
|
|
109439
|
+
const cwdRelative = path78.relative(repo, options.cwd);
|
|
109469
109440
|
const asArg = (file) => {
|
|
109470
|
-
const relative = toPosix(
|
|
109441
|
+
const relative = toPosix(path78.relative(cwdRelative, file));
|
|
109471
109442
|
return shellQuote(relative.startsWith(".") ? relative : `./${relative}`);
|
|
109472
109443
|
};
|
|
109473
109444
|
const commandFor = (tests) => options.command.replaceAll("{files}", () => tests.map(asArg).join(" "));
|
|
@@ -109503,7 +109474,7 @@ async function runMutation(options) {
|
|
|
109503
109474
|
return finish3(options, 0, results, counts, started);
|
|
109504
109475
|
removeStaleCopies();
|
|
109505
109476
|
const { dir: copyDir, tree: copy } = copyWorkingTree(repo);
|
|
109506
|
-
const copyCwd =
|
|
109477
|
+
const copyCwd = path78.join(copy, cwdRelative);
|
|
109507
109478
|
let current = null;
|
|
109508
109479
|
const restore = () => {
|
|
109509
109480
|
if (current)
|
|
@@ -109538,7 +109509,7 @@ async function runMutation(options) {
|
|
|
109538
109509
|
record({ ...mutant, status: "skipped", durationMs: 0, tests, reason: "budget" });
|
|
109539
109510
|
continue;
|
|
109540
109511
|
}
|
|
109541
|
-
const original =
|
|
109512
|
+
const original = readFileSync33(path78.join(copy, mutant.file), "utf8");
|
|
109542
109513
|
const mutated = original.slice(0, mutant.start) + mutant.replacement + original.slice(mutant.end);
|
|
109543
109514
|
current = { file: mutant.file, original };
|
|
109544
109515
|
if (!writeInside(copy, mutant.file, mutated)) {
|
|
@@ -109595,8 +109566,8 @@ var NOT_SOURCE, FLIPS, isStringy = (node) => node.type === "StringLiteral" || no
|
|
|
109595
109566
|
return error.code === "EPERM";
|
|
109596
109567
|
}
|
|
109597
109568
|
}, inside5 = (root, file) => {
|
|
109598
|
-
const relative =
|
|
109599
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
109569
|
+
const relative = path78.relative(root, file);
|
|
109570
|
+
return relative === "" || !relative.startsWith("..") && !path78.isAbsolute(relative);
|
|
109600
109571
|
}, active, killTree = (child) => {
|
|
109601
109572
|
try {
|
|
109602
109573
|
if (child.pid && process.platform !== "win32")
|
|
@@ -109645,7 +109616,7 @@ __export(exports_test_audit, {
|
|
|
109645
109616
|
run: () => run23
|
|
109646
109617
|
});
|
|
109647
109618
|
import { existsSync as existsSync31 } from "node:fs";
|
|
109648
|
-
import
|
|
109619
|
+
import path79 from "node:path";
|
|
109649
109620
|
function parse8(argv) {
|
|
109650
109621
|
const options = {
|
|
109651
109622
|
paths: [],
|
|
@@ -109750,8 +109721,8 @@ async function run23(argv, io) {
|
|
|
109750
109721
|
return emit(io, fail2("invalid_input", `${options}
|
|
109751
109722
|
usage: ${USAGE16}`));
|
|
109752
109723
|
const top = git7(io.cwd, ["rev-parse", "--show-toplevel"]);
|
|
109753
|
-
const repo = top.ok ?
|
|
109754
|
-
const display = (file) => toPosix(
|
|
109724
|
+
const repo = top.ok ? path79.resolve(top.stdout.trim()) : null;
|
|
109725
|
+
const display = (file) => toPosix(path79.relative(io.cwd, file) || file);
|
|
109755
109726
|
let base = null;
|
|
109756
109727
|
let changed = null;
|
|
109757
109728
|
if (options.diff || options.mutate) {
|
|
@@ -109889,8 +109860,8 @@ var exports_youtrack = {};
|
|
|
109889
109860
|
__export(exports_youtrack, {
|
|
109890
109861
|
run: () => run25
|
|
109891
109862
|
});
|
|
109892
|
-
import { readFileSync as
|
|
109893
|
-
import
|
|
109863
|
+
import { readFileSync as readFileSync34 } from "node:fs";
|
|
109864
|
+
import path80 from "node:path";
|
|
109894
109865
|
async function run25(argv, io) {
|
|
109895
109866
|
const [sub, ...rest] = argv;
|
|
109896
109867
|
if (sub !== "note" && sub !== "time" && sub !== "meeting")
|
|
@@ -109936,7 +109907,7 @@ async function run25(argv, io) {
|
|
|
109936
109907
|
let markdown = flags.values.markdown ?? "";
|
|
109937
109908
|
if (flags.values.file)
|
|
109938
109909
|
try {
|
|
109939
|
-
markdown =
|
|
109910
|
+
markdown = readFileSync34(path80.resolve(io.cwd, flags.values.file), "utf8");
|
|
109940
109911
|
} catch (error) {
|
|
109941
109912
|
return usage4(io, `cannot read ${flags.values.file}: ${String(error)}`, USAGE18);
|
|
109942
109913
|
}
|
|
@@ -110007,8 +109978,8 @@ var exports_changelog = {};
|
|
|
110007
109978
|
__export(exports_changelog, {
|
|
110008
109979
|
run: () => run26
|
|
110009
109980
|
});
|
|
110010
|
-
import { readFileSync as
|
|
110011
|
-
import
|
|
109981
|
+
import { readFileSync as readFileSync35 } from "node:fs";
|
|
109982
|
+
import path81 from "node:path";
|
|
110012
109983
|
async function run26(argv, io) {
|
|
110013
109984
|
const [sub, ...rest] = argv;
|
|
110014
109985
|
if (sub !== "apply")
|
|
@@ -110054,7 +110025,7 @@ async function run26(argv, io) {
|
|
|
110054
110025
|
]);
|
|
110055
110026
|
}
|
|
110056
110027
|
var USAGE19 = "workit changelog apply (--entries <JSON|@file|-> | --normalize-only) [--path CHANGELOG.md] [--preview]", readEntries = (raw, cwd) => {
|
|
110057
|
-
const text = raw === "-" ?
|
|
110028
|
+
const text = raw === "-" ? readFileSync35(0, "utf8") : raw.startsWith("@") ? readFileSync35(path81.resolve(cwd, raw.slice(1)), "utf8") : raw;
|
|
110058
110029
|
return JSON.parse(text);
|
|
110059
110030
|
};
|
|
110060
110031
|
var init_changelog2 = __esm(() => {
|
|
@@ -110070,7 +110041,7 @@ __export(exports_handoff, {
|
|
|
110070
110041
|
run: () => run27
|
|
110071
110042
|
});
|
|
110072
110043
|
import fs37 from "node:fs";
|
|
110073
|
-
import
|
|
110044
|
+
import path82 from "node:path";
|
|
110074
110045
|
import { parseArgs as parseArgs2 } from "node:util";
|
|
110075
110046
|
function render3(brief) {
|
|
110076
110047
|
const lines = [
|
|
@@ -110110,9 +110081,9 @@ function bounded(brief, cwd) {
|
|
|
110110
110081
|
let file = null;
|
|
110111
110082
|
if (store.ok)
|
|
110112
110083
|
try {
|
|
110113
|
-
const dir =
|
|
110084
|
+
const dir = path82.join(store.value.root, "handoff");
|
|
110114
110085
|
fs37.mkdirSync(dir, { recursive: true });
|
|
110115
|
-
file =
|
|
110086
|
+
file = path82.join(dir, `${(brief.branch ?? "detached").replaceAll(/[^\w.-]+/gu, "-")}.txt`);
|
|
110116
110087
|
fs37.writeFileSync(file, `${[...body, ...tail].join(`
|
|
110117
110088
|
`)}
|
|
110118
110089
|
`, {
|
|
@@ -110187,7 +110158,7 @@ var init_handoff = __esm(() => {
|
|
|
110187
110158
|
});
|
|
110188
110159
|
|
|
110189
110160
|
// packages/workit-cli/src/main.ts
|
|
110190
|
-
import
|
|
110161
|
+
import path83 from "node:path";
|
|
110191
110162
|
|
|
110192
110163
|
// packages/workit-core/src/git/env-redirect.ts
|
|
110193
110164
|
var GIT_REDIRECT_ENV = [
|
|
@@ -111148,7 +111119,7 @@ var defaultIo = (json) => ({
|
|
|
111148
111119
|
});
|
|
111149
111120
|
async function main(argv, overrides = {}, options = {}) {
|
|
111150
111121
|
const parsed = parseGlobals(argv);
|
|
111151
|
-
const cwd =
|
|
111122
|
+
const cwd = path83.resolve(overrides.cwd ?? process.cwd(), parsed.cwd ?? ".");
|
|
111152
111123
|
const io = {
|
|
111153
111124
|
...defaultIo(parsed.json),
|
|
111154
111125
|
terminals: {
|