@workit-dev/opencode 2.24.0 → 2.25.1
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 +212 -96
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -8799,6 +8799,7 @@ var workspaceConfigSchema = looseObject({
|
|
|
8799
8799
|
cleanup: described(optional(unknown()), "What happens when work finishes: `auto` (default) removes the delivered branch's clean Workit worktree and local branch, switches a clean checkout on it back to the trunk, and stops the processes registered inside them; `keep` removes and stops nothing. A value Workit does not know reads as `keep`."),
|
|
8800
8800
|
feedback: described(optional(unknown()), '`workit feedback` for this workspace: `off` hides its contract line and makes the verb refuse; `{ "account": "<login>" }` names the GitHub login it posts with; workspaces inside this one inherit it.'),
|
|
8801
8801
|
liveSessionGuard: described(optional(boolean2()), "Whether the live-session guard denies edits in a checkout another live agent session owns (default true)."),
|
|
8802
|
+
shared: described(optional(boolean2()), "Whether this workspace's repos are shared with a team that must not see Workit named (default false): `workit pr create` and `workit pr edit` then warn, never block, when the PR title, body or a new doc names it."),
|
|
8802
8803
|
fanout: described(optional(looseObject({
|
|
8803
8804
|
tierModels: described(optional(unknown()), "The model per slice TIER (mundane, standard, hard), as one name or per host."),
|
|
8804
8805
|
deps: described(optional(unknown()), "How `workit fanout worktree create` gives a slice worktree node_modules: `install` (default: its own frozen install of its lockfile) or `link` (links into the main checkout's installed packages, for a repo too slow to install per slice). `--deps` overrides it."),
|
|
@@ -28057,6 +28058,58 @@ var linkSources = (args, at) => {
|
|
|
28057
28058
|
return resolved ? [resolved] : [];
|
|
28058
28059
|
});
|
|
28059
28060
|
};
|
|
28061
|
+
var commandName2 = (word) => (word.split(/[\\/]/).at(-1) ?? "").toLowerCase();
|
|
28062
|
+
var fedRuns = (words, fed) => {
|
|
28063
|
+
const run = words.slice(Math.max(0, words.findIndex((word) => word === "xargs" || !PREFIXES2.has(word))));
|
|
28064
|
+
const name = commandName2(run[0] ?? "");
|
|
28065
|
+
if (name === "xargs")
|
|
28066
|
+
return xargsCommands(run, fed);
|
|
28067
|
+
if (name !== "parallel")
|
|
28068
|
+
return [run];
|
|
28069
|
+
return parallelCommands(fed === undefined || run.includes(":::") ? run : [...run, ":::", ...fed.split(`
|
|
28070
|
+
`).filter(Boolean)]);
|
|
28071
|
+
};
|
|
28072
|
+
var windowsScript = (input, stdin) => {
|
|
28073
|
+
const words = input.slice(Math.max(0, input.findIndex((word) => !PREFIXES2.has(word))));
|
|
28074
|
+
const name = commandName2(words[0] ?? "").replace(/\.exe$/, "");
|
|
28075
|
+
if (name === "cmd")
|
|
28076
|
+
return cmdScript(words);
|
|
28077
|
+
return name === "pwsh" || name === "powershell" ? powershellScript(words, stdin) : null;
|
|
28078
|
+
};
|
|
28079
|
+
var WINDOWS_LINK_TYPE = /^(?:symboliclink|junction|hardlink)$/i;
|
|
28080
|
+
var linkReach = (verb, args, at, atAll) => {
|
|
28081
|
+
const all = (files) => files.flatMap((file) => atAll(file));
|
|
28082
|
+
const names = operands(args);
|
|
28083
|
+
if (verb === "mount" || verb === "bindfs")
|
|
28084
|
+
return all(names);
|
|
28085
|
+
if (verb === "ln" || verb === "cp" && args.some((arg) => /^-[a-zA-Z]*[ls]|^--(?:link|symbolic-link)$/.test(arg)))
|
|
28086
|
+
return [...linkSources(args, at), ...all(names.length < 2 ? names : names.slice(0, -1))];
|
|
28087
|
+
if (verb === "install") {
|
|
28088
|
+
const flag = args.findIndex((arg) => arg.startsWith("-l"));
|
|
28089
|
+
if (flag < 0)
|
|
28090
|
+
return [];
|
|
28091
|
+
const rest = operands(args.filter((_, index) => index !== flag && (args[flag] !== "-l" || index !== flag + 1)));
|
|
28092
|
+
return all(rest.slice(0, -1));
|
|
28093
|
+
}
|
|
28094
|
+
if (verb === "rsync") {
|
|
28095
|
+
const dest = names.at(-1);
|
|
28096
|
+
return args.flatMap((arg, index) => {
|
|
28097
|
+
const match = /^--link-dest(?:=(.*))?$/s.exec(arg);
|
|
28098
|
+
const dir = match ? match[1] ?? args[index + 1] : undefined;
|
|
28099
|
+
if (!dir)
|
|
28100
|
+
return [];
|
|
28101
|
+
return [...atAll(dir), ...dest && !path42.isAbsolute(dir) ? atAll(path42.join(dest, dir)) : []];
|
|
28102
|
+
});
|
|
28103
|
+
}
|
|
28104
|
+
if (verb === "mklink")
|
|
28105
|
+
return all(args.filter((arg) => !/^\/[dhj]$/i.test(arg)));
|
|
28106
|
+
if ((verb === "new-item" || verb === "ni") && args.some((arg) => WINDOWS_LINK_TYPE.test(arg.replace(/^-[\w-]+:/, ""))))
|
|
28107
|
+
return all(args.flatMap((arg) => {
|
|
28108
|
+
const value = arg.startsWith("-") ? /^-[\w-]+:(.+)$/s.exec(arg)?.[1] : arg;
|
|
28109
|
+
return value && !WINDOWS_LINK_TYPE.test(value) ? [value] : [];
|
|
28110
|
+
}));
|
|
28111
|
+
return [];
|
|
28112
|
+
};
|
|
28060
28113
|
var shellWrites = (command, depth = 0) => {
|
|
28061
28114
|
const targets = [];
|
|
28062
28115
|
let unknown = false;
|
|
@@ -28164,6 +28217,7 @@ var recording = (make) => {
|
|
|
28164
28217
|
};
|
|
28165
28218
|
var OPAQUE_TARGET = ".workit-runs-";
|
|
28166
28219
|
var UNRESOLVED_TARGET = ".workit-unresolved-target";
|
|
28220
|
+
var LINK_SOURCE = ".workit-link-source";
|
|
28167
28221
|
var OVERRIDE = "WORKIT_LIVE_SESSION=override";
|
|
28168
28222
|
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("--"));
|
|
28169
28223
|
var gitMutationDirs = (cwd, command, dialect) => {
|
|
@@ -28565,6 +28619,10 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
28565
28619
|
if (inner !== null && dir !== undefined)
|
|
28566
28620
|
for (const runIn of workitRunDir(dir, words, atAll))
|
|
28567
28621
|
targets.push(...segmentTargets(runIn, inner, "posix", depth + 1, strict, runIn === dir ? vars : unPwd()));
|
|
28622
|
+
const windows = strict && depth < 4 ? windowsScript(words, segment.stdin?.join(`
|
|
28623
|
+
`)) : null;
|
|
28624
|
+
if (windows !== null && dir !== undefined)
|
|
28625
|
+
targets.push(...segmentTargets(dir, windows, "powershell", depth + 1, strict, vars));
|
|
28568
28626
|
const bare = strict === "registry" && depth < 4 ? unwrapped(words) : null;
|
|
28569
28627
|
if (bare?.length && dir !== undefined)
|
|
28570
28628
|
targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord2).join(" "), "posix", depth + 1, strict, vars));
|
|
@@ -28640,9 +28698,11 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
28640
28698
|
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"))))
|
|
28641
28699
|
for (const file of operands(args))
|
|
28642
28700
|
targets.push(...atAll(file));
|
|
28643
|
-
|
|
28644
|
-
|
|
28645
|
-
|
|
28701
|
+
const feed = fed === undefined && !piped.length ? undefined : [fed, ...piped].join(`
|
|
28702
|
+
`);
|
|
28703
|
+
for (const [linker = "", ...rest] of fedRuns(words, feed))
|
|
28704
|
+
for (const source of linkReach(commandName2(linker), rest, at, atAll))
|
|
28705
|
+
targets.push(path42.join(source, LINK_SOURCE));
|
|
28646
28706
|
}
|
|
28647
28707
|
if (strict && dir !== undefined) {
|
|
28648
28708
|
const runIn = dir;
|
|
@@ -28838,19 +28898,42 @@ var hardLinked = (file, state, configs, inodes) => {
|
|
|
28838
28898
|
return;
|
|
28839
28899
|
}
|
|
28840
28900
|
};
|
|
28901
|
+
var inRepoLedger = (file) => [...file.matchAll(/[\\/]workit[\\/]ledger(?=[\\/]|$)/g)].some(({ index }) => {
|
|
28902
|
+
const gitDir = file.slice(0, index);
|
|
28903
|
+
return /(?:^|[\\/])\.git$/.test(gitDir) || existsSync16(path42.join(gitDir, "HEAD")) && existsSync16(path42.join(gitDir, "objects"));
|
|
28904
|
+
});
|
|
28905
|
+
var holdsGuarded = (cwd, source, state, configs) => {
|
|
28906
|
+
const real = canonical5(source);
|
|
28907
|
+
const below = (parent, child) => {
|
|
28908
|
+
const rel = path42.relative(parent, child);
|
|
28909
|
+
return rel === "" || !rel.startsWith("..") && !path42.isAbsolute(rel);
|
|
28910
|
+
};
|
|
28911
|
+
const holds = (file) => below(real, canonical5(file));
|
|
28912
|
+
const inState = path42.relative(canonical5(state), real).split(path42.sep);
|
|
28913
|
+
const ledgers = ["ledger", "workit/ledger", ".git/workit/ledger"].map((rel) => path42.join(real, rel)).filter((dir) => existsSync16(dir) && inRepoLedger(dir));
|
|
28914
|
+
const own = ledgerPath(cwd);
|
|
28915
|
+
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(path42.dirname(own.value));
|
|
28916
|
+
};
|
|
28841
28917
|
var registryTarget = (cwd, targets) => {
|
|
28842
28918
|
const state = resolveStateDir();
|
|
28843
28919
|
const configs = configDirs();
|
|
28844
28920
|
const inodes = {};
|
|
28845
28921
|
for (const target of targets) {
|
|
28846
28922
|
const file = homeExpanded(target);
|
|
28923
|
+
if (path42.basename(file) === LINK_SOURCE) {
|
|
28924
|
+
const source = path42.dirname(path42.resolve(cwd, file));
|
|
28925
|
+
const reached = registryTarget(cwd, [source])?.registry ?? (holdsGuarded(cwd, source, state, configs) ? "holds" : null);
|
|
28926
|
+
if (reached)
|
|
28927
|
+
return { file: target, registry: reached };
|
|
28928
|
+
continue;
|
|
28929
|
+
}
|
|
28847
28930
|
if (realPath(path42.resolve(cwd, file)) === null)
|
|
28848
28931
|
return { file: target, registry: "link" };
|
|
28849
28932
|
const glob = globbed(cwd, file, state, configs)[0];
|
|
28850
28933
|
const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
|
|
28851
28934
|
if (viaGlob)
|
|
28852
28935
|
return { file: target, registry: viaGlob.registry };
|
|
28853
|
-
const registry = hardLinked(path42.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical5) ?? (
|
|
28936
|
+
const registry = hardLinked(path42.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical5) ?? (inRepoLedger(canonical5(path42.resolve(cwd, file))) ? "ledger" : null) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical5)) ? "grants" : null);
|
|
28854
28937
|
if (registry)
|
|
28855
28938
|
return { file: target, registry };
|
|
28856
28939
|
}
|
|
@@ -28877,6 +28960,7 @@ var underConfig = (dir, cwd, target, platform = process.platform, real = (file)
|
|
|
28877
28960
|
const parts = partsUnder(dir, cwd, target, platform, real);
|
|
28878
28961
|
return parts?.length === 1 && ["", ...CONFIG_FILES, DIR_TARGET, UNRESOLVED_TARGET].includes(parts[0]);
|
|
28879
28962
|
};
|
|
28963
|
+
var windowsSlashed = (command, platform = process.platform) => platform === "win32" && command.includes("\\") ? command.replace(/[^\s'"|;&<>()]*\\[^\s'"|;&<>()]*/g, (word) => word.replaceAll("\\", "/")) : null;
|
|
28880
28964
|
var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
28881
28965
|
if (platform !== "win32" || !command.includes("\\"))
|
|
28882
28966
|
return null;
|
|
@@ -28885,28 +28969,36 @@ var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
|
28885
28969
|
const state = flat(resolveStateDir());
|
|
28886
28970
|
const configs = configDirs().map(flat);
|
|
28887
28971
|
const folders = `${state}/folders/`;
|
|
28888
|
-
const ledger = (at) => at.includes(`${state}/verdicts`) ||
|
|
28889
|
-
const
|
|
28890
|
-
if (!
|
|
28972
|
+
const ledger = (at, named = false) => at.includes(`${state}/verdicts`) || (named ? inRepoLedger(at) : /\/workit\/ledger(?:[/\s'"]|$)/.test(at)) || at.split(folders).slice(1).some((rest) => /^[^/\s]+\/ledger(?:[/\s'"]|$)/.test(rest));
|
|
28973
|
+
const present = ["issued", "approvals", "ledger", "grants"].filter((kind) => kind === "ledger" ? ledger(text) : kind === "grants" ? configs.some((dir) => text.includes(dir)) : text.includes(`${state}/${kind}`));
|
|
28974
|
+
if (!present.length)
|
|
28891
28975
|
return null;
|
|
28892
|
-
const spans = command
|
|
28976
|
+
const spans = windowsSlashed(command, platform) ?? command;
|
|
28893
28977
|
const writes = shellWrites(spans);
|
|
28978
|
+
if (!writes.writes)
|
|
28979
|
+
return null;
|
|
28894
28980
|
const moved = [
|
|
28895
28981
|
"",
|
|
28896
28982
|
...[...spans.matchAll(/(?:^|[;&|(]\s*)(?:cd|pushd|chdir)\s+([^\s;&|)]+)/g)].map((match) => `${match[1]}/`)
|
|
28897
28983
|
];
|
|
28898
|
-
const named = (target) => moved.some((dir) => {
|
|
28984
|
+
const named = (registry, target) => moved.some((dir) => {
|
|
28899
28985
|
const at = flat(/^(?:[a-z]:)?\//i.test(target) ? target : dir + target).replace(/\/\.?\//g, "/");
|
|
28900
|
-
return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, ...CONFIG_FILES.map((name) => `${cfg}/${name}`)].includes(at)) : registry === "ledger" ? ledger(at) : at.includes(`${state}/${registry}`);
|
|
28986
|
+
return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, ...CONFIG_FILES.map((name) => `${cfg}/${name}`)].includes(at)) : registry === "ledger" ? ledger(at, true) : at.includes(`${state}/${registry}`);
|
|
28901
28987
|
});
|
|
28902
|
-
return
|
|
28988
|
+
return present.find((registry) => writes.targets === null || writes.targets.some((target) => named(registry, target))) ?? null;
|
|
28903
28989
|
};
|
|
28990
|
+
var LINK_UNBLOCK = "Never link or bind-mount Workit's state, config or ledgers: a write through the link would land in them. Read the file in place.";
|
|
28904
28991
|
var REGISTRY_DENY = {
|
|
28905
28992
|
link: {
|
|
28906
28993
|
label: "registry guard",
|
|
28907
28994
|
what: "a symlink chain Workit could not resolve (over 40 links), which may reach a guarded path",
|
|
28908
28995
|
unblock: "Write to the file's real path."
|
|
28909
28996
|
},
|
|
28997
|
+
holds: {
|
|
28998
|
+
label: "registry guard",
|
|
28999
|
+
what: "Workit's state, its config or a repository ledger",
|
|
29000
|
+
unblock: LINK_UNBLOCK
|
|
29001
|
+
},
|
|
28910
29002
|
issued: {
|
|
28911
29003
|
label: "issued-registry guard",
|
|
28912
29004
|
what: "Workit's issued-session state",
|
|
@@ -28930,6 +29022,12 @@ var REGISTRY_DENY = {
|
|
|
28930
29022
|
};
|
|
28931
29023
|
var registryDeny = ({ file, registry }) => {
|
|
28932
29024
|
const { label, what, unblock } = REGISTRY_DENY[registry];
|
|
29025
|
+
if (path42.basename(file) === LINK_SOURCE)
|
|
29026
|
+
return {
|
|
29027
|
+
kind: "deny",
|
|
29028
|
+
reason: `workit ${label}: this command links or mounts ${path42.dirname(file)}, which is or holds ${what}. ${LINK_UNBLOCK}`,
|
|
29029
|
+
unblock: LINK_UNBLOCK
|
|
29030
|
+
};
|
|
28933
29031
|
if (path42.basename(file) === UNRESOLVED_TARGET)
|
|
28934
29032
|
return {
|
|
28935
29033
|
kind: "deny",
|
|
@@ -28961,7 +29059,8 @@ function writeGate(cwd, paths, owner, deps) {
|
|
|
28961
29059
|
function shellGate(cwd, command, owner, dialect = "posix", deps) {
|
|
28962
29060
|
try {
|
|
28963
29061
|
const windows = unquotedWindowsRegistry(command);
|
|
28964
|
-
const
|
|
29062
|
+
const slashed = dialect === "posix" ? windowsSlashed(command) : null;
|
|
29063
|
+
const forged = registryTarget(cwd, shellMutationTargets(cwd, command, dialect, "registry")) ?? (slashed === null ? null : registryTarget(cwd, shellMutationTargets(cwd, slashed, dialect, "registry"))) ?? (windows ? { file: `the ${windows} registry`, registry: windows } : null);
|
|
28965
29064
|
if (forged)
|
|
28966
29065
|
return registryDeny(forged);
|
|
28967
29066
|
} catch {
|
|
@@ -29100,6 +29199,26 @@ function currentJudgment(cwd) {
|
|
|
29100
29199
|
}
|
|
29101
29200
|
}
|
|
29102
29201
|
|
|
29202
|
+
// packages/workit-core/src/core/verdict-set.ts
|
|
29203
|
+
import path44 from "node:path";
|
|
29204
|
+
var SET_TTL_MS = 7 * 86400000;
|
|
29205
|
+
var SET_VOID = "verdict.set.voided";
|
|
29206
|
+
var setStorePath = () => path44.join(resolveStateDir(), "verdicts", "sets", "ledger.jsonl");
|
|
29207
|
+
function gateStands(cwd, gate, rows, now = Date.now()) {
|
|
29208
|
+
const id = typeof gate.verdictId === "string" ? gate.verdictId : null;
|
|
29209
|
+
if (id !== null && verdictVoids(rows).has(id))
|
|
29210
|
+
return false;
|
|
29211
|
+
if (gate.via !== "set")
|
|
29212
|
+
return true;
|
|
29213
|
+
const until = typeof gate.expires === "string" ? Date.parse(gate.expires) : Date.parse(gate.at) + SET_TTL_MS;
|
|
29214
|
+
if (!(until > now))
|
|
29215
|
+
return false;
|
|
29216
|
+
if (id === null)
|
|
29217
|
+
return true;
|
|
29218
|
+
const read = readLedgerAt(cwd, setStorePath(), { integrity: true });
|
|
29219
|
+
return read.ok && !read.value.rows.some((row) => row.type === SET_VOID && row.target === id && row.integrity === "verified");
|
|
29220
|
+
}
|
|
29221
|
+
|
|
29103
29222
|
// packages/workit-core/src/hooks/stop.ts
|
|
29104
29223
|
var NONE4 = { kind: "none" };
|
|
29105
29224
|
var QUESTION = /[??؟](?=[\s*_`"')\]>]*(?:\s|$))|¿/;
|
|
@@ -29213,7 +29332,7 @@ var unverified = (cwd, branch, all, descriptor, verification, head) => {
|
|
|
29213
29332
|
const check = checkVerdicts(cwd, branch, all);
|
|
29214
29333
|
if (check.accepted.accepted || check.accepted.reasons.includes("failing_verdict"))
|
|
29215
29334
|
return null;
|
|
29216
|
-
if (all.some((row) => row.type === "pr.gate" && row.branch === branch && row.head === check.head))
|
|
29335
|
+
if (all.some((row) => row.type === "pr.gate" && row.branch === branch && row.head === check.head && gateStands(cwd, row, all)))
|
|
29217
29336
|
return null;
|
|
29218
29337
|
const judgment = currentJudgment(cwd);
|
|
29219
29338
|
const high = judgment?.riskTier === "high";
|
|
@@ -29542,7 +29661,7 @@ var WRITE_TOOLS = new Set([
|
|
|
29542
29661
|
]);
|
|
29543
29662
|
// packages/workit-core/src/hooks/standing.ts
|
|
29544
29663
|
import fs30 from "node:fs";
|
|
29545
|
-
import
|
|
29664
|
+
import path45 from "node:path";
|
|
29546
29665
|
|
|
29547
29666
|
// packages/workit-core/src/approvals/store.ts
|
|
29548
29667
|
var REQUEST_TTL_MS = 30 * 60000;
|
|
@@ -30057,7 +30176,7 @@ var workitRole = (descriptor, agentType) => {
|
|
|
30057
30176
|
|
|
30058
30177
|
// packages/workit-core/src/hooks/standing.ts
|
|
30059
30178
|
var readPlans = (store) => {
|
|
30060
|
-
const dir =
|
|
30179
|
+
const dir = path45.join(store, "fanouts");
|
|
30061
30180
|
let names;
|
|
30062
30181
|
try {
|
|
30063
30182
|
names = fs30.readdirSync(dir).filter((name) => name.endsWith(".json"));
|
|
@@ -30067,7 +30186,7 @@ var readPlans = (store) => {
|
|
|
30067
30186
|
const plans = [];
|
|
30068
30187
|
for (const name of names) {
|
|
30069
30188
|
try {
|
|
30070
|
-
const raw = JSON.parse(fs30.readFileSync(
|
|
30189
|
+
const raw = JSON.parse(fs30.readFileSync(path45.join(dir, name), "utf8"));
|
|
30071
30190
|
if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
|
|
30072
30191
|
continue;
|
|
30073
30192
|
const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
|
|
@@ -30386,8 +30505,8 @@ var UNLISTED = new Set(["description", "prompt"]);
|
|
|
30386
30505
|
|
|
30387
30506
|
// packages/workit-core/src/hooks/server-gate.ts
|
|
30388
30507
|
import fs31 from "node:fs";
|
|
30389
|
-
import
|
|
30390
|
-
var procNoticeFile = (env, session) =>
|
|
30508
|
+
import path46 from "node:path";
|
|
30509
|
+
var procNoticeFile = (env, session) => path46.join(stateDir(env), "procs", "notices", `${session.replace(/[^A-Za-z0-9_.@+-]/gu, "-").slice(0, 120) || "none"}.json`);
|
|
30391
30510
|
var mb = (bytes) => `${Math.round(Number(bytes) / 1048576)} MB`;
|
|
30392
30511
|
function takeProcNotice(session, env = process.env) {
|
|
30393
30512
|
if (!session)
|
|
@@ -30425,21 +30544,21 @@ function takeProcNotice(session, env = process.env) {
|
|
|
30425
30544
|
// packages/workit-core/src/hooks/teardown.ts
|
|
30426
30545
|
import { spawn } from "node:child_process";
|
|
30427
30546
|
import fs32 from "node:fs";
|
|
30428
|
-
import
|
|
30547
|
+
import path48 from "node:path";
|
|
30429
30548
|
|
|
30430
30549
|
// packages/workit-core/src/core/cli-locate.ts
|
|
30431
30550
|
import { closeSync as closeSync3, existsSync as existsSync17, openSync as openSync3, readSync } from "node:fs";
|
|
30432
|
-
import
|
|
30551
|
+
import path47 from "node:path";
|
|
30433
30552
|
var LAUNCHER_MARKER = "workit-owned-launcher";
|
|
30434
30553
|
var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
|
|
30435
30554
|
var installRoot = (env, platform = process.platform) => {
|
|
30436
30555
|
if (env.WORKIT_INSTALL_ROOT)
|
|
30437
30556
|
return env.WORKIT_INSTALL_ROOT;
|
|
30438
30557
|
const data = dataDir(env, platform);
|
|
30439
|
-
return platform === "win32" ?
|
|
30558
|
+
return platform === "win32" ? path47.join(data, "install") : data;
|
|
30440
30559
|
};
|
|
30441
|
-
var ownedLauncherPath = (env, platform = process.platform) =>
|
|
30442
|
-
var ownedCurrentEntry = (env, platform = process.platform) =>
|
|
30560
|
+
var ownedLauncherPath = (env, platform = process.platform) => path47.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
|
|
30561
|
+
var ownedCurrentEntry = (env, platform = process.platform) => path47.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
|
|
30443
30562
|
var head = (file) => {
|
|
30444
30563
|
let fd;
|
|
30445
30564
|
try {
|
|
@@ -30466,7 +30585,7 @@ var locateWorkitCli = (options = {}) => {
|
|
|
30466
30585
|
source: "owned-launcher",
|
|
30467
30586
|
command: launcher,
|
|
30468
30587
|
args: [],
|
|
30469
|
-
binDir:
|
|
30588
|
+
binDir: path47.dirname(launcher)
|
|
30470
30589
|
};
|
|
30471
30590
|
const current = ownedCurrentEntry(env, platform);
|
|
30472
30591
|
if (exists(current))
|
|
@@ -30495,7 +30614,7 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
|
|
|
30495
30614
|
if (located.binDir) {
|
|
30496
30615
|
const key = pathKey(env);
|
|
30497
30616
|
const delimiter = platform === "win32" ? ";" : ":";
|
|
30498
|
-
const same = (dir) => platform === "win32" ?
|
|
30617
|
+
const same = (dir) => platform === "win32" ? path47.win32.normalize(dir).toLowerCase() === path47.win32.normalize(located.binDir).toLowerCase() : path47.posix.normalize(dir) === path47.posix.normalize(located.binDir);
|
|
30499
30618
|
const rest = (env[key] ?? "").split(delimiter).filter((dir) => dir && !same(dir));
|
|
30500
30619
|
patch[key] = [located.binDir, ...rest].join(delimiter);
|
|
30501
30620
|
}
|
|
@@ -30519,9 +30638,9 @@ var ENDS = {
|
|
|
30519
30638
|
};
|
|
30520
30639
|
var SAFE_SESSION = /^[\w.@+][\w.:@/+-]{0,127}$/u;
|
|
30521
30640
|
var HOST_SESSION_VARS2 = ["OPENCODE_SESSION_ID", "PI_SESSION_ID", "CODEX_THREAD_ID"];
|
|
30522
|
-
var teardownDir = (env) =>
|
|
30523
|
-
var teardownLog = (env) =>
|
|
30524
|
-
var reapStamp = (env) =>
|
|
30641
|
+
var teardownDir = (env) => path48.join(stateDir(env), "procs");
|
|
30642
|
+
var teardownLog = (env) => path48.join(teardownDir(env), "teardown.log");
|
|
30643
|
+
var reapStamp = (env) => path48.join(teardownDir(env), "reap-at-start.stamp");
|
|
30525
30644
|
function spawnDetached(request) {
|
|
30526
30645
|
try {
|
|
30527
30646
|
const shell = process.platform === "win32" && !/\.exe$/iu.test(request.command);
|
|
@@ -30548,7 +30667,7 @@ var teardownDeps = {
|
|
|
30548
30667
|
var openLog = (env, args) => {
|
|
30549
30668
|
try {
|
|
30550
30669
|
const file = teardownLog(env);
|
|
30551
|
-
fs32.mkdirSync(
|
|
30670
|
+
fs32.mkdirSync(path48.dirname(file), { recursive: true });
|
|
30552
30671
|
let size = 0;
|
|
30553
30672
|
try {
|
|
30554
30673
|
size = fs32.statSync(file).size;
|
|
@@ -30633,7 +30752,7 @@ function reapAtStart(_cwd, env = process.env) {
|
|
|
30633
30752
|
try {
|
|
30634
30753
|
if (fresh(stamp, now))
|
|
30635
30754
|
return false;
|
|
30636
|
-
fs32.mkdirSync(
|
|
30755
|
+
fs32.mkdirSync(path48.dirname(stamp), { recursive: true });
|
|
30637
30756
|
if (!claim2(lock, now))
|
|
30638
30757
|
return false;
|
|
30639
30758
|
} catch {
|
|
@@ -31339,11 +31458,11 @@ var PROCESS_START = performance.timeOrigin;
|
|
|
31339
31458
|
// packages/workit-core/src/hooks/run.ts
|
|
31340
31459
|
if (false) {}
|
|
31341
31460
|
// packages/workit-opencode/src/shared/init-apply.ts
|
|
31342
|
-
import
|
|
31461
|
+
import path53 from "node:path";
|
|
31343
31462
|
|
|
31344
31463
|
// packages/workit-core/src/core/gitignore.ts
|
|
31345
31464
|
import { existsSync as existsSync18, readFileSync as readFileSync13, writeFileSync as writeFileSync6 } from "node:fs";
|
|
31346
|
-
import
|
|
31465
|
+
import path49 from "node:path";
|
|
31347
31466
|
var GITIGNORE_ENTRIES = [
|
|
31348
31467
|
"# workit: SDD working state (never commit)",
|
|
31349
31468
|
"docs/*/sdd/",
|
|
@@ -31363,7 +31482,7 @@ var GITIGNORE_ENTRIES = [
|
|
|
31363
31482
|
var ensureProjectGitignore = (workspaceRoot, confirmed) => {
|
|
31364
31483
|
if (!confirmed)
|
|
31365
31484
|
return { ok: false, error: "confirmed: true required" };
|
|
31366
|
-
const file =
|
|
31485
|
+
const file = path49.join(workspaceRoot, ".gitignore");
|
|
31367
31486
|
const existing = existsSync18(file) ? readFileSync13(file, "utf8") : "";
|
|
31368
31487
|
const existingLines = new Set(existing.split(`
|
|
31369
31488
|
`).map((l) => l.trim()).filter(Boolean));
|
|
@@ -31391,25 +31510,25 @@ var ensureProjectGitignore = (workspaceRoot, confirmed) => {
|
|
|
31391
31510
|
|
|
31392
31511
|
// packages/workit-core/src/core/hygiene.ts
|
|
31393
31512
|
import { existsSync as existsSync19, readFileSync as readFileSync14, readdirSync as readdirSync6, writeFileSync as writeFileSync7 } from "node:fs";
|
|
31394
|
-
import
|
|
31513
|
+
import path50 from "node:path";
|
|
31395
31514
|
var repoRoot3 = assetRoot();
|
|
31396
|
-
var templatesDir = () =>
|
|
31515
|
+
var templatesDir = () => path50.join(repoRoot3, "templates", "hygiene");
|
|
31397
31516
|
var packageJson2 = (root) => {
|
|
31398
|
-
if (!existsSync19(
|
|
31517
|
+
if (!existsSync19(path50.join(root, "package.json")))
|
|
31399
31518
|
return null;
|
|
31400
31519
|
try {
|
|
31401
|
-
return JSON.parse(readFileSync14(
|
|
31520
|
+
return JSON.parse(readFileSync14(path50.join(root, "package.json"), "utf8"));
|
|
31402
31521
|
} catch {
|
|
31403
31522
|
return null;
|
|
31404
31523
|
}
|
|
31405
31524
|
};
|
|
31406
31525
|
var isOpenSource = (root) => {
|
|
31407
|
-
if (existsSync19(
|
|
31526
|
+
if (existsSync19(path50.join(root, "LICENSE")))
|
|
31408
31527
|
return true;
|
|
31409
31528
|
const pkg = packageJson2(root);
|
|
31410
31529
|
if (pkg && !pkg.private)
|
|
31411
31530
|
return true;
|
|
31412
|
-
return
|
|
31531
|
+
return path50.basename(root) === "workit";
|
|
31413
31532
|
};
|
|
31414
31533
|
var licenseHolder = (root) => {
|
|
31415
31534
|
const pkg = packageJson2(root);
|
|
@@ -31432,13 +31551,13 @@ var planHygieneFiles = (root, opts = {}) => {
|
|
|
31432
31551
|
files.push("LICENSE", "CONTRIBUTING.md");
|
|
31433
31552
|
const planned = [];
|
|
31434
31553
|
for (const file of files) {
|
|
31435
|
-
if (existsSync19(
|
|
31554
|
+
if (existsSync19(path50.join(root, file)))
|
|
31436
31555
|
continue;
|
|
31437
|
-
const tpl =
|
|
31556
|
+
const tpl = path50.join(templatesDir(), file);
|
|
31438
31557
|
if (!existsSync19(tpl))
|
|
31439
31558
|
continue;
|
|
31440
|
-
const content = readFileSync14(tpl, "utf8").replace(/<PROJECT>/g,
|
|
31441
|
-
planned.push({ path:
|
|
31559
|
+
const content = readFileSync14(tpl, "utf8").replace(/<PROJECT>/g, path50.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
|
|
31560
|
+
planned.push({ path: path50.join(root, file), content });
|
|
31442
31561
|
}
|
|
31443
31562
|
return planned;
|
|
31444
31563
|
};
|
|
@@ -31448,19 +31567,19 @@ var ensureHygieneFiles = (root, opts) => {
|
|
|
31448
31567
|
const created = [];
|
|
31449
31568
|
for (const planned of planHygieneFiles(root, opts)) {
|
|
31450
31569
|
writeFileSync7(planned.path, planned.content, "utf8");
|
|
31451
|
-
created.push(
|
|
31570
|
+
created.push(path50.basename(planned.path));
|
|
31452
31571
|
}
|
|
31453
31572
|
return { ok: true, created };
|
|
31454
31573
|
};
|
|
31455
31574
|
|
|
31456
31575
|
// packages/workit-core/src/core/init.ts
|
|
31457
31576
|
import fs33 from "node:fs";
|
|
31458
|
-
import
|
|
31577
|
+
import path52 from "node:path";
|
|
31459
31578
|
import { spawnSync as spawnSync25 } from "node:child_process";
|
|
31460
31579
|
|
|
31461
31580
|
// packages/workit-core/src/core/workspace-branch-policy.ts
|
|
31462
31581
|
import { mkdirSync as mkdirSync6, readFileSync as readFileSync15, renameSync as renameSync5, rmSync as rmSync3, writeFileSync as writeFileSync8 } from "node:fs";
|
|
31463
|
-
import
|
|
31582
|
+
import path51 from "node:path";
|
|
31464
31583
|
import { isDeepStrictEqual } from "node:util";
|
|
31465
31584
|
var readFileSafe = (p) => {
|
|
31466
31585
|
try {
|
|
@@ -31471,7 +31590,7 @@ var readFileSafe = (p) => {
|
|
|
31471
31590
|
};
|
|
31472
31591
|
function applyWorkspaceBranchPolicy(opts) {
|
|
31473
31592
|
const { workspace_root, env = process.env } = opts;
|
|
31474
|
-
const dir =
|
|
31593
|
+
const dir = path51.join(env.WORKIT_CONFIG ?? configDir2());
|
|
31475
31594
|
const {
|
|
31476
31595
|
status,
|
|
31477
31596
|
path: wsPath,
|
|
@@ -31483,7 +31602,7 @@ function applyWorkspaceBranchPolicy(opts) {
|
|
|
31483
31602
|
if (status === "malformed" || status === "invalid")
|
|
31484
31603
|
return { ok: false, error: workspacesError ?? `invalid workspaces.json: ${wsPath}` };
|
|
31485
31604
|
const detection = detectBranchPolicy(workspace_root);
|
|
31486
|
-
const name = String(env.WORKIT_BP_NAME ??
|
|
31605
|
+
const name = String(env.WORKIT_BP_NAME ?? path51.basename(workspace_root));
|
|
31487
31606
|
const integration = env.WORKIT_BP_INTEGRATION ?? detection.integration;
|
|
31488
31607
|
const policy = {
|
|
31489
31608
|
preset: detection.preset,
|
|
@@ -31532,7 +31651,7 @@ function applyWorkspaceBranchPolicy(opts) {
|
|
|
31532
31651
|
ok: false,
|
|
31533
31652
|
error: `workspaces.json changed while applying the branch policy: ${wsPath}`
|
|
31534
31653
|
};
|
|
31535
|
-
mkdirSync6(
|
|
31654
|
+
mkdirSync6(path51.dirname(wsPath), { recursive: true });
|
|
31536
31655
|
const tmp = `${wsPath}.${process.pid}.tmp`;
|
|
31537
31656
|
try {
|
|
31538
31657
|
writeFileSync8(tmp, JSON.stringify({ ...document, workspaces: next }, null, 2) + `
|
|
@@ -31632,7 +31751,7 @@ function initApplyData(action, env = process.env) {
|
|
|
31632
31751
|
fs33.mkdirSync(dir, { recursive: true });
|
|
31633
31752
|
switch (action) {
|
|
31634
31753
|
case "youtrack_json": {
|
|
31635
|
-
const out =
|
|
31754
|
+
const out = path52.join(dir, "youtrack.json");
|
|
31636
31755
|
fs33.writeFileSync(out, JSON.stringify(youtrackJsonContent(), null, 2) + `
|
|
31637
31756
|
`, "utf8");
|
|
31638
31757
|
return { action, ok: true, path: out };
|
|
@@ -31646,10 +31765,10 @@ function initApplyData(action, env = process.env) {
|
|
|
31646
31765
|
};
|
|
31647
31766
|
}
|
|
31648
31767
|
case "youtrack_scaffold": {
|
|
31649
|
-
const jsonOut =
|
|
31768
|
+
const jsonOut = path52.join(dir, "youtrack.json");
|
|
31650
31769
|
fs33.writeFileSync(jsonOut, JSON.stringify(youtrackJsonContent(), null, 2) + `
|
|
31651
31770
|
`, "utf8");
|
|
31652
|
-
const configPath =
|
|
31771
|
+
const configPath = path52.resolve(jsonOut);
|
|
31653
31772
|
const cfg = readJson3(configPath) ?? {};
|
|
31654
31773
|
const base = String(cfg.baseUrl ?? "").replace(/\/+$/, "");
|
|
31655
31774
|
const meeting = String(cfg.meetingIssue ?? "");
|
|
@@ -31685,10 +31804,10 @@ function initApplyData(action, env = process.env) {
|
|
|
31685
31804
|
};
|
|
31686
31805
|
}
|
|
31687
31806
|
case "vcs_scaffold": {
|
|
31688
|
-
const jsonOut =
|
|
31807
|
+
const jsonOut = path52.join(dir, "vcs.json");
|
|
31689
31808
|
fs33.writeFileSync(jsonOut, JSON.stringify(vcsJsonContent(), null, 2) + `
|
|
31690
31809
|
`, "utf8");
|
|
31691
|
-
const configPath =
|
|
31810
|
+
const configPath = path52.resolve(jsonOut);
|
|
31692
31811
|
const prev = process.env.WORKIT_VCS_CONFIG;
|
|
31693
31812
|
process.env.WORKIT_VCS_CONFIG = configPath;
|
|
31694
31813
|
try {
|
|
@@ -31807,7 +31926,7 @@ var executeInitApply = (args, directory, runtime) => {
|
|
|
31807
31926
|
protectedNames: args.branch_policy_protected
|
|
31808
31927
|
}, current);
|
|
31809
31928
|
writeConfig(next);
|
|
31810
|
-
return output(ok({ action: "config", path:
|
|
31929
|
+
return output(ok({ action: "config", path: path53.join(configDir2(), "config.json"), ...next }));
|
|
31811
31930
|
}
|
|
31812
31931
|
const env = Object.fromEntries(Object.entries({
|
|
31813
31932
|
WORKIT_YT_BASE_URL: args.base_url,
|
|
@@ -31824,14 +31943,14 @@ var executeInitApply = (args, directory, runtime) => {
|
|
|
31824
31943
|
|
|
31825
31944
|
// packages/workit-opencode/src/shared/session.ts
|
|
31826
31945
|
import { realpathSync as realpathSync12 } from "node:fs";
|
|
31827
|
-
import
|
|
31946
|
+
import path54 from "node:path";
|
|
31828
31947
|
var sameWorkspace = (expected, observed) => {
|
|
31829
31948
|
if (typeof observed !== "string" || !observed)
|
|
31830
31949
|
return false;
|
|
31831
31950
|
try {
|
|
31832
31951
|
return realpathSync12(expected) === realpathSync12(observed);
|
|
31833
31952
|
} catch {
|
|
31834
|
-
return
|
|
31953
|
+
return path54.resolve(expected) === path54.resolve(observed);
|
|
31835
31954
|
}
|
|
31836
31955
|
};
|
|
31837
31956
|
|
|
@@ -31903,7 +32022,7 @@ var workitFamilyOf = (toolName) => {
|
|
|
31903
32022
|
|
|
31904
32023
|
// packages/workit-opencode/src/tools/context.ts
|
|
31905
32024
|
import { realpathSync as realpathSync13 } from "node:fs";
|
|
31906
|
-
import
|
|
32025
|
+
import path55 from "node:path";
|
|
31907
32026
|
var createContextTool = () => ({
|
|
31908
32027
|
description: "Read Git, pull request, YouTrack, issue, changelog, release, or affected-file context.",
|
|
31909
32028
|
execute: async (args, context) => {
|
|
@@ -31913,7 +32032,7 @@ var createContextTool = () => ({
|
|
|
31913
32032
|
let root;
|
|
31914
32033
|
try {
|
|
31915
32034
|
const cwd = parsed.data.cwd;
|
|
31916
|
-
root = realpathSync13(cwd ?
|
|
32035
|
+
root = realpathSync13(cwd ? path55.resolve(context.directory, cwd) : context.directory);
|
|
31917
32036
|
} catch {
|
|
31918
32037
|
return JSON.stringify(failure2("invalid_input", "context target directory cannot be resolved"), null, 2);
|
|
31919
32038
|
}
|
|
@@ -31946,7 +32065,7 @@ var workerCoordinatorFor = (task, worker) => {
|
|
|
31946
32065
|
import { spawnSync as spawnSync29 } from "node:child_process";
|
|
31947
32066
|
import { createHash as createHash21 } from "node:crypto";
|
|
31948
32067
|
import fs35 from "node:fs";
|
|
31949
|
-
import
|
|
32068
|
+
import path58 from "node:path";
|
|
31950
32069
|
|
|
31951
32070
|
// packages/workit-core/src/fanout-landed.ts
|
|
31952
32071
|
import { spawnSync as spawnSync26 } from "node:child_process";
|
|
@@ -32180,7 +32299,7 @@ var NOTICE_TTL_MS = 7 * 86400000;
|
|
|
32180
32299
|
import { spawnSync as spawnSync28 } from "node:child_process";
|
|
32181
32300
|
import { createHash as createHash20, randomBytes as randomBytes4 } from "node:crypto";
|
|
32182
32301
|
import fs34 from "node:fs";
|
|
32183
|
-
import
|
|
32302
|
+
import path57 from "node:path";
|
|
32184
32303
|
|
|
32185
32304
|
// packages/workit-core/src/git/ops.ts
|
|
32186
32305
|
import { spawnSync as spawnSync27 } from "node:child_process";
|
|
@@ -32193,7 +32312,7 @@ import {
|
|
|
32193
32312
|
rmSync as rmSync4,
|
|
32194
32313
|
writeFileSync as writeFileSync9
|
|
32195
32314
|
} from "node:fs";
|
|
32196
|
-
import
|
|
32315
|
+
import path56 from "node:path";
|
|
32197
32316
|
var COMMIT_TIMEOUT_MS = 10 * 60000;
|
|
32198
32317
|
var git5 = (cwd, args, options = {}) => {
|
|
32199
32318
|
const result = spawnSync27("git", args, {
|
|
@@ -32226,18 +32345,18 @@ function operationInProgress(cwd) {
|
|
|
32226
32345
|
if (!run.ok)
|
|
32227
32346
|
return null;
|
|
32228
32347
|
const found = run.stdout.split(`
|
|
32229
|
-
`).map((line) =>
|
|
32348
|
+
`).map((line) => path56.resolve(cwd, line.trim()));
|
|
32230
32349
|
const conflicted = () => git5(cwd, ["ls-files", "-u"]).stdout.trim() !== "";
|
|
32231
32350
|
for (const [index, [, operation]] of markers.entries()) {
|
|
32232
32351
|
const marker = found[index];
|
|
32233
32352
|
if (!marker || !existsSync20(marker))
|
|
32234
32353
|
continue;
|
|
32235
|
-
if (index === 1 && existsSync20(
|
|
32354
|
+
if (index === 1 && existsSync20(path56.join(marker, "applying")))
|
|
32236
32355
|
return { operation: "am", commitAllowed: false, branch: null };
|
|
32237
|
-
if (index === 0 && existsSync20(
|
|
32356
|
+
if (index === 0 && existsSync20(path56.join(marker, "amend")) && !conflicted()) {
|
|
32238
32357
|
let headName = "";
|
|
32239
32358
|
try {
|
|
32240
|
-
headName = readFileSync16(
|
|
32359
|
+
headName = readFileSync16(path56.join(marker, "head-name"), "utf8").trim();
|
|
32241
32360
|
} catch {}
|
|
32242
32361
|
const branch = headName.startsWith("refs/heads/") ? headName.slice("refs/heads/".length) : null;
|
|
32243
32362
|
return { operation, commitAllowed: branch !== null, branch };
|
|
@@ -32285,9 +32404,6 @@ function pushPreflight(cwd, options = {}) {
|
|
|
32285
32404
|
});
|
|
32286
32405
|
}
|
|
32287
32406
|
|
|
32288
|
-
// packages/workit-core/src/core/verdict-set.ts
|
|
32289
|
-
var SET_TTL_MS = 7 * 86400000;
|
|
32290
|
-
|
|
32291
32407
|
// packages/workit-core/src/forge/report.ts
|
|
32292
32408
|
var GITLAB_MERGEABLE = new Set(["mergeable"]);
|
|
32293
32409
|
var GITHUB_MERGEABLE = new Set(["clean", "unstable", "has_hooks"]);
|
|
@@ -32368,7 +32484,7 @@ function rebaseInProgress(dir) {
|
|
|
32368
32484
|
}
|
|
32369
32485
|
var scratchDir = (cwd) => {
|
|
32370
32486
|
const dir = stacksDir(cwd);
|
|
32371
|
-
return dir.ok ?
|
|
32487
|
+
return dir.ok ? path57.join(dir.data, "worktrees") : null;
|
|
32372
32488
|
};
|
|
32373
32489
|
function gitRestack(cwd, input) {
|
|
32374
32490
|
const owner = worktreeOf(cwd, input.branch);
|
|
@@ -32383,7 +32499,7 @@ function gitRestack(cwd, input) {
|
|
|
32383
32499
|
error: "no store root"
|
|
32384
32500
|
};
|
|
32385
32501
|
fs34.mkdirSync(scratch, { recursive: true });
|
|
32386
|
-
dir =
|
|
32502
|
+
dir = path57.join(scratch, `${input.branch.replace(/[^A-Za-z0-9._-]+/gu, "_").slice(0, 40)}-${randomBytes4(4).toString("hex")}`);
|
|
32387
32503
|
const added = gitRun4(cwd, ["worktree", "add", "-q", dir, input.branch], GIT_TIMEOUTS.worktree);
|
|
32388
32504
|
if (!added.ok)
|
|
32389
32505
|
return {
|
|
@@ -32442,7 +32558,7 @@ function stacksDir(cwd) {
|
|
|
32442
32558
|
const root = storeRoot(cwd);
|
|
32443
32559
|
if (!root.ok)
|
|
32444
32560
|
return stackFail(root.code, root.error, root.unblock);
|
|
32445
|
-
return { ok: true, data:
|
|
32561
|
+
return { ok: true, data: path57.join(root.value.root, "stacks") };
|
|
32446
32562
|
}
|
|
32447
32563
|
var HEARTBEAT_STALE_MS = 2 * 60000;
|
|
32448
32564
|
var SETTLED_BY_RESTACK = new Set(["checks_pending", "behind_base_required"]);
|
|
@@ -32589,7 +32705,7 @@ function fanoutsDir(cwd) {
|
|
|
32589
32705
|
const root = storeRoot(cwd);
|
|
32590
32706
|
if (!root.ok)
|
|
32591
32707
|
return fanoutFail(root.code, root.error, root.unblock);
|
|
32592
|
-
return { ok: true, data:
|
|
32708
|
+
return { ok: true, data: path58.join(root.value.root, "fanouts") };
|
|
32593
32709
|
}
|
|
32594
32710
|
function parseStored(raw) {
|
|
32595
32711
|
if (!isRecord9(raw) || typeof raw.name !== "string" || typeof raw.trunk !== "string")
|
|
@@ -32657,7 +32773,7 @@ function readFanout(cwd, name) {
|
|
|
32657
32773
|
const dir = fanoutsDir(cwd);
|
|
32658
32774
|
if (!dir.ok)
|
|
32659
32775
|
return dir;
|
|
32660
|
-
const file =
|
|
32776
|
+
const file = path58.join(dir.data, stackFileName(name));
|
|
32661
32777
|
let parsed = null;
|
|
32662
32778
|
try {
|
|
32663
32779
|
parsed = parseStored(JSON.parse(fs35.readFileSync(file, "utf8")));
|
|
@@ -32682,7 +32798,7 @@ function listFanouts(cwd) {
|
|
|
32682
32798
|
for (const entry of names) {
|
|
32683
32799
|
let parsed = null;
|
|
32684
32800
|
try {
|
|
32685
|
-
parsed = parseStored(JSON.parse(fs35.readFileSync(
|
|
32801
|
+
parsed = parseStored(JSON.parse(fs35.readFileSync(path58.join(dir.data, entry), "utf8")));
|
|
32686
32802
|
} catch {
|
|
32687
32803
|
parsed = null;
|
|
32688
32804
|
}
|
|
@@ -33573,7 +33689,7 @@ var childTaskMissing = (store, input) => {
|
|
|
33573
33689
|
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`;
|
|
33574
33690
|
|
|
33575
33691
|
// packages/workit-opencode/src/v2/shell.ts
|
|
33576
|
-
import
|
|
33692
|
+
import path59 from "node:path";
|
|
33577
33693
|
|
|
33578
33694
|
// packages/workit-core/src/hooks/repeat-failure.ts
|
|
33579
33695
|
import { createHash as createHash22 } from "node:crypto";
|
|
@@ -33636,7 +33752,7 @@ var commandOf = (input) => {
|
|
|
33636
33752
|
};
|
|
33637
33753
|
var hookInput = (root, sessionID, id, shell) => ({
|
|
33638
33754
|
host: "opencode",
|
|
33639
|
-
cwd: shell.workdir ?
|
|
33755
|
+
cwd: shell.workdir ? path59.resolve(root, shell.workdir) : root,
|
|
33640
33756
|
session: { id: sessionID, agentId: null, agentType: null, parentId: null },
|
|
33641
33757
|
permissionMode: null,
|
|
33642
33758
|
transcriptPath: null,
|
|
@@ -34160,37 +34276,37 @@ var createStopControl = (root, port) => {
|
|
|
34160
34276
|
|
|
34161
34277
|
// packages/workit-opencode/src/v2/registry.ts
|
|
34162
34278
|
import { existsSync as existsSync22, readFileSync as readFileSync17 } from "node:fs";
|
|
34163
|
-
import
|
|
34279
|
+
import path61 from "node:path";
|
|
34164
34280
|
|
|
34165
34281
|
// packages/workit-opencode/src/shared/assets.ts
|
|
34166
34282
|
import { existsSync as existsSync21, realpathSync as realpathSync14 } from "node:fs";
|
|
34167
|
-
import
|
|
34283
|
+
import path60 from "node:path";
|
|
34168
34284
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
34169
34285
|
var moduleDir = () => {
|
|
34170
34286
|
try {
|
|
34171
|
-
return realpathSync14(
|
|
34287
|
+
return realpathSync14(path60.dirname(fileURLToPath2(import.meta.url)));
|
|
34172
34288
|
} catch {
|
|
34173
|
-
return
|
|
34289
|
+
return path60.dirname(fileURLToPath2(import.meta.url));
|
|
34174
34290
|
}
|
|
34175
34291
|
};
|
|
34176
34292
|
var packageRoot2 = () => {
|
|
34177
34293
|
const dir = moduleDir();
|
|
34178
34294
|
for (const candidate of [
|
|
34179
|
-
|
|
34180
|
-
|
|
34181
|
-
|
|
34295
|
+
path60.resolve(dir, ".."),
|
|
34296
|
+
path60.resolve(dir, "..", ".."),
|
|
34297
|
+
path60.resolve(dir, "..", "..", "..")
|
|
34182
34298
|
]) {
|
|
34183
|
-
if (existsSync21(
|
|
34299
|
+
if (existsSync21(path60.join(candidate, "package.json")))
|
|
34184
34300
|
return candidate;
|
|
34185
34301
|
}
|
|
34186
|
-
return
|
|
34302
|
+
return path60.resolve(dir, "..");
|
|
34187
34303
|
};
|
|
34188
34304
|
var skillsRoot = () => {
|
|
34189
34305
|
const root = packageRoot2();
|
|
34190
|
-
const canonical =
|
|
34191
|
-
if (existsSync21(
|
|
34306
|
+
const canonical = path60.resolve(root, "..", "workit-core", "skills");
|
|
34307
|
+
if (existsSync21(path60.join(root, "src")) && existsSync21(canonical))
|
|
34192
34308
|
return canonical;
|
|
34193
|
-
return
|
|
34309
|
+
return path60.join(root, "assets", "skills");
|
|
34194
34310
|
};
|
|
34195
34311
|
|
|
34196
34312
|
// packages/workit-opencode/src/v2/registry.ts
|
|
@@ -34217,11 +34333,11 @@ var registerSkills = async (ctx) => {
|
|
|
34217
34333
|
if (!existsSync22(skillsDir))
|
|
34218
34334
|
return new Set;
|
|
34219
34335
|
const listed = await ctx.skill.list().catch(() => ({ data: [] }));
|
|
34220
|
-
const own = (skill) => typeof skill.path === "string" &&
|
|
34336
|
+
const own = (skill) => typeof skill.path === "string" && path61.resolve(skill.path).startsWith(skillsDir + path61.sep);
|
|
34221
34337
|
const userSkills = new Set((listed?.data ?? []).filter((skill) => !own(skill)).map((skill) => skill.id));
|
|
34222
34338
|
const packaged = new Map;
|
|
34223
34339
|
for (const id of WORKIT_METHOD_SKILLS) {
|
|
34224
|
-
const file =
|
|
34340
|
+
const file = path61.join(skillsDir, id, "SKILL.md");
|
|
34225
34341
|
if (!userSkills.has(id) && existsSync22(file))
|
|
34226
34342
|
packaged.set(id, file);
|
|
34227
34343
|
}
|
|
@@ -34269,22 +34385,22 @@ var registerCommands = async (ctx, registeredSkills) => {
|
|
|
34269
34385
|
|
|
34270
34386
|
// packages/workit-opencode/src/stale-sources.ts
|
|
34271
34387
|
import { existsSync as existsSync23, readdirSync as readdirSync8 } from "node:fs";
|
|
34272
|
-
import
|
|
34388
|
+
import path62 from "node:path";
|
|
34273
34389
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
34274
34390
|
var typescriptFiles = (directory) => {
|
|
34275
34391
|
if (!existsSync23(directory))
|
|
34276
34392
|
return [];
|
|
34277
34393
|
return readdirSync8(directory, { withFileTypes: true }).flatMap((entry) => {
|
|
34278
|
-
const file =
|
|
34394
|
+
const file = path62.join(directory, entry.name);
|
|
34279
34395
|
return entry.isDirectory() ? typescriptFiles(file) : entry.isFile() && file.endsWith(".ts") ? [file] : [];
|
|
34280
34396
|
});
|
|
34281
34397
|
};
|
|
34282
34398
|
var pluginSourceFiles = [
|
|
34283
34399
|
...new Set([
|
|
34284
34400
|
fileURLToPath3(import.meta.url),
|
|
34285
|
-
...typescriptFiles(
|
|
34286
|
-
|
|
34287
|
-
...typescriptFiles(
|
|
34401
|
+
...typescriptFiles(path62.join(packageRoot2(), "src")),
|
|
34402
|
+
path62.join(packageRoot2(), "..", "workit-core", "src", "core.ts"),
|
|
34403
|
+
...typescriptFiles(path62.join(packageRoot2(), "..", "workit-core", "src", "core"))
|
|
34288
34404
|
])
|
|
34289
34405
|
].filter((file) => existsSync23(file)).toSorted();
|
|
34290
34406
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/opencode",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.25.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Workit OpenCode plugin — native tools, adaptive policy, and sixteen method skills",
|
|
6
6
|
"keywords": [
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@opencode/plugin": "2.3.2",
|
|
44
|
-
"@workit-dev/core": "^2.
|
|
44
|
+
"@workit-dev/core": "^2.25.1"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=24"
|