@workit-dev/codex 1.11.0 → 1.13.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";
|
|
@@ -17366,6 +17366,22 @@ var retryTransient = (run) => {
|
|
|
17366
17366
|
};
|
|
17367
17367
|
var renameWithRetry = (from, to) => retryTransient(() => fs7.renameSync(from, to));
|
|
17368
17368
|
|
|
17369
|
+
// packages/workit-core/src/core/checkout-leftovers.ts
|
|
17370
|
+
var CHECKOUT_LEFTOVERS = [
|
|
17371
|
+
"workspace.json",
|
|
17372
|
+
"index.json",
|
|
17373
|
+
"tasks",
|
|
17374
|
+
"recovery",
|
|
17375
|
+
"metadata.lock",
|
|
17376
|
+
"store.moved.json",
|
|
17377
|
+
"task-index.json",
|
|
17378
|
+
"checkouts",
|
|
17379
|
+
"blobs",
|
|
17380
|
+
"legacy",
|
|
17381
|
+
"ledger",
|
|
17382
|
+
"keys"
|
|
17383
|
+
];
|
|
17384
|
+
|
|
17369
17385
|
// packages/workit-core/src/store/patch.ts
|
|
17370
17386
|
var isPlainObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17371
17387
|
var equal = (left, right) => {
|
|
@@ -19236,20 +19252,6 @@ var COMPACT_ABOVE = 200;
|
|
|
19236
19252
|
var COMPACT_KEEP = 50;
|
|
19237
19253
|
var AUTO_COMPACT_BYTES = 2 * 1024 * 1024;
|
|
19238
19254
|
var STALE_TEMPORARY_MS = 60 * 60000;
|
|
19239
|
-
var CHECKOUT_LEFTOVERS = [
|
|
19240
|
-
"workspace.json",
|
|
19241
|
-
"index.json",
|
|
19242
|
-
"tasks",
|
|
19243
|
-
"recovery",
|
|
19244
|
-
"metadata.lock",
|
|
19245
|
-
"store.moved.json",
|
|
19246
|
-
"task-index.json",
|
|
19247
|
-
"checkouts",
|
|
19248
|
-
"blobs",
|
|
19249
|
-
"legacy",
|
|
19250
|
-
"ledger",
|
|
19251
|
-
"keys"
|
|
19252
|
-
];
|
|
19253
19255
|
var GENERATED_GITIGNORES = new Set([`*
|
|
19254
19256
|
`, `*
|
|
19255
19257
|
!risk-paths
|
|
@@ -24025,7 +24027,7 @@ var exportDigest = (bundle) => sha256({
|
|
|
24025
24027
|
task: bundle.task
|
|
24026
24028
|
});
|
|
24027
24029
|
// packages/workit-core/src/autonomy.ts
|
|
24028
|
-
import
|
|
24030
|
+
import path26 from "node:path";
|
|
24029
24031
|
|
|
24030
24032
|
// packages/workit-core/src/core/eval-world.ts
|
|
24031
24033
|
import { existsSync as existsSync9, realpathSync as realpathSync5 } from "node:fs";
|
|
@@ -24057,6 +24059,68 @@ var evalWorldEntry = (cwd) => {
|
|
|
24057
24059
|
}
|
|
24058
24060
|
};
|
|
24059
24061
|
|
|
24062
|
+
// packages/workit-core/src/core/grant-seal.ts
|
|
24063
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
24064
|
+
import { readFileSync as readFileSync10 } from "node:fs";
|
|
24065
|
+
import path25 from "node:path";
|
|
24066
|
+
var SEAL_FILE = "workspaces.json.seal";
|
|
24067
|
+
var SEAL_VERSION = 1;
|
|
24068
|
+
var SEAL_COMMAND = "workit workspace seal";
|
|
24069
|
+
var pick2 = (value, keys) => {
|
|
24070
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
24071
|
+
return;
|
|
24072
|
+
const out = Object.fromEntries(keys.flatMap((key) => {
|
|
24073
|
+
const item = value[key];
|
|
24074
|
+
return item === undefined ? [] : [[key, item]];
|
|
24075
|
+
}));
|
|
24076
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
24077
|
+
};
|
|
24078
|
+
var ENTRY_KEYS = [
|
|
24079
|
+
"name",
|
|
24080
|
+
"glob",
|
|
24081
|
+
"remotes",
|
|
24082
|
+
"vcs",
|
|
24083
|
+
"autonomy",
|
|
24084
|
+
"autoApprove",
|
|
24085
|
+
"defaultEndpoint",
|
|
24086
|
+
"verification",
|
|
24087
|
+
"youtrack"
|
|
24088
|
+
];
|
|
24089
|
+
var sealProjection = (entries) => entries.map((entry) => {
|
|
24090
|
+
const all = pick2(entry, ENTRY_KEYS) ?? {};
|
|
24091
|
+
return pick2({
|
|
24092
|
+
...all,
|
|
24093
|
+
vcs: pick2(all.vcs, ["provider", "account"]),
|
|
24094
|
+
youtrack: pick2(all.youtrack, ["writes"])
|
|
24095
|
+
}, ENTRY_KEYS);
|
|
24096
|
+
});
|
|
24097
|
+
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);
|
|
24098
|
+
var sealDigest = (projection) => createHash11("sha256").update(canonical3(projection)).digest("hex");
|
|
24099
|
+
var broken = (reason, sealed = null) => ({
|
|
24100
|
+
state: "broken",
|
|
24101
|
+
reason,
|
|
24102
|
+
sealed
|
|
24103
|
+
});
|
|
24104
|
+
function checkSeal(dir) {
|
|
24105
|
+
const file = path25.join(dir, SEAL_FILE);
|
|
24106
|
+
let seal;
|
|
24107
|
+
try {
|
|
24108
|
+
seal = JSON.parse(readFileSync10(file, "utf8"));
|
|
24109
|
+
} catch (error) {
|
|
24110
|
+
if (error.code === "ENOENT")
|
|
24111
|
+
return { state: "none" };
|
|
24112
|
+
return broken(`${SEAL_FILE} cannot be read`);
|
|
24113
|
+
}
|
|
24114
|
+
if (seal?.version !== SEAL_VERSION || !Array.isArray(seal.projection) || seal.sha256 !== sealDigest(seal.projection))
|
|
24115
|
+
return broken(`${SEAL_FILE} is malformed`);
|
|
24116
|
+
const sealed = validateWorkspacesDocument({ workspaces: seal.projection }, file);
|
|
24117
|
+
if (sealed.status !== "valid")
|
|
24118
|
+
return broken(`${SEAL_FILE} is malformed`);
|
|
24119
|
+
const current = readWorkspacesResult(dir);
|
|
24120
|
+
const ok = current.status === "valid" || current.status === "missing";
|
|
24121
|
+
return ok && sealDigest(sealProjection(current.entries)) === seal.sha256 ? { state: "valid" } : broken("workspaces.json changed since it was sealed", sealed.entries);
|
|
24122
|
+
}
|
|
24123
|
+
|
|
24060
24124
|
// packages/workit-core/src/autonomy.ts
|
|
24061
24125
|
var grantsHome = { resolve: accountHome };
|
|
24062
24126
|
var accountDir = () => {
|
|
@@ -24066,13 +24130,23 @@ var accountDir = () => {
|
|
|
24066
24130
|
var grantsDir = () => accountDir() ?? resolveConfigDir();
|
|
24067
24131
|
var NO_ACCOUNT = "no OS account record answered (core/account-home.ts), so no grants are read: the D4 defaults apply";
|
|
24068
24132
|
var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
|
|
24069
|
-
var
|
|
24133
|
+
var fileSource = (dir = accountDir()) => ({
|
|
24134
|
+
resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom(cwd, dir, name),
|
|
24135
|
+
entries: () => entriesIn(dir)
|
|
24136
|
+
});
|
|
24137
|
+
var sealedSource = (entries) => ({
|
|
24138
|
+
resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name),
|
|
24139
|
+
entries: () => entries
|
|
24140
|
+
});
|
|
24141
|
+
var sealOf = () => {
|
|
24070
24142
|
const dir = accountDir();
|
|
24071
|
-
return dir === null ?
|
|
24143
|
+
return dir === null ? { state: "none" } : checkSeal(dir);
|
|
24072
24144
|
};
|
|
24145
|
+
var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own terminal: ${SEAL_COMMAND}`;
|
|
24146
|
+
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
24147
|
var shownGrantsDir = () => {
|
|
24074
24148
|
const world = evalWorld(process.cwd());
|
|
24075
|
-
return world ?
|
|
24149
|
+
return world ? path26.join(world, "config") : accountDir();
|
|
24076
24150
|
};
|
|
24077
24151
|
var benchWorld = (cwd) => {
|
|
24078
24152
|
const entry = evalWorldEntry(cwd);
|
|
@@ -24096,8 +24170,8 @@ var grantsOverride = () => {
|
|
|
24096
24170
|
const shown = shownGrantsDir();
|
|
24097
24171
|
if (shown === null)
|
|
24098
24172
|
return NO_ACCOUNT;
|
|
24099
|
-
const configured =
|
|
24100
|
-
return configured ===
|
|
24173
|
+
const configured = path26.resolve(resolveConfigDir());
|
|
24174
|
+
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
24175
|
};
|
|
24102
24176
|
var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
|
|
24103
24177
|
var DEFAULT_GRANTS = Object.freeze({
|
|
@@ -24217,13 +24291,13 @@ function autonomyOf(workspace) {
|
|
|
24217
24291
|
verification: verificationOf(workspace)
|
|
24218
24292
|
};
|
|
24219
24293
|
}
|
|
24220
|
-
function capAt(named, where, by, why, main = false) {
|
|
24294
|
+
function capAt(source, named, where, by, why, main = false) {
|
|
24221
24295
|
let folder = null;
|
|
24222
24296
|
let none = "";
|
|
24223
24297
|
try {
|
|
24224
24298
|
if (where instanceof Error)
|
|
24225
24299
|
throw where;
|
|
24226
|
-
folder = autonomyOf(typeof where === "string" ?
|
|
24300
|
+
folder = autonomyOf(typeof where === "string" ? source.resolve(where) : where.entry);
|
|
24227
24301
|
} catch (error) {
|
|
24228
24302
|
none = error.message;
|
|
24229
24303
|
}
|
|
@@ -24266,31 +24340,84 @@ function resolveAutonomy(cwd, target) {
|
|
|
24266
24340
|
const override = world ? null : grantsOverride();
|
|
24267
24341
|
if (override)
|
|
24268
24342
|
return { ...autonomyOf(null), note: override };
|
|
24343
|
+
let resolved;
|
|
24344
|
+
const once = typeof target === "function" ? () => resolved ??= target() : target;
|
|
24345
|
+
const current = resolveWith(fileSource(), cwd, world, once);
|
|
24346
|
+
const seal = sealOf();
|
|
24347
|
+
if (seal.state !== "broken")
|
|
24348
|
+
return current;
|
|
24349
|
+
let sealed = autonomyOf(null);
|
|
24350
|
+
try {
|
|
24351
|
+
if (seal.sealed)
|
|
24352
|
+
sealed = resolveWith(sealedSource(seal.sealed), cwd, world, once);
|
|
24353
|
+
} catch {
|
|
24354
|
+
sealed = null;
|
|
24355
|
+
}
|
|
24356
|
+
return stricter(current, sealed, sealNote(seal));
|
|
24357
|
+
}
|
|
24358
|
+
function resolveWith(source, cwd, world, target) {
|
|
24269
24359
|
const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
24270
|
-
const real =
|
|
24360
|
+
const real = source.resolve(cwd, name);
|
|
24271
24361
|
let autonomy = autonomyOf(real ?? world);
|
|
24272
24362
|
if (!real && world)
|
|
24273
24363
|
autonomy.world = evalWorld(cwd) ?? undefined;
|
|
24274
24364
|
if (name)
|
|
24275
|
-
autonomy = capAt(autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
|
|
24365
|
+
autonomy = capAt(source, autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
|
|
24276
24366
|
const above = checkoutsAbove(cwd);
|
|
24277
24367
|
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);
|
|
24368
|
+
autonomy = capAt(source, autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
|
|
24369
|
+
return capAtRemotes(source, autonomy, cwd, target);
|
|
24280
24370
|
}
|
|
24281
|
-
|
|
24282
|
-
|
|
24371
|
+
var needsAccount = (autonomy) => autonomy.configured.length > 0 && !autonomy.accountConfigured;
|
|
24372
|
+
function stricter(current, sealed, note) {
|
|
24373
|
+
const grants = { ...current.grants };
|
|
24374
|
+
const unblocks = { ...current.unblocks };
|
|
24375
|
+
for (const kind of GRANT_KINDS) {
|
|
24376
|
+
const floor = sealed ? sealed.grants[kind] : false;
|
|
24377
|
+
if (!raises(kind, floor, grants[kind]))
|
|
24378
|
+
continue;
|
|
24379
|
+
grants[kind] = floor;
|
|
24380
|
+
unblocks[kind] = SEAL_UNBLOCK;
|
|
24381
|
+
}
|
|
24382
|
+
const configured = GRANT_KINDS.filter((kind) => current.configured.includes(kind) || sealed?.configured.includes(kind));
|
|
24383
|
+
const accountConfigured = !needsAccount(current) && !(sealed && needsAccount(sealed)) && (current.accountConfigured || Boolean(sealed?.accountConfigured));
|
|
24384
|
+
const lower = (a, b) => raisesEndpoint(a, b) ? a : b;
|
|
24385
|
+
const defaultEndpoint = lower(current.defaultEndpoint, sealed?.defaultEndpoint ?? DEFAULT_ENDPOINT);
|
|
24386
|
+
const effective = effectiveEndpoint(defaultEndpoint, {
|
|
24387
|
+
workspace: current.workspace,
|
|
24388
|
+
grants,
|
|
24389
|
+
configured,
|
|
24390
|
+
accountConfigured
|
|
24391
|
+
});
|
|
24392
|
+
const endpoint = lower(lower(effective.endpoint, current.effectiveEndpoint), sealed?.effectiveEndpoint ?? DEFAULT_ENDPOINT);
|
|
24393
|
+
const strict = sealed?.verification ?? "independent";
|
|
24394
|
+
const looser = VERIFICATION_STRICTNESS.indexOf(current.verification) > VERIFICATION_STRICTNESS.indexOf(strict);
|
|
24395
|
+
return {
|
|
24396
|
+
...current,
|
|
24397
|
+
grants,
|
|
24398
|
+
configured,
|
|
24399
|
+
accountConfigured,
|
|
24400
|
+
defaultEndpoint,
|
|
24401
|
+
effectiveEndpoint: endpoint,
|
|
24402
|
+
endpointReason: endpoint === current.effectiveEndpoint ? current.endpointReason : SEAL_UNBLOCK,
|
|
24403
|
+
verification: looser ? strict : current.verification,
|
|
24404
|
+
unblocks,
|
|
24405
|
+
note: current.note ? `${current.note}; ${note}` : note
|
|
24406
|
+
};
|
|
24407
|
+
}
|
|
24408
|
+
function capAtRemotes(source, autonomy, cwd, target) {
|
|
24409
|
+
const claiming = source.entries().filter((entry) => entry.remotes?.length);
|
|
24283
24410
|
if (claiming.length === 0)
|
|
24284
24411
|
return autonomy;
|
|
24285
24412
|
const remotes = target === undefined ? checkoutRemotes(cwd) : typeof target === "function" ? target() : target;
|
|
24286
24413
|
if (remotes instanceof Error)
|
|
24287
|
-
return capAt(autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
|
|
24414
|
+
return capAt(source, autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
|
|
24288
24415
|
let capped = autonomy;
|
|
24289
24416
|
for (const remote of Array.isArray(remotes) ? remotes : remotes.remotes)
|
|
24290
24417
|
for (const entry of claiming) {
|
|
24291
24418
|
const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
|
|
24292
24419
|
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");
|
|
24420
|
+
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
24421
|
}
|
|
24295
24422
|
return capped;
|
|
24296
24423
|
}
|
|
@@ -26394,8 +26521,8 @@ class WorkitCore {
|
|
|
26394
26521
|
}
|
|
26395
26522
|
// packages/workit-core/src/core/repo-context.ts
|
|
26396
26523
|
import { spawnSync as spawnSync16 } from "node:child_process";
|
|
26397
|
-
import { existsSync as existsSync10, readFileSync as
|
|
26398
|
-
import
|
|
26524
|
+
import { existsSync as existsSync10, readFileSync as readFileSync11, readdirSync as readdirSync4 } from "node:fs";
|
|
26525
|
+
import path27 from "node:path";
|
|
26399
26526
|
var isSafeContextRange = (value) => value.length <= 4096 && (() => {
|
|
26400
26527
|
try {
|
|
26401
26528
|
gitRevisionParts(value);
|
|
@@ -26539,13 +26666,13 @@ var findPrTemplate = (cwd) => {
|
|
|
26539
26666
|
for (const rel of PR_TEMPLATE_FILES) {
|
|
26540
26667
|
const parts = rel.split("/");
|
|
26541
26668
|
const base = parts[parts.length - 1];
|
|
26542
|
-
const dir = parts.length > 1 ?
|
|
26669
|
+
const dir = parts.length > 1 ? path27.join(cwd, ...parts.slice(0, -1)) : cwd;
|
|
26543
26670
|
const actual = probeCaseInsensitive(dir, base);
|
|
26544
26671
|
if (actual)
|
|
26545
26672
|
return [...parts.slice(0, -1), actual].join("/");
|
|
26546
26673
|
}
|
|
26547
26674
|
for (const rel of PR_TEMPLATE_DIRS) {
|
|
26548
|
-
const only = singleMarkdown(
|
|
26675
|
+
const only = singleMarkdown(path27.join(cwd, ...rel.split("/")));
|
|
26549
26676
|
if (only)
|
|
26550
26677
|
return `${rel}/${only}`;
|
|
26551
26678
|
}
|
|
@@ -26575,11 +26702,11 @@ var diffStatForRange = (cwd, range) => {
|
|
|
26575
26702
|
return runGit(cwd, ["diff", "--stat", "--"]).stdout;
|
|
26576
26703
|
};
|
|
26577
26704
|
var packageScripts = (cwd, keys) => {
|
|
26578
|
-
const pkgPath =
|
|
26705
|
+
const pkgPath = path27.join(cwd, "package.json");
|
|
26579
26706
|
if (!existsSync10(pkgPath))
|
|
26580
26707
|
return [];
|
|
26581
26708
|
try {
|
|
26582
|
-
const pkg = JSON.parse(
|
|
26709
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
|
|
26583
26710
|
return keys.filter((k) => pkg.scripts && typeof pkg.scripts[k] === "string").map((k) => `${k}: ${pkg.scripts?.[k]}`);
|
|
26584
26711
|
} catch {
|
|
26585
26712
|
return [];
|
|
@@ -26601,9 +26728,9 @@ var documentationFiles = (cwd) => {
|
|
|
26601
26728
|
if (entry.isDirectory()) {
|
|
26602
26729
|
if (excluded.has(entry.name))
|
|
26603
26730
|
continue;
|
|
26604
|
-
walk(
|
|
26731
|
+
walk(path27.join(dir, entry.name), depth + 1);
|
|
26605
26732
|
} else if (entry.isFile() && (entry.name === "README.md" || entry.name.endsWith(".md"))) {
|
|
26606
|
-
matches.push("./" +
|
|
26733
|
+
matches.push("./" + path27.relative(cwd, path27.join(dir, entry.name)).replaceAll("\\", "/"));
|
|
26607
26734
|
}
|
|
26608
26735
|
}
|
|
26609
26736
|
};
|
|
@@ -26613,13 +26740,13 @@ var documentationFiles = (cwd) => {
|
|
|
26613
26740
|
var readTrimmed2 = (file, maxLines) => {
|
|
26614
26741
|
if (!existsSync10(file))
|
|
26615
26742
|
return "";
|
|
26616
|
-
const lines =
|
|
26743
|
+
const lines = readFileSync11(file, "utf8").split(`
|
|
26617
26744
|
`);
|
|
26618
26745
|
return lines.slice(0, maxLines).join(`
|
|
26619
26746
|
`);
|
|
26620
26747
|
};
|
|
26621
26748
|
function prReadyContext(root, range) {
|
|
26622
|
-
const cwd =
|
|
26749
|
+
const cwd = path27.resolve(repoRoot(root));
|
|
26623
26750
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
26624
26751
|
return invalidRange(cwd);
|
|
26625
26752
|
let stdout = "";
|
|
@@ -26677,7 +26804,7 @@ ${status.stderr}` : "");
|
|
|
26677
26804
|
stdout += `template_path: ${template}
|
|
26678
26805
|
|
|
26679
26806
|
`;
|
|
26680
|
-
stdout += readTrimmed2(
|
|
26807
|
+
stdout += readTrimmed2(path27.join(cwd, template), 220);
|
|
26681
26808
|
} else {
|
|
26682
26809
|
stdout += `template_path: none
|
|
26683
26810
|
|
|
@@ -26687,7 +26814,7 @@ ${status.stderr}` : "");
|
|
|
26687
26814
|
stdout += `
|
|
26688
26815
|
`;
|
|
26689
26816
|
stdout += printSection("Recent Validation Signals");
|
|
26690
|
-
if (existsSync10(
|
|
26817
|
+
if (existsSync10(path27.join(cwd, "package.json"))) {
|
|
26691
26818
|
stdout += `package.json detected. Common scripts:
|
|
26692
26819
|
`;
|
|
26693
26820
|
const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
|
|
@@ -26696,7 +26823,7 @@ ${status.stderr}` : "");
|
|
|
26696
26823
|
`) + `
|
|
26697
26824
|
`;
|
|
26698
26825
|
}
|
|
26699
|
-
if (existsSync10(
|
|
26826
|
+
if (existsSync10(path27.join(cwd, "Cargo.toml")) || existsSync10(path27.join(cwd, "src-tauri/Cargo.toml"))) {
|
|
26700
26827
|
stdout += `Rust project detected.
|
|
26701
26828
|
`;
|
|
26702
26829
|
}
|
|
@@ -26729,7 +26856,7 @@ var CHANGELOG_RULES = `- Use an [Unreleased] section.
|
|
|
26729
26856
|
- Apply with the host-native editor, preserving the repository changelog conventions.
|
|
26730
26857
|
- If Unreleased already has duplicate category headings, normalize_only first.`;
|
|
26731
26858
|
function changelogContext(root, range) {
|
|
26732
|
-
const cwd =
|
|
26859
|
+
const cwd = path27.resolve(repoRoot(root));
|
|
26733
26860
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
26734
26861
|
return invalidRange(cwd);
|
|
26735
26862
|
const resolvedRange = rangeArgOrDefault(range, cwd);
|
|
@@ -26747,7 +26874,7 @@ function changelogContext(root, range) {
|
|
|
26747
26874
|
stdout += CHANGELOG_RULES + `
|
|
26748
26875
|
`;
|
|
26749
26876
|
stdout += printSection("Existing CHANGELOG.md");
|
|
26750
|
-
const changelogPath =
|
|
26877
|
+
const changelogPath = path27.join(cwd, "CHANGELOG.md");
|
|
26751
26878
|
if (existsSync10(changelogPath)) {
|
|
26752
26879
|
stdout += readTrimmed2(changelogPath, 260) + `
|
|
26753
26880
|
`;
|
|
@@ -26767,7 +26894,7 @@ function changelogContext(root, range) {
|
|
|
26767
26894
|
return { stdout, stderr: "", exitCode: 0, cwd };
|
|
26768
26895
|
}
|
|
26769
26896
|
function docsRefreshContext(root, range) {
|
|
26770
|
-
const cwd =
|
|
26897
|
+
const cwd = path27.resolve(repoRoot(root));
|
|
26771
26898
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
26772
26899
|
return invalidRange(cwd);
|
|
26773
26900
|
const resolvedRange = rangeArgOrDefault(range, cwd);
|
|
@@ -26789,7 +26916,7 @@ function docsRefreshContext(root, range) {
|
|
|
26789
26916
|
`) + `
|
|
26790
26917
|
`;
|
|
26791
26918
|
stdout += printSection("README Preview");
|
|
26792
|
-
const readme =
|
|
26919
|
+
const readme = path27.join(cwd, "README.md");
|
|
26793
26920
|
if (existsSync10(readme)) {
|
|
26794
26921
|
stdout += readTrimmed2(readme, 220) + `
|
|
26795
26922
|
`;
|
|
@@ -26798,10 +26925,10 @@ function docsRefreshContext(root, range) {
|
|
|
26798
26925
|
`;
|
|
26799
26926
|
}
|
|
26800
26927
|
stdout += printSection("Package Scripts");
|
|
26801
|
-
const pkgPath =
|
|
26928
|
+
const pkgPath = path27.join(cwd, "package.json");
|
|
26802
26929
|
if (existsSync10(pkgPath)) {
|
|
26803
26930
|
try {
|
|
26804
|
-
const pkg = JSON.parse(
|
|
26931
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
|
|
26805
26932
|
stdout += JSON.stringify({ name: pkg.name, version: pkg.version, scripts: pkg.scripts }, null, 2) + `
|
|
26806
26933
|
`;
|
|
26807
26934
|
} catch {}
|
|
@@ -26812,7 +26939,7 @@ function docsRefreshContext(root, range) {
|
|
|
26812
26939
|
return { stdout, stderr: "", exitCode: 0, cwd };
|
|
26813
26940
|
}
|
|
26814
26941
|
function releaseNotesContext(root, rangeOrTag) {
|
|
26815
|
-
const cwd =
|
|
26942
|
+
const cwd = path27.resolve(repoRoot(root));
|
|
26816
26943
|
if (!rangeOrTag) {
|
|
26817
26944
|
return {
|
|
26818
26945
|
stdout: "",
|
|
@@ -26855,7 +26982,7 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
26855
26982
|
`;
|
|
26856
26983
|
stdout += printSection("Existing Release Files");
|
|
26857
26984
|
for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
|
|
26858
|
-
if (existsSync10(
|
|
26985
|
+
if (existsSync10(path27.join(cwd, rel)))
|
|
26859
26986
|
stdout += rel + `
|
|
26860
26987
|
`;
|
|
26861
26988
|
}
|
|
@@ -26887,7 +27014,7 @@ import { spawnSync as spawnSync18 } from "node:child_process";
|
|
|
26887
27014
|
|
|
26888
27015
|
// packages/workit-core/src/core/pr-create.ts
|
|
26889
27016
|
import fs18 from "node:fs";
|
|
26890
|
-
import
|
|
27017
|
+
import path28 from "node:path";
|
|
26891
27018
|
import { spawnSync as spawnSync17 } from "node:child_process";
|
|
26892
27019
|
// packages/workit-core/src/forge/pr-body.ts
|
|
26893
27020
|
function parseGhIssue(value) {
|
|
@@ -26907,11 +27034,11 @@ var LOCAL = bounded(20000);
|
|
|
26907
27034
|
var NETWORK = bounded(60000);
|
|
26908
27035
|
function whichOnPath(tool) {
|
|
26909
27036
|
const names = process.platform === "win32" ? [tool, `${tool}.exe`, `${tool}.cmd`] : [tool];
|
|
26910
|
-
for (const dir of (process.env.PATH ?? "").split(
|
|
27037
|
+
for (const dir of (process.env.PATH ?? "").split(path28.delimiter)) {
|
|
26911
27038
|
if (!dir)
|
|
26912
27039
|
continue;
|
|
26913
27040
|
for (const name of names) {
|
|
26914
|
-
const candidate =
|
|
27041
|
+
const candidate = path28.join(dir, name);
|
|
26915
27042
|
try {
|
|
26916
27043
|
fs18.accessSync(candidate, fs18.constants.X_OK);
|
|
26917
27044
|
return candidate;
|
|
@@ -27032,7 +27159,7 @@ var fetchGitLabIssueBody = async (ref, root, deps = {}) => {
|
|
|
27032
27159
|
|
|
27033
27160
|
// packages/workit-core/src/core/youtrack.ts
|
|
27034
27161
|
import fs20 from "node:fs";
|
|
27035
|
-
import
|
|
27162
|
+
import path30 from "node:path";
|
|
27036
27163
|
|
|
27037
27164
|
// packages/workit-core/src/core/templates.ts
|
|
27038
27165
|
var repoRoot2 = assetRoot();
|
|
@@ -27047,7 +27174,7 @@ import { spawnSync as spawnSync19 } from "node:child_process";
|
|
|
27047
27174
|
|
|
27048
27175
|
// packages/workit-core/src/forge/exec.ts
|
|
27049
27176
|
import fs19 from "node:fs";
|
|
27050
|
-
import
|
|
27177
|
+
import path29 from "node:path";
|
|
27051
27178
|
|
|
27052
27179
|
// packages/workit-core/src/forge/redact.ts
|
|
27053
27180
|
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 +27185,11 @@ var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\
|
|
|
27058
27185
|
// packages/workit-core/src/forge/exec.ts
|
|
27059
27186
|
var MAX_BUFFER2 = 64 * 1024 * 1024;
|
|
27060
27187
|
function findExecutable(bin, env) {
|
|
27061
|
-
const dirs = (env.PATH ?? env.Path ?? "").split(
|
|
27188
|
+
const dirs = (env.PATH ?? env.Path ?? "").split(path29.delimiter).filter(Boolean);
|
|
27062
27189
|
const exts = process.platform === "win32" ? [".exe"] : [""];
|
|
27063
27190
|
for (const dir of dirs)
|
|
27064
27191
|
for (const ext of exts) {
|
|
27065
|
-
const candidate =
|
|
27192
|
+
const candidate = path29.join(dir, `${bin}${ext}`);
|
|
27066
27193
|
try {
|
|
27067
27194
|
const stat = fs19.statSync(candidate);
|
|
27068
27195
|
if (stat.isFile())
|
|
@@ -27105,7 +27232,7 @@ var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only throug
|
|
|
27105
27232
|
|
|
27106
27233
|
// packages/workit-core/src/core/youtrack.ts
|
|
27107
27234
|
var ISSUE_RE = /^[A-Z][A-Z0-9_]*-\d+$/;
|
|
27108
|
-
var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ??
|
|
27235
|
+
var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path30.join(resolveConfigDir(), "youtrack.json");
|
|
27109
27236
|
var readYouTrackContextConfig = () => {
|
|
27110
27237
|
const cfgPath = youTrackReadOnlyConfigPath();
|
|
27111
27238
|
if (!fs20.existsSync(cfgPath))
|
|
@@ -27458,15 +27585,15 @@ function resolveGitRevision(root, value) {
|
|
|
27458
27585
|
}
|
|
27459
27586
|
function resolveInside(root, candidate) {
|
|
27460
27587
|
const base = realpathSync8(root);
|
|
27461
|
-
const target =
|
|
27462
|
-
if (target !== base && !target.startsWith(base +
|
|
27588
|
+
const target = path31.resolve(base, candidate);
|
|
27589
|
+
if (target !== base && !target.startsWith(base + path31.sep)) {
|
|
27463
27590
|
throw new Error("path must stay inside repository root");
|
|
27464
27591
|
}
|
|
27465
27592
|
let ancestor = target;
|
|
27466
27593
|
while (!existsSync11(ancestor))
|
|
27467
|
-
ancestor =
|
|
27594
|
+
ancestor = path31.dirname(ancestor);
|
|
27468
27595
|
const canonicalAncestor = realpathSync8(ancestor);
|
|
27469
|
-
if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base +
|
|
27596
|
+
if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path31.sep)) {
|
|
27470
27597
|
throw new Error("path must stay inside repository root");
|
|
27471
27598
|
}
|
|
27472
27599
|
return target;
|
|
@@ -27488,17 +27615,17 @@ function run2(root, executable, args, env = {}) {
|
|
|
27488
27615
|
|
|
27489
27616
|
// packages/workit-core/src/core/cli-locate.ts
|
|
27490
27617
|
import { closeSync as closeSync2, existsSync as existsSync12, openSync as openSync2, readSync } from "node:fs";
|
|
27491
|
-
import
|
|
27618
|
+
import path32 from "node:path";
|
|
27492
27619
|
var LAUNCHER_MARKER = "workit-owned-launcher";
|
|
27493
27620
|
var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
|
|
27494
27621
|
var installRoot = (env, platform = process.platform) => {
|
|
27495
27622
|
if (env.WORKIT_INSTALL_ROOT)
|
|
27496
27623
|
return env.WORKIT_INSTALL_ROOT;
|
|
27497
27624
|
const data = dataDir(env, platform);
|
|
27498
|
-
return platform === "win32" ?
|
|
27625
|
+
return platform === "win32" ? path32.join(data, "install") : data;
|
|
27499
27626
|
};
|
|
27500
|
-
var ownedLauncherPath = (env, platform = process.platform) =>
|
|
27501
|
-
var ownedCurrentEntry = (env, platform = process.platform) =>
|
|
27627
|
+
var ownedLauncherPath = (env, platform = process.platform) => path32.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
|
|
27628
|
+
var ownedCurrentEntry = (env, platform = process.platform) => path32.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
|
|
27502
27629
|
var head = (file) => {
|
|
27503
27630
|
let fd;
|
|
27504
27631
|
try {
|
|
@@ -27525,7 +27652,7 @@ var locateWorkitCli = (options = {}) => {
|
|
|
27525
27652
|
source: "owned-launcher",
|
|
27526
27653
|
command: launcher,
|
|
27527
27654
|
args: [],
|
|
27528
|
-
binDir:
|
|
27655
|
+
binDir: path32.dirname(launcher)
|
|
27529
27656
|
};
|
|
27530
27657
|
const current = ownedCurrentEntry(env, platform);
|
|
27531
27658
|
if (exists(current))
|
|
@@ -27554,7 +27681,7 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
|
|
|
27554
27681
|
if (located.binDir) {
|
|
27555
27682
|
const key = pathKey(env);
|
|
27556
27683
|
const delimiter = platform === "win32" ? ";" : ":";
|
|
27557
|
-
const same = (dir) => platform === "win32" ?
|
|
27684
|
+
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
27685
|
const rest = (env[key] ?? "").split(delimiter).filter((dir) => dir && !same(dir));
|
|
27559
27686
|
patch[key] = [located.binDir, ...rest].join(delimiter);
|
|
27560
27687
|
}
|
|
@@ -27578,8 +27705,8 @@ var SUPPORT_MATRIX = {
|
|
|
27578
27705
|
};
|
|
27579
27706
|
|
|
27580
27707
|
// packages/workit-mcp/src/server.ts
|
|
27581
|
-
import { existsSync as existsSync13, readFileSync as
|
|
27582
|
-
import
|
|
27708
|
+
import { existsSync as existsSync13, readFileSync as readFileSync12, realpathSync as realpathSync9 } from "node:fs";
|
|
27709
|
+
import path33 from "node:path";
|
|
27583
27710
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
|
|
27584
27711
|
function isZ4Schema(s) {
|
|
27585
27712
|
const schema = s;
|
|
@@ -29975,11 +30102,11 @@ var changedSourcesSinceLoad = (marker) => {
|
|
|
29975
30102
|
};
|
|
29976
30103
|
|
|
29977
30104
|
// packages/workit-core/src/hooks/repeat-failure.ts
|
|
29978
|
-
import { createHash as
|
|
30105
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
29979
30106
|
var SAME_CALL_FAILED = "Same call failed twice:";
|
|
29980
30107
|
var MAX_SESSIONS = 256;
|
|
29981
30108
|
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) =>
|
|
30109
|
+
var hashOf = (call) => createHash12("sha256").update(call).digest("hex").slice(0, 32);
|
|
29983
30110
|
var record3 = (memo, sessionId, call, failed, next) => {
|
|
29984
30111
|
const previous = memo.get(sessionId);
|
|
29985
30112
|
memo.delete(sessionId);
|
|
@@ -30034,7 +30161,7 @@ var safeCapability = (value, allowed) => allowed.includes(value) ? value : "cont
|
|
|
30034
30161
|
var TOOL_CAPABILITIES = [...CONTEXT_KINDS, "workspace", "native_caller_identity"];
|
|
30035
30162
|
var VERSION = (() => {
|
|
30036
30163
|
try {
|
|
30037
|
-
const packageJson = JSON.parse(
|
|
30164
|
+
const packageJson = JSON.parse(readFileSync12(new URL("../package.json", import.meta.url), "utf8"));
|
|
30038
30165
|
return typeof packageJson.version === "string" ? packageJson.version : "0.0.0";
|
|
30039
30166
|
} catch {
|
|
30040
30167
|
return "0.0.0";
|
|
@@ -30044,13 +30171,13 @@ var rootVariants = (workspaceRoot) => {
|
|
|
30044
30171
|
if (!workspaceRoot)
|
|
30045
30172
|
return [];
|
|
30046
30173
|
const roots = new Set;
|
|
30047
|
-
for (const candidate of [workspaceRoot,
|
|
30048
|
-
if (
|
|
30174
|
+
for (const candidate of [workspaceRoot, path33.resolve(workspaceRoot)]) {
|
|
30175
|
+
if (path33.isAbsolute(candidate) && candidate !== path33.parse(candidate).root)
|
|
30049
30176
|
roots.add(candidate);
|
|
30050
30177
|
}
|
|
30051
30178
|
try {
|
|
30052
30179
|
const canonical = realpathSync9(workspaceRoot);
|
|
30053
|
-
if (canonical !==
|
|
30180
|
+
if (canonical !== path33.parse(canonical).root)
|
|
30054
30181
|
roots.add(canonical);
|
|
30055
30182
|
} catch {}
|
|
30056
30183
|
return [...roots].toSorted((left, right) => right.length - left.length);
|
|
@@ -30132,11 +30259,11 @@ var thrownResult = (tool, error, workspaceRoot) => {
|
|
|
30132
30259
|
};
|
|
30133
30260
|
function createMcpServer(host, contextProvider) {
|
|
30134
30261
|
assertMcpHost(host);
|
|
30135
|
-
const here =
|
|
30262
|
+
const here = path33.dirname(fileURLToPath2(import.meta.url));
|
|
30136
30263
|
const sourceMarker = markSourcesLoaded([
|
|
30137
|
-
|
|
30138
|
-
|
|
30139
|
-
|
|
30264
|
+
path33.join(here, "server.ts"),
|
|
30265
|
+
path33.join(here, "..", "..", "workit-core", "src", "core", "task-contract.ts"),
|
|
30266
|
+
path33.join(here, "..", "..", "workit-core", "src", "core", "task-engine.ts")
|
|
30140
30267
|
].filter((file) => existsSync13(file)));
|
|
30141
30268
|
let staleWarned = false;
|
|
30142
30269
|
const failures = new Map;
|
|
@@ -30475,7 +30602,7 @@ var EXEC = new Set(["exec", "x", "dlx"]);
|
|
|
30475
30602
|
// packages/workit-core/src/core/heavy-words.ts
|
|
30476
30603
|
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
30604
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
30478
|
-
import
|
|
30605
|
+
import path34 from "node:path";
|
|
30479
30606
|
|
|
30480
30607
|
// packages/workit-core/src/core/live-session.ts
|
|
30481
30608
|
import { spawnSync as spawnSync21 } from "node:child_process";
|
|
@@ -30516,7 +30643,7 @@ var MUTATING_WORKIT_GIT = new Set(["commit", "branch", "stage", "unstage"]);
|
|
|
30516
30643
|
var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
|
|
30517
30644
|
var PUSHD2 = new Set(["pushd", "push-location"]);
|
|
30518
30645
|
var POPD2 = new Set(["popd", "pop-location"]);
|
|
30519
|
-
var UNKNOWN_DIR =
|
|
30646
|
+
var UNKNOWN_DIR = path34.resolve(path34.parse(process.cwd()).root, ".workit-unknown-dir");
|
|
30520
30647
|
var DECLARERS = new Set(["export", "declare", "typeset", "local", "readonly"]);
|
|
30521
30648
|
var REBINDS_ANY = new Set([
|
|
30522
30649
|
"source",
|
|
@@ -30570,7 +30697,7 @@ var OPENS = new Set(["if", "for", "while", "until", "{"]);
|
|
|
30570
30697
|
var CLOSES = new Set(["fi", "done", "}"]);
|
|
30571
30698
|
var UNFOLLOWED = new Set(["case", "esac", "select", "function"]);
|
|
30572
30699
|
var TRANSPARENT = new Set(["builtin", "command", "time", "!"]);
|
|
30573
|
-
var UNKNOWN_VAR =
|
|
30700
|
+
var UNKNOWN_VAR = path34.resolve(path34.parse(process.cwd()).root, ".workit-unknown-var");
|
|
30574
30701
|
// packages/workit-core/src/core/skill-manifests.ts
|
|
30575
30702
|
if (false) {}
|
|
30576
30703
|
|
|
@@ -30612,12 +30739,12 @@ var PROMPT_INTENTS = [
|
|
|
30612
30739
|
var READERS = new Set("cat sed head tail less more bat nl get-content gc type".split(" "));
|
|
30613
30740
|
// packages/workit-core/src/hooks/hosts/fields.ts
|
|
30614
30741
|
import { existsSync as existsSync14, realpathSync as realpathSync10, statSync as statSync5 } from "node:fs";
|
|
30615
|
-
import
|
|
30742
|
+
import path35 from "node:path";
|
|
30616
30743
|
var isRecord4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
30617
30744
|
var nonEmpty2 = (value) => typeof value === "string" && value.trim() !== "";
|
|
30618
30745
|
var optionalText = (value) => typeof value === "string" ? value : null;
|
|
30619
30746
|
var existingDirectory = (value) => {
|
|
30620
|
-
if (!nonEmpty2(value) || !
|
|
30747
|
+
if (!nonEmpty2(value) || !path35.isAbsolute(value) || !existsSync14(value))
|
|
30621
30748
|
return null;
|
|
30622
30749
|
try {
|
|
30623
30750
|
return statSync5(value).isDirectory() ? realpathSync10(value) : null;
|
|
@@ -31401,13 +31528,13 @@ var PROCESS_START = performance.timeOrigin;
|
|
|
31401
31528
|
// packages/workit-core/src/hooks/run.ts
|
|
31402
31529
|
if (false) {}
|
|
31403
31530
|
// packages/workit-core/src/hooks/budget-signal.ts
|
|
31404
|
-
import { createHash as
|
|
31531
|
+
import { createHash as createHash13 } from "node:crypto";
|
|
31405
31532
|
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) =>
|
|
31533
|
+
import path36 from "node:path";
|
|
31534
|
+
var hash2 = (text) => createHash13("sha256").update(text).digest("hex").slice(0, 32);
|
|
31535
|
+
var budgetDir = (store) => path36.join(store, "budget");
|
|
31536
|
+
var agentBase = (store, session, agentId) => path36.join(budgetDir(store), hash2(`${session}\x00${agentId ?? ""}`));
|
|
31537
|
+
var spawnsFile = (store, session) => path36.join(budgetDir(store), `spawns-${hash2(session)}.jsonl`);
|
|
31411
31538
|
var spawnBudget = (prompt) => {
|
|
31412
31539
|
const found = /^TIMEBOX:[^\n]*?\b(\d+)\s+tool calls\b/mu.exec(prompt);
|
|
31413
31540
|
const n = found ? Number(found[1]) : NaN;
|
|
@@ -31459,8 +31586,8 @@ var startBudget = (store, session, agentId, n) => {
|
|
|
31459
31586
|
const cutoff = Date.now() - 604800000;
|
|
31460
31587
|
for (const name of fs21.readdirSync(dir))
|
|
31461
31588
|
try {
|
|
31462
|
-
if (fs21.statSync(
|
|
31463
|
-
fs21.rmSync(
|
|
31589
|
+
if (fs21.statSync(path36.join(dir, name)).mtimeMs < cutoff)
|
|
31590
|
+
fs21.rmSync(path36.join(dir, name));
|
|
31464
31591
|
} catch {}
|
|
31465
31592
|
const base = agentBase(store, session, agentId);
|
|
31466
31593
|
fs21.writeFileSync(`${base}.json`, JSON.stringify({ limit: n, told: 0 }));
|
|
@@ -31523,24 +31650,24 @@ import {
|
|
|
31523
31650
|
lstatSync as lstatSync6,
|
|
31524
31651
|
mkdirSync as mkdirSync5,
|
|
31525
31652
|
readdirSync as readdirSync5,
|
|
31526
|
-
readFileSync as
|
|
31653
|
+
readFileSync as readFileSync13,
|
|
31527
31654
|
renameSync as renameSync4,
|
|
31528
31655
|
rmSync as rmSync3,
|
|
31529
31656
|
writeFileSync as writeFileSync5
|
|
31530
31657
|
} from "node:fs";
|
|
31531
31658
|
import os6 from "node:os";
|
|
31532
|
-
import
|
|
31659
|
+
import path37 from "node:path";
|
|
31533
31660
|
var CODEX_AGENT_ROLES = ["verifier", "reviewer", "implementer"];
|
|
31534
31661
|
var CODEX_AGENT_MARKER = "# Generated by Workit";
|
|
31535
31662
|
var codexAgentName = (role) => `workit-${role}`;
|
|
31536
31663
|
var codexAgentFile = (role) => `${codexAgentName(role)}.toml`;
|
|
31537
31664
|
var tomlString = (value) => JSON.stringify(value);
|
|
31538
31665
|
var codexHomeOfInstall = (pluginRoot) => {
|
|
31539
|
-
const parts =
|
|
31666
|
+
const parts = path37.resolve(pluginRoot).split(path37.sep);
|
|
31540
31667
|
const cache = parts.length - 4;
|
|
31541
|
-
return cache >= 2 && parts[cache] === "cache" && parts[cache - 1] === "plugins" ? parts.slice(0, cache - 1).join(
|
|
31668
|
+
return cache >= 2 && parts[cache] === "cache" && parts[cache - 1] === "plugins" ? parts.slice(0, cache - 1).join(path37.sep) || path37.sep : null;
|
|
31542
31669
|
};
|
|
31543
|
-
var codexHomeFor = (pluginRoot, env) => codexHomeOfInstall(pluginRoot) ?? (env.CODEX_HOME ||
|
|
31670
|
+
var codexHomeFor = (pluginRoot, env) => codexHomeOfInstall(pluginRoot) ?? (env.CODEX_HOME || path37.join(env.HOME || os6.homedir(), ".codex"));
|
|
31544
31671
|
var withRoleModel = (content, file, models) => {
|
|
31545
31672
|
const role = CODEX_AGENT_ROLES.find((candidate) => codexAgentFile(candidate) === file);
|
|
31546
31673
|
const chosen = role ? models[role] : undefined;
|
|
@@ -31563,7 +31690,7 @@ var versionAtLeast = (version, min) => {
|
|
|
31563
31690
|
};
|
|
31564
31691
|
var pluginVersion = (pluginRoot) => {
|
|
31565
31692
|
try {
|
|
31566
|
-
const version = JSON.parse(
|
|
31693
|
+
const version = JSON.parse(readFileSync13(path37.join(pluginRoot, "package.json"), "utf8")).version;
|
|
31567
31694
|
return typeof version === "string" && /^\d+\.\d+\.\d+/.test(version) ? version.match(/^\d+\.\d+\.\d+/)[0] : null;
|
|
31568
31695
|
} catch {
|
|
31569
31696
|
return null;
|
|
@@ -31577,15 +31704,15 @@ var lstatOrNull = (file) => {
|
|
|
31577
31704
|
}
|
|
31578
31705
|
};
|
|
31579
31706
|
var installCodexAgents = (pluginRoot, codexHome, models = {}) => {
|
|
31580
|
-
const source =
|
|
31707
|
+
const source = path37.join(pluginRoot, "agents");
|
|
31581
31708
|
if (!existsSync15(source))
|
|
31582
31709
|
return [];
|
|
31583
31710
|
const version = pluginVersion(pluginRoot);
|
|
31584
|
-
const target =
|
|
31711
|
+
const target = path37.join(codexHome, "agents");
|
|
31585
31712
|
const results = [];
|
|
31586
31713
|
for (const file of readdirSync5(source).filter((name) => name.endsWith(".toml")).toSorted()) {
|
|
31587
|
-
const content = withRoleModel(stampCodexAgent(
|
|
31588
|
-
const dest =
|
|
31714
|
+
const content = withRoleModel(stampCodexAgent(readFileSync13(path37.join(source, file), "utf8"), version), file, models);
|
|
31715
|
+
const dest = path37.join(target, file);
|
|
31589
31716
|
const stat = lstatOrNull(dest);
|
|
31590
31717
|
if (stat?.isSymbolicLink()) {
|
|
31591
31718
|
results.push({ file: dest, action: "skipped-symlink" });
|
|
@@ -31607,7 +31734,7 @@ var installCodexAgents = (pluginRoot, codexHome, models = {}) => {
|
|
|
31607
31734
|
results.push({ file: dest, action: "kept-user-file" });
|
|
31608
31735
|
continue;
|
|
31609
31736
|
}
|
|
31610
|
-
const current =
|
|
31737
|
+
const current = readFileSync13(dest, "utf8");
|
|
31611
31738
|
if (current === content) {
|
|
31612
31739
|
results.push({ file: dest, action: "current" });
|
|
31613
31740
|
continue;
|
|
@@ -31621,7 +31748,7 @@ var installCodexAgents = (pluginRoot, codexHome, models = {}) => {
|
|
|
31621
31748
|
results.push({ file: dest, action: "kept-newer-version" });
|
|
31622
31749
|
continue;
|
|
31623
31750
|
}
|
|
31624
|
-
const temp =
|
|
31751
|
+
const temp = path37.join(target, `.${file}.${process.pid}.${Date.now()}.tmp`);
|
|
31625
31752
|
writeFileSync5(temp, content, { flag: "wx" });
|
|
31626
31753
|
try {
|
|
31627
31754
|
renameSync4(temp, dest);
|
|
@@ -31643,8 +31770,8 @@ var codexQualification = (host) => host === "codex_cli" ? { surface: host, cli:
|
|
|
31643
31770
|
var resolveCodexWorkspaceRoot = (pluginRoot, env) => {
|
|
31644
31771
|
const explicit = env.WORKIT_WORKSPACE_ROOT;
|
|
31645
31772
|
const inherited = env.PWD;
|
|
31646
|
-
const candidate = explicit ?? (inherited &&
|
|
31647
|
-
if (!candidate || !
|
|
31773
|
+
const candidate = explicit ?? (inherited && path38.resolve(inherited) !== path38.resolve(pluginRoot) ? inherited : undefined);
|
|
31774
|
+
if (!candidate || !path38.isAbsolute(candidate) || !existsSync16(candidate))
|
|
31648
31775
|
return null;
|
|
31649
31776
|
try {
|
|
31650
31777
|
if (!statSync6(candidate).isDirectory())
|
|
@@ -31683,7 +31810,7 @@ var codexContextProvider = (host = detectCodexSurface(process.env), root) => ({
|
|
|
31683
31810
|
};
|
|
31684
31811
|
}
|
|
31685
31812
|
});
|
|
31686
|
-
var pluginRoot = () =>
|
|
31813
|
+
var pluginRoot = () => path38.resolve(path38.dirname(fileURLToPath3(import.meta.url)), "..");
|
|
31687
31814
|
var codexRoleModels = (cwd) => {
|
|
31688
31815
|
const out = {};
|
|
31689
31816
|
for (const role of ["verifier", "reviewer"]) {
|