@brainervirus/workit-claude-code 8.40.2 → 8.40.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-hook.js +119 -119
- package/dist/workit.js +315 -256
- package/package.json +3 -3
package/dist/workit.js
CHANGED
|
@@ -6389,7 +6389,7 @@ var init_zod = __esm(() => {
|
|
|
6389
6389
|
// packages/workit-core/src/core/workspaces.ts
|
|
6390
6390
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
6391
6391
|
import { createHash } from "node:crypto";
|
|
6392
|
-
import { readFileSync as readFileSync2, realpathSync } from "node:fs";
|
|
6392
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, realpathSync } from "node:fs";
|
|
6393
6393
|
import path2 from "node:path";
|
|
6394
6394
|
function workspaceDefaultTarget(cwd, globalDefault) {
|
|
6395
6395
|
const ws = resolveRuntimeWorkspaceVcs(cwd);
|
|
@@ -6531,10 +6531,17 @@ var nonBlank, branchPreset, commitPreset, workspaceBranchPolicySchema, workspace
|
|
|
6531
6531
|
};
|
|
6532
6532
|
}
|
|
6533
6533
|
return { ok: true };
|
|
6534
|
-
}, WorkspaceConfigError,
|
|
6535
|
-
const cached =
|
|
6534
|
+
}, WorkspaceConfigError, probes, probeCheckout = (cwd) => {
|
|
6535
|
+
const cached = probes.get(cwd);
|
|
6536
6536
|
if (cached !== undefined)
|
|
6537
6537
|
return cached;
|
|
6538
|
+
let dir = path2.resolve(cwd);
|
|
6539
|
+
while (!existsSync2(path2.join(dir, ".git"))) {
|
|
6540
|
+
const up = path2.dirname(dir);
|
|
6541
|
+
if (up === dir)
|
|
6542
|
+
return null;
|
|
6543
|
+
dir = up;
|
|
6544
|
+
}
|
|
6538
6545
|
const env = { ...process.env };
|
|
6539
6546
|
for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
|
|
6540
6547
|
delete env[name];
|
|
@@ -6548,15 +6555,43 @@ var nonBlank, branchPreset, commitPreset, workspaceBranchPolicySchema, workspace
|
|
|
6548
6555
|
});
|
|
6549
6556
|
return run.status === 0 ? run.stdout : null;
|
|
6550
6557
|
};
|
|
6558
|
+
const failed = Error(`git could not tell what checkout ${cwd} is`);
|
|
6559
|
+
const [gitDir, common, superproject] = (git([
|
|
6560
|
+
"rev-parse",
|
|
6561
|
+
"--path-format=absolute",
|
|
6562
|
+
"--git-dir",
|
|
6563
|
+
"--git-common-dir",
|
|
6564
|
+
"--show-superproject-working-tree"
|
|
6565
|
+
]) ?? "").trim().split(/\r?\n/u);
|
|
6566
|
+
if (!gitDir || !common)
|
|
6567
|
+
return failed;
|
|
6551
6568
|
let main = null;
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
main =
|
|
6557
|
-
}
|
|
6558
|
-
|
|
6559
|
-
|
|
6569
|
+
if (path2.resolve(gitDir) !== path2.resolve(common)) {
|
|
6570
|
+
const list = git(["worktree", "list", "--porcelain"]);
|
|
6571
|
+
if (list === null)
|
|
6572
|
+
return failed;
|
|
6573
|
+
main = /^worktree (.+)$/mu.exec(list)?.[1]?.trim() || (path2.basename(common) === ".git" ? path2.dirname(common) : common);
|
|
6574
|
+
}
|
|
6575
|
+
const probe = { main, superproject: superproject || null };
|
|
6576
|
+
probes.set(cwd, probe);
|
|
6577
|
+
return probe;
|
|
6578
|
+
}, mainCheckoutOf = (cwd) => {
|
|
6579
|
+
const probe = probeCheckout(cwd);
|
|
6580
|
+
return probe instanceof Error ? null : probe?.main ?? null;
|
|
6581
|
+
}, checkoutsAbove = (cwd, seen = new Set) => {
|
|
6582
|
+
const probe = probeCheckout(cwd);
|
|
6583
|
+
if (probe instanceof Error)
|
|
6584
|
+
return probe;
|
|
6585
|
+
const out = [];
|
|
6586
|
+
for (const above of [probe?.main, probe?.superproject])
|
|
6587
|
+
if (above && !seen.has(above)) {
|
|
6588
|
+
seen.add(above);
|
|
6589
|
+
const rest = checkoutsAbove(above, seen);
|
|
6590
|
+
if (rest instanceof Error)
|
|
6591
|
+
return rest;
|
|
6592
|
+
out.push(above, ...rest);
|
|
6593
|
+
}
|
|
6594
|
+
return out;
|
|
6560
6595
|
}, matchingEntries = (cwd, entries) => {
|
|
6561
6596
|
const match = (where) => {
|
|
6562
6597
|
const targets = [where, realpathOf(where)].map((value) => value.replaceAll("\\", "/"));
|
|
@@ -6999,7 +7034,7 @@ var init_workspaces = __esm(() => {
|
|
|
6999
7034
|
WorkspaceConfigError = class WorkspaceConfigError extends Error {
|
|
7000
7035
|
name = "WorkspaceConfigError";
|
|
7001
7036
|
};
|
|
7002
|
-
|
|
7037
|
+
probes = new Map;
|
|
7003
7038
|
runtimeWorkspaceIndexSchema = object({
|
|
7004
7039
|
workspaces: array(object({ name: nonBlank, glob: nonBlank }).passthrough()).optional()
|
|
7005
7040
|
}).passthrough();
|
|
@@ -9317,7 +9352,7 @@ var package_default;
|
|
|
9317
9352
|
var init_package = __esm(() => {
|
|
9318
9353
|
package_default = {
|
|
9319
9354
|
name: "@brainervirus/workit-cli",
|
|
9320
|
-
version: "8.40.
|
|
9355
|
+
version: "8.40.4",
|
|
9321
9356
|
private: false,
|
|
9322
9357
|
description: "Workit CLI — setup wizard, doctor, and task control for agentic coding workflows",
|
|
9323
9358
|
keywords: [
|
|
@@ -9355,13 +9390,13 @@ var init_package = __esm(() => {
|
|
|
9355
9390
|
},
|
|
9356
9391
|
dependencies: {
|
|
9357
9392
|
"@babel/parser": "7.29.9",
|
|
9358
|
-
"@brainervirus/workit-cursor": "^8.40.
|
|
9393
|
+
"@brainervirus/workit-cursor": "^8.40.4",
|
|
9359
9394
|
"@inkjs/ui": "2.0.0",
|
|
9360
9395
|
ink: "7.1.1",
|
|
9361
9396
|
react: "19.2.8"
|
|
9362
9397
|
},
|
|
9363
9398
|
devDependencies: {
|
|
9364
|
-
"@brainervirus/workit-core": "^8.40.
|
|
9399
|
+
"@brainervirus/workit-core": "^8.40.4"
|
|
9365
9400
|
},
|
|
9366
9401
|
engines: {
|
|
9367
9402
|
node: ">=24"
|
|
@@ -9700,7 +9735,7 @@ function writeFileAtomic(file, content, mode) {
|
|
|
9700
9735
|
var init_safe_write = () => {};
|
|
9701
9736
|
|
|
9702
9737
|
// packages/workit-core/src/autonomy.ts
|
|
9703
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
9738
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync3 } from "node:fs";
|
|
9704
9739
|
import os4 from "node:os";
|
|
9705
9740
|
import path11 from "node:path";
|
|
9706
9741
|
function endpointOf(entry) {
|
|
@@ -9726,7 +9761,7 @@ function effectiveEndpoint(endpoint, context) {
|
|
|
9726
9761
|
if (context.configured.length > 0 && !context.accountConfigured)
|
|
9727
9762
|
return {
|
|
9728
9763
|
endpoint: "commit",
|
|
9729
|
-
reason: `vcs.account missing;
|
|
9764
|
+
reason: `vcs.account missing; ${accountHint(context.workspace)}`
|
|
9730
9765
|
};
|
|
9731
9766
|
if (endpoint === "merged" && context.grants.merge === false)
|
|
9732
9767
|
return { endpoint: "green", reason: missing("merge") };
|
|
@@ -9800,17 +9835,28 @@ function autonomyOf(workspace) {
|
|
|
9800
9835
|
verification: verificationOf(workspace)
|
|
9801
9836
|
};
|
|
9802
9837
|
}
|
|
9803
|
-
function
|
|
9804
|
-
|
|
9838
|
+
function capAt(named, where, by, why, main = false) {
|
|
9839
|
+
let folder = null;
|
|
9840
|
+
let none = "";
|
|
9841
|
+
try {
|
|
9842
|
+
if (where instanceof Error)
|
|
9843
|
+
throw where;
|
|
9844
|
+
folder = autonomyOf(resolveWorkspaceFrom(where, grantsDir()));
|
|
9845
|
+
} catch (error) {
|
|
9846
|
+
none = error.message;
|
|
9847
|
+
}
|
|
9848
|
+
if (!main && folder?.workspace === named.workspace)
|
|
9805
9849
|
return named;
|
|
9806
9850
|
const nothing = !folder || folder.configured.length > 0 && !folder.accountConfigured;
|
|
9807
9851
|
const grants = { ...named.grants };
|
|
9852
|
+
const unblocks = { ...named.unblocks };
|
|
9808
9853
|
const lowered = [];
|
|
9809
9854
|
for (const kind of GRANT_KINDS) {
|
|
9810
9855
|
const floor = !nothing && folder.grants[kind];
|
|
9811
9856
|
if (!raises(kind, floor, grants[kind]))
|
|
9812
9857
|
continue;
|
|
9813
9858
|
grants[kind] = floor;
|
|
9859
|
+
unblocks[kind] = folder ? nothing ? accountHint(folder.workspace) : grantHint(folder.workspace, kind) : `ask the user to fix: ${none}`;
|
|
9814
9860
|
lowered.push(kind);
|
|
9815
9861
|
}
|
|
9816
9862
|
const ceiling = !nothing && folder.effectiveEndpoint || DEFAULT_ENDPOINT;
|
|
@@ -9823,40 +9869,28 @@ function capByFolder(named, folder, name) {
|
|
|
9823
9869
|
lowered.push("verification");
|
|
9824
9870
|
if (lowered.length === 0)
|
|
9825
9871
|
return named;
|
|
9872
|
+
const note = `${by}: ${lowered.join(", ")} capped at ${folder ? `workspace ${folder.workspace}` : `nothing (${none})`}; ${why}`;
|
|
9826
9873
|
return {
|
|
9827
9874
|
...named,
|
|
9828
9875
|
grants,
|
|
9876
|
+
unblocks,
|
|
9829
9877
|
...endpoint ? { effectiveEndpoint: ceiling, endpointReason: undefined } : {},
|
|
9830
9878
|
verification: looser ? strict : named.verification,
|
|
9831
|
-
note:
|
|
9879
|
+
note: named.note ? `${named.note}; ${note}` : note
|
|
9832
9880
|
};
|
|
9833
9881
|
}
|
|
9834
9882
|
function resolveAutonomy(cwd) {
|
|
9835
9883
|
const override = grantsOverride();
|
|
9836
9884
|
if (override)
|
|
9837
|
-
return {
|
|
9838
|
-
workspace: null,
|
|
9839
|
-
grants: { ...DEFAULT_GRANTS },
|
|
9840
|
-
configured: [],
|
|
9841
|
-
source: "default",
|
|
9842
|
-
accountConfigured: false,
|
|
9843
|
-
defaultEndpoint: DEFAULT_ENDPOINT,
|
|
9844
|
-
configuredEndpoint: null,
|
|
9845
|
-
effectiveEndpoint: DEFAULT_ENDPOINT,
|
|
9846
|
-
verification: DEFAULT_VERIFICATION,
|
|
9847
|
-
note: override
|
|
9848
|
-
};
|
|
9885
|
+
return { ...autonomyOf(null), note: override };
|
|
9849
9886
|
const name = process.env.WORKFLOW_WORKSPACE_NAME?.trim() || undefined;
|
|
9850
|
-
|
|
9851
|
-
if (name
|
|
9852
|
-
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
|
|
9856
|
-
|
|
9857
|
-
folder = null;
|
|
9858
|
-
}
|
|
9859
|
-
return capByFolder(named, folder, name);
|
|
9887
|
+
let autonomy = autonomyOf(resolveWorkspaceFrom(cwd, grantsDir(), name));
|
|
9888
|
+
if (name)
|
|
9889
|
+
autonomy = capAt(autonomy, cwd, `WORKFLOW_WORKSPACE_NAME=${name}`, "a name never raises grants");
|
|
9890
|
+
const above = checkoutsAbove(cwd);
|
|
9891
|
+
for (const where of above instanceof Error ? [above] : above)
|
|
9892
|
+
autonomy = capAt(autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
|
|
9893
|
+
return autonomy;
|
|
9860
9894
|
}
|
|
9861
9895
|
function requireGrant(cwd, kind, options = {}) {
|
|
9862
9896
|
let autonomy;
|
|
@@ -9881,7 +9915,7 @@ function requireGrant(cwd, kind, options = {}) {
|
|
|
9881
9915
|
kind,
|
|
9882
9916
|
reason: "grant_required",
|
|
9883
9917
|
error: `grant_required: ${kind} is not granted for ${workspace ? `workspace "${workspace}"` : "this checkout (no workspace matches it)"}${configured ? "" : " (the default ceiling stops at verified, ready)"}${autonomy.note ? `; ${autonomy.note}` : ""}`,
|
|
9884
|
-
unblock: workspace ? grantHint(workspace, kind) : "ask the user to add a workspace for this checkout (workit init → Workspaces), then: workit grant set <workspace> " + `${kind}=${suggested(kind)}
|
|
9918
|
+
unblock: autonomy.unblocks?.[kind] ?? (workspace ? grantHint(workspace, kind) : "ask the user to add a workspace for this checkout (workit init → Workspaces), then: workit grant set <workspace> " + `${kind}=${suggested(kind)}`),
|
|
9885
9919
|
workspace
|
|
9886
9920
|
};
|
|
9887
9921
|
if (autonomy.configured.length > 0 && !autonomy.accountConfigured && options.forge !== false && kind !== "release")
|
|
@@ -9890,7 +9924,7 @@ function requireGrant(cwd, kind, options = {}) {
|
|
|
9890
9924
|
kind,
|
|
9891
9925
|
reason: "account_required",
|
|
9892
9926
|
error: `account_required: workspace "${workspace ?? "?"}" has autonomy grants but no vcs.account, so the credential cannot be checked`,
|
|
9893
|
-
unblock:
|
|
9927
|
+
unblock: accountHint(workspace),
|
|
9894
9928
|
workspace
|
|
9895
9929
|
};
|
|
9896
9930
|
return {
|
|
@@ -9947,7 +9981,7 @@ function writeGrants(workspaceName, changes, dir = grantsDir(), endpoint, verifi
|
|
|
9947
9981
|
return { ok: false, code: "failed", error: `${current.path} changed; retry` };
|
|
9948
9982
|
let backup = null;
|
|
9949
9983
|
try {
|
|
9950
|
-
if (
|
|
9984
|
+
if (existsSync3(current.path)) {
|
|
9951
9985
|
backup = `${current.path}.bak`;
|
|
9952
9986
|
copyFileSync2(current.path, backup);
|
|
9953
9987
|
}
|
|
@@ -10028,7 +10062,7 @@ var accountHome = () => {
|
|
|
10028
10062
|
else if (item === "merge")
|
|
10029
10063
|
grants.merge = "verified";
|
|
10030
10064
|
return Object.keys(grants).length > 0 ? grants : null;
|
|
10031
|
-
}, accountOf = (entry) => entry?.vcs?.account, suggested = (kind) => kind === "merge" ? "verified" : "true", grantHint = (workspace, kind) => `ask the user to run, in their own terminal: workit grant set ${workspace ?? "<workspace>"} ${kind}=${suggested(kind)}`, raises = (kind, current, next) => {
|
|
10065
|
+
}, accountOf = (entry) => entry?.vcs?.account, suggested = (kind) => kind === "merge" ? "verified" : "true", accountHint = (workspace) => `set vcs.account for workspace "${workspace ?? "?"}" in ~/.config/workit/workspaces.json`, grantHint = (workspace, kind) => `ask the user to run, in their own terminal: workit grant set ${workspace ?? "<workspace>"} ${kind}=${suggested(kind)}`, raises = (kind, current, next) => {
|
|
10032
10066
|
const rank = (value) => value === true ? 2 : value === "verified" ? 1 : 0;
|
|
10033
10067
|
return rank(normalized(kind, next)) > rank(normalized(kind, current));
|
|
10034
10068
|
};
|
|
@@ -10686,21 +10720,21 @@ var init_file_lock = __esm(() => {
|
|
|
10686
10720
|
});
|
|
10687
10721
|
|
|
10688
10722
|
// packages/workit-core/src/core/package-root.ts
|
|
10689
|
-
import { existsSync as
|
|
10723
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
10690
10724
|
import path14 from "node:path";
|
|
10691
10725
|
import { fileURLToPath } from "node:url";
|
|
10692
10726
|
var packageRoot = () => {
|
|
10693
10727
|
let dir = path14.dirname(fileURLToPath(import.meta.url));
|
|
10694
10728
|
while (true) {
|
|
10695
10729
|
const parent = path14.dirname(dir);
|
|
10696
|
-
if (
|
|
10730
|
+
if (existsSync4(path14.join(dir, "package.json")) || parent === dir)
|
|
10697
10731
|
return dir;
|
|
10698
10732
|
dir = parent;
|
|
10699
10733
|
}
|
|
10700
10734
|
}, assetRoot = () => {
|
|
10701
10735
|
const root = packageRoot();
|
|
10702
10736
|
const assets = path14.join(root, "assets");
|
|
10703
|
-
return
|
|
10737
|
+
return existsSync4(assets) ? assets : root;
|
|
10704
10738
|
};
|
|
10705
10739
|
var init_package_root = () => {};
|
|
10706
10740
|
|
|
@@ -14307,7 +14341,7 @@ var init_substance = __esm(() => {
|
|
|
14307
14341
|
});
|
|
14308
14342
|
|
|
14309
14343
|
// packages/workit-core/src/core/policy/lane.ts
|
|
14310
|
-
import { existsSync as
|
|
14344
|
+
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "node:fs";
|
|
14311
14345
|
import path18 from "node:path";
|
|
14312
14346
|
function kindOf(file) {
|
|
14313
14347
|
if (file.binary)
|
|
@@ -14521,7 +14555,7 @@ function branchLane(cwd, options) {
|
|
|
14521
14555
|
}
|
|
14522
14556
|
function untrackedRiskPathsWarning(cwd) {
|
|
14523
14557
|
const root = worktreeTop(cwd);
|
|
14524
|
-
if (!root || !
|
|
14558
|
+
if (!root || !existsSync6(path18.join(root, RISK_PATHS_FILE)))
|
|
14525
14559
|
return null;
|
|
14526
14560
|
return isTracked(root, RISK_PATHS_FILE) ? null : `${RISK_PATHS_FILE} is not committed: it does not apply until it is committed on the base branch`;
|
|
14527
14561
|
}
|
|
@@ -16139,7 +16173,7 @@ var init_ledger = __esm(() => {
|
|
|
16139
16173
|
});
|
|
16140
16174
|
|
|
16141
16175
|
// packages/workit-core/src/core/policy/derive.ts
|
|
16142
|
-
import { existsSync as
|
|
16176
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
16143
16177
|
import path21 from "node:path";
|
|
16144
16178
|
function deriveRequirements(judgment, scope, constraints, verification = "self") {
|
|
16145
16179
|
const out = [];
|
|
@@ -16294,7 +16328,7 @@ var RULES, derived2 = (spec) => ({
|
|
|
16294
16328
|
decisionIds: []
|
|
16295
16329
|
};
|
|
16296
16330
|
}, planRecorded = (task, root) => {
|
|
16297
|
-
const cited = (latestJudgment(task)?.refs ?? []).find((ref) => ref.kind === "external" || ref.kind === "file" &&
|
|
16331
|
+
const cited = (latestJudgment(task)?.refs ?? []).find((ref) => ref.kind === "external" || ref.kind === "file" && existsSync7(path21.resolve(root, ref.path)));
|
|
16298
16332
|
if (cited)
|
|
16299
16333
|
return {
|
|
16300
16334
|
met: true,
|
|
@@ -19011,8 +19045,97 @@ var init_policy_resolver = __esm(() => {
|
|
|
19011
19045
|
init_derive();
|
|
19012
19046
|
});
|
|
19013
19047
|
|
|
19014
|
-
// packages/workit-core/src/core/task-
|
|
19048
|
+
// packages/workit-core/src/core/task-view.ts
|
|
19015
19049
|
import { realpathSync as realpathSync4 } from "node:fs";
|
|
19050
|
+
function contextRootError(store, context) {
|
|
19051
|
+
try {
|
|
19052
|
+
realpathSync4(context.root);
|
|
19053
|
+
const root = checkoutRootOf(context.root);
|
|
19054
|
+
if (root !== store.root && !sameDirectoryIdentity(root, store.root))
|
|
19055
|
+
return failure2("invalid_input", "operation context root does not match the task store root");
|
|
19056
|
+
} catch {
|
|
19057
|
+
return failure2("invalid_input", "operation context root cannot be resolved");
|
|
19058
|
+
}
|
|
19059
|
+
return success(null, null, null);
|
|
19060
|
+
}
|
|
19061
|
+
function helperEntry(task, context, requireSession = false, requireActive = false) {
|
|
19062
|
+
const workerId = context.workerId ?? null;
|
|
19063
|
+
if (workerId === null)
|
|
19064
|
+
return failure2("permission_denied", "operation is lead-only");
|
|
19065
|
+
const worker = task.workers.find((entry) => entry.id === workerId);
|
|
19066
|
+
if (!worker)
|
|
19067
|
+
return failure2("permission_denied", "worker is not assigned to this task");
|
|
19068
|
+
if (worker.data.session && !sameSession2(worker.data.session, context))
|
|
19069
|
+
return failure2("permission_denied", "worker session does not match the caller");
|
|
19070
|
+
if (requireSession && (!worker.data.session || !sameSession2(worker.data.session, context)))
|
|
19071
|
+
return failure2("permission_denied", "worker session has not been observed");
|
|
19072
|
+
if (requireActive && worker.data.state !== "running")
|
|
19073
|
+
return failure2("permission_denied", "worker is not active");
|
|
19074
|
+
return success(null, null, worker);
|
|
19075
|
+
}
|
|
19076
|
+
function helperTaskGuard(task, context, allowRead = false) {
|
|
19077
|
+
if ((context.workerId ?? null) === null)
|
|
19078
|
+
return success(null, null, null);
|
|
19079
|
+
const worker = helperEntry(task, context);
|
|
19080
|
+
if (!worker.ok)
|
|
19081
|
+
return worker;
|
|
19082
|
+
return allowRead ? success(null, null, null) : failure2("permission_denied", "helpers cannot control task lifecycle or scope");
|
|
19083
|
+
}
|
|
19084
|
+
function taskView(store, context, task, capture = true, freshness = treeFreshness(store.root)) {
|
|
19085
|
+
const workspace = store.readWorkspace();
|
|
19086
|
+
if (!workspace.ok)
|
|
19087
|
+
return workspace;
|
|
19088
|
+
if (!workspace.data)
|
|
19089
|
+
return failure2("not_found", "workspace not found");
|
|
19090
|
+
const historical = task.status === "closed" ? task.candidates.at(-1) : undefined;
|
|
19091
|
+
const current = historical ? success(null, null, historical) : capture ? captureCandidate(store.root, task.intent.data.scope, environment()) : success(null, null, task.candidates.at(-1) ?? null);
|
|
19092
|
+
if (!current.ok)
|
|
19093
|
+
return current;
|
|
19094
|
+
const evaluationWorkspace = workspace.data;
|
|
19095
|
+
const tree = freshness;
|
|
19096
|
+
const requirements = evaluateRequirements(task, evaluationWorkspace, context.capabilities, current.data, store.root, context.caller, tree);
|
|
19097
|
+
return success(task.revision, workspace.data.revision, {
|
|
19098
|
+
task,
|
|
19099
|
+
workspace: evaluationWorkspace,
|
|
19100
|
+
capabilities: context.capabilities,
|
|
19101
|
+
requirements,
|
|
19102
|
+
evidence: evaluateEvidence(task, current.data, tree)
|
|
19103
|
+
});
|
|
19104
|
+
}
|
|
19105
|
+
function compactContext(store, context, taskId, freshness, origin = null) {
|
|
19106
|
+
const root = contextRootError(store, context);
|
|
19107
|
+
if (!root.ok)
|
|
19108
|
+
return root;
|
|
19109
|
+
const base = origin && store.readStoreTask(origin.taskId);
|
|
19110
|
+
const inherited = base?.ok && base.data ? {
|
|
19111
|
+
origin: origin.origin,
|
|
19112
|
+
taskId: base.data.id,
|
|
19113
|
+
decisions: base.data.decisions.filter((entry) => entry.data.revoked === null)
|
|
19114
|
+
} : null;
|
|
19115
|
+
if (taskId === null)
|
|
19116
|
+
return success(null, null, inherited?.decisions.length ? compactTaskContext(null, inherited) : "");
|
|
19117
|
+
const task = store.readTask(taskId);
|
|
19118
|
+
if (!task.ok)
|
|
19119
|
+
return task;
|
|
19120
|
+
const helper = helperTaskGuard(task.data, context, true);
|
|
19121
|
+
if (!helper.ok)
|
|
19122
|
+
return helper;
|
|
19123
|
+
const view = taskView(store, context, task.data, false, freshness ?? signalFreshness(store.root));
|
|
19124
|
+
if (!view.ok)
|
|
19125
|
+
return view;
|
|
19126
|
+
return success(view.revision, view.workspaceRevision, compactTaskContext(view.data, inherited));
|
|
19127
|
+
}
|
|
19128
|
+
var environment = () => [], sameSession2 = (value, context) => typeof value === "object" && value !== null && value.kind === "host" && value.host === context.caller.host && value.handle === context.caller.actor;
|
|
19129
|
+
var init_task_view = __esm(() => {
|
|
19130
|
+
init_task_contract();
|
|
19131
|
+
init_paths();
|
|
19132
|
+
init_task_store();
|
|
19133
|
+
init_task_context();
|
|
19134
|
+
init_task_evaluation();
|
|
19135
|
+
});
|
|
19136
|
+
|
|
19137
|
+
// packages/workit-core/src/core/task-engine.ts
|
|
19138
|
+
import { realpathSync as realpathSync5 } from "node:fs";
|
|
19016
19139
|
|
|
19017
19140
|
class WorkitCore {
|
|
19018
19141
|
store;
|
|
@@ -19026,15 +19149,7 @@ class WorkitCore {
|
|
|
19026
19149
|
return this.context.workerId !== null && this.context.workerId !== undefined;
|
|
19027
19150
|
}
|
|
19028
19151
|
contextRootError() {
|
|
19029
|
-
|
|
19030
|
-
realpathSync4(this.context.root);
|
|
19031
|
-
const root = checkoutRootOf(this.context.root);
|
|
19032
|
-
if (root !== this.store.root && !sameDirectoryIdentity(root, this.store.root))
|
|
19033
|
-
return failure2("invalid_input", "operation context root does not match the task store root");
|
|
19034
|
-
} catch {
|
|
19035
|
-
return failure2("invalid_input", "operation context root cannot be resolved");
|
|
19036
|
-
}
|
|
19037
|
-
return success(null, null, null);
|
|
19152
|
+
return contextRootError(this.store, this.context);
|
|
19038
19153
|
}
|
|
19039
19154
|
fillRevisions(input, task, workspace) {
|
|
19040
19155
|
if (input.expectedRevision === undefined && task)
|
|
@@ -19082,27 +19197,10 @@ class WorkitCore {
|
|
|
19082
19197
|
return success(null, null, { ...request, taskId: found.data.task.id });
|
|
19083
19198
|
}
|
|
19084
19199
|
helperEntry(task, requireSession = false, requireActive = false) {
|
|
19085
|
-
|
|
19086
|
-
if (workerId === null)
|
|
19087
|
-
return failure2("permission_denied", "operation is lead-only");
|
|
19088
|
-
const worker = task.workers.find((entry) => entry.id === workerId);
|
|
19089
|
-
if (!worker)
|
|
19090
|
-
return failure2("permission_denied", "worker is not assigned to this task");
|
|
19091
|
-
if (worker.data.session && !sameSession2(worker.data.session, this.context))
|
|
19092
|
-
return failure2("permission_denied", "worker session does not match the caller");
|
|
19093
|
-
if (requireSession && (!worker.data.session || !sameSession2(worker.data.session, this.context)))
|
|
19094
|
-
return failure2("permission_denied", "worker session has not been observed");
|
|
19095
|
-
if (requireActive && worker.data.state !== "running")
|
|
19096
|
-
return failure2("permission_denied", "worker is not active");
|
|
19097
|
-
return success(null, null, worker);
|
|
19200
|
+
return helperEntry(task, this.context, requireSession, requireActive);
|
|
19098
19201
|
}
|
|
19099
19202
|
helperTaskGuard(task, allowRead = false) {
|
|
19100
|
-
|
|
19101
|
-
return success(null, null, null);
|
|
19102
|
-
const worker = this.helperEntry(task);
|
|
19103
|
-
if (!worker.ok)
|
|
19104
|
-
return worker;
|
|
19105
|
-
return allowRead ? success(null, null, null) : failure2("permission_denied", "helpers cannot control task lifecycle or scope");
|
|
19203
|
+
return helperTaskGuard(task, this.context, allowRead);
|
|
19106
19204
|
}
|
|
19107
19205
|
activeWorkerBlocker(task) {
|
|
19108
19206
|
if (task.workers.some((entry) => workerBlocksTransition("close", entry.data.state)))
|
|
@@ -20012,48 +20110,10 @@ class WorkitCore {
|
|
|
20012
20110
|
});
|
|
20013
20111
|
}
|
|
20014
20112
|
compactContext(taskId, freshness, origin = null) {
|
|
20015
|
-
|
|
20016
|
-
if (!root.ok)
|
|
20017
|
-
return root;
|
|
20018
|
-
const base = origin && this.store.readStoreTask(origin.taskId);
|
|
20019
|
-
const inherited = base?.ok && base.data ? {
|
|
20020
|
-
origin: origin.origin,
|
|
20021
|
-
taskId: base.data.id,
|
|
20022
|
-
decisions: base.data.decisions.filter((entry) => entry.data.revoked === null)
|
|
20023
|
-
} : null;
|
|
20024
|
-
if (taskId === null)
|
|
20025
|
-
return success(null, null, inherited?.decisions.length ? compactTaskContext(null, inherited) : "");
|
|
20026
|
-
const task = this.store.readTask(taskId);
|
|
20027
|
-
if (!task.ok)
|
|
20028
|
-
return task;
|
|
20029
|
-
const helper = this.helperTaskGuard(task.data, true);
|
|
20030
|
-
if (!helper.ok)
|
|
20031
|
-
return helper;
|
|
20032
|
-
const view = this.view(task.data, false, freshness ?? signalFreshness(this.store.root));
|
|
20033
|
-
if (!view.ok)
|
|
20034
|
-
return view;
|
|
20035
|
-
return success(view.revision, view.workspaceRevision, compactTaskContext(view.data, inherited));
|
|
20113
|
+
return compactContext(this.store, this.context, taskId, freshness, origin);
|
|
20036
20114
|
}
|
|
20037
|
-
view(task, capture = true, freshness
|
|
20038
|
-
|
|
20039
|
-
if (!workspace.ok)
|
|
20040
|
-
return workspace;
|
|
20041
|
-
if (!workspace.data)
|
|
20042
|
-
return failure2("not_found", "workspace not found");
|
|
20043
|
-
const historical = task.status === "closed" ? task.candidates.at(-1) : undefined;
|
|
20044
|
-
const current = historical ? success(null, null, historical) : capture ? captureCandidate(this.store.root, task.intent.data.scope, environment()) : success(null, null, task.candidates.at(-1) ?? null);
|
|
20045
|
-
if (!current.ok)
|
|
20046
|
-
return current;
|
|
20047
|
-
const evaluationWorkspace = workspace.data;
|
|
20048
|
-
const tree = freshness;
|
|
20049
|
-
const requirements = evaluateRequirements(task, evaluationWorkspace, this.context.capabilities, current.data, this.store.root, this.context.caller, tree);
|
|
20050
|
-
return success(task.revision, workspace.data.revision, {
|
|
20051
|
-
task,
|
|
20052
|
-
workspace: evaluationWorkspace,
|
|
20053
|
-
capabilities: this.context.capabilities,
|
|
20054
|
-
requirements,
|
|
20055
|
-
evidence: evaluateEvidence(task, current.data, tree)
|
|
20056
|
-
});
|
|
20115
|
+
view(task, capture = true, freshness) {
|
|
20116
|
+
return taskView(this.store, this.context, task, capture, freshness);
|
|
20057
20117
|
}
|
|
20058
20118
|
reconcileResume(view, observations = []) {
|
|
20059
20119
|
const root = this.contextRootError();
|
|
@@ -20064,7 +20124,7 @@ class WorkitCore {
|
|
|
20064
20124
|
if (view.task.workspaceId !== view.workspace.id)
|
|
20065
20125
|
return failure2("invalid_input", "task and workspace bindings are invalid");
|
|
20066
20126
|
try {
|
|
20067
|
-
if (
|
|
20127
|
+
if (realpathSync5(view.workspace.root) !== this.store.root)
|
|
20068
20128
|
return failure2("invalid_input", "task view root does not match the task store");
|
|
20069
20129
|
} catch {
|
|
20070
20130
|
return failure2("invalid_input", "task view root cannot be resolved");
|
|
@@ -20324,7 +20384,7 @@ var MAX_JUDGED_REFS = 5, workspaceVerification = (root) => {
|
|
|
20324
20384
|
host: context.caller.host,
|
|
20325
20385
|
session: { kind: "host", host: context.caller.host, handle: context.caller.actor },
|
|
20326
20386
|
workerId: context.workerId ?? null
|
|
20327
|
-
}),
|
|
20387
|
+
}), verifiedWorkers, sameValue = (left, right) => {
|
|
20328
20388
|
try {
|
|
20329
20389
|
return canonicalJson(left) === canonicalJson(right);
|
|
20330
20390
|
} catch {
|
|
@@ -20643,8 +20703,7 @@ var init_task_engine = __esm(() => {
|
|
|
20643
20703
|
init_ledger();
|
|
20644
20704
|
init_rev();
|
|
20645
20705
|
init_autonomy();
|
|
20646
|
-
|
|
20647
|
-
init_paths();
|
|
20706
|
+
init_task_view();
|
|
20648
20707
|
init_store_lock();
|
|
20649
20708
|
init_task_context();
|
|
20650
20709
|
init_workers();
|
|
@@ -21286,18 +21345,18 @@ var init_context_read = __esm(() => {
|
|
|
21286
21345
|
});
|
|
21287
21346
|
|
|
21288
21347
|
// packages/workit-core/src/core.ts
|
|
21289
|
-
import { existsSync as
|
|
21348
|
+
import { existsSync as existsSync9, realpathSync as realpathSync6 } from "node:fs";
|
|
21290
21349
|
import path26 from "node:path";
|
|
21291
21350
|
function resolveInside(root, candidate) {
|
|
21292
|
-
const base =
|
|
21351
|
+
const base = realpathSync6(root);
|
|
21293
21352
|
const target = path26.resolve(base, candidate);
|
|
21294
21353
|
if (target !== base && !target.startsWith(base + path26.sep)) {
|
|
21295
21354
|
throw new Error("path must stay inside repository root");
|
|
21296
21355
|
}
|
|
21297
21356
|
let ancestor = target;
|
|
21298
|
-
while (!
|
|
21357
|
+
while (!existsSync9(ancestor))
|
|
21299
21358
|
ancestor = path26.dirname(ancestor);
|
|
21300
|
-
const canonicalAncestor =
|
|
21359
|
+
const canonicalAncestor = realpathSync6(ancestor);
|
|
21301
21360
|
if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path26.sep)) {
|
|
21302
21361
|
throw new Error("path must stay inside repository root");
|
|
21303
21362
|
}
|
|
@@ -65531,10 +65590,10 @@ var init_changelog = __esm(() => {
|
|
|
65531
65590
|
|
|
65532
65591
|
// packages/workit-core/src/core/hygiene.ts
|
|
65533
65592
|
import { spawnSync as spawnSync12 } from "node:child_process";
|
|
65534
|
-
import { existsSync as
|
|
65593
|
+
import { existsSync as existsSync11, readFileSync as readFileSync11, readdirSync as readdirSync5, writeFileSync as writeFileSync5 } from "node:fs";
|
|
65535
65594
|
import path29 from "node:path";
|
|
65536
65595
|
var repoRoot2, templatesDir = () => path29.join(repoRoot2, "templates", "hygiene"), packageJson = (root) => {
|
|
65537
|
-
if (!
|
|
65596
|
+
if (!existsSync11(path29.join(root, "package.json")))
|
|
65538
65597
|
return null;
|
|
65539
65598
|
try {
|
|
65540
65599
|
return JSON.parse(readFileSync11(path29.join(root, "package.json"), "utf8"));
|
|
@@ -65542,7 +65601,7 @@ var repoRoot2, templatesDir = () => path29.join(repoRoot2, "templates", "hygiene
|
|
|
65542
65601
|
return null;
|
|
65543
65602
|
}
|
|
65544
65603
|
}, isOpenSource = (root) => {
|
|
65545
|
-
if (
|
|
65604
|
+
if (existsSync11(path29.join(root, "LICENSE")))
|
|
65546
65605
|
return true;
|
|
65547
65606
|
const pkg = packageJson(root);
|
|
65548
65607
|
if (pkg && !pkg.private)
|
|
@@ -65569,7 +65628,7 @@ var repoRoot2, templatesDir = () => path29.join(repoRoot2, "templates", "hygiene
|
|
|
65569
65628
|
return { ok: true, root: path29.resolve(root) };
|
|
65570
65629
|
let children = [];
|
|
65571
65630
|
try {
|
|
65572
|
-
children = readdirSync5(start, { withFileTypes: true }).filter((entry) => entry.isDirectory() &&
|
|
65631
|
+
children = readdirSync5(start, { withFileTypes: true }).filter((entry) => entry.isDirectory() && existsSync11(path29.join(start, entry.name, ".git"))).map((entry) => path29.join(start, entry.name)).toSorted();
|
|
65573
65632
|
} catch {
|
|
65574
65633
|
children = [];
|
|
65575
65634
|
}
|
|
@@ -65585,10 +65644,10 @@ var repoRoot2, templatesDir = () => path29.join(repoRoot2, "templates", "hygiene
|
|
|
65585
65644
|
files.push("LICENSE", "CONTRIBUTING.md");
|
|
65586
65645
|
const planned = [];
|
|
65587
65646
|
for (const file of files) {
|
|
65588
|
-
if (
|
|
65647
|
+
if (existsSync11(path29.join(root, file)))
|
|
65589
65648
|
continue;
|
|
65590
65649
|
const tpl = path29.join(templatesDir(), file);
|
|
65591
|
-
if (!
|
|
65650
|
+
if (!existsSync11(tpl))
|
|
65592
65651
|
continue;
|
|
65593
65652
|
const content = readFileSync11(tpl, "utf8").replace(/<PROJECT>/g, path29.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
|
|
65594
65653
|
planned.push({ path: path29.join(root, file), content });
|
|
@@ -65602,7 +65661,7 @@ var init_hygiene = __esm(() => {
|
|
|
65602
65661
|
});
|
|
65603
65662
|
|
|
65604
65663
|
// packages/workit-cli/src/admin/setup-state.ts
|
|
65605
|
-
import { existsSync as
|
|
65664
|
+
import { existsSync as existsSync12, readFileSync as readFileSync12 } from "node:fs";
|
|
65606
65665
|
import path30 from "node:path";
|
|
65607
65666
|
var classifySetupFile = (dir, name) => {
|
|
65608
65667
|
const file = path30.join(dir, name);
|
|
@@ -65610,7 +65669,7 @@ var classifySetupFile = (dir, name) => {
|
|
|
65610
65669
|
try {
|
|
65611
65670
|
raw = readFileSync12(file, "utf8");
|
|
65612
65671
|
} catch {
|
|
65613
|
-
if (
|
|
65672
|
+
if (existsSync12(file)) {
|
|
65614
65673
|
return { file, status: "malformed", error: `${file} is not readable` };
|
|
65615
65674
|
}
|
|
65616
65675
|
return { file, status: "missing" };
|
|
@@ -66048,10 +66107,10 @@ import { spawnSync as spawnSync14 } from "node:child_process";
|
|
|
66048
66107
|
import {
|
|
66049
66108
|
accessSync,
|
|
66050
66109
|
constants as constants2,
|
|
66051
|
-
existsSync as
|
|
66110
|
+
existsSync as existsSync13,
|
|
66052
66111
|
readFileSync as readFileSync13,
|
|
66053
66112
|
readdirSync as readdirSync6,
|
|
66054
|
-
realpathSync as
|
|
66113
|
+
realpathSync as realpathSync7,
|
|
66055
66114
|
statSync as statSync2
|
|
66056
66115
|
} from "node:fs";
|
|
66057
66116
|
import os9 from "node:os";
|
|
@@ -66071,7 +66130,7 @@ function hostCommand(name, args, options = {}) {
|
|
|
66071
66130
|
}
|
|
66072
66131
|
return { command: executable, args, cwd: options.cwd, purpose: `${name} CLI` };
|
|
66073
66132
|
}
|
|
66074
|
-
function resolveWindowsShimEntry(contents, shim, exists =
|
|
66133
|
+
function resolveWindowsShimEntry(contents, shim, exists = existsSync13) {
|
|
66075
66134
|
const root = path33.win32.dirname(shim);
|
|
66076
66135
|
const matches = contents.matchAll(/(["']?)([^\r\n"']*node_modules[\\/][^\r\n"']+?\.js)\1/gi);
|
|
66077
66136
|
for (const match of matches) {
|
|
@@ -66114,7 +66173,7 @@ function findHostExecutable(name, options = {}) {
|
|
|
66114
66173
|
}
|
|
66115
66174
|
return null;
|
|
66116
66175
|
}
|
|
66117
|
-
function installedHostApp(host, home, env = process.env, platform = process.platform, exists =
|
|
66176
|
+
function installedHostApp(host, home, env = process.env, platform = process.platform, exists = existsSync13) {
|
|
66118
66177
|
const candidates = [];
|
|
66119
66178
|
const pathApi = platform === "win32" ? path33.win32 : path33;
|
|
66120
66179
|
if (platform === "darwin") {
|
|
@@ -66271,7 +66330,7 @@ ${result.stdout}
|
|
|
66271
66330
|
${result.stderr}`;
|
|
66272
66331
|
if (command.packageRoot && command.packageTarget) {
|
|
66273
66332
|
try {
|
|
66274
|
-
if (!
|
|
66333
|
+
if (!existsSync13(command.packageRoot)) {
|
|
66275
66334
|
return {
|
|
66276
66335
|
ok: false,
|
|
66277
66336
|
results: [
|
|
@@ -66491,7 +66550,7 @@ var resolveWindowsShimScript = (shim) => {
|
|
|
66491
66550
|
return found;
|
|
66492
66551
|
}, isClaudeWorkitInstalled = (home, env = process.env, cwd = process.cwd()) => claudeWorkitInstalls(home, env, cwd).length > 0, findNpmCli = (npm) => {
|
|
66493
66552
|
try {
|
|
66494
|
-
const resolved =
|
|
66553
|
+
const resolved = realpathSync7(npm);
|
|
66495
66554
|
if (path33.basename(resolved) === "npm-cli.js")
|
|
66496
66555
|
return resolved;
|
|
66497
66556
|
} catch {}
|
|
@@ -66501,7 +66560,7 @@ var resolveWindowsShimScript = (shim) => {
|
|
|
66501
66560
|
path33.join(dir, "..", "node_modules", "npm", "bin", "npm-cli.js"),
|
|
66502
66561
|
path33.join(dir, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js")
|
|
66503
66562
|
];
|
|
66504
|
-
return candidates.find((candidate) =>
|
|
66563
|
+
return candidates.find((candidate) => existsSync13(candidate)) ?? null;
|
|
66505
66564
|
};
|
|
66506
66565
|
var init_host_install = __esm(() => {
|
|
66507
66566
|
CLAUDE_PLUGIN_ID = `workit@${CLAUDE_MARKETPLACE_NAME}`;
|
|
@@ -66509,9 +66568,9 @@ var init_host_install = __esm(() => {
|
|
|
66509
66568
|
});
|
|
66510
66569
|
|
|
66511
66570
|
// packages/workit-core/src/core/skill-manifests.ts
|
|
66512
|
-
import { cpSync as cpSync3, existsSync as
|
|
66571
|
+
import { cpSync as cpSync3, existsSync as existsSync14, readFileSync as readFileSync14, readdirSync as readdirSync7, statSync as statSync3, writeFileSync as writeFileSync6 } from "node:fs";
|
|
66513
66572
|
import path34 from "node:path";
|
|
66514
|
-
var WORKIT_METHOD_SKILLS, skillManifestNames = (root) =>
|
|
66573
|
+
var WORKIT_METHOD_SKILLS, skillManifestNames = (root) => existsSync14(root) ? readdirSync7(root).filter((name) => existsSync14(path34.join(root, name, "SKILL.md"))).toSorted() : [], validateSkillManifests = (root, expected, label) => {
|
|
66515
66574
|
const actual = skillManifestNames(root);
|
|
66516
66575
|
const missing = expected.filter((name) => !actual.includes(name));
|
|
66517
66576
|
const extra = actual.filter((name) => !expected.includes(name));
|
|
@@ -66557,7 +66616,7 @@ var init_skill_manifests = __esm(() => {
|
|
|
66557
66616
|
import { spawnSync as spawnSync15 } from "node:child_process";
|
|
66558
66617
|
import {
|
|
66559
66618
|
chmodSync,
|
|
66560
|
-
existsSync as
|
|
66619
|
+
existsSync as existsSync15,
|
|
66561
66620
|
lstatSync as lstatSync4,
|
|
66562
66621
|
mkdirSync as mkdirSync5,
|
|
66563
66622
|
readFileSync as readFileSync15,
|
|
@@ -66569,7 +66628,7 @@ import {
|
|
|
66569
66628
|
import path35 from "node:path";
|
|
66570
66629
|
function inspectSessionHook(cwd, env = process.env) {
|
|
66571
66630
|
const none = { hooksDir: null, hookPath: null, helperPath: null, helperCurrent: false };
|
|
66572
|
-
if (!
|
|
66631
|
+
if (!existsSync15(cwd))
|
|
66573
66632
|
return { state: "not_git", ...none };
|
|
66574
66633
|
const top = run2(cwd, ["rev-parse", "--show-toplevel"], env);
|
|
66575
66634
|
if (!top.ok || !top.out)
|
|
@@ -66774,7 +66833,7 @@ exit 0
|
|
|
66774
66833
|
} catch {
|
|
66775
66834
|
return false;
|
|
66776
66835
|
}
|
|
66777
|
-
}, LEFTHOOK_CONFIGS, lefthookConfig = (top) => LEFTHOOK_CONFIGS.map((name) => path35.join(top, name)).find((file) =>
|
|
66836
|
+
}, LEFTHOOK_CONFIGS, lefthookConfig = (top) => LEFTHOOK_CONFIGS.map((name) => path35.join(top, name)).find((file) => existsSync15(file)) ?? null, isComment = (line) => /^\s*#/.test(line), COMMAND_SH, DIRECT_CALL, VAR_CALL, runsHelperText = (text) => {
|
|
66778
66837
|
const lines = text.split(/\r?\n/).filter((line) => !isComment(line));
|
|
66779
66838
|
const assigned = lines.some((line) => /(?:^|[\s;])h=/.test(line) && line.includes(HELPER_REF));
|
|
66780
66839
|
return lines.some((line) => DIRECT_CALL.test(line) || assigned && VAR_CALL.test(line));
|
|
@@ -66826,7 +66885,7 @@ exit 0
|
|
|
66826
66885
|
if (text === null || !runsHelperText(text))
|
|
66827
66886
|
return false;
|
|
66828
66887
|
return input.owner === "husky" && target !== input.hookPath || isExecutable(target);
|
|
66829
|
-
}, isHuskyV9 = (text, hooksDir) => /\$\(dirname (?:-- )?"\$0"\)\/h"/.test(text) &&
|
|
66888
|
+
}, isHuskyV9 = (text, hooksDir) => /\$\(dirname (?:-- )?"\$0"\)\/h"/.test(text) && existsSync15(path35.join(hooksDir, "h")), ownerOf = (text, hooksDir, top) => {
|
|
66830
66889
|
if (text.includes("husky.sh") || isHuskyV9(text, hooksDir))
|
|
66831
66890
|
return "husky";
|
|
66832
66891
|
if (/lefthook/i.test(text) || lefthookConfig(top))
|
|
@@ -66985,11 +67044,11 @@ var init_delivery_verbs = __esm(() => {
|
|
|
66985
67044
|
// packages/workit-cli/src/admin/host-permissions.ts
|
|
66986
67045
|
import {
|
|
66987
67046
|
copyFileSync as copyFileSync4,
|
|
66988
|
-
existsSync as
|
|
67047
|
+
existsSync as existsSync16,
|
|
66989
67048
|
readdirSync as readdirSync9,
|
|
66990
67049
|
mkdirSync as mkdirSync7,
|
|
66991
67050
|
readFileSync as readFileSync17,
|
|
66992
|
-
realpathSync as
|
|
67051
|
+
realpathSync as realpathSync8,
|
|
66993
67052
|
rmSync as rmSync3,
|
|
66994
67053
|
statSync as statSync5
|
|
66995
67054
|
} from "node:fs";
|
|
@@ -67089,7 +67148,7 @@ function planHostPermissions(options) {
|
|
|
67089
67148
|
if (!PERMISSION_HOSTS.has(host))
|
|
67090
67149
|
continue;
|
|
67091
67150
|
const target = permissionTarget(host, paths);
|
|
67092
|
-
if (!
|
|
67151
|
+
if (!existsSync16(target.hostDir)) {
|
|
67093
67152
|
plan.notes.push(`${host}: not installed (${target.hostDir} is missing); nothing written`);
|
|
67094
67153
|
continue;
|
|
67095
67154
|
}
|
|
@@ -67212,7 +67271,7 @@ function applyHostPermissions(plan, options = {}) {
|
|
|
67212
67271
|
continue;
|
|
67213
67272
|
}
|
|
67214
67273
|
try {
|
|
67215
|
-
const target = change.before === null ? change.file :
|
|
67274
|
+
const target = change.before === null ? change.file : realpathSync8(change.file);
|
|
67216
67275
|
if (change.before !== null) {
|
|
67217
67276
|
const backups = path38.join(paths.stateDir, "host-permissions-backup");
|
|
67218
67277
|
mkdirSync7(backups, { recursive: true, mode: 448 });
|
|
@@ -67242,7 +67301,7 @@ function applyHostPermissions(plan, options = {}) {
|
|
|
67242
67301
|
}
|
|
67243
67302
|
function permissionHealth(host, options = {}) {
|
|
67244
67303
|
const target = permissionTarget(host, options);
|
|
67245
|
-
if (!
|
|
67304
|
+
if (!existsSync16(target.hostDir))
|
|
67246
67305
|
return { state: "no-host" };
|
|
67247
67306
|
const text = readText4(target.file);
|
|
67248
67307
|
if (host === "codex") {
|
|
@@ -67276,7 +67335,7 @@ function permissionHealth(host, options = {}) {
|
|
|
67276
67335
|
}
|
|
67277
67336
|
function permissionCoverage(host, commands, options = {}) {
|
|
67278
67337
|
const target = permissionTarget(host, options);
|
|
67279
|
-
if (!
|
|
67338
|
+
if (!existsSync16(target.hostDir))
|
|
67280
67339
|
return { state: "no-host" };
|
|
67281
67340
|
const cwd = options.cwd ?? process.cwd();
|
|
67282
67341
|
let missing;
|
|
@@ -67461,7 +67520,7 @@ ${[...rules, ...lease, grant].join(`
|
|
|
67461
67520
|
return null;
|
|
67462
67521
|
}, setupCommand = (hosts) => `workit setup --hosts=${hosts.join(",")}`, removeCodexRules = (file, options = {}) => {
|
|
67463
67522
|
const expected = permissionTarget("codex", options).file;
|
|
67464
|
-
if (path38.resolve(file) !== path38.resolve(expected) || !
|
|
67523
|
+
if (path38.resolve(file) !== path38.resolve(expected) || !existsSync16(expected))
|
|
67465
67524
|
return false;
|
|
67466
67525
|
rmSync3(expected);
|
|
67467
67526
|
return true;
|
|
@@ -67602,7 +67661,7 @@ var init_host_permissions = __esm(() => {
|
|
|
67602
67661
|
import { spawnSync as spawnSync16 } from "node:child_process";
|
|
67603
67662
|
import { createHash as createHash14 } from "node:crypto";
|
|
67604
67663
|
import {
|
|
67605
|
-
existsSync as
|
|
67664
|
+
existsSync as existsSync17,
|
|
67606
67665
|
lstatSync as lstatSync5,
|
|
67607
67666
|
mkdirSync as mkdirSync8,
|
|
67608
67667
|
mkdtempSync,
|
|
@@ -67620,7 +67679,7 @@ import path39 from "node:path";
|
|
|
67620
67679
|
var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
67621
67680
|
let dir = path39.resolve(cwd);
|
|
67622
67681
|
while (true) {
|
|
67623
|
-
if (
|
|
67682
|
+
if (existsSync17(path39.join(dir, "packages", "workit-core", "package.json")))
|
|
67624
67683
|
return dir;
|
|
67625
67684
|
const parent = path39.dirname(dir);
|
|
67626
67685
|
if (parent === dir)
|
|
@@ -67725,14 +67784,14 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
67725
67784
|
}
|
|
67726
67785
|
return true;
|
|
67727
67786
|
}, resolveBun = (env) => {
|
|
67728
|
-
if (env.BUN &&
|
|
67787
|
+
if (env.BUN && existsSync17(env.BUN))
|
|
67729
67788
|
return env.BUN;
|
|
67730
67789
|
for (const candidate of [
|
|
67731
67790
|
path39.join(env.HOME || os12.homedir(), ".bun/bin/bun"),
|
|
67732
67791
|
"/usr/local/bin/bun",
|
|
67733
67792
|
"/usr/bin/bun"
|
|
67734
67793
|
]) {
|
|
67735
|
-
if (
|
|
67794
|
+
if (existsSync17(candidate))
|
|
67736
67795
|
return candidate;
|
|
67737
67796
|
}
|
|
67738
67797
|
return commandOnPath("bun", env) ? "bun" : null;
|
|
@@ -67957,7 +68016,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
67957
68016
|
const dir = path39.join(codexHome, "plugins", "cache", marketplace, "workit");
|
|
67958
68017
|
let versions = [];
|
|
67959
68018
|
try {
|
|
67960
|
-
versions = readdirSync10(dir).filter((v) =>
|
|
68019
|
+
versions = readdirSync10(dir).filter((v) => existsSync17(path39.join(dir, v, ".codex-plugin")));
|
|
67961
68020
|
} catch {
|
|
67962
68021
|
versions = [];
|
|
67963
68022
|
}
|
|
@@ -68066,7 +68125,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68066
68125
|
const installed = [];
|
|
68067
68126
|
for (const install of installs) {
|
|
68068
68127
|
const source = install.root ? path39.join(install.root, "agents") : null;
|
|
68069
|
-
const files = source &&
|
|
68128
|
+
const files = source && existsSync17(source) ? readdirSync10(source).filter((f) => f.endsWith(".toml")).toSorted() : [];
|
|
68070
68129
|
if (files.length === 0) {
|
|
68071
68130
|
problems.push(`${install.id} ${install.version ?? "?"} bundles no agents`);
|
|
68072
68131
|
fixes.push(`codex plugin remove ${install.id} && codex plugin add ${install.id}`);
|
|
@@ -68202,7 +68261,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68202
68261
|
return kept;
|
|
68203
68262
|
}, checkPiExtension = (res) => {
|
|
68204
68263
|
const agentDir = piAgentDirOf(res);
|
|
68205
|
-
if (!
|
|
68264
|
+
if (!existsSync17(agentDir) && !commandOnPath("pi", res.env))
|
|
68206
68265
|
return {
|
|
68207
68266
|
id: "pi_extension",
|
|
68208
68267
|
status: "pass",
|
|
@@ -68228,7 +68287,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68228
68287
|
fix: entry.npm ? installCmd(entry.scope, entry.source) : `restore ${entry.root}, then ${rebuild}`
|
|
68229
68288
|
};
|
|
68230
68289
|
const declared = Array.isArray(pkg.pi?.extensions) ? pkg.pi.extensions.some((e) => typeof e === "string" && e.replace(/^\.\//, "") === PI_EXTENSION) : false;
|
|
68231
|
-
if (!declared || !
|
|
68290
|
+
if (!declared || !existsSync17(path39.join(entry.root, PI_EXTENSION)))
|
|
68232
68291
|
return {
|
|
68233
68292
|
id: "pi_extension",
|
|
68234
68293
|
status: "warn",
|
|
@@ -68285,7 +68344,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68285
68344
|
switch (host) {
|
|
68286
68345
|
case "opencode": {
|
|
68287
68346
|
const packaged = path39.join(pkg, "assets", "skills");
|
|
68288
|
-
const root =
|
|
68347
|
+
const root = existsSync17(packaged) ? packaged : path39.join(dev, "packages", "workit-core", "skills");
|
|
68289
68348
|
return WORKIT_METHOD_SKILLS.map((skill) => path39.join(root, skill, "SKILL.md"));
|
|
68290
68349
|
}
|
|
68291
68350
|
case "cursor":
|
|
@@ -68299,7 +68358,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68299
68358
|
}
|
|
68300
68359
|
}, hostsFor = (host) => host === "cli" ? ["opencode", "cursor", "cli"] : [host], checkAssets = (res) => {
|
|
68301
68360
|
const dev = res.dev;
|
|
68302
|
-
const missing = dev ? hostsFor(res.host).flatMap((h) => assetPathsFor(h, dev).filter((p) => !
|
|
68361
|
+
const missing = dev ? hostsFor(res.host).flatMap((h) => assetPathsFor(h, dev).filter((p) => !existsSync17(p)).map((p) => `${h}: ${p}`)) : [];
|
|
68303
68362
|
if (res.host === "cursor" || res.host === "cli") {
|
|
68304
68363
|
const cursorError = validateCursorSkills(res.cursorPluginDir, WORKIT_METHOD_SKILLS);
|
|
68305
68364
|
if (cursorError)
|
|
@@ -68350,7 +68409,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68350
68409
|
return false;
|
|
68351
68410
|
}
|
|
68352
68411
|
}, registeredCursorLauncher = (res) => {
|
|
68353
|
-
if (!
|
|
68412
|
+
if (!existsSync17(res.cursorMcp))
|
|
68354
68413
|
return "invalid";
|
|
68355
68414
|
const config = readJson(res.cursorMcp);
|
|
68356
68415
|
if (!config)
|
|
@@ -68379,7 +68438,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68379
68438
|
};
|
|
68380
68439
|
}, canonicalCursorHook, isCanonicalCursorHook = (command, res) => command === canonicalCursorHook || command === cursorHooksEntry(res.cursorPluginDir).command, registeredCursorHook = (res) => {
|
|
68381
68440
|
const hooksFile = path39.join(res.cursorPluginDir, "hooks", "hooks-cursor.json");
|
|
68382
|
-
if (!
|
|
68441
|
+
if (!existsSync17(hooksFile))
|
|
68383
68442
|
return "invalid";
|
|
68384
68443
|
const config = readJson(hooksFile);
|
|
68385
68444
|
if (!config)
|
|
@@ -68422,7 +68481,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68422
68481
|
}
|
|
68423
68482
|
}
|
|
68424
68483
|
if (dev) {
|
|
68425
|
-
missing.push(...hosts.filter((h) => h !== "cursor").flatMap((h) => launcherSlotsFor(h, dev).filter((slot) => !slot.some((p) =>
|
|
68484
|
+
missing.push(...hosts.filter((h) => h !== "cursor").flatMap((h) => launcherSlotsFor(h, dev).filter((slot) => !slot.some((p) => existsSync17(p))).map((slot) => `${h}: ${slot.join(" or ")}`)));
|
|
68426
68485
|
}
|
|
68427
68486
|
if (missing.length > 0) {
|
|
68428
68487
|
return {
|
|
@@ -68448,7 +68507,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68448
68507
|
const problems = [];
|
|
68449
68508
|
const fixes = [];
|
|
68450
68509
|
if (hostsFor(res.host).includes("cursor")) {
|
|
68451
|
-
const settings =
|
|
68510
|
+
const settings = existsSync17(res.cursorSettings) ? readJson(res.cursorSettings) : null;
|
|
68452
68511
|
const dirs = Array.isArray(settings?.plugin_dirs) ? settings.plugin_dirs : [];
|
|
68453
68512
|
for (const entry of dirs.map(String)) {
|
|
68454
68513
|
const normal = entry.replaceAll("\\", "/").replace(/\/+$/, "");
|
|
@@ -68492,14 +68551,14 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68492
68551
|
status: "pass",
|
|
68493
68552
|
detail: "cursor hook not inspected on this host"
|
|
68494
68553
|
};
|
|
68495
|
-
if (!
|
|
68554
|
+
if (!existsSync17(res.cursorPluginDir))
|
|
68496
68555
|
return {
|
|
68497
68556
|
id: "cursor_hook",
|
|
68498
68557
|
status: "pass",
|
|
68499
68558
|
detail: "no Cursor plugin install — hook launcher not inspected"
|
|
68500
68559
|
};
|
|
68501
68560
|
const launcher = path39.join(res.cursorPluginDir, "hooks", "launch.mjs");
|
|
68502
|
-
if (!
|
|
68561
|
+
if (!existsSync17(launcher))
|
|
68503
68562
|
return {
|
|
68504
68563
|
id: "cursor_hook",
|
|
68505
68564
|
status: "warn",
|
|
@@ -68621,7 +68680,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68621
68680
|
return "fragile-cache";
|
|
68622
68681
|
if (entry.startsWith("file:")) {
|
|
68623
68682
|
const target = entry.replace(/^file:\/\//, "").replace(/^file:/, "");
|
|
68624
|
-
return
|
|
68683
|
+
return existsSync17(target) ? "ok" : "missing-file";
|
|
68625
68684
|
}
|
|
68626
68685
|
return "ok";
|
|
68627
68686
|
}, checkStalePin = (res) => {
|
|
@@ -68632,7 +68691,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68632
68691
|
detail: "opencode pin not inspected on the cursor host"
|
|
68633
68692
|
};
|
|
68634
68693
|
}
|
|
68635
|
-
if (!
|
|
68694
|
+
if (!existsSync17(res.opencodeConfig)) {
|
|
68636
68695
|
return {
|
|
68637
68696
|
id: "stale_pin",
|
|
68638
68697
|
status: "pass",
|
|
@@ -68685,7 +68744,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68685
68744
|
return { id: "stale_pin", status: "pass", detail: "opencode pin resolves" };
|
|
68686
68745
|
}, pluginMcpSelectors = (res) => {
|
|
68687
68746
|
const p = path39.join(res.cursorPluginDir, "mcp.json");
|
|
68688
|
-
if (!
|
|
68747
|
+
if (!existsSync17(p))
|
|
68689
68748
|
return null;
|
|
68690
68749
|
const cfg = readJson(p);
|
|
68691
68750
|
const server = cfg?.mcpServers?.workit;
|
|
@@ -68733,7 +68792,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68733
68792
|
dir = path39.dirname(dir);
|
|
68734
68793
|
return { version: found.version, dir };
|
|
68735
68794
|
}, checkOpenCodePackageCache = (res) => {
|
|
68736
|
-
if (!
|
|
68795
|
+
if (!existsSync17(res.opencodeConfig)) {
|
|
68737
68796
|
return {
|
|
68738
68797
|
id: "stale_install",
|
|
68739
68798
|
status: "pass",
|
|
@@ -68808,7 +68867,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68808
68867
|
detail: "cursor plugin not inspected on this host"
|
|
68809
68868
|
};
|
|
68810
68869
|
}
|
|
68811
|
-
if (
|
|
68870
|
+
if (existsSync17(res.cursorPluginDir) && lstatSync5(res.cursorPluginDir).isSymbolicLink()) {
|
|
68812
68871
|
let target = "";
|
|
68813
68872
|
try {
|
|
68814
68873
|
target = readlinkSync2(res.cursorPluginDir);
|
|
@@ -68846,7 +68905,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68846
68905
|
fix: "Re-run install-cursor-plugin.sh — it rewrites the sessionStart hook to the canonical pinned launcher"
|
|
68847
68906
|
};
|
|
68848
68907
|
}
|
|
68849
|
-
const hookDrift =
|
|
68908
|
+
const hookDrift = existsSync17(hooksFile) ? cursorHookDrift(readJson(hooksFile), res.cursorPluginDir) : [];
|
|
68850
68909
|
if (hookDrift.length > 0) {
|
|
68851
68910
|
return {
|
|
68852
68911
|
id: "stale_install",
|
|
@@ -68930,13 +68989,13 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68930
68989
|
const problems = [];
|
|
68931
68990
|
const opencodeHost = res.host !== "cursor";
|
|
68932
68991
|
const cursorHost = res.host !== "opencode";
|
|
68933
|
-
if (opencodeHost &&
|
|
68992
|
+
if (opencodeHost && existsSync17(res.opencodeConfig)) {
|
|
68934
68993
|
const cfg = readJson(res.opencodeConfig);
|
|
68935
68994
|
const entries = pluginEntries(cfg);
|
|
68936
68995
|
if (entries.length > 1)
|
|
68937
68996
|
problems.push(`opencode registers ${entries.length} workit plugin entries`);
|
|
68938
68997
|
}
|
|
68939
|
-
if (cursorHost &&
|
|
68998
|
+
if (cursorHost && existsSync17(res.cursorSettings)) {
|
|
68940
68999
|
const settings = readJson(res.cursorSettings);
|
|
68941
69000
|
const enabled = settings?.enabled_plugins;
|
|
68942
69001
|
if (enabled && typeof enabled === "object") {
|
|
@@ -68951,7 +69010,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68951
69010
|
if (dirs.length > 1)
|
|
68952
69011
|
problems.push(`cursor plugin_dirs has ${dirs.length} workit entries`);
|
|
68953
69012
|
}
|
|
68954
|
-
if (cursorHost &&
|
|
69013
|
+
if (cursorHost && existsSync17(res.cursorMcp)) {
|
|
68955
69014
|
const mcp = readJson(res.cursorMcp);
|
|
68956
69015
|
const servers = mcp?.mcpServers ?? {};
|
|
68957
69016
|
if (servers && typeof servers === "object") {
|
|
@@ -68977,16 +69036,16 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
68977
69036
|
const files = [];
|
|
68978
69037
|
for (const name of ["config.json", "youtrack.json", "vcs.json", "workspaces.json"]) {
|
|
68979
69038
|
const p = path39.join(res.configDir, name);
|
|
68980
|
-
if (
|
|
69039
|
+
if (existsSync17(p))
|
|
68981
69040
|
files.push(p);
|
|
68982
69041
|
}
|
|
68983
69042
|
const opencodeHost = res.host !== "cursor";
|
|
68984
69043
|
const cursorHost = res.host !== "opencode";
|
|
68985
|
-
if (opencodeHost &&
|
|
69044
|
+
if (opencodeHost && existsSync17(res.opencodeConfig))
|
|
68986
69045
|
files.push(res.opencodeConfig);
|
|
68987
|
-
if (cursorHost &&
|
|
69046
|
+
if (cursorHost && existsSync17(res.cursorSettings))
|
|
68988
69047
|
files.push(res.cursorSettings);
|
|
68989
|
-
if (cursorHost &&
|
|
69048
|
+
if (cursorHost && existsSync17(res.cursorMcp))
|
|
68990
69049
|
files.push(res.cursorMcp);
|
|
68991
69050
|
const bad = files.filter((p) => !parsesAsConfigObject(p));
|
|
68992
69051
|
if (bad.length === 0)
|
|
@@ -69206,7 +69265,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
69206
69265
|
const youtrackJson = readJson(path39.join(res.configDir, "youtrack.json"));
|
|
69207
69266
|
if (youtrackJson) {
|
|
69208
69267
|
tokenPaths.push(typeof youtrackJson.tokenFile === "string" ? youtrackJson.tokenFile : path39.join(res.configDir, "youtrack.token"));
|
|
69209
|
-
} else if (
|
|
69268
|
+
} else if (existsSync17(path39.join(res.configDir, "youtrack.token"))) {
|
|
69210
69269
|
tokenPaths.push(path39.join(res.configDir, "youtrack.token"));
|
|
69211
69270
|
}
|
|
69212
69271
|
if (tokenPaths.length === 0) {
|
|
@@ -69219,7 +69278,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
69219
69278
|
const problems = [];
|
|
69220
69279
|
for (const raw of tokenPaths) {
|
|
69221
69280
|
const p = path39.isAbsolute(raw) ? raw : path39.resolve(res.configDir, raw);
|
|
69222
|
-
if (!
|
|
69281
|
+
if (!existsSync17(p)) {
|
|
69223
69282
|
problems.push(`${p} is missing`);
|
|
69224
69283
|
continue;
|
|
69225
69284
|
}
|
|
@@ -69546,8 +69605,8 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
69546
69605
|
};
|
|
69547
69606
|
}, checkChecksConfig = (res) => {
|
|
69548
69607
|
const root = checkRoot(res.cwd);
|
|
69549
|
-
const current =
|
|
69550
|
-
const legacy =
|
|
69608
|
+
const current = existsSync17(path39.join(root, CHECKS_FILE));
|
|
69609
|
+
const legacy = existsSync17(path39.join(root, LEGACY_CHECKS_FILE));
|
|
69551
69610
|
if (!legacy)
|
|
69552
69611
|
return {
|
|
69553
69612
|
id: "checks_config",
|
|
@@ -69564,9 +69623,9 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
69564
69623
|
const root = checkRoot(resolve(options).cwd);
|
|
69565
69624
|
const from = path39.join(root, LEGACY_CHECKS_FILE);
|
|
69566
69625
|
const to = path39.join(root, CHECKS_FILE);
|
|
69567
|
-
if (!
|
|
69626
|
+
if (!existsSync17(from))
|
|
69568
69627
|
return { action: "none", detail: `no ${LEGACY_CHECKS_FILE} at ${root}` };
|
|
69569
|
-
if (
|
|
69628
|
+
if (existsSync17(to))
|
|
69570
69629
|
return {
|
|
69571
69630
|
action: "skipped",
|
|
69572
69631
|
detail: `${CHECKS_FILE} already exists; ${LEGACY_CHECKS_FILE} left in place`
|
|
@@ -69860,7 +69919,7 @@ var TOKEN_PLACEHOLDER2 = "YOUR_TOKEN_HERE", findDevFromCwd = (cwd) => {
|
|
|
69860
69919
|
return {
|
|
69861
69920
|
id,
|
|
69862
69921
|
status: "warn",
|
|
69863
|
-
detail: `${host} rules in ${coverage.file} do not cover ${shown}${coverage.missing.length > 4 ? ", …" : ""}${
|
|
69922
|
+
detail: `${host} rules in ${coverage.file} do not cover ${shown}${coverage.missing.length > 4 ? ", …" : ""}${existsSync17(coverage.file) ? "" : ` (${coverage.file} does not exist yet; \`workit setup\` writes it)`}: agents get a prompt (or an auto-mode denial) on verbs the workspace grants`,
|
|
69864
69923
|
fix: `workit setup --hosts=${host}`
|
|
69865
69924
|
};
|
|
69866
69925
|
}, ago = (ms) => {
|
|
@@ -70021,13 +70080,13 @@ var init_doctor = __esm(() => {
|
|
|
70021
70080
|
import {
|
|
70022
70081
|
copyFileSync as copyFileSync5,
|
|
70023
70082
|
cpSync as cpSync4,
|
|
70024
|
-
existsSync as
|
|
70083
|
+
existsSync as existsSync18,
|
|
70025
70084
|
lstatSync as lstatSync6,
|
|
70026
70085
|
mkdirSync as mkdirSync9,
|
|
70027
70086
|
mkdtempSync as mkdtempSync2,
|
|
70028
70087
|
readFileSync as readFileSync19,
|
|
70029
70088
|
readdirSync as readdirSync11,
|
|
70030
|
-
realpathSync as
|
|
70089
|
+
realpathSync as realpathSync9,
|
|
70031
70090
|
renameSync as renameSync5,
|
|
70032
70091
|
rmSync as rmSync5,
|
|
70033
70092
|
statSync as statSync7,
|
|
@@ -70132,7 +70191,7 @@ function buildSetupPreview(values, opts = {}) {
|
|
|
70132
70191
|
path: ytPath,
|
|
70133
70192
|
value: draft
|
|
70134
70193
|
});
|
|
70135
|
-
if (
|
|
70194
|
+
if (existsSync18(tokenPath))
|
|
70136
70195
|
preserved.push(tokenPath);
|
|
70137
70196
|
else
|
|
70138
70197
|
mutations.push({
|
|
@@ -70199,7 +70258,7 @@ function buildSetupPreview(values, opts = {}) {
|
|
|
70199
70258
|
if (target?.ok) {
|
|
70200
70259
|
const root = target.root;
|
|
70201
70260
|
const gitignorePath = path40.join(root, ".gitignore");
|
|
70202
|
-
const existing =
|
|
70261
|
+
const existing = existsSync18(gitignorePath) ? readFileSync19(gitignorePath, "utf8") : "";
|
|
70203
70262
|
const existingLines = new Set(existing.split(`
|
|
70204
70263
|
`).map((l) => l.trim()).filter(Boolean));
|
|
70205
70264
|
const entries = GITIGNORE_ENTRIES.filter((e) => e.trim() !== "" && !existingLines.has(e.trim()));
|
|
@@ -70473,13 +70532,13 @@ function applyOpenCode(root, res) {
|
|
|
70473
70532
|
};
|
|
70474
70533
|
}
|
|
70475
70534
|
function copyPluginDir(src, dest) {
|
|
70476
|
-
const realSrc =
|
|
70535
|
+
const realSrc = realpathSync9(src);
|
|
70477
70536
|
const marker = path40.join(dest, ".workit-root");
|
|
70478
|
-
const destIsLink =
|
|
70537
|
+
const destIsLink = existsSync18(dest) && lstatSync6(dest).isSymbolicLink();
|
|
70479
70538
|
const synced = !destIsLink && readFileSafe(marker)?.trim() === realSrc && samePluginContent(realSrc, dest, dest);
|
|
70480
70539
|
if (synced)
|
|
70481
70540
|
return "Skipped";
|
|
70482
|
-
const hadDir =
|
|
70541
|
+
const hadDir = existsSync18(dest);
|
|
70483
70542
|
const rules = preservedCursorRules(realSrc, dest);
|
|
70484
70543
|
const parent = path40.dirname(dest);
|
|
70485
70544
|
mkdirSync9(parent, { recursive: true });
|
|
@@ -70492,7 +70551,7 @@ function copyPluginDir(src, dest) {
|
|
|
70492
70551
|
filter: (entry) => !path40.relative(realSrc, entry).split(path40.sep).includes("node_modules")
|
|
70493
70552
|
});
|
|
70494
70553
|
const stagedHooks = path40.join(stage, CURSOR_HOOKS_FILE);
|
|
70495
|
-
if (
|
|
70554
|
+
if (existsSync18(stagedHooks))
|
|
70496
70555
|
writeFileSync10(stagedHooks, localizedCursorHooks(readFileSync19(stagedHooks), dest));
|
|
70497
70556
|
for (const [name, content] of rules) {
|
|
70498
70557
|
mkdirSync9(path40.join(stage, "rules"), { recursive: true });
|
|
@@ -70510,7 +70569,7 @@ function copyPluginDir(src, dest) {
|
|
|
70510
70569
|
try {
|
|
70511
70570
|
renameSync5(stage, dest);
|
|
70512
70571
|
} catch (error) {
|
|
70513
|
-
if (hadDir && !
|
|
70572
|
+
if (hadDir && !existsSync18(dest))
|
|
70514
70573
|
renameSync5(backup, dest);
|
|
70515
70574
|
throw error;
|
|
70516
70575
|
}
|
|
@@ -70588,9 +70647,9 @@ function applyCursorMcp(root, res) {
|
|
|
70588
70647
|
};
|
|
70589
70648
|
}
|
|
70590
70649
|
function verifyPlatform(platform, res) {
|
|
70591
|
-
if (platform === "opencode" && !
|
|
70650
|
+
if (platform === "opencode" && !existsSync18(res.opencodeConfig))
|
|
70592
70651
|
return null;
|
|
70593
|
-
if (platform === "cursor" && !
|
|
70652
|
+
if (platform === "cursor" && !existsSync18(res.cursorSettings) && !existsSync18(res.cursorMcp)) {
|
|
70594
70653
|
return null;
|
|
70595
70654
|
}
|
|
70596
70655
|
return runDoctor({
|
|
@@ -70871,7 +70930,7 @@ var TOKEN_PLACEHOLDER3 = "YOUR_TOKEN_HERE", YT_OVERRIDES, VCS_OVERRIDES, SETUP_O
|
|
|
70871
70930
|
try {
|
|
70872
70931
|
raw = readFileSync19(p, "utf8");
|
|
70873
70932
|
} catch {
|
|
70874
|
-
if (
|
|
70933
|
+
if (existsSync18(p))
|
|
70875
70934
|
return { kind: "malformed", error: `${p} is not readable` };
|
|
70876
70935
|
return { kind: "missing" };
|
|
70877
70936
|
}
|
|
@@ -70912,7 +70971,7 @@ var TOKEN_PLACEHOLDER3 = "YOUR_TOKEN_HERE", YT_OVERRIDES, VCS_OVERRIDES, SETUP_O
|
|
|
70912
70971
|
return (require2.resolve.paths(name) ?? []).map((dir) => path40.join(dir, name));
|
|
70913
70972
|
}, realRoot = (root) => {
|
|
70914
70973
|
try {
|
|
70915
|
-
return
|
|
70974
|
+
return realpathSync9(root);
|
|
70916
70975
|
} catch {
|
|
70917
70976
|
return root;
|
|
70918
70977
|
}
|
|
@@ -70926,7 +70985,7 @@ var TOKEN_PLACEHOLDER3 = "YOUR_TOKEN_HERE", YT_OVERRIDES, VCS_OVERRIDES, SETUP_O
|
|
|
70926
70985
|
return OPENCODE_NPM_PIN;
|
|
70927
70986
|
for (const rel of ["src/plugin.ts", "dist/plugin.js"]) {
|
|
70928
70987
|
const entry = path40.join(root, rel);
|
|
70929
|
-
if (
|
|
70988
|
+
if (existsSync18(entry))
|
|
70930
70989
|
return `file://${entry}`;
|
|
70931
70990
|
}
|
|
70932
70991
|
return null;
|
|
@@ -70956,7 +71015,7 @@ var TOKEN_PLACEHOLDER3 = "YOUR_TOKEN_HERE", YT_OVERRIDES, VCS_OVERRIDES, SETUP_O
|
|
|
70956
71015
|
}
|
|
70957
71016
|
}
|
|
70958
71017
|
for (const entry of readdirSync11(dest, { withFileTypes: true })) {
|
|
70959
|
-
if (
|
|
71018
|
+
if (existsSync18(path40.join(src, entry.name)))
|
|
70960
71019
|
continue;
|
|
70961
71020
|
const rel = path40.join(relative, entry.name);
|
|
70962
71021
|
if (rel === ".workit-root")
|
|
@@ -70977,7 +71036,7 @@ var TOKEN_PLACEHOLDER3 = "YOUR_TOKEN_HERE", YT_OVERRIDES, VCS_OVERRIDES, SETUP_O
|
|
|
70977
71036
|
for (const entry of readdirSync11(installedRules, { withFileTypes: true })) {
|
|
70978
71037
|
if (!entry.isFile() || !entry.name.endsWith(".mdc"))
|
|
70979
71038
|
continue;
|
|
70980
|
-
if (
|
|
71039
|
+
if (existsSync18(path40.join(sourceRules, entry.name)))
|
|
70981
71040
|
continue;
|
|
70982
71041
|
preserved.set(entry.name, readFileSync19(path40.join(installedRules, entry.name)));
|
|
70983
71042
|
}
|
|
@@ -70985,17 +71044,17 @@ var TOKEN_PLACEHOLDER3 = "YOUR_TOKEN_HERE", YT_OVERRIDES, VCS_OVERRIDES, SETUP_O
|
|
|
70985
71044
|
return preserved;
|
|
70986
71045
|
}, removeLegacyCursorDir = (res) => {
|
|
70987
71046
|
const legacy = path40.join(res.home, ".cursor", "plugins", "local", "workflow-toolkit");
|
|
70988
|
-
if (legacy === res.cursorPluginDir || !
|
|
71047
|
+
if (legacy === res.cursorPluginDir || !existsSync18(legacy))
|
|
70989
71048
|
return;
|
|
70990
71049
|
const legacyRules = path40.join(legacy, "rules");
|
|
70991
|
-
if (
|
|
71050
|
+
if (existsSync18(legacyRules)) {
|
|
70992
71051
|
try {
|
|
70993
71052
|
mkdirSync9(path40.join(res.cursorPluginDir, "rules"), { recursive: true });
|
|
70994
71053
|
for (const entry of readdirSync11(legacyRules, { withFileTypes: true })) {
|
|
70995
71054
|
if (!entry.isFile() || !entry.name.endsWith(".mdc"))
|
|
70996
71055
|
continue;
|
|
70997
71056
|
const target = path40.join(res.cursorPluginDir, "rules", entry.name);
|
|
70998
|
-
if (!
|
|
71057
|
+
if (!existsSync18(target))
|
|
70999
71058
|
copyFileSync5(path40.join(legacyRules, entry.name), target);
|
|
71000
71059
|
}
|
|
71001
71060
|
} catch {}
|
|
@@ -71384,7 +71443,7 @@ var init_logic = __esm(() => {
|
|
|
71384
71443
|
});
|
|
71385
71444
|
|
|
71386
71445
|
// packages/workit-cli/src/wizard-state.ts
|
|
71387
|
-
import { existsSync as
|
|
71446
|
+
import { existsSync as existsSync19, statSync as statSync8 } from "node:fs";
|
|
71388
71447
|
import path42 from "node:path";
|
|
71389
71448
|
import { isDeepStrictEqual as isDeepStrictEqual4 } from "node:util";
|
|
71390
71449
|
function resolveBasePath(values, env = process.env) {
|
|
@@ -71913,7 +71972,7 @@ var NEXT, PREV, skipsCustomBranch = (screen, preset) => (screen === "branchAllow
|
|
|
71913
71972
|
if (!p)
|
|
71914
71973
|
return "workspace root path is required";
|
|
71915
71974
|
return !path42.isAbsolute(p) || !isDirectory(p) ? `invalid workspace root "${p}" — enter an existing absolute directory` : null;
|
|
71916
|
-
}, skipsBranchPolicy = (screen, basePath) => (screen === "branchPolicy" || screen === "branchPolicyDevelop") && !
|
|
71975
|
+
}, skipsBranchPolicy = (screen, basePath) => (screen === "branchPolicy" || screen === "branchPolicyDevelop") && !existsSync19(path42.join(basePath, ".git")), decodeBranchPreset = (value, fallback) => value === "gitflow" || value === "github-flow" || value === "trunk-based" || value === "custom" ? value : fallback, decodeVcsProvider = (value, fallback) => value === "gitlab" || value === "github" || value === "skip" ? value : fallback, decodeIssueTracker = (value, fallback) => value === "youtrack" || value === "github" || value === "gitlab" || value === "none" ? value : fallback, GITHUB_ISSUES, withGithubIssues = (draft, tracker) => tracker === "github" ? { ...draft, issues: { ...GITHUB_ISSUES } } : draft;
|
|
71917
71976
|
var init_wizard_state = __esm(() => {
|
|
71918
71977
|
init_config();
|
|
71919
71978
|
init_workspaces();
|
|
@@ -71972,7 +72031,7 @@ var init_wizard_state = __esm(() => {
|
|
|
71972
72031
|
});
|
|
71973
72032
|
|
|
71974
72033
|
// packages/workit-cli/src/admin/uninstall.ts
|
|
71975
|
-
import { existsSync as
|
|
72034
|
+
import { existsSync as existsSync20, readFileSync as readFileSync21, realpathSync as realpathSync10, rmSync as rmSync7, writeFileSync as writeFileSync12 } from "node:fs";
|
|
71976
72035
|
import os14 from "node:os";
|
|
71977
72036
|
import path43 from "node:path";
|
|
71978
72037
|
function cleanCursorSettings(settings, pluginDir) {
|
|
@@ -72074,7 +72133,7 @@ function planUninstall(paths = {}) {
|
|
|
72074
72133
|
const mcpExisting = readJsonRecord(res.cursorMcp);
|
|
72075
72134
|
const settingsDirty = settingsExisting.kind === "malformed" || settingsExisting.kind === "record" && cleanCursorSettings(settingsExisting.value, res.cursorPluginDir).changed;
|
|
72076
72135
|
const mcpDirty = mcpExisting.kind === "malformed" || mcpExisting.kind === "record" && cleanCursorMcp(mcpExisting.value).changed;
|
|
72077
|
-
const dirExists =
|
|
72136
|
+
const dirExists = existsSync20(res.cursorPluginDir);
|
|
72078
72137
|
const actions = [];
|
|
72079
72138
|
if (settingsDirty) {
|
|
72080
72139
|
actions.push({
|
|
@@ -72102,7 +72161,7 @@ function planUninstall(paths = {}) {
|
|
|
72102
72161
|
installed: settingsDirty || mcpDirty || dirExists,
|
|
72103
72162
|
actions
|
|
72104
72163
|
};
|
|
72105
|
-
const codexInstalled =
|
|
72164
|
+
const codexInstalled = existsSync20(res.codexPluginDir);
|
|
72106
72165
|
const codex = {
|
|
72107
72166
|
host: "codex",
|
|
72108
72167
|
installed: codexInstalled,
|
|
@@ -72150,7 +72209,7 @@ function planUninstall(paths = {}) {
|
|
|
72150
72209
|
detail: `remove Workit's permission block from ${path43.basename(file)}`
|
|
72151
72210
|
});
|
|
72152
72211
|
}
|
|
72153
|
-
if (
|
|
72212
|
+
if (existsSync20(res.codexRules))
|
|
72154
72213
|
codex.actions.push({
|
|
72155
72214
|
kind: "remove-file",
|
|
72156
72215
|
path: res.codexRules,
|
|
@@ -72186,7 +72245,7 @@ function applyUninstall(plan, paths = {}) {
|
|
|
72186
72245
|
if (!allowed) {
|
|
72187
72246
|
status = "failed";
|
|
72188
72247
|
detail = `refusing to remove non-canonical plugin directory: ${resolved}`;
|
|
72189
|
-
} else if (!
|
|
72248
|
+
} else if (!existsSync20(resolved)) {
|
|
72190
72249
|
status = "skipped";
|
|
72191
72250
|
detail = "directory already absent";
|
|
72192
72251
|
} else {
|
|
@@ -72236,7 +72295,7 @@ var resolveUninstallPaths = (options = {}) => {
|
|
|
72236
72295
|
try {
|
|
72237
72296
|
raw = readFileSync21(file, "utf8");
|
|
72238
72297
|
} catch {
|
|
72239
|
-
if (
|
|
72298
|
+
if (existsSync20(file))
|
|
72240
72299
|
return { kind: "malformed", error: `${file} is not readable` };
|
|
72241
72300
|
return { kind: "missing" };
|
|
72242
72301
|
}
|
|
@@ -72280,7 +72339,7 @@ var resolveUninstallPaths = (options = {}) => {
|
|
|
72280
72339
|
return false;
|
|
72281
72340
|
}
|
|
72282
72341
|
try {
|
|
72283
|
-
return
|
|
72342
|
+
return realpathSync10(actionPath) === realpathSync10(expected);
|
|
72284
72343
|
} catch {
|
|
72285
72344
|
return true;
|
|
72286
72345
|
}
|
|
@@ -75085,7 +75144,7 @@ var init_setup2 = __esm(() => {
|
|
|
75085
75144
|
});
|
|
75086
75145
|
|
|
75087
75146
|
// packages/workit-cli/src/upgrade/shared.ts
|
|
75088
|
-
import { existsSync as
|
|
75147
|
+
import { existsSync as existsSync21, readFileSync as readFileSync22 } from "node:fs";
|
|
75089
75148
|
import path44 from "node:path";
|
|
75090
75149
|
import os16 from "node:os";
|
|
75091
75150
|
import { createHash as createHash15 } from "node:crypto";
|
|
@@ -75118,7 +75177,7 @@ var LAUNCH_HOSTS, HOSTS2, LIVE_HOSTS, OPENCODE_PACKAGE = "@brainervirus/workit-o
|
|
|
75118
75177
|
cursorRoot: path44.join(home, ".cursor/plugins/local/workit")
|
|
75119
75178
|
};
|
|
75120
75179
|
}, object2 = (file) => {
|
|
75121
|
-
if (!
|
|
75180
|
+
if (!existsSync21(file))
|
|
75122
75181
|
return null;
|
|
75123
75182
|
let data;
|
|
75124
75183
|
try {
|
|
@@ -75135,7 +75194,7 @@ var LAUNCH_HOSTS, HOSTS2, LIVE_HOSTS, OPENCODE_PACKAGE = "@brainervirus/workit-o
|
|
|
75135
75194
|
} catch {
|
|
75136
75195
|
return null;
|
|
75137
75196
|
}
|
|
75138
|
-
}, digest2 = (file) =>
|
|
75197
|
+
}, digest2 = (file) => existsSync21(file) ? createHash15("sha256").update(readFileSync22(file)).digest("hex") : "missing", runner = (deps) => deps.run ?? ((command, args) => {
|
|
75139
75198
|
const { home, env } = upgradePaths(deps);
|
|
75140
75199
|
let step;
|
|
75141
75200
|
try {
|
|
@@ -75231,7 +75290,7 @@ var init_processes = __esm(() => {
|
|
|
75231
75290
|
});
|
|
75232
75291
|
|
|
75233
75292
|
// packages/workit-cli/src/upgrade/apply.ts
|
|
75234
|
-
import { existsSync as
|
|
75293
|
+
import { existsSync as existsSync22, readdirSync as readdirSync12, mkdirSync as mkdirSync11, copyFileSync as copyFileSync6, chmodSync as chmodSync2, cpSync as cpSync5 } from "node:fs";
|
|
75235
75294
|
import path46 from "node:path";
|
|
75236
75295
|
import { createHash as createHash16 } from "node:crypto";
|
|
75237
75296
|
function applyUpgrade(plan, deps = {}) {
|
|
@@ -75270,7 +75329,7 @@ function applyUpgrade(plan, deps = {}) {
|
|
|
75270
75329
|
const backup = path46.join(home, ".local/state/workit/upgrades", new Date().toISOString().replaceAll(":", "-"));
|
|
75271
75330
|
mkdirSync11(backup, { recursive: true, mode: 448 });
|
|
75272
75331
|
for (const file of Object.keys(plan.configDigests))
|
|
75273
|
-
if (
|
|
75332
|
+
if (existsSync22(file)) {
|
|
75274
75333
|
const target = path46.join(backup, createHash16("sha256").update(file).digest("hex").slice(0, 12) + "-" + path46.basename(file));
|
|
75275
75334
|
copyFileSync6(file, target);
|
|
75276
75335
|
chmodSync2(target, 384);
|
|
@@ -75290,7 +75349,7 @@ function applyUpgrade(plan, deps = {}) {
|
|
|
75290
75349
|
}
|
|
75291
75350
|
const run = runner(deps);
|
|
75292
75351
|
let cursorBackupError = null;
|
|
75293
|
-
if (plan.entries.some((entry) => entry.host === "cursor") &&
|
|
75352
|
+
if (plan.entries.some((entry) => entry.host === "cursor") && existsSync22(paths.cursorRoot))
|
|
75294
75353
|
try {
|
|
75295
75354
|
cpSync5(paths.cursorRoot, path46.join(backup, "cursor-package"), {
|
|
75296
75355
|
recursive: true
|
|
@@ -75557,7 +75616,7 @@ var codexPluginRoot = (codexHome) => {
|
|
|
75557
75616
|
}, refreshCodexAgents = (run, codexHome) => {
|
|
75558
75617
|
const root = codexPluginRoot(codexHome);
|
|
75559
75618
|
const launcher = root && path46.join(root, "dist", "launch-mcp.js");
|
|
75560
|
-
if (!launcher || !
|
|
75619
|
+
if (!launcher || !existsSync22(launcher))
|
|
75561
75620
|
return { ok: true, note: "" };
|
|
75562
75621
|
const fix = `node ${JSON.stringify(launcher)} --install-agents`;
|
|
75563
75622
|
return run("node", [launcher, "--install-agents"]).status === 0 ? { ok: true, note: "agents refreshed" } : { ok: false, note: "agent refresh failed", fix };
|
|
@@ -75596,7 +75655,7 @@ var init_apply = __esm(() => {
|
|
|
75596
75655
|
});
|
|
75597
75656
|
|
|
75598
75657
|
// packages/workit-cli/src/upgrade/plan.ts
|
|
75599
|
-
import { existsSync as
|
|
75658
|
+
import { existsSync as existsSync23, mkdtempSync as mkdtempSync3, rmSync as rmSync8, lstatSync as lstatSync7, readFileSync as readFileSync23 } from "node:fs";
|
|
75600
75659
|
import path47 from "node:path";
|
|
75601
75660
|
import os17 from "node:os";
|
|
75602
75661
|
function previewUpgrade(hosts = HOSTS2, deps = {}) {
|
|
@@ -75783,7 +75842,7 @@ var codexRegistered = (configFile) => {
|
|
|
75783
75842
|
}
|
|
75784
75843
|
};
|
|
75785
75844
|
guard("opencode", () => {
|
|
75786
|
-
if (
|
|
75845
|
+
if (existsSync23(paths.opencodeConfig + "c"))
|
|
75787
75846
|
throw new Error("OpenCode JSONC config is present; inspect effective native configuration before updating");
|
|
75788
75847
|
const oc = object2(paths.opencodeConfig);
|
|
75789
75848
|
if (oc && [oc.plugins, oc.plugin].some((value) => value !== undefined && !Array.isArray(value)))
|
|
@@ -75840,7 +75899,7 @@ var codexRegistered = (configFile) => {
|
|
|
75840
75899
|
hostCommand("codex", [], { home, env: paths.env });
|
|
75841
75900
|
available = true;
|
|
75842
75901
|
} catch {}
|
|
75843
|
-
if (available ||
|
|
75902
|
+
if (available || existsSync23(paths.codexConfig))
|
|
75844
75903
|
throw new Error("Codex plugin inventory failed; inspect the native host before upgrading");
|
|
75845
75904
|
return;
|
|
75846
75905
|
}
|
|
@@ -77302,7 +77361,7 @@ __export(exports_workspace, {
|
|
|
77302
77361
|
run: () => run11,
|
|
77303
77362
|
runWorkspace: () => runWorkspace
|
|
77304
77363
|
});
|
|
77305
|
-
import { copyFileSync as copyFileSync7, existsSync as
|
|
77364
|
+
import { copyFileSync as copyFileSync7, existsSync as existsSync24 } from "node:fs";
|
|
77306
77365
|
function list2(argv, io) {
|
|
77307
77366
|
if (argv.length)
|
|
77308
77367
|
return usage3(io, `unexpected argument ${argv[0]}`);
|
|
@@ -77611,7 +77670,7 @@ usage: ${USAGE5}`)), load = (io) => {
|
|
|
77611
77670
|
return { ok: false, error: `${current.path} changed; retry` };
|
|
77612
77671
|
let backup = null;
|
|
77613
77672
|
try {
|
|
77614
|
-
if (
|
|
77673
|
+
if (existsSync24(current.path)) {
|
|
77615
77674
|
backup = `${current.path}.bak`;
|
|
77616
77675
|
copyFileSync7(current.path, backup);
|
|
77617
77676
|
}
|
|
@@ -79447,7 +79506,7 @@ var exports_models = {};
|
|
|
79447
79506
|
__export(exports_models, {
|
|
79448
79507
|
run: () => run14
|
|
79449
79508
|
});
|
|
79450
|
-
import { existsSync as
|
|
79509
|
+
import { existsSync as existsSync25, readdirSync as readdirSync13, readFileSync as readFileSync24, statSync as statSync9 } from "node:fs";
|
|
79451
79510
|
import os22 from "node:os";
|
|
79452
79511
|
import path55 from "node:path";
|
|
79453
79512
|
async function run14(argv, io) {
|
|
@@ -79543,7 +79602,7 @@ var USAGE8 = "workit models show [--role <role>] [--tier <tier>] [--host <host>]
|
|
|
79543
79602
|
continue;
|
|
79544
79603
|
const agentType = JSON.parse(readFileSync24(meta, "utf8")).agentType;
|
|
79545
79604
|
const transcript = meta.replace(/\.meta\.json$/, ".jsonl");
|
|
79546
|
-
if (typeof agentType !== "string" || !
|
|
79605
|
+
if (typeof agentType !== "string" || !existsSync25(transcript))
|
|
79547
79606
|
continue;
|
|
79548
79607
|
const ran = modelsOf(transcript);
|
|
79549
79608
|
if (!ran.size)
|
|
@@ -79682,7 +79741,7 @@ var success2 = (data) => ({ ok: true, data }), failure3 = (code, error, unblock)
|
|
|
79682
79741
|
|
|
79683
79742
|
// packages/workit-core/src/git/ops.ts
|
|
79684
79743
|
import { spawnSync as spawnSync20 } from "node:child_process";
|
|
79685
|
-
import { existsSync as
|
|
79744
|
+
import { existsSync as existsSync26, readFileSync as readFileSync25 } from "node:fs";
|
|
79686
79745
|
import path56 from "node:path";
|
|
79687
79746
|
function operationInProgress(cwd) {
|
|
79688
79747
|
const markers = [
|
|
@@ -79700,11 +79759,11 @@ function operationInProgress(cwd) {
|
|
|
79700
79759
|
const conflicted = () => git5(cwd, ["ls-files", "-u"]).stdout.trim() !== "";
|
|
79701
79760
|
for (const [index, [, operation]] of markers.entries()) {
|
|
79702
79761
|
const marker = found[index];
|
|
79703
|
-
if (!marker || !
|
|
79762
|
+
if (!marker || !existsSync26(marker))
|
|
79704
79763
|
continue;
|
|
79705
|
-
if (index === 1 &&
|
|
79764
|
+
if (index === 1 && existsSync26(path56.join(marker, "applying")))
|
|
79706
79765
|
return { operation: "am", commitAllowed: false, branch: null };
|
|
79707
|
-
if (index === 0 &&
|
|
79766
|
+
if (index === 0 && existsSync26(path56.join(marker, "amend")) && !conflicted()) {
|
|
79708
79767
|
let headName = "";
|
|
79709
79768
|
try {
|
|
79710
79769
|
headName = readFileSync25(path56.join(marker, "head-name"), "utf8").trim();
|
|
@@ -80035,7 +80094,7 @@ function gitCommit(cwd, input) {
|
|
|
80035
80094
|
if (paths.some((value) => value.startsWith("-") || !value.trim()))
|
|
80036
80095
|
return failure3("invalid_input", "paths must not be empty or start with -");
|
|
80037
80096
|
const tracked = new Set(nulList(git5(cwd, ["ls-files", "-z", "--", ...paths]).stdout));
|
|
80038
|
-
const addable = paths.filter((value) =>
|
|
80097
|
+
const addable = paths.filter((value) => existsSync26(path56.resolve(cwd, value)) || [...tracked].some((file) => file === value || file.startsWith(`${value}/`)));
|
|
80039
80098
|
if (addable.length) {
|
|
80040
80099
|
const added = git5(cwd, ["add", "-A", "--", ...addable]);
|
|
80041
80100
|
if (!added.ok)
|
|
@@ -87016,7 +87075,7 @@ __export(exports_pr, {
|
|
|
87016
87075
|
checkPrTitle: () => checkPrTitle,
|
|
87017
87076
|
run: () => run15
|
|
87018
87077
|
});
|
|
87019
|
-
import { existsSync as
|
|
87078
|
+
import { existsSync as existsSync27, readFileSync as readFileSync27 } from "node:fs";
|
|
87020
87079
|
import path66 from "node:path";
|
|
87021
87080
|
function titleRules(cwd) {
|
|
87022
87081
|
let root;
|
|
@@ -87029,7 +87088,7 @@ function titleRules(cwd) {
|
|
|
87029
87088
|
let name = "";
|
|
87030
87089
|
for (const candidate of COMMITLINT_FILES) {
|
|
87031
87090
|
const full = path66.join(root, candidate);
|
|
87032
|
-
if (!
|
|
87091
|
+
if (!existsSync27(full))
|
|
87033
87092
|
continue;
|
|
87034
87093
|
text = readFileSync27(full, "utf8");
|
|
87035
87094
|
name = candidate;
|
|
@@ -106724,7 +106783,7 @@ var init_rules = __esm(() => {
|
|
|
106724
106783
|
|
|
106725
106784
|
// packages/workit-cli/src/test-audit/audit.ts
|
|
106726
106785
|
import { spawnSync as spawnSync29 } from "node:child_process";
|
|
106727
|
-
import { existsSync as
|
|
106786
|
+
import { existsSync as existsSync28, readdirSync as readdirSync14, readFileSync as readFileSync29, statSync as statSync10 } from "node:fs";
|
|
106728
106787
|
import path71 from "node:path";
|
|
106729
106788
|
function git7(cwd, args) {
|
|
106730
106789
|
const run = spawnSync29("git", ["-c", "core.quotepath=off", ...args], {
|
|
@@ -106751,7 +106810,7 @@ function expandPaths(cwd, inputs) {
|
|
|
106751
106810
|
const missing = [];
|
|
106752
106811
|
for (const input of inputs.length > 0 ? inputs : ["."]) {
|
|
106753
106812
|
const full = path71.resolve(cwd, input);
|
|
106754
|
-
if (!
|
|
106813
|
+
if (!existsSync28(full))
|
|
106755
106814
|
missing.push(input);
|
|
106756
106815
|
else if (statSync10(full).isDirectory())
|
|
106757
106816
|
walkTests(full, files);
|
|
@@ -106867,14 +106926,14 @@ var init_audit = __esm(() => {
|
|
|
106867
106926
|
// packages/workit-cli/src/test-audit/mutate.ts
|
|
106868
106927
|
import { spawn as spawn2 } from "node:child_process";
|
|
106869
106928
|
import {
|
|
106870
|
-
existsSync as
|
|
106929
|
+
existsSync as existsSync29,
|
|
106871
106930
|
lstatSync as lstatSync8,
|
|
106872
106931
|
mkdirSync as mkdirSync12,
|
|
106873
106932
|
mkdtempSync as mkdtempSync4,
|
|
106874
106933
|
readdirSync as readdirSync15,
|
|
106875
106934
|
readFileSync as readFileSync30,
|
|
106876
106935
|
readlinkSync as readlinkSync3,
|
|
106877
|
-
realpathSync as
|
|
106936
|
+
realpathSync as realpathSync11,
|
|
106878
106937
|
renameSync as renameSync7,
|
|
106879
106938
|
rmSync as rmSync9,
|
|
106880
106939
|
statSync as statSync11,
|
|
@@ -107011,7 +107070,7 @@ function linkNodeModules(origin, target, repo, copy) {
|
|
|
107011
107070
|
if (entry.isSymbolicLink()) {
|
|
107012
107071
|
let real;
|
|
107013
107072
|
try {
|
|
107014
|
-
real =
|
|
107073
|
+
real = realpathSync11(from);
|
|
107015
107074
|
} catch {
|
|
107016
107075
|
continue;
|
|
107017
107076
|
}
|
|
@@ -107027,11 +107086,11 @@ function linkNodeModules(origin, target, repo, copy) {
|
|
|
107027
107086
|
function copySymlink(repo, tree, from, to) {
|
|
107028
107087
|
let real = null;
|
|
107029
107088
|
try {
|
|
107030
|
-
real =
|
|
107089
|
+
real = realpathSync11(from);
|
|
107031
107090
|
} catch {
|
|
107032
107091
|
real = null;
|
|
107033
107092
|
}
|
|
107034
|
-
const realRepo =
|
|
107093
|
+
const realRepo = realpathSync11(repo);
|
|
107035
107094
|
if (real && inside5(realRepo, real)) {
|
|
107036
107095
|
symlinkSync(path72.relative(path72.dirname(to), path72.join(tree, path72.relative(realRepo, real))), to);
|
|
107037
107096
|
return;
|
|
@@ -107045,7 +107104,7 @@ function writeInside(copy, file, content) {
|
|
|
107045
107104
|
const target = path72.join(copy, file);
|
|
107046
107105
|
try {
|
|
107047
107106
|
const stat = lstatSync8(target);
|
|
107048
|
-
if (!stat.isFile() || !inside5(
|
|
107107
|
+
if (!stat.isFile() || !inside5(realpathSync11(copy), realpathSync11(path72.dirname(target))))
|
|
107049
107108
|
return false;
|
|
107050
107109
|
} catch {
|
|
107051
107110
|
return false;
|
|
@@ -107096,7 +107155,7 @@ function copyWorkingTree(repo) {
|
|
|
107096
107155
|
}
|
|
107097
107156
|
for (const parent of dirs) {
|
|
107098
107157
|
const modules = path72.join(repo, parent, "node_modules");
|
|
107099
|
-
if (
|
|
107158
|
+
if (existsSync29(modules) && !existsSync29(path72.join(tree, parent, "node_modules")))
|
|
107100
107159
|
linkNodeModules(modules, path72.join(tree, parent, "node_modules"), repo, tree);
|
|
107101
107160
|
}
|
|
107102
107161
|
return { dir, tree };
|
|
@@ -107146,7 +107205,7 @@ async function runMutation(options) {
|
|
|
107146
107205
|
const relative = toPosix(path72.relative(repo, absolute));
|
|
107147
107206
|
if (!CODE_FILE.test(relative) || TEST_FILE.test(relative) || relative.endsWith(".d.ts"))
|
|
107148
107207
|
continue;
|
|
107149
|
-
if (NOT_SOURCE.test(relative) || !
|
|
107208
|
+
if (NOT_SOURCE.test(relative) || !existsSync29(absolute))
|
|
107150
107209
|
continue;
|
|
107151
107210
|
try {
|
|
107152
107211
|
candidates.push(...mutantsFor(readFileSync30(absolute, "utf8"), relative, lines));
|
|
@@ -107336,7 +107395,7 @@ var exports_test_audit = {};
|
|
|
107336
107395
|
__export(exports_test_audit, {
|
|
107337
107396
|
run: () => run23
|
|
107338
107397
|
});
|
|
107339
|
-
import { existsSync as
|
|
107398
|
+
import { existsSync as existsSync30 } from "node:fs";
|
|
107340
107399
|
import path73 from "node:path";
|
|
107341
107400
|
function parse8(argv) {
|
|
107342
107401
|
const options = {
|
|
@@ -107460,7 +107519,7 @@ usage: ${USAGE16}`));
|
|
|
107460
107519
|
}
|
|
107461
107520
|
let files;
|
|
107462
107521
|
if (options.diff && changed)
|
|
107463
|
-
files = [...changed.keys()].filter((file) => TEST_FILE.test(toPosix(file)) &&
|
|
107522
|
+
files = [...changed.keys()].filter((file) => TEST_FILE.test(toPosix(file)) && existsSync30(file)).toSorted();
|
|
107464
107523
|
else {
|
|
107465
107524
|
const expanded = expandPaths(io.cwd, options.paths);
|
|
107466
107525
|
if (expanded.missing.length > 0)
|