@workit-dev/opencode 2.18.1 → 2.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/skills/workit-retro/SKILL.md +1 -1
- package/dist/plugin.js +808 -55
- package/package.json +2 -2
|
@@ -42,7 +42,7 @@ proposes and stops. Nothing changes until the user approves.
|
|
|
42
42
|
agent behaviour, becomes an issue or PR on BrainerVirus/workit, not a host
|
|
43
43
|
memory (one host reads it). Never fork a local copy. Use a minimal synthetic
|
|
44
44
|
repro: no private repo name, path, code, ledger text, PR, thread or transcript.
|
|
45
|
-
Paste the
|
|
45
|
+
Paste the whole `workit feedback "<title>" --body-file -` draft; `--post` once approved.
|
|
46
46
|
6. **Bloat guards.** AGENTS.md stays within 8 KB: each addition names what it
|
|
47
47
|
removes. Create `CODING_STANDARDS.md` or `GLOSSARY.md` only in the same
|
|
48
48
|
edit as its first real entry, never as a scaffold. Edit steering text by
|
package/dist/plugin.js
CHANGED
|
@@ -9496,6 +9496,7 @@ var workspaceConfigSchema = object({
|
|
|
9496
9496
|
trailers: boolean2().optional().describe("Whether commits get the `Workit-Session:` trailer (default true). With false, authorship lives in the ledger only."),
|
|
9497
9497
|
deleteBranch: boolean2().optional().describe("Whether `workit pr merge` deletes the head branch after a merge (default true); `--keep-branch` opts out for one merge."),
|
|
9498
9498
|
cleanup: unknown().optional().describe("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`."),
|
|
9499
|
+
feedback: unknown().optional().describe('`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.'),
|
|
9499
9500
|
liveSessionGuard: boolean2().optional().describe("Whether the live-session guard denies edits in a checkout another live agent session owns (default true)."),
|
|
9500
9501
|
fanout: object({
|
|
9501
9502
|
tierModels: unknown().optional().describe("The model per slice TIER (mundane, standard, hard), as one name or per host.")
|
|
@@ -9538,7 +9539,10 @@ var workspaceConfigSchema = object({
|
|
|
9538
9539
|
});
|
|
9539
9540
|
var workspacesFileSchema = object({
|
|
9540
9541
|
workspaces: array(workspaceConfigSchema).optional().describe("Workspace entries, each mapping a path glob to its forge, policies and grants."),
|
|
9541
|
-
models: object({ roles: modelRoles }).passthrough().optional().describe("The global default model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false).")
|
|
9542
|
+
models: object({ roles: modelRoles }).passthrough().optional().describe("The global default model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false)."),
|
|
9543
|
+
feedback: object({
|
|
9544
|
+
account: nonBlank.optional().describe("The GitHub login `workit feedback --post` uses when no workspace names one; never the workspace's work account by default.")
|
|
9545
|
+
}).passthrough().optional().describe("`workit feedback` defaults for every workspace.")
|
|
9542
9546
|
}).passthrough().superRefine((file, context) => {
|
|
9543
9547
|
const names = new Set;
|
|
9544
9548
|
for (const [index, workspace] of (file.workspaces ?? []).entries()) {
|
|
@@ -9976,6 +9980,12 @@ var resolveRuntimeReleasePackages = (cwd, dir) => {
|
|
|
9976
9980
|
return found?.source ? { workspace: found.source.name, releasePackages: found.source.releasePackages } : null;
|
|
9977
9981
|
};
|
|
9978
9982
|
var workspaceLiveSessionGuard = (cwd, dir) => inheritedSetting(cwd, dir, (entry) => typeof entry.liveSessionGuard === "boolean")?.source?.liveSessionGuard !== false;
|
|
9983
|
+
var feedbackSetting = (cwd, dir) => {
|
|
9984
|
+
const found = inheritedSetting(cwd, dir, (entry) => entry.feedback !== undefined);
|
|
9985
|
+
const value = found?.source?.feedback;
|
|
9986
|
+
return { found, value, off: value === "off" };
|
|
9987
|
+
};
|
|
9988
|
+
var workspaceFeedbackOff = (cwd, dir) => feedbackSetting(cwd, dir).off;
|
|
9979
9989
|
var changelogPathOf = (value) => {
|
|
9980
9990
|
if (typeof value !== "string")
|
|
9981
9991
|
return null;
|
|
@@ -15249,6 +15259,203 @@ function generatedByAttributes(files, paths) {
|
|
|
15249
15259
|
return out;
|
|
15250
15260
|
}
|
|
15251
15261
|
|
|
15262
|
+
// packages/workit-core/src/core/policy/dep-bump.ts
|
|
15263
|
+
var MANIFESTS = new Set(["package.json", "go.mod", "Cargo.toml", "pyproject.toml"]);
|
|
15264
|
+
var basename = (file) => file.slice(file.lastIndexOf("/") + 1);
|
|
15265
|
+
var isManifest = (file) => MANIFESTS.has(basename(file));
|
|
15266
|
+
var refused = (why) => ({ pins: false, bumped: 0, scripts: [], why });
|
|
15267
|
+
var pinned = (bumped, scripts = []) => ({
|
|
15268
|
+
pins: true,
|
|
15269
|
+
bumped,
|
|
15270
|
+
scripts,
|
|
15271
|
+
why: ""
|
|
15272
|
+
});
|
|
15273
|
+
var DEP_FIELDS = new Set([
|
|
15274
|
+
"dependencies",
|
|
15275
|
+
"devDependencies",
|
|
15276
|
+
"peerDependencies",
|
|
15277
|
+
"optionalDependencies"
|
|
15278
|
+
]);
|
|
15279
|
+
var NPM_COMPARATOR = /^(?:[~^]|[<>]=?|=)?v?\d+(?:\.(?:\d+|x|\*)){0,2}(?:-[\da-z.-]+)?(?:\+[\da-z.-]+)?$/iu;
|
|
15280
|
+
function npmVersion(spec) {
|
|
15281
|
+
if (spec.length > 256)
|
|
15282
|
+
return false;
|
|
15283
|
+
return spec.split("||").every((set) => {
|
|
15284
|
+
const tokens = set.trim().replace(/([<>]=?|=|[~^])\s+/gu, "$1").split(/\s+/u);
|
|
15285
|
+
if (tokens.length === 3 && tokens[1] === "-")
|
|
15286
|
+
return NPM_COMPARATOR.test(tokens[0] ?? "") && NPM_COMPARATOR.test(tokens[2] ?? "");
|
|
15287
|
+
return tokens.every((token) => NPM_COMPARATOR.test(token));
|
|
15288
|
+
});
|
|
15289
|
+
}
|
|
15290
|
+
var HOOK_SCRIPT = /^(?:pre|post)|^(?:install|uninstall|prepare|publish|pack|version|dependencies|start|stop|restart|test)$/u;
|
|
15291
|
+
var isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15292
|
+
var same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
15293
|
+
function packageJson(before, after) {
|
|
15294
|
+
let old;
|
|
15295
|
+
let now;
|
|
15296
|
+
try {
|
|
15297
|
+
old = JSON.parse(before);
|
|
15298
|
+
now = JSON.parse(after);
|
|
15299
|
+
} catch {
|
|
15300
|
+
return refused("does not parse");
|
|
15301
|
+
}
|
|
15302
|
+
if (!isRecord3(old) || !isRecord3(now))
|
|
15303
|
+
return refused("is no JSON object");
|
|
15304
|
+
let bumped = 0;
|
|
15305
|
+
const scripts = [];
|
|
15306
|
+
for (const field of new Set([...Object.keys(old), ...Object.keys(now)])) {
|
|
15307
|
+
const a = old[field];
|
|
15308
|
+
const b = now[field];
|
|
15309
|
+
if (same(a, b))
|
|
15310
|
+
continue;
|
|
15311
|
+
if (DEP_FIELDS.has(field)) {
|
|
15312
|
+
if (!isRecord3(a) || !isRecord3(b))
|
|
15313
|
+
return refused(`changes ${field}`);
|
|
15314
|
+
for (const name of new Set([...Object.keys(a), ...Object.keys(b)])) {
|
|
15315
|
+
if (a[name] === b[name])
|
|
15316
|
+
continue;
|
|
15317
|
+
if (!(name in a))
|
|
15318
|
+
return refused(`adds the dependency ${name}`);
|
|
15319
|
+
if (!(name in b))
|
|
15320
|
+
return refused(`removes the dependency ${name}`);
|
|
15321
|
+
const from = a[name];
|
|
15322
|
+
const to = b[name];
|
|
15323
|
+
if (typeof from !== "string" || typeof to !== "string")
|
|
15324
|
+
return refused(`changes ${field}.${name}`);
|
|
15325
|
+
if (!npmVersion(from.trim()) || !npmVersion(to.trim()))
|
|
15326
|
+
return refused(`changes the source of ${name}`);
|
|
15327
|
+
bumped += 1;
|
|
15328
|
+
}
|
|
15329
|
+
} else if (field === "scripts") {
|
|
15330
|
+
if (!isRecord3(a) || !isRecord3(b))
|
|
15331
|
+
return refused("changes scripts");
|
|
15332
|
+
for (const name of Object.keys(a))
|
|
15333
|
+
if (a[name] !== b[name])
|
|
15334
|
+
return refused(`changes the script ${name}`);
|
|
15335
|
+
for (const name of Object.keys(b)) {
|
|
15336
|
+
if (name in a)
|
|
15337
|
+
continue;
|
|
15338
|
+
if (HOOK_SCRIPT.test(name))
|
|
15339
|
+
return refused(`adds the lifecycle script ${name}`);
|
|
15340
|
+
if (name.startsWith("pnpm:"))
|
|
15341
|
+
return refused(`adds the pnpm: script ${name}`);
|
|
15342
|
+
const runner = Object.entries(a).find(([, command]) => typeof command === "string" && runsByGlob(command, name));
|
|
15343
|
+
if (runner)
|
|
15344
|
+
return refused(`adds the script ${name}, which the script ${runner[0]} runs by glob`);
|
|
15345
|
+
scripts.push(name);
|
|
15346
|
+
}
|
|
15347
|
+
} else
|
|
15348
|
+
return refused(`changes ${field}`);
|
|
15349
|
+
}
|
|
15350
|
+
return pinned(bumped, scripts);
|
|
15351
|
+
}
|
|
15352
|
+
function runsByGlob(command, name) {
|
|
15353
|
+
const tokens = command.split(/\s+/u).map((token) => token.replace(/^--filter=/u, "").replaceAll(/^["']|["']$/gu, "").replace(/^(?:npm|pnpm|yarn|bun):/u, ""));
|
|
15354
|
+
if (/\bpnpm\b/u.test(command) && tokens.some((token) => /^\/.+\/$/u.test(token)))
|
|
15355
|
+
return true;
|
|
15356
|
+
return tokens.filter((token) => token.includes("*")).some((glob) => new RegExp(`^${glob.split(/\*+/u).map((part) => part.replaceAll(/[.+?^${}()|[\]\\]/gu, "\\$&")).join(".*")}$`, "u").test(name));
|
|
15357
|
+
}
|
|
15358
|
+
function goDirectives(text) {
|
|
15359
|
+
const out = [];
|
|
15360
|
+
let block = null;
|
|
15361
|
+
for (const raw of text.split(`
|
|
15362
|
+
`)) {
|
|
15363
|
+
const indirect = /\/\/\s*indirect\s*$/u.test(raw);
|
|
15364
|
+
const line = raw.replace(/\/\/.*$/u, "").trim();
|
|
15365
|
+
if (!line)
|
|
15366
|
+
continue;
|
|
15367
|
+
if (block !== null) {
|
|
15368
|
+
if (line === ")")
|
|
15369
|
+
block = null;
|
|
15370
|
+
else
|
|
15371
|
+
out.push({ verb: block, args: line.replace(/\s+/gu, " "), indirect });
|
|
15372
|
+
continue;
|
|
15373
|
+
}
|
|
15374
|
+
const match = /^(\S+)\s*(.*)$/u.exec(line);
|
|
15375
|
+
if (!match)
|
|
15376
|
+
return null;
|
|
15377
|
+
const [, verb = "", rest = ""] = match;
|
|
15378
|
+
if (rest === "(")
|
|
15379
|
+
block = verb;
|
|
15380
|
+
else
|
|
15381
|
+
out.push({ verb, args: rest.replace(/\s+/gu, " "), indirect });
|
|
15382
|
+
}
|
|
15383
|
+
return block === null ? out : null;
|
|
15384
|
+
}
|
|
15385
|
+
var GO_VERSION = /^v\d+\.\d+\.\d+(?:-[\w.-]+)?(?:\+incompatible)?$/u;
|
|
15386
|
+
function goMod(before, after) {
|
|
15387
|
+
const old = goDirectives(before);
|
|
15388
|
+
const now = goDirectives(after);
|
|
15389
|
+
if (!old || !now)
|
|
15390
|
+
return refused("does not parse");
|
|
15391
|
+
if (old.length !== now.length)
|
|
15392
|
+
return refused("adds or removes a directive");
|
|
15393
|
+
let bumped = 0;
|
|
15394
|
+
for (const [index, a] of old.entries()) {
|
|
15395
|
+
const b = now[index];
|
|
15396
|
+
if (a.verb === b.verb && a.args === b.args && a.indirect === b.indirect)
|
|
15397
|
+
continue;
|
|
15398
|
+
if (a.verb !== "require" || b.verb !== "require" || a.indirect !== b.indirect)
|
|
15399
|
+
return refused(`changes ${a.verb}`);
|
|
15400
|
+
const [module, from, extra] = a.args.split(" ");
|
|
15401
|
+
const [moduleAfter, to, extraAfter] = b.args.split(" ");
|
|
15402
|
+
if (module !== moduleAfter || extra !== undefined || extraAfter !== undefined)
|
|
15403
|
+
return refused(`changes require ${module ?? ""}`);
|
|
15404
|
+
if (!GO_VERSION.test(from ?? "") || !GO_VERSION.test(to ?? ""))
|
|
15405
|
+
return refused(`changes the source of ${module ?? ""}`);
|
|
15406
|
+
bumped += 1;
|
|
15407
|
+
}
|
|
15408
|
+
return pinned(bumped);
|
|
15409
|
+
}
|
|
15410
|
+
var CARGO_TABLE = /^(?:workspace\.)?(?:target\..+\.)?(?:dev-|build-)?dependencies(?:\.[^.]+)?$/u;
|
|
15411
|
+
var PYPROJECT_TABLE = /^(?:project\.optional-dependencies|dependency-groups|tool\.poetry\.(?:dev-)?dependencies|tool\.poetry\.group\.[^.]+\.dependencies)$/u;
|
|
15412
|
+
var OTHER_SOURCE = /\b(?:git|rev|branch|tag|path|url|registry|package)\s*=|@|:\/\//u;
|
|
15413
|
+
var VERSION_TOKEN = /(?<=[\s"'=<>~^!,*v])\d+(?:\.\d+)*(?:[a-z]+\d*)?(?:\.(?:post|dev)\d+)?/giu;
|
|
15414
|
+
function tomlPins(before, after, cargo) {
|
|
15415
|
+
const old = before.split(`
|
|
15416
|
+
`);
|
|
15417
|
+
const now = after.split(`
|
|
15418
|
+
`);
|
|
15419
|
+
if (old.length !== now.length)
|
|
15420
|
+
return refused("adds or removes lines");
|
|
15421
|
+
let table = "";
|
|
15422
|
+
let inArray = false;
|
|
15423
|
+
let bumped = 0;
|
|
15424
|
+
for (const [index, a] of old.entries()) {
|
|
15425
|
+
const b = now[index] ?? "";
|
|
15426
|
+
const header = /^\s*\[\[?([^\]]+)\]\]?\s*(?:#.*)?$/u.exec(a);
|
|
15427
|
+
if (header) {
|
|
15428
|
+
table = (header[1] ?? "").replace(/\s+/gu, "");
|
|
15429
|
+
inArray = false;
|
|
15430
|
+
} else if (!cargo && table === "project" && /^\s*dependencies\s*=\s*\[\s*(?:#.*)?$/u.test(a))
|
|
15431
|
+
inArray = true;
|
|
15432
|
+
else if (inArray && /^\s*\]/u.test(a))
|
|
15433
|
+
inArray = false;
|
|
15434
|
+
if (a === b)
|
|
15435
|
+
continue;
|
|
15436
|
+
const listed = cargo ? CARGO_TABLE.test(table) : PYPROJECT_TABLE.test(table) || inArray || table === "project" && /^\s*dependencies\s*=/u.test(a);
|
|
15437
|
+
if (header || !listed)
|
|
15438
|
+
return refused(`changes line ${index + 1} outside a dependency table`);
|
|
15439
|
+
if (OTHER_SOURCE.test(a) || OTHER_SOURCE.test(b))
|
|
15440
|
+
return refused(`changes a dependency source on line ${index + 1}`);
|
|
15441
|
+
const key = (line) => /^\s*("?[\w.[\],-]+"?)/u.exec(line)?.[1] ?? "";
|
|
15442
|
+
const versionless = (line) => line.replace(VERSION_TOKEN, "V");
|
|
15443
|
+
const names = (line) => cargo ? "" : [...line.matchAll(/"([A-Za-z_][\w.-]*)/gu)].map((match) => match[1]).join(",");
|
|
15444
|
+
if (key(a) !== key(b) || names(a) !== names(b) || versionless(a) !== versionless(b))
|
|
15445
|
+
return refused(`changes more than a version on line ${index + 1}`);
|
|
15446
|
+
bumped += 1;
|
|
15447
|
+
}
|
|
15448
|
+
return pinned(bumped);
|
|
15449
|
+
}
|
|
15450
|
+
function manifestEdit(file, before, after) {
|
|
15451
|
+
const name = basename(file);
|
|
15452
|
+
if (name === "package.json")
|
|
15453
|
+
return packageJson(before, after);
|
|
15454
|
+
if (name === "go.mod")
|
|
15455
|
+
return goMod(before, after);
|
|
15456
|
+
return tomlPins(before, after, name === "Cargo.toml");
|
|
15457
|
+
}
|
|
15458
|
+
|
|
15252
15459
|
// packages/workit-core/src/core/policy/substance.ts
|
|
15253
15460
|
var SLASH_BLOCK = [["/*", "*/"]];
|
|
15254
15461
|
var C_LIKE = { line: ["//"], block: SLASH_BLOCK, quotes: `"'` };
|
|
@@ -15567,6 +15774,483 @@ function cosmeticChange(file, before, after) {
|
|
|
15567
15774
|
return a !== null && a === substanceOf(file, right);
|
|
15568
15775
|
}
|
|
15569
15776
|
|
|
15777
|
+
// packages/workit-core/src/core/policy/workflow-edit.ts
|
|
15778
|
+
class Unparsed extends Error {
|
|
15779
|
+
}
|
|
15780
|
+
var refuse = (why) => {
|
|
15781
|
+
throw new Unparsed(why);
|
|
15782
|
+
};
|
|
15783
|
+
var NON_STRING = /^(?:~|null|true|false|yes|no|on|off|y|n|[-+]?(?:\d[\d_]*(?:\.\d*)?|\.\d+)(?:e[-+]?\d+)?|0x[\da-f]+|0o[0-7]+|[-+]?\.inf|\.nan)$/iu;
|
|
15784
|
+
var HEX_DIGITS = { x: 2, u: 4, U: 8 };
|
|
15785
|
+
var ESCAPES = {
|
|
15786
|
+
n: `
|
|
15787
|
+
`,
|
|
15788
|
+
t: "\t",
|
|
15789
|
+
r: "\r",
|
|
15790
|
+
"0": "\x00",
|
|
15791
|
+
'"': '"',
|
|
15792
|
+
"\\": "\\",
|
|
15793
|
+
"/": "/",
|
|
15794
|
+
" ": " "
|
|
15795
|
+
};
|
|
15796
|
+
var scalar = (text, string, folded = false) => ({
|
|
15797
|
+
kind: "scalar",
|
|
15798
|
+
text,
|
|
15799
|
+
string,
|
|
15800
|
+
folded
|
|
15801
|
+
});
|
|
15802
|
+
function quoted(text, start) {
|
|
15803
|
+
const quote = text[start];
|
|
15804
|
+
let out = "";
|
|
15805
|
+
for (let index = start + 1;index < text.length; index += 1) {
|
|
15806
|
+
const char = text[index] ?? "";
|
|
15807
|
+
if (quote === "'" && char === "'") {
|
|
15808
|
+
if (text[index + 1] !== "'")
|
|
15809
|
+
return { value: out, end: index + 1 };
|
|
15810
|
+
out += "'";
|
|
15811
|
+
index += 1;
|
|
15812
|
+
} else if (quote === '"' && char === '"')
|
|
15813
|
+
return { value: out, end: index + 1 };
|
|
15814
|
+
else if (quote === '"' && char === "\\") {
|
|
15815
|
+
const next = text[index + 1] ?? "";
|
|
15816
|
+
const hex = HEX_DIGITS[next];
|
|
15817
|
+
if (hex) {
|
|
15818
|
+
const digits = text.slice(index + 2, index + 2 + hex);
|
|
15819
|
+
if (!/^[\da-f]+$/iu.test(digits) || digits.length !== hex)
|
|
15820
|
+
refuse("a bad escape");
|
|
15821
|
+
out += String.fromCodePoint(Number.parseInt(digits, 16));
|
|
15822
|
+
index += 1 + hex;
|
|
15823
|
+
} else {
|
|
15824
|
+
out += ESCAPES[next] ?? refuse("an unknown escape");
|
|
15825
|
+
index += 1;
|
|
15826
|
+
}
|
|
15827
|
+
} else
|
|
15828
|
+
out += char;
|
|
15829
|
+
}
|
|
15830
|
+
return refuse("a quoted scalar spans lines");
|
|
15831
|
+
}
|
|
15832
|
+
function trailing(text, end) {
|
|
15833
|
+
const rest = text.slice(end);
|
|
15834
|
+
if (rest.trim() && !/^\s+#/u.test(rest))
|
|
15835
|
+
refuse("text after a value");
|
|
15836
|
+
}
|
|
15837
|
+
var INDICATOR = /^[&*!%@`|>,[\]{}?:#-]/u;
|
|
15838
|
+
function plain(text) {
|
|
15839
|
+
const value = text.replace(/\s+#.*$/u, "").trimEnd();
|
|
15840
|
+
if (INDICATOR.test(value) && !/^-[^\s]/u.test(value))
|
|
15841
|
+
refuse("an indicator starts a scalar");
|
|
15842
|
+
if (/:\s|:$/u.test(value))
|
|
15843
|
+
refuse("a mapping inside a scalar");
|
|
15844
|
+
return scalar(value, !NON_STRING.test(value));
|
|
15845
|
+
}
|
|
15846
|
+
function flow(text, start) {
|
|
15847
|
+
const close = text[start] === "[" ? "]" : "}";
|
|
15848
|
+
const items = [];
|
|
15849
|
+
const entries = new Map;
|
|
15850
|
+
let index = start + 1;
|
|
15851
|
+
const skip = () => {
|
|
15852
|
+
while (text[index] === " ")
|
|
15853
|
+
index += 1;
|
|
15854
|
+
};
|
|
15855
|
+
const element = (stops) => {
|
|
15856
|
+
skip();
|
|
15857
|
+
const char = text[index];
|
|
15858
|
+
if (char === '"' || char === "'") {
|
|
15859
|
+
const read = quoted(text, index);
|
|
15860
|
+
index = read.end;
|
|
15861
|
+
return scalar(read.value, true);
|
|
15862
|
+
}
|
|
15863
|
+
if (char === "[" || char === "{") {
|
|
15864
|
+
const read = flow(text, index);
|
|
15865
|
+
index = read.end;
|
|
15866
|
+
return read.node;
|
|
15867
|
+
}
|
|
15868
|
+
let end = index;
|
|
15869
|
+
while (end < text.length && !stops.test(text[end] ?? ""))
|
|
15870
|
+
end += 1;
|
|
15871
|
+
const value = text.slice(index, end).trim();
|
|
15872
|
+
index = end;
|
|
15873
|
+
if (!value || value.includes("#"))
|
|
15874
|
+
refuse("an empty or commented flow element");
|
|
15875
|
+
return plain(value);
|
|
15876
|
+
};
|
|
15877
|
+
for (;; ) {
|
|
15878
|
+
skip();
|
|
15879
|
+
if (index >= text.length)
|
|
15880
|
+
refuse("a flow collection spans lines");
|
|
15881
|
+
if (text[index] === close)
|
|
15882
|
+
return {
|
|
15883
|
+
node: close === "]" ? { kind: "seq", items } : { kind: "map", entries },
|
|
15884
|
+
end: index + 1
|
|
15885
|
+
};
|
|
15886
|
+
if (close === "]")
|
|
15887
|
+
items.push(element(/[,\]]/u));
|
|
15888
|
+
else {
|
|
15889
|
+
const key = element(/[:,}]/u);
|
|
15890
|
+
skip();
|
|
15891
|
+
if (text[index] !== ":" || key.kind !== "scalar")
|
|
15892
|
+
refuse("a flow mapping without a value");
|
|
15893
|
+
index += 1;
|
|
15894
|
+
const value = element(/[,}]/u);
|
|
15895
|
+
const name = key.kind === "scalar" ? key.text : "";
|
|
15896
|
+
if (entries.has(name))
|
|
15897
|
+
refuse("a duplicate key");
|
|
15898
|
+
entries.set(name, value);
|
|
15899
|
+
}
|
|
15900
|
+
skip();
|
|
15901
|
+
if (text[index] === ",")
|
|
15902
|
+
index += 1;
|
|
15903
|
+
else if (text[index] !== close)
|
|
15904
|
+
refuse("a malformed flow collection");
|
|
15905
|
+
}
|
|
15906
|
+
}
|
|
15907
|
+
var isItem = (text) => text === "-" || text.startsWith("- ");
|
|
15908
|
+
function splitKey(text) {
|
|
15909
|
+
if (text[0] === '"' || text[0] === "'") {
|
|
15910
|
+
const read = quoted(text, 0);
|
|
15911
|
+
const after = text.slice(read.end);
|
|
15912
|
+
const match = /^\s*:(?:\s+|$)/u.exec(after);
|
|
15913
|
+
return match ? { key: read.value, rest: after.slice(match[0].length) } : null;
|
|
15914
|
+
}
|
|
15915
|
+
const match = /:(?:\s|$)/u.exec(text);
|
|
15916
|
+
if (!match || INDICATOR.test(text))
|
|
15917
|
+
return null;
|
|
15918
|
+
const key = text.slice(0, match.index).trimEnd();
|
|
15919
|
+
if (!key || key.includes(" #"))
|
|
15920
|
+
return null;
|
|
15921
|
+
return { key, rest: text.slice(match.index + 1).trimStart() };
|
|
15922
|
+
}
|
|
15923
|
+
|
|
15924
|
+
class Reader {
|
|
15925
|
+
lines;
|
|
15926
|
+
pos = 0;
|
|
15927
|
+
constructor(text) {
|
|
15928
|
+
const normal = text.replace(/\r\n/gu, `
|
|
15929
|
+
`);
|
|
15930
|
+
if (normal.includes("\r") || normal.charCodeAt(0) === 65279)
|
|
15931
|
+
refuse("an odd line break or BOM");
|
|
15932
|
+
this.lines = normal.split(`
|
|
15933
|
+
`);
|
|
15934
|
+
const first = this.lines.findIndex((line) => line.trim() && !line.trimStart().startsWith("#"));
|
|
15935
|
+
if (first >= 0 && /^---\s*(?:#.*)?$/u.test(this.lines[first] ?? ""))
|
|
15936
|
+
this.lines[first] = "";
|
|
15937
|
+
}
|
|
15938
|
+
next() {
|
|
15939
|
+
while (this.pos < this.lines.length) {
|
|
15940
|
+
const raw = this.lines[this.pos] ?? "";
|
|
15941
|
+
const text = raw.trimStart();
|
|
15942
|
+
if (text === "" || text.startsWith("#")) {
|
|
15943
|
+
this.pos += 1;
|
|
15944
|
+
continue;
|
|
15945
|
+
}
|
|
15946
|
+
const indent = raw.length - text.length;
|
|
15947
|
+
if (raw.slice(0, indent).includes("\t"))
|
|
15948
|
+
refuse("a tab indents a line");
|
|
15949
|
+
if (indent === 0 && /^(?:---|\.\.\.)(?:\s|$)|^%/u.test(text))
|
|
15950
|
+
refuse("several documents");
|
|
15951
|
+
return { indent, text: text.trimEnd() };
|
|
15952
|
+
}
|
|
15953
|
+
return null;
|
|
15954
|
+
}
|
|
15955
|
+
document() {
|
|
15956
|
+
const root = this.block(0);
|
|
15957
|
+
if (this.next())
|
|
15958
|
+
refuse("content after the document");
|
|
15959
|
+
return root;
|
|
15960
|
+
}
|
|
15961
|
+
block(min) {
|
|
15962
|
+
const line = this.next();
|
|
15963
|
+
if (!line || line.indent < min)
|
|
15964
|
+
return scalar("", false);
|
|
15965
|
+
return isItem(line.text) ? this.sequence(line.indent) : this.mapping(line.indent);
|
|
15966
|
+
}
|
|
15967
|
+
mapping(indent) {
|
|
15968
|
+
const entries = new Map;
|
|
15969
|
+
for (let line = this.next();line && line.indent >= indent; line = this.next()) {
|
|
15970
|
+
if (line.indent > indent || isItem(line.text))
|
|
15971
|
+
refuse("bad indentation");
|
|
15972
|
+
const split = splitKey(line.text) ?? refuse("a line that is no mapping entry");
|
|
15973
|
+
if (entries.has(split.key))
|
|
15974
|
+
refuse("a duplicate key");
|
|
15975
|
+
this.pos += 1;
|
|
15976
|
+
entries.set(split.key, this.value(split.rest, indent, true));
|
|
15977
|
+
}
|
|
15978
|
+
return { kind: "map", entries };
|
|
15979
|
+
}
|
|
15980
|
+
sequence(indent) {
|
|
15981
|
+
const items = [];
|
|
15982
|
+
for (let line = this.next();line && line.indent === indent && isItem(line.text); line = this.next()) {
|
|
15983
|
+
const rest = line.text.slice(1).trimStart();
|
|
15984
|
+
const offset = indent + line.text.length - rest.length;
|
|
15985
|
+
if (isItem(rest))
|
|
15986
|
+
refuse("a sequence inside a sequence item");
|
|
15987
|
+
if (rest && !/^[|>[{]/u.test(rest) && splitKey(rest)) {
|
|
15988
|
+
this.lines[this.pos] = " ".repeat(offset) + rest;
|
|
15989
|
+
items.push(this.mapping(offset));
|
|
15990
|
+
} else {
|
|
15991
|
+
this.pos += 1;
|
|
15992
|
+
items.push(this.value(rest, indent, false));
|
|
15993
|
+
}
|
|
15994
|
+
}
|
|
15995
|
+
const line = this.next();
|
|
15996
|
+
if (line && line.indent > indent)
|
|
15997
|
+
refuse("bad indentation");
|
|
15998
|
+
return { kind: "seq", items };
|
|
15999
|
+
}
|
|
16000
|
+
value(rest, indent, inMapping) {
|
|
16001
|
+
if (rest === "" || rest.startsWith("#")) {
|
|
16002
|
+
const line = this.next();
|
|
16003
|
+
if (line && line.indent > indent)
|
|
16004
|
+
return this.block(line.indent);
|
|
16005
|
+
if (inMapping && line?.indent === indent && isItem(line.text))
|
|
16006
|
+
return this.sequence(indent);
|
|
16007
|
+
return scalar("", false);
|
|
16008
|
+
}
|
|
16009
|
+
let node;
|
|
16010
|
+
if (rest[0] === "|" || rest[0] === ">")
|
|
16011
|
+
return this.blockScalar(rest, indent);
|
|
16012
|
+
if (rest[0] === '"' || rest[0] === "'") {
|
|
16013
|
+
const read = quoted(rest, 0);
|
|
16014
|
+
trailing(rest, read.end);
|
|
16015
|
+
node = scalar(read.value, true);
|
|
16016
|
+
} else if (rest[0] === "[" || rest[0] === "{") {
|
|
16017
|
+
const read = flow(rest, 0);
|
|
16018
|
+
trailing(rest, read.end);
|
|
16019
|
+
node = read.node;
|
|
16020
|
+
} else
|
|
16021
|
+
node = plain(rest);
|
|
16022
|
+
const line = this.next();
|
|
16023
|
+
if (line && line.indent > indent)
|
|
16024
|
+
refuse("a value continues on the next line");
|
|
16025
|
+
return node;
|
|
16026
|
+
}
|
|
16027
|
+
blockScalar(header, indent) {
|
|
16028
|
+
const match = /^([|>])(?:([-+])([1-9])?|([1-9])([-+])?)?\s*(?:#.*)?$/u.exec(header);
|
|
16029
|
+
if (!match)
|
|
16030
|
+
return refuse("a bad block scalar header");
|
|
16031
|
+
const chomp = match[2] ?? match[5] ?? "";
|
|
16032
|
+
const indicator = match[3] ?? match[4];
|
|
16033
|
+
let column = indicator ? indent + Number(indicator) : null;
|
|
16034
|
+
const body = [];
|
|
16035
|
+
while (this.pos < this.lines.length) {
|
|
16036
|
+
const raw = this.lines[this.pos] ?? "";
|
|
16037
|
+
if (raw.trim() === "") {
|
|
16038
|
+
body.push(column !== null && raw.length > column ? raw.slice(column) : "");
|
|
16039
|
+
this.pos += 1;
|
|
16040
|
+
continue;
|
|
16041
|
+
}
|
|
16042
|
+
const lead = raw.length - raw.trimStart().length;
|
|
16043
|
+
if (column === null) {
|
|
16044
|
+
if (lead <= indent)
|
|
16045
|
+
break;
|
|
16046
|
+
column = lead;
|
|
16047
|
+
}
|
|
16048
|
+
if (lead < column) {
|
|
16049
|
+
if (lead > indent)
|
|
16050
|
+
refuse("an under-indented block line");
|
|
16051
|
+
break;
|
|
16052
|
+
}
|
|
16053
|
+
if (raw.slice(0, column).includes("\t"))
|
|
16054
|
+
refuse("a tab indents a line");
|
|
16055
|
+
body.push(raw.slice(column));
|
|
16056
|
+
this.pos += 1;
|
|
16057
|
+
}
|
|
16058
|
+
let end = body.length;
|
|
16059
|
+
while (end > 0 && body[end - 1] === "")
|
|
16060
|
+
end -= 1;
|
|
16061
|
+
const content = body.slice(0, end).join(`
|
|
16062
|
+
`);
|
|
16063
|
+
const text = chomp === "+" ? `${body.join(`
|
|
16064
|
+
`)}
|
|
16065
|
+
` : chomp === "-" || !content ? content : `${content}
|
|
16066
|
+
`;
|
|
16067
|
+
return scalar(text, true, match[1] === ">");
|
|
16068
|
+
}
|
|
16069
|
+
}
|
|
16070
|
+
function parseWorkflowYaml(text) {
|
|
16071
|
+
try {
|
|
16072
|
+
return new Reader(text).document();
|
|
16073
|
+
} catch (error) {
|
|
16074
|
+
if (error instanceof Unparsed)
|
|
16075
|
+
return null;
|
|
16076
|
+
throw error;
|
|
16077
|
+
}
|
|
16078
|
+
}
|
|
16079
|
+
var isWorkflowFile = (file) => /^\.github\/workflows\/[^/]+\.ya?ml$/u.test(file);
|
|
16080
|
+
var GUARDED = new Set(["permissions", "secrets", "on", "uses", "environment", "if"]);
|
|
16081
|
+
var pathText = (keys) => keys.join(".").replaceAll(".[", "[");
|
|
16082
|
+
var WORD2 = /[\w./:@=+,-]+/uy;
|
|
16083
|
+
var QUOTED = /"[^"$`\\]*"/uy;
|
|
16084
|
+
var COMMAND = /^[\w.+][\w./+-]*$/u;
|
|
16085
|
+
var SHELL_STATE = new Set(". alias bg bind break builtin call caller case cd command compgen complete compopt continue coproc declare dirs disown do done elif else enable esac eval exec exit export fc fg fi for function getopts goto hash help history if in jobs kill let local logout mapfile popd pushd read readarray readonly return select set shift shopt source suspend then time times trap type typeset ulimit umask unalias unset until wait while".split(" "));
|
|
16086
|
+
var FALLBACK = new Set(["echo", "true"]);
|
|
16087
|
+
var FORM = 'more than && <command> or && (<command> || echo "<text>")';
|
|
16088
|
+
var OUTSIDE = '(outside plain words and "double-quoted text")';
|
|
16089
|
+
var COMMAND_INPUT = /(?:^|[-_])(?:commands?|cmd|script)$/iu;
|
|
16090
|
+
function tokens2(text) {
|
|
16091
|
+
const out = [];
|
|
16092
|
+
let index = 0;
|
|
16093
|
+
while (index < text.length) {
|
|
16094
|
+
const char = text[index] ?? "";
|
|
16095
|
+
if (char === " " || char === "\t")
|
|
16096
|
+
index += 1;
|
|
16097
|
+
else if (char === "(" || char === ")") {
|
|
16098
|
+
out.push({ op: char });
|
|
16099
|
+
index += 1;
|
|
16100
|
+
} else if ((char === "&" || char === "|") && text[index + 1] === char) {
|
|
16101
|
+
out.push({ op: char + char });
|
|
16102
|
+
index += 2;
|
|
16103
|
+
} else {
|
|
16104
|
+
const pattern = char === '"' ? QUOTED : WORD2;
|
|
16105
|
+
pattern.lastIndex = index;
|
|
16106
|
+
const match = pattern.exec(text);
|
|
16107
|
+
if (!match)
|
|
16108
|
+
return char === '"' ? 'a "quoted text" left open or holding $, a backtick or a backslash' : `the character ${char} ${OUTSIDE}`;
|
|
16109
|
+
index += match[0].length;
|
|
16110
|
+
const next = text[index] ?? " ";
|
|
16111
|
+
if (!" \t)&|".includes(next))
|
|
16112
|
+
return `the character ${next} ${OUTSIDE}`;
|
|
16113
|
+
out.push(char === '"' ? { quoted: match[0] } : { word: match[0] });
|
|
16114
|
+
}
|
|
16115
|
+
}
|
|
16116
|
+
return out;
|
|
16117
|
+
}
|
|
16118
|
+
function masking(before, appended) {
|
|
16119
|
+
if (appended.includes("${{"))
|
|
16120
|
+
return "an expression";
|
|
16121
|
+
if (/[\n\r]/u.test(appended))
|
|
16122
|
+
return "a new line";
|
|
16123
|
+
if (!before.trim())
|
|
16124
|
+
return "a command where none ran before";
|
|
16125
|
+
if (before.endsWith("\\"))
|
|
16126
|
+
return "a command after a trailing backslash";
|
|
16127
|
+
if (!appended.trimStart().startsWith("&&"))
|
|
16128
|
+
return "a command not chained with a leading &&";
|
|
16129
|
+
const list = tokens2(appended);
|
|
16130
|
+
if (typeof list === "string")
|
|
16131
|
+
return list;
|
|
16132
|
+
let index = 0;
|
|
16133
|
+
const op = (text) => {
|
|
16134
|
+
const token = list[index];
|
|
16135
|
+
if (!token || !("op" in token) || token.op !== text)
|
|
16136
|
+
return false;
|
|
16137
|
+
index += 1;
|
|
16138
|
+
return true;
|
|
16139
|
+
};
|
|
16140
|
+
const command = (names) => {
|
|
16141
|
+
const name = list[index];
|
|
16142
|
+
if (!name || !("word" in name) || !COMMAND.test(name.word))
|
|
16143
|
+
return FORM;
|
|
16144
|
+
if (names ? !names.has(name.word) : SHELL_STATE.has(name.word.toLowerCase()))
|
|
16145
|
+
return names ? FORM : `the shell command ${name.word}`;
|
|
16146
|
+
index += 1;
|
|
16147
|
+
for (let token = list[index];token && !("op" in token); token = list[index])
|
|
16148
|
+
index += 1;
|
|
16149
|
+
return null;
|
|
16150
|
+
};
|
|
16151
|
+
while (index < list.length) {
|
|
16152
|
+
if (!op("&&"))
|
|
16153
|
+
return FORM;
|
|
16154
|
+
const group = op("(");
|
|
16155
|
+
const bad = command() ?? (group && op("||") ? command(FALLBACK) : null);
|
|
16156
|
+
if (bad)
|
|
16157
|
+
return bad;
|
|
16158
|
+
if (group && !op(")"))
|
|
16159
|
+
return FORM;
|
|
16160
|
+
}
|
|
16161
|
+
return null;
|
|
16162
|
+
}
|
|
16163
|
+
function compare(before, after, at, room, out) {
|
|
16164
|
+
if (before.kind === "scalar" && after.kind === "scalar") {
|
|
16165
|
+
if (before.text === after.text && before.string === after.string)
|
|
16166
|
+
return;
|
|
16167
|
+
const grown = room !== null && before.string && after.string && before.folded === after.folded && after.text.length > before.text.length && after.text.startsWith(before.text);
|
|
16168
|
+
const masks = grown ? masking(before.text, after.text.slice(before.text.length)) : null;
|
|
16169
|
+
if (masks)
|
|
16170
|
+
out.refused.push({ path: at, what: `appends ${masks} to ${pathText(at)}` });
|
|
16171
|
+
else if (grown)
|
|
16172
|
+
out.allowed.push(`${pathText(at)} appended`);
|
|
16173
|
+
else
|
|
16174
|
+
out.refused.push({ path: at, what: `changes ${pathText(at)}` });
|
|
16175
|
+
return;
|
|
16176
|
+
}
|
|
16177
|
+
if (before.kind === "seq" && after.kind === "seq") {
|
|
16178
|
+
if (before.items.length !== after.items.length) {
|
|
16179
|
+
const fewer = after.items.length < before.items.length;
|
|
16180
|
+
const noun = at.at(-1) === "steps" ? "a step" : "an item";
|
|
16181
|
+
out.refused.push({
|
|
16182
|
+
path: at,
|
|
16183
|
+
what: `${fewer ? "removes" : "adds"} ${noun} ${fewer ? "from" : "to"} ${pathText(at)}`
|
|
16184
|
+
});
|
|
16185
|
+
return;
|
|
16186
|
+
}
|
|
16187
|
+
before.items.forEach((item, index) => compare(item, after.items[index], [...at, `[${index}]`], null, out));
|
|
16188
|
+
return;
|
|
16189
|
+
}
|
|
16190
|
+
if (before.kind === "map" && after.kind === "map") {
|
|
16191
|
+
const step = at.at(-2) === "steps";
|
|
16192
|
+
const job = at.length === 2 && at[0] === "jobs";
|
|
16193
|
+
const usesBoth = before.entries.has("uses") && after.entries.has("uses");
|
|
16194
|
+
for (const [key, value] of before.entries) {
|
|
16195
|
+
const next = after.entries.get(key);
|
|
16196
|
+
if (!next) {
|
|
16197
|
+
out.refused.push({
|
|
16198
|
+
path: [...at, key],
|
|
16199
|
+
what: at.length === 1 && at[0] === "jobs" ? `removes the job ${key}` : `removes ${pathText([...at, key])}`
|
|
16200
|
+
});
|
|
16201
|
+
continue;
|
|
16202
|
+
}
|
|
16203
|
+
if (key === "with" && job && usesBoth && value.kind === "map" && next.kind === "map")
|
|
16204
|
+
compareInputs(value, next, [...at, key], out);
|
|
16205
|
+
else
|
|
16206
|
+
compare(value, next, [...at, key], key === "run" && step ? "run" : null, out);
|
|
16207
|
+
}
|
|
16208
|
+
for (const [key] of after.entries)
|
|
16209
|
+
if (!before.entries.has(key))
|
|
16210
|
+
out.refused.push({ path: [...at, key], what: `adds ${pathText([...at, key])}` });
|
|
16211
|
+
return;
|
|
16212
|
+
}
|
|
16213
|
+
out.refused.push({ path: at, what: `changes the shape of ${pathText(at) || "the file"}` });
|
|
16214
|
+
}
|
|
16215
|
+
function compareInputs(before, after, at, out) {
|
|
16216
|
+
for (const [key, value] of before.entries) {
|
|
16217
|
+
const next = after.entries.get(key);
|
|
16218
|
+
if (next)
|
|
16219
|
+
compare(value, next, [...at, key], COMMAND_INPUT.test(key) ? "with" : null, out);
|
|
16220
|
+
else
|
|
16221
|
+
out.refused.push({ path: [...at, key], what: `removes ${pathText([...at, key])}` });
|
|
16222
|
+
}
|
|
16223
|
+
for (const [key] of after.entries)
|
|
16224
|
+
if (!before.entries.has(key))
|
|
16225
|
+
out.refused.push({ path: [...at, key], what: `adds the input ${pathText([...at, key])}` });
|
|
16226
|
+
}
|
|
16227
|
+
function decisive(refused) {
|
|
16228
|
+
for (const change of refused) {
|
|
16229
|
+
const key = change.path.find((part) => GUARDED.has(part));
|
|
16230
|
+
if (key === "uses")
|
|
16231
|
+
return `moves a uses: ref (${pathText(change.path)})`;
|
|
16232
|
+
if (key)
|
|
16233
|
+
return `changes ${key}: (${pathText(change.path)})`;
|
|
16234
|
+
}
|
|
16235
|
+
return (refused.find((change) => change.what.startsWith("removes")) ?? refused[0])?.what ?? "changes it";
|
|
16236
|
+
}
|
|
16237
|
+
function workflowEdit(before, after) {
|
|
16238
|
+
const old = parseWorkflowYaml(before);
|
|
16239
|
+
const now = parseWorkflowYaml(after);
|
|
16240
|
+
if (!old || !now)
|
|
16241
|
+
return { additive: false, detail: "does not parse as plain workflow YAML" };
|
|
16242
|
+
const out = { allowed: [], refused: [] };
|
|
16243
|
+
compare(old, now, [], null, out);
|
|
16244
|
+
if (out.refused.length)
|
|
16245
|
+
return { additive: false, detail: decisive(out.refused) };
|
|
16246
|
+
if (!out.allowed.length)
|
|
16247
|
+
return { additive: false, detail: "changes only comments or layout, read as code" };
|
|
16248
|
+
return {
|
|
16249
|
+
additive: true,
|
|
16250
|
+
detail: out.allowed.slice(0, 3).join(", ") + (out.allowed.length > 3 ? ", …" : "")
|
|
16251
|
+
};
|
|
16252
|
+
}
|
|
16253
|
+
|
|
15570
16254
|
// packages/workit-core/src/core/policy/lane.ts
|
|
15571
16255
|
var LANE_THRESHOLDS = {
|
|
15572
16256
|
selfMaxLines: 100,
|
|
@@ -15627,15 +16311,16 @@ var DOC_EXT = /\.(?:md|mdx|markdown|rst|adoc)$/iu;
|
|
|
15627
16311
|
var DOC_NAMES = /^(?:license|licence|notice|authors|changelog|changes|contributors)$/iu;
|
|
15628
16312
|
var INSTRUCTIONS = /(?:^|\/)(?:AGENTS|CLAUDE|GEMINI|SKILL)\.md$|(?:^|\/)(?:skills|agents|commands|rules|prompts)\/[^/]+/iu;
|
|
15629
16313
|
var TEST_PATH = /(?:^|\/)(?:test|tests|__tests__)\/|\.(?:test|spec)\.[^/]+$|_test\.[^/]+$/iu;
|
|
16314
|
+
var DEPENDENCY_BUMP_EVIDENCE = "green CI on the head";
|
|
15630
16315
|
var plural = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
|
|
15631
|
-
var
|
|
15632
|
-
var isDoc = (file) => !INSTRUCTIONS.test(file) && (DOC_EXT.test(file) || DOC_NAMES.test(
|
|
16316
|
+
var basename2 = (file) => file.slice(file.lastIndexOf("/") + 1);
|
|
16317
|
+
var isDoc = (file) => !INSTRUCTIONS.test(file) && (DOC_EXT.test(file) || DOC_NAMES.test(basename2(file)));
|
|
15633
16318
|
function kindOf(file) {
|
|
15634
16319
|
if (file.binary)
|
|
15635
16320
|
return "behavior";
|
|
15636
16321
|
if (file.generated)
|
|
15637
16322
|
return "generated";
|
|
15638
|
-
if (LOCKFILES.has(
|
|
16323
|
+
if (LOCKFILES.has(basename2(file.path)))
|
|
15639
16324
|
return "lockfile";
|
|
15640
16325
|
if (isDoc(file.path))
|
|
15641
16326
|
return "doc";
|
|
@@ -15668,7 +16353,7 @@ function globMatch(pattern, file) {
|
|
|
15668
16353
|
function isRiskPath(file, extra = []) {
|
|
15669
16354
|
if (extra.some((pattern) => globMatch(pattern, file)))
|
|
15670
16355
|
return true;
|
|
15671
|
-
if (RISK_FILES.has(file) || RISK_NAMES.has(
|
|
16356
|
+
if (RISK_FILES.has(file) || RISK_NAMES.has(basename2(file)))
|
|
15672
16357
|
return true;
|
|
15673
16358
|
if (TEST_PATH.test(file) || isDoc(file))
|
|
15674
16359
|
return false;
|
|
@@ -15676,8 +16361,41 @@ function isRiskPath(file, extra = []) {
|
|
|
15676
16361
|
}
|
|
15677
16362
|
var parseRiskPaths = (text) => text.split(`
|
|
15678
16363
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.replace(/^\//u, ""));
|
|
16364
|
+
function additiveWorkflow(file, extra) {
|
|
16365
|
+
if (file.workflow?.additive !== true || file.binary || !isWorkflowFile(file.path))
|
|
16366
|
+
return false;
|
|
16367
|
+
if (extra.some((pattern) => globMatch(pattern, file.path)))
|
|
16368
|
+
return false;
|
|
16369
|
+
return !isRiskPath(file.path.replace(/^\.github\/workflows\//u, ".github/"), extra);
|
|
16370
|
+
}
|
|
16371
|
+
var ADDITIVE_CI_FLOOR = "an additive workflow edit needs a non-author verdict unless it rides a dependency bump";
|
|
16372
|
+
var CHANGELOG = /^(?:changelog|changes)(?:\.[^.]+)?$/iu;
|
|
16373
|
+
function dependencyBump(files, additive) {
|
|
16374
|
+
const manifests = files.filter((file) => file.manifest?.pins && !file.binary);
|
|
16375
|
+
if (!manifests.some((file) => (file.manifest?.bumped ?? 0) > 0))
|
|
16376
|
+
return null;
|
|
16377
|
+
const locks = [];
|
|
16378
|
+
for (const file of files) {
|
|
16379
|
+
if (additive.has(file.path) || manifests.includes(file))
|
|
16380
|
+
continue;
|
|
16381
|
+
if (LOCKFILES.has(basename2(file.path)))
|
|
16382
|
+
locks.push(file.path);
|
|
16383
|
+
else if (file.binary || !(isDoc(file.path) && CHANGELOG.test(basename2(file.path))))
|
|
16384
|
+
return null;
|
|
16385
|
+
}
|
|
16386
|
+
const bumped = manifests.reduce((sum, file) => sum + (file.manifest?.bumped ?? 0), 0);
|
|
16387
|
+
const scripts = manifests.flatMap((file) => file.manifest?.scripts ?? []);
|
|
16388
|
+
const list = (paths) => `${paths.slice(0, 3).join(", ")}${paths.length > 3 ? ", …" : ""}`;
|
|
16389
|
+
return `dependency-bump: ${plural(bumped, "version pin")} in ${list(manifests.map((file) => file.path))}${scripts.length ? `, ${plural(scripts.length, "new script")} (${list(scripts)})` : ""}${locks.length ? `, lockfile ${list(locks)}` : ""}; ${DEPENDENCY_BUMP_EVIDENCE} is its evidence`;
|
|
16390
|
+
}
|
|
15679
16391
|
function computeLane(input) {
|
|
15680
|
-
const
|
|
16392
|
+
const extra = input.riskPaths ?? [];
|
|
16393
|
+
const additive = input.files.filter((file) => additiveWorkflow(file, extra));
|
|
16394
|
+
const relaxed = new Set(additive.map((file) => file.path));
|
|
16395
|
+
const workflowNote = additive.length ? [
|
|
16396
|
+
`additive workflow edit: ${additive.slice(0, 3).map((file) => `${file.path} (${file.workflow?.detail ?? ""})`).join(", ")}${additive.length > 3 ? ", …" : ""}`
|
|
16397
|
+
] : [];
|
|
16398
|
+
const riskFiles = input.files.filter((file) => isRiskPath(file.path, extra) && !relaxed.has(file.path)).map((file) => file.path);
|
|
15681
16399
|
const risky = new Set(riskFiles);
|
|
15682
16400
|
const kinds = input.files.map((file) => ({
|
|
15683
16401
|
file,
|
|
@@ -15688,20 +16406,30 @@ function computeLane(input) {
|
|
|
15688
16406
|
const opaque = behavior.filter((entry) => entry.kind === "lockfile" || entry.file.binary);
|
|
15689
16407
|
const diffLines = input.files.reduce((sum, file) => sum + file.added + file.deleted, 0);
|
|
15690
16408
|
const counted = diffLines === lines && input.files.length === behavior.length ? "" : ` counted (the whole diff is ${plural(diffLines, "line")} in ${plural(input.files.length, "file")}; docs, comments, formatting, generated copies and lockfile lines are not counted)`;
|
|
15691
|
-
const result = (lane, reasons) =>
|
|
15692
|
-
lane
|
|
15693
|
-
|
|
15694
|
-
|
|
15695
|
-
|
|
15696
|
-
|
|
15697
|
-
|
|
16409
|
+
const result = (lane, reasons, classification) => {
|
|
16410
|
+
const floor = additive.length > 0 && !classification && (lane === "none" || lane === "self");
|
|
16411
|
+
return {
|
|
16412
|
+
lane: floor ? "focused" : lane,
|
|
16413
|
+
reasons: [...floor ? [ADDITIVE_CI_FLOOR] : [], ...reasons, ...workflowNote],
|
|
16414
|
+
lines,
|
|
16415
|
+
files: behavior.length,
|
|
16416
|
+
riskFiles,
|
|
16417
|
+
...classification ? { classification } : {}
|
|
16418
|
+
};
|
|
16419
|
+
};
|
|
15698
16420
|
const { selfMaxLines, selfMaxFiles, fullMinLines } = LANE_THRESHOLDS;
|
|
15699
16421
|
if (input.riskTier === "high")
|
|
15700
16422
|
return result("full", ["the task judgment records high risk"]);
|
|
15701
16423
|
if (riskFiles.length)
|
|
15702
16424
|
return result("full", [
|
|
15703
|
-
`touches a risk path: ${riskFiles.slice(0, 3).
|
|
16425
|
+
`touches a risk path: ${riskFiles.slice(0, 3).map((file) => {
|
|
16426
|
+
const refused = input.files.find((entry) => entry.path === file)?.workflow;
|
|
16427
|
+
return refused && !refused.additive ? `${file} (${refused.detail})` : file;
|
|
16428
|
+
}).join(", ")}${riskFiles.length > 3 ? ", …" : ""}`
|
|
15704
16429
|
]);
|
|
16430
|
+
const bump = dependencyBump(input.files, relaxed);
|
|
16431
|
+
if (bump && lines < fullMinLines)
|
|
16432
|
+
return result("self", [bump], "dependency-bump");
|
|
15705
16433
|
if (!behavior.length)
|
|
15706
16434
|
return result("none", [
|
|
15707
16435
|
input.files.length ? "only docs, comments, formatting or generated copies changed" : "no changes"
|
|
@@ -15748,6 +16476,7 @@ function cosmeticFiles(cwd, fork, head) {
|
|
|
15748
16476
|
return null;
|
|
15749
16477
|
const out = new Set;
|
|
15750
16478
|
const opaque = new Set;
|
|
16479
|
+
const facts = new Map;
|
|
15751
16480
|
for (const entry of candidates) {
|
|
15752
16481
|
const before = blobs.get(entry.oldBlob);
|
|
15753
16482
|
let after = blobs.get(entry.newBlob);
|
|
@@ -15757,12 +16486,20 @@ function cosmeticFiles(cwd, fork, head) {
|
|
|
15757
16486
|
} catch {
|
|
15758
16487
|
after = undefined;
|
|
15759
16488
|
}
|
|
16489
|
+
if (before && after && isWorkflowFile(entry.path))
|
|
16490
|
+
facts.set(entry.path, {
|
|
16491
|
+
workflow: workflowEdit(before.toString("utf8"), after.toString("utf8"))
|
|
16492
|
+
});
|
|
16493
|
+
else if (before && after && isManifest(entry.path))
|
|
16494
|
+
facts.set(entry.path, {
|
|
16495
|
+
manifest: manifestEdit(entry.path, before.toString("utf8"), after.toString("utf8"))
|
|
16496
|
+
});
|
|
15760
16497
|
if (before && after && cosmeticChange(entry.path, before, after))
|
|
15761
16498
|
out.add(entry.path);
|
|
15762
16499
|
else if ([before, after].some((bytes) => bytes && hasOpaqueLineBreak(bytes.toString("utf8"))))
|
|
15763
16500
|
opaque.add(entry.path);
|
|
15764
16501
|
}
|
|
15765
|
-
return { cosmetic: out, opaque };
|
|
16502
|
+
return { cosmetic: out, opaque, facts };
|
|
15766
16503
|
}
|
|
15767
16504
|
function generatedAt(cwd, fork, paths) {
|
|
15768
16505
|
const files = treeFilesNamed(cwd, fork, ".gitattributes");
|
|
@@ -15787,7 +16524,8 @@ function laneFiles(cwd, fork, head, attributesAt = fork) {
|
|
|
15787
16524
|
...stats.map((entry) => ({
|
|
15788
16525
|
...entry,
|
|
15789
16526
|
...cosmetic.opaque.has(entry.path) ? { binary: true } : {},
|
|
15790
|
-
cosmetic: !entry.binary && cosmetic.cosmetic.has(entry.path)
|
|
16527
|
+
cosmetic: !entry.binary && cosmetic.cosmetic.has(entry.path),
|
|
16528
|
+
...cosmetic.facts.get(entry.path)
|
|
15791
16529
|
})),
|
|
15792
16530
|
...head === null ? untrackedFiles(cwd).map((file) => untrackedStat(cwd, file)) : []
|
|
15793
16531
|
];
|
|
@@ -16237,10 +16975,10 @@ function appendObserved(cwd, row, options = {}) {
|
|
|
16237
16975
|
function appendHookObserved(cwd, row) {
|
|
16238
16976
|
return appendRaw(cwd, { ...row, observer: "host_hook" }, {});
|
|
16239
16977
|
}
|
|
16240
|
-
var
|
|
16978
|
+
var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16241
16979
|
var str2 = (value) => typeof value === "string" ? value : null;
|
|
16242
16980
|
var normalizeActor = (value) => {
|
|
16243
|
-
const actor =
|
|
16981
|
+
const actor = isRecord4(value) ? value : {};
|
|
16244
16982
|
return {
|
|
16245
16983
|
host: str2(actor.host) ?? "unknown",
|
|
16246
16984
|
session: str2(actor.session),
|
|
@@ -16304,7 +17042,7 @@ function readLedgerAt(cwd, file, options) {
|
|
|
16304
17042
|
skipped += 1;
|
|
16305
17043
|
continue;
|
|
16306
17044
|
}
|
|
16307
|
-
if (!
|
|
17045
|
+
if (!isRecord4(parsed) || !str2(parsed.id) || !str2(parsed.type) || !str2(parsed.at)) {
|
|
16308
17046
|
skipped += 1;
|
|
16309
17047
|
continue;
|
|
16310
17048
|
}
|
|
@@ -18387,6 +19125,7 @@ function selectMethods(policy, capabilities) {
|
|
|
18387
19125
|
return [{ id, reason: reasons.join("; "), assurance: capability.assurance }];
|
|
18388
19126
|
});
|
|
18389
19127
|
}
|
|
19128
|
+
var FEEDBACK_LINE = "Workit friction: offer `workit feedback` once per problem; keep working.";
|
|
18390
19129
|
var BOOTSTRAP = `
|
|
18391
19130
|
Workit is optional coordination and proof tooling: you decide what and
|
|
18392
19131
|
whether, the CLI does how and records what it observed.
|
|
@@ -18441,6 +19180,7 @@ effect before a retry.
|
|
|
18441
19180
|
Mid-task: never silently drop or resume an objective (workit-continue).
|
|
18442
19181
|
Notes, drafts, logs, resume files: \`workit dir notes|handoffs\` (outside the
|
|
18443
19182
|
repo), never the repo tree.
|
|
19183
|
+
FEEDBACK_LINE
|
|
18444
19184
|
|
|
18445
19185
|
Skills: load the skill, never act from memory.
|
|
18446
19186
|
- brainstorm, plan, spec, grill, should we: workit-shape
|
|
@@ -18458,9 +19198,13 @@ Skills: load the skill, never act from memory.
|
|
|
18458
19198
|
- architecture, deepen modules (user-invoked; offer it): workit-architecture
|
|
18459
19199
|
`.trim();
|
|
18460
19200
|
var invariantBootstrap = (session = null) => {
|
|
19201
|
+
const feedbackOff = session !== null && workspaceFeedbackOff(session.cwd);
|
|
19202
|
+
const bootstrap = BOOTSTRAP.replace(`FEEDBACK_LINE
|
|
19203
|
+
`, () => feedbackOff ? "" : `${FEEDBACK_LINE}
|
|
19204
|
+
`);
|
|
18461
19205
|
const table = session && hostFamily(session.host) === "claude_code" ? claudeSpawnTable(session.cwd) : null;
|
|
18462
|
-
return table ? `${
|
|
18463
|
-
${table}` :
|
|
19206
|
+
return table ? `${bootstrap}
|
|
19207
|
+
${table}` : bootstrap;
|
|
18464
19208
|
};
|
|
18465
19209
|
|
|
18466
19210
|
// packages/workit-core/src/core/task-context.ts
|
|
@@ -19132,14 +19876,14 @@ var SCOPE_FIELDS = new Set([
|
|
|
19132
19876
|
|
|
19133
19877
|
// packages/workit-core/src/core/release-packages.ts
|
|
19134
19878
|
var KNOWN_FIELDS2 = new Set(["tagNamespace", "changelogPath"]);
|
|
19135
|
-
var
|
|
19879
|
+
var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19136
19880
|
var NAMESPACE = /^[A-Za-z@][\w.@/+-]*$/u;
|
|
19137
19881
|
var validTagNamespace = (value) => NAMESPACE.test(value) && !value.includes("..") && !value.includes("@{") && !value.includes("//") && !value.endsWith(".lock") && !/\d$/u.test(value);
|
|
19138
19882
|
function readReleasePackages(raw) {
|
|
19139
19883
|
const out = { packages: [], issues: [] };
|
|
19140
19884
|
if (raw === undefined || raw === null)
|
|
19141
19885
|
return out;
|
|
19142
|
-
if (!
|
|
19886
|
+
if (!isRecord5(raw)) {
|
|
19143
19887
|
out.issues.push("releasePackages is not an object; ignored");
|
|
19144
19888
|
return out;
|
|
19145
19889
|
}
|
|
@@ -19150,7 +19894,7 @@ function readReleasePackages(raw) {
|
|
|
19150
19894
|
out.issues.push(`${label}: a blank or padded name; ignored`);
|
|
19151
19895
|
continue;
|
|
19152
19896
|
}
|
|
19153
|
-
if (!
|
|
19897
|
+
if (!isRecord5(entry)) {
|
|
19154
19898
|
out.issues.push(`${label} is not an object; ignored`);
|
|
19155
19899
|
continue;
|
|
19156
19900
|
}
|
|
@@ -25051,7 +25795,8 @@ var WORKIT_USER_ONLY = [
|
|
|
25051
25795
|
["install"],
|
|
25052
25796
|
["workspace", "seal"]
|
|
25053
25797
|
];
|
|
25054
|
-
var
|
|
25798
|
+
var WORKIT_ASKED_VERBS = ["feedback"];
|
|
25799
|
+
var USER_ONLY_WORD = new RegExp(`\\b(?:${[...new Set([...WORKIT_USER_ONLY.map((words) => words[0]), ...WORKIT_ASKED_VERBS])].join("|")})\\b`);
|
|
25055
25800
|
var mayRunUserOnly = (text) => {
|
|
25056
25801
|
const joined = text.replace(/\\\r?\n/g, "");
|
|
25057
25802
|
const bare = joined.replace(/['"\\]/g, "");
|
|
@@ -25146,7 +25891,7 @@ var readText3 = (file) => {
|
|
|
25146
25891
|
throw error;
|
|
25147
25892
|
}
|
|
25148
25893
|
};
|
|
25149
|
-
var
|
|
25894
|
+
var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25150
25895
|
function parseJsonc(text) {
|
|
25151
25896
|
let out = "";
|
|
25152
25897
|
for (let index = 0;index < text.length; index += 1) {
|
|
@@ -25220,12 +25965,12 @@ function claudeRules(cwd, env = process.env) {
|
|
|
25220
25965
|
if (text === null)
|
|
25221
25966
|
continue;
|
|
25222
25967
|
const value = JSON.parse(text);
|
|
25223
|
-
if (!
|
|
25968
|
+
if (!isRecord6(value))
|
|
25224
25969
|
return "unreadable";
|
|
25225
25970
|
const permissions = value.permissions;
|
|
25226
25971
|
if (permissions === undefined)
|
|
25227
25972
|
continue;
|
|
25228
|
-
if (!
|
|
25973
|
+
if (!isRecord6(permissions))
|
|
25229
25974
|
return "unreadable";
|
|
25230
25975
|
for (const [key, bucket] of [
|
|
25231
25976
|
["deny", rules.deny],
|
|
@@ -25259,7 +26004,7 @@ var opencodePermission = (permission, rules) => {
|
|
|
25259
26004
|
(permission === "allow" ? rules.allow : rules.deny).push("");
|
|
25260
26005
|
return ["allow", "ask", "deny"].includes(permission);
|
|
25261
26006
|
}
|
|
25262
|
-
if (!
|
|
26007
|
+
if (!isRecord6(permission))
|
|
25263
26008
|
return false;
|
|
25264
26009
|
for (const key of ["bash", "shell"]) {
|
|
25265
26010
|
const value = permission[key];
|
|
@@ -25271,7 +26016,7 @@ var opencodePermission = (permission, rules) => {
|
|
|
25271
26016
|
(value === "allow" ? rules.allow : rules.deny).push("");
|
|
25272
26017
|
continue;
|
|
25273
26018
|
}
|
|
25274
|
-
if (!
|
|
26019
|
+
if (!isRecord6(value))
|
|
25275
26020
|
return false;
|
|
25276
26021
|
for (const [pattern, action] of Object.entries(value)) {
|
|
25277
26022
|
if (action !== "allow" && action !== "ask" && action !== "deny")
|
|
@@ -25289,7 +26034,7 @@ var opencodeRuleset = (ruleset, rules) => {
|
|
|
25289
26034
|
if (!Array.isArray(ruleset))
|
|
25290
26035
|
return false;
|
|
25291
26036
|
for (const rule of ruleset) {
|
|
25292
|
-
if (!
|
|
26037
|
+
if (!isRecord6(rule))
|
|
25293
26038
|
return false;
|
|
25294
26039
|
const { action, resource, effect } = rule;
|
|
25295
26040
|
if (typeof action !== "string" || typeof resource !== "string")
|
|
@@ -25304,11 +26049,11 @@ var opencodeRuleset = (ruleset, rules) => {
|
|
|
25304
26049
|
var opencodeAgents = (agents, read) => {
|
|
25305
26050
|
if (agents === undefined)
|
|
25306
26051
|
return true;
|
|
25307
|
-
if (!
|
|
26052
|
+
if (!isRecord6(agents))
|
|
25308
26053
|
return false;
|
|
25309
|
-
return Object.values(agents).every((agent) =>
|
|
26054
|
+
return Object.values(agents).every((agent) => isRecord6(agent) && read(agent));
|
|
25310
26055
|
};
|
|
25311
|
-
var opencodeConfig = (value, rules) =>
|
|
26056
|
+
var opencodeConfig = (value, rules) => isRecord6(value) && opencodeRuleset(value.permissions, rules) && opencodePermission(value.permission, rules) && opencodeAgents(value.agents, (agent) => opencodeRuleset(agent.permissions, rules)) && opencodeAgents(value.agent, (agent) => opencodePermission(agent.permission, rules));
|
|
25312
26057
|
function opencodeRules(cwd, env = process.env) {
|
|
25313
26058
|
const rules = EMPTY2();
|
|
25314
26059
|
try {
|
|
@@ -25397,11 +26142,11 @@ function cursorRules(cwd, env = process.env) {
|
|
|
25397
26142
|
if (text === null)
|
|
25398
26143
|
continue;
|
|
25399
26144
|
const value = JSON.parse(text);
|
|
25400
|
-
if (!
|
|
26145
|
+
if (!isRecord6(value))
|
|
25401
26146
|
return "unreadable";
|
|
25402
26147
|
if (value.permissions === undefined)
|
|
25403
26148
|
continue;
|
|
25404
|
-
if (!
|
|
26149
|
+
if (!isRecord6(value.permissions))
|
|
25405
26150
|
return "unreadable";
|
|
25406
26151
|
for (const [key, bucket] of [
|
|
25407
26152
|
["deny", rules.deny],
|
|
@@ -25826,11 +26571,11 @@ var readJson = (file) => {
|
|
|
25826
26571
|
return;
|
|
25827
26572
|
}
|
|
25828
26573
|
};
|
|
25829
|
-
var
|
|
26574
|
+
var isRecord7 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25830
26575
|
var stringList = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
25831
26576
|
function machinePatterns(env) {
|
|
25832
26577
|
const value = readJson(heavyCommandsFile(env));
|
|
25833
|
-
return
|
|
26578
|
+
return isRecord7(value) ? stringList(value.patterns) : [];
|
|
25834
26579
|
}
|
|
25835
26580
|
function repoPatterns(cwd) {
|
|
25836
26581
|
return repoHeavyCommands(gitTop(cwd) ?? path38.resolve(cwd));
|
|
@@ -28107,11 +28852,11 @@ var workitSkillOf = (name) => {
|
|
|
28107
28852
|
const skill = bare.replace(/^workit:/, "workit-");
|
|
28108
28853
|
return WORKIT_METHOD_SKILLS.includes(skill) ? skill : null;
|
|
28109
28854
|
};
|
|
28110
|
-
var
|
|
28855
|
+
var QUOTED2 = /```[\s\S]*?```|["`“][^"`”\n]*["`”]|\B'[^'\n]*'\B/g;
|
|
28111
28856
|
var COMPLAINT = /\b(why \w+ you|you keep|stop \w+ing)\b.*?(?=\b(and|but)\b|[?.,;\n]|$)/gi;
|
|
28112
28857
|
var promptTrigger = (prompt) => {
|
|
28113
28858
|
let asking = false;
|
|
28114
|
-
const text = prompt.slice(0, 4000).replace(
|
|
28859
|
+
const text = prompt.slice(0, 4000).replace(QUOTED2, " ").replace(COMPLAINT, (clause) => (asking ||= /ask|quest/i.test(clause), " "));
|
|
28115
28860
|
for (const [skill, pattern] of PROMPT_INTENTS) {
|
|
28116
28861
|
const match = !(asking && skill === "workit-shape") && pattern.exec(text);
|
|
28117
28862
|
if (match)
|
|
@@ -30004,7 +30749,7 @@ import { existsSync as existsSync18, readFileSync as readFileSync14, readdirSync
|
|
|
30004
30749
|
import path48 from "node:path";
|
|
30005
30750
|
var repoRoot3 = assetRoot();
|
|
30006
30751
|
var templatesDir = () => path48.join(repoRoot3, "templates", "hygiene");
|
|
30007
|
-
var
|
|
30752
|
+
var packageJson2 = (root) => {
|
|
30008
30753
|
if (!existsSync18(path48.join(root, "package.json")))
|
|
30009
30754
|
return null;
|
|
30010
30755
|
try {
|
|
@@ -30016,13 +30761,13 @@ var packageJson = (root) => {
|
|
|
30016
30761
|
var isOpenSource = (root) => {
|
|
30017
30762
|
if (existsSync18(path48.join(root, "LICENSE")))
|
|
30018
30763
|
return true;
|
|
30019
|
-
const pkg =
|
|
30764
|
+
const pkg = packageJson2(root);
|
|
30020
30765
|
if (pkg && !pkg.private)
|
|
30021
30766
|
return true;
|
|
30022
30767
|
return path48.basename(root) === "workit";
|
|
30023
30768
|
};
|
|
30024
30769
|
var licenseHolder = (root) => {
|
|
30025
|
-
const pkg =
|
|
30770
|
+
const pkg = packageJson2(root);
|
|
30026
30771
|
if (pkg) {
|
|
30027
30772
|
const author = pkg.author;
|
|
30028
30773
|
if (typeof author === "string" && author.trim())
|
|
@@ -31113,7 +31858,7 @@ function normalizePattern(raw) {
|
|
|
31113
31858
|
return { error: "has unbalanced or nested braces" };
|
|
31114
31859
|
return { pattern };
|
|
31115
31860
|
}
|
|
31116
|
-
var
|
|
31861
|
+
var isRecord9 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31117
31862
|
function findCycle(slices) {
|
|
31118
31863
|
const byId = new Map(slices.map((slice) => [slice.id, slice]));
|
|
31119
31864
|
const state = new Map;
|
|
@@ -31199,7 +31944,7 @@ function fanoutsDir(cwd) {
|
|
|
31199
31944
|
return { ok: true, data: path56.join(root.value.root, "fanouts") };
|
|
31200
31945
|
}
|
|
31201
31946
|
function parseStored(raw) {
|
|
31202
|
-
if (!
|
|
31947
|
+
if (!isRecord9(raw) || typeof raw.name !== "string" || typeof raw.trunk !== "string")
|
|
31203
31948
|
return null;
|
|
31204
31949
|
if (!Array.isArray(raw.slices))
|
|
31205
31950
|
return null;
|
|
@@ -31216,7 +31961,7 @@ function parseStored(raw) {
|
|
|
31216
31961
|
});
|
|
31217
31962
|
const slices = [];
|
|
31218
31963
|
for (const item of raw.slices) {
|
|
31219
|
-
if (!
|
|
31964
|
+
if (!isRecord9(item) || typeof item.id !== "string" || typeof item.branch !== "string")
|
|
31220
31965
|
return null;
|
|
31221
31966
|
slices.push({
|
|
31222
31967
|
id: item.id,
|
|
@@ -31937,15 +32682,23 @@ var createV2Lifecycle = (deps) => {
|
|
|
31937
32682
|
|
|
31938
32683
|
// packages/workit-opencode/src/bootstrap.ts
|
|
31939
32684
|
var OPENCODE_ADDENDUM = "On OpenCode, run external mutations with native host tools or the workit CLI; workit_context is read-only and there is no managed external-action executor, so do not create proposals or request Workit approvals merely to invoke native tools. Record a meaningful user choice with workit_decision directly; it needs no question.";
|
|
31940
|
-
var cached2;
|
|
31941
|
-
var
|
|
31942
|
-
|
|
31943
|
-
|
|
31944
|
-
|
|
31945
|
-
|
|
32685
|
+
var cached2 = new Map;
|
|
32686
|
+
var CACHE_DIRS = 32;
|
|
32687
|
+
var getWorkitBootstrap = (cwd = process.cwd()) => {
|
|
32688
|
+
const hit = cached2.get(cwd);
|
|
32689
|
+
if (hit !== undefined) {
|
|
32690
|
+
cached2.delete(cwd);
|
|
32691
|
+
cached2.set(cwd, hit);
|
|
32692
|
+
return hit;
|
|
32693
|
+
}
|
|
32694
|
+
const block = `<workit-contract>
|
|
32695
|
+
${invariantBootstrap({ cwd, host: "opencode" })}
|
|
31946
32696
|
${OPENCODE_ADDENDUM}
|
|
31947
32697
|
</workit-contract>`;
|
|
31948
|
-
|
|
32698
|
+
cached2.set(cwd, block);
|
|
32699
|
+
if (cached2.size > CACHE_DIRS)
|
|
32700
|
+
cached2.delete(cached2.keys().next().value);
|
|
32701
|
+
return block;
|
|
31949
32702
|
};
|
|
31950
32703
|
|
|
31951
32704
|
// packages/workit-opencode/src/runtime.ts
|
|
@@ -32010,7 +32763,7 @@ var hasMarker = (system, marker) => system.some((part) => part.type === "text" &
|
|
|
32010
32763
|
var injectAgentContext = (root, session, directChildren, system) => {
|
|
32011
32764
|
if (!session || !sameWorkspace(root, session.directory))
|
|
32012
32765
|
return;
|
|
32013
|
-
const bootstrap = session.parentID === undefined ? getWorkitBootstrap() : null;
|
|
32766
|
+
const bootstrap = session.parentID === undefined ? getWorkitBootstrap(session.directory ?? root) : null;
|
|
32014
32767
|
const taskContext = compactContextFor(root, session.id);
|
|
32015
32768
|
const workerContext = session.parentID ? workerContextFor(root, session.id, session.parentID, directChildren) : null;
|
|
32016
32769
|
if (bootstrap && !hasMarker(system, "<workit-contract>"))
|
|
@@ -32060,7 +32813,7 @@ var judgeVerdictText = (root, session, workerContext) => {
|
|
|
32060
32813
|
var injectModelSwitch = (root, session, directChildren, system) => {
|
|
32061
32814
|
if (!session || !sameWorkspace(root, session.directory))
|
|
32062
32815
|
return;
|
|
32063
|
-
const contract = session.parentID ? workerContextFor(root, session.id, session.parentID, directChildren) : getWorkitBootstrap();
|
|
32816
|
+
const contract = session.parentID ? workerContextFor(root, session.id, session.parentID, directChildren) : getWorkitBootstrap(session.directory ?? root);
|
|
32064
32817
|
const taskContext = compactContextFor(root, session.id);
|
|
32065
32818
|
const parts = [
|
|
32066
32819
|
contract,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/opencode",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.20.0",
|
|
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.0.18",
|
|
44
|
-
"@workit-dev/core": "^2.
|
|
44
|
+
"@workit-dev/core": "^2.20.0"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=24"
|