@workit-dev/opencode 2.27.7 → 2.27.9
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 +433 -172
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -10332,12 +10332,6 @@ var escapeRegExp2 = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
|
10332
10332
|
var resolveStateDir = () => stateDir(process.env);
|
|
10333
10333
|
var homePattern = new RegExp(`${escapeRegExp2(os4.homedir())}(?=[/\\\\]|$)|\\$HOME(?=[/\\\\]|$)`, "g");
|
|
10334
10334
|
|
|
10335
|
-
// packages/workit-core/src/store/paths.ts
|
|
10336
|
-
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
10337
|
-
import { createHash as createHash9 } from "node:crypto";
|
|
10338
|
-
import fs8 from "node:fs";
|
|
10339
|
-
import path12 from "node:path";
|
|
10340
|
-
|
|
10341
10335
|
// packages/workit-core/src/store/folder-store.ts
|
|
10342
10336
|
import fs7 from "node:fs";
|
|
10343
10337
|
import os5 from "node:os";
|
|
@@ -10554,13 +10548,14 @@ var below = (parent, child) => {
|
|
|
10554
10548
|
const rel = path11.relative(parent, child);
|
|
10555
10549
|
return rel !== "" && !rel.startsWith("..") && !path11.isAbsolute(rel);
|
|
10556
10550
|
};
|
|
10551
|
+
var insideTempDir = (dir, tempDir = os5.tmpdir()) => below(canonical3(tempDir), canonical3(dir));
|
|
10557
10552
|
var TEST_RUN_REFUSALS = "folder-store-refusals.log";
|
|
10558
10553
|
var testRunFolderRefusal = (folder, hasStray, env = process.env, tempDir = os5.tmpdir()) => {
|
|
10559
10554
|
if (env.WORKIT_TEST_RUN === undefined || !hasStray)
|
|
10560
10555
|
return null;
|
|
10561
10556
|
const real = canonical3(folder);
|
|
10562
10557
|
const tmp = canonical3(tempDir);
|
|
10563
|
-
if (
|
|
10558
|
+
if (insideTempDir(folder, tempDir))
|
|
10564
10559
|
return null;
|
|
10565
10560
|
return `workit test run (WORKIT_TEST_RUN): refusing to move ${path11.join(real, ".workit")} into the run's throwaway state dir; a test must work in a fresh dir inside ${tmp}, never the temp dir itself, a parent of it or a folder outside it (#892)`;
|
|
10566
10561
|
};
|
|
@@ -10646,6 +10641,10 @@ Merge them by hand (cp -Rn ${workit}/. ${target}/), then delete them here.
|
|
|
10646
10641
|
}
|
|
10647
10642
|
|
|
10648
10643
|
// packages/workit-core/src/store/paths.ts
|
|
10644
|
+
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
10645
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
10646
|
+
import fs8 from "node:fs";
|
|
10647
|
+
import path12 from "node:path";
|
|
10649
10648
|
var NOT_A_REPO = /not a git repository \(or any (of the parent directories|parent up to)/u;
|
|
10650
10649
|
var gitRun = (cwd, args) => {
|
|
10651
10650
|
const run = spawnSync9("git", args, {
|
|
@@ -10956,8 +10955,40 @@ function hostSessionFromEnv(env) {
|
|
|
10956
10955
|
return inner ? { host: inner.host, session: inner.session } : { host: declared, session: null };
|
|
10957
10956
|
}
|
|
10958
10957
|
var hash2 = (value) => createHash10("sha256").update(value).digest("hex").slice(0, 32);
|
|
10959
|
-
var
|
|
10960
|
-
var
|
|
10958
|
+
var PIN_FILE = "issued-registry";
|
|
10959
|
+
var pinFiles = new Map;
|
|
10960
|
+
var pinFile = (cwd) => {
|
|
10961
|
+
if (cwd === undefined)
|
|
10962
|
+
return null;
|
|
10963
|
+
const key = path13.resolve(cwd);
|
|
10964
|
+
const known = pinFiles.get(key);
|
|
10965
|
+
if (known !== undefined)
|
|
10966
|
+
return known;
|
|
10967
|
+
try {
|
|
10968
|
+
const location = resolveStore(key);
|
|
10969
|
+
if (location instanceof Error)
|
|
10970
|
+
return null;
|
|
10971
|
+
const file = location.shared ? path13.join(location.dir, "ledger", PIN_FILE) : null;
|
|
10972
|
+
pinFiles.set(key, file);
|
|
10973
|
+
return file;
|
|
10974
|
+
} catch {
|
|
10975
|
+
return null;
|
|
10976
|
+
}
|
|
10977
|
+
};
|
|
10978
|
+
var pinnedStateDir = (cwd) => {
|
|
10979
|
+
const file = pinFile(cwd);
|
|
10980
|
+
if (file === null)
|
|
10981
|
+
return null;
|
|
10982
|
+
try {
|
|
10983
|
+
const pinned = fs9.readFileSync(file, "utf8").trim();
|
|
10984
|
+
return path13.isAbsolute(pinned) ? pinned : null;
|
|
10985
|
+
} catch {
|
|
10986
|
+
return null;
|
|
10987
|
+
}
|
|
10988
|
+
};
|
|
10989
|
+
var registryDir = (cwd) => pinnedStateDir(cwd) ?? resolveStateDir();
|
|
10990
|
+
var userIssuedRoot = (cwd) => path13.join(registryDir(cwd), "issued");
|
|
10991
|
+
var userTokenRoot = (cwd) => path13.join(registryDir(cwd), "issued-tokens");
|
|
10961
10992
|
function migrateRepoIssued(cwd) {
|
|
10962
10993
|
if (cwd === undefined)
|
|
10963
10994
|
return;
|
|
@@ -10977,7 +11008,7 @@ function migrateRepoIssued(cwd) {
|
|
|
10977
11008
|
const from = path13.join(old, lead);
|
|
10978
11009
|
if (!fs9.statSync(from).isDirectory())
|
|
10979
11010
|
continue;
|
|
10980
|
-
const to = path13.join(userIssuedRoot(), lead);
|
|
11011
|
+
const to = path13.join(userIssuedRoot(cwd), lead);
|
|
10981
11012
|
fs9.mkdirSync(to, { recursive: true, mode: 448 });
|
|
10982
11013
|
for (const id of fs9.readdirSync(from)) {
|
|
10983
11014
|
try {
|
|
@@ -11028,17 +11059,17 @@ var issuedRecord = (cwd, claimed) => {
|
|
|
11028
11059
|
return null;
|
|
11029
11060
|
migrateRepoIssued(cwd);
|
|
11030
11061
|
try {
|
|
11031
|
-
return fs9.readFileSync(path13.join(userIssuedRoot(), hash2(claimed.slice(0, cut)), hash2(claimed)), "utf8");
|
|
11062
|
+
return fs9.readFileSync(path13.join(userIssuedRoot(cwd), hash2(claimed.slice(0, cut)), hash2(claimed)), "utf8");
|
|
11032
11063
|
} catch {
|
|
11033
11064
|
return null;
|
|
11034
11065
|
}
|
|
11035
11066
|
};
|
|
11036
11067
|
var TOKEN_HASH = /^([0-9a-f]{64})$/mu;
|
|
11037
|
-
var issuedToken = (claimed) => {
|
|
11068
|
+
var issuedToken = (cwd, claimed) => {
|
|
11038
11069
|
const cut = claimed.lastIndexOf(":");
|
|
11039
11070
|
if (cut <= 0)
|
|
11040
11071
|
return { stored: null, leadBound: false };
|
|
11041
|
-
const dir = path13.join(userTokenRoot(), hash2(claimed.slice(0, cut)));
|
|
11072
|
+
const dir = path13.join(userTokenRoot(cwd), hash2(claimed.slice(0, cut)));
|
|
11042
11073
|
try {
|
|
11043
11074
|
const text = fs9.readFileSync(path13.join(dir, hash2(claimed)), "utf8");
|
|
11044
11075
|
return { stored: TOKEN_HASH.exec(text)?.[1] ?? null, leadBound: true };
|
|
@@ -11048,7 +11079,7 @@ var issuedToken = (claimed) => {
|
|
|
11048
11079
|
};
|
|
11049
11080
|
function issuedBinding(cwd, claimed) {
|
|
11050
11081
|
const record = issuedRecord(cwd, claimed);
|
|
11051
|
-
const { stored, leadBound } = issuedToken(claimed);
|
|
11082
|
+
const { stored, leadBound } = issuedToken(cwd, claimed);
|
|
11052
11083
|
if (stored)
|
|
11053
11084
|
return "token";
|
|
11054
11085
|
if (record === null)
|
|
@@ -27417,7 +27448,7 @@ function heavyGate(cwd, command, options) {
|
|
|
27417
27448
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
27418
27449
|
import {
|
|
27419
27450
|
existsSync as existsSync16,
|
|
27420
|
-
readdirSync as
|
|
27451
|
+
readdirSync as readdirSync6,
|
|
27421
27452
|
readFileSync as readFileSync12,
|
|
27422
27453
|
readlinkSync as readlinkSync3,
|
|
27423
27454
|
realpathSync as realpathSync11,
|
|
@@ -27425,7 +27456,7 @@ import {
|
|
|
27425
27456
|
} from "node:fs";
|
|
27426
27457
|
import { builtinModules } from "node:module";
|
|
27427
27458
|
import os10 from "node:os";
|
|
27428
|
-
import
|
|
27459
|
+
import path43 from "node:path";
|
|
27429
27460
|
|
|
27430
27461
|
// packages/workit-core/src/core/live-session.ts
|
|
27431
27462
|
import { spawnSync as spawnSync23 } from "node:child_process";
|
|
@@ -27628,6 +27659,41 @@ var claimLiveSession = (target, owner, deps = {}) => {
|
|
|
27628
27659
|
} catch {}
|
|
27629
27660
|
};
|
|
27630
27661
|
|
|
27662
|
+
// packages/workit-core/src/hooks/path-glob.ts
|
|
27663
|
+
import { readdirSync as readdirSync5 } from "node:fs";
|
|
27664
|
+
import path42 from "node:path";
|
|
27665
|
+
var GLOB2 = /[*?[]/u;
|
|
27666
|
+
var globPattern = (glob, dots = false) => {
|
|
27667
|
+
try {
|
|
27668
|
+
return new RegExp(`^${dots || glob.startsWith(".") ? "" : "(?!\\.)"}${glob.replace(/[.+^$(){}|\\]/gu, "\\$&").replace(/\[!/gu, "[^").replaceAll("*", ".*").replaceAll("?", ".")}$`, "u");
|
|
27669
|
+
} catch {
|
|
27670
|
+
return null;
|
|
27671
|
+
}
|
|
27672
|
+
};
|
|
27673
|
+
var expandGlob = (file, limit = 64) => {
|
|
27674
|
+
if (!GLOB2.test(file))
|
|
27675
|
+
return [file];
|
|
27676
|
+
const { root } = path42.parse(file);
|
|
27677
|
+
let found = [root];
|
|
27678
|
+
for (const part of file.slice(root.length).split(/[\\/]/u).filter(Boolean)) {
|
|
27679
|
+
if (!GLOB2.test(part)) {
|
|
27680
|
+
found = found.map((dir) => path42.join(dir, part));
|
|
27681
|
+
continue;
|
|
27682
|
+
}
|
|
27683
|
+
const pattern = globPattern(part);
|
|
27684
|
+
if (pattern === null)
|
|
27685
|
+
return [file];
|
|
27686
|
+
found = found.flatMap((dir) => {
|
|
27687
|
+
try {
|
|
27688
|
+
return readdirSync5(dir).filter((name) => pattern.test(name)).map((name) => path42.join(dir, name));
|
|
27689
|
+
} catch {
|
|
27690
|
+
return [];
|
|
27691
|
+
}
|
|
27692
|
+
}).slice(0, limit);
|
|
27693
|
+
}
|
|
27694
|
+
return found.length > 0 ? found : [file];
|
|
27695
|
+
};
|
|
27696
|
+
|
|
27631
27697
|
// packages/workit-core/src/hooks/windows-reads.ts
|
|
27632
27698
|
var READ_CMDLETS = new Set([
|
|
27633
27699
|
"foreach-object",
|
|
@@ -27945,44 +28011,44 @@ var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "wi
|
|
|
27945
28011
|
var linkTarget = (file) => {
|
|
27946
28012
|
try {
|
|
27947
28013
|
const to = readlinkSync3(file);
|
|
27948
|
-
let from =
|
|
28014
|
+
let from = path43.dirname(file);
|
|
27949
28015
|
try {
|
|
27950
28016
|
from = realpathSync11.native(from);
|
|
27951
28017
|
} catch {}
|
|
27952
|
-
return
|
|
28018
|
+
return path43.resolve(from, to);
|
|
27953
28019
|
} catch {
|
|
27954
28020
|
return null;
|
|
27955
28021
|
}
|
|
27956
28022
|
};
|
|
27957
28023
|
var realPath = (file, dangling = true) => {
|
|
27958
|
-
let dir =
|
|
28024
|
+
let dir = path43.resolve(file);
|
|
27959
28025
|
let rest = "";
|
|
27960
28026
|
for (let hops = 0;; ) {
|
|
27961
28027
|
try {
|
|
27962
|
-
return
|
|
28028
|
+
return path43.join(realpathSync11.native(dir), rest);
|
|
27963
28029
|
} catch {
|
|
27964
28030
|
const link = dangling ? linkTarget(dir) : null;
|
|
27965
28031
|
if (link !== null) {
|
|
27966
28032
|
if (++hops > 40)
|
|
27967
28033
|
return null;
|
|
27968
|
-
dir =
|
|
28034
|
+
dir = path43.join(link, rest);
|
|
27969
28035
|
rest = "";
|
|
27970
|
-
} else if (
|
|
27971
|
-
return
|
|
28036
|
+
} else if (path43.dirname(dir) === dir)
|
|
28037
|
+
return path43.resolve(file);
|
|
27972
28038
|
else {
|
|
27973
|
-
rest = rest ?
|
|
27974
|
-
dir =
|
|
28039
|
+
rest = rest ? path43.join(path43.basename(dir), rest) : path43.basename(dir);
|
|
28040
|
+
dir = path43.dirname(dir);
|
|
27975
28041
|
}
|
|
27976
28042
|
}
|
|
27977
28043
|
}
|
|
27978
28044
|
};
|
|
27979
|
-
var canonical5 = (file, dangling = true) => realPath(file, dangling) ??
|
|
28045
|
+
var canonical5 = (file, dangling = true) => realPath(file, dangling) ?? path43.resolve(file);
|
|
27980
28046
|
var exempt = (cwd, root, file, plans) => {
|
|
27981
28047
|
const fold = (value) => CASE_INSENSITIVE ? value.toLowerCase() : value;
|
|
27982
|
-
const relative =
|
|
27983
|
-
if (relative.startsWith("..") ||
|
|
28048
|
+
const relative = path43.relative(fold(canonical5(root, false)), fold(canonical5(path43.resolve(cwd, file), false)));
|
|
28049
|
+
if (relative.startsWith("..") || path43.isAbsolute(relative))
|
|
27984
28050
|
return true;
|
|
27985
|
-
const posix = relative.split(
|
|
28051
|
+
const posix = relative.split(path43.sep).join("/");
|
|
27986
28052
|
const segments = posix.split("/");
|
|
27987
28053
|
return /\.mdx?$/i.test(posix) || segments[0] === "docs" || segments.includes("plans") || [...plans].some((plan) => fold(plan) === posix);
|
|
27988
28054
|
};
|
|
@@ -28062,7 +28128,7 @@ var editsOf = (input) => {
|
|
|
28062
28128
|
return [into];
|
|
28063
28129
|
const files = operands(args);
|
|
28064
28130
|
if (name === "ln" && files.length === 1)
|
|
28065
|
-
return [
|
|
28131
|
+
return [path43.basename(files[0])];
|
|
28066
28132
|
return files.length ? [files.at(-1)] : null;
|
|
28067
28133
|
}
|
|
28068
28134
|
case "mklink": {
|
|
@@ -28124,6 +28190,35 @@ var editsOf = (input) => {
|
|
|
28124
28190
|
return [];
|
|
28125
28191
|
}
|
|
28126
28192
|
};
|
|
28193
|
+
var removalsOf = (input) => {
|
|
28194
|
+
const [verb = "", ...args] = pastLead(input);
|
|
28195
|
+
const name = (verb.split(/[\\/]/).at(-1) ?? "").toLowerCase();
|
|
28196
|
+
const files = operands(args);
|
|
28197
|
+
if (/^(?:rm|rmdir|rd|unlink|shred|remove-item|ri|del|erase)$/.test(name))
|
|
28198
|
+
return { files };
|
|
28199
|
+
if (/^(?:mv|move-item|mi|move)$/.test(name)) {
|
|
28200
|
+
const into = valueOf(args, /^(?:-[a-zA-Z]*t|--target-directory=?)(.*)$/s);
|
|
28201
|
+
return {
|
|
28202
|
+
files: into === undefined ? files.slice(0, -1) : files.filter((file) => file !== into)
|
|
28203
|
+
};
|
|
28204
|
+
}
|
|
28205
|
+
if (name === "rsync" && args.some((arg) => /^--del(?:ete|$)/.test(arg)))
|
|
28206
|
+
return { files: files.slice(-1) };
|
|
28207
|
+
const removes = args.some((arg, at) => arg === "-delete" || /^-(?:exec|execdir|ok|okdir)$/.test(arg) && /^(?:rm|rmdir|unlink|shred|mv|truncate|cp|dd|tee|sh|bash|dash|zsh)$/.test(commandName2(args[at + 1] ?? "")));
|
|
28208
|
+
if (name !== "find" || !removes)
|
|
28209
|
+
return { files: [] };
|
|
28210
|
+
const end = args.findIndex((arg) => /^[-(!]/.test(arg));
|
|
28211
|
+
const roots = end === 0 ? ["."] : args.slice(0, end);
|
|
28212
|
+
const tests = [];
|
|
28213
|
+
for (const [at, arg] of args.entries()) {
|
|
28214
|
+
const kind = /^-(i?)(?:name|path|wholename|regex)$/.exec(arg);
|
|
28215
|
+
const value = args[at + 1];
|
|
28216
|
+
if (kind && value !== undefined)
|
|
28217
|
+
tests.push([`${arg.replace(/^-i?/, "").replace("wholename", "path")}${kind[1]}`, value]);
|
|
28218
|
+
}
|
|
28219
|
+
const negated = args.some((arg) => arg === "!" || arg === "-not");
|
|
28220
|
+
return { files: roots, find: { roots, tests: negated ? [] : tests } };
|
|
28221
|
+
};
|
|
28127
28222
|
var WRAPPERS3 = {
|
|
28128
28223
|
sudo: "ugCDhpRrTtU",
|
|
28129
28224
|
doas: "uC",
|
|
@@ -28147,7 +28242,7 @@ var WRAPPERS3 = {
|
|
|
28147
28242
|
var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php|tsx|ts-node)$/;
|
|
28148
28243
|
var INLINE_CODE = /^-[a-zA-Z]*[cep]$|^--(?:eval|print)(?:=|$)/;
|
|
28149
28244
|
var isConfigDir = (file) => configDirs().some((dir) => canonical5(dir) === canonical5(file));
|
|
28150
|
-
var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals|verdicts|agent-stamps)$/.test(
|
|
28245
|
+
var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals|verdicts|agent-stamps)$/.test(path43.relative(canonical5(resolveStateDir()), canonical5(file)));
|
|
28151
28246
|
var READ_CALLS = /^(?:print|log|info|warn|error|debug|puts|readdir(?:Sync)?|listdir|scandir|iterdir|glob|l?stat(?:Sync)?|exists(?:Sync)?|isdir|isfile|is_dir|is_file|access(?:Sync)?|realpath(?:Sync)?|dirname|basename|relative|str|repr|len)$/;
|
|
28152
28247
|
var MUTATING_CALLS = /^(?:renames?(?:Sync)?|move(?:_into)?|copy(?:2|file|tree|File|_into)?(?:Sync)?|cp(?:Sync)?|rm(?:tree|dir|Sync|dirSync)?|unlink(?:Sync)?|remove(?:dirs)?|mkdirs?(?:Sync)?|makedirs|mkdtemp(?:Sync)?|(?:sym|hard)?link(?:Sync|_to)?|write\w*|append\w*|f?truncate(?:Sync)?|ch(?:mod|own)(?:Sync)?|touch|open(?:Sync)?|dump|save|extractall|unpack_archive|put_contents|mv|FileUtils)$/;
|
|
28153
28248
|
var SPAWNS = /getattr|Reflect|getOwnPropertyDescriptor|FileIO|\.copy\s*\((?!\s*\))|utime|ch(?:mod|own)|\.delete\s*\(\s*\)|(?:PYTHON|NODE_)\w*\+?=|-r\b|--(?:require|import|env-file|[\w-]*loader)|\b(?:exec\w*|eval|(?:unlink|rename|remove)\w*)\b|\]\s*\(/;
|
|
@@ -28672,10 +28767,10 @@ var linkSources = (args, at) => {
|
|
|
28672
28767
|
const sources = names.filter((name, index) => into >= 0 ? name !== dest : index < names.length - 1 || names.length === 1);
|
|
28673
28768
|
const target = dest === undefined ? null : at(dest);
|
|
28674
28769
|
const symbolic = args.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg));
|
|
28675
|
-
const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync16(target) || /[\\/]$/.test(dest ?? "") ? target :
|
|
28770
|
+
const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync16(target) || /[\\/]$/.test(dest ?? "") ? target : path43.dirname(target);
|
|
28676
28771
|
return sources.flatMap((source) => {
|
|
28677
|
-
if (symbolic && base !== null && !
|
|
28678
|
-
return [
|
|
28772
|
+
if (symbolic && base !== null && !path43.isAbsolute(homeExpanded(source)))
|
|
28773
|
+
return [path43.resolve(base, source)];
|
|
28679
28774
|
const resolved = at(source);
|
|
28680
28775
|
return resolved ? [resolved] : [];
|
|
28681
28776
|
});
|
|
@@ -28720,7 +28815,7 @@ var linkReach = (verb, args, at, atAll) => {
|
|
|
28720
28815
|
const dir = match ? match[1] ?? args[index + 1] : undefined;
|
|
28721
28816
|
if (!dir)
|
|
28722
28817
|
return [];
|
|
28723
|
-
return [...atAll(dir), ...dest && !
|
|
28818
|
+
return [...atAll(dir), ...dest && !path43.isAbsolute(dir) ? atAll(path43.join(dest, dir)) : []];
|
|
28724
28819
|
});
|
|
28725
28820
|
}
|
|
28726
28821
|
if (verb === "mklink")
|
|
@@ -28756,7 +28851,7 @@ var shellWrites = (command, depth = 0) => {
|
|
|
28756
28851
|
return { writes: true, targets: unknown ? null : targets };
|
|
28757
28852
|
};
|
|
28758
28853
|
var cache3 = new Map;
|
|
28759
|
-
var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(
|
|
28854
|
+
var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path43.resolve(root, file)) ?? "-").join("\x00");
|
|
28760
28855
|
var gateFor = (cwd) => {
|
|
28761
28856
|
const store = new TaskReader(cwd);
|
|
28762
28857
|
const listed = store.listTaskIndex();
|
|
@@ -28819,7 +28914,7 @@ var DIR_TARGET = ".workit-live-target";
|
|
|
28819
28914
|
var PLACEHOLDERS = new WeakMap;
|
|
28820
28915
|
var collecting = null;
|
|
28821
28916
|
var placeholderIn = (dir, name) => {
|
|
28822
|
-
const target =
|
|
28917
|
+
const target = path43.join(dir, name);
|
|
28823
28918
|
collecting?.add(target);
|
|
28824
28919
|
return target;
|
|
28825
28920
|
};
|
|
@@ -28845,6 +28940,7 @@ var recording = (make) => {
|
|
|
28845
28940
|
var OPAQUE_TARGET = ".workit-runs-";
|
|
28846
28941
|
var UNRESOLVED_TARGET = ".workit-unresolved-target";
|
|
28847
28942
|
var LINK_SOURCE = ".workit-link-source";
|
|
28943
|
+
var REMOVED_SOURCE = ".workit-removed-source";
|
|
28848
28944
|
var OVERRIDE = "WORKIT_LIVE_SESSION=override";
|
|
28849
28945
|
var inert = (args, sub) => args.some((arg) => arg === "--help" || arg === "-h" || arg === "--dry-run" || DRY_N.has(sub) && /^-[a-zA-Z]*n[a-zA-Z]*$/.test(arg) && !arg.startsWith("--"));
|
|
28850
28946
|
var gitMutationDirs = (cwd, command, dialect) => {
|
|
@@ -28864,13 +28960,13 @@ var gitMutationDirs = (cwd, command, dialect) => {
|
|
|
28864
28960
|
return [];
|
|
28865
28961
|
if (sub === "stash" && ["list", "show"].includes(rest[0] ?? ""))
|
|
28866
28962
|
return [];
|
|
28867
|
-
return [
|
|
28963
|
+
return [path43.resolve(cwd, invocation.dir ?? ".")];
|
|
28868
28964
|
});
|
|
28869
28965
|
};
|
|
28870
28966
|
var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
|
|
28871
28967
|
var PUSHD2 = new Set(["pushd", "push-location"]);
|
|
28872
28968
|
var POPD2 = new Set(["popd", "pop-location"]);
|
|
28873
|
-
var UNKNOWN_DIR =
|
|
28969
|
+
var UNKNOWN_DIR = path43.resolve(path43.parse(process.cwd()).root, ".workit-unknown-dir");
|
|
28874
28970
|
var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
|
|
28875
28971
|
const lost = strict ? UNKNOWN_DIR : undefined;
|
|
28876
28972
|
const found = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
|
|
@@ -28880,7 +28976,7 @@ var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
|
|
|
28880
28976
|
return lost;
|
|
28881
28977
|
if (dir === undefined)
|
|
28882
28978
|
return lost;
|
|
28883
|
-
return target === undefined ? os10.homedir() :
|
|
28979
|
+
return target === undefined ? os10.homedir() : path43.resolve(dir, target);
|
|
28884
28980
|
};
|
|
28885
28981
|
var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
|
|
28886
28982
|
var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
|
|
@@ -29028,7 +29124,7 @@ var untrustedVars = (segments) => {
|
|
|
29028
29124
|
}
|
|
29029
29125
|
return { all, names };
|
|
29030
29126
|
};
|
|
29031
|
-
var UNKNOWN_VAR =
|
|
29127
|
+
var UNKNOWN_VAR = path43.resolve(path43.parse(process.cwd()).root, ".workit-unknown-var");
|
|
29032
29128
|
var REFERENCE = /\$\{(\w+)[^}]*\}|\$(\w+)|\$\([^)]*\)?|`[^`]*`?/g;
|
|
29033
29129
|
var unresolvedRefs = (text) => [
|
|
29034
29130
|
...new Set([...text.matchAll(REFERENCE)].map((match) => {
|
|
@@ -29038,7 +29134,7 @@ var unresolvedRefs = (text) => [
|
|
|
29038
29134
|
];
|
|
29039
29135
|
var unknownVarTarget = (text) => {
|
|
29040
29136
|
const refs = unresolvedRefs(text);
|
|
29041
|
-
return
|
|
29137
|
+
return path43.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
|
|
29042
29138
|
};
|
|
29043
29139
|
var applyOperator = (value, operator) => {
|
|
29044
29140
|
if (operator === "")
|
|
@@ -29099,12 +29195,12 @@ var mktempPath = (value, dir) => {
|
|
|
29099
29195
|
if (base === null && (temp || template === undefined))
|
|
29100
29196
|
base = os10.tmpdir();
|
|
29101
29197
|
const name = homeExpanded(template ?? "tmp.XXXXXXXXXX");
|
|
29102
|
-
if (
|
|
29198
|
+
if (path43.isAbsolute(name))
|
|
29103
29199
|
return name;
|
|
29104
29200
|
const from = base === null ? dir : homeExpanded(base);
|
|
29105
|
-
if (from === undefined || !
|
|
29201
|
+
if (from === undefined || !path43.isAbsolute(from) && dir === undefined)
|
|
29106
29202
|
return null;
|
|
29107
|
-
return
|
|
29203
|
+
return path43.resolve(dir ?? from, from, name);
|
|
29108
29204
|
};
|
|
29109
29205
|
var homeExpanded = (file) => {
|
|
29110
29206
|
const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
|
|
@@ -29128,7 +29224,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
29128
29224
|
const home = homeExpanded(text);
|
|
29129
29225
|
if (strict && unresolvedRefs(home).length > 0)
|
|
29130
29226
|
return [unknownVarTarget(home)];
|
|
29131
|
-
if (
|
|
29227
|
+
if (path43.isAbsolute(home))
|
|
29132
29228
|
return [home];
|
|
29133
29229
|
return base === undefined ? [] : [resolvedUnder(base, home)];
|
|
29134
29230
|
});
|
|
@@ -29199,7 +29295,8 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
29199
29295
|
if (loop >= 0) {
|
|
29200
29296
|
const [name = "", keyword, ...items] = segment.words.slice(loop + 1);
|
|
29201
29297
|
const expanding = new Set(segment.expands ?? []);
|
|
29202
|
-
const
|
|
29298
|
+
const globbedItem = (item) => strict === "registry" && dir !== undefined && /[*?[]/.test(item) ? expandGlob(path43.resolve(dir, homeExpanded(item))) : null;
|
|
29299
|
+
const list = items.flatMap((item, index) => globbedItem(item) ?? (expanding.has(loop + 3 + index) ? listWords(item) : [listWord(homeExpanded(item))]));
|
|
29203
29300
|
vars.delete(name);
|
|
29204
29301
|
if (keyword === "in" && list.length <= MAX_EXPANSIONS2 && !list.includes(null) && !untrusted.all && !untrusted.names.has(name))
|
|
29205
29302
|
loops.set(name, list);
|
|
@@ -29338,7 +29435,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
29338
29435
|
index
|
|
29339
29436
|
}));
|
|
29340
29437
|
const homes = /homedir\(|expanduser\(|Path\.home\(|['"]HOME['"]|env\.HOME|\$HOME|~/.test(text);
|
|
29341
|
-
const under = (word) => homes ? [
|
|
29438
|
+
const under = (word) => homes ? [path43.join(homeExpanded("~"), word.replace(/^~/, ""))] : [];
|
|
29342
29439
|
const found = [
|
|
29343
29440
|
...[...text.matchAll(PATHS)].flatMap(({ 0: word, index }) => [...atAll(word), ...under(word)].map((file) => ({ file, index }))),
|
|
29344
29441
|
...joined.flatMap(({ word, index }) => under(word).map((file) => ({ file, index })))
|
|
@@ -29346,7 +29443,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
29346
29443
|
for (const { file, index } of found) {
|
|
29347
29444
|
const use = isRoot(file) ? rootUse(text, index) : "takes";
|
|
29348
29445
|
if (use !== "reads")
|
|
29349
|
-
targets.push(use === "builds" ?
|
|
29446
|
+
targets.push(use === "builds" ? path43.join(file, UNRESOLVED_TARGET) : file);
|
|
29350
29447
|
}
|
|
29351
29448
|
}
|
|
29352
29449
|
if (/^(?:n?vim?|ex|ed|emacs)$/.test(verb) && (segment.stdin || inputs.length > 0 || feeder || args.some((arg, index) => /^(?:-[a-zA-Z]*[se]|--(?:batch|eval|script))$/.test(arg) || /^(?:-c|--cmd)$/.test(arg) && !inertEdit(args[index + 1] ?? "") || arg.startsWith("+") && !inertEdit(arg.slice(1) || "1"))))
|
|
@@ -29356,7 +29453,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
29356
29453
|
`);
|
|
29357
29454
|
for (const [linker = "", ...rest] of fedRuns(words, feed))
|
|
29358
29455
|
for (const source of linkReach(commandName2(linker), rest, at, atAll))
|
|
29359
|
-
targets.push(
|
|
29456
|
+
targets.push(path43.join(source, LINK_SOURCE));
|
|
29360
29457
|
}
|
|
29361
29458
|
if (strict && dir !== undefined) {
|
|
29362
29459
|
const runIn = dir;
|
|
@@ -29383,7 +29480,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
29383
29480
|
for (const file of opaque ?? [])
|
|
29384
29481
|
for (const resolved of atAll(file))
|
|
29385
29482
|
if (!quiet || !isRoot(resolved))
|
|
29386
|
-
targets.push(file === "." ? placeholderIn(resolved, here) :
|
|
29483
|
+
targets.push(file === "." ? placeholderIn(resolved, here) : path43.basename(resolved).startsWith(OPAQUE_TARGET) ? placeholderIn(path43.dirname(resolved), path43.basename(resolved)) : resolved);
|
|
29387
29484
|
const [shell = "", ...shellArgs] = pastLead(words);
|
|
29388
29485
|
const verb = (shell.split(/[\\/]/).at(-1) ?? "").toLowerCase();
|
|
29389
29486
|
const named = (SCRIPT_SHELLS.has(verb) || verb === "source" || verb === ".") && shellScript2([verb, ...shellArgs]) === null ? scriptArgs(verb, shellArgs).named ?? "" : null;
|
|
@@ -29404,6 +29501,12 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
29404
29501
|
if (dir !== undefined)
|
|
29405
29502
|
targets.push(placeholderIn(dir, DIR_TARGET));
|
|
29406
29503
|
}
|
|
29504
|
+
if (strict === "registry") {
|
|
29505
|
+
const { files: gone, find } = removalsOf(body);
|
|
29506
|
+
for (const root of gone)
|
|
29507
|
+
for (const file of atAll(root))
|
|
29508
|
+
targets.push(path43.join(file, find ? `${REMOVED_SOURCE}~${encodeURIComponent(JSON.stringify({ root, tests: find.tests }))}` : REMOVED_SOURCE));
|
|
29509
|
+
}
|
|
29407
29510
|
for (const file of [...segment.redirects, ...edits ?? []])
|
|
29408
29511
|
if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file) && !(dialect === "powershell" && /^(?:\$null|nul)$/i.test(file)))
|
|
29409
29512
|
targets.push(...atAll(file));
|
|
@@ -29430,7 +29533,10 @@ var workitCwd = (dir, args, resolve) => {
|
|
|
29430
29533
|
};
|
|
29431
29534
|
var shellMutationTargets = (cwd, command, dialect = "posix", strict = false) => {
|
|
29432
29535
|
try {
|
|
29433
|
-
const env = new Map(strict === "registry" ? [
|
|
29536
|
+
const env = new Map(strict === "registry" ? [
|
|
29537
|
+
...[...command.matchAll(/\$\{?([A-Za-z_]\w*)/g)].filter((match) => !/^(?:OLD)?PWD$/.test(match[1])).map((match) => [match[1], process.env[match[1]] ?? ""]),
|
|
29538
|
+
["PWD", cwd]
|
|
29539
|
+
] : []);
|
|
29434
29540
|
return recording(() => [
|
|
29435
29541
|
...segmentTargets(cwd, command, dialect, 0, strict, env),
|
|
29436
29542
|
...gitMutationDirs(cwd, command, dialect).map((dir) => placeholderIn(dir, DIR_TARGET))
|
|
@@ -29472,7 +29578,7 @@ var liveDeny = ({ marker, checkout, ageMs, file }) => {
|
|
|
29472
29578
|
var guarded = (targets) => {
|
|
29473
29579
|
const seen = new Set;
|
|
29474
29580
|
return targets.filter((target) => {
|
|
29475
|
-
const dir =
|
|
29581
|
+
const dir = path43.dirname(target);
|
|
29476
29582
|
if (seen.has(dir))
|
|
29477
29583
|
return false;
|
|
29478
29584
|
seen.add(dir);
|
|
@@ -29493,17 +29599,17 @@ var claimAll = (owner, targets, deps) => {
|
|
|
29493
29599
|
for (const target of guarded(targets))
|
|
29494
29600
|
claimLiveSession(target, owner, deps);
|
|
29495
29601
|
};
|
|
29496
|
-
var resolvedUnder = (dir, file) => !/(?:^|[\\/])\.\.(?:[\\/]|$)/.test(file) ?
|
|
29602
|
+
var resolvedUnder = (dir, file) => !/(?:^|[\\/])\.\.(?:[\\/]|$)/.test(file) ? path43.resolve(dir, file) : path43.isAbsolute(file) ? file : `${dir}${path43.sep}${file}`;
|
|
29497
29603
|
var liveTargets = (cwd, paths) => recording(() => paths?.length ? paths.map((file) => resolvedUnder(cwd, file)) : [placeholderIn(cwd, DIR_TARGET)]);
|
|
29498
29604
|
var CONFIG_FILES = ["workspaces.json", SEAL_FILE];
|
|
29499
29605
|
var configDirs = () => [resolveConfigDir(), grantsDir()];
|
|
29500
29606
|
var globbed = (cwd, target, state, configs) => {
|
|
29501
29607
|
if (!/[*?[]/.test(target))
|
|
29502
29608
|
return [];
|
|
29503
|
-
const raw =
|
|
29609
|
+
const raw = path43.resolve(cwd, target).split(path43.sep);
|
|
29504
29610
|
const literal = raw.findIndex((part) => /[*?[]/.test(part));
|
|
29505
29611
|
const pattern = [
|
|
29506
|
-
...canonical5(raw.slice(0, literal).join(
|
|
29612
|
+
...canonical5(raw.slice(0, literal).join(path43.sep) || path43.sep).replace(/[\\/]+$/, "").split(path43.sep),
|
|
29507
29613
|
...raw.slice(literal)
|
|
29508
29614
|
];
|
|
29509
29615
|
const segment = (glob, name) => {
|
|
@@ -29514,16 +29620,16 @@ var globbed = (cwd, target, state, configs) => {
|
|
|
29514
29620
|
}
|
|
29515
29621
|
};
|
|
29516
29622
|
const hit = (file, below) => {
|
|
29517
|
-
const parts = canonical5(file).split(
|
|
29623
|
+
const parts = canonical5(file).split(path43.sep);
|
|
29518
29624
|
return (below ? pattern.length >= parts.length : pattern.length === parts.length) && parts.every((part, index) => segment(pattern[index], part));
|
|
29519
29625
|
};
|
|
29520
29626
|
let roots = [];
|
|
29521
29627
|
try {
|
|
29522
|
-
roots =
|
|
29628
|
+
roots = readdirSync6(state).filter((name) => /^(?:issued|approvals$|verdicts$|agent-stamps$)/.test(name));
|
|
29523
29629
|
} catch {}
|
|
29524
29630
|
return [
|
|
29525
|
-
...roots.map((name) =>
|
|
29526
|
-
...configs.flatMap((dir) => [dir, ...CONFIG_FILES.map((name) =>
|
|
29631
|
+
...roots.map((name) => path43.join(state, name)).filter((root) => hit(root, true)),
|
|
29632
|
+
...configs.flatMap((dir) => [dir, ...CONFIG_FILES.map((name) => path43.join(dir, name))]).filter((file) => hit(file, false))
|
|
29527
29633
|
];
|
|
29528
29634
|
};
|
|
29529
29635
|
var guardedInodes = (state, configs) => {
|
|
@@ -29536,18 +29642,18 @@ var guardedInodes = (state, configs) => {
|
|
|
29536
29642
|
if (stat?.isFile())
|
|
29537
29643
|
seen.set(`${stat.dev}:${stat.ino}`, registry);
|
|
29538
29644
|
else if (stat?.isDirectory())
|
|
29539
|
-
for (const name of
|
|
29540
|
-
add(
|
|
29645
|
+
for (const name of readdirSync6(file))
|
|
29646
|
+
add(path43.join(file, name), registry);
|
|
29541
29647
|
};
|
|
29542
29648
|
try {
|
|
29543
29649
|
for (const dir of configs)
|
|
29544
29650
|
for (const name of CONFIG_FILES)
|
|
29545
|
-
add(
|
|
29546
|
-
for (const name of
|
|
29651
|
+
add(path43.join(dir, name), "grants");
|
|
29652
|
+
for (const name of readdirSync6(state))
|
|
29547
29653
|
if (/^(?:issued|approvals$|verdicts$|agent-stamps$)/.test(name))
|
|
29548
|
-
add(
|
|
29549
|
-
for (const slug of
|
|
29550
|
-
add(
|
|
29654
|
+
add(path43.join(state, name), name === "approvals" ? "approvals" : name === "verdicts" || name === "agent-stamps" ? "ledger" : "issued");
|
|
29655
|
+
for (const slug of readdirSync6(path43.join(state, "folders")))
|
|
29656
|
+
add(path43.join(state, "folders", slug, "ledger"), "ledger");
|
|
29551
29657
|
} catch {}
|
|
29552
29658
|
return seen;
|
|
29553
29659
|
};
|
|
@@ -29564,19 +29670,87 @@ var hardLinked = (file, state, configs, inodes) => {
|
|
|
29564
29670
|
};
|
|
29565
29671
|
var inRepoLedger = (file) => [...file.matchAll(/[\\/]workit[\\/]ledger(?=[\\/]|$)/g)].some(({ index }) => {
|
|
29566
29672
|
const gitDir = file.slice(0, index);
|
|
29567
|
-
return /(?:^|[\\/])\.git$/.test(gitDir) || existsSync16(
|
|
29673
|
+
return /(?:^|[\\/])\.git$/.test(gitDir) || existsSync16(path43.join(gitDir, "HEAD")) && existsSync16(path43.join(gitDir, "objects"));
|
|
29568
29674
|
});
|
|
29569
29675
|
var holdsGuarded = (cwd, source, state, configs) => {
|
|
29570
29676
|
const real = canonical5(source);
|
|
29571
29677
|
const below = (parent, child) => {
|
|
29572
|
-
const rel =
|
|
29573
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
29678
|
+
const rel = path43.relative(parent, child);
|
|
29679
|
+
return rel === "" || !rel.startsWith("..") && !path43.isAbsolute(rel);
|
|
29574
29680
|
};
|
|
29575
29681
|
const holds = (file) => below(real, canonical5(file));
|
|
29576
|
-
const inState =
|
|
29577
|
-
const ledgers = ["ledger", "workit/ledger", ".git/workit/ledger"].map((rel) =>
|
|
29682
|
+
const inState = path43.relative(canonical5(state), real).split(path43.sep);
|
|
29683
|
+
const ledgers = ["ledger", "workit/ledger", ".git/workit/ledger"].map((rel) => path43.join(real, rel)).filter((dir) => existsSync16(dir) && inRepoLedger(dir));
|
|
29578
29684
|
const own = ledgerPath(cwd);
|
|
29579
|
-
return holds(state) || below(canonical5(state), real) && inState[0] === "folders" && inState.length <= 2 || configs.some(holds) || ledgers.length > 0 || own.ok && existsSync16(own.value) && holds(
|
|
29685
|
+
return holds(state) || below(canonical5(state), real) && inState[0] === "folders" && inState.length <= 2 || configs.some(holds) || ledgers.length > 0 || own.ok && existsSync16(own.value) && holds(path43.dirname(own.value));
|
|
29686
|
+
};
|
|
29687
|
+
var removesLedger = (cwd, source, state, configs) => {
|
|
29688
|
+
const real = canonical5(source);
|
|
29689
|
+
if (/(?:^|[\\/])\.git(?:[\\/]workit)?$/i.test(real) || inRepoLedger(real))
|
|
29690
|
+
return true;
|
|
29691
|
+
const own = ledgerPath(cwd);
|
|
29692
|
+
if (own.ok) {
|
|
29693
|
+
const rel = path43.relative(real, canonical5(path43.dirname(own.value)));
|
|
29694
|
+
if (rel === "" || !rel.startsWith("..") && !path43.isAbsolute(rel))
|
|
29695
|
+
return true;
|
|
29696
|
+
}
|
|
29697
|
+
return holdsGuarded(cwd, source, state, configs);
|
|
29698
|
+
};
|
|
29699
|
+
var findTests = (marker) => {
|
|
29700
|
+
try {
|
|
29701
|
+
return JSON.parse(decodeURIComponent(marker.slice(REMOVED_SOURCE.length + 1)));
|
|
29702
|
+
} catch {
|
|
29703
|
+
return null;
|
|
29704
|
+
}
|
|
29705
|
+
};
|
|
29706
|
+
var findReachesLedger = (cwd, root, find) => {
|
|
29707
|
+
if (find === null)
|
|
29708
|
+
return true;
|
|
29709
|
+
const real = canonical5(root);
|
|
29710
|
+
const own = ledgerPath(cwd);
|
|
29711
|
+
const ledgers = [
|
|
29712
|
+
...own.ok ? [canonical5(path43.dirname(own.value))] : [],
|
|
29713
|
+
...[".git/workit/ledger", "workit/ledger", "ledger"].map((rel) => path43.join(real, rel)).filter((dir) => existsSync16(dir) && inRepoLedger(dir))
|
|
29714
|
+
];
|
|
29715
|
+
const under = (parent, child) => {
|
|
29716
|
+
const rel = path43.relative(parent, child);
|
|
29717
|
+
return rel === "" || !rel.startsWith("..") && !path43.isAbsolute(rel);
|
|
29718
|
+
};
|
|
29719
|
+
const patterns = find.tests.map(([kind, pattern]) => {
|
|
29720
|
+
const fold = kind.endsWith("i");
|
|
29721
|
+
const glob = globPattern(pattern, true);
|
|
29722
|
+
let test = /(?:)/;
|
|
29723
|
+
try {
|
|
29724
|
+
test = kind.startsWith("regex") ? new RegExp(`^${pattern}$`, fold ? "i" : "") : glob ? new RegExp(glob.source, fold ? "iu" : "u") : test;
|
|
29725
|
+
} catch {}
|
|
29726
|
+
return { kind, test };
|
|
29727
|
+
});
|
|
29728
|
+
const matches = (entry) => patterns.length === 0 || patterns.some(({ kind, test }) => test.test(kind.startsWith("name") ? path43.basename(entry) : path43.join(find.root, path43.relative(real, entry)).replaceAll("\\", "/")));
|
|
29729
|
+
for (const ledger of ledgers) {
|
|
29730
|
+
if (!existsSync16(ledger) || !under(real, ledger) && !under(ledger, real))
|
|
29731
|
+
continue;
|
|
29732
|
+
const entries = [];
|
|
29733
|
+
for (let dir = ledger;under(real, dir) && dir !== real; dir = path43.dirname(dir))
|
|
29734
|
+
entries.push(dir);
|
|
29735
|
+
const walk = (dir) => {
|
|
29736
|
+
for (const item of readdirSync6(dir, { withFileTypes: true })) {
|
|
29737
|
+
if (entries.length > 500)
|
|
29738
|
+
return;
|
|
29739
|
+
const file = path43.join(dir, item.name);
|
|
29740
|
+
entries.push(file);
|
|
29741
|
+
if (item.isDirectory())
|
|
29742
|
+
walk(file);
|
|
29743
|
+
}
|
|
29744
|
+
};
|
|
29745
|
+
try {
|
|
29746
|
+
walk(ledger);
|
|
29747
|
+
} catch {
|
|
29748
|
+
return true;
|
|
29749
|
+
}
|
|
29750
|
+
if (entries.some((entry) => under(real, entry) && matches(entry)))
|
|
29751
|
+
return true;
|
|
29752
|
+
}
|
|
29753
|
+
return false;
|
|
29580
29754
|
};
|
|
29581
29755
|
var registryTarget = (cwd, targets) => {
|
|
29582
29756
|
const state = resolveStateDir();
|
|
@@ -29584,20 +29758,28 @@ var registryTarget = (cwd, targets) => {
|
|
|
29584
29758
|
const inodes = {};
|
|
29585
29759
|
for (const target of targets) {
|
|
29586
29760
|
const file = homeExpanded(target);
|
|
29587
|
-
if (
|
|
29588
|
-
const
|
|
29761
|
+
if (path43.basename(file).startsWith(REMOVED_SOURCE)) {
|
|
29762
|
+
const marker = path43.basename(file);
|
|
29763
|
+
const source = path43.dirname(path43.resolve(cwd, file));
|
|
29764
|
+
const find = marker === REMOVED_SOURCE ? null : findTests(marker);
|
|
29765
|
+
if (expandGlob(source).some((gone) => find ? findReachesLedger(cwd, gone, find) : removesLedger(cwd, gone, state, configs)))
|
|
29766
|
+
return { file: path43.join(source, REMOVED_SOURCE), registry: "removes" };
|
|
29767
|
+
continue;
|
|
29768
|
+
}
|
|
29769
|
+
if (path43.basename(file) === LINK_SOURCE) {
|
|
29770
|
+
const source = path43.dirname(path43.resolve(cwd, file));
|
|
29589
29771
|
const reached = registryTarget(cwd, [source])?.registry ?? (holdsGuarded(cwd, source, state, configs) ? "holds" : null);
|
|
29590
29772
|
if (reached)
|
|
29591
29773
|
return { file: target, registry: reached };
|
|
29592
29774
|
continue;
|
|
29593
29775
|
}
|
|
29594
|
-
if (realPath(
|
|
29776
|
+
if (realPath(path43.resolve(cwd, file)) === null)
|
|
29595
29777
|
return { file: target, registry: "link" };
|
|
29596
29778
|
const glob = globbed(cwd, file, state, configs)[0];
|
|
29597
29779
|
const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
|
|
29598
29780
|
if (viaGlob)
|
|
29599
29781
|
return { file: target, registry: viaGlob.registry };
|
|
29600
|
-
const registry = hardLinked(
|
|
29782
|
+
const registry = hardLinked(path43.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical5) ?? (inRepoLedger(canonical5(path43.resolve(cwd, file))) ? "ledger" : null) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical5)) ? "grants" : null);
|
|
29601
29783
|
if (registry)
|
|
29602
29784
|
return { file: target, registry };
|
|
29603
29785
|
}
|
|
@@ -29605,7 +29787,7 @@ var registryTarget = (cwd, targets) => {
|
|
|
29605
29787
|
};
|
|
29606
29788
|
var partsUnder = (dir, cwd, target, platform, real) => {
|
|
29607
29789
|
const win = platform === "win32";
|
|
29608
|
-
const p = win ?
|
|
29790
|
+
const p = win ? path43.win32 : path43.posix;
|
|
29609
29791
|
const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
|
|
29610
29792
|
const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
|
|
29611
29793
|
const relative = p.relative(fold(real(p.resolve(dir))), fold(real(p.resolve(cwd, named))));
|
|
@@ -29658,6 +29840,11 @@ var REGISTRY_DENY = {
|
|
|
29658
29840
|
what: "a symlink chain Workit could not resolve (over 40 links), which may reach a guarded path",
|
|
29659
29841
|
unblock: "Write to the file's real path."
|
|
29660
29842
|
},
|
|
29843
|
+
removes: {
|
|
29844
|
+
label: "ledger guard",
|
|
29845
|
+
what: "a Workit ledger, the git dir that holds one or Workit's state",
|
|
29846
|
+
unblock: "Never remove or move `.git`, `.git/workit` or a dir that holds a Workit ledger: the ledger keeps the session's verdicts and pins. Remove the files you made by name."
|
|
29847
|
+
},
|
|
29661
29848
|
holds: {
|
|
29662
29849
|
label: "registry guard",
|
|
29663
29850
|
what: "Workit's state, its config or a repository ledger",
|
|
@@ -29686,19 +29873,25 @@ var REGISTRY_DENY = {
|
|
|
29686
29873
|
};
|
|
29687
29874
|
var registryDeny = ({ file, registry }) => {
|
|
29688
29875
|
const { label, what, unblock } = REGISTRY_DENY[registry];
|
|
29689
|
-
if (
|
|
29876
|
+
if (path43.basename(file) === LINK_SOURCE)
|
|
29690
29877
|
return {
|
|
29691
29878
|
kind: "deny",
|
|
29692
|
-
reason: `workit ${label}: this command links or mounts ${
|
|
29879
|
+
reason: `workit ${label}: this command links or mounts ${path43.dirname(file)}, which is or holds ${what}. ${LINK_UNBLOCK}`,
|
|
29693
29880
|
unblock: LINK_UNBLOCK
|
|
29694
29881
|
};
|
|
29695
|
-
if (
|
|
29882
|
+
if (path43.basename(file) === REMOVED_SOURCE)
|
|
29883
|
+
return {
|
|
29884
|
+
kind: "deny",
|
|
29885
|
+
reason: `workit ${label}: this command removes or moves ${path43.dirname(file)}, which is or holds ${what}. ${unblock}`,
|
|
29886
|
+
unblock
|
|
29887
|
+
};
|
|
29888
|
+
if (path43.basename(file) === UNRESOLVED_TARGET)
|
|
29696
29889
|
return {
|
|
29697
29890
|
kind: "deny",
|
|
29698
29891
|
reason: `workit ${label}: Workit could not resolve the file this command's script writes, which it builds from a path under ${what}. ${unblock}`,
|
|
29699
29892
|
unblock
|
|
29700
29893
|
};
|
|
29701
|
-
const named =
|
|
29894
|
+
const named = path43.basename(file).startsWith(".workit-") ? path43.dirname(file) : file;
|
|
29702
29895
|
return {
|
|
29703
29896
|
kind: "deny",
|
|
29704
29897
|
reason: `workit ${label}: ${named} is under ${what}. ${unblock}`,
|
|
@@ -29789,10 +29982,10 @@ import { spawnSync as spawnSync24 } from "node:child_process";
|
|
|
29789
29982
|
|
|
29790
29983
|
// packages/workit-core/src/ci-waiter.ts
|
|
29791
29984
|
import fs29 from "node:fs";
|
|
29792
|
-
import
|
|
29985
|
+
import path44 from "node:path";
|
|
29793
29986
|
var waiterFile = (cwd, pr) => {
|
|
29794
29987
|
const common = gitCommonDir(cwd);
|
|
29795
|
-
return common ?
|
|
29988
|
+
return common ? path44.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
|
|
29796
29989
|
};
|
|
29797
29990
|
var pidAlive2 = (pid) => {
|
|
29798
29991
|
if (!Number.isSafeInteger(pid) || pid <= 0)
|
|
@@ -29864,11 +30057,11 @@ function currentJudgment(cwd) {
|
|
|
29864
30057
|
}
|
|
29865
30058
|
|
|
29866
30059
|
// packages/workit-core/src/core/verdict-set.ts
|
|
29867
|
-
import
|
|
30060
|
+
import path45 from "node:path";
|
|
29868
30061
|
var SET_TTL_MS = 7 * 86400000;
|
|
29869
30062
|
var SET_ROW = "verdict.set";
|
|
29870
30063
|
var SET_VOID = "verdict.set.voided";
|
|
29871
|
-
var setStorePath = () =>
|
|
30064
|
+
var setStorePath = () => path45.join(resolveStateDir(), "verdicts", "sets", "ledger.jsonl");
|
|
29872
30065
|
var distrusted = (cwd, id, rows, type) => rows.some((row) => row.type === type && row.id === id && trustReasons(cwd, row).length > 0);
|
|
29873
30066
|
function gateStands(cwd, gate, rows, now = Date.now()) {
|
|
29874
30067
|
const id = typeof gate.verdictId === "string" ? gate.verdictId : null;
|
|
@@ -30327,7 +30520,7 @@ var WRITE_TOOLS = new Set([
|
|
|
30327
30520
|
]);
|
|
30328
30521
|
// packages/workit-core/src/hooks/standing.ts
|
|
30329
30522
|
import fs30 from "node:fs";
|
|
30330
|
-
import
|
|
30523
|
+
import path46 from "node:path";
|
|
30331
30524
|
|
|
30332
30525
|
// packages/workit-core/src/approvals/store.ts
|
|
30333
30526
|
var REQUEST_TTL_MS = 30 * 60000;
|
|
@@ -30842,7 +31035,7 @@ var workitRole = (descriptor, agentType) => {
|
|
|
30842
31035
|
|
|
30843
31036
|
// packages/workit-core/src/hooks/standing.ts
|
|
30844
31037
|
var readPlans = (store) => {
|
|
30845
|
-
const dir =
|
|
31038
|
+
const dir = path46.join(store, "fanouts");
|
|
30846
31039
|
let names;
|
|
30847
31040
|
try {
|
|
30848
31041
|
names = fs30.readdirSync(dir).filter((name) => name.endsWith(".json"));
|
|
@@ -30852,7 +31045,7 @@ var readPlans = (store) => {
|
|
|
30852
31045
|
const plans = [];
|
|
30853
31046
|
for (const name of names) {
|
|
30854
31047
|
try {
|
|
30855
|
-
const raw = JSON.parse(fs30.readFileSync(
|
|
31048
|
+
const raw = JSON.parse(fs30.readFileSync(path46.join(dir, name), "utf8"));
|
|
30856
31049
|
if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
|
|
30857
31050
|
continue;
|
|
30858
31051
|
const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
|
|
@@ -31171,8 +31364,8 @@ var UNLISTED = new Set(["description", "prompt"]);
|
|
|
31171
31364
|
|
|
31172
31365
|
// packages/workit-core/src/hooks/server-gate.ts
|
|
31173
31366
|
import fs31 from "node:fs";
|
|
31174
|
-
import
|
|
31175
|
-
var procNoticeFile = (env, session) =>
|
|
31367
|
+
import path47 from "node:path";
|
|
31368
|
+
var procNoticeFile = (env, session) => path47.join(stateDir(env), "procs", "notices", `${session.replace(/[^A-Za-z0-9_.@+-]/gu, "-").slice(0, 120) || "none"}.json`);
|
|
31176
31369
|
var mb = (bytes) => `${Math.round(Number(bytes) / 1048576)} MB`;
|
|
31177
31370
|
function takeProcNotice(session, env = process.env) {
|
|
31178
31371
|
if (!session)
|
|
@@ -31210,21 +31403,21 @@ function takeProcNotice(session, env = process.env) {
|
|
|
31210
31403
|
// packages/workit-core/src/hooks/teardown.ts
|
|
31211
31404
|
import { spawn } from "node:child_process";
|
|
31212
31405
|
import fs32 from "node:fs";
|
|
31213
|
-
import
|
|
31406
|
+
import path49 from "node:path";
|
|
31214
31407
|
|
|
31215
31408
|
// packages/workit-core/src/core/cli-locate.ts
|
|
31216
31409
|
import { closeSync as closeSync3, existsSync as existsSync17, openSync as openSync3, readSync } from "node:fs";
|
|
31217
|
-
import
|
|
31410
|
+
import path48 from "node:path";
|
|
31218
31411
|
var LAUNCHER_MARKER = "workit-owned-launcher";
|
|
31219
31412
|
var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
|
|
31220
31413
|
var installRoot = (env, platform = process.platform) => {
|
|
31221
31414
|
if (env.WORKIT_INSTALL_ROOT)
|
|
31222
31415
|
return env.WORKIT_INSTALL_ROOT;
|
|
31223
31416
|
const data = dataDir(env, platform);
|
|
31224
|
-
return platform === "win32" ?
|
|
31417
|
+
return platform === "win32" ? path48.join(data, "install") : data;
|
|
31225
31418
|
};
|
|
31226
|
-
var ownedLauncherPath = (env, platform = process.platform) =>
|
|
31227
|
-
var ownedCurrentEntry = (env, platform = process.platform) =>
|
|
31419
|
+
var ownedLauncherPath = (env, platform = process.platform) => path48.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
|
|
31420
|
+
var ownedCurrentEntry = (env, platform = process.platform) => path48.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
|
|
31228
31421
|
var head = (file) => {
|
|
31229
31422
|
let fd;
|
|
31230
31423
|
try {
|
|
@@ -31251,7 +31444,7 @@ var locateWorkitCli = (options = {}) => {
|
|
|
31251
31444
|
source: "owned-launcher",
|
|
31252
31445
|
command: launcher,
|
|
31253
31446
|
args: [],
|
|
31254
|
-
binDir:
|
|
31447
|
+
binDir: path48.dirname(launcher)
|
|
31255
31448
|
};
|
|
31256
31449
|
const current = ownedCurrentEntry(env, platform);
|
|
31257
31450
|
if (exists(current))
|
|
@@ -31280,7 +31473,7 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
|
|
|
31280
31473
|
if (located.binDir) {
|
|
31281
31474
|
const key = pathKey(env);
|
|
31282
31475
|
const delimiter = platform === "win32" ? ";" : ":";
|
|
31283
|
-
const same = (dir) => platform === "win32" ?
|
|
31476
|
+
const same = (dir) => platform === "win32" ? path48.win32.normalize(dir).toLowerCase() === path48.win32.normalize(located.binDir).toLowerCase() : path48.posix.normalize(dir) === path48.posix.normalize(located.binDir);
|
|
31284
31477
|
const rest = (env[key] ?? "").split(delimiter).filter((dir) => dir && !same(dir));
|
|
31285
31478
|
patch[key] = [located.binDir, ...rest].join(delimiter);
|
|
31286
31479
|
}
|
|
@@ -31304,9 +31497,9 @@ var ENDS = {
|
|
|
31304
31497
|
};
|
|
31305
31498
|
var SAFE_SESSION = /^[\w.@+][\w.:@/+-]{0,127}$/u;
|
|
31306
31499
|
var HOST_SESSION_VARS2 = ["OPENCODE_SESSION_ID", "PI_SESSION_ID", "CODEX_THREAD_ID"];
|
|
31307
|
-
var teardownDir = (env) =>
|
|
31308
|
-
var teardownLog = (env) =>
|
|
31309
|
-
var reapStamp = (env) =>
|
|
31500
|
+
var teardownDir = (env) => path49.join(stateDir(env), "procs");
|
|
31501
|
+
var teardownLog = (env) => path49.join(teardownDir(env), "teardown.log");
|
|
31502
|
+
var reapStamp = (env) => path49.join(teardownDir(env), "reap-at-start.stamp");
|
|
31310
31503
|
function spawnDetached(request) {
|
|
31311
31504
|
try {
|
|
31312
31505
|
const shell = process.platform === "win32" && !/\.exe$/iu.test(request.command);
|
|
@@ -31333,7 +31526,7 @@ var teardownDeps = {
|
|
|
31333
31526
|
var openLog = (env, args) => {
|
|
31334
31527
|
try {
|
|
31335
31528
|
const file = teardownLog(env);
|
|
31336
|
-
fs32.mkdirSync(
|
|
31529
|
+
fs32.mkdirSync(path49.dirname(file), { recursive: true });
|
|
31337
31530
|
let size = 0;
|
|
31338
31531
|
try {
|
|
31339
31532
|
size = fs32.statSync(file).size;
|
|
@@ -31418,7 +31611,7 @@ function reapAtStart(_cwd, env = process.env) {
|
|
|
31418
31611
|
try {
|
|
31419
31612
|
if (fresh(stamp, now))
|
|
31420
31613
|
return false;
|
|
31421
|
-
fs32.mkdirSync(
|
|
31614
|
+
fs32.mkdirSync(path49.dirname(stamp), { recursive: true });
|
|
31422
31615
|
if (!claim2(lock, now))
|
|
31423
31616
|
return false;
|
|
31424
31617
|
} catch {
|
|
@@ -32107,14 +32300,82 @@ Retry as: ${retry}`,
|
|
|
32107
32300
|
return null;
|
|
32108
32301
|
}
|
|
32109
32302
|
|
|
32303
|
+
// packages/workit-core/src/hooks/hook-entry.ts
|
|
32304
|
+
var RUNNERS2 = new Set([
|
|
32305
|
+
"node",
|
|
32306
|
+
"nodejs",
|
|
32307
|
+
"bun",
|
|
32308
|
+
"deno",
|
|
32309
|
+
"tsx",
|
|
32310
|
+
"ts-node",
|
|
32311
|
+
"sh",
|
|
32312
|
+
"bash",
|
|
32313
|
+
"zsh",
|
|
32314
|
+
"dash",
|
|
32315
|
+
"ksh",
|
|
32316
|
+
"fish",
|
|
32317
|
+
"source",
|
|
32318
|
+
"."
|
|
32319
|
+
]);
|
|
32320
|
+
var PACKAGE_RUNNERS2 = new Set(["npx", "bunx", "pnpx"]);
|
|
32321
|
+
var NO_RUN = new Set([
|
|
32322
|
+
"build",
|
|
32323
|
+
"test",
|
|
32324
|
+
"fmt",
|
|
32325
|
+
"lint",
|
|
32326
|
+
"check",
|
|
32327
|
+
"doc",
|
|
32328
|
+
"info",
|
|
32329
|
+
"install",
|
|
32330
|
+
"add",
|
|
32331
|
+
"pm"
|
|
32332
|
+
]);
|
|
32333
|
+
var MORE_WRAPPERS = new Set(["strace", "ltrace", "watch", "unshare", "firejail", "xargs", "&"]);
|
|
32334
|
+
var KEYWORDS3 = new Set([
|
|
32335
|
+
"{",
|
|
32336
|
+
"}",
|
|
32337
|
+
"if",
|
|
32338
|
+
"then",
|
|
32339
|
+
"elif",
|
|
32340
|
+
"else",
|
|
32341
|
+
"fi",
|
|
32342
|
+
"while",
|
|
32343
|
+
"until",
|
|
32344
|
+
"do",
|
|
32345
|
+
"done",
|
|
32346
|
+
"esac",
|
|
32347
|
+
"!"
|
|
32348
|
+
]);
|
|
32349
|
+
var READERS2 = new Set(("cat less more head tail ls dir stat file wc grep egrep fgrep rg ag diff cmp sha256sum md5sum " + "shasum du bat echo printf cp mv rm chmod touch mkdir realpath readlink dirname basename tee " + "oxfmt oxlint prettier eslint tsc gh jq sort uniq cut tr nl od xxd hexdump strings code vim " + "nano sed get-content gc type select-string get-childitem test-path").split(" "));
|
|
32350
|
+
|
|
32110
32351
|
// packages/workit-core/src/hooks/identity-env.ts
|
|
32111
32352
|
var NAMES = "WORKIT_(?:AGENT_ID|HOST|SESSION_ID|SESSION_TOKEN)";
|
|
32112
|
-
var HOST_NAMES = "(?:OPENCODE_SESSION_ID|PI_SESSION_ID|CODEX_THREAD_ID|CLAUDECODE|CLAUDE_CODE_ENTRYPOINT)";
|
|
32113
32353
|
var IDENTITY = new RegExp(`^${NAMES}$`, "u");
|
|
32354
|
+
var HOST_NAMES = "(?:OPENCODE_SESSION_ID|PI_SESSION_ID|CODEX_THREAD_ID|CLAUDECODE|CLAUDE_CODE_ENTRYPOINT)";
|
|
32114
32355
|
var HOST_VARIABLE = new RegExp(`^${HOST_NAMES}$`, "u");
|
|
32115
|
-
var
|
|
32356
|
+
var IDENTITY_ANY = new RegExp(NAMES, "iu");
|
|
32357
|
+
var STATE_NAMES = "(?:WORKIT_(?:STATE_DIR|CONFIG(?:_DIR)?)|XDG_(?:STATE|CONFIG|DATA)_HOME|HOME|USERPROFILE|(?:LOCAL)?APPDATA)";
|
|
32358
|
+
var STATE2 = new RegExp(`^${STATE_NAMES}$`, "u");
|
|
32359
|
+
var STATE_ANY = new RegExp(STATE_NAMES, "iu");
|
|
32360
|
+
var powershell = (names) => new RegExp([
|
|
32361
|
+
`\\$\\{?env:${names}\\}?\\s*(?:[-+*/]|\\?\\?)?=(?!=)`,
|
|
32362
|
+
`${PS_ITEM}[^;|\\n]*?(?<![$\\w{])env:[\\\\/]?${names}\\b`,
|
|
32363
|
+
`SetEnvironmentVariable\\(\\s*['"]${names}\\b`
|
|
32364
|
+
].join("|"), "iu");
|
|
32365
|
+
var PS_ITEM = "\\b(?:(?:Set|New|Remove|Clear|Rename|Move|Copy)-Item(?:Property)?|(?:Set|Add|Clear)-Content|si|ni|ri|rm|del|erase|rd|rmdir|cli|sc|ac|clc|rni|mi|move|mv|cpi|copy|cp|ren)\\b";
|
|
32116
32366
|
var POWERSHELL = powershell(NAMES);
|
|
32367
|
+
var POWERSHELL_STATE = powershell(STATE_NAMES);
|
|
32117
32368
|
var POWERSHELL_HOST = powershell(HOST_NAMES);
|
|
32369
|
+
var POWERSHELL_OPAQUE = new RegExp([
|
|
32370
|
+
`SetEnvironmentVariable\\(\\s*(?:[^'"\\s]|"[^"]*\\$)`,
|
|
32371
|
+
`${PS_ITEM}[^;|\\n]*?(?<![$\\w{])env:[\\\\/]?["']?[$(]`,
|
|
32372
|
+
`(?:^|[;&|{(\\n])\\s*\\.\\s+[^\\s.]`,
|
|
32373
|
+
`\\b(?:iex|Invoke-Expression)\\b`
|
|
32374
|
+
].join("|"), "iu");
|
|
32375
|
+
var cmdSet = (names) => new RegExp(`(?:^|[&|(\\s"])set\\s+(?:/[ap]\\s+)?"?(${names})\\s*\\+?=`, "iu");
|
|
32376
|
+
var CMD_IDENTITY = cmdSet(NAMES);
|
|
32377
|
+
var CMD_STATE = cmdSet(STATE_NAMES);
|
|
32378
|
+
var CMD_HOST = cmdSet(HOST_NAMES);
|
|
32118
32379
|
var DECLARES = new Set(["export", "unset", "declare", "typeset", "local", "readonly"]);
|
|
32119
32380
|
var OPAQUE = new Set([
|
|
32120
32381
|
"watch",
|
|
@@ -32148,11 +32409,11 @@ var PROCESS_START = performance.timeOrigin;
|
|
|
32148
32409
|
// packages/workit-core/src/hooks/run.ts
|
|
32149
32410
|
if (false) {}
|
|
32150
32411
|
// packages/workit-opencode/src/shared/init-apply.ts
|
|
32151
|
-
import
|
|
32412
|
+
import path55 from "node:path";
|
|
32152
32413
|
|
|
32153
32414
|
// packages/workit-core/src/core/gitignore.ts
|
|
32154
32415
|
import { existsSync as existsSync18, readFileSync as readFileSync13, writeFileSync as writeFileSync6 } from "node:fs";
|
|
32155
|
-
import
|
|
32416
|
+
import path50 from "node:path";
|
|
32156
32417
|
var GITIGNORE_ENTRIES = [
|
|
32157
32418
|
"# workit: SDD working state (never commit)",
|
|
32158
32419
|
"docs/*/sdd/",
|
|
@@ -32172,7 +32433,7 @@ var GITIGNORE_ENTRIES = [
|
|
|
32172
32433
|
var ensureProjectGitignore = (workspaceRoot, confirmed) => {
|
|
32173
32434
|
if (!confirmed)
|
|
32174
32435
|
return { ok: false, error: "confirmed: true required" };
|
|
32175
|
-
const file =
|
|
32436
|
+
const file = path50.join(workspaceRoot, ".gitignore");
|
|
32176
32437
|
const existing = existsSync18(file) ? readFileSync13(file, "utf8") : "";
|
|
32177
32438
|
const existingLines = new Set(existing.split(`
|
|
32178
32439
|
`).map((l) => l.trim()).filter(Boolean));
|
|
@@ -32199,8 +32460,8 @@ var ensureProjectGitignore = (workspaceRoot, confirmed) => {
|
|
|
32199
32460
|
};
|
|
32200
32461
|
|
|
32201
32462
|
// packages/workit-core/src/core/hygiene.ts
|
|
32202
|
-
import { existsSync as existsSync20, readFileSync as readFileSync15, readdirSync as
|
|
32203
|
-
import
|
|
32463
|
+
import { existsSync as existsSync20, readFileSync as readFileSync15, readdirSync as readdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
|
|
32464
|
+
import path52 from "node:path";
|
|
32204
32465
|
|
|
32205
32466
|
// packages/workit-core/src/git/ops.ts
|
|
32206
32467
|
import { spawnSync as spawnSync25 } from "node:child_process";
|
|
@@ -32208,12 +32469,12 @@ import {
|
|
|
32208
32469
|
copyFileSync as copyFileSync3,
|
|
32209
32470
|
existsSync as existsSync19,
|
|
32210
32471
|
mkdirSync as mkdirSync6,
|
|
32211
|
-
readdirSync as
|
|
32472
|
+
readdirSync as readdirSync7,
|
|
32212
32473
|
readFileSync as readFileSync14,
|
|
32213
32474
|
rmSync as rmSync3,
|
|
32214
32475
|
writeFileSync as writeFileSync7
|
|
32215
32476
|
} from "node:fs";
|
|
32216
|
-
import
|
|
32477
|
+
import path51 from "node:path";
|
|
32217
32478
|
var COMMIT_TIMEOUT_MS = 10 * 60000;
|
|
32218
32479
|
var git5 = (cwd, args, options = {}) => {
|
|
32219
32480
|
const result = spawnSync25("git", args, {
|
|
@@ -32246,18 +32507,18 @@ function operationInProgress(cwd) {
|
|
|
32246
32507
|
if (!run.ok)
|
|
32247
32508
|
return null;
|
|
32248
32509
|
const found = run.stdout.split(`
|
|
32249
|
-
`).map((line) =>
|
|
32510
|
+
`).map((line) => path51.resolve(cwd, line.trim()));
|
|
32250
32511
|
const conflicted = () => git5(cwd, ["ls-files", "-u"]).stdout.trim() !== "";
|
|
32251
32512
|
for (const [index, [, operation]] of markers.entries()) {
|
|
32252
32513
|
const marker = found[index];
|
|
32253
32514
|
if (!marker || !existsSync19(marker))
|
|
32254
32515
|
continue;
|
|
32255
|
-
if (index === 1 && existsSync19(
|
|
32516
|
+
if (index === 1 && existsSync19(path51.join(marker, "applying")))
|
|
32256
32517
|
return { operation: "am", commitAllowed: false, branch: null };
|
|
32257
|
-
if (index === 0 && existsSync19(
|
|
32518
|
+
if (index === 0 && existsSync19(path51.join(marker, "amend")) && !conflicted()) {
|
|
32258
32519
|
let headName = "";
|
|
32259
32520
|
try {
|
|
32260
|
-
headName = readFileSync14(
|
|
32521
|
+
headName = readFileSync14(path51.join(marker, "head-name"), "utf8").trim();
|
|
32261
32522
|
} catch {}
|
|
32262
32523
|
const branch = headName.startsWith("refs/heads/") ? headName.slice("refs/heads/".length) : null;
|
|
32263
32524
|
return { operation, commitAllowed: branch !== null, branch };
|
|
@@ -32310,23 +32571,23 @@ var BATCH_BYTES = 16 * 1024 * 1024;
|
|
|
32310
32571
|
|
|
32311
32572
|
// packages/workit-core/src/core/hygiene.ts
|
|
32312
32573
|
var repoRoot3 = assetRoot();
|
|
32313
|
-
var templatesDir = () =>
|
|
32574
|
+
var templatesDir = () => path52.join(repoRoot3, "templates", "hygiene");
|
|
32314
32575
|
var packageJson2 = (root) => {
|
|
32315
|
-
if (!existsSync20(
|
|
32576
|
+
if (!existsSync20(path52.join(root, "package.json")))
|
|
32316
32577
|
return null;
|
|
32317
32578
|
try {
|
|
32318
|
-
return JSON.parse(readFileSync15(
|
|
32579
|
+
return JSON.parse(readFileSync15(path52.join(root, "package.json"), "utf8"));
|
|
32319
32580
|
} catch {
|
|
32320
32581
|
return null;
|
|
32321
32582
|
}
|
|
32322
32583
|
};
|
|
32323
32584
|
var isOpenSource = (root) => {
|
|
32324
|
-
if (existsSync20(
|
|
32585
|
+
if (existsSync20(path52.join(root, "LICENSE")))
|
|
32325
32586
|
return true;
|
|
32326
32587
|
const pkg = packageJson2(root);
|
|
32327
32588
|
if (pkg && !pkg.private)
|
|
32328
32589
|
return true;
|
|
32329
|
-
return
|
|
32590
|
+
return path52.basename(root) === "workit";
|
|
32330
32591
|
};
|
|
32331
32592
|
var licenseHolder = (root) => {
|
|
32332
32593
|
const pkg = packageJson2(root);
|
|
@@ -32349,13 +32610,13 @@ var planHygieneFiles = (root, opts = {}) => {
|
|
|
32349
32610
|
files.push("LICENSE", "CONTRIBUTING.md");
|
|
32350
32611
|
const planned = [];
|
|
32351
32612
|
for (const file of files) {
|
|
32352
|
-
if (existsSync20(
|
|
32613
|
+
if (existsSync20(path52.join(root, file)))
|
|
32353
32614
|
continue;
|
|
32354
|
-
const tpl =
|
|
32615
|
+
const tpl = path52.join(templatesDir(), file);
|
|
32355
32616
|
if (!existsSync20(tpl))
|
|
32356
32617
|
continue;
|
|
32357
|
-
const content = readFileSync15(tpl, "utf8").replace(/<PROJECT>/g,
|
|
32358
|
-
planned.push({ path:
|
|
32618
|
+
const content = readFileSync15(tpl, "utf8").replace(/<PROJECT>/g, path52.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
|
|
32619
|
+
planned.push({ path: path52.join(root, file), content });
|
|
32359
32620
|
}
|
|
32360
32621
|
return planned;
|
|
32361
32622
|
};
|
|
@@ -32365,19 +32626,19 @@ var ensureHygieneFiles = (root, opts) => {
|
|
|
32365
32626
|
const created = [];
|
|
32366
32627
|
for (const planned of planHygieneFiles(root, opts)) {
|
|
32367
32628
|
writeFileSync8(planned.path, planned.content, "utf8");
|
|
32368
|
-
created.push(
|
|
32629
|
+
created.push(path52.basename(planned.path));
|
|
32369
32630
|
}
|
|
32370
32631
|
return { ok: true, created };
|
|
32371
32632
|
};
|
|
32372
32633
|
|
|
32373
32634
|
// packages/workit-core/src/core/init.ts
|
|
32374
32635
|
import fs33 from "node:fs";
|
|
32375
|
-
import
|
|
32636
|
+
import path54 from "node:path";
|
|
32376
32637
|
import { spawnSync as spawnSync26 } from "node:child_process";
|
|
32377
32638
|
|
|
32378
32639
|
// packages/workit-core/src/core/workspace-branch-policy.ts
|
|
32379
32640
|
import { mkdirSync as mkdirSync7, readFileSync as readFileSync16, renameSync as renameSync5, rmSync as rmSync4, writeFileSync as writeFileSync9 } from "node:fs";
|
|
32380
|
-
import
|
|
32641
|
+
import path53 from "node:path";
|
|
32381
32642
|
import { isDeepStrictEqual } from "node:util";
|
|
32382
32643
|
var readFileSafe = (p) => {
|
|
32383
32644
|
try {
|
|
@@ -32388,7 +32649,7 @@ var readFileSafe = (p) => {
|
|
|
32388
32649
|
};
|
|
32389
32650
|
function applyWorkspaceBranchPolicy(opts) {
|
|
32390
32651
|
const { workspace_root, env = process.env } = opts;
|
|
32391
|
-
const dir =
|
|
32652
|
+
const dir = path53.join(env.WORKIT_CONFIG ?? configDir2());
|
|
32392
32653
|
const {
|
|
32393
32654
|
status,
|
|
32394
32655
|
path: wsPath,
|
|
@@ -32400,7 +32661,7 @@ function applyWorkspaceBranchPolicy(opts) {
|
|
|
32400
32661
|
if (status === "malformed" || status === "invalid")
|
|
32401
32662
|
return { ok: false, error: workspacesError ?? `invalid workspaces.json: ${wsPath}` };
|
|
32402
32663
|
const detection = detectBranchPolicy(workspace_root);
|
|
32403
|
-
const name = String(env.WORKIT_BP_NAME ??
|
|
32664
|
+
const name = String(env.WORKIT_BP_NAME ?? path53.basename(workspace_root));
|
|
32404
32665
|
const integration = env.WORKIT_BP_INTEGRATION ?? detection.integration;
|
|
32405
32666
|
const policy = {
|
|
32406
32667
|
preset: detection.preset,
|
|
@@ -32449,7 +32710,7 @@ function applyWorkspaceBranchPolicy(opts) {
|
|
|
32449
32710
|
ok: false,
|
|
32450
32711
|
error: `workspaces.json changed while applying the branch policy: ${wsPath}`
|
|
32451
32712
|
};
|
|
32452
|
-
mkdirSync7(
|
|
32713
|
+
mkdirSync7(path53.dirname(wsPath), { recursive: true });
|
|
32453
32714
|
const tmp = `${wsPath}.${process.pid}.tmp`;
|
|
32454
32715
|
try {
|
|
32455
32716
|
writeFileSync9(tmp, JSON.stringify({ ...document, workspaces: next }, null, 2) + `
|
|
@@ -32549,7 +32810,7 @@ function initApplyData(action, env = process.env) {
|
|
|
32549
32810
|
fs33.mkdirSync(dir, { recursive: true });
|
|
32550
32811
|
switch (action) {
|
|
32551
32812
|
case "youtrack_json": {
|
|
32552
|
-
const out =
|
|
32813
|
+
const out = path54.join(dir, "youtrack.json");
|
|
32553
32814
|
fs33.writeFileSync(out, JSON.stringify(youtrackJsonContent(), null, 2) + `
|
|
32554
32815
|
`, "utf8");
|
|
32555
32816
|
return { action, ok: true, path: out };
|
|
@@ -32563,10 +32824,10 @@ function initApplyData(action, env = process.env) {
|
|
|
32563
32824
|
};
|
|
32564
32825
|
}
|
|
32565
32826
|
case "youtrack_scaffold": {
|
|
32566
|
-
const jsonOut =
|
|
32827
|
+
const jsonOut = path54.join(dir, "youtrack.json");
|
|
32567
32828
|
fs33.writeFileSync(jsonOut, JSON.stringify(youtrackJsonContent(), null, 2) + `
|
|
32568
32829
|
`, "utf8");
|
|
32569
|
-
const configPath =
|
|
32830
|
+
const configPath = path54.resolve(jsonOut);
|
|
32570
32831
|
const cfg = readJson3(configPath) ?? {};
|
|
32571
32832
|
const base = String(cfg.baseUrl ?? "").replace(/\/+$/, "");
|
|
32572
32833
|
const meeting = String(cfg.meetingIssue ?? "");
|
|
@@ -32602,10 +32863,10 @@ function initApplyData(action, env = process.env) {
|
|
|
32602
32863
|
};
|
|
32603
32864
|
}
|
|
32604
32865
|
case "vcs_scaffold": {
|
|
32605
|
-
const jsonOut =
|
|
32866
|
+
const jsonOut = path54.join(dir, "vcs.json");
|
|
32606
32867
|
fs33.writeFileSync(jsonOut, JSON.stringify(vcsJsonContent(), null, 2) + `
|
|
32607
32868
|
`, "utf8");
|
|
32608
|
-
const configPath =
|
|
32869
|
+
const configPath = path54.resolve(jsonOut);
|
|
32609
32870
|
const prev = process.env.WORKIT_VCS_CONFIG;
|
|
32610
32871
|
process.env.WORKIT_VCS_CONFIG = configPath;
|
|
32611
32872
|
try {
|
|
@@ -32724,7 +32985,7 @@ var executeInitApply = (args, directory, runtime) => {
|
|
|
32724
32985
|
protectedNames: args.branch_policy_protected
|
|
32725
32986
|
}, current);
|
|
32726
32987
|
writeConfig(next);
|
|
32727
|
-
return output(ok({ action: "config", path:
|
|
32988
|
+
return output(ok({ action: "config", path: path55.join(configDir2(), "config.json"), ...next }));
|
|
32728
32989
|
}
|
|
32729
32990
|
const env = Object.fromEntries(Object.entries({
|
|
32730
32991
|
WORKIT_YT_BASE_URL: args.base_url,
|
|
@@ -32741,14 +33002,14 @@ var executeInitApply = (args, directory, runtime) => {
|
|
|
32741
33002
|
|
|
32742
33003
|
// packages/workit-opencode/src/shared/session.ts
|
|
32743
33004
|
import { realpathSync as realpathSync12 } from "node:fs";
|
|
32744
|
-
import
|
|
33005
|
+
import path56 from "node:path";
|
|
32745
33006
|
var sameWorkspace = (expected, observed) => {
|
|
32746
33007
|
if (typeof observed !== "string" || !observed)
|
|
32747
33008
|
return false;
|
|
32748
33009
|
try {
|
|
32749
33010
|
return realpathSync12(expected) === realpathSync12(observed);
|
|
32750
33011
|
} catch {
|
|
32751
|
-
return
|
|
33012
|
+
return path56.resolve(expected) === path56.resolve(observed);
|
|
32752
33013
|
}
|
|
32753
33014
|
};
|
|
32754
33015
|
|
|
@@ -32820,7 +33081,7 @@ var workitFamilyOf = (toolName) => {
|
|
|
32820
33081
|
|
|
32821
33082
|
// packages/workit-opencode/src/tools/context.ts
|
|
32822
33083
|
import { realpathSync as realpathSync13 } from "node:fs";
|
|
32823
|
-
import
|
|
33084
|
+
import path57 from "node:path";
|
|
32824
33085
|
var createContextTool = () => ({
|
|
32825
33086
|
description: "Read Git, pull request, YouTrack, issue, changelog, release, or affected-file context.",
|
|
32826
33087
|
execute: async (args, context) => {
|
|
@@ -32830,7 +33091,7 @@ var createContextTool = () => ({
|
|
|
32830
33091
|
let root;
|
|
32831
33092
|
try {
|
|
32832
33093
|
const cwd = parsed.data.cwd;
|
|
32833
|
-
root = realpathSync13(cwd ?
|
|
33094
|
+
root = realpathSync13(cwd ? path57.resolve(context.directory, cwd) : context.directory);
|
|
32834
33095
|
} catch {
|
|
32835
33096
|
return JSON.stringify(failure2("invalid_input", "context target directory cannot be resolved"), null, 2);
|
|
32836
33097
|
}
|
|
@@ -32863,7 +33124,7 @@ var workerCoordinatorFor = (task, worker) => {
|
|
|
32863
33124
|
import { spawnSync as spawnSync29 } from "node:child_process";
|
|
32864
33125
|
import { createHash as createHash21 } from "node:crypto";
|
|
32865
33126
|
import fs35 from "node:fs";
|
|
32866
|
-
import
|
|
33127
|
+
import path59 from "node:path";
|
|
32867
33128
|
|
|
32868
33129
|
// packages/workit-core/src/fanout-landed.ts
|
|
32869
33130
|
import { spawnSync as spawnSync27 } from "node:child_process";
|
|
@@ -33097,7 +33358,7 @@ var NOTICE_TTL_MS = 7 * 86400000;
|
|
|
33097
33358
|
import { spawnSync as spawnSync28 } from "node:child_process";
|
|
33098
33359
|
import { createHash as createHash20, randomBytes as randomBytes4 } from "node:crypto";
|
|
33099
33360
|
import fs34 from "node:fs";
|
|
33100
|
-
import
|
|
33361
|
+
import path58 from "node:path";
|
|
33101
33362
|
|
|
33102
33363
|
// packages/workit-core/src/forge/report.ts
|
|
33103
33364
|
var GITLAB_MERGEABLE = new Set(["mergeable"]);
|
|
@@ -33179,7 +33440,7 @@ function rebaseInProgress(dir) {
|
|
|
33179
33440
|
}
|
|
33180
33441
|
var scratchDir = (cwd) => {
|
|
33181
33442
|
const dir = stacksDir(cwd);
|
|
33182
|
-
return dir.ok ?
|
|
33443
|
+
return dir.ok ? path58.join(dir.data, "worktrees") : null;
|
|
33183
33444
|
};
|
|
33184
33445
|
function gitRestack(cwd, input) {
|
|
33185
33446
|
const owner = worktreeOf(cwd, input.branch);
|
|
@@ -33194,7 +33455,7 @@ function gitRestack(cwd, input) {
|
|
|
33194
33455
|
error: "no store root"
|
|
33195
33456
|
};
|
|
33196
33457
|
fs34.mkdirSync(scratch, { recursive: true });
|
|
33197
|
-
dir =
|
|
33458
|
+
dir = path58.join(scratch, `${input.branch.replace(/[^A-Za-z0-9._-]+/gu, "_").slice(0, 40)}-${randomBytes4(4).toString("hex")}`);
|
|
33198
33459
|
const added = gitRun4(cwd, ["worktree", "add", "-q", dir, input.branch], GIT_TIMEOUTS.worktree);
|
|
33199
33460
|
if (!added.ok)
|
|
33200
33461
|
return {
|
|
@@ -33253,7 +33514,7 @@ function stacksDir(cwd) {
|
|
|
33253
33514
|
const root = storeRoot(cwd);
|
|
33254
33515
|
if (!root.ok)
|
|
33255
33516
|
return stackFail(root.code, root.error, root.unblock);
|
|
33256
|
-
return { ok: true, data:
|
|
33517
|
+
return { ok: true, data: path58.join(root.value.root, "stacks") };
|
|
33257
33518
|
}
|
|
33258
33519
|
var HEARTBEAT_STALE_MS = 2 * 60000;
|
|
33259
33520
|
var SETTLED_BY_RESTACK = new Set(["checks_pending", "behind_base_required"]);
|
|
@@ -33400,7 +33661,7 @@ function fanoutsDir(cwd) {
|
|
|
33400
33661
|
const root = storeRoot(cwd);
|
|
33401
33662
|
if (!root.ok)
|
|
33402
33663
|
return fanoutFail(root.code, root.error, root.unblock);
|
|
33403
|
-
return { ok: true, data:
|
|
33664
|
+
return { ok: true, data: path59.join(root.value.root, "fanouts") };
|
|
33404
33665
|
}
|
|
33405
33666
|
function parseStored(raw) {
|
|
33406
33667
|
if (!isRecord9(raw) || typeof raw.name !== "string" || typeof raw.trunk !== "string")
|
|
@@ -33468,7 +33729,7 @@ function readFanout(cwd, name) {
|
|
|
33468
33729
|
const dir = fanoutsDir(cwd);
|
|
33469
33730
|
if (!dir.ok)
|
|
33470
33731
|
return dir;
|
|
33471
|
-
const file =
|
|
33732
|
+
const file = path59.join(dir.data, stackFileName(name));
|
|
33472
33733
|
let parsed = null;
|
|
33473
33734
|
try {
|
|
33474
33735
|
parsed = parseStored(JSON.parse(fs35.readFileSync(file, "utf8")));
|
|
@@ -33493,7 +33754,7 @@ function listFanouts(cwd) {
|
|
|
33493
33754
|
for (const entry of names) {
|
|
33494
33755
|
let parsed = null;
|
|
33495
33756
|
try {
|
|
33496
|
-
parsed = parseStored(JSON.parse(fs35.readFileSync(
|
|
33757
|
+
parsed = parseStored(JSON.parse(fs35.readFileSync(path59.join(dir.data, entry), "utf8")));
|
|
33497
33758
|
} catch {
|
|
33498
33759
|
parsed = null;
|
|
33499
33760
|
}
|
|
@@ -34386,7 +34647,7 @@ var childTaskMissing = (store, input) => {
|
|
|
34386
34647
|
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`;
|
|
34387
34648
|
|
|
34388
34649
|
// packages/workit-opencode/src/v2/shell.ts
|
|
34389
|
-
import
|
|
34650
|
+
import path60 from "node:path";
|
|
34390
34651
|
|
|
34391
34652
|
// packages/workit-core/src/hooks/repeat-failure.ts
|
|
34392
34653
|
import { createHash as createHash22 } from "node:crypto";
|
|
@@ -34449,7 +34710,7 @@ var commandOf = (input) => {
|
|
|
34449
34710
|
};
|
|
34450
34711
|
var hookInput = (root, sessionID, id, shell) => ({
|
|
34451
34712
|
host: "opencode",
|
|
34452
|
-
cwd: shell.workdir ?
|
|
34713
|
+
cwd: shell.workdir ? path60.resolve(root, shell.workdir) : root,
|
|
34453
34714
|
session: { id: sessionID, agentId: null, agentType: null, parentId: null },
|
|
34454
34715
|
permissionMode: null,
|
|
34455
34716
|
transcriptPath: null,
|
|
@@ -34973,37 +35234,37 @@ var createStopControl = (root, port) => {
|
|
|
34973
35234
|
|
|
34974
35235
|
// packages/workit-opencode/src/v2/registry.ts
|
|
34975
35236
|
import { existsSync as existsSync22, readFileSync as readFileSync17 } from "node:fs";
|
|
34976
|
-
import
|
|
35237
|
+
import path62 from "node:path";
|
|
34977
35238
|
|
|
34978
35239
|
// packages/workit-opencode/src/shared/assets.ts
|
|
34979
35240
|
import { existsSync as existsSync21, realpathSync as realpathSync14 } from "node:fs";
|
|
34980
|
-
import
|
|
35241
|
+
import path61 from "node:path";
|
|
34981
35242
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
34982
35243
|
var moduleDir = () => {
|
|
34983
35244
|
try {
|
|
34984
|
-
return realpathSync14(
|
|
35245
|
+
return realpathSync14(path61.dirname(fileURLToPath2(import.meta.url)));
|
|
34985
35246
|
} catch {
|
|
34986
|
-
return
|
|
35247
|
+
return path61.dirname(fileURLToPath2(import.meta.url));
|
|
34987
35248
|
}
|
|
34988
35249
|
};
|
|
34989
35250
|
var packageRoot2 = () => {
|
|
34990
35251
|
const dir = moduleDir();
|
|
34991
35252
|
for (const candidate of [
|
|
34992
|
-
|
|
34993
|
-
|
|
34994
|
-
|
|
35253
|
+
path61.resolve(dir, ".."),
|
|
35254
|
+
path61.resolve(dir, "..", ".."),
|
|
35255
|
+
path61.resolve(dir, "..", "..", "..")
|
|
34995
35256
|
]) {
|
|
34996
|
-
if (existsSync21(
|
|
35257
|
+
if (existsSync21(path61.join(candidate, "package.json")))
|
|
34997
35258
|
return candidate;
|
|
34998
35259
|
}
|
|
34999
|
-
return
|
|
35260
|
+
return path61.resolve(dir, "..");
|
|
35000
35261
|
};
|
|
35001
35262
|
var skillsRoot = () => {
|
|
35002
35263
|
const root = packageRoot2();
|
|
35003
|
-
const canonical =
|
|
35004
|
-
if (existsSync21(
|
|
35264
|
+
const canonical = path61.resolve(root, "..", "workit-core", "skills");
|
|
35265
|
+
if (existsSync21(path61.join(root, "src")) && existsSync21(canonical))
|
|
35005
35266
|
return canonical;
|
|
35006
|
-
return
|
|
35267
|
+
return path61.join(root, "assets", "skills");
|
|
35007
35268
|
};
|
|
35008
35269
|
|
|
35009
35270
|
// packages/workit-opencode/src/v2/registry.ts
|
|
@@ -35030,11 +35291,11 @@ var registerSkills = async (ctx) => {
|
|
|
35030
35291
|
if (!existsSync22(skillsDir))
|
|
35031
35292
|
return new Set;
|
|
35032
35293
|
const listed = await ctx.skill.list().catch(() => ({ data: [] }));
|
|
35033
|
-
const own = (skill) => typeof skill.path === "string" &&
|
|
35294
|
+
const own = (skill) => typeof skill.path === "string" && path62.resolve(skill.path).startsWith(skillsDir + path62.sep);
|
|
35034
35295
|
const userSkills = new Set((listed?.data ?? []).filter((skill) => !own(skill)).map((skill) => skill.id));
|
|
35035
35296
|
const packaged = new Map;
|
|
35036
35297
|
for (const id of WORKIT_METHOD_SKILLS) {
|
|
35037
|
-
const file =
|
|
35298
|
+
const file = path62.join(skillsDir, id, "SKILL.md");
|
|
35038
35299
|
if (!userSkills.has(id) && existsSync22(file))
|
|
35039
35300
|
packaged.set(id, file);
|
|
35040
35301
|
}
|
|
@@ -35081,23 +35342,23 @@ var registerCommands = async (ctx, registeredSkills) => {
|
|
|
35081
35342
|
};
|
|
35082
35343
|
|
|
35083
35344
|
// packages/workit-opencode/src/stale-sources.ts
|
|
35084
|
-
import { existsSync as existsSync23, readdirSync as
|
|
35085
|
-
import
|
|
35345
|
+
import { existsSync as existsSync23, readdirSync as readdirSync9 } from "node:fs";
|
|
35346
|
+
import path63 from "node:path";
|
|
35086
35347
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
35087
35348
|
var typescriptFiles = (directory) => {
|
|
35088
35349
|
if (!existsSync23(directory))
|
|
35089
35350
|
return [];
|
|
35090
|
-
return
|
|
35091
|
-
const file =
|
|
35351
|
+
return readdirSync9(directory, { withFileTypes: true }).flatMap((entry) => {
|
|
35352
|
+
const file = path63.join(directory, entry.name);
|
|
35092
35353
|
return entry.isDirectory() ? typescriptFiles(file) : entry.isFile() && file.endsWith(".ts") ? [file] : [];
|
|
35093
35354
|
});
|
|
35094
35355
|
};
|
|
35095
35356
|
var pluginSourceFiles = [
|
|
35096
35357
|
...new Set([
|
|
35097
35358
|
fileURLToPath3(import.meta.url),
|
|
35098
|
-
...typescriptFiles(
|
|
35099
|
-
|
|
35100
|
-
...typescriptFiles(
|
|
35359
|
+
...typescriptFiles(path63.join(packageRoot2(), "src")),
|
|
35360
|
+
path63.join(packageRoot2(), "..", "workit-core", "src", "core.ts"),
|
|
35361
|
+
...typescriptFiles(path63.join(packageRoot2(), "..", "workit-core", "src", "core"))
|
|
35101
35362
|
])
|
|
35102
35363
|
].filter((file) => existsSync23(file)).toSorted();
|
|
35103
35364
|
|