@workit-dev/codex 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/launch-mcp.js
CHANGED
|
@@ -6622,13 +6622,13 @@ var require_dist = __commonJS(function(exports, module) {
|
|
|
6622
6622
|
|
|
6623
6623
|
// packages/workit-codex/scripts/launch-mcp.ts
|
|
6624
6624
|
import { existsSync as existsSync16, realpathSync as realpathSync11, statSync as statSync6 } from "node:fs";
|
|
6625
|
-
import
|
|
6625
|
+
import path38 from "node:path";
|
|
6626
6626
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
6627
6627
|
|
|
6628
6628
|
// packages/workit-core/src/core.ts
|
|
6629
6629
|
import { spawnSync as spawnSync20 } from "node:child_process";
|
|
6630
6630
|
import { existsSync as existsSync11, realpathSync as realpathSync8 } from "node:fs";
|
|
6631
|
-
import
|
|
6631
|
+
import path31 from "node:path";
|
|
6632
6632
|
|
|
6633
6633
|
// packages/workit-core/src/core/task-contract.ts
|
|
6634
6634
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -24025,7 +24025,7 @@ var exportDigest = (bundle) => sha256({
|
|
|
24025
24025
|
task: bundle.task
|
|
24026
24026
|
});
|
|
24027
24027
|
// packages/workit-core/src/autonomy.ts
|
|
24028
|
-
import
|
|
24028
|
+
import path26 from "node:path";
|
|
24029
24029
|
|
|
24030
24030
|
// packages/workit-core/src/core/eval-world.ts
|
|
24031
24031
|
import { existsSync as existsSync9, realpathSync as realpathSync5 } from "node:fs";
|
|
@@ -24057,6 +24057,68 @@ var evalWorldEntry = (cwd) => {
|
|
|
24057
24057
|
}
|
|
24058
24058
|
};
|
|
24059
24059
|
|
|
24060
|
+
// packages/workit-core/src/core/grant-seal.ts
|
|
24061
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
24062
|
+
import { readFileSync as readFileSync10 } from "node:fs";
|
|
24063
|
+
import path25 from "node:path";
|
|
24064
|
+
var SEAL_FILE = "workspaces.json.seal";
|
|
24065
|
+
var SEAL_VERSION = 1;
|
|
24066
|
+
var SEAL_COMMAND = "workit workspace seal";
|
|
24067
|
+
var pick2 = (value, keys) => {
|
|
24068
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
24069
|
+
return;
|
|
24070
|
+
const out = Object.fromEntries(keys.flatMap((key) => {
|
|
24071
|
+
const item = value[key];
|
|
24072
|
+
return item === undefined ? [] : [[key, item]];
|
|
24073
|
+
}));
|
|
24074
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
24075
|
+
};
|
|
24076
|
+
var ENTRY_KEYS = [
|
|
24077
|
+
"name",
|
|
24078
|
+
"glob",
|
|
24079
|
+
"remotes",
|
|
24080
|
+
"vcs",
|
|
24081
|
+
"autonomy",
|
|
24082
|
+
"autoApprove",
|
|
24083
|
+
"defaultEndpoint",
|
|
24084
|
+
"verification",
|
|
24085
|
+
"youtrack"
|
|
24086
|
+
];
|
|
24087
|
+
var sealProjection = (entries) => entries.map((entry) => {
|
|
24088
|
+
const all = pick2(entry, ENTRY_KEYS) ?? {};
|
|
24089
|
+
return pick2({
|
|
24090
|
+
...all,
|
|
24091
|
+
vcs: pick2(all.vcs, ["provider", "account"]),
|
|
24092
|
+
youtrack: pick2(all.youtrack, ["writes"])
|
|
24093
|
+
}, ENTRY_KEYS);
|
|
24094
|
+
});
|
|
24095
|
+
var canonical3 = (value) => JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) : item);
|
|
24096
|
+
var sealDigest = (projection) => createHash11("sha256").update(canonical3(projection)).digest("hex");
|
|
24097
|
+
var broken = (reason, sealed = null) => ({
|
|
24098
|
+
state: "broken",
|
|
24099
|
+
reason,
|
|
24100
|
+
sealed
|
|
24101
|
+
});
|
|
24102
|
+
function checkSeal(dir) {
|
|
24103
|
+
const file = path25.join(dir, SEAL_FILE);
|
|
24104
|
+
let seal;
|
|
24105
|
+
try {
|
|
24106
|
+
seal = JSON.parse(readFileSync10(file, "utf8"));
|
|
24107
|
+
} catch (error) {
|
|
24108
|
+
if (error.code === "ENOENT")
|
|
24109
|
+
return { state: "none" };
|
|
24110
|
+
return broken(`${SEAL_FILE} cannot be read`);
|
|
24111
|
+
}
|
|
24112
|
+
if (seal?.version !== SEAL_VERSION || !Array.isArray(seal.projection) || seal.sha256 !== sealDigest(seal.projection))
|
|
24113
|
+
return broken(`${SEAL_FILE} is malformed`);
|
|
24114
|
+
const sealed = validateWorkspacesDocument({ workspaces: seal.projection }, file);
|
|
24115
|
+
if (sealed.status !== "valid")
|
|
24116
|
+
return broken(`${SEAL_FILE} is malformed`);
|
|
24117
|
+
const current = readWorkspacesResult(dir);
|
|
24118
|
+
const ok = current.status === "valid" || current.status === "missing";
|
|
24119
|
+
return ok && sealDigest(sealProjection(current.entries)) === seal.sha256 ? { state: "valid" } : broken("workspaces.json changed since it was sealed", sealed.entries);
|
|
24120
|
+
}
|
|
24121
|
+
|
|
24060
24122
|
// packages/workit-core/src/autonomy.ts
|
|
24061
24123
|
var grantsHome = { resolve: accountHome };
|
|
24062
24124
|
var accountDir = () => {
|
|
@@ -24066,13 +24128,23 @@ var accountDir = () => {
|
|
|
24066
24128
|
var grantsDir = () => accountDir() ?? resolveConfigDir();
|
|
24067
24129
|
var NO_ACCOUNT = "no OS account record answered (core/account-home.ts), so no grants are read: the D4 defaults apply";
|
|
24068
24130
|
var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
|
|
24069
|
-
var
|
|
24131
|
+
var fileSource = (dir = accountDir()) => ({
|
|
24132
|
+
resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom(cwd, dir, name),
|
|
24133
|
+
entries: () => entriesIn(dir)
|
|
24134
|
+
});
|
|
24135
|
+
var sealedSource = (entries) => ({
|
|
24136
|
+
resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name),
|
|
24137
|
+
entries: () => entries
|
|
24138
|
+
});
|
|
24139
|
+
var sealOf = () => {
|
|
24070
24140
|
const dir = accountDir();
|
|
24071
|
-
return dir === null ?
|
|
24141
|
+
return dir === null ? { state: "none" } : checkSeal(dir);
|
|
24072
24142
|
};
|
|
24143
|
+
var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own terminal: ${SEAL_COMMAND}`;
|
|
24144
|
+
var sealNote = (seal = sealOf()) => seal.state === "broken" ? `workspaces.json does not match its seal (${seal.reason}), so grants, endpoint, verification and youtrack.writes are the stricter of their current and last sealed values; ${SEAL_UNBLOCK}` : null;
|
|
24073
24145
|
var shownGrantsDir = () => {
|
|
24074
24146
|
const world = evalWorld(process.cwd());
|
|
24075
|
-
return world ?
|
|
24147
|
+
return world ? path26.join(world, "config") : accountDir();
|
|
24076
24148
|
};
|
|
24077
24149
|
var benchWorld = (cwd) => {
|
|
24078
24150
|
const entry = evalWorldEntry(cwd);
|
|
@@ -24096,8 +24168,8 @@ var grantsOverride = () => {
|
|
|
24096
24168
|
const shown = shownGrantsDir();
|
|
24097
24169
|
if (shown === null)
|
|
24098
24170
|
return NO_ACCOUNT;
|
|
24099
|
-
const configured =
|
|
24100
|
-
return configured ===
|
|
24171
|
+
const configured = path26.resolve(resolveConfigDir());
|
|
24172
|
+
return configured === path26.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path26.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
|
|
24101
24173
|
};
|
|
24102
24174
|
var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
|
|
24103
24175
|
var DEFAULT_GRANTS = Object.freeze({
|
|
@@ -24217,13 +24289,13 @@ function autonomyOf(workspace) {
|
|
|
24217
24289
|
verification: verificationOf(workspace)
|
|
24218
24290
|
};
|
|
24219
24291
|
}
|
|
24220
|
-
function capAt(named, where, by, why, main = false) {
|
|
24292
|
+
function capAt(source, named, where, by, why, main = false) {
|
|
24221
24293
|
let folder = null;
|
|
24222
24294
|
let none = "";
|
|
24223
24295
|
try {
|
|
24224
24296
|
if (where instanceof Error)
|
|
24225
24297
|
throw where;
|
|
24226
|
-
folder = autonomyOf(typeof where === "string" ?
|
|
24298
|
+
folder = autonomyOf(typeof where === "string" ? source.resolve(where) : where.entry);
|
|
24227
24299
|
} catch (error) {
|
|
24228
24300
|
none = error.message;
|
|
24229
24301
|
}
|
|
@@ -24266,31 +24338,84 @@ function resolveAutonomy(cwd, target) {
|
|
|
24266
24338
|
const override = world ? null : grantsOverride();
|
|
24267
24339
|
if (override)
|
|
24268
24340
|
return { ...autonomyOf(null), note: override };
|
|
24341
|
+
let resolved;
|
|
24342
|
+
const once = typeof target === "function" ? () => resolved ??= target() : target;
|
|
24343
|
+
const current = resolveWith(fileSource(), cwd, world, once);
|
|
24344
|
+
const seal = sealOf();
|
|
24345
|
+
if (seal.state !== "broken")
|
|
24346
|
+
return current;
|
|
24347
|
+
let sealed = autonomyOf(null);
|
|
24348
|
+
try {
|
|
24349
|
+
if (seal.sealed)
|
|
24350
|
+
sealed = resolveWith(sealedSource(seal.sealed), cwd, world, once);
|
|
24351
|
+
} catch {
|
|
24352
|
+
sealed = null;
|
|
24353
|
+
}
|
|
24354
|
+
return stricter(current, sealed, sealNote(seal));
|
|
24355
|
+
}
|
|
24356
|
+
function resolveWith(source, cwd, world, target) {
|
|
24269
24357
|
const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
24270
|
-
const real =
|
|
24358
|
+
const real = source.resolve(cwd, name);
|
|
24271
24359
|
let autonomy = autonomyOf(real ?? world);
|
|
24272
24360
|
if (!real && world)
|
|
24273
24361
|
autonomy.world = evalWorld(cwd) ?? undefined;
|
|
24274
24362
|
if (name)
|
|
24275
|
-
autonomy = capAt(autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
|
|
24363
|
+
autonomy = capAt(source, autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
|
|
24276
24364
|
const above = checkoutsAbove(cwd);
|
|
24277
24365
|
for (const where of above instanceof Error ? [above] : above)
|
|
24278
|
-
autonomy = capAt(autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
|
|
24279
|
-
return capAtRemotes(autonomy, cwd, target);
|
|
24366
|
+
autonomy = capAt(source, autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
|
|
24367
|
+
return capAtRemotes(source, autonomy, cwd, target);
|
|
24280
24368
|
}
|
|
24281
|
-
|
|
24282
|
-
|
|
24369
|
+
var needsAccount = (autonomy) => autonomy.configured.length > 0 && !autonomy.accountConfigured;
|
|
24370
|
+
function stricter(current, sealed, note) {
|
|
24371
|
+
const grants = { ...current.grants };
|
|
24372
|
+
const unblocks = { ...current.unblocks };
|
|
24373
|
+
for (const kind of GRANT_KINDS) {
|
|
24374
|
+
const floor = sealed ? sealed.grants[kind] : false;
|
|
24375
|
+
if (!raises(kind, floor, grants[kind]))
|
|
24376
|
+
continue;
|
|
24377
|
+
grants[kind] = floor;
|
|
24378
|
+
unblocks[kind] = SEAL_UNBLOCK;
|
|
24379
|
+
}
|
|
24380
|
+
const configured = GRANT_KINDS.filter((kind) => current.configured.includes(kind) || sealed?.configured.includes(kind));
|
|
24381
|
+
const accountConfigured = !needsAccount(current) && !(sealed && needsAccount(sealed)) && (current.accountConfigured || Boolean(sealed?.accountConfigured));
|
|
24382
|
+
const lower = (a, b) => raisesEndpoint(a, b) ? a : b;
|
|
24383
|
+
const defaultEndpoint = lower(current.defaultEndpoint, sealed?.defaultEndpoint ?? DEFAULT_ENDPOINT);
|
|
24384
|
+
const effective = effectiveEndpoint(defaultEndpoint, {
|
|
24385
|
+
workspace: current.workspace,
|
|
24386
|
+
grants,
|
|
24387
|
+
configured,
|
|
24388
|
+
accountConfigured
|
|
24389
|
+
});
|
|
24390
|
+
const endpoint = lower(lower(effective.endpoint, current.effectiveEndpoint), sealed?.effectiveEndpoint ?? DEFAULT_ENDPOINT);
|
|
24391
|
+
const strict = sealed?.verification ?? "independent";
|
|
24392
|
+
const looser = VERIFICATION_STRICTNESS.indexOf(current.verification) > VERIFICATION_STRICTNESS.indexOf(strict);
|
|
24393
|
+
return {
|
|
24394
|
+
...current,
|
|
24395
|
+
grants,
|
|
24396
|
+
configured,
|
|
24397
|
+
accountConfigured,
|
|
24398
|
+
defaultEndpoint,
|
|
24399
|
+
effectiveEndpoint: endpoint,
|
|
24400
|
+
endpointReason: endpoint === current.effectiveEndpoint ? current.endpointReason : SEAL_UNBLOCK,
|
|
24401
|
+
verification: looser ? strict : current.verification,
|
|
24402
|
+
unblocks,
|
|
24403
|
+
note: current.note ? `${current.note}; ${note}` : note
|
|
24404
|
+
};
|
|
24405
|
+
}
|
|
24406
|
+
function capAtRemotes(source, autonomy, cwd, target) {
|
|
24407
|
+
const claiming = source.entries().filter((entry) => entry.remotes?.length);
|
|
24283
24408
|
if (claiming.length === 0)
|
|
24284
24409
|
return autonomy;
|
|
24285
24410
|
const remotes = target === undefined ? checkoutRemotes(cwd) : typeof target === "function" ? target() : target;
|
|
24286
24411
|
if (remotes instanceof Error)
|
|
24287
|
-
return capAt(autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
|
|
24412
|
+
return capAt(source, autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
|
|
24288
24413
|
let capped = autonomy;
|
|
24289
24414
|
for (const remote of Array.isArray(remotes) ? remotes : remotes.remotes)
|
|
24290
24415
|
for (const entry of claiming) {
|
|
24291
24416
|
const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
|
|
24292
24417
|
if (pattern)
|
|
24293
|
-
capped = capAt(capped, { entry }, `remote ${remote.name} ${remote.url} (workspace ${entry.name} claims ${pattern})`, "a checkout never exceeds the workspace that owns its remote");
|
|
24418
|
+
capped = capAt(source, capped, { entry }, `remote ${remote.name} ${remote.url} (workspace ${entry.name} claims ${pattern})`, "a checkout never exceeds the workspace that owns its remote");
|
|
24294
24419
|
}
|
|
24295
24420
|
return capped;
|
|
24296
24421
|
}
|
|
@@ -26394,8 +26519,8 @@ class WorkitCore {
|
|
|
26394
26519
|
}
|
|
26395
26520
|
// packages/workit-core/src/core/repo-context.ts
|
|
26396
26521
|
import { spawnSync as spawnSync16 } from "node:child_process";
|
|
26397
|
-
import { existsSync as existsSync10, readFileSync as
|
|
26398
|
-
import
|
|
26522
|
+
import { existsSync as existsSync10, readFileSync as readFileSync11, readdirSync as readdirSync4 } from "node:fs";
|
|
26523
|
+
import path27 from "node:path";
|
|
26399
26524
|
var isSafeContextRange = (value) => value.length <= 4096 && (() => {
|
|
26400
26525
|
try {
|
|
26401
26526
|
gitRevisionParts(value);
|
|
@@ -26539,13 +26664,13 @@ var findPrTemplate = (cwd) => {
|
|
|
26539
26664
|
for (const rel of PR_TEMPLATE_FILES) {
|
|
26540
26665
|
const parts = rel.split("/");
|
|
26541
26666
|
const base = parts[parts.length - 1];
|
|
26542
|
-
const dir = parts.length > 1 ?
|
|
26667
|
+
const dir = parts.length > 1 ? path27.join(cwd, ...parts.slice(0, -1)) : cwd;
|
|
26543
26668
|
const actual = probeCaseInsensitive(dir, base);
|
|
26544
26669
|
if (actual)
|
|
26545
26670
|
return [...parts.slice(0, -1), actual].join("/");
|
|
26546
26671
|
}
|
|
26547
26672
|
for (const rel of PR_TEMPLATE_DIRS) {
|
|
26548
|
-
const only = singleMarkdown(
|
|
26673
|
+
const only = singleMarkdown(path27.join(cwd, ...rel.split("/")));
|
|
26549
26674
|
if (only)
|
|
26550
26675
|
return `${rel}/${only}`;
|
|
26551
26676
|
}
|
|
@@ -26575,11 +26700,11 @@ var diffStatForRange = (cwd, range) => {
|
|
|
26575
26700
|
return runGit(cwd, ["diff", "--stat", "--"]).stdout;
|
|
26576
26701
|
};
|
|
26577
26702
|
var packageScripts = (cwd, keys) => {
|
|
26578
|
-
const pkgPath =
|
|
26703
|
+
const pkgPath = path27.join(cwd, "package.json");
|
|
26579
26704
|
if (!existsSync10(pkgPath))
|
|
26580
26705
|
return [];
|
|
26581
26706
|
try {
|
|
26582
|
-
const pkg = JSON.parse(
|
|
26707
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
|
|
26583
26708
|
return keys.filter((k) => pkg.scripts && typeof pkg.scripts[k] === "string").map((k) => `${k}: ${pkg.scripts?.[k]}`);
|
|
26584
26709
|
} catch {
|
|
26585
26710
|
return [];
|
|
@@ -26601,9 +26726,9 @@ var documentationFiles = (cwd) => {
|
|
|
26601
26726
|
if (entry.isDirectory()) {
|
|
26602
26727
|
if (excluded.has(entry.name))
|
|
26603
26728
|
continue;
|
|
26604
|
-
walk(
|
|
26729
|
+
walk(path27.join(dir, entry.name), depth + 1);
|
|
26605
26730
|
} else if (entry.isFile() && (entry.name === "README.md" || entry.name.endsWith(".md"))) {
|
|
26606
|
-
matches.push("./" +
|
|
26731
|
+
matches.push("./" + path27.relative(cwd, path27.join(dir, entry.name)).replaceAll("\\", "/"));
|
|
26607
26732
|
}
|
|
26608
26733
|
}
|
|
26609
26734
|
};
|
|
@@ -26613,13 +26738,13 @@ var documentationFiles = (cwd) => {
|
|
|
26613
26738
|
var readTrimmed2 = (file, maxLines) => {
|
|
26614
26739
|
if (!existsSync10(file))
|
|
26615
26740
|
return "";
|
|
26616
|
-
const lines =
|
|
26741
|
+
const lines = readFileSync11(file, "utf8").split(`
|
|
26617
26742
|
`);
|
|
26618
26743
|
return lines.slice(0, maxLines).join(`
|
|
26619
26744
|
`);
|
|
26620
26745
|
};
|
|
26621
26746
|
function prReadyContext(root, range) {
|
|
26622
|
-
const cwd =
|
|
26747
|
+
const cwd = path27.resolve(repoRoot(root));
|
|
26623
26748
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
26624
26749
|
return invalidRange(cwd);
|
|
26625
26750
|
let stdout = "";
|
|
@@ -26677,7 +26802,7 @@ ${status.stderr}` : "");
|
|
|
26677
26802
|
stdout += `template_path: ${template}
|
|
26678
26803
|
|
|
26679
26804
|
`;
|
|
26680
|
-
stdout += readTrimmed2(
|
|
26805
|
+
stdout += readTrimmed2(path27.join(cwd, template), 220);
|
|
26681
26806
|
} else {
|
|
26682
26807
|
stdout += `template_path: none
|
|
26683
26808
|
|
|
@@ -26687,7 +26812,7 @@ ${status.stderr}` : "");
|
|
|
26687
26812
|
stdout += `
|
|
26688
26813
|
`;
|
|
26689
26814
|
stdout += printSection("Recent Validation Signals");
|
|
26690
|
-
if (existsSync10(
|
|
26815
|
+
if (existsSync10(path27.join(cwd, "package.json"))) {
|
|
26691
26816
|
stdout += `package.json detected. Common scripts:
|
|
26692
26817
|
`;
|
|
26693
26818
|
const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
|
|
@@ -26696,7 +26821,7 @@ ${status.stderr}` : "");
|
|
|
26696
26821
|
`) + `
|
|
26697
26822
|
`;
|
|
26698
26823
|
}
|
|
26699
|
-
if (existsSync10(
|
|
26824
|
+
if (existsSync10(path27.join(cwd, "Cargo.toml")) || existsSync10(path27.join(cwd, "src-tauri/Cargo.toml"))) {
|
|
26700
26825
|
stdout += `Rust project detected.
|
|
26701
26826
|
`;
|
|
26702
26827
|
}
|
|
@@ -26729,7 +26854,7 @@ var CHANGELOG_RULES = `- Use an [Unreleased] section.
|
|
|
26729
26854
|
- Apply with the host-native editor, preserving the repository changelog conventions.
|
|
26730
26855
|
- If Unreleased already has duplicate category headings, normalize_only first.`;
|
|
26731
26856
|
function changelogContext(root, range) {
|
|
26732
|
-
const cwd =
|
|
26857
|
+
const cwd = path27.resolve(repoRoot(root));
|
|
26733
26858
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
26734
26859
|
return invalidRange(cwd);
|
|
26735
26860
|
const resolvedRange = rangeArgOrDefault(range, cwd);
|
|
@@ -26747,7 +26872,7 @@ function changelogContext(root, range) {
|
|
|
26747
26872
|
stdout += CHANGELOG_RULES + `
|
|
26748
26873
|
`;
|
|
26749
26874
|
stdout += printSection("Existing CHANGELOG.md");
|
|
26750
|
-
const changelogPath =
|
|
26875
|
+
const changelogPath = path27.join(cwd, "CHANGELOG.md");
|
|
26751
26876
|
if (existsSync10(changelogPath)) {
|
|
26752
26877
|
stdout += readTrimmed2(changelogPath, 260) + `
|
|
26753
26878
|
`;
|
|
@@ -26767,7 +26892,7 @@ function changelogContext(root, range) {
|
|
|
26767
26892
|
return { stdout, stderr: "", exitCode: 0, cwd };
|
|
26768
26893
|
}
|
|
26769
26894
|
function docsRefreshContext(root, range) {
|
|
26770
|
-
const cwd =
|
|
26895
|
+
const cwd = path27.resolve(repoRoot(root));
|
|
26771
26896
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
26772
26897
|
return invalidRange(cwd);
|
|
26773
26898
|
const resolvedRange = rangeArgOrDefault(range, cwd);
|
|
@@ -26789,7 +26914,7 @@ function docsRefreshContext(root, range) {
|
|
|
26789
26914
|
`) + `
|
|
26790
26915
|
`;
|
|
26791
26916
|
stdout += printSection("README Preview");
|
|
26792
|
-
const readme =
|
|
26917
|
+
const readme = path27.join(cwd, "README.md");
|
|
26793
26918
|
if (existsSync10(readme)) {
|
|
26794
26919
|
stdout += readTrimmed2(readme, 220) + `
|
|
26795
26920
|
`;
|
|
@@ -26798,10 +26923,10 @@ function docsRefreshContext(root, range) {
|
|
|
26798
26923
|
`;
|
|
26799
26924
|
}
|
|
26800
26925
|
stdout += printSection("Package Scripts");
|
|
26801
|
-
const pkgPath =
|
|
26926
|
+
const pkgPath = path27.join(cwd, "package.json");
|
|
26802
26927
|
if (existsSync10(pkgPath)) {
|
|
26803
26928
|
try {
|
|
26804
|
-
const pkg = JSON.parse(
|
|
26929
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
|
|
26805
26930
|
stdout += JSON.stringify({ name: pkg.name, version: pkg.version, scripts: pkg.scripts }, null, 2) + `
|
|
26806
26931
|
`;
|
|
26807
26932
|
} catch {}
|
|
@@ -26812,7 +26937,7 @@ function docsRefreshContext(root, range) {
|
|
|
26812
26937
|
return { stdout, stderr: "", exitCode: 0, cwd };
|
|
26813
26938
|
}
|
|
26814
26939
|
function releaseNotesContext(root, rangeOrTag) {
|
|
26815
|
-
const cwd =
|
|
26940
|
+
const cwd = path27.resolve(repoRoot(root));
|
|
26816
26941
|
if (!rangeOrTag) {
|
|
26817
26942
|
return {
|
|
26818
26943
|
stdout: "",
|
|
@@ -26855,7 +26980,7 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
26855
26980
|
`;
|
|
26856
26981
|
stdout += printSection("Existing Release Files");
|
|
26857
26982
|
for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
|
|
26858
|
-
if (existsSync10(
|
|
26983
|
+
if (existsSync10(path27.join(cwd, rel)))
|
|
26859
26984
|
stdout += rel + `
|
|
26860
26985
|
`;
|
|
26861
26986
|
}
|
|
@@ -26887,7 +27012,7 @@ import { spawnSync as spawnSync18 } from "node:child_process";
|
|
|
26887
27012
|
|
|
26888
27013
|
// packages/workit-core/src/core/pr-create.ts
|
|
26889
27014
|
import fs18 from "node:fs";
|
|
26890
|
-
import
|
|
27015
|
+
import path28 from "node:path";
|
|
26891
27016
|
import { spawnSync as spawnSync17 } from "node:child_process";
|
|
26892
27017
|
// packages/workit-core/src/forge/pr-body.ts
|
|
26893
27018
|
function parseGhIssue(value) {
|
|
@@ -26907,11 +27032,11 @@ var LOCAL = bounded(20000);
|
|
|
26907
27032
|
var NETWORK = bounded(60000);
|
|
26908
27033
|
function whichOnPath(tool) {
|
|
26909
27034
|
const names = process.platform === "win32" ? [tool, `${tool}.exe`, `${tool}.cmd`] : [tool];
|
|
26910
|
-
for (const dir of (process.env.PATH ?? "").split(
|
|
27035
|
+
for (const dir of (process.env.PATH ?? "").split(path28.delimiter)) {
|
|
26911
27036
|
if (!dir)
|
|
26912
27037
|
continue;
|
|
26913
27038
|
for (const name of names) {
|
|
26914
|
-
const candidate =
|
|
27039
|
+
const candidate = path28.join(dir, name);
|
|
26915
27040
|
try {
|
|
26916
27041
|
fs18.accessSync(candidate, fs18.constants.X_OK);
|
|
26917
27042
|
return candidate;
|
|
@@ -27032,7 +27157,7 @@ var fetchGitLabIssueBody = async (ref, root, deps = {}) => {
|
|
|
27032
27157
|
|
|
27033
27158
|
// packages/workit-core/src/core/youtrack.ts
|
|
27034
27159
|
import fs20 from "node:fs";
|
|
27035
|
-
import
|
|
27160
|
+
import path30 from "node:path";
|
|
27036
27161
|
|
|
27037
27162
|
// packages/workit-core/src/core/templates.ts
|
|
27038
27163
|
var repoRoot2 = assetRoot();
|
|
@@ -27047,7 +27172,7 @@ import { spawnSync as spawnSync19 } from "node:child_process";
|
|
|
27047
27172
|
|
|
27048
27173
|
// packages/workit-core/src/forge/exec.ts
|
|
27049
27174
|
import fs19 from "node:fs";
|
|
27050
|
-
import
|
|
27175
|
+
import path29 from "node:path";
|
|
27051
27176
|
|
|
27052
27177
|
// packages/workit-core/src/forge/redact.ts
|
|
27053
27178
|
var KEY = String.raw`[A-Za-z0-9_.-]*?(?:token|secret|password|passwd|pwd|api[_-]?key|access[_-]?key|account[_-]?key|private[_-]?key|client[_-]?secret|credentials?|authorization|cookie|signature)[A-Za-z0-9_.-]*`;
|
|
@@ -27058,11 +27183,11 @@ var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\
|
|
|
27058
27183
|
// packages/workit-core/src/forge/exec.ts
|
|
27059
27184
|
var MAX_BUFFER2 = 64 * 1024 * 1024;
|
|
27060
27185
|
function findExecutable(bin, env) {
|
|
27061
|
-
const dirs = (env.PATH ?? env.Path ?? "").split(
|
|
27186
|
+
const dirs = (env.PATH ?? env.Path ?? "").split(path29.delimiter).filter(Boolean);
|
|
27062
27187
|
const exts = process.platform === "win32" ? [".exe"] : [""];
|
|
27063
27188
|
for (const dir of dirs)
|
|
27064
27189
|
for (const ext of exts) {
|
|
27065
|
-
const candidate =
|
|
27190
|
+
const candidate = path29.join(dir, `${bin}${ext}`);
|
|
27066
27191
|
try {
|
|
27067
27192
|
const stat = fs19.statSync(candidate);
|
|
27068
27193
|
if (stat.isFile())
|
|
@@ -27105,7 +27230,7 @@ var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only throug
|
|
|
27105
27230
|
|
|
27106
27231
|
// packages/workit-core/src/core/youtrack.ts
|
|
27107
27232
|
var ISSUE_RE = /^[A-Z][A-Z0-9_]*-\d+$/;
|
|
27108
|
-
var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ??
|
|
27233
|
+
var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path30.join(resolveConfigDir(), "youtrack.json");
|
|
27109
27234
|
var readYouTrackContextConfig = () => {
|
|
27110
27235
|
const cfgPath = youTrackReadOnlyConfigPath();
|
|
27111
27236
|
if (!fs20.existsSync(cfgPath))
|
|
@@ -27458,15 +27583,15 @@ function resolveGitRevision(root, value) {
|
|
|
27458
27583
|
}
|
|
27459
27584
|
function resolveInside(root, candidate) {
|
|
27460
27585
|
const base = realpathSync8(root);
|
|
27461
|
-
const target =
|
|
27462
|
-
if (target !== base && !target.startsWith(base +
|
|
27586
|
+
const target = path31.resolve(base, candidate);
|
|
27587
|
+
if (target !== base && !target.startsWith(base + path31.sep)) {
|
|
27463
27588
|
throw new Error("path must stay inside repository root");
|
|
27464
27589
|
}
|
|
27465
27590
|
let ancestor = target;
|
|
27466
27591
|
while (!existsSync11(ancestor))
|
|
27467
|
-
ancestor =
|
|
27592
|
+
ancestor = path31.dirname(ancestor);
|
|
27468
27593
|
const canonicalAncestor = realpathSync8(ancestor);
|
|
27469
|
-
if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base +
|
|
27594
|
+
if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path31.sep)) {
|
|
27470
27595
|
throw new Error("path must stay inside repository root");
|
|
27471
27596
|
}
|
|
27472
27597
|
return target;
|
|
@@ -27488,17 +27613,17 @@ function run2(root, executable, args, env = {}) {
|
|
|
27488
27613
|
|
|
27489
27614
|
// packages/workit-core/src/core/cli-locate.ts
|
|
27490
27615
|
import { closeSync as closeSync2, existsSync as existsSync12, openSync as openSync2, readSync } from "node:fs";
|
|
27491
|
-
import
|
|
27616
|
+
import path32 from "node:path";
|
|
27492
27617
|
var LAUNCHER_MARKER = "workit-owned-launcher";
|
|
27493
27618
|
var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
|
|
27494
27619
|
var installRoot = (env, platform = process.platform) => {
|
|
27495
27620
|
if (env.WORKIT_INSTALL_ROOT)
|
|
27496
27621
|
return env.WORKIT_INSTALL_ROOT;
|
|
27497
27622
|
const data = dataDir(env, platform);
|
|
27498
|
-
return platform === "win32" ?
|
|
27623
|
+
return platform === "win32" ? path32.join(data, "install") : data;
|
|
27499
27624
|
};
|
|
27500
|
-
var ownedLauncherPath = (env, platform = process.platform) =>
|
|
27501
|
-
var ownedCurrentEntry = (env, platform = process.platform) =>
|
|
27625
|
+
var ownedLauncherPath = (env, platform = process.platform) => path32.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
|
|
27626
|
+
var ownedCurrentEntry = (env, platform = process.platform) => path32.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
|
|
27502
27627
|
var head = (file) => {
|
|
27503
27628
|
let fd;
|
|
27504
27629
|
try {
|
|
@@ -27525,7 +27650,7 @@ var locateWorkitCli = (options = {}) => {
|
|
|
27525
27650
|
source: "owned-launcher",
|
|
27526
27651
|
command: launcher,
|
|
27527
27652
|
args: [],
|
|
27528
|
-
binDir:
|
|
27653
|
+
binDir: path32.dirname(launcher)
|
|
27529
27654
|
};
|
|
27530
27655
|
const current = ownedCurrentEntry(env, platform);
|
|
27531
27656
|
if (exists(current))
|
|
@@ -27554,7 +27679,7 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
|
|
|
27554
27679
|
if (located.binDir) {
|
|
27555
27680
|
const key = pathKey(env);
|
|
27556
27681
|
const delimiter = platform === "win32" ? ";" : ":";
|
|
27557
|
-
const same = (dir) => platform === "win32" ?
|
|
27682
|
+
const same = (dir) => platform === "win32" ? path32.win32.normalize(dir).toLowerCase() === path32.win32.normalize(located.binDir).toLowerCase() : path32.posix.normalize(dir) === path32.posix.normalize(located.binDir);
|
|
27558
27683
|
const rest = (env[key] ?? "").split(delimiter).filter((dir) => dir && !same(dir));
|
|
27559
27684
|
patch[key] = [located.binDir, ...rest].join(delimiter);
|
|
27560
27685
|
}
|
|
@@ -27578,8 +27703,8 @@ var SUPPORT_MATRIX = {
|
|
|
27578
27703
|
};
|
|
27579
27704
|
|
|
27580
27705
|
// packages/workit-mcp/src/server.ts
|
|
27581
|
-
import { existsSync as existsSync13, readFileSync as
|
|
27582
|
-
import
|
|
27706
|
+
import { existsSync as existsSync13, readFileSync as readFileSync12, realpathSync as realpathSync9 } from "node:fs";
|
|
27707
|
+
import path33 from "node:path";
|
|
27583
27708
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
|
|
27584
27709
|
function isZ4Schema(s) {
|
|
27585
27710
|
const schema = s;
|
|
@@ -29975,11 +30100,11 @@ var changedSourcesSinceLoad = (marker) => {
|
|
|
29975
30100
|
};
|
|
29976
30101
|
|
|
29977
30102
|
// packages/workit-core/src/hooks/repeat-failure.ts
|
|
29978
|
-
import { createHash as
|
|
30103
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
29979
30104
|
var SAME_CALL_FAILED = "Same call failed twice:";
|
|
29980
30105
|
var MAX_SESSIONS = 256;
|
|
29981
30106
|
var stable = (value) => JSON.stringify(value, (_key, entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? Object.fromEntries(Object.entries(entry).toSorted(([a], [b]) => a.localeCompare(b))) : entry) ?? "null";
|
|
29982
|
-
var hashOf = (call) =>
|
|
30107
|
+
var hashOf = (call) => createHash12("sha256").update(call).digest("hex").slice(0, 32);
|
|
29983
30108
|
var record3 = (memo, sessionId, call, failed, next) => {
|
|
29984
30109
|
const previous = memo.get(sessionId);
|
|
29985
30110
|
memo.delete(sessionId);
|
|
@@ -30034,7 +30159,7 @@ var safeCapability = (value, allowed) => allowed.includes(value) ? value : "cont
|
|
|
30034
30159
|
var TOOL_CAPABILITIES = [...CONTEXT_KINDS, "workspace", "native_caller_identity"];
|
|
30035
30160
|
var VERSION = (() => {
|
|
30036
30161
|
try {
|
|
30037
|
-
const packageJson = JSON.parse(
|
|
30162
|
+
const packageJson = JSON.parse(readFileSync12(new URL("../package.json", import.meta.url), "utf8"));
|
|
30038
30163
|
return typeof packageJson.version === "string" ? packageJson.version : "0.0.0";
|
|
30039
30164
|
} catch {
|
|
30040
30165
|
return "0.0.0";
|
|
@@ -30044,13 +30169,13 @@ var rootVariants = (workspaceRoot) => {
|
|
|
30044
30169
|
if (!workspaceRoot)
|
|
30045
30170
|
return [];
|
|
30046
30171
|
const roots = new Set;
|
|
30047
|
-
for (const candidate of [workspaceRoot,
|
|
30048
|
-
if (
|
|
30172
|
+
for (const candidate of [workspaceRoot, path33.resolve(workspaceRoot)]) {
|
|
30173
|
+
if (path33.isAbsolute(candidate) && candidate !== path33.parse(candidate).root)
|
|
30049
30174
|
roots.add(candidate);
|
|
30050
30175
|
}
|
|
30051
30176
|
try {
|
|
30052
30177
|
const canonical = realpathSync9(workspaceRoot);
|
|
30053
|
-
if (canonical !==
|
|
30178
|
+
if (canonical !== path33.parse(canonical).root)
|
|
30054
30179
|
roots.add(canonical);
|
|
30055
30180
|
} catch {}
|
|
30056
30181
|
return [...roots].toSorted((left, right) => right.length - left.length);
|
|
@@ -30132,11 +30257,11 @@ var thrownResult = (tool, error, workspaceRoot) => {
|
|
|
30132
30257
|
};
|
|
30133
30258
|
function createMcpServer(host, contextProvider) {
|
|
30134
30259
|
assertMcpHost(host);
|
|
30135
|
-
const here =
|
|
30260
|
+
const here = path33.dirname(fileURLToPath2(import.meta.url));
|
|
30136
30261
|
const sourceMarker = markSourcesLoaded([
|
|
30137
|
-
|
|
30138
|
-
|
|
30139
|
-
|
|
30262
|
+
path33.join(here, "server.ts"),
|
|
30263
|
+
path33.join(here, "..", "..", "workit-core", "src", "core", "task-contract.ts"),
|
|
30264
|
+
path33.join(here, "..", "..", "workit-core", "src", "core", "task-engine.ts")
|
|
30140
30265
|
].filter((file) => existsSync13(file)));
|
|
30141
30266
|
let staleWarned = false;
|
|
30142
30267
|
const failures = new Map;
|
|
@@ -30475,7 +30600,7 @@ var EXEC = new Set(["exec", "x", "dlx"]);
|
|
|
30475
30600
|
// packages/workit-core/src/core/heavy-words.ts
|
|
30476
30601
|
var HEAVY_WORDS = new Set(("npm npx pnpm pnpx yarn bun bunx deno corepack make gmake docker podman nerdctl " + "python python3 py uv poetry pdm pipenv hatch rye bundle rake nx " + "jest vitest mocha ava tap karma jasmine nyc c8 tsc vue-tsc svelte-check eslint stylelint " + "tslint webpack webpack-cli rollup parcel tsup vite next nuxt nuxi astro ng react-scripts " + "playwright cypress wdio testcafe turbo lerna sonar-scanner sonarless sonarless-mcp go " + "golangci-lint gotestsum staticcheck cargo mvn mvnw gradle gradlew ant sbt bazel bazelisk " + "buck2 dotnet msbuild pytest py.test tox nox mypy pyright pylint coverage maturin pip pip3 " + "rspec rails phpunit pest phpstan psalm composer mix swift xcodebuild flutter dart pod cmake " + "ninja meson ctest scons docker-compose buildah earthly").split(" "));
|
|
30477
30602
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
30478
|
-
import
|
|
30603
|
+
import path34 from "node:path";
|
|
30479
30604
|
|
|
30480
30605
|
// packages/workit-core/src/core/live-session.ts
|
|
30481
30606
|
import { spawnSync as spawnSync21 } from "node:child_process";
|
|
@@ -30516,7 +30641,7 @@ var MUTATING_WORKIT_GIT = new Set(["commit", "branch", "stage", "unstage"]);
|
|
|
30516
30641
|
var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
|
|
30517
30642
|
var PUSHD2 = new Set(["pushd", "push-location"]);
|
|
30518
30643
|
var POPD2 = new Set(["popd", "pop-location"]);
|
|
30519
|
-
var UNKNOWN_DIR =
|
|
30644
|
+
var UNKNOWN_DIR = path34.resolve(path34.parse(process.cwd()).root, ".workit-unknown-dir");
|
|
30520
30645
|
var DECLARERS = new Set(["export", "declare", "typeset", "local", "readonly"]);
|
|
30521
30646
|
var REBINDS_ANY = new Set([
|
|
30522
30647
|
"source",
|
|
@@ -30570,7 +30695,7 @@ var OPENS = new Set(["if", "for", "while", "until", "{"]);
|
|
|
30570
30695
|
var CLOSES = new Set(["fi", "done", "}"]);
|
|
30571
30696
|
var UNFOLLOWED = new Set(["case", "esac", "select", "function"]);
|
|
30572
30697
|
var TRANSPARENT = new Set(["builtin", "command", "time", "!"]);
|
|
30573
|
-
var UNKNOWN_VAR =
|
|
30698
|
+
var UNKNOWN_VAR = path34.resolve(path34.parse(process.cwd()).root, ".workit-unknown-var");
|
|
30574
30699
|
// packages/workit-core/src/core/skill-manifests.ts
|
|
30575
30700
|
if (false) {}
|
|
30576
30701
|
|
|
@@ -30612,12 +30737,12 @@ var PROMPT_INTENTS = [
|
|
|
30612
30737
|
var READERS = new Set("cat sed head tail less more bat nl get-content gc type".split(" "));
|
|
30613
30738
|
// packages/workit-core/src/hooks/hosts/fields.ts
|
|
30614
30739
|
import { existsSync as existsSync14, realpathSync as realpathSync10, statSync as statSync5 } from "node:fs";
|
|
30615
|
-
import
|
|
30740
|
+
import path35 from "node:path";
|
|
30616
30741
|
var isRecord4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
30617
30742
|
var nonEmpty2 = (value) => typeof value === "string" && value.trim() !== "";
|
|
30618
30743
|
var optionalText = (value) => typeof value === "string" ? value : null;
|
|
30619
30744
|
var existingDirectory = (value) => {
|
|
30620
|
-
if (!nonEmpty2(value) || !
|
|
30745
|
+
if (!nonEmpty2(value) || !path35.isAbsolute(value) || !existsSync14(value))
|
|
30621
30746
|
return null;
|
|
30622
30747
|
try {
|
|
30623
30748
|
return statSync5(value).isDirectory() ? realpathSync10(value) : null;
|
|
@@ -31401,13 +31526,13 @@ var PROCESS_START = performance.timeOrigin;
|
|
|
31401
31526
|
// packages/workit-core/src/hooks/run.ts
|
|
31402
31527
|
if (false) {}
|
|
31403
31528
|
// packages/workit-core/src/hooks/budget-signal.ts
|
|
31404
|
-
import { createHash as
|
|
31529
|
+
import { createHash as createHash13 } from "node:crypto";
|
|
31405
31530
|
import fs21 from "node:fs";
|
|
31406
|
-
import
|
|
31407
|
-
var hash2 = (text) =>
|
|
31408
|
-
var budgetDir = (store) =>
|
|
31409
|
-
var agentBase = (store, session, agentId) =>
|
|
31410
|
-
var spawnsFile = (store, session) =>
|
|
31531
|
+
import path36 from "node:path";
|
|
31532
|
+
var hash2 = (text) => createHash13("sha256").update(text).digest("hex").slice(0, 32);
|
|
31533
|
+
var budgetDir = (store) => path36.join(store, "budget");
|
|
31534
|
+
var agentBase = (store, session, agentId) => path36.join(budgetDir(store), hash2(`${session}\x00${agentId ?? ""}`));
|
|
31535
|
+
var spawnsFile = (store, session) => path36.join(budgetDir(store), `spawns-${hash2(session)}.jsonl`);
|
|
31411
31536
|
var spawnBudget = (prompt) => {
|
|
31412
31537
|
const found = /^TIMEBOX:[^\n]*?\b(\d+)\s+tool calls\b/mu.exec(prompt);
|
|
31413
31538
|
const n = found ? Number(found[1]) : NaN;
|
|
@@ -31459,8 +31584,8 @@ var startBudget = (store, session, agentId, n) => {
|
|
|
31459
31584
|
const cutoff = Date.now() - 604800000;
|
|
31460
31585
|
for (const name of fs21.readdirSync(dir))
|
|
31461
31586
|
try {
|
|
31462
|
-
if (fs21.statSync(
|
|
31463
|
-
fs21.rmSync(
|
|
31587
|
+
if (fs21.statSync(path36.join(dir, name)).mtimeMs < cutoff)
|
|
31588
|
+
fs21.rmSync(path36.join(dir, name));
|
|
31464
31589
|
} catch {}
|
|
31465
31590
|
const base = agentBase(store, session, agentId);
|
|
31466
31591
|
fs21.writeFileSync(`${base}.json`, JSON.stringify({ limit: n, told: 0 }));
|
|
@@ -31523,24 +31648,24 @@ import {
|
|
|
31523
31648
|
lstatSync as lstatSync6,
|
|
31524
31649
|
mkdirSync as mkdirSync5,
|
|
31525
31650
|
readdirSync as readdirSync5,
|
|
31526
|
-
readFileSync as
|
|
31651
|
+
readFileSync as readFileSync13,
|
|
31527
31652
|
renameSync as renameSync4,
|
|
31528
31653
|
rmSync as rmSync3,
|
|
31529
31654
|
writeFileSync as writeFileSync5
|
|
31530
31655
|
} from "node:fs";
|
|
31531
31656
|
import os6 from "node:os";
|
|
31532
|
-
import
|
|
31657
|
+
import path37 from "node:path";
|
|
31533
31658
|
var CODEX_AGENT_ROLES = ["verifier", "reviewer", "implementer"];
|
|
31534
31659
|
var CODEX_AGENT_MARKER = "# Generated by Workit";
|
|
31535
31660
|
var codexAgentName = (role) => `workit-${role}`;
|
|
31536
31661
|
var codexAgentFile = (role) => `${codexAgentName(role)}.toml`;
|
|
31537
31662
|
var tomlString = (value) => JSON.stringify(value);
|
|
31538
31663
|
var codexHomeOfInstall = (pluginRoot) => {
|
|
31539
|
-
const parts =
|
|
31664
|
+
const parts = path37.resolve(pluginRoot).split(path37.sep);
|
|
31540
31665
|
const cache = parts.length - 4;
|
|
31541
|
-
return cache >= 2 && parts[cache] === "cache" && parts[cache - 1] === "plugins" ? parts.slice(0, cache - 1).join(
|
|
31666
|
+
return cache >= 2 && parts[cache] === "cache" && parts[cache - 1] === "plugins" ? parts.slice(0, cache - 1).join(path37.sep) || path37.sep : null;
|
|
31542
31667
|
};
|
|
31543
|
-
var codexHomeFor = (pluginRoot, env) => codexHomeOfInstall(pluginRoot) ?? (env.CODEX_HOME ||
|
|
31668
|
+
var codexHomeFor = (pluginRoot, env) => codexHomeOfInstall(pluginRoot) ?? (env.CODEX_HOME || path37.join(env.HOME || os6.homedir(), ".codex"));
|
|
31544
31669
|
var withRoleModel = (content, file, models) => {
|
|
31545
31670
|
const role = CODEX_AGENT_ROLES.find((candidate) => codexAgentFile(candidate) === file);
|
|
31546
31671
|
const chosen = role ? models[role] : undefined;
|
|
@@ -31563,7 +31688,7 @@ var versionAtLeast = (version, min) => {
|
|
|
31563
31688
|
};
|
|
31564
31689
|
var pluginVersion = (pluginRoot) => {
|
|
31565
31690
|
try {
|
|
31566
|
-
const version = JSON.parse(
|
|
31691
|
+
const version = JSON.parse(readFileSync13(path37.join(pluginRoot, "package.json"), "utf8")).version;
|
|
31567
31692
|
return typeof version === "string" && /^\d+\.\d+\.\d+/.test(version) ? version.match(/^\d+\.\d+\.\d+/)[0] : null;
|
|
31568
31693
|
} catch {
|
|
31569
31694
|
return null;
|
|
@@ -31577,15 +31702,15 @@ var lstatOrNull = (file) => {
|
|
|
31577
31702
|
}
|
|
31578
31703
|
};
|
|
31579
31704
|
var installCodexAgents = (pluginRoot, codexHome, models = {}) => {
|
|
31580
|
-
const source =
|
|
31705
|
+
const source = path37.join(pluginRoot, "agents");
|
|
31581
31706
|
if (!existsSync15(source))
|
|
31582
31707
|
return [];
|
|
31583
31708
|
const version = pluginVersion(pluginRoot);
|
|
31584
|
-
const target =
|
|
31709
|
+
const target = path37.join(codexHome, "agents");
|
|
31585
31710
|
const results = [];
|
|
31586
31711
|
for (const file of readdirSync5(source).filter((name) => name.endsWith(".toml")).toSorted()) {
|
|
31587
|
-
const content = withRoleModel(stampCodexAgent(
|
|
31588
|
-
const dest =
|
|
31712
|
+
const content = withRoleModel(stampCodexAgent(readFileSync13(path37.join(source, file), "utf8"), version), file, models);
|
|
31713
|
+
const dest = path37.join(target, file);
|
|
31589
31714
|
const stat = lstatOrNull(dest);
|
|
31590
31715
|
if (stat?.isSymbolicLink()) {
|
|
31591
31716
|
results.push({ file: dest, action: "skipped-symlink" });
|
|
@@ -31607,7 +31732,7 @@ var installCodexAgents = (pluginRoot, codexHome, models = {}) => {
|
|
|
31607
31732
|
results.push({ file: dest, action: "kept-user-file" });
|
|
31608
31733
|
continue;
|
|
31609
31734
|
}
|
|
31610
|
-
const current =
|
|
31735
|
+
const current = readFileSync13(dest, "utf8");
|
|
31611
31736
|
if (current === content) {
|
|
31612
31737
|
results.push({ file: dest, action: "current" });
|
|
31613
31738
|
continue;
|
|
@@ -31621,7 +31746,7 @@ var installCodexAgents = (pluginRoot, codexHome, models = {}) => {
|
|
|
31621
31746
|
results.push({ file: dest, action: "kept-newer-version" });
|
|
31622
31747
|
continue;
|
|
31623
31748
|
}
|
|
31624
|
-
const temp =
|
|
31749
|
+
const temp = path37.join(target, `.${file}.${process.pid}.${Date.now()}.tmp`);
|
|
31625
31750
|
writeFileSync5(temp, content, { flag: "wx" });
|
|
31626
31751
|
try {
|
|
31627
31752
|
renameSync4(temp, dest);
|
|
@@ -31643,8 +31768,8 @@ var codexQualification = (host) => host === "codex_cli" ? { surface: host, cli:
|
|
|
31643
31768
|
var resolveCodexWorkspaceRoot = (pluginRoot, env) => {
|
|
31644
31769
|
const explicit = env.WORKIT_WORKSPACE_ROOT;
|
|
31645
31770
|
const inherited = env.PWD;
|
|
31646
|
-
const candidate = explicit ?? (inherited &&
|
|
31647
|
-
if (!candidate || !
|
|
31771
|
+
const candidate = explicit ?? (inherited && path38.resolve(inherited) !== path38.resolve(pluginRoot) ? inherited : undefined);
|
|
31772
|
+
if (!candidate || !path38.isAbsolute(candidate) || !existsSync16(candidate))
|
|
31648
31773
|
return null;
|
|
31649
31774
|
try {
|
|
31650
31775
|
if (!statSync6(candidate).isDirectory())
|
|
@@ -31683,7 +31808,7 @@ var codexContextProvider = (host = detectCodexSurface(process.env), root) => ({
|
|
|
31683
31808
|
};
|
|
31684
31809
|
}
|
|
31685
31810
|
});
|
|
31686
|
-
var pluginRoot = () =>
|
|
31811
|
+
var pluginRoot = () => path38.resolve(path38.dirname(fileURLToPath3(import.meta.url)), "..");
|
|
31687
31812
|
var codexRoleModels = (cwd) => {
|
|
31688
31813
|
const out = {};
|
|
31689
31814
|
for (const role of ["verifier", "reviewer"]) {
|