@workit-dev/mcp 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/index.js +206 -79
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6620,11 +6620,11 @@ var require_dist = __commonJS(function(exports, module) {
|
|
|
6620
6620
|
|
|
6621
6621
|
// packages/workit-mcp/src/index.ts
|
|
6622
6622
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
6623
|
-
import
|
|
6623
|
+
import path31 from "node:path";
|
|
6624
6624
|
|
|
6625
6625
|
// packages/workit-mcp/src/server.ts
|
|
6626
|
-
import { existsSync as existsSync12, readFileSync as
|
|
6627
|
-
import
|
|
6626
|
+
import { existsSync as existsSync12, readFileSync as readFileSync11, realpathSync as realpathSync9 } from "node:fs";
|
|
6627
|
+
import path30 from "node:path";
|
|
6628
6628
|
|
|
6629
6629
|
// node_modules/zod/v4/core/util.js
|
|
6630
6630
|
function getEnumValues(entries) {
|
|
@@ -14938,7 +14938,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
|
14938
14938
|
// packages/workit-core/src/core.ts
|
|
14939
14939
|
import { spawnSync as spawnSync20 } from "node:child_process";
|
|
14940
14940
|
import { existsSync as existsSync11, realpathSync as realpathSync8 } from "node:fs";
|
|
14941
|
-
import
|
|
14941
|
+
import path29 from "node:path";
|
|
14942
14942
|
|
|
14943
14943
|
// packages/workit-core/src/core/task-contract.ts
|
|
14944
14944
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -19713,6 +19713,22 @@ var retryTransient = (run) => {
|
|
|
19713
19713
|
};
|
|
19714
19714
|
var renameWithRetry = (from, to) => retryTransient(() => fs7.renameSync(from, to));
|
|
19715
19715
|
|
|
19716
|
+
// packages/workit-core/src/core/checkout-leftovers.ts
|
|
19717
|
+
var CHECKOUT_LEFTOVERS = [
|
|
19718
|
+
"workspace.json",
|
|
19719
|
+
"index.json",
|
|
19720
|
+
"tasks",
|
|
19721
|
+
"recovery",
|
|
19722
|
+
"metadata.lock",
|
|
19723
|
+
"store.moved.json",
|
|
19724
|
+
"task-index.json",
|
|
19725
|
+
"checkouts",
|
|
19726
|
+
"blobs",
|
|
19727
|
+
"legacy",
|
|
19728
|
+
"ledger",
|
|
19729
|
+
"keys"
|
|
19730
|
+
];
|
|
19731
|
+
|
|
19716
19732
|
// packages/workit-core/src/store/patch.ts
|
|
19717
19733
|
var isPlainObject3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19718
19734
|
var equal = (left, right) => {
|
|
@@ -21583,20 +21599,6 @@ var COMPACT_ABOVE = 200;
|
|
|
21583
21599
|
var COMPACT_KEEP = 50;
|
|
21584
21600
|
var AUTO_COMPACT_BYTES = 2 * 1024 * 1024;
|
|
21585
21601
|
var STALE_TEMPORARY_MS = 60 * 60000;
|
|
21586
|
-
var CHECKOUT_LEFTOVERS = [
|
|
21587
|
-
"workspace.json",
|
|
21588
|
-
"index.json",
|
|
21589
|
-
"tasks",
|
|
21590
|
-
"recovery",
|
|
21591
|
-
"metadata.lock",
|
|
21592
|
-
"store.moved.json",
|
|
21593
|
-
"task-index.json",
|
|
21594
|
-
"checkouts",
|
|
21595
|
-
"blobs",
|
|
21596
|
-
"legacy",
|
|
21597
|
-
"ledger",
|
|
21598
|
-
"keys"
|
|
21599
|
-
];
|
|
21600
21602
|
var GENERATED_GITIGNORES = new Set([`*
|
|
21601
21603
|
`, `*
|
|
21602
21604
|
!risk-paths
|
|
@@ -26202,7 +26204,7 @@ var exportDigest = (bundle) => sha256({
|
|
|
26202
26204
|
task: bundle.task
|
|
26203
26205
|
});
|
|
26204
26206
|
// packages/workit-core/src/autonomy.ts
|
|
26205
|
-
import
|
|
26207
|
+
import path24 from "node:path";
|
|
26206
26208
|
|
|
26207
26209
|
// packages/workit-core/src/core/eval-world.ts
|
|
26208
26210
|
import { existsSync as existsSync9, realpathSync as realpathSync5 } from "node:fs";
|
|
@@ -26234,6 +26236,68 @@ var evalWorldEntry = (cwd) => {
|
|
|
26234
26236
|
}
|
|
26235
26237
|
};
|
|
26236
26238
|
|
|
26239
|
+
// packages/workit-core/src/core/grant-seal.ts
|
|
26240
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
26241
|
+
import { readFileSync as readFileSync9 } from "node:fs";
|
|
26242
|
+
import path23 from "node:path";
|
|
26243
|
+
var SEAL_FILE = "workspaces.json.seal";
|
|
26244
|
+
var SEAL_VERSION = 1;
|
|
26245
|
+
var SEAL_COMMAND = "workit workspace seal";
|
|
26246
|
+
var pick2 = (value, keys) => {
|
|
26247
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
26248
|
+
return;
|
|
26249
|
+
const out = Object.fromEntries(keys.flatMap((key) => {
|
|
26250
|
+
const item = value[key];
|
|
26251
|
+
return item === undefined ? [] : [[key, item]];
|
|
26252
|
+
}));
|
|
26253
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
26254
|
+
};
|
|
26255
|
+
var ENTRY_KEYS = [
|
|
26256
|
+
"name",
|
|
26257
|
+
"glob",
|
|
26258
|
+
"remotes",
|
|
26259
|
+
"vcs",
|
|
26260
|
+
"autonomy",
|
|
26261
|
+
"autoApprove",
|
|
26262
|
+
"defaultEndpoint",
|
|
26263
|
+
"verification",
|
|
26264
|
+
"youtrack"
|
|
26265
|
+
];
|
|
26266
|
+
var sealProjection = (entries) => entries.map((entry) => {
|
|
26267
|
+
const all = pick2(entry, ENTRY_KEYS) ?? {};
|
|
26268
|
+
return pick2({
|
|
26269
|
+
...all,
|
|
26270
|
+
vcs: pick2(all.vcs, ["provider", "account"]),
|
|
26271
|
+
youtrack: pick2(all.youtrack, ["writes"])
|
|
26272
|
+
}, ENTRY_KEYS);
|
|
26273
|
+
});
|
|
26274
|
+
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);
|
|
26275
|
+
var sealDigest = (projection) => createHash11("sha256").update(canonical3(projection)).digest("hex");
|
|
26276
|
+
var broken = (reason, sealed = null) => ({
|
|
26277
|
+
state: "broken",
|
|
26278
|
+
reason,
|
|
26279
|
+
sealed
|
|
26280
|
+
});
|
|
26281
|
+
function checkSeal(dir) {
|
|
26282
|
+
const file = path23.join(dir, SEAL_FILE);
|
|
26283
|
+
let seal;
|
|
26284
|
+
try {
|
|
26285
|
+
seal = JSON.parse(readFileSync9(file, "utf8"));
|
|
26286
|
+
} catch (error) {
|
|
26287
|
+
if (error.code === "ENOENT")
|
|
26288
|
+
return { state: "none" };
|
|
26289
|
+
return broken(`${SEAL_FILE} cannot be read`);
|
|
26290
|
+
}
|
|
26291
|
+
if (seal?.version !== SEAL_VERSION || !Array.isArray(seal.projection) || seal.sha256 !== sealDigest(seal.projection))
|
|
26292
|
+
return broken(`${SEAL_FILE} is malformed`);
|
|
26293
|
+
const sealed = validateWorkspacesDocument({ workspaces: seal.projection }, file);
|
|
26294
|
+
if (sealed.status !== "valid")
|
|
26295
|
+
return broken(`${SEAL_FILE} is malformed`);
|
|
26296
|
+
const current = readWorkspacesResult(dir);
|
|
26297
|
+
const ok = current.status === "valid" || current.status === "missing";
|
|
26298
|
+
return ok && sealDigest(sealProjection(current.entries)) === seal.sha256 ? { state: "valid" } : broken("workspaces.json changed since it was sealed", sealed.entries);
|
|
26299
|
+
}
|
|
26300
|
+
|
|
26237
26301
|
// packages/workit-core/src/autonomy.ts
|
|
26238
26302
|
var grantsHome = { resolve: accountHome };
|
|
26239
26303
|
var accountDir = () => {
|
|
@@ -26243,13 +26307,23 @@ var accountDir = () => {
|
|
|
26243
26307
|
var grantsDir = () => accountDir() ?? resolveConfigDir();
|
|
26244
26308
|
var NO_ACCOUNT = "no OS account record answered (core/account-home.ts), so no grants are read: the D4 defaults apply";
|
|
26245
26309
|
var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
|
|
26246
|
-
var
|
|
26310
|
+
var fileSource = (dir = accountDir()) => ({
|
|
26311
|
+
resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom(cwd, dir, name),
|
|
26312
|
+
entries: () => entriesIn(dir)
|
|
26313
|
+
});
|
|
26314
|
+
var sealedSource = (entries) => ({
|
|
26315
|
+
resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name),
|
|
26316
|
+
entries: () => entries
|
|
26317
|
+
});
|
|
26318
|
+
var sealOf = () => {
|
|
26247
26319
|
const dir = accountDir();
|
|
26248
|
-
return dir === null ?
|
|
26320
|
+
return dir === null ? { state: "none" } : checkSeal(dir);
|
|
26249
26321
|
};
|
|
26322
|
+
var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own terminal: ${SEAL_COMMAND}`;
|
|
26323
|
+
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;
|
|
26250
26324
|
var shownGrantsDir = () => {
|
|
26251
26325
|
const world = evalWorld(process.cwd());
|
|
26252
|
-
return world ?
|
|
26326
|
+
return world ? path24.join(world, "config") : accountDir();
|
|
26253
26327
|
};
|
|
26254
26328
|
var benchWorld = (cwd) => {
|
|
26255
26329
|
const entry = evalWorldEntry(cwd);
|
|
@@ -26273,8 +26347,8 @@ var grantsOverride = () => {
|
|
|
26273
26347
|
const shown = shownGrantsDir();
|
|
26274
26348
|
if (shown === null)
|
|
26275
26349
|
return NO_ACCOUNT;
|
|
26276
|
-
const configured =
|
|
26277
|
-
return configured ===
|
|
26350
|
+
const configured = path24.resolve(resolveConfigDir());
|
|
26351
|
+
return configured === path24.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 ${path24.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
|
|
26278
26352
|
};
|
|
26279
26353
|
var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
|
|
26280
26354
|
var DEFAULT_GRANTS = Object.freeze({
|
|
@@ -26394,13 +26468,13 @@ function autonomyOf(workspace) {
|
|
|
26394
26468
|
verification: verificationOf(workspace)
|
|
26395
26469
|
};
|
|
26396
26470
|
}
|
|
26397
|
-
function capAt(named, where, by, why, main = false) {
|
|
26471
|
+
function capAt(source, named, where, by, why, main = false) {
|
|
26398
26472
|
let folder = null;
|
|
26399
26473
|
let none = "";
|
|
26400
26474
|
try {
|
|
26401
26475
|
if (where instanceof Error)
|
|
26402
26476
|
throw where;
|
|
26403
|
-
folder = autonomyOf(typeof where === "string" ?
|
|
26477
|
+
folder = autonomyOf(typeof where === "string" ? source.resolve(where) : where.entry);
|
|
26404
26478
|
} catch (error) {
|
|
26405
26479
|
none = error.message;
|
|
26406
26480
|
}
|
|
@@ -26443,31 +26517,84 @@ function resolveAutonomy(cwd, target) {
|
|
|
26443
26517
|
const override = world ? null : grantsOverride();
|
|
26444
26518
|
if (override)
|
|
26445
26519
|
return { ...autonomyOf(null), note: override };
|
|
26520
|
+
let resolved;
|
|
26521
|
+
const once = typeof target === "function" ? () => resolved ??= target() : target;
|
|
26522
|
+
const current = resolveWith(fileSource(), cwd, world, once);
|
|
26523
|
+
const seal = sealOf();
|
|
26524
|
+
if (seal.state !== "broken")
|
|
26525
|
+
return current;
|
|
26526
|
+
let sealed = autonomyOf(null);
|
|
26527
|
+
try {
|
|
26528
|
+
if (seal.sealed)
|
|
26529
|
+
sealed = resolveWith(sealedSource(seal.sealed), cwd, world, once);
|
|
26530
|
+
} catch {
|
|
26531
|
+
sealed = null;
|
|
26532
|
+
}
|
|
26533
|
+
return stricter(current, sealed, sealNote(seal));
|
|
26534
|
+
}
|
|
26535
|
+
function resolveWith(source, cwd, world, target) {
|
|
26446
26536
|
const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
26447
|
-
const real =
|
|
26537
|
+
const real = source.resolve(cwd, name);
|
|
26448
26538
|
let autonomy = autonomyOf(real ?? world);
|
|
26449
26539
|
if (!real && world)
|
|
26450
26540
|
autonomy.world = evalWorld(cwd) ?? undefined;
|
|
26451
26541
|
if (name)
|
|
26452
|
-
autonomy = capAt(autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
|
|
26542
|
+
autonomy = capAt(source, autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
|
|
26453
26543
|
const above = checkoutsAbove(cwd);
|
|
26454
26544
|
for (const where of above instanceof Error ? [above] : above)
|
|
26455
|
-
autonomy = capAt(autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
|
|
26456
|
-
return capAtRemotes(autonomy, cwd, target);
|
|
26545
|
+
autonomy = capAt(source, autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
|
|
26546
|
+
return capAtRemotes(source, autonomy, cwd, target);
|
|
26547
|
+
}
|
|
26548
|
+
var needsAccount = (autonomy) => autonomy.configured.length > 0 && !autonomy.accountConfigured;
|
|
26549
|
+
function stricter(current, sealed, note) {
|
|
26550
|
+
const grants = { ...current.grants };
|
|
26551
|
+
const unblocks = { ...current.unblocks };
|
|
26552
|
+
for (const kind of GRANT_KINDS) {
|
|
26553
|
+
const floor = sealed ? sealed.grants[kind] : false;
|
|
26554
|
+
if (!raises(kind, floor, grants[kind]))
|
|
26555
|
+
continue;
|
|
26556
|
+
grants[kind] = floor;
|
|
26557
|
+
unblocks[kind] = SEAL_UNBLOCK;
|
|
26558
|
+
}
|
|
26559
|
+
const configured = GRANT_KINDS.filter((kind) => current.configured.includes(kind) || sealed?.configured.includes(kind));
|
|
26560
|
+
const accountConfigured = !needsAccount(current) && !(sealed && needsAccount(sealed)) && (current.accountConfigured || Boolean(sealed?.accountConfigured));
|
|
26561
|
+
const lower = (a, b) => raisesEndpoint(a, b) ? a : b;
|
|
26562
|
+
const defaultEndpoint = lower(current.defaultEndpoint, sealed?.defaultEndpoint ?? DEFAULT_ENDPOINT);
|
|
26563
|
+
const effective = effectiveEndpoint(defaultEndpoint, {
|
|
26564
|
+
workspace: current.workspace,
|
|
26565
|
+
grants,
|
|
26566
|
+
configured,
|
|
26567
|
+
accountConfigured
|
|
26568
|
+
});
|
|
26569
|
+
const endpoint = lower(lower(effective.endpoint, current.effectiveEndpoint), sealed?.effectiveEndpoint ?? DEFAULT_ENDPOINT);
|
|
26570
|
+
const strict = sealed?.verification ?? "independent";
|
|
26571
|
+
const looser = VERIFICATION_STRICTNESS.indexOf(current.verification) > VERIFICATION_STRICTNESS.indexOf(strict);
|
|
26572
|
+
return {
|
|
26573
|
+
...current,
|
|
26574
|
+
grants,
|
|
26575
|
+
configured,
|
|
26576
|
+
accountConfigured,
|
|
26577
|
+
defaultEndpoint,
|
|
26578
|
+
effectiveEndpoint: endpoint,
|
|
26579
|
+
endpointReason: endpoint === current.effectiveEndpoint ? current.endpointReason : SEAL_UNBLOCK,
|
|
26580
|
+
verification: looser ? strict : current.verification,
|
|
26581
|
+
unblocks,
|
|
26582
|
+
note: current.note ? `${current.note}; ${note}` : note
|
|
26583
|
+
};
|
|
26457
26584
|
}
|
|
26458
|
-
function capAtRemotes(autonomy, cwd, target) {
|
|
26459
|
-
const claiming =
|
|
26585
|
+
function capAtRemotes(source, autonomy, cwd, target) {
|
|
26586
|
+
const claiming = source.entries().filter((entry) => entry.remotes?.length);
|
|
26460
26587
|
if (claiming.length === 0)
|
|
26461
26588
|
return autonomy;
|
|
26462
26589
|
const remotes = target === undefined ? checkoutRemotes(cwd) : typeof target === "function" ? target() : target;
|
|
26463
26590
|
if (remotes instanceof Error)
|
|
26464
|
-
return capAt(autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
|
|
26591
|
+
return capAt(source, autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
|
|
26465
26592
|
let capped = autonomy;
|
|
26466
26593
|
for (const remote of Array.isArray(remotes) ? remotes : remotes.remotes)
|
|
26467
26594
|
for (const entry of claiming) {
|
|
26468
26595
|
const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
|
|
26469
26596
|
if (pattern)
|
|
26470
|
-
capped = capAt(capped, { entry }, `remote ${remote.name} ${remote.url} (workspace ${entry.name} claims ${pattern})`, "a checkout never exceeds the workspace that owns its remote");
|
|
26597
|
+
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");
|
|
26471
26598
|
}
|
|
26472
26599
|
return capped;
|
|
26473
26600
|
}
|
|
@@ -28571,8 +28698,8 @@ class WorkitCore {
|
|
|
28571
28698
|
}
|
|
28572
28699
|
// packages/workit-core/src/core/repo-context.ts
|
|
28573
28700
|
import { spawnSync as spawnSync16 } from "node:child_process";
|
|
28574
|
-
import { existsSync as existsSync10, readFileSync as
|
|
28575
|
-
import
|
|
28701
|
+
import { existsSync as existsSync10, readFileSync as readFileSync10, readdirSync as readdirSync4 } from "node:fs";
|
|
28702
|
+
import path25 from "node:path";
|
|
28576
28703
|
var isSafeContextRange = (value) => value.length <= 4096 && (() => {
|
|
28577
28704
|
try {
|
|
28578
28705
|
gitRevisionParts(value);
|
|
@@ -28716,13 +28843,13 @@ var findPrTemplate = (cwd) => {
|
|
|
28716
28843
|
for (const rel of PR_TEMPLATE_FILES) {
|
|
28717
28844
|
const parts = rel.split("/");
|
|
28718
28845
|
const base = parts[parts.length - 1];
|
|
28719
|
-
const dir = parts.length > 1 ?
|
|
28846
|
+
const dir = parts.length > 1 ? path25.join(cwd, ...parts.slice(0, -1)) : cwd;
|
|
28720
28847
|
const actual = probeCaseInsensitive(dir, base);
|
|
28721
28848
|
if (actual)
|
|
28722
28849
|
return [...parts.slice(0, -1), actual].join("/");
|
|
28723
28850
|
}
|
|
28724
28851
|
for (const rel of PR_TEMPLATE_DIRS) {
|
|
28725
|
-
const only = singleMarkdown(
|
|
28852
|
+
const only = singleMarkdown(path25.join(cwd, ...rel.split("/")));
|
|
28726
28853
|
if (only)
|
|
28727
28854
|
return `${rel}/${only}`;
|
|
28728
28855
|
}
|
|
@@ -28752,11 +28879,11 @@ var diffStatForRange = (cwd, range) => {
|
|
|
28752
28879
|
return runGit(cwd, ["diff", "--stat", "--"]).stdout;
|
|
28753
28880
|
};
|
|
28754
28881
|
var packageScripts = (cwd, keys) => {
|
|
28755
|
-
const pkgPath =
|
|
28882
|
+
const pkgPath = path25.join(cwd, "package.json");
|
|
28756
28883
|
if (!existsSync10(pkgPath))
|
|
28757
28884
|
return [];
|
|
28758
28885
|
try {
|
|
28759
|
-
const pkg = JSON.parse(
|
|
28886
|
+
const pkg = JSON.parse(readFileSync10(pkgPath, "utf8"));
|
|
28760
28887
|
return keys.filter((k) => pkg.scripts && typeof pkg.scripts[k] === "string").map((k) => `${k}: ${pkg.scripts?.[k]}`);
|
|
28761
28888
|
} catch {
|
|
28762
28889
|
return [];
|
|
@@ -28778,9 +28905,9 @@ var documentationFiles = (cwd) => {
|
|
|
28778
28905
|
if (entry.isDirectory()) {
|
|
28779
28906
|
if (excluded.has(entry.name))
|
|
28780
28907
|
continue;
|
|
28781
|
-
walk(
|
|
28908
|
+
walk(path25.join(dir, entry.name), depth + 1);
|
|
28782
28909
|
} else if (entry.isFile() && (entry.name === "README.md" || entry.name.endsWith(".md"))) {
|
|
28783
|
-
matches.push("./" +
|
|
28910
|
+
matches.push("./" + path25.relative(cwd, path25.join(dir, entry.name)).replaceAll("\\", "/"));
|
|
28784
28911
|
}
|
|
28785
28912
|
}
|
|
28786
28913
|
};
|
|
@@ -28790,13 +28917,13 @@ var documentationFiles = (cwd) => {
|
|
|
28790
28917
|
var readTrimmed2 = (file, maxLines) => {
|
|
28791
28918
|
if (!existsSync10(file))
|
|
28792
28919
|
return "";
|
|
28793
|
-
const lines =
|
|
28920
|
+
const lines = readFileSync10(file, "utf8").split(`
|
|
28794
28921
|
`);
|
|
28795
28922
|
return lines.slice(0, maxLines).join(`
|
|
28796
28923
|
`);
|
|
28797
28924
|
};
|
|
28798
28925
|
function prReadyContext(root, range) {
|
|
28799
|
-
const cwd =
|
|
28926
|
+
const cwd = path25.resolve(repoRoot(root));
|
|
28800
28927
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
28801
28928
|
return invalidRange(cwd);
|
|
28802
28929
|
let stdout = "";
|
|
@@ -28854,7 +28981,7 @@ ${status.stderr}` : "");
|
|
|
28854
28981
|
stdout += `template_path: ${template}
|
|
28855
28982
|
|
|
28856
28983
|
`;
|
|
28857
|
-
stdout += readTrimmed2(
|
|
28984
|
+
stdout += readTrimmed2(path25.join(cwd, template), 220);
|
|
28858
28985
|
} else {
|
|
28859
28986
|
stdout += `template_path: none
|
|
28860
28987
|
|
|
@@ -28864,7 +28991,7 @@ ${status.stderr}` : "");
|
|
|
28864
28991
|
stdout += `
|
|
28865
28992
|
`;
|
|
28866
28993
|
stdout += printSection("Recent Validation Signals");
|
|
28867
|
-
if (existsSync10(
|
|
28994
|
+
if (existsSync10(path25.join(cwd, "package.json"))) {
|
|
28868
28995
|
stdout += `package.json detected. Common scripts:
|
|
28869
28996
|
`;
|
|
28870
28997
|
const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
|
|
@@ -28873,7 +29000,7 @@ ${status.stderr}` : "");
|
|
|
28873
29000
|
`) + `
|
|
28874
29001
|
`;
|
|
28875
29002
|
}
|
|
28876
|
-
if (existsSync10(
|
|
29003
|
+
if (existsSync10(path25.join(cwd, "Cargo.toml")) || existsSync10(path25.join(cwd, "src-tauri/Cargo.toml"))) {
|
|
28877
29004
|
stdout += `Rust project detected.
|
|
28878
29005
|
`;
|
|
28879
29006
|
}
|
|
@@ -28906,7 +29033,7 @@ var CHANGELOG_RULES = `- Use an [Unreleased] section.
|
|
|
28906
29033
|
- Apply with the host-native editor, preserving the repository changelog conventions.
|
|
28907
29034
|
- If Unreleased already has duplicate category headings, normalize_only first.`;
|
|
28908
29035
|
function changelogContext(root, range) {
|
|
28909
|
-
const cwd =
|
|
29036
|
+
const cwd = path25.resolve(repoRoot(root));
|
|
28910
29037
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
28911
29038
|
return invalidRange(cwd);
|
|
28912
29039
|
const resolvedRange = rangeArgOrDefault(range, cwd);
|
|
@@ -28924,7 +29051,7 @@ function changelogContext(root, range) {
|
|
|
28924
29051
|
stdout += CHANGELOG_RULES + `
|
|
28925
29052
|
`;
|
|
28926
29053
|
stdout += printSection("Existing CHANGELOG.md");
|
|
28927
|
-
const changelogPath =
|
|
29054
|
+
const changelogPath = path25.join(cwd, "CHANGELOG.md");
|
|
28928
29055
|
if (existsSync10(changelogPath)) {
|
|
28929
29056
|
stdout += readTrimmed2(changelogPath, 260) + `
|
|
28930
29057
|
`;
|
|
@@ -28944,7 +29071,7 @@ function changelogContext(root, range) {
|
|
|
28944
29071
|
return { stdout, stderr: "", exitCode: 0, cwd };
|
|
28945
29072
|
}
|
|
28946
29073
|
function docsRefreshContext(root, range) {
|
|
28947
|
-
const cwd =
|
|
29074
|
+
const cwd = path25.resolve(repoRoot(root));
|
|
28948
29075
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
28949
29076
|
return invalidRange(cwd);
|
|
28950
29077
|
const resolvedRange = rangeArgOrDefault(range, cwd);
|
|
@@ -28966,7 +29093,7 @@ function docsRefreshContext(root, range) {
|
|
|
28966
29093
|
`) + `
|
|
28967
29094
|
`;
|
|
28968
29095
|
stdout += printSection("README Preview");
|
|
28969
|
-
const readme =
|
|
29096
|
+
const readme = path25.join(cwd, "README.md");
|
|
28970
29097
|
if (existsSync10(readme)) {
|
|
28971
29098
|
stdout += readTrimmed2(readme, 220) + `
|
|
28972
29099
|
`;
|
|
@@ -28975,10 +29102,10 @@ function docsRefreshContext(root, range) {
|
|
|
28975
29102
|
`;
|
|
28976
29103
|
}
|
|
28977
29104
|
stdout += printSection("Package Scripts");
|
|
28978
|
-
const pkgPath =
|
|
29105
|
+
const pkgPath = path25.join(cwd, "package.json");
|
|
28979
29106
|
if (existsSync10(pkgPath)) {
|
|
28980
29107
|
try {
|
|
28981
|
-
const pkg = JSON.parse(
|
|
29108
|
+
const pkg = JSON.parse(readFileSync10(pkgPath, "utf8"));
|
|
28982
29109
|
stdout += JSON.stringify({ name: pkg.name, version: pkg.version, scripts: pkg.scripts }, null, 2) + `
|
|
28983
29110
|
`;
|
|
28984
29111
|
} catch {}
|
|
@@ -28989,7 +29116,7 @@ function docsRefreshContext(root, range) {
|
|
|
28989
29116
|
return { stdout, stderr: "", exitCode: 0, cwd };
|
|
28990
29117
|
}
|
|
28991
29118
|
function releaseNotesContext(root, rangeOrTag) {
|
|
28992
|
-
const cwd =
|
|
29119
|
+
const cwd = path25.resolve(repoRoot(root));
|
|
28993
29120
|
if (!rangeOrTag) {
|
|
28994
29121
|
return {
|
|
28995
29122
|
stdout: "",
|
|
@@ -29032,7 +29159,7 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
29032
29159
|
`;
|
|
29033
29160
|
stdout += printSection("Existing Release Files");
|
|
29034
29161
|
for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
|
|
29035
|
-
if (existsSync10(
|
|
29162
|
+
if (existsSync10(path25.join(cwd, rel)))
|
|
29036
29163
|
stdout += rel + `
|
|
29037
29164
|
`;
|
|
29038
29165
|
}
|
|
@@ -29064,7 +29191,7 @@ import { spawnSync as spawnSync18 } from "node:child_process";
|
|
|
29064
29191
|
|
|
29065
29192
|
// packages/workit-core/src/core/pr-create.ts
|
|
29066
29193
|
import fs17 from "node:fs";
|
|
29067
|
-
import
|
|
29194
|
+
import path26 from "node:path";
|
|
29068
29195
|
import { spawnSync as spawnSync17 } from "node:child_process";
|
|
29069
29196
|
// packages/workit-core/src/forge/pr-body.ts
|
|
29070
29197
|
function parseGhIssue(value) {
|
|
@@ -29084,11 +29211,11 @@ var LOCAL = bounded(20000);
|
|
|
29084
29211
|
var NETWORK = bounded(60000);
|
|
29085
29212
|
function whichOnPath(tool) {
|
|
29086
29213
|
const names = process.platform === "win32" ? [tool, `${tool}.exe`, `${tool}.cmd`] : [tool];
|
|
29087
|
-
for (const dir of (process.env.PATH ?? "").split(
|
|
29214
|
+
for (const dir of (process.env.PATH ?? "").split(path26.delimiter)) {
|
|
29088
29215
|
if (!dir)
|
|
29089
29216
|
continue;
|
|
29090
29217
|
for (const name of names) {
|
|
29091
|
-
const candidate =
|
|
29218
|
+
const candidate = path26.join(dir, name);
|
|
29092
29219
|
try {
|
|
29093
29220
|
fs17.accessSync(candidate, fs17.constants.X_OK);
|
|
29094
29221
|
return candidate;
|
|
@@ -29209,7 +29336,7 @@ var fetchGitLabIssueBody = async (ref, root, deps = {}) => {
|
|
|
29209
29336
|
|
|
29210
29337
|
// packages/workit-core/src/core/youtrack.ts
|
|
29211
29338
|
import fs19 from "node:fs";
|
|
29212
|
-
import
|
|
29339
|
+
import path28 from "node:path";
|
|
29213
29340
|
|
|
29214
29341
|
// packages/workit-core/src/core/templates.ts
|
|
29215
29342
|
var repoRoot2 = assetRoot();
|
|
@@ -29224,7 +29351,7 @@ import { spawnSync as spawnSync19 } from "node:child_process";
|
|
|
29224
29351
|
|
|
29225
29352
|
// packages/workit-core/src/forge/exec.ts
|
|
29226
29353
|
import fs18 from "node:fs";
|
|
29227
|
-
import
|
|
29354
|
+
import path27 from "node:path";
|
|
29228
29355
|
|
|
29229
29356
|
// packages/workit-core/src/forge/redact.ts
|
|
29230
29357
|
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_.-]*`;
|
|
@@ -29235,11 +29362,11 @@ var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\
|
|
|
29235
29362
|
// packages/workit-core/src/forge/exec.ts
|
|
29236
29363
|
var MAX_BUFFER2 = 64 * 1024 * 1024;
|
|
29237
29364
|
function findExecutable(bin, env) {
|
|
29238
|
-
const dirs = (env.PATH ?? env.Path ?? "").split(
|
|
29365
|
+
const dirs = (env.PATH ?? env.Path ?? "").split(path27.delimiter).filter(Boolean);
|
|
29239
29366
|
const exts = process.platform === "win32" ? [".exe"] : [""];
|
|
29240
29367
|
for (const dir of dirs)
|
|
29241
29368
|
for (const ext of exts) {
|
|
29242
|
-
const candidate =
|
|
29369
|
+
const candidate = path27.join(dir, `${bin}${ext}`);
|
|
29243
29370
|
try {
|
|
29244
29371
|
const stat = fs18.statSync(candidate);
|
|
29245
29372
|
if (stat.isFile())
|
|
@@ -29282,7 +29409,7 @@ var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only throug
|
|
|
29282
29409
|
|
|
29283
29410
|
// packages/workit-core/src/core/youtrack.ts
|
|
29284
29411
|
var ISSUE_RE = /^[A-Z][A-Z0-9_]*-\d+$/;
|
|
29285
|
-
var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ??
|
|
29412
|
+
var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path28.join(resolveConfigDir(), "youtrack.json");
|
|
29286
29413
|
var readYouTrackContextConfig = () => {
|
|
29287
29414
|
const cfgPath = youTrackReadOnlyConfigPath();
|
|
29288
29415
|
if (!fs19.existsSync(cfgPath))
|
|
@@ -29635,15 +29762,15 @@ function resolveGitRevision(root, value) {
|
|
|
29635
29762
|
}
|
|
29636
29763
|
function resolveInside(root, candidate) {
|
|
29637
29764
|
const base = realpathSync8(root);
|
|
29638
|
-
const target =
|
|
29639
|
-
if (target !== base && !target.startsWith(base +
|
|
29765
|
+
const target = path29.resolve(base, candidate);
|
|
29766
|
+
if (target !== base && !target.startsWith(base + path29.sep)) {
|
|
29640
29767
|
throw new Error("path must stay inside repository root");
|
|
29641
29768
|
}
|
|
29642
29769
|
let ancestor = target;
|
|
29643
29770
|
while (!existsSync11(ancestor))
|
|
29644
|
-
ancestor =
|
|
29771
|
+
ancestor = path29.dirname(ancestor);
|
|
29645
29772
|
const canonicalAncestor = realpathSync8(ancestor);
|
|
29646
|
-
if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base +
|
|
29773
|
+
if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path29.sep)) {
|
|
29647
29774
|
throw new Error("path must stay inside repository root");
|
|
29648
29775
|
}
|
|
29649
29776
|
return target;
|
|
@@ -29681,11 +29808,11 @@ var changedSourcesSinceLoad = (marker) => {
|
|
|
29681
29808
|
};
|
|
29682
29809
|
|
|
29683
29810
|
// packages/workit-core/src/hooks/repeat-failure.ts
|
|
29684
|
-
import { createHash as
|
|
29811
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
29685
29812
|
var SAME_CALL_FAILED = "Same call failed twice:";
|
|
29686
29813
|
var MAX_SESSIONS = 256;
|
|
29687
29814
|
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";
|
|
29688
|
-
var hashOf = (call) =>
|
|
29815
|
+
var hashOf = (call) => createHash12("sha256").update(call).digest("hex").slice(0, 32);
|
|
29689
29816
|
var record3 = (memo, sessionId, call, failed, next) => {
|
|
29690
29817
|
const previous = memo.get(sessionId);
|
|
29691
29818
|
memo.delete(sessionId);
|
|
@@ -29740,7 +29867,7 @@ var safeCapability = (value, allowed) => allowed.includes(value) ? value : "cont
|
|
|
29740
29867
|
var TOOL_CAPABILITIES = [...CONTEXT_KINDS, "workspace", "native_caller_identity"];
|
|
29741
29868
|
var VERSION = (() => {
|
|
29742
29869
|
try {
|
|
29743
|
-
const packageJson = JSON.parse(
|
|
29870
|
+
const packageJson = JSON.parse(readFileSync11(new URL("../package.json", import.meta.url), "utf8"));
|
|
29744
29871
|
return typeof packageJson.version === "string" ? packageJson.version : "0.0.0";
|
|
29745
29872
|
} catch {
|
|
29746
29873
|
return "0.0.0";
|
|
@@ -29750,13 +29877,13 @@ var rootVariants = (workspaceRoot) => {
|
|
|
29750
29877
|
if (!workspaceRoot)
|
|
29751
29878
|
return [];
|
|
29752
29879
|
const roots = new Set;
|
|
29753
|
-
for (const candidate of [workspaceRoot,
|
|
29754
|
-
if (
|
|
29880
|
+
for (const candidate of [workspaceRoot, path30.resolve(workspaceRoot)]) {
|
|
29881
|
+
if (path30.isAbsolute(candidate) && candidate !== path30.parse(candidate).root)
|
|
29755
29882
|
roots.add(candidate);
|
|
29756
29883
|
}
|
|
29757
29884
|
try {
|
|
29758
29885
|
const canonical = realpathSync9(workspaceRoot);
|
|
29759
|
-
if (canonical !==
|
|
29886
|
+
if (canonical !== path30.parse(canonical).root)
|
|
29760
29887
|
roots.add(canonical);
|
|
29761
29888
|
} catch {}
|
|
29762
29889
|
return [...roots].toSorted((left, right) => right.length - left.length);
|
|
@@ -29838,11 +29965,11 @@ var thrownResult = (tool, error, workspaceRoot) => {
|
|
|
29838
29965
|
};
|
|
29839
29966
|
function createMcpServer(host, contextProvider) {
|
|
29840
29967
|
assertMcpHost(host);
|
|
29841
|
-
const here =
|
|
29968
|
+
const here = path30.dirname(fileURLToPath2(import.meta.url));
|
|
29842
29969
|
const sourceMarker = markSourcesLoaded([
|
|
29843
|
-
|
|
29844
|
-
|
|
29845
|
-
|
|
29970
|
+
path30.join(here, "server.ts"),
|
|
29971
|
+
path30.join(here, "..", "..", "workit-core", "src", "core", "task-contract.ts"),
|
|
29972
|
+
path30.join(here, "..", "..", "workit-core", "src", "core", "task-engine.ts")
|
|
29846
29973
|
].filter((file) => existsSync12(file)));
|
|
29847
29974
|
let staleWarned = false;
|
|
29848
29975
|
const failures = new Map;
|
|
@@ -30025,8 +30152,8 @@ var main = async () => {
|
|
|
30025
30152
|
process.exitCode = 2;
|
|
30026
30153
|
}
|
|
30027
30154
|
};
|
|
30028
|
-
var entryPath = process.argv[1] ?
|
|
30029
|
-
if (entryPath ===
|
|
30155
|
+
var entryPath = process.argv[1] ? path31.resolve(process.argv[1]) : "";
|
|
30156
|
+
if (entryPath === path31.resolve(fileURLToPath3(import.meta.url)))
|
|
30030
30157
|
await main();
|
|
30031
30158
|
export {
|
|
30032
30159
|
McpCapabilityUnavailableError,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Workit shared MCP transport for the eight task and policy operation families",
|
|
6
6
|
"keywords": [
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@modelcontextprotocol/sdk": "1.32.0",
|
|
47
|
-
"@workit-dev/core": "^1.
|
|
47
|
+
"@workit-dev/core": "^1.13.0",
|
|
48
48
|
"zod": "4.6.5"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|