@workit-dev/opencode 2.19.0 → 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/dist/plugin.js +770 -42
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -15259,6 +15259,203 @@ function generatedByAttributes(files, paths) {
|
|
|
15259
15259
|
return out;
|
|
15260
15260
|
}
|
|
15261
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
|
+
|
|
15262
15459
|
// packages/workit-core/src/core/policy/substance.ts
|
|
15263
15460
|
var SLASH_BLOCK = [["/*", "*/"]];
|
|
15264
15461
|
var C_LIKE = { line: ["//"], block: SLASH_BLOCK, quotes: `"'` };
|
|
@@ -15577,6 +15774,483 @@ function cosmeticChange(file, before, after) {
|
|
|
15577
15774
|
return a !== null && a === substanceOf(file, right);
|
|
15578
15775
|
}
|
|
15579
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
|
+
|
|
15580
16254
|
// packages/workit-core/src/core/policy/lane.ts
|
|
15581
16255
|
var LANE_THRESHOLDS = {
|
|
15582
16256
|
selfMaxLines: 100,
|
|
@@ -15637,15 +16311,16 @@ var DOC_EXT = /\.(?:md|mdx|markdown|rst|adoc)$/iu;
|
|
|
15637
16311
|
var DOC_NAMES = /^(?:license|licence|notice|authors|changelog|changes|contributors)$/iu;
|
|
15638
16312
|
var INSTRUCTIONS = /(?:^|\/)(?:AGENTS|CLAUDE|GEMINI|SKILL)\.md$|(?:^|\/)(?:skills|agents|commands|rules|prompts)\/[^/]+/iu;
|
|
15639
16313
|
var TEST_PATH = /(?:^|\/)(?:test|tests|__tests__)\/|\.(?:test|spec)\.[^/]+$|_test\.[^/]+$/iu;
|
|
16314
|
+
var DEPENDENCY_BUMP_EVIDENCE = "green CI on the head";
|
|
15640
16315
|
var plural = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
|
|
15641
|
-
var
|
|
15642
|
-
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)));
|
|
15643
16318
|
function kindOf(file) {
|
|
15644
16319
|
if (file.binary)
|
|
15645
16320
|
return "behavior";
|
|
15646
16321
|
if (file.generated)
|
|
15647
16322
|
return "generated";
|
|
15648
|
-
if (LOCKFILES.has(
|
|
16323
|
+
if (LOCKFILES.has(basename2(file.path)))
|
|
15649
16324
|
return "lockfile";
|
|
15650
16325
|
if (isDoc(file.path))
|
|
15651
16326
|
return "doc";
|
|
@@ -15678,7 +16353,7 @@ function globMatch(pattern, file) {
|
|
|
15678
16353
|
function isRiskPath(file, extra = []) {
|
|
15679
16354
|
if (extra.some((pattern) => globMatch(pattern, file)))
|
|
15680
16355
|
return true;
|
|
15681
|
-
if (RISK_FILES.has(file) || RISK_NAMES.has(
|
|
16356
|
+
if (RISK_FILES.has(file) || RISK_NAMES.has(basename2(file)))
|
|
15682
16357
|
return true;
|
|
15683
16358
|
if (TEST_PATH.test(file) || isDoc(file))
|
|
15684
16359
|
return false;
|
|
@@ -15686,8 +16361,41 @@ function isRiskPath(file, extra = []) {
|
|
|
15686
16361
|
}
|
|
15687
16362
|
var parseRiskPaths = (text) => text.split(`
|
|
15688
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
|
+
}
|
|
15689
16391
|
function computeLane(input) {
|
|
15690
|
-
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);
|
|
15691
16399
|
const risky = new Set(riskFiles);
|
|
15692
16400
|
const kinds = input.files.map((file) => ({
|
|
15693
16401
|
file,
|
|
@@ -15698,20 +16406,30 @@ function computeLane(input) {
|
|
|
15698
16406
|
const opaque = behavior.filter((entry) => entry.kind === "lockfile" || entry.file.binary);
|
|
15699
16407
|
const diffLines = input.files.reduce((sum, file) => sum + file.added + file.deleted, 0);
|
|
15700
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)`;
|
|
15701
|
-
const result = (lane, reasons) =>
|
|
15702
|
-
lane
|
|
15703
|
-
|
|
15704
|
-
|
|
15705
|
-
|
|
15706
|
-
|
|
15707
|
-
|
|
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
|
+
};
|
|
15708
16420
|
const { selfMaxLines, selfMaxFiles, fullMinLines } = LANE_THRESHOLDS;
|
|
15709
16421
|
if (input.riskTier === "high")
|
|
15710
16422
|
return result("full", ["the task judgment records high risk"]);
|
|
15711
16423
|
if (riskFiles.length)
|
|
15712
16424
|
return result("full", [
|
|
15713
|
-
`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 ? ", …" : ""}`
|
|
15714
16429
|
]);
|
|
16430
|
+
const bump = dependencyBump(input.files, relaxed);
|
|
16431
|
+
if (bump && lines < fullMinLines)
|
|
16432
|
+
return result("self", [bump], "dependency-bump");
|
|
15715
16433
|
if (!behavior.length)
|
|
15716
16434
|
return result("none", [
|
|
15717
16435
|
input.files.length ? "only docs, comments, formatting or generated copies changed" : "no changes"
|
|
@@ -15758,6 +16476,7 @@ function cosmeticFiles(cwd, fork, head) {
|
|
|
15758
16476
|
return null;
|
|
15759
16477
|
const out = new Set;
|
|
15760
16478
|
const opaque = new Set;
|
|
16479
|
+
const facts = new Map;
|
|
15761
16480
|
for (const entry of candidates) {
|
|
15762
16481
|
const before = blobs.get(entry.oldBlob);
|
|
15763
16482
|
let after = blobs.get(entry.newBlob);
|
|
@@ -15767,12 +16486,20 @@ function cosmeticFiles(cwd, fork, head) {
|
|
|
15767
16486
|
} catch {
|
|
15768
16487
|
after = undefined;
|
|
15769
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
|
+
});
|
|
15770
16497
|
if (before && after && cosmeticChange(entry.path, before, after))
|
|
15771
16498
|
out.add(entry.path);
|
|
15772
16499
|
else if ([before, after].some((bytes) => bytes && hasOpaqueLineBreak(bytes.toString("utf8"))))
|
|
15773
16500
|
opaque.add(entry.path);
|
|
15774
16501
|
}
|
|
15775
|
-
return { cosmetic: out, opaque };
|
|
16502
|
+
return { cosmetic: out, opaque, facts };
|
|
15776
16503
|
}
|
|
15777
16504
|
function generatedAt(cwd, fork, paths) {
|
|
15778
16505
|
const files = treeFilesNamed(cwd, fork, ".gitattributes");
|
|
@@ -15797,7 +16524,8 @@ function laneFiles(cwd, fork, head, attributesAt = fork) {
|
|
|
15797
16524
|
...stats.map((entry) => ({
|
|
15798
16525
|
...entry,
|
|
15799
16526
|
...cosmetic.opaque.has(entry.path) ? { binary: true } : {},
|
|
15800
|
-
cosmetic: !entry.binary && cosmetic.cosmetic.has(entry.path)
|
|
16527
|
+
cosmetic: !entry.binary && cosmetic.cosmetic.has(entry.path),
|
|
16528
|
+
...cosmetic.facts.get(entry.path)
|
|
15801
16529
|
})),
|
|
15802
16530
|
...head === null ? untrackedFiles(cwd).map((file) => untrackedStat(cwd, file)) : []
|
|
15803
16531
|
];
|
|
@@ -16247,10 +16975,10 @@ function appendObserved(cwd, row, options = {}) {
|
|
|
16247
16975
|
function appendHookObserved(cwd, row) {
|
|
16248
16976
|
return appendRaw(cwd, { ...row, observer: "host_hook" }, {});
|
|
16249
16977
|
}
|
|
16250
|
-
var
|
|
16978
|
+
var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16251
16979
|
var str2 = (value) => typeof value === "string" ? value : null;
|
|
16252
16980
|
var normalizeActor = (value) => {
|
|
16253
|
-
const actor =
|
|
16981
|
+
const actor = isRecord4(value) ? value : {};
|
|
16254
16982
|
return {
|
|
16255
16983
|
host: str2(actor.host) ?? "unknown",
|
|
16256
16984
|
session: str2(actor.session),
|
|
@@ -16314,7 +17042,7 @@ function readLedgerAt(cwd, file, options) {
|
|
|
16314
17042
|
skipped += 1;
|
|
16315
17043
|
continue;
|
|
16316
17044
|
}
|
|
16317
|
-
if (!
|
|
17045
|
+
if (!isRecord4(parsed) || !str2(parsed.id) || !str2(parsed.type) || !str2(parsed.at)) {
|
|
16318
17046
|
skipped += 1;
|
|
16319
17047
|
continue;
|
|
16320
17048
|
}
|
|
@@ -19148,14 +19876,14 @@ var SCOPE_FIELDS = new Set([
|
|
|
19148
19876
|
|
|
19149
19877
|
// packages/workit-core/src/core/release-packages.ts
|
|
19150
19878
|
var KNOWN_FIELDS2 = new Set(["tagNamespace", "changelogPath"]);
|
|
19151
|
-
var
|
|
19879
|
+
var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19152
19880
|
var NAMESPACE = /^[A-Za-z@][\w.@/+-]*$/u;
|
|
19153
19881
|
var validTagNamespace = (value) => NAMESPACE.test(value) && !value.includes("..") && !value.includes("@{") && !value.includes("//") && !value.endsWith(".lock") && !/\d$/u.test(value);
|
|
19154
19882
|
function readReleasePackages(raw) {
|
|
19155
19883
|
const out = { packages: [], issues: [] };
|
|
19156
19884
|
if (raw === undefined || raw === null)
|
|
19157
19885
|
return out;
|
|
19158
|
-
if (!
|
|
19886
|
+
if (!isRecord5(raw)) {
|
|
19159
19887
|
out.issues.push("releasePackages is not an object; ignored");
|
|
19160
19888
|
return out;
|
|
19161
19889
|
}
|
|
@@ -19166,7 +19894,7 @@ function readReleasePackages(raw) {
|
|
|
19166
19894
|
out.issues.push(`${label}: a blank or padded name; ignored`);
|
|
19167
19895
|
continue;
|
|
19168
19896
|
}
|
|
19169
|
-
if (!
|
|
19897
|
+
if (!isRecord5(entry)) {
|
|
19170
19898
|
out.issues.push(`${label} is not an object; ignored`);
|
|
19171
19899
|
continue;
|
|
19172
19900
|
}
|
|
@@ -25163,7 +25891,7 @@ var readText3 = (file) => {
|
|
|
25163
25891
|
throw error;
|
|
25164
25892
|
}
|
|
25165
25893
|
};
|
|
25166
|
-
var
|
|
25894
|
+
var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25167
25895
|
function parseJsonc(text) {
|
|
25168
25896
|
let out = "";
|
|
25169
25897
|
for (let index = 0;index < text.length; index += 1) {
|
|
@@ -25237,12 +25965,12 @@ function claudeRules(cwd, env = process.env) {
|
|
|
25237
25965
|
if (text === null)
|
|
25238
25966
|
continue;
|
|
25239
25967
|
const value = JSON.parse(text);
|
|
25240
|
-
if (!
|
|
25968
|
+
if (!isRecord6(value))
|
|
25241
25969
|
return "unreadable";
|
|
25242
25970
|
const permissions = value.permissions;
|
|
25243
25971
|
if (permissions === undefined)
|
|
25244
25972
|
continue;
|
|
25245
|
-
if (!
|
|
25973
|
+
if (!isRecord6(permissions))
|
|
25246
25974
|
return "unreadable";
|
|
25247
25975
|
for (const [key, bucket] of [
|
|
25248
25976
|
["deny", rules.deny],
|
|
@@ -25276,7 +26004,7 @@ var opencodePermission = (permission, rules) => {
|
|
|
25276
26004
|
(permission === "allow" ? rules.allow : rules.deny).push("");
|
|
25277
26005
|
return ["allow", "ask", "deny"].includes(permission);
|
|
25278
26006
|
}
|
|
25279
|
-
if (!
|
|
26007
|
+
if (!isRecord6(permission))
|
|
25280
26008
|
return false;
|
|
25281
26009
|
for (const key of ["bash", "shell"]) {
|
|
25282
26010
|
const value = permission[key];
|
|
@@ -25288,7 +26016,7 @@ var opencodePermission = (permission, rules) => {
|
|
|
25288
26016
|
(value === "allow" ? rules.allow : rules.deny).push("");
|
|
25289
26017
|
continue;
|
|
25290
26018
|
}
|
|
25291
|
-
if (!
|
|
26019
|
+
if (!isRecord6(value))
|
|
25292
26020
|
return false;
|
|
25293
26021
|
for (const [pattern, action] of Object.entries(value)) {
|
|
25294
26022
|
if (action !== "allow" && action !== "ask" && action !== "deny")
|
|
@@ -25306,7 +26034,7 @@ var opencodeRuleset = (ruleset, rules) => {
|
|
|
25306
26034
|
if (!Array.isArray(ruleset))
|
|
25307
26035
|
return false;
|
|
25308
26036
|
for (const rule of ruleset) {
|
|
25309
|
-
if (!
|
|
26037
|
+
if (!isRecord6(rule))
|
|
25310
26038
|
return false;
|
|
25311
26039
|
const { action, resource, effect } = rule;
|
|
25312
26040
|
if (typeof action !== "string" || typeof resource !== "string")
|
|
@@ -25321,11 +26049,11 @@ var opencodeRuleset = (ruleset, rules) => {
|
|
|
25321
26049
|
var opencodeAgents = (agents, read) => {
|
|
25322
26050
|
if (agents === undefined)
|
|
25323
26051
|
return true;
|
|
25324
|
-
if (!
|
|
26052
|
+
if (!isRecord6(agents))
|
|
25325
26053
|
return false;
|
|
25326
|
-
return Object.values(agents).every((agent) =>
|
|
26054
|
+
return Object.values(agents).every((agent) => isRecord6(agent) && read(agent));
|
|
25327
26055
|
};
|
|
25328
|
-
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));
|
|
25329
26057
|
function opencodeRules(cwd, env = process.env) {
|
|
25330
26058
|
const rules = EMPTY2();
|
|
25331
26059
|
try {
|
|
@@ -25414,11 +26142,11 @@ function cursorRules(cwd, env = process.env) {
|
|
|
25414
26142
|
if (text === null)
|
|
25415
26143
|
continue;
|
|
25416
26144
|
const value = JSON.parse(text);
|
|
25417
|
-
if (!
|
|
26145
|
+
if (!isRecord6(value))
|
|
25418
26146
|
return "unreadable";
|
|
25419
26147
|
if (value.permissions === undefined)
|
|
25420
26148
|
continue;
|
|
25421
|
-
if (!
|
|
26149
|
+
if (!isRecord6(value.permissions))
|
|
25422
26150
|
return "unreadable";
|
|
25423
26151
|
for (const [key, bucket] of [
|
|
25424
26152
|
["deny", rules.deny],
|
|
@@ -25843,11 +26571,11 @@ var readJson = (file) => {
|
|
|
25843
26571
|
return;
|
|
25844
26572
|
}
|
|
25845
26573
|
};
|
|
25846
|
-
var
|
|
26574
|
+
var isRecord7 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25847
26575
|
var stringList = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
25848
26576
|
function machinePatterns(env) {
|
|
25849
26577
|
const value = readJson(heavyCommandsFile(env));
|
|
25850
|
-
return
|
|
26578
|
+
return isRecord7(value) ? stringList(value.patterns) : [];
|
|
25851
26579
|
}
|
|
25852
26580
|
function repoPatterns(cwd) {
|
|
25853
26581
|
return repoHeavyCommands(gitTop(cwd) ?? path38.resolve(cwd));
|
|
@@ -28124,11 +28852,11 @@ var workitSkillOf = (name) => {
|
|
|
28124
28852
|
const skill = bare.replace(/^workit:/, "workit-");
|
|
28125
28853
|
return WORKIT_METHOD_SKILLS.includes(skill) ? skill : null;
|
|
28126
28854
|
};
|
|
28127
|
-
var
|
|
28855
|
+
var QUOTED2 = /```[\s\S]*?```|["`“][^"`”\n]*["`”]|\B'[^'\n]*'\B/g;
|
|
28128
28856
|
var COMPLAINT = /\b(why \w+ you|you keep|stop \w+ing)\b.*?(?=\b(and|but)\b|[?.,;\n]|$)/gi;
|
|
28129
28857
|
var promptTrigger = (prompt) => {
|
|
28130
28858
|
let asking = false;
|
|
28131
|
-
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), " "));
|
|
28132
28860
|
for (const [skill, pattern] of PROMPT_INTENTS) {
|
|
28133
28861
|
const match = !(asking && skill === "workit-shape") && pattern.exec(text);
|
|
28134
28862
|
if (match)
|
|
@@ -30021,7 +30749,7 @@ import { existsSync as existsSync18, readFileSync as readFileSync14, readdirSync
|
|
|
30021
30749
|
import path48 from "node:path";
|
|
30022
30750
|
var repoRoot3 = assetRoot();
|
|
30023
30751
|
var templatesDir = () => path48.join(repoRoot3, "templates", "hygiene");
|
|
30024
|
-
var
|
|
30752
|
+
var packageJson2 = (root) => {
|
|
30025
30753
|
if (!existsSync18(path48.join(root, "package.json")))
|
|
30026
30754
|
return null;
|
|
30027
30755
|
try {
|
|
@@ -30033,13 +30761,13 @@ var packageJson = (root) => {
|
|
|
30033
30761
|
var isOpenSource = (root) => {
|
|
30034
30762
|
if (existsSync18(path48.join(root, "LICENSE")))
|
|
30035
30763
|
return true;
|
|
30036
|
-
const pkg =
|
|
30764
|
+
const pkg = packageJson2(root);
|
|
30037
30765
|
if (pkg && !pkg.private)
|
|
30038
30766
|
return true;
|
|
30039
30767
|
return path48.basename(root) === "workit";
|
|
30040
30768
|
};
|
|
30041
30769
|
var licenseHolder = (root) => {
|
|
30042
|
-
const pkg =
|
|
30770
|
+
const pkg = packageJson2(root);
|
|
30043
30771
|
if (pkg) {
|
|
30044
30772
|
const author = pkg.author;
|
|
30045
30773
|
if (typeof author === "string" && author.trim())
|
|
@@ -31130,7 +31858,7 @@ function normalizePattern(raw) {
|
|
|
31130
31858
|
return { error: "has unbalanced or nested braces" };
|
|
31131
31859
|
return { pattern };
|
|
31132
31860
|
}
|
|
31133
|
-
var
|
|
31861
|
+
var isRecord9 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31134
31862
|
function findCycle(slices) {
|
|
31135
31863
|
const byId = new Map(slices.map((slice) => [slice.id, slice]));
|
|
31136
31864
|
const state = new Map;
|
|
@@ -31216,7 +31944,7 @@ function fanoutsDir(cwd) {
|
|
|
31216
31944
|
return { ok: true, data: path56.join(root.value.root, "fanouts") };
|
|
31217
31945
|
}
|
|
31218
31946
|
function parseStored(raw) {
|
|
31219
|
-
if (!
|
|
31947
|
+
if (!isRecord9(raw) || typeof raw.name !== "string" || typeof raw.trunk !== "string")
|
|
31220
31948
|
return null;
|
|
31221
31949
|
if (!Array.isArray(raw.slices))
|
|
31222
31950
|
return null;
|
|
@@ -31233,7 +31961,7 @@ function parseStored(raw) {
|
|
|
31233
31961
|
});
|
|
31234
31962
|
const slices = [];
|
|
31235
31963
|
for (const item of raw.slices) {
|
|
31236
|
-
if (!
|
|
31964
|
+
if (!isRecord9(item) || typeof item.id !== "string" || typeof item.branch !== "string")
|
|
31237
31965
|
return null;
|
|
31238
31966
|
slices.push({
|
|
31239
31967
|
id: item.id,
|
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"
|