@workit-dev/opencode 1.4.2 → 1.5.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/plugin.js +296 -251
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -183,8 +183,8 @@ function define(plugin) {
|
|
|
183
183
|
|
|
184
184
|
// packages/workit-core/src/core.ts
|
|
185
185
|
import { spawnSync as spawnSync21 } from "node:child_process";
|
|
186
|
-
import { existsSync as
|
|
187
|
-
import
|
|
186
|
+
import { existsSync as existsSync11, realpathSync as realpathSync8 } from "node:fs";
|
|
187
|
+
import path33 from "node:path";
|
|
188
188
|
|
|
189
189
|
// packages/workit-core/src/core/task-contract.ts
|
|
190
190
|
import { createHash as createHash3, randomUUID } from "node:crypto";
|
|
@@ -18475,31 +18475,75 @@ var exportDigest = (bundle) => sha256({
|
|
|
18475
18475
|
});
|
|
18476
18476
|
// packages/workit-core/src/core/route-intent.ts
|
|
18477
18477
|
import { spawnSync as spawnSync16 } from "node:child_process";
|
|
18478
|
-
import { existsSync as
|
|
18479
|
-
import
|
|
18478
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
18479
|
+
import path28 from "node:path";
|
|
18480
18480
|
|
|
18481
18481
|
// packages/workit-core/src/hooks/raw-git.ts
|
|
18482
18482
|
import { spawnSync as spawnSync15 } from "node:child_process";
|
|
18483
18483
|
import { createHash as createHash16 } from "node:crypto";
|
|
18484
18484
|
import fs19 from "node:fs";
|
|
18485
|
-
import
|
|
18486
|
-
import
|
|
18485
|
+
import os7 from "node:os";
|
|
18486
|
+
import path27 from "node:path";
|
|
18487
18487
|
|
|
18488
18488
|
// packages/workit-core/src/autonomy.ts
|
|
18489
|
+
import os6 from "node:os";
|
|
18490
|
+
import path25 from "node:path";
|
|
18491
|
+
|
|
18492
|
+
// packages/workit-core/src/core/eval-world.ts
|
|
18493
|
+
import { existsSync as existsSync8, realpathSync as realpathSync5 } from "node:fs";
|
|
18489
18494
|
import os5 from "node:os";
|
|
18490
18495
|
import path24 from "node:path";
|
|
18496
|
+
var EVAL_WORLD_ENV = "WORKIT_EVAL_WORLD";
|
|
18497
|
+
var EVAL_WORLD_MARKER = ".workit-eval-world";
|
|
18498
|
+
var inside2 = (dir, file) => {
|
|
18499
|
+
const rel = path24.relative(dir, file);
|
|
18500
|
+
return !rel.startsWith("..") && !path24.isAbsolute(rel);
|
|
18501
|
+
};
|
|
18502
|
+
var evalWorldEntry = (cwd) => {
|
|
18503
|
+
const raw = process.env[EVAL_WORLD_ENV];
|
|
18504
|
+
if (!raw || !path24.isAbsolute(raw))
|
|
18505
|
+
return null;
|
|
18506
|
+
try {
|
|
18507
|
+
const world = realpathSync5(raw);
|
|
18508
|
+
if (!inside2(realpathSync5(os5.tmpdir()), world) || !inside2(world, realpathSync5(cwd)) || !existsSync8(path24.join(world, EVAL_WORLD_MARKER)))
|
|
18509
|
+
return null;
|
|
18510
|
+
return loadWorkspacesFrom(path24.join(world, "config"))[0] ?? null;
|
|
18511
|
+
} catch {
|
|
18512
|
+
return null;
|
|
18513
|
+
}
|
|
18514
|
+
};
|
|
18515
|
+
|
|
18516
|
+
// packages/workit-core/src/autonomy.ts
|
|
18491
18517
|
var accountHome2 = () => {
|
|
18492
18518
|
try {
|
|
18493
|
-
return
|
|
18519
|
+
return os6.userInfo().homedir;
|
|
18494
18520
|
} catch {
|
|
18495
|
-
return
|
|
18521
|
+
return os6.homedir();
|
|
18496
18522
|
}
|
|
18497
18523
|
};
|
|
18498
18524
|
var grantsHome = { resolve: accountHome2 };
|
|
18499
18525
|
var grantsDir = () => configDir({ HOME: grantsHome.resolve() });
|
|
18526
|
+
var benchWorld = (cwd) => {
|
|
18527
|
+
const entry = evalWorldEntry(cwd);
|
|
18528
|
+
if (!entry)
|
|
18529
|
+
return null;
|
|
18530
|
+
const { grants } = configuredGrants(entry);
|
|
18531
|
+
const lowered = {};
|
|
18532
|
+
for (const kind of GRANT_KINDS) {
|
|
18533
|
+
const value = grants[kind];
|
|
18534
|
+
if (value !== undefined && raises(kind, value, DEFAULT_GRANTS[kind]))
|
|
18535
|
+
lowered[kind] = value;
|
|
18536
|
+
}
|
|
18537
|
+
return {
|
|
18538
|
+
name: entry.name,
|
|
18539
|
+
glob: entry.glob,
|
|
18540
|
+
...entry.defaultEndpoint ? { defaultEndpoint: entry.defaultEndpoint } : {},
|
|
18541
|
+
autonomy: lowered
|
|
18542
|
+
};
|
|
18543
|
+
};
|
|
18500
18544
|
var grantsOverride = () => {
|
|
18501
|
-
const configured =
|
|
18502
|
-
return configured ===
|
|
18545
|
+
const configured = path25.resolve(resolveConfigDir());
|
|
18546
|
+
return configured === path25.resolve(grantsDir()) ? 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 ${path25.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
|
|
18503
18547
|
};
|
|
18504
18548
|
var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
|
|
18505
18549
|
var DEFAULT_GRANTS = Object.freeze({
|
|
@@ -18664,11 +18708,12 @@ function capAt(named, where, by, why, main = false) {
|
|
|
18664
18708
|
};
|
|
18665
18709
|
}
|
|
18666
18710
|
function resolveAutonomy(cwd, target) {
|
|
18667
|
-
const
|
|
18711
|
+
const world = benchWorld(cwd);
|
|
18712
|
+
const override = world ? null : grantsOverride();
|
|
18668
18713
|
if (override)
|
|
18669
18714
|
return { ...autonomyOf(null), note: override };
|
|
18670
18715
|
const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
18671
|
-
let autonomy = autonomyOf(resolveWorkspaceFrom(cwd, grantsDir(), name));
|
|
18716
|
+
let autonomy = autonomyOf(resolveWorkspaceFrom(cwd, grantsDir(), name) ?? world);
|
|
18672
18717
|
if (name)
|
|
18673
18718
|
autonomy = capAt(autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
|
|
18674
18719
|
const above = checkoutsAbove(cwd);
|
|
@@ -18756,7 +18801,7 @@ var raises = (kind, current, next) => {
|
|
|
18756
18801
|
// packages/workit-core/src/hooks/session-marker.ts
|
|
18757
18802
|
import { createHash as createHash15 } from "node:crypto";
|
|
18758
18803
|
import fs18 from "node:fs";
|
|
18759
|
-
import
|
|
18804
|
+
import path26 from "node:path";
|
|
18760
18805
|
var sessionMarkerFile = (input, session, store) => {
|
|
18761
18806
|
let dir = store;
|
|
18762
18807
|
if (dir === undefined) {
|
|
@@ -18766,7 +18811,7 @@ var sessionMarkerFile = (input, session, store) => {
|
|
|
18766
18811
|
dir = location.dir;
|
|
18767
18812
|
}
|
|
18768
18813
|
const name = createHash15("sha256").update(`${input.host}\x00${session}`).digest("hex").slice(0, 32);
|
|
18769
|
-
return
|
|
18814
|
+
return path26.join(dir, "hooks", `skills-${name}.json`);
|
|
18770
18815
|
};
|
|
18771
18816
|
var list2 = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
18772
18817
|
var EMPTY = {
|
|
@@ -18801,7 +18846,7 @@ var parseMarker = (text) => {
|
|
|
18801
18846
|
};
|
|
18802
18847
|
var readSessionMarker = (file) => parseMarker(readRaw(file));
|
|
18803
18848
|
var writeAtomic = (file, marker) => {
|
|
18804
|
-
fs18.mkdirSync(
|
|
18849
|
+
fs18.mkdirSync(path26.dirname(file), { recursive: true });
|
|
18805
18850
|
const temp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
18806
18851
|
try {
|
|
18807
18852
|
fs18.writeFileSync(temp, JSON.stringify(marker));
|
|
@@ -19364,14 +19409,14 @@ var GIT_CONFIG_ENV = /^(?:GIT_(?:CONFIG\w*|DIR|COMMON_DIR|WORK_TREE|SSH|SSH_COMM
|
|
|
19364
19409
|
var ASSIGNMENT = /^([A-Za-z_]\w*)=([\s\S]*)$/;
|
|
19365
19410
|
var MAX_DEPTH = 4;
|
|
19366
19411
|
var MAX_EXPANSIONS = 16;
|
|
19367
|
-
var isAbsolute = (value) =>
|
|
19412
|
+
var isAbsolute = (value) => path27.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
|
|
19368
19413
|
var HERE = /^(?:\$PWD|\$\{PWD\}|\$\(\s*pwd\s*\)|`pwd`|\$\(\s*git\s+rev-parse\s+--show-toplevel\s*\))(?=$|[\\/])/;
|
|
19369
19414
|
var joinDir = (base, raw) => {
|
|
19370
19415
|
const next = raw.replace(HERE, ".");
|
|
19371
19416
|
if (base === undefined || /[$`*?]/.test(next) || next === "-")
|
|
19372
19417
|
return;
|
|
19373
|
-
const expanded = next === "~" || next.startsWith("~/") ?
|
|
19374
|
-
return base === null || isAbsolute(expanded) ? expanded :
|
|
19418
|
+
const expanded = next === "~" || next.startsWith("~/") ? path27.join(os7.homedir(), next.slice(1)) : next;
|
|
19419
|
+
return base === null || isAbsolute(expanded) ? expanded : path27.join(base, expanded);
|
|
19375
19420
|
};
|
|
19376
19421
|
var rebase = (base, inner) => inner === null ? base : inner === undefined ? undefined : joinDir(base, inner);
|
|
19377
19422
|
var cdTarget = (words) => {
|
|
@@ -19772,7 +19817,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
|
|
|
19772
19817
|
}
|
|
19773
19818
|
if (CD.has(name)) {
|
|
19774
19819
|
const target = cdTarget(words);
|
|
19775
|
-
dir = target === null ?
|
|
19820
|
+
dir = target === null ? os7.homedir() : joinDir(dir, target);
|
|
19776
19821
|
} else if (PUSHD.has(name)) {
|
|
19777
19822
|
const target = cdTarget(words);
|
|
19778
19823
|
stack.push(dir);
|
|
@@ -20293,17 +20338,17 @@ var headSha2 = (repo) => {
|
|
|
20293
20338
|
if (!git || git.reftable)
|
|
20294
20339
|
return null;
|
|
20295
20340
|
try {
|
|
20296
|
-
const head = fs19.readFileSync(
|
|
20341
|
+
const head = fs19.readFileSync(path27.join(git.gitDir, "HEAD"), "utf8").trim();
|
|
20297
20342
|
if (/^[0-9a-f]{40,64}$/.test(head))
|
|
20298
20343
|
return head;
|
|
20299
20344
|
const ref = /^ref: (refs\/.+)$/.exec(head)?.[1];
|
|
20300
20345
|
if (!ref)
|
|
20301
20346
|
return null;
|
|
20302
|
-
const common =
|
|
20347
|
+
const common = path27.dirname(repo.location.dir);
|
|
20303
20348
|
try {
|
|
20304
|
-
return fs19.readFileSync(
|
|
20349
|
+
return fs19.readFileSync(path27.join(common, ref), "utf8").trim() || null;
|
|
20305
20350
|
} catch {}
|
|
20306
|
-
const packed = fs19.readFileSync(
|
|
20351
|
+
const packed = fs19.readFileSync(path27.join(common, "packed-refs"), "utf8");
|
|
20307
20352
|
return new RegExp(`^([0-9a-f]{40,64}) ${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`, "m").exec(packed)?.[1] ?? null;
|
|
20308
20353
|
} catch {
|
|
20309
20354
|
return null;
|
|
@@ -20396,7 +20441,7 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
|
|
|
20396
20441
|
const sub = invocation.args[0];
|
|
20397
20442
|
if (invocation.tool !== "git" || invocation.dir === undefined || !sub || sub.startsWith("-") || GIT_COMMANDS.has(sub) || depth >= MAX_DEPTH)
|
|
20398
20443
|
return [invocation];
|
|
20399
|
-
const dir =
|
|
20444
|
+
const dir = path27.resolve(root, invocation.dir ?? ".");
|
|
20400
20445
|
if (!fs19.existsSync(dir))
|
|
20401
20446
|
return [invocation];
|
|
20402
20447
|
const config = gitConfig(dir, invocation, cache);
|
|
@@ -20419,11 +20464,11 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
|
|
|
20419
20464
|
var normalizedUrl = (url, dir) => {
|
|
20420
20465
|
const trimmed = url.trim();
|
|
20421
20466
|
if (/^file:\/\//i.test(trimmed))
|
|
20422
|
-
return
|
|
20467
|
+
return path27.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
|
|
20423
20468
|
const scheme = /^[a-z][a-z0-9+.-]*:\/\//i.exec(trimmed);
|
|
20424
20469
|
const scp = !scheme && /^(?:[^@/\\]+@)?[^/\\:]{2,}:/.test(trimmed);
|
|
20425
20470
|
if (!scheme && !scp)
|
|
20426
|
-
return
|
|
20471
|
+
return path27.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
|
|
20427
20472
|
const value = scheme ? trimmed.slice(scheme[0].length).replace(/^[^@/]*@/, "").replace(/^([^/:]+):\d+(?=\/)/, "$1") : trimmed.replace(/^[^@/]*@/, "").replace(":", "/");
|
|
20428
20473
|
return value.toLowerCase().replace(/\/{2,}/g, "/").replace(/^www\./, "").replace(/\/+$/, "").replace(/\.git$/, "");
|
|
20429
20474
|
};
|
|
@@ -20651,7 +20696,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
|
|
|
20651
20696
|
const out = [];
|
|
20652
20697
|
const repos = new Map;
|
|
20653
20698
|
const repoFor = (relative) => {
|
|
20654
|
-
const dir =
|
|
20699
|
+
const dir = path27.resolve(cwd, relative ?? ".");
|
|
20655
20700
|
if (!repos.has(dir)) {
|
|
20656
20701
|
const repo = repoAt(dir);
|
|
20657
20702
|
const workit = repo !== null && isWorkitWorkspace(repo);
|
|
@@ -20671,7 +20716,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
|
|
|
20671
20716
|
continue;
|
|
20672
20717
|
const action = rawAction(invocation);
|
|
20673
20718
|
const at = !action ? null : repoFor(invocation.dir) ?? (all && invocation.tool !== "git" && explicitRepo(invocation.tool === "gh", "repo" in action && action.repo || "", invocation.env ?? {}) ? {
|
|
20674
|
-
repo: { dir:
|
|
20719
|
+
repo: { dir: path27.resolve(cwd, invocation.dir ?? "."), branch: null },
|
|
20675
20720
|
workit: false
|
|
20676
20721
|
} : null);
|
|
20677
20722
|
if (action && at)
|
|
@@ -20808,9 +20853,9 @@ var grantRefusal = (action, repo, invocation, cache) => {
|
|
|
20808
20853
|
return null;
|
|
20809
20854
|
};
|
|
20810
20855
|
var localTag = (repo, name) => {
|
|
20811
|
-
const common =
|
|
20856
|
+
const common = path27.dirname(repo.location.dir);
|
|
20812
20857
|
try {
|
|
20813
|
-
return fs19.existsSync(
|
|
20858
|
+
return fs19.existsSync(path27.join(common, "refs/tags", name)) || fs19.readFileSync(path27.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
|
|
20814
20859
|
`);
|
|
20815
20860
|
} catch {
|
|
20816
20861
|
return false;
|
|
@@ -20829,7 +20874,7 @@ var analysisDenial = (error) => ({
|
|
|
20829
20874
|
unblock: SPLIT_IT
|
|
20830
20875
|
});
|
|
20831
20876
|
var MARKER_TTL_SECONDS = 3600;
|
|
20832
|
-
var markerFile = (repo, session, key) =>
|
|
20877
|
+
var markerFile = (repo, session, key) => path27.join(repo.location.dir, "hooks", `commit-${createHash16("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
|
|
20833
20878
|
var callKey = (toolUseId, command) => toolUseId ?? `cmd:${createHash16("sha256").update(command).digest("hex")}`;
|
|
20834
20879
|
function noteRawCommit(input, command, key) {
|
|
20835
20880
|
try {
|
|
@@ -20840,7 +20885,7 @@ function noteRawCommit(input, command, key) {
|
|
|
20840
20885
|
if (action.kind !== "commit")
|
|
20841
20886
|
continue;
|
|
20842
20887
|
const file = markerFile(repo, input.session.id, key);
|
|
20843
|
-
fs19.mkdirSync(
|
|
20888
|
+
fs19.mkdirSync(path27.dirname(file), { recursive: true });
|
|
20844
20889
|
fs19.writeFileSync(file, `${JSON.stringify({ head: headSha2(repo), at })}
|
|
20845
20890
|
`);
|
|
20846
20891
|
}
|
|
@@ -21069,8 +21114,8 @@ var judgedDir = (root, dir) => {
|
|
|
21069
21114
|
return null;
|
|
21070
21115
|
if (dir === null)
|
|
21071
21116
|
return root;
|
|
21072
|
-
const resolved =
|
|
21073
|
-
return
|
|
21117
|
+
const resolved = path28.resolve(root, dir);
|
|
21118
|
+
return existsSync9(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
|
|
21074
21119
|
};
|
|
21075
21120
|
var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
|
|
21076
21121
|
let judged = false;
|
|
@@ -21091,7 +21136,7 @@ var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
|
|
|
21091
21136
|
return judged ? { ok: true } : null;
|
|
21092
21137
|
};
|
|
21093
21138
|
// packages/workit-core/src/core/task-engine.ts
|
|
21094
|
-
import { realpathSync as
|
|
21139
|
+
import { realpathSync as realpathSync7 } from "node:fs";
|
|
21095
21140
|
|
|
21096
21141
|
// packages/workit-core/src/core/policy-resolver.ts
|
|
21097
21142
|
function resolvePolicy(input) {
|
|
@@ -21340,12 +21385,12 @@ var judgeInputSummary = (raw) => {
|
|
|
21340
21385
|
};
|
|
21341
21386
|
|
|
21342
21387
|
// packages/workit-core/src/core/task-view.ts
|
|
21343
|
-
import { realpathSync as
|
|
21388
|
+
import { realpathSync as realpathSync6 } from "node:fs";
|
|
21344
21389
|
var environment = () => [];
|
|
21345
21390
|
var sameSession2 = (value, context) => typeof value === "object" && value !== null && value.kind === "host" && value.host === context.caller.host && value.handle === context.caller.actor;
|
|
21346
21391
|
function contextRootError(store, context) {
|
|
21347
21392
|
try {
|
|
21348
|
-
|
|
21393
|
+
realpathSync6(context.root);
|
|
21349
21394
|
const root = checkoutRootOf(context.root);
|
|
21350
21395
|
if (root !== store.root && !sameDirectoryIdentity(root, store.root))
|
|
21351
21396
|
return failure2("invalid_input", "operation context root does not match the task store root");
|
|
@@ -22815,7 +22860,7 @@ class WorkitCore {
|
|
|
22815
22860
|
if (view.task.workspaceId !== view.workspace.id)
|
|
22816
22861
|
return failure2("invalid_input", "task and workspace bindings are invalid");
|
|
22817
22862
|
try {
|
|
22818
|
-
if (
|
|
22863
|
+
if (realpathSync7(view.workspace.root) !== this.store.root)
|
|
22819
22864
|
return failure2("invalid_input", "task view root does not match the task store");
|
|
22820
22865
|
} catch {
|
|
22821
22866
|
return failure2("invalid_input", "task view root cannot be resolved");
|
|
@@ -23066,8 +23111,8 @@ class WorkitCore {
|
|
|
23066
23111
|
}
|
|
23067
23112
|
// packages/workit-core/src/core/repo-context.ts
|
|
23068
23113
|
import { spawnSync as spawnSync17 } from "node:child_process";
|
|
23069
|
-
import { existsSync as
|
|
23070
|
-
import
|
|
23114
|
+
import { existsSync as existsSync10, readFileSync as readFileSync8, readdirSync as readdirSync3 } from "node:fs";
|
|
23115
|
+
import path29 from "node:path";
|
|
23071
23116
|
var isSafeContextRange = (value) => value.length <= 4096 && (() => {
|
|
23072
23117
|
try {
|
|
23073
23118
|
gitRevisionParts(value);
|
|
@@ -23211,13 +23256,13 @@ var findPrTemplate = (cwd) => {
|
|
|
23211
23256
|
for (const rel of PR_TEMPLATE_FILES) {
|
|
23212
23257
|
const parts = rel.split("/");
|
|
23213
23258
|
const base = parts[parts.length - 1];
|
|
23214
|
-
const dir = parts.length > 1 ?
|
|
23259
|
+
const dir = parts.length > 1 ? path29.join(cwd, ...parts.slice(0, -1)) : cwd;
|
|
23215
23260
|
const actual = probeCaseInsensitive(dir, base);
|
|
23216
23261
|
if (actual)
|
|
23217
23262
|
return [...parts.slice(0, -1), actual].join("/");
|
|
23218
23263
|
}
|
|
23219
23264
|
for (const rel of PR_TEMPLATE_DIRS) {
|
|
23220
|
-
const only = singleMarkdown(
|
|
23265
|
+
const only = singleMarkdown(path29.join(cwd, ...rel.split("/")));
|
|
23221
23266
|
if (only)
|
|
23222
23267
|
return `${rel}/${only}`;
|
|
23223
23268
|
}
|
|
@@ -23247,8 +23292,8 @@ var diffStatForRange = (cwd, range) => {
|
|
|
23247
23292
|
return runGit(cwd, ["diff", "--stat", "--"]).stdout;
|
|
23248
23293
|
};
|
|
23249
23294
|
var packageScripts = (cwd, keys) => {
|
|
23250
|
-
const pkgPath =
|
|
23251
|
-
if (!
|
|
23295
|
+
const pkgPath = path29.join(cwd, "package.json");
|
|
23296
|
+
if (!existsSync10(pkgPath))
|
|
23252
23297
|
return [];
|
|
23253
23298
|
try {
|
|
23254
23299
|
const pkg = JSON.parse(readFileSync8(pkgPath, "utf8"));
|
|
@@ -23273,9 +23318,9 @@ var documentationFiles = (cwd) => {
|
|
|
23273
23318
|
if (entry.isDirectory()) {
|
|
23274
23319
|
if (excluded.has(entry.name))
|
|
23275
23320
|
continue;
|
|
23276
|
-
walk(
|
|
23321
|
+
walk(path29.join(dir, entry.name), depth + 1);
|
|
23277
23322
|
} else if (entry.isFile() && (entry.name === "README.md" || entry.name.endsWith(".md"))) {
|
|
23278
|
-
matches.push("./" +
|
|
23323
|
+
matches.push("./" + path29.relative(cwd, path29.join(dir, entry.name)).replaceAll("\\", "/"));
|
|
23279
23324
|
}
|
|
23280
23325
|
}
|
|
23281
23326
|
};
|
|
@@ -23283,7 +23328,7 @@ var documentationFiles = (cwd) => {
|
|
|
23283
23328
|
return matches.toSorted().slice(0, 200);
|
|
23284
23329
|
};
|
|
23285
23330
|
var readTrimmed2 = (file, maxLines) => {
|
|
23286
|
-
if (!
|
|
23331
|
+
if (!existsSync10(file))
|
|
23287
23332
|
return "";
|
|
23288
23333
|
const lines = readFileSync8(file, "utf8").split(`
|
|
23289
23334
|
`);
|
|
@@ -23291,7 +23336,7 @@ var readTrimmed2 = (file, maxLines) => {
|
|
|
23291
23336
|
`);
|
|
23292
23337
|
};
|
|
23293
23338
|
function prReadyContext(root, range) {
|
|
23294
|
-
const cwd =
|
|
23339
|
+
const cwd = path29.resolve(repoRoot(root));
|
|
23295
23340
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
23296
23341
|
return invalidRange(cwd);
|
|
23297
23342
|
let stdout = "";
|
|
@@ -23349,7 +23394,7 @@ ${status.stderr}` : "");
|
|
|
23349
23394
|
stdout += `template_path: ${template}
|
|
23350
23395
|
|
|
23351
23396
|
`;
|
|
23352
|
-
stdout += readTrimmed2(
|
|
23397
|
+
stdout += readTrimmed2(path29.join(cwd, template), 220);
|
|
23353
23398
|
} else {
|
|
23354
23399
|
stdout += `template_path: none
|
|
23355
23400
|
|
|
@@ -23359,7 +23404,7 @@ ${status.stderr}` : "");
|
|
|
23359
23404
|
stdout += `
|
|
23360
23405
|
`;
|
|
23361
23406
|
stdout += printSection("Recent Validation Signals");
|
|
23362
|
-
if (
|
|
23407
|
+
if (existsSync10(path29.join(cwd, "package.json"))) {
|
|
23363
23408
|
stdout += `package.json detected. Common scripts:
|
|
23364
23409
|
`;
|
|
23365
23410
|
const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
|
|
@@ -23368,7 +23413,7 @@ ${status.stderr}` : "");
|
|
|
23368
23413
|
`) + `
|
|
23369
23414
|
`;
|
|
23370
23415
|
}
|
|
23371
|
-
if (
|
|
23416
|
+
if (existsSync10(path29.join(cwd, "Cargo.toml")) || existsSync10(path29.join(cwd, "src-tauri/Cargo.toml"))) {
|
|
23372
23417
|
stdout += `Rust project detected.
|
|
23373
23418
|
`;
|
|
23374
23419
|
}
|
|
@@ -23401,7 +23446,7 @@ var CHANGELOG_RULES = `- Use an [Unreleased] section.
|
|
|
23401
23446
|
- Apply with the host-native editor, preserving the repository changelog conventions.
|
|
23402
23447
|
- If Unreleased already has duplicate category headings, normalize_only first.`;
|
|
23403
23448
|
function changelogContext(root, range) {
|
|
23404
|
-
const cwd =
|
|
23449
|
+
const cwd = path29.resolve(repoRoot(root));
|
|
23405
23450
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
23406
23451
|
return invalidRange(cwd);
|
|
23407
23452
|
const resolvedRange = rangeArgOrDefault(range, cwd);
|
|
@@ -23419,8 +23464,8 @@ function changelogContext(root, range) {
|
|
|
23419
23464
|
stdout += CHANGELOG_RULES + `
|
|
23420
23465
|
`;
|
|
23421
23466
|
stdout += printSection("Existing CHANGELOG.md");
|
|
23422
|
-
const changelogPath =
|
|
23423
|
-
if (
|
|
23467
|
+
const changelogPath = path29.join(cwd, "CHANGELOG.md");
|
|
23468
|
+
if (existsSync10(changelogPath)) {
|
|
23424
23469
|
stdout += readTrimmed2(changelogPath, 260) + `
|
|
23425
23470
|
`;
|
|
23426
23471
|
} else {
|
|
@@ -23439,7 +23484,7 @@ function changelogContext(root, range) {
|
|
|
23439
23484
|
return { stdout, stderr: "", exitCode: 0, cwd };
|
|
23440
23485
|
}
|
|
23441
23486
|
function docsRefreshContext(root, range) {
|
|
23442
|
-
const cwd =
|
|
23487
|
+
const cwd = path29.resolve(repoRoot(root));
|
|
23443
23488
|
if (range !== undefined && !isResolvableContextRange(cwd, range))
|
|
23444
23489
|
return invalidRange(cwd);
|
|
23445
23490
|
const resolvedRange = rangeArgOrDefault(range, cwd);
|
|
@@ -23461,8 +23506,8 @@ function docsRefreshContext(root, range) {
|
|
|
23461
23506
|
`) + `
|
|
23462
23507
|
`;
|
|
23463
23508
|
stdout += printSection("README Preview");
|
|
23464
|
-
const readme =
|
|
23465
|
-
if (
|
|
23509
|
+
const readme = path29.join(cwd, "README.md");
|
|
23510
|
+
if (existsSync10(readme)) {
|
|
23466
23511
|
stdout += readTrimmed2(readme, 220) + `
|
|
23467
23512
|
`;
|
|
23468
23513
|
} else {
|
|
@@ -23470,8 +23515,8 @@ function docsRefreshContext(root, range) {
|
|
|
23470
23515
|
`;
|
|
23471
23516
|
}
|
|
23472
23517
|
stdout += printSection("Package Scripts");
|
|
23473
|
-
const pkgPath =
|
|
23474
|
-
if (
|
|
23518
|
+
const pkgPath = path29.join(cwd, "package.json");
|
|
23519
|
+
if (existsSync10(pkgPath)) {
|
|
23475
23520
|
try {
|
|
23476
23521
|
const pkg = JSON.parse(readFileSync8(pkgPath, "utf8"));
|
|
23477
23522
|
stdout += JSON.stringify({ name: pkg.name, version: pkg.version, scripts: pkg.scripts }, null, 2) + `
|
|
@@ -23484,7 +23529,7 @@ function docsRefreshContext(root, range) {
|
|
|
23484
23529
|
return { stdout, stderr: "", exitCode: 0, cwd };
|
|
23485
23530
|
}
|
|
23486
23531
|
function releaseNotesContext(root, rangeOrTag) {
|
|
23487
|
-
const cwd =
|
|
23532
|
+
const cwd = path29.resolve(repoRoot(root));
|
|
23488
23533
|
if (!rangeOrTag) {
|
|
23489
23534
|
return {
|
|
23490
23535
|
stdout: "",
|
|
@@ -23527,7 +23572,7 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
23527
23572
|
`;
|
|
23528
23573
|
stdout += printSection("Existing Release Files");
|
|
23529
23574
|
for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
|
|
23530
|
-
if (
|
|
23575
|
+
if (existsSync10(path29.join(cwd, rel)))
|
|
23531
23576
|
stdout += rel + `
|
|
23532
23577
|
`;
|
|
23533
23578
|
}
|
|
@@ -23559,7 +23604,7 @@ import { spawnSync as spawnSync19 } from "node:child_process";
|
|
|
23559
23604
|
|
|
23560
23605
|
// packages/workit-core/src/core/pr-create.ts
|
|
23561
23606
|
import fs20 from "node:fs";
|
|
23562
|
-
import
|
|
23607
|
+
import path30 from "node:path";
|
|
23563
23608
|
import { spawnSync as spawnSync18 } from "node:child_process";
|
|
23564
23609
|
import { pathToFileURL } from "node:url";
|
|
23565
23610
|
// packages/workit-core/src/forge/pr-body.ts
|
|
@@ -23580,11 +23625,11 @@ var LOCAL = bounded(20000);
|
|
|
23580
23625
|
var NETWORK = bounded(60000);
|
|
23581
23626
|
function whichOnPath(tool) {
|
|
23582
23627
|
const names = process.platform === "win32" ? [tool, `${tool}.exe`, `${tool}.cmd`] : [tool];
|
|
23583
|
-
for (const dir of (process.env.PATH ?? "").split(
|
|
23628
|
+
for (const dir of (process.env.PATH ?? "").split(path30.delimiter)) {
|
|
23584
23629
|
if (!dir)
|
|
23585
23630
|
continue;
|
|
23586
23631
|
for (const name of names) {
|
|
23587
|
-
const candidate =
|
|
23632
|
+
const candidate = path30.join(dir, name);
|
|
23588
23633
|
try {
|
|
23589
23634
|
fs20.accessSync(candidate, fs20.constants.X_OK);
|
|
23590
23635
|
return candidate;
|
|
@@ -23606,7 +23651,7 @@ var pushRemote = (cwd) => {
|
|
|
23606
23651
|
};
|
|
23607
23652
|
var safePushUrl = (remote) => {
|
|
23608
23653
|
const raw = remote.trim();
|
|
23609
|
-
if (
|
|
23654
|
+
if (path30.isAbsolute(raw))
|
|
23610
23655
|
return pathToFileURL(raw).href;
|
|
23611
23656
|
if (!raw.includes("://")) {
|
|
23612
23657
|
const scp = /^(?:([^@\s]+)@)?([^:]+):(.+)$/u.exec(raw);
|
|
@@ -23738,7 +23783,7 @@ var fetchGitLabIssueBody = async (ref, root, deps = {}) => {
|
|
|
23738
23783
|
|
|
23739
23784
|
// packages/workit-core/src/core/youtrack.ts
|
|
23740
23785
|
import fs22 from "node:fs";
|
|
23741
|
-
import
|
|
23786
|
+
import path32 from "node:path";
|
|
23742
23787
|
|
|
23743
23788
|
// packages/workit-core/src/core/templates.ts
|
|
23744
23789
|
var repoRoot2 = assetRoot();
|
|
@@ -23753,7 +23798,7 @@ import { spawnSync as spawnSync20 } from "node:child_process";
|
|
|
23753
23798
|
|
|
23754
23799
|
// packages/workit-core/src/forge/exec.ts
|
|
23755
23800
|
import fs21 from "node:fs";
|
|
23756
|
-
import
|
|
23801
|
+
import path31 from "node:path";
|
|
23757
23802
|
|
|
23758
23803
|
// packages/workit-core/src/forge/redact.ts
|
|
23759
23804
|
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_.-]*`;
|
|
@@ -23768,11 +23813,11 @@ var failure3 = (code, error, unblock) => ({ ok: false, code, error, ...unblock ?
|
|
|
23768
23813
|
// packages/workit-core/src/forge/exec.ts
|
|
23769
23814
|
var MAX_BUFFER2 = 64 * 1024 * 1024;
|
|
23770
23815
|
function findExecutable(bin, env) {
|
|
23771
|
-
const dirs = (env.PATH ?? env.Path ?? "").split(
|
|
23816
|
+
const dirs = (env.PATH ?? env.Path ?? "").split(path31.delimiter).filter(Boolean);
|
|
23772
23817
|
const exts = process.platform === "win32" ? [".exe"] : [""];
|
|
23773
23818
|
for (const dir of dirs)
|
|
23774
23819
|
for (const ext of exts) {
|
|
23775
|
-
const candidate =
|
|
23820
|
+
const candidate = path31.join(dir, `${bin}${ext}`);
|
|
23776
23821
|
try {
|
|
23777
23822
|
const stat = fs21.statSync(candidate);
|
|
23778
23823
|
if (stat.isFile())
|
|
@@ -23884,7 +23929,7 @@ function ytrackReadiness(run, host) {
|
|
|
23884
23929
|
|
|
23885
23930
|
// packages/workit-core/src/core/youtrack.ts
|
|
23886
23931
|
var ISSUE_RE = /^[A-Z]+-\d+$/;
|
|
23887
|
-
var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ??
|
|
23932
|
+
var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path32.join(resolveConfigDir(), "youtrack.json");
|
|
23888
23933
|
var readYouTrackContextConfig = () => {
|
|
23889
23934
|
const cfgPath = youTrackReadOnlyConfigPath();
|
|
23890
23935
|
if (!fs22.existsSync(cfgPath))
|
|
@@ -24258,22 +24303,22 @@ function resolveGitRevision(root, value) {
|
|
|
24258
24303
|
}
|
|
24259
24304
|
}
|
|
24260
24305
|
function resolveInside(root, candidate) {
|
|
24261
|
-
const base =
|
|
24262
|
-
const target =
|
|
24263
|
-
if (target !== base && !target.startsWith(base +
|
|
24306
|
+
const base = realpathSync8(root);
|
|
24307
|
+
const target = path33.resolve(base, candidate);
|
|
24308
|
+
if (target !== base && !target.startsWith(base + path33.sep)) {
|
|
24264
24309
|
throw new Error("path must stay inside repository root");
|
|
24265
24310
|
}
|
|
24266
24311
|
let ancestor = target;
|
|
24267
|
-
while (!
|
|
24268
|
-
ancestor =
|
|
24269
|
-
const canonicalAncestor =
|
|
24270
|
-
if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base +
|
|
24312
|
+
while (!existsSync11(ancestor))
|
|
24313
|
+
ancestor = path33.dirname(ancestor);
|
|
24314
|
+
const canonicalAncestor = realpathSync8(ancestor);
|
|
24315
|
+
if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path33.sep)) {
|
|
24271
24316
|
throw new Error("path must stay inside repository root");
|
|
24272
24317
|
}
|
|
24273
24318
|
return target;
|
|
24274
24319
|
}
|
|
24275
24320
|
function run2(root, executable, args, env = {}) {
|
|
24276
|
-
const cwd =
|
|
24321
|
+
const cwd = realpathSync8(root);
|
|
24277
24322
|
const result = spawnSync21(executable, args, {
|
|
24278
24323
|
cwd,
|
|
24279
24324
|
encoding: "utf8",
|
|
@@ -24328,7 +24373,7 @@ var capabilitiesFor = (descriptor, observed = {}) => descriptor.capabilities.map
|
|
|
24328
24373
|
};
|
|
24329
24374
|
});
|
|
24330
24375
|
// packages/workit-core/src/hooks/context.ts
|
|
24331
|
-
import
|
|
24376
|
+
import path34 from "node:path";
|
|
24332
24377
|
var MIGRATION_PENDING_NOTE = "workit migration pending — run `workit task status`";
|
|
24333
24378
|
var migrationPending = (result) => !result.ok && result.code === "needs_input" && (result.error ?? "").startsWith(MIGRATION_PENDING);
|
|
24334
24379
|
var boundTo = (entry, session) => entry.sessions.some((item) => item.host === session.host && item.handle === session.handle);
|
|
@@ -24416,7 +24461,7 @@ function entryCompactContext(store, entry, session, context) {
|
|
|
24416
24461
|
current: () => recentSignal(store.root)
|
|
24417
24462
|
};
|
|
24418
24463
|
const observed = task?.data.evidence.some(isObservedCheck) ?? false;
|
|
24419
|
-
const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [
|
|
24464
|
+
const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [path34.resolve(store.root, ref.path)] : []));
|
|
24420
24465
|
const observedFiles = filesKey(files);
|
|
24421
24466
|
const compact = compactContext(store, context, entry?.id ?? null, freshness, origin && { origin: origin.origin, taskId: origin.entry.id });
|
|
24422
24467
|
if (!compact.ok || !compact.data)
|
|
@@ -24515,8 +24560,8 @@ var isAllowedWorkitCommand = (command) => {
|
|
|
24515
24560
|
};
|
|
24516
24561
|
// packages/workit-core/src/core/heavy-rules.ts
|
|
24517
24562
|
import fs23 from "node:fs";
|
|
24518
|
-
import
|
|
24519
|
-
import
|
|
24563
|
+
import os8 from "node:os";
|
|
24564
|
+
import path35 from "node:path";
|
|
24520
24565
|
var EMPTY2 = () => ({ deny: [], allow: [] });
|
|
24521
24566
|
var readText3 = (file) => {
|
|
24522
24567
|
try {
|
|
@@ -24557,23 +24602,23 @@ function parseJsonc(text) {
|
|
|
24557
24602
|
return JSON.parse(out.replace(/,(\s*[}\]])/gu, "$1"));
|
|
24558
24603
|
}
|
|
24559
24604
|
function gitTop(cwd) {
|
|
24560
|
-
for (let dir =
|
|
24561
|
-
if (fs23.existsSync(
|
|
24605
|
+
for (let dir = path35.resolve(cwd);; dir = path35.dirname(dir)) {
|
|
24606
|
+
if (fs23.existsSync(path35.join(dir, ".git")))
|
|
24562
24607
|
return dir;
|
|
24563
|
-
if (
|
|
24608
|
+
if (path35.dirname(dir) === dir)
|
|
24564
24609
|
return null;
|
|
24565
24610
|
}
|
|
24566
24611
|
}
|
|
24567
24612
|
var projectDirs = (cwd) => {
|
|
24568
24613
|
const top = gitTop(cwd);
|
|
24569
24614
|
const dirs = [];
|
|
24570
|
-
for (let dir =
|
|
24615
|
+
for (let dir = path35.resolve(cwd);; dir = path35.dirname(dir)) {
|
|
24571
24616
|
dirs.push(dir);
|
|
24572
|
-
if (!top || dir === top ||
|
|
24617
|
+
if (!top || dir === top || path35.dirname(dir) === dir)
|
|
24573
24618
|
return dirs;
|
|
24574
24619
|
}
|
|
24575
24620
|
};
|
|
24576
|
-
var homeOf = (env) => env.HOME ||
|
|
24621
|
+
var homeOf = (env) => env.HOME || os8.homedir();
|
|
24577
24622
|
var CLAUDE_MANAGED = {
|
|
24578
24623
|
linux: "/etc/claude-code/managed-settings.json",
|
|
24579
24624
|
darwin: "/Library/Application Support/ClaudeCode/managed-settings.json",
|
|
@@ -24581,12 +24626,12 @@ var CLAUDE_MANAGED = {
|
|
|
24581
24626
|
};
|
|
24582
24627
|
function claudeSettingsFiles(cwd, env, platform = process.platform) {
|
|
24583
24628
|
const project = env.CLAUDE_PROJECT_DIR || gitTop(cwd) || cwd;
|
|
24584
|
-
const user = env.CLAUDE_CONFIG_DIR ||
|
|
24629
|
+
const user = env.CLAUDE_CONFIG_DIR || path35.join(homeOf(env), ".claude");
|
|
24585
24630
|
return [
|
|
24586
24631
|
...CLAUDE_MANAGED[platform] ? [CLAUDE_MANAGED[platform]] : [],
|
|
24587
|
-
|
|
24588
|
-
|
|
24589
|
-
|
|
24632
|
+
path35.join(user, "settings.json"),
|
|
24633
|
+
path35.join(project, ".claude", "settings.json"),
|
|
24634
|
+
path35.join(project, ".claude", "settings.local.json")
|
|
24590
24635
|
];
|
|
24591
24636
|
}
|
|
24592
24637
|
var bashPattern = (entry) => {
|
|
@@ -24676,10 +24721,10 @@ var opencodeConfig = (value, rules) => {
|
|
|
24676
24721
|
function opencodeRules(cwd, env = process.env) {
|
|
24677
24722
|
const rules = EMPTY2();
|
|
24678
24723
|
try {
|
|
24679
|
-
const config = env.XDG_CONFIG_HOME ||
|
|
24724
|
+
const config = env.XDG_CONFIG_HOME || path35.join(homeOf(env), ".config");
|
|
24680
24725
|
const files = [
|
|
24681
|
-
...OPENCODE_NAMES.map((name) =>
|
|
24682
|
-
...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [
|
|
24726
|
+
...OPENCODE_NAMES.map((name) => path35.join(config, "opencode", name)),
|
|
24727
|
+
...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [path35.join(dir, name), path35.join(dir, ".opencode", name)])),
|
|
24683
24728
|
...env.OPENCODE_CONFIG ? [env.OPENCODE_CONFIG] : []
|
|
24684
24729
|
];
|
|
24685
24730
|
for (const file of files) {
|
|
@@ -24723,9 +24768,9 @@ var codexRule = (body) => {
|
|
|
24723
24768
|
function codexRules(cwd, env = process.env) {
|
|
24724
24769
|
const rules = EMPTY2();
|
|
24725
24770
|
try {
|
|
24726
|
-
const home = env.CODEX_HOME ||
|
|
24771
|
+
const home = env.CODEX_HOME || path35.join(homeOf(env), ".codex");
|
|
24727
24772
|
const top = gitTop(cwd) ?? cwd;
|
|
24728
|
-
for (const dir of [
|
|
24773
|
+
for (const dir of [path35.join(home, "rules"), path35.join(top, ".codex", "rules")]) {
|
|
24729
24774
|
let files;
|
|
24730
24775
|
try {
|
|
24731
24776
|
files = fs23.readdirSync(dir).filter((name) => name.endsWith(".rules"));
|
|
@@ -24735,7 +24780,7 @@ function codexRules(cwd, env = process.env) {
|
|
|
24735
24780
|
return "unreadable";
|
|
24736
24781
|
}
|
|
24737
24782
|
for (const name of files) {
|
|
24738
|
-
const text = readText3(
|
|
24783
|
+
const text = readText3(path35.join(dir, name)) ?? "";
|
|
24739
24784
|
for (const part of text.split(/\bprefix_rule\s*\(/u).slice(1)) {
|
|
24740
24785
|
const rule = codexRule(part);
|
|
24741
24786
|
if (!rule)
|
|
@@ -24754,8 +24799,8 @@ function cursorRules(cwd, env = process.env) {
|
|
|
24754
24799
|
try {
|
|
24755
24800
|
const top = gitTop(cwd) ?? cwd;
|
|
24756
24801
|
for (const file of [
|
|
24757
|
-
|
|
24758
|
-
|
|
24802
|
+
path35.join(homeOf(env), ".cursor", "cli-config.json"),
|
|
24803
|
+
path35.join(top, ".cursor", "cli.json")
|
|
24759
24804
|
]) {
|
|
24760
24805
|
const text = readText3(file);
|
|
24761
24806
|
if (text === null)
|
|
@@ -24830,10 +24875,10 @@ function wrapAllowed(read, words, command, options = {}) {
|
|
|
24830
24875
|
|
|
24831
24876
|
// packages/workit-core/src/core/heavy.ts
|
|
24832
24877
|
import fs24 from "node:fs";
|
|
24833
|
-
import
|
|
24878
|
+
import path36 from "node:path";
|
|
24834
24879
|
var stateDir2 = (env, platform = process.platform) => stateDir(env, platform);
|
|
24835
24880
|
var HEAVY_COMMANDS_FILE = "heavy-commands.json";
|
|
24836
|
-
var heavyCommandsFile = (env) =>
|
|
24881
|
+
var heavyCommandsFile = (env) => path36.join(stateDir2(env), HEAVY_COMMANDS_FILE);
|
|
24837
24882
|
var HEAVY_SCRIPT = /^(?:test|tests|t|tst|unit|integration|e2e|coverage|cov|lint|eslint|typecheck|type-check|types|tsc|check|verify|validate|build|compile|bundle|ci|sonar|cypress|playwright|jest|vitest|mocha|bench|benchmark|all)(?:$|[:_.-])/iu;
|
|
24838
24883
|
var INFO_FLAGS = new Set(["--version", "-v", "-V", "--help", "-h", "help", "version"]);
|
|
24839
24884
|
var WATCH_FLAG = /^(?:--watch(?:All)?(?:=.*)?|-w|--serve)$/u;
|
|
@@ -25108,7 +25153,7 @@ function machinePatterns(env) {
|
|
|
25108
25153
|
return isRecord5(value) ? stringList(value.patterns) : [];
|
|
25109
25154
|
}
|
|
25110
25155
|
function repoPatterns(cwd) {
|
|
25111
|
-
return repoHeavyCommands(gitTop(cwd) ??
|
|
25156
|
+
return repoHeavyCommands(gitTop(cwd) ?? path36.resolve(cwd));
|
|
25112
25157
|
}
|
|
25113
25158
|
function heavyLines(lines, options) {
|
|
25114
25159
|
const found = [];
|
|
@@ -25186,12 +25231,12 @@ function heavyPlan(command, options) {
|
|
|
25186
25231
|
}
|
|
25187
25232
|
function workitOnPath2(env = process.env) {
|
|
25188
25233
|
const names = process.platform === "win32" ? ["workit.exe", "workit.cmd", "workit"] : ["workit"];
|
|
25189
|
-
for (const dir of (env.PATH ?? "").split(
|
|
25234
|
+
for (const dir of (env.PATH ?? "").split(path36.delimiter))
|
|
25190
25235
|
for (const name of names) {
|
|
25191
25236
|
if (!dir)
|
|
25192
25237
|
continue;
|
|
25193
25238
|
try {
|
|
25194
|
-
fs24.accessSync(
|
|
25239
|
+
fs24.accessSync(path36.join(dir, name), fs24.constants.X_OK);
|
|
25195
25240
|
return true;
|
|
25196
25241
|
} catch {}
|
|
25197
25242
|
}
|
|
@@ -25209,7 +25254,7 @@ function leaseRewrite(command) {
|
|
|
25209
25254
|
|
|
25210
25255
|
// packages/workit-core/src/core/heavy-words.ts
|
|
25211
25256
|
import fs25 from "node:fs";
|
|
25212
|
-
import
|
|
25257
|
+
import path37 from "node:path";
|
|
25213
25258
|
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(" "));
|
|
25214
25259
|
var wordsOf = (command) => command.split(/[\s;&|()<>`'"]+/u).map((word) => (word.split(/[\\/]/u).at(-1) ?? "").toLowerCase().replace(/\.(?:exe|cmd|bat)$/u, "")).filter(Boolean);
|
|
25215
25260
|
var stateDir3 = (env) => stateDir(env);
|
|
@@ -25222,15 +25267,15 @@ var readJson2 = (file) => {
|
|
|
25222
25267
|
};
|
|
25223
25268
|
var patternWords = (cwd, env) => {
|
|
25224
25269
|
const patterns = [];
|
|
25225
|
-
const machine = readJson2(
|
|
25270
|
+
const machine = readJson2(path37.join(stateDir3(env), "heavy-commands.json"));
|
|
25226
25271
|
if (Array.isArray(machine?.patterns))
|
|
25227
25272
|
patterns.push(...machine.patterns);
|
|
25228
|
-
for (let dir =
|
|
25229
|
-
if (fs25.existsSync(
|
|
25273
|
+
for (let dir = path37.resolve(cwd);; dir = path37.dirname(dir)) {
|
|
25274
|
+
if (fs25.existsSync(path37.join(dir, ".git"))) {
|
|
25230
25275
|
patterns.push(...repoHeavyCommands(dir));
|
|
25231
25276
|
break;
|
|
25232
25277
|
}
|
|
25233
|
-
if (
|
|
25278
|
+
if (path37.dirname(dir) === dir)
|
|
25234
25279
|
break;
|
|
25235
25280
|
}
|
|
25236
25281
|
const words = new Set;
|
|
@@ -25293,16 +25338,16 @@ function heavyGate(cwd, command, options) {
|
|
|
25293
25338
|
}
|
|
25294
25339
|
}
|
|
25295
25340
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
25296
|
-
import { existsSync as
|
|
25297
|
-
import
|
|
25298
|
-
import
|
|
25341
|
+
import { existsSync as existsSync12, realpathSync as realpathSync9, statSync as statSync4 } from "node:fs";
|
|
25342
|
+
import os10 from "node:os";
|
|
25343
|
+
import path39 from "node:path";
|
|
25299
25344
|
|
|
25300
25345
|
// packages/workit-core/src/core/live-session.ts
|
|
25301
25346
|
import { spawnSync as spawnSync22 } from "node:child_process";
|
|
25302
25347
|
import { createHash as createHash17 } from "node:crypto";
|
|
25303
25348
|
import fs26 from "node:fs";
|
|
25304
|
-
import
|
|
25305
|
-
import
|
|
25349
|
+
import os9 from "node:os";
|
|
25350
|
+
import path38 from "node:path";
|
|
25306
25351
|
var LIVE_SESSION_TTL_MS = 15 * 60000;
|
|
25307
25352
|
var HEARTBEAT_EVERY_MS = 30000;
|
|
25308
25353
|
var liveProbe = {
|
|
@@ -25376,15 +25421,15 @@ var liveOwner = (input, transport, env = process.env) => {
|
|
|
25376
25421
|
};
|
|
25377
25422
|
};
|
|
25378
25423
|
var checkoutOf = (target) => {
|
|
25379
|
-
let dir =
|
|
25380
|
-
while (!fs26.existsSync(dir) &&
|
|
25381
|
-
dir =
|
|
25424
|
+
let dir = path38.resolve(target);
|
|
25425
|
+
while (!fs26.existsSync(dir) && path38.dirname(dir) !== dir)
|
|
25426
|
+
dir = path38.dirname(dir);
|
|
25382
25427
|
if (fs26.existsSync(dir) && !fs26.statSync(dir).isDirectory())
|
|
25383
|
-
dir =
|
|
25384
|
-
const parts = dir.split(
|
|
25428
|
+
dir = path38.dirname(dir);
|
|
25429
|
+
const parts = dir.split(path38.sep);
|
|
25385
25430
|
const dotGit = parts.lastIndexOf(".git");
|
|
25386
25431
|
if (dotGit > 0)
|
|
25387
|
-
dir = parts.slice(0, dotGit).join(
|
|
25432
|
+
dir = parts.slice(0, dotGit).join(path38.sep) || path38.sep;
|
|
25388
25433
|
const location = resolveStore(dir);
|
|
25389
25434
|
if (location instanceof Error || !location.shared || !location.top)
|
|
25390
25435
|
return null;
|
|
@@ -25394,9 +25439,9 @@ var checkoutOf = (target) => {
|
|
|
25394
25439
|
} catch {}
|
|
25395
25440
|
return top;
|
|
25396
25441
|
};
|
|
25397
|
-
var markerFile2 = (top) =>
|
|
25442
|
+
var markerFile2 = (top) => path38.join(resolveStateDir(), "live-sessions", `${createHash17("sha256").update(checkoutKey(top)).digest("hex").slice(0, 32)}.json`);
|
|
25398
25443
|
var checkoutKey = (top, platform = process.platform) => {
|
|
25399
|
-
let key =
|
|
25444
|
+
let key = path38.resolve(top);
|
|
25400
25445
|
try {
|
|
25401
25446
|
key = fs26.realpathSync.native(key);
|
|
25402
25447
|
} catch {}
|
|
@@ -25427,7 +25472,7 @@ var isLive = (marker, deps) => {
|
|
|
25427
25472
|
const age = ageOf2(marker, deps.now ?? new Date);
|
|
25428
25473
|
if (age > (deps.ttlMs ?? LIVE_SESSION_TTL_MS))
|
|
25429
25474
|
return false;
|
|
25430
|
-
if (marker.machine !== (deps.machine ??
|
|
25475
|
+
if (marker.machine !== (deps.machine ?? os9.hostname()) || marker.pid === null)
|
|
25431
25476
|
return true;
|
|
25432
25477
|
if (!(deps.alive ?? processAlive)(marker.pid))
|
|
25433
25478
|
return false;
|
|
@@ -25456,7 +25501,7 @@ var liveConflict = (target, owner, deps = {}) => {
|
|
|
25456
25501
|
const marker = readMarker(file);
|
|
25457
25502
|
if (!marker || sameLead(marker, owner) || !isLive(marker, deps))
|
|
25458
25503
|
return null;
|
|
25459
|
-
if (sameOwner(marker, owner, deps.machine ??
|
|
25504
|
+
if (sameOwner(marker, owner, deps.machine ?? os9.hostname()))
|
|
25460
25505
|
return null;
|
|
25461
25506
|
return { marker, file, ageMs: ageOf2(marker, deps.now ?? new Date), checkout };
|
|
25462
25507
|
} catch {
|
|
@@ -25470,7 +25515,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
|
|
|
25470
25515
|
return;
|
|
25471
25516
|
const file = markerFile2(checkout);
|
|
25472
25517
|
const now = deps.now ?? new Date;
|
|
25473
|
-
const machine = deps.machine ??
|
|
25518
|
+
const machine = deps.machine ?? os9.hostname();
|
|
25474
25519
|
const current = readMarker(file);
|
|
25475
25520
|
if (current) {
|
|
25476
25521
|
const age = ageOf2(current, now);
|
|
@@ -25491,7 +25536,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
|
|
|
25491
25536
|
checkout,
|
|
25492
25537
|
heartbeatAt: now.toISOString()
|
|
25493
25538
|
};
|
|
25494
|
-
fs26.mkdirSync(
|
|
25539
|
+
fs26.mkdirSync(path38.dirname(file), { recursive: true });
|
|
25495
25540
|
const temp = `${file}.${process.pid}.tmp`;
|
|
25496
25541
|
fs26.writeFileSync(temp, JSON.stringify(marker));
|
|
25497
25542
|
fs26.renameSync(temp, file);
|
|
@@ -25503,22 +25548,22 @@ var NONE3 = { kind: "none" };
|
|
|
25503
25548
|
var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
|
|
25504
25549
|
var canonical3 = (file) => {
|
|
25505
25550
|
let rest = "";
|
|
25506
|
-
for (let dir =
|
|
25551
|
+
for (let dir = path39.resolve(file);; dir = path39.dirname(dir)) {
|
|
25507
25552
|
try {
|
|
25508
|
-
return
|
|
25553
|
+
return path39.join(realpathSync9.native(dir), rest);
|
|
25509
25554
|
} catch {
|
|
25510
|
-
if (
|
|
25511
|
-
return
|
|
25512
|
-
rest = rest ?
|
|
25555
|
+
if (path39.dirname(dir) === dir)
|
|
25556
|
+
return path39.resolve(file);
|
|
25557
|
+
rest = rest ? path39.join(path39.basename(dir), rest) : path39.basename(dir);
|
|
25513
25558
|
}
|
|
25514
25559
|
}
|
|
25515
25560
|
};
|
|
25516
25561
|
var exempt = (cwd, root, file, plans) => {
|
|
25517
25562
|
const fold = (value) => CASE_INSENSITIVE ? value.toLowerCase() : value;
|
|
25518
|
-
const relative =
|
|
25519
|
-
if (relative.startsWith("..") ||
|
|
25563
|
+
const relative = path39.relative(fold(canonical3(root)), fold(canonical3(path39.resolve(cwd, file))));
|
|
25564
|
+
if (relative.startsWith("..") || path39.isAbsolute(relative))
|
|
25520
25565
|
return true;
|
|
25521
|
-
const posix = relative.split(
|
|
25566
|
+
const posix = relative.split(path39.sep).join("/");
|
|
25522
25567
|
const segments = posix.split("/");
|
|
25523
25568
|
return /\.mdx?$/i.test(posix) || segments[0] === "docs" || segments.includes("plans") || [...plans].some((plan) => fold(plan) === posix);
|
|
25524
25569
|
};
|
|
@@ -25869,10 +25914,10 @@ var linkSources = (args, at) => {
|
|
|
25869
25914
|
const sources = names.filter((name, index) => into >= 0 ? name !== dest : index < names.length - 1 || names.length === 1);
|
|
25870
25915
|
const target = dest === undefined ? null : at(dest);
|
|
25871
25916
|
const symbolic = args.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg));
|
|
25872
|
-
const base = target === null ? null : into >= 0 || sources.length > 1 ||
|
|
25917
|
+
const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync12(target) || /[\\/]$/.test(dest ?? "") ? target : path39.dirname(target);
|
|
25873
25918
|
return sources.flatMap((source) => {
|
|
25874
|
-
if (symbolic && base !== null && !
|
|
25875
|
-
return [
|
|
25919
|
+
if (symbolic && base !== null && !path39.isAbsolute(homeExpanded(source)))
|
|
25920
|
+
return [path39.resolve(base, source)];
|
|
25876
25921
|
const resolved = at(source);
|
|
25877
25922
|
return resolved ? [resolved] : [];
|
|
25878
25923
|
});
|
|
@@ -25901,7 +25946,7 @@ var shellWrites = (command, depth = 0) => {
|
|
|
25901
25946
|
return { writes: true, targets: unknown ? null : targets };
|
|
25902
25947
|
};
|
|
25903
25948
|
var cache3 = new Map;
|
|
25904
|
-
var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(
|
|
25949
|
+
var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path39.resolve(root, file)) ?? "-").join("\x00");
|
|
25905
25950
|
var gateFor = (cwd) => {
|
|
25906
25951
|
const store = new TaskStore(cwd);
|
|
25907
25952
|
const listed = store.listTaskIndex();
|
|
@@ -25981,13 +26026,13 @@ var gitMutationDirs = (cwd, command, dialect) => {
|
|
|
25981
26026
|
return [];
|
|
25982
26027
|
if (sub === "stash" && ["list", "show"].includes(rest[0] ?? ""))
|
|
25983
26028
|
return [];
|
|
25984
|
-
return [
|
|
26029
|
+
return [path39.resolve(cwd, invocation.dir ?? ".")];
|
|
25985
26030
|
});
|
|
25986
26031
|
};
|
|
25987
26032
|
var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
|
|
25988
26033
|
var PUSHD2 = new Set(["pushd", "push-location"]);
|
|
25989
26034
|
var POPD2 = new Set(["popd", "pop-location"]);
|
|
25990
|
-
var UNKNOWN_DIR =
|
|
26035
|
+
var UNKNOWN_DIR = path39.resolve(path39.parse(process.cwd()).root, ".workit-unknown-dir");
|
|
25991
26036
|
var cdInto = (dir, words, strict = false, vars = new Map) => {
|
|
25992
26037
|
const lost = strict ? UNKNOWN_DIR : undefined;
|
|
25993
26038
|
const found = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
|
|
@@ -25997,7 +26042,7 @@ var cdInto = (dir, words, strict = false, vars = new Map) => {
|
|
|
25997
26042
|
return lost;
|
|
25998
26043
|
if (dir === undefined)
|
|
25999
26044
|
return lost;
|
|
26000
|
-
return target === undefined ?
|
|
26045
|
+
return target === undefined ? os10.homedir() : path39.resolve(dir, target);
|
|
26001
26046
|
};
|
|
26002
26047
|
var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
|
|
26003
26048
|
var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
|
|
@@ -26131,7 +26176,7 @@ var untrustedVars = (segments) => {
|
|
|
26131
26176
|
}
|
|
26132
26177
|
return { all, names };
|
|
26133
26178
|
};
|
|
26134
|
-
var UNKNOWN_VAR =
|
|
26179
|
+
var UNKNOWN_VAR = path39.resolve(path39.parse(process.cwd()).root, ".workit-unknown-var");
|
|
26135
26180
|
var REFERENCE = /\$\{(\w+)[^}]*\}|\$(\w+)|\$\([^)]*\)?|`[^`]*`?/g;
|
|
26136
26181
|
var unresolvedRefs = (text) => [
|
|
26137
26182
|
...new Set([...text.matchAll(REFERENCE)].map((match) => {
|
|
@@ -26141,7 +26186,7 @@ var unresolvedRefs = (text) => [
|
|
|
26141
26186
|
];
|
|
26142
26187
|
var unknownVarTarget = (text) => {
|
|
26143
26188
|
const refs = unresolvedRefs(text);
|
|
26144
|
-
return
|
|
26189
|
+
return path39.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
|
|
26145
26190
|
};
|
|
26146
26191
|
var applyOperator = (value, operator) => {
|
|
26147
26192
|
if (operator === "")
|
|
@@ -26199,18 +26244,18 @@ var mktempPath = (value, dir) => {
|
|
|
26199
26244
|
template = arg;
|
|
26200
26245
|
}
|
|
26201
26246
|
if (base === null && (temp || template === undefined))
|
|
26202
|
-
base =
|
|
26247
|
+
base = os10.tmpdir();
|
|
26203
26248
|
const name = homeExpanded(template ?? "tmp.XXXXXXXXXX");
|
|
26204
|
-
if (
|
|
26249
|
+
if (path39.isAbsolute(name))
|
|
26205
26250
|
return name;
|
|
26206
26251
|
const from = base === null ? dir : homeExpanded(base);
|
|
26207
|
-
if (from === undefined || !
|
|
26252
|
+
if (from === undefined || !path39.isAbsolute(from) && dir === undefined)
|
|
26208
26253
|
return null;
|
|
26209
|
-
return
|
|
26254
|
+
return path39.resolve(dir ?? from, from, name);
|
|
26210
26255
|
};
|
|
26211
26256
|
var homeExpanded = (file) => {
|
|
26212
26257
|
const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
|
|
26213
|
-
return match ? (process.env.HOME ||
|
|
26258
|
+
return match ? (process.env.HOME || os10.homedir()) + file.slice(match[0].length) : file;
|
|
26214
26259
|
};
|
|
26215
26260
|
var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherited = new Map) => {
|
|
26216
26261
|
const targets = [];
|
|
@@ -26226,9 +26271,9 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26226
26271
|
const home = homeExpanded(text);
|
|
26227
26272
|
if (strict && unresolvedRefs(home).length > 0)
|
|
26228
26273
|
return [unknownVarTarget(home)];
|
|
26229
|
-
if (
|
|
26274
|
+
if (path39.isAbsolute(home))
|
|
26230
26275
|
return [home];
|
|
26231
|
-
return base === undefined ? [] : [
|
|
26276
|
+
return base === undefined ? [] : [path39.resolve(base, home)];
|
|
26232
26277
|
});
|
|
26233
26278
|
const at = (file) => {
|
|
26234
26279
|
const all = atAll(file);
|
|
@@ -26370,7 +26415,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26370
26415
|
const here = segment.unanalyzable ? DIR_TARGET : `${OPAQUE_TARGET}${encodeURIComponent(runner?.split(/[\\/]/).at(-1) ?? "a command")}`;
|
|
26371
26416
|
for (const file of opaque ?? [])
|
|
26372
26417
|
for (const resolved of atAll(file))
|
|
26373
|
-
targets.push(file === "." ?
|
|
26418
|
+
targets.push(file === "." ? path39.join(resolved, here) : resolved);
|
|
26374
26419
|
const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
|
|
26375
26420
|
if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)))
|
|
26376
26421
|
targets.push(...linkSources(words.slice(ln + 1), at));
|
|
@@ -26381,7 +26426,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26381
26426
|
const edits = editsOf(body);
|
|
26382
26427
|
if (edits === null) {
|
|
26383
26428
|
if (dir !== undefined)
|
|
26384
|
-
targets.push(
|
|
26429
|
+
targets.push(path39.join(dir, DIR_TARGET));
|
|
26385
26430
|
} else
|
|
26386
26431
|
for (const file of edits)
|
|
26387
26432
|
targets.push(...atAll(file));
|
|
@@ -26389,7 +26434,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26389
26434
|
for (const invocation of workitInvocations(body.map(quoteWord2).join(" "), "posix")) {
|
|
26390
26435
|
const { at: runsIn, args } = workitCwd(dir, invocation, atAll);
|
|
26391
26436
|
if (args[0] === "git" && MUTATING_WORKIT_GIT.has(args[1] ?? "") && !inert(args.slice(2), ""))
|
|
26392
|
-
targets.push(...runsIn.map((runs) =>
|
|
26437
|
+
targets.push(...runsIn.map((runs) => path39.join(runs, DIR_TARGET)));
|
|
26393
26438
|
}
|
|
26394
26439
|
}
|
|
26395
26440
|
return targets;
|
|
@@ -26410,7 +26455,7 @@ var shellMutationTargets = (cwd, command, dialect = "posix", strict = false) =>
|
|
|
26410
26455
|
try {
|
|
26411
26456
|
return [
|
|
26412
26457
|
...segmentTargets(cwd, command, dialect, 0, strict),
|
|
26413
|
-
...gitMutationDirs(cwd, command, dialect).map((dir) =>
|
|
26458
|
+
...gitMutationDirs(cwd, command, dialect).map((dir) => path39.join(dir, DIR_TARGET))
|
|
26414
26459
|
];
|
|
26415
26460
|
} catch {
|
|
26416
26461
|
return [];
|
|
@@ -26447,7 +26492,7 @@ var liveDeny = ({ marker, checkout, ageMs, file }) => {
|
|
|
26447
26492
|
var guarded = (targets) => {
|
|
26448
26493
|
const seen = new Set;
|
|
26449
26494
|
return targets.filter((target) => {
|
|
26450
|
-
const dir =
|
|
26495
|
+
const dir = path39.dirname(target);
|
|
26451
26496
|
if (seen.has(dir))
|
|
26452
26497
|
return false;
|
|
26453
26498
|
seen.add(dir);
|
|
@@ -26468,7 +26513,7 @@ var claimAll = (owner, targets, deps) => {
|
|
|
26468
26513
|
for (const target of guarded(targets))
|
|
26469
26514
|
claimLiveSession(target, owner, deps);
|
|
26470
26515
|
};
|
|
26471
|
-
var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) =>
|
|
26516
|
+
var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path39.resolve(cwd, file)) : [path39.join(cwd, DIR_TARGET)];
|
|
26472
26517
|
var issuedTarget = (cwd, targets) => {
|
|
26473
26518
|
const state = resolveStateDir();
|
|
26474
26519
|
const found = targets.find((target) => underIssued(state, cwd, homeExpanded(target), process.platform, canonical3));
|
|
@@ -26476,7 +26521,7 @@ var issuedTarget = (cwd, targets) => {
|
|
|
26476
26521
|
};
|
|
26477
26522
|
var underIssued = (state, cwd, target, platform = process.platform, real = (file) => file) => {
|
|
26478
26523
|
const win = platform === "win32";
|
|
26479
|
-
const p = win ?
|
|
26524
|
+
const p = win ? path39.win32 : path39.posix;
|
|
26480
26525
|
const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
|
|
26481
26526
|
const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
|
|
26482
26527
|
const relative = p.relative(fold(real(p.resolve(state))), fold(real(p.resolve(cwd, named))));
|
|
@@ -26570,10 +26615,10 @@ import { spawnSync as spawnSync23 } from "node:child_process";
|
|
|
26570
26615
|
|
|
26571
26616
|
// packages/workit-core/src/ci-waiter.ts
|
|
26572
26617
|
import fs27 from "node:fs";
|
|
26573
|
-
import
|
|
26618
|
+
import path40 from "node:path";
|
|
26574
26619
|
var waiterFile = (cwd, pr) => {
|
|
26575
26620
|
const common = gitCommonDir(cwd);
|
|
26576
|
-
return common ?
|
|
26621
|
+
return common ? path40.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
|
|
26577
26622
|
};
|
|
26578
26623
|
var pidAlive2 = (pid) => {
|
|
26579
26624
|
if (!Number.isSafeInteger(pid) || pid <= 0)
|
|
@@ -27096,7 +27141,7 @@ var WRITE_TOOLS = new Set([
|
|
|
27096
27141
|
]);
|
|
27097
27142
|
// packages/workit-core/src/hooks/standing.ts
|
|
27098
27143
|
import fs28 from "node:fs";
|
|
27099
|
-
import
|
|
27144
|
+
import path41 from "node:path";
|
|
27100
27145
|
|
|
27101
27146
|
// packages/workit-core/src/hooks/hosts/claude-code.ts
|
|
27102
27147
|
var CLAUDE_CODE_DESCRIPTOR = {
|
|
@@ -27596,7 +27641,7 @@ var workitRole = (descriptor, agentType) => {
|
|
|
27596
27641
|
|
|
27597
27642
|
// packages/workit-core/src/hooks/standing.ts
|
|
27598
27643
|
var readPlans = (store) => {
|
|
27599
|
-
const dir =
|
|
27644
|
+
const dir = path41.join(store, "fanouts");
|
|
27600
27645
|
let names;
|
|
27601
27646
|
try {
|
|
27602
27647
|
names = fs28.readdirSync(dir).filter((name) => name.endsWith(".json"));
|
|
@@ -27606,7 +27651,7 @@ var readPlans = (store) => {
|
|
|
27606
27651
|
const plans = [];
|
|
27607
27652
|
for (const name of names) {
|
|
27608
27653
|
try {
|
|
27609
|
-
const raw = JSON.parse(fs28.readFileSync(
|
|
27654
|
+
const raw = JSON.parse(fs28.readFileSync(path41.join(dir, name), "utf8"));
|
|
27610
27655
|
if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
|
|
27611
27656
|
continue;
|
|
27612
27657
|
const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
|
|
@@ -27880,11 +27925,11 @@ var PROCESS_START = performance.timeOrigin;
|
|
|
27880
27925
|
// packages/workit-core/src/hooks/run.ts
|
|
27881
27926
|
if (false) {}
|
|
27882
27927
|
// packages/workit-opencode/src/shared/init-apply.ts
|
|
27883
|
-
import
|
|
27928
|
+
import path46 from "node:path";
|
|
27884
27929
|
|
|
27885
27930
|
// packages/workit-core/src/core/gitignore.ts
|
|
27886
|
-
import { existsSync as
|
|
27887
|
-
import
|
|
27931
|
+
import { existsSync as existsSync13, readFileSync as readFileSync9, writeFileSync as writeFileSync4 } from "node:fs";
|
|
27932
|
+
import path42 from "node:path";
|
|
27888
27933
|
var GITIGNORE_ENTRIES = [
|
|
27889
27934
|
"# workit: SDD working state (never commit)",
|
|
27890
27935
|
"docs/*/sdd/",
|
|
@@ -27904,8 +27949,8 @@ var GITIGNORE_ENTRIES = [
|
|
|
27904
27949
|
var ensureProjectGitignore = (workspaceRoot, confirmed) => {
|
|
27905
27950
|
if (!confirmed)
|
|
27906
27951
|
return { ok: false, error: "confirmed: true required" };
|
|
27907
|
-
const file =
|
|
27908
|
-
const existing =
|
|
27952
|
+
const file = path42.join(workspaceRoot, ".gitignore");
|
|
27953
|
+
const existing = existsSync13(file) ? readFileSync9(file, "utf8") : "";
|
|
27909
27954
|
const existingLines = new Set(existing.split(`
|
|
27910
27955
|
`).map((l) => l.trim()).filter(Boolean));
|
|
27911
27956
|
const added = [];
|
|
@@ -27924,33 +27969,33 @@ var ensureProjectGitignore = (workspaceRoot, confirmed) => {
|
|
|
27924
27969
|
` : "") + append.join(`
|
|
27925
27970
|
`) + `
|
|
27926
27971
|
`, "utf8");
|
|
27927
|
-
} else if (!
|
|
27972
|
+
} else if (!existsSync13(file)) {
|
|
27928
27973
|
writeFileSync4(file, "", "utf8");
|
|
27929
27974
|
}
|
|
27930
27975
|
return { ok: true, path: file, added };
|
|
27931
27976
|
};
|
|
27932
27977
|
|
|
27933
27978
|
// packages/workit-core/src/core/hygiene.ts
|
|
27934
|
-
import { existsSync as
|
|
27935
|
-
import
|
|
27979
|
+
import { existsSync as existsSync14, readFileSync as readFileSync10, readdirSync as readdirSync4, writeFileSync as writeFileSync5 } from "node:fs";
|
|
27980
|
+
import path43 from "node:path";
|
|
27936
27981
|
var repoRoot3 = assetRoot();
|
|
27937
|
-
var templatesDir = () =>
|
|
27982
|
+
var templatesDir = () => path43.join(repoRoot3, "templates", "hygiene");
|
|
27938
27983
|
var packageJson = (root) => {
|
|
27939
|
-
if (!
|
|
27984
|
+
if (!existsSync14(path43.join(root, "package.json")))
|
|
27940
27985
|
return null;
|
|
27941
27986
|
try {
|
|
27942
|
-
return JSON.parse(readFileSync10(
|
|
27987
|
+
return JSON.parse(readFileSync10(path43.join(root, "package.json"), "utf8"));
|
|
27943
27988
|
} catch {
|
|
27944
27989
|
return null;
|
|
27945
27990
|
}
|
|
27946
27991
|
};
|
|
27947
27992
|
var isOpenSource = (root) => {
|
|
27948
|
-
if (
|
|
27993
|
+
if (existsSync14(path43.join(root, "LICENSE")))
|
|
27949
27994
|
return true;
|
|
27950
27995
|
const pkg = packageJson(root);
|
|
27951
27996
|
if (pkg && !pkg.private)
|
|
27952
27997
|
return true;
|
|
27953
|
-
return
|
|
27998
|
+
return path43.basename(root) === "workit";
|
|
27954
27999
|
};
|
|
27955
28000
|
var licenseHolder = (root) => {
|
|
27956
28001
|
const pkg = packageJson(root);
|
|
@@ -27973,13 +28018,13 @@ var planHygieneFiles = (root, opts = {}) => {
|
|
|
27973
28018
|
files.push("LICENSE", "CONTRIBUTING.md");
|
|
27974
28019
|
const planned = [];
|
|
27975
28020
|
for (const file of files) {
|
|
27976
|
-
if (
|
|
28021
|
+
if (existsSync14(path43.join(root, file)))
|
|
27977
28022
|
continue;
|
|
27978
|
-
const tpl =
|
|
27979
|
-
if (!
|
|
28023
|
+
const tpl = path43.join(templatesDir(), file);
|
|
28024
|
+
if (!existsSync14(tpl))
|
|
27980
28025
|
continue;
|
|
27981
|
-
const content = readFileSync10(tpl, "utf8").replace(/<PROJECT>/g,
|
|
27982
|
-
planned.push({ path:
|
|
28026
|
+
const content = readFileSync10(tpl, "utf8").replace(/<PROJECT>/g, path43.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
|
|
28027
|
+
planned.push({ path: path43.join(root, file), content });
|
|
27983
28028
|
}
|
|
27984
28029
|
return planned;
|
|
27985
28030
|
};
|
|
@@ -27989,19 +28034,19 @@ var ensureHygieneFiles = (root, opts) => {
|
|
|
27989
28034
|
const created = [];
|
|
27990
28035
|
for (const planned of planHygieneFiles(root, opts)) {
|
|
27991
28036
|
writeFileSync5(planned.path, planned.content, "utf8");
|
|
27992
|
-
created.push(
|
|
28037
|
+
created.push(path43.basename(planned.path));
|
|
27993
28038
|
}
|
|
27994
28039
|
return { ok: true, created };
|
|
27995
28040
|
};
|
|
27996
28041
|
|
|
27997
28042
|
// packages/workit-core/src/core/init.ts
|
|
27998
28043
|
import fs29 from "node:fs";
|
|
27999
|
-
import
|
|
28044
|
+
import path45 from "node:path";
|
|
28000
28045
|
import { spawnSync as spawnSync24 } from "node:child_process";
|
|
28001
28046
|
|
|
28002
28047
|
// packages/workit-core/src/core/workspace-branch-policy.ts
|
|
28003
28048
|
import { mkdirSync as mkdirSync4, readFileSync as readFileSync11, renameSync as renameSync3, rmSync as rmSync2, writeFileSync as writeFileSync6 } from "node:fs";
|
|
28004
|
-
import
|
|
28049
|
+
import path44 from "node:path";
|
|
28005
28050
|
import { isDeepStrictEqual } from "node:util";
|
|
28006
28051
|
var readFileSafe = (p) => {
|
|
28007
28052
|
try {
|
|
@@ -28012,7 +28057,7 @@ var readFileSafe = (p) => {
|
|
|
28012
28057
|
};
|
|
28013
28058
|
function applyWorkspaceBranchPolicy(opts) {
|
|
28014
28059
|
const { workspace_root, env = process.env } = opts;
|
|
28015
|
-
const dir =
|
|
28060
|
+
const dir = path44.join(env.WORKIT_CONFIG ?? configDir2());
|
|
28016
28061
|
const {
|
|
28017
28062
|
status,
|
|
28018
28063
|
path: wsPath,
|
|
@@ -28024,7 +28069,7 @@ function applyWorkspaceBranchPolicy(opts) {
|
|
|
28024
28069
|
if (status === "malformed" || status === "invalid")
|
|
28025
28070
|
return { ok: false, error: workspacesError ?? `invalid workspaces.json: ${wsPath}` };
|
|
28026
28071
|
const detection = detectBranchPolicy(workspace_root);
|
|
28027
|
-
const name = String(env.WORKIT_BP_NAME ??
|
|
28072
|
+
const name = String(env.WORKIT_BP_NAME ?? path44.basename(workspace_root));
|
|
28028
28073
|
const integration = env.WORKIT_BP_INTEGRATION ?? detection.integration;
|
|
28029
28074
|
const policy = {
|
|
28030
28075
|
preset: detection.preset,
|
|
@@ -28073,7 +28118,7 @@ function applyWorkspaceBranchPolicy(opts) {
|
|
|
28073
28118
|
ok: false,
|
|
28074
28119
|
error: `workspaces.json changed while applying the branch policy: ${wsPath}`
|
|
28075
28120
|
};
|
|
28076
|
-
mkdirSync4(
|
|
28121
|
+
mkdirSync4(path44.dirname(wsPath), { recursive: true });
|
|
28077
28122
|
const tmp = `${wsPath}.${process.pid}.tmp`;
|
|
28078
28123
|
try {
|
|
28079
28124
|
writeFileSync6(tmp, JSON.stringify({ ...document, workspaces: next }, null, 2) + `
|
|
@@ -28173,7 +28218,7 @@ function initApplyData(action, env = process.env) {
|
|
|
28173
28218
|
fs29.mkdirSync(dir, { recursive: true });
|
|
28174
28219
|
switch (action) {
|
|
28175
28220
|
case "youtrack_json": {
|
|
28176
|
-
const out =
|
|
28221
|
+
const out = path45.join(dir, "youtrack.json");
|
|
28177
28222
|
fs29.writeFileSync(out, JSON.stringify(youtrackJsonContent(), null, 2) + `
|
|
28178
28223
|
`, "utf8");
|
|
28179
28224
|
return { action, ok: true, path: out };
|
|
@@ -28187,10 +28232,10 @@ function initApplyData(action, env = process.env) {
|
|
|
28187
28232
|
};
|
|
28188
28233
|
}
|
|
28189
28234
|
case "youtrack_scaffold": {
|
|
28190
|
-
const jsonOut =
|
|
28235
|
+
const jsonOut = path45.join(dir, "youtrack.json");
|
|
28191
28236
|
fs29.writeFileSync(jsonOut, JSON.stringify(youtrackJsonContent(), null, 2) + `
|
|
28192
28237
|
`, "utf8");
|
|
28193
|
-
const configPath =
|
|
28238
|
+
const configPath = path45.resolve(jsonOut);
|
|
28194
28239
|
const cfg = readJson3(configPath) ?? {};
|
|
28195
28240
|
const base = String(cfg.baseUrl ?? "").replace(/\/+$/, "");
|
|
28196
28241
|
const meeting = String(cfg.meetingIssue ?? "");
|
|
@@ -28226,10 +28271,10 @@ function initApplyData(action, env = process.env) {
|
|
|
28226
28271
|
};
|
|
28227
28272
|
}
|
|
28228
28273
|
case "vcs_scaffold": {
|
|
28229
|
-
const jsonOut =
|
|
28274
|
+
const jsonOut = path45.join(dir, "vcs.json");
|
|
28230
28275
|
fs29.writeFileSync(jsonOut, JSON.stringify(vcsJsonContent(), null, 2) + `
|
|
28231
28276
|
`, "utf8");
|
|
28232
|
-
const configPath =
|
|
28277
|
+
const configPath = path45.resolve(jsonOut);
|
|
28233
28278
|
const prev = process.env.WORKIT_VCS_CONFIG;
|
|
28234
28279
|
process.env.WORKIT_VCS_CONFIG = configPath;
|
|
28235
28280
|
try {
|
|
@@ -28348,7 +28393,7 @@ var executeInitApply = (args, directory, runtime) => {
|
|
|
28348
28393
|
protectedNames: args.branch_policy_protected
|
|
28349
28394
|
}, current);
|
|
28350
28395
|
writeConfig(next);
|
|
28351
|
-
return output(ok({ action: "config", path:
|
|
28396
|
+
return output(ok({ action: "config", path: path46.join(configDir2(), "config.json"), ...next }));
|
|
28352
28397
|
}
|
|
28353
28398
|
const env = Object.fromEntries(Object.entries({
|
|
28354
28399
|
WORKIT_YT_BASE_URL: args.base_url,
|
|
@@ -28364,15 +28409,15 @@ var executeInitApply = (args, directory, runtime) => {
|
|
|
28364
28409
|
};
|
|
28365
28410
|
|
|
28366
28411
|
// packages/workit-opencode/src/shared/session.ts
|
|
28367
|
-
import { realpathSync as
|
|
28368
|
-
import
|
|
28412
|
+
import { realpathSync as realpathSync10 } from "node:fs";
|
|
28413
|
+
import path47 from "node:path";
|
|
28369
28414
|
var sameWorkspace = (expected, observed) => {
|
|
28370
28415
|
if (typeof observed !== "string" || !observed)
|
|
28371
28416
|
return false;
|
|
28372
28417
|
try {
|
|
28373
|
-
return
|
|
28418
|
+
return realpathSync10(expected) === realpathSync10(observed);
|
|
28374
28419
|
} catch {
|
|
28375
|
-
return
|
|
28420
|
+
return path47.resolve(expected) === path47.resolve(observed);
|
|
28376
28421
|
}
|
|
28377
28422
|
};
|
|
28378
28423
|
|
|
@@ -28443,8 +28488,8 @@ var workitFamilyOf = (toolName) => {
|
|
|
28443
28488
|
};
|
|
28444
28489
|
|
|
28445
28490
|
// packages/workit-opencode/src/tools/context.ts
|
|
28446
|
-
import { realpathSync as
|
|
28447
|
-
import
|
|
28491
|
+
import { realpathSync as realpathSync11 } from "node:fs";
|
|
28492
|
+
import path48 from "node:path";
|
|
28448
28493
|
var createContextTool = () => ({
|
|
28449
28494
|
description: "Read Git, pull request, YouTrack, issue, changelog, release, or affected-file context.",
|
|
28450
28495
|
execute: async (args, context) => {
|
|
@@ -28454,7 +28499,7 @@ var createContextTool = () => ({
|
|
|
28454
28499
|
let root;
|
|
28455
28500
|
try {
|
|
28456
28501
|
const cwd = parsed.data.cwd;
|
|
28457
|
-
root =
|
|
28502
|
+
root = realpathSync11(cwd ? path48.resolve(context.directory, cwd) : context.directory);
|
|
28458
28503
|
} catch {
|
|
28459
28504
|
return JSON.stringify(failure2("invalid_input", "context target directory cannot be resolved"), null, 2);
|
|
28460
28505
|
}
|
|
@@ -28487,7 +28532,7 @@ var workerCoordinatorFor = (task, worker) => {
|
|
|
28487
28532
|
import { spawnSync as spawnSync28 } from "node:child_process";
|
|
28488
28533
|
import { createHash as createHash19 } from "node:crypto";
|
|
28489
28534
|
import fs31 from "node:fs";
|
|
28490
|
-
import
|
|
28535
|
+
import path51 from "node:path";
|
|
28491
28536
|
|
|
28492
28537
|
// packages/workit-core/src/fanout-landed.ts
|
|
28493
28538
|
import { spawnSync as spawnSync25 } from "node:child_process";
|
|
@@ -28717,12 +28762,12 @@ var NOTICE_TTL_MS = 7 * 86400000;
|
|
|
28717
28762
|
import { spawnSync as spawnSync27 } from "node:child_process";
|
|
28718
28763
|
import { createHash as createHash18, randomBytes as randomBytes4 } from "node:crypto";
|
|
28719
28764
|
import fs30 from "node:fs";
|
|
28720
|
-
import
|
|
28765
|
+
import path50 from "node:path";
|
|
28721
28766
|
|
|
28722
28767
|
// packages/workit-core/src/git/ops.ts
|
|
28723
28768
|
import { spawnSync as spawnSync26 } from "node:child_process";
|
|
28724
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
28725
|
-
import
|
|
28769
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync15, readdirSync as readdirSync5, readFileSync as readFileSync12, rmSync as rmSync3 } from "node:fs";
|
|
28770
|
+
import path49 from "node:path";
|
|
28726
28771
|
var COMMIT_TIMEOUT_MS = 10 * 60000;
|
|
28727
28772
|
var git5 = (cwd, args, options = {}) => {
|
|
28728
28773
|
const result = spawnSync26("git", args, {
|
|
@@ -28755,18 +28800,18 @@ function operationInProgress(cwd) {
|
|
|
28755
28800
|
if (!run.ok)
|
|
28756
28801
|
return null;
|
|
28757
28802
|
const found = run.stdout.split(`
|
|
28758
|
-
`).map((line) =>
|
|
28803
|
+
`).map((line) => path49.resolve(cwd, line.trim()));
|
|
28759
28804
|
const conflicted = () => git5(cwd, ["ls-files", "-u"]).stdout.trim() !== "";
|
|
28760
28805
|
for (const [index, [, operation]] of markers.entries()) {
|
|
28761
28806
|
const marker = found[index];
|
|
28762
|
-
if (!marker || !
|
|
28807
|
+
if (!marker || !existsSync15(marker))
|
|
28763
28808
|
continue;
|
|
28764
|
-
if (index === 1 &&
|
|
28809
|
+
if (index === 1 && existsSync15(path49.join(marker, "applying")))
|
|
28765
28810
|
return { operation: "am", commitAllowed: false, branch: null };
|
|
28766
|
-
if (index === 0 &&
|
|
28811
|
+
if (index === 0 && existsSync15(path49.join(marker, "amend")) && !conflicted()) {
|
|
28767
28812
|
let headName = "";
|
|
28768
28813
|
try {
|
|
28769
|
-
headName = readFileSync12(
|
|
28814
|
+
headName = readFileSync12(path49.join(marker, "head-name"), "utf8").trim();
|
|
28770
28815
|
} catch {}
|
|
28771
28816
|
const branch = headName.startsWith("refs/heads/") ? headName.slice("refs/heads/".length) : null;
|
|
28772
28817
|
return { operation, commitAllowed: branch !== null, branch };
|
|
@@ -28894,7 +28939,7 @@ function rebaseInProgress(dir) {
|
|
|
28894
28939
|
}
|
|
28895
28940
|
var scratchDir = (cwd) => {
|
|
28896
28941
|
const dir = stacksDir(cwd);
|
|
28897
|
-
return dir.ok ?
|
|
28942
|
+
return dir.ok ? path50.join(dir.data, "worktrees") : null;
|
|
28898
28943
|
};
|
|
28899
28944
|
function gitRestack(cwd, input) {
|
|
28900
28945
|
const owner = worktreeOf(cwd, input.branch);
|
|
@@ -28909,7 +28954,7 @@ function gitRestack(cwd, input) {
|
|
|
28909
28954
|
error: "no store root"
|
|
28910
28955
|
};
|
|
28911
28956
|
fs30.mkdirSync(scratch, { recursive: true });
|
|
28912
|
-
dir =
|
|
28957
|
+
dir = path50.join(scratch, `${input.branch.replace(/[^A-Za-z0-9._-]+/gu, "_").slice(0, 40)}-${randomBytes4(4).toString("hex")}`);
|
|
28913
28958
|
const added = gitRun4(cwd, ["worktree", "add", "-q", dir, input.branch], GIT_TIMEOUTS.worktree);
|
|
28914
28959
|
if (!added.ok)
|
|
28915
28960
|
return {
|
|
@@ -28968,7 +29013,7 @@ function stacksDir(cwd) {
|
|
|
28968
29013
|
const root = storeRoot(cwd);
|
|
28969
29014
|
if (!root.ok)
|
|
28970
29015
|
return stackFail(root.code, root.error, root.unblock);
|
|
28971
|
-
return { ok: true, data:
|
|
29016
|
+
return { ok: true, data: path50.join(root.value.root, "stacks") };
|
|
28972
29017
|
}
|
|
28973
29018
|
var HEARTBEAT_STALE_MS = 2 * 60000;
|
|
28974
29019
|
var SETTLED_BY_RESTACK = new Set(["checks_pending", "behind_base_required"]);
|
|
@@ -29115,7 +29160,7 @@ function fanoutsDir(cwd) {
|
|
|
29115
29160
|
const root = storeRoot(cwd);
|
|
29116
29161
|
if (!root.ok)
|
|
29117
29162
|
return fanoutFail(root.code, root.error, root.unblock);
|
|
29118
|
-
return { ok: true, data:
|
|
29163
|
+
return { ok: true, data: path51.join(root.value.root, "fanouts") };
|
|
29119
29164
|
}
|
|
29120
29165
|
function parseStored(raw) {
|
|
29121
29166
|
if (!isRecord7(raw) || typeof raw.name !== "string" || typeof raw.trunk !== "string")
|
|
@@ -29183,7 +29228,7 @@ function readFanout(cwd, name) {
|
|
|
29183
29228
|
const dir = fanoutsDir(cwd);
|
|
29184
29229
|
if (!dir.ok)
|
|
29185
29230
|
return dir;
|
|
29186
|
-
const file =
|
|
29231
|
+
const file = path51.join(dir.data, stackFileName(name));
|
|
29187
29232
|
let parsed = null;
|
|
29188
29233
|
try {
|
|
29189
29234
|
parsed = parseStored(JSON.parse(fs31.readFileSync(file, "utf8")));
|
|
@@ -29208,7 +29253,7 @@ function listFanouts(cwd) {
|
|
|
29208
29253
|
for (const entry of names) {
|
|
29209
29254
|
let parsed = null;
|
|
29210
29255
|
try {
|
|
29211
|
-
parsed = parseStored(JSON.parse(fs31.readFileSync(
|
|
29256
|
+
parsed = parseStored(JSON.parse(fs31.readFileSync(path51.join(dir.data, entry), "utf8")));
|
|
29212
29257
|
} catch {
|
|
29213
29258
|
parsed = null;
|
|
29214
29259
|
}
|
|
@@ -30053,7 +30098,7 @@ var childTaskMissing = (store, input) => {
|
|
|
30053
30098
|
var childDenial = (identity) => `OpenCode child session has no validated Workit worker: as ${identity} it may only inspect the task summary (workit_task action "inspect") or record evidence or findings (workit_evidence/workit_finding action "record") on an existing task; for anything else the lead assigns it a worker with workit_worker before launching it`;
|
|
30054
30099
|
|
|
30055
30100
|
// packages/workit-opencode/src/v2/shell.ts
|
|
30056
|
-
import
|
|
30101
|
+
import path52 from "node:path";
|
|
30057
30102
|
|
|
30058
30103
|
// packages/workit-core/src/hooks/repeat-failure.ts
|
|
30059
30104
|
import { createHash as createHash20 } from "node:crypto";
|
|
@@ -30116,7 +30161,7 @@ var commandOf = (input) => {
|
|
|
30116
30161
|
};
|
|
30117
30162
|
var hookInput = (root, sessionID, id, shell) => ({
|
|
30118
30163
|
host: "opencode",
|
|
30119
|
-
cwd: shell.workdir ?
|
|
30164
|
+
cwd: shell.workdir ? path52.resolve(root, shell.workdir) : root,
|
|
30120
30165
|
session: { id: sessionID, agentId: null, agentType: null, parentId: null },
|
|
30121
30166
|
permissionMode: null,
|
|
30122
30167
|
transcriptPath: null,
|
|
@@ -30391,38 +30436,38 @@ var createStopControl = (root, port) => {
|
|
|
30391
30436
|
};
|
|
30392
30437
|
|
|
30393
30438
|
// packages/workit-opencode/src/v2/registry.ts
|
|
30394
|
-
import { existsSync as
|
|
30395
|
-
import
|
|
30439
|
+
import { existsSync as existsSync17, readFileSync as readFileSync13 } from "node:fs";
|
|
30440
|
+
import path54 from "node:path";
|
|
30396
30441
|
|
|
30397
30442
|
// packages/workit-opencode/src/shared/assets.ts
|
|
30398
|
-
import { existsSync as
|
|
30399
|
-
import
|
|
30443
|
+
import { existsSync as existsSync16, realpathSync as realpathSync12 } from "node:fs";
|
|
30444
|
+
import path53 from "node:path";
|
|
30400
30445
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
30401
30446
|
var moduleDir = () => {
|
|
30402
30447
|
try {
|
|
30403
|
-
return
|
|
30448
|
+
return realpathSync12(path53.dirname(fileURLToPath2(import.meta.url)));
|
|
30404
30449
|
} catch {
|
|
30405
|
-
return
|
|
30450
|
+
return path53.dirname(fileURLToPath2(import.meta.url));
|
|
30406
30451
|
}
|
|
30407
30452
|
};
|
|
30408
30453
|
var packageRoot2 = () => {
|
|
30409
30454
|
const dir = moduleDir();
|
|
30410
30455
|
for (const candidate of [
|
|
30411
|
-
|
|
30412
|
-
|
|
30413
|
-
|
|
30456
|
+
path53.resolve(dir, ".."),
|
|
30457
|
+
path53.resolve(dir, "..", ".."),
|
|
30458
|
+
path53.resolve(dir, "..", "..", "..")
|
|
30414
30459
|
]) {
|
|
30415
|
-
if (
|
|
30460
|
+
if (existsSync16(path53.join(candidate, "package.json")))
|
|
30416
30461
|
return candidate;
|
|
30417
30462
|
}
|
|
30418
|
-
return
|
|
30463
|
+
return path53.resolve(dir, "..");
|
|
30419
30464
|
};
|
|
30420
30465
|
var skillsRoot = () => {
|
|
30421
30466
|
const root = packageRoot2();
|
|
30422
|
-
const canonical =
|
|
30423
|
-
if (
|
|
30467
|
+
const canonical = path53.resolve(root, "..", "workit-core", "skills");
|
|
30468
|
+
if (existsSync16(path53.join(root, "src")) && existsSync16(canonical))
|
|
30424
30469
|
return canonical;
|
|
30425
|
-
return
|
|
30470
|
+
return path53.join(root, "assets", "skills");
|
|
30426
30471
|
};
|
|
30427
30472
|
|
|
30428
30473
|
// packages/workit-opencode/src/v2/registry.ts
|
|
@@ -30446,15 +30491,15 @@ var parseFrontmatter = (markdown) => {
|
|
|
30446
30491
|
};
|
|
30447
30492
|
var registerSkills = async (ctx) => {
|
|
30448
30493
|
const skillsDir = skillsRoot();
|
|
30449
|
-
if (!
|
|
30494
|
+
if (!existsSync17(skillsDir))
|
|
30450
30495
|
return new Set;
|
|
30451
30496
|
const listed = await ctx.skill.list().catch(() => ({ data: [] }));
|
|
30452
|
-
const own = (skill) => typeof skill.path === "string" &&
|
|
30497
|
+
const own = (skill) => typeof skill.path === "string" && path54.resolve(skill.path).startsWith(skillsDir + path54.sep);
|
|
30453
30498
|
const userSkills = new Set((listed?.data ?? []).filter((skill) => !own(skill)).map((skill) => skill.id));
|
|
30454
30499
|
const packaged = new Map;
|
|
30455
30500
|
for (const id of WORKIT_METHOD_SKILLS) {
|
|
30456
|
-
const file =
|
|
30457
|
-
if (!userSkills.has(id) &&
|
|
30501
|
+
const file = path54.join(skillsDir, id, "SKILL.md");
|
|
30502
|
+
if (!userSkills.has(id) && existsSync17(file))
|
|
30458
30503
|
packaged.set(id, file);
|
|
30459
30504
|
}
|
|
30460
30505
|
await ctx.skill.transform((editor) => {
|
|
@@ -30500,39 +30545,39 @@ var registerCommands = async (ctx, registeredSkills) => {
|
|
|
30500
30545
|
};
|
|
30501
30546
|
|
|
30502
30547
|
// packages/workit-opencode/src/stale-sources.ts
|
|
30503
|
-
import { existsSync as
|
|
30504
|
-
import
|
|
30548
|
+
import { existsSync as existsSync18, readdirSync as readdirSync6 } from "node:fs";
|
|
30549
|
+
import path55 from "node:path";
|
|
30505
30550
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
30506
30551
|
var typescriptFiles = (directory) => {
|
|
30507
|
-
if (!
|
|
30552
|
+
if (!existsSync18(directory))
|
|
30508
30553
|
return [];
|
|
30509
30554
|
return readdirSync6(directory, { withFileTypes: true }).flatMap((entry) => {
|
|
30510
|
-
const file =
|
|
30555
|
+
const file = path55.join(directory, entry.name);
|
|
30511
30556
|
return entry.isDirectory() ? typescriptFiles(file) : entry.isFile() && file.endsWith(".ts") ? [file] : [];
|
|
30512
30557
|
});
|
|
30513
30558
|
};
|
|
30514
30559
|
var pluginSourceFiles = [
|
|
30515
30560
|
...new Set([
|
|
30516
30561
|
fileURLToPath3(import.meta.url),
|
|
30517
|
-
...typescriptFiles(
|
|
30518
|
-
|
|
30519
|
-
...typescriptFiles(
|
|
30562
|
+
...typescriptFiles(path55.join(packageRoot2(), "src")),
|
|
30563
|
+
path55.join(packageRoot2(), "..", "workit-core", "src", "core.ts"),
|
|
30564
|
+
...typescriptFiles(path55.join(packageRoot2(), "..", "workit-core", "src", "core"))
|
|
30520
30565
|
])
|
|
30521
|
-
].filter((file) =>
|
|
30566
|
+
].filter((file) => existsSync18(file)).toSorted();
|
|
30522
30567
|
|
|
30523
30568
|
// packages/workit-core/src/core/cli-locate.ts
|
|
30524
|
-
import { closeSync as closeSync2, existsSync as
|
|
30525
|
-
import
|
|
30569
|
+
import { closeSync as closeSync2, existsSync as existsSync19, openSync as openSync2, readSync } from "node:fs";
|
|
30570
|
+
import path56 from "node:path";
|
|
30526
30571
|
var LAUNCHER_MARKER = "workit-owned-launcher";
|
|
30527
30572
|
var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
|
|
30528
30573
|
var installRoot = (env, platform = process.platform) => {
|
|
30529
30574
|
if (env.WORKIT_INSTALL_ROOT)
|
|
30530
30575
|
return env.WORKIT_INSTALL_ROOT;
|
|
30531
30576
|
const data = dataDir(env, platform);
|
|
30532
|
-
return platform === "win32" ?
|
|
30577
|
+
return platform === "win32" ? path56.join(data, "install") : data;
|
|
30533
30578
|
};
|
|
30534
|
-
var ownedLauncherPath = (env, platform = process.platform) =>
|
|
30535
|
-
var ownedCurrentEntry = (env, platform = process.platform) =>
|
|
30579
|
+
var ownedLauncherPath = (env, platform = process.platform) => path56.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
|
|
30580
|
+
var ownedCurrentEntry = (env, platform = process.platform) => path56.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
|
|
30536
30581
|
var head = (file) => {
|
|
30537
30582
|
let fd;
|
|
30538
30583
|
try {
|
|
@@ -30550,7 +30595,7 @@ var head = (file) => {
|
|
|
30550
30595
|
var locateWorkitCli = (options = {}) => {
|
|
30551
30596
|
const env = options.env ?? process.env;
|
|
30552
30597
|
const platform = options.platform ?? process.platform;
|
|
30553
|
-
const exists = options.exists ??
|
|
30598
|
+
const exists = options.exists ?? existsSync19;
|
|
30554
30599
|
const read = options.read ?? head;
|
|
30555
30600
|
const node = options.node ?? process.execPath;
|
|
30556
30601
|
const launcher = ownedLauncherPath(env, platform);
|
|
@@ -30559,7 +30604,7 @@ var locateWorkitCli = (options = {}) => {
|
|
|
30559
30604
|
source: "owned-launcher",
|
|
30560
30605
|
command: launcher,
|
|
30561
30606
|
args: [],
|
|
30562
|
-
binDir:
|
|
30607
|
+
binDir: path56.dirname(launcher)
|
|
30563
30608
|
};
|
|
30564
30609
|
const current = ownedCurrentEntry(env, platform);
|
|
30565
30610
|
if (exists(current))
|
|
@@ -30588,7 +30633,7 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
|
|
|
30588
30633
|
if (located.binDir) {
|
|
30589
30634
|
const key = pathKey(env);
|
|
30590
30635
|
const delimiter = platform === "win32" ? ";" : ":";
|
|
30591
|
-
const same = (dir) => platform === "win32" ?
|
|
30636
|
+
const same = (dir) => platform === "win32" ? path56.win32.normalize(dir).toLowerCase() === path56.win32.normalize(located.binDir).toLowerCase() : path56.posix.normalize(dir) === path56.posix.normalize(located.binDir);
|
|
30592
30637
|
const rest = (env[key] ?? "").split(delimiter).filter((dir) => dir && !same(dir));
|
|
30593
30638
|
patch[key] = [located.binDir, ...rest].join(delimiter);
|
|
30594
30639
|
}
|