@workit-dev/pi 2.19.0 → 2.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.js CHANGED
@@ -8172,6 +8172,15 @@ import { createHash as createHash3, randomBytes } from "node:crypto";
8172
8172
  import fs7 from "node:fs";
8173
8173
  import path10 from "node:path";
8174
8174
 
8175
+ // packages/workit-core/src/core/policy/dep-bump.ts
8176
+ var MANIFESTS = new Set(["package.json", "go.mod", "Cargo.toml", "pyproject.toml"]);
8177
+ var DEP_FIELDS = new Set([
8178
+ "dependencies",
8179
+ "devDependencies",
8180
+ "peerDependencies",
8181
+ "optionalDependencies"
8182
+ ]);
8183
+
8175
8184
  // packages/workit-core/src/core/policy/substance.ts
8176
8185
  var SLASH_BLOCK = [["/*", "*/"]];
8177
8186
  var C_LIKE = { line: ["//"], block: SLASH_BLOCK, quotes: `"'` };
@@ -8214,6 +8223,11 @@ var REGEX_KEYWORDS = new Set([
8214
8223
  ]);
8215
8224
  var decoder = new TextDecoder("utf-8", { fatal: true });
8216
8225
 
8226
+ // packages/workit-core/src/core/policy/workflow-edit.ts
8227
+ var GUARDED = new Set(["permissions", "secrets", "on", "uses", "environment", "if"]);
8228
+ 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(" "));
8229
+ var FALLBACK = new Set(["echo", "true"]);
8230
+
8217
8231
  // packages/workit-core/src/core/policy/lane.ts
8218
8232
  var RISK_TOKENS = new Set([
8219
8233
  "auth",
package/dist/workit.js CHANGED
@@ -15003,6 +15003,203 @@ function generatedByAttributes(files, paths) {
15003
15003
  return out;
15004
15004
  }
15005
15005
 
15006
+ // packages/workit-core/src/core/policy/dep-bump.ts
15007
+ var MANIFESTS = new Set(["package.json", "go.mod", "Cargo.toml", "pyproject.toml"]);
15008
+ var basename = (file) => file.slice(file.lastIndexOf("/") + 1);
15009
+ var isManifest = (file) => MANIFESTS.has(basename(file));
15010
+ var refused = (why) => ({ pins: false, bumped: 0, scripts: [], why });
15011
+ var pinned = (bumped, scripts = []) => ({
15012
+ pins: true,
15013
+ bumped,
15014
+ scripts,
15015
+ why: ""
15016
+ });
15017
+ var DEP_FIELDS = new Set([
15018
+ "dependencies",
15019
+ "devDependencies",
15020
+ "peerDependencies",
15021
+ "optionalDependencies"
15022
+ ]);
15023
+ var NPM_COMPARATOR = /^(?:[~^]|[<>]=?|=)?v?\d+(?:\.(?:\d+|x|\*)){0,2}(?:-[\da-z.-]+)?(?:\+[\da-z.-]+)?$/iu;
15024
+ function npmVersion(spec) {
15025
+ if (spec.length > 256)
15026
+ return false;
15027
+ return spec.split("||").every((set) => {
15028
+ const tokens = set.trim().replace(/([<>]=?|=|[~^])\s+/gu, "$1").split(/\s+/u);
15029
+ if (tokens.length === 3 && tokens[1] === "-")
15030
+ return NPM_COMPARATOR.test(tokens[0] ?? "") && NPM_COMPARATOR.test(tokens[2] ?? "");
15031
+ return tokens.every((token) => NPM_COMPARATOR.test(token));
15032
+ });
15033
+ }
15034
+ var HOOK_SCRIPT = /^(?:pre|post)|^(?:install|uninstall|prepare|publish|pack|version|dependencies|start|stop|restart|test)$/u;
15035
+ var isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
15036
+ var same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
15037
+ function packageJson(before, after) {
15038
+ let old;
15039
+ let now;
15040
+ try {
15041
+ old = JSON.parse(before);
15042
+ now = JSON.parse(after);
15043
+ } catch {
15044
+ return refused("does not parse");
15045
+ }
15046
+ if (!isRecord3(old) || !isRecord3(now))
15047
+ return refused("is no JSON object");
15048
+ let bumped = 0;
15049
+ const scripts = [];
15050
+ for (const field of new Set([...Object.keys(old), ...Object.keys(now)])) {
15051
+ const a = old[field];
15052
+ const b = now[field];
15053
+ if (same(a, b))
15054
+ continue;
15055
+ if (DEP_FIELDS.has(field)) {
15056
+ if (!isRecord3(a) || !isRecord3(b))
15057
+ return refused(`changes ${field}`);
15058
+ for (const name of new Set([...Object.keys(a), ...Object.keys(b)])) {
15059
+ if (a[name] === b[name])
15060
+ continue;
15061
+ if (!(name in a))
15062
+ return refused(`adds the dependency ${name}`);
15063
+ if (!(name in b))
15064
+ return refused(`removes the dependency ${name}`);
15065
+ const from = a[name];
15066
+ const to = b[name];
15067
+ if (typeof from !== "string" || typeof to !== "string")
15068
+ return refused(`changes ${field}.${name}`);
15069
+ if (!npmVersion(from.trim()) || !npmVersion(to.trim()))
15070
+ return refused(`changes the source of ${name}`);
15071
+ bumped += 1;
15072
+ }
15073
+ } else if (field === "scripts") {
15074
+ if (!isRecord3(a) || !isRecord3(b))
15075
+ return refused("changes scripts");
15076
+ for (const name of Object.keys(a))
15077
+ if (a[name] !== b[name])
15078
+ return refused(`changes the script ${name}`);
15079
+ for (const name of Object.keys(b)) {
15080
+ if (name in a)
15081
+ continue;
15082
+ if (HOOK_SCRIPT.test(name))
15083
+ return refused(`adds the lifecycle script ${name}`);
15084
+ if (name.startsWith("pnpm:"))
15085
+ return refused(`adds the pnpm: script ${name}`);
15086
+ const runner = Object.entries(a).find(([, command]) => typeof command === "string" && runsByGlob(command, name));
15087
+ if (runner)
15088
+ return refused(`adds the script ${name}, which the script ${runner[0]} runs by glob`);
15089
+ scripts.push(name);
15090
+ }
15091
+ } else
15092
+ return refused(`changes ${field}`);
15093
+ }
15094
+ return pinned(bumped, scripts);
15095
+ }
15096
+ function runsByGlob(command, name) {
15097
+ const tokens = command.split(/\s+/u).map((token) => token.replace(/^--filter=/u, "").replaceAll(/^["']|["']$/gu, "").replace(/^(?:npm|pnpm|yarn|bun):/u, ""));
15098
+ if (/\bpnpm\b/u.test(command) && tokens.some((token) => /^\/.+\/$/u.test(token)))
15099
+ return true;
15100
+ return tokens.filter((token) => token.includes("*")).some((glob) => new RegExp(`^${glob.split(/\*+/u).map((part) => part.replaceAll(/[.+?^${}()|[\]\\]/gu, "\\$&")).join(".*")}$`, "u").test(name));
15101
+ }
15102
+ function goDirectives(text) {
15103
+ const out = [];
15104
+ let block = null;
15105
+ for (const raw of text.split(`
15106
+ `)) {
15107
+ const indirect = /\/\/\s*indirect\s*$/u.test(raw);
15108
+ const line = raw.replace(/\/\/.*$/u, "").trim();
15109
+ if (!line)
15110
+ continue;
15111
+ if (block !== null) {
15112
+ if (line === ")")
15113
+ block = null;
15114
+ else
15115
+ out.push({ verb: block, args: line.replace(/\s+/gu, " "), indirect });
15116
+ continue;
15117
+ }
15118
+ const match = /^(\S+)\s*(.*)$/u.exec(line);
15119
+ if (!match)
15120
+ return null;
15121
+ const [, verb = "", rest = ""] = match;
15122
+ if (rest === "(")
15123
+ block = verb;
15124
+ else
15125
+ out.push({ verb, args: rest.replace(/\s+/gu, " "), indirect });
15126
+ }
15127
+ return block === null ? out : null;
15128
+ }
15129
+ var GO_VERSION = /^v\d+\.\d+\.\d+(?:-[\w.-]+)?(?:\+incompatible)?$/u;
15130
+ function goMod(before, after) {
15131
+ const old = goDirectives(before);
15132
+ const now = goDirectives(after);
15133
+ if (!old || !now)
15134
+ return refused("does not parse");
15135
+ if (old.length !== now.length)
15136
+ return refused("adds or removes a directive");
15137
+ let bumped = 0;
15138
+ for (const [index, a] of old.entries()) {
15139
+ const b = now[index];
15140
+ if (a.verb === b.verb && a.args === b.args && a.indirect === b.indirect)
15141
+ continue;
15142
+ if (a.verb !== "require" || b.verb !== "require" || a.indirect !== b.indirect)
15143
+ return refused(`changes ${a.verb}`);
15144
+ const [module, from, extra] = a.args.split(" ");
15145
+ const [moduleAfter, to, extraAfter] = b.args.split(" ");
15146
+ if (module !== moduleAfter || extra !== undefined || extraAfter !== undefined)
15147
+ return refused(`changes require ${module ?? ""}`);
15148
+ if (!GO_VERSION.test(from ?? "") || !GO_VERSION.test(to ?? ""))
15149
+ return refused(`changes the source of ${module ?? ""}`);
15150
+ bumped += 1;
15151
+ }
15152
+ return pinned(bumped);
15153
+ }
15154
+ var CARGO_TABLE = /^(?:workspace\.)?(?:target\..+\.)?(?:dev-|build-)?dependencies(?:\.[^.]+)?$/u;
15155
+ var PYPROJECT_TABLE = /^(?:project\.optional-dependencies|dependency-groups|tool\.poetry\.(?:dev-)?dependencies|tool\.poetry\.group\.[^.]+\.dependencies)$/u;
15156
+ var OTHER_SOURCE = /\b(?:git|rev|branch|tag|path|url|registry|package)\s*=|@|:\/\//u;
15157
+ var VERSION_TOKEN = /(?<=[\s"'=<>~^!,*v])\d+(?:\.\d+)*(?:[a-z]+\d*)?(?:\.(?:post|dev)\d+)?/giu;
15158
+ function tomlPins(before, after, cargo) {
15159
+ const old = before.split(`
15160
+ `);
15161
+ const now = after.split(`
15162
+ `);
15163
+ if (old.length !== now.length)
15164
+ return refused("adds or removes lines");
15165
+ let table = "";
15166
+ let inArray = false;
15167
+ let bumped = 0;
15168
+ for (const [index, a] of old.entries()) {
15169
+ const b = now[index] ?? "";
15170
+ const header = /^\s*\[\[?([^\]]+)\]\]?\s*(?:#.*)?$/u.exec(a);
15171
+ if (header) {
15172
+ table = (header[1] ?? "").replace(/\s+/gu, "");
15173
+ inArray = false;
15174
+ } else if (!cargo && table === "project" && /^\s*dependencies\s*=\s*\[\s*(?:#.*)?$/u.test(a))
15175
+ inArray = true;
15176
+ else if (inArray && /^\s*\]/u.test(a))
15177
+ inArray = false;
15178
+ if (a === b)
15179
+ continue;
15180
+ const listed = cargo ? CARGO_TABLE.test(table) : PYPROJECT_TABLE.test(table) || inArray || table === "project" && /^\s*dependencies\s*=/u.test(a);
15181
+ if (header || !listed)
15182
+ return refused(`changes line ${index + 1} outside a dependency table`);
15183
+ if (OTHER_SOURCE.test(a) || OTHER_SOURCE.test(b))
15184
+ return refused(`changes a dependency source on line ${index + 1}`);
15185
+ const key = (line) => /^\s*("?[\w.[\],-]+"?)/u.exec(line)?.[1] ?? "";
15186
+ const versionless = (line) => line.replace(VERSION_TOKEN, "V");
15187
+ const names = (line) => cargo ? "" : [...line.matchAll(/"([A-Za-z_][\w.-]*)/gu)].map((match) => match[1]).join(",");
15188
+ if (key(a) !== key(b) || names(a) !== names(b) || versionless(a) !== versionless(b))
15189
+ return refused(`changes more than a version on line ${index + 1}`);
15190
+ bumped += 1;
15191
+ }
15192
+ return pinned(bumped);
15193
+ }
15194
+ function manifestEdit(file, before, after) {
15195
+ const name = basename(file);
15196
+ if (name === "package.json")
15197
+ return packageJson(before, after);
15198
+ if (name === "go.mod")
15199
+ return goMod(before, after);
15200
+ return tomlPins(before, after, name === "Cargo.toml");
15201
+ }
15202
+
15006
15203
  // packages/workit-core/src/core/policy/substance.ts
15007
15204
  var SLASH_BLOCK = [["/*", "*/"]];
15008
15205
  var C_LIKE = { line: ["//"], block: SLASH_BLOCK, quotes: `"'` };
@@ -15321,6 +15518,483 @@ function cosmeticChange(file, before, after) {
15321
15518
  return a !== null && a === substanceOf(file, right);
15322
15519
  }
15323
15520
 
15521
+ // packages/workit-core/src/core/policy/workflow-edit.ts
15522
+ class Unparsed extends Error {
15523
+ }
15524
+ var refuse = (why) => {
15525
+ throw new Unparsed(why);
15526
+ };
15527
+ 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;
15528
+ var HEX_DIGITS = { x: 2, u: 4, U: 8 };
15529
+ var ESCAPES = {
15530
+ n: `
15531
+ `,
15532
+ t: "\t",
15533
+ r: "\r",
15534
+ "0": "\x00",
15535
+ '"': '"',
15536
+ "\\": "\\",
15537
+ "/": "/",
15538
+ " ": " "
15539
+ };
15540
+ var scalar = (text, string, folded = false) => ({
15541
+ kind: "scalar",
15542
+ text,
15543
+ string,
15544
+ folded
15545
+ });
15546
+ function quoted(text, start) {
15547
+ const quote = text[start];
15548
+ let out = "";
15549
+ for (let index = start + 1;index < text.length; index += 1) {
15550
+ const char = text[index] ?? "";
15551
+ if (quote === "'" && char === "'") {
15552
+ if (text[index + 1] !== "'")
15553
+ return { value: out, end: index + 1 };
15554
+ out += "'";
15555
+ index += 1;
15556
+ } else if (quote === '"' && char === '"')
15557
+ return { value: out, end: index + 1 };
15558
+ else if (quote === '"' && char === "\\") {
15559
+ const next = text[index + 1] ?? "";
15560
+ const hex = HEX_DIGITS[next];
15561
+ if (hex) {
15562
+ const digits = text.slice(index + 2, index + 2 + hex);
15563
+ if (!/^[\da-f]+$/iu.test(digits) || digits.length !== hex)
15564
+ refuse("a bad escape");
15565
+ out += String.fromCodePoint(Number.parseInt(digits, 16));
15566
+ index += 1 + hex;
15567
+ } else {
15568
+ out += ESCAPES[next] ?? refuse("an unknown escape");
15569
+ index += 1;
15570
+ }
15571
+ } else
15572
+ out += char;
15573
+ }
15574
+ return refuse("a quoted scalar spans lines");
15575
+ }
15576
+ function trailing(text, end) {
15577
+ const rest = text.slice(end);
15578
+ if (rest.trim() && !/^\s+#/u.test(rest))
15579
+ refuse("text after a value");
15580
+ }
15581
+ var INDICATOR = /^[&*!%@`|>,[\]{}?:#-]/u;
15582
+ function plain(text) {
15583
+ const value = text.replace(/\s+#.*$/u, "").trimEnd();
15584
+ if (INDICATOR.test(value) && !/^-[^\s]/u.test(value))
15585
+ refuse("an indicator starts a scalar");
15586
+ if (/:\s|:$/u.test(value))
15587
+ refuse("a mapping inside a scalar");
15588
+ return scalar(value, !NON_STRING.test(value));
15589
+ }
15590
+ function flow(text, start) {
15591
+ const close = text[start] === "[" ? "]" : "}";
15592
+ const items = [];
15593
+ const entries = new Map;
15594
+ let index = start + 1;
15595
+ const skip = () => {
15596
+ while (text[index] === " ")
15597
+ index += 1;
15598
+ };
15599
+ const element = (stops) => {
15600
+ skip();
15601
+ const char = text[index];
15602
+ if (char === '"' || char === "'") {
15603
+ const read = quoted(text, index);
15604
+ index = read.end;
15605
+ return scalar(read.value, true);
15606
+ }
15607
+ if (char === "[" || char === "{") {
15608
+ const read = flow(text, index);
15609
+ index = read.end;
15610
+ return read.node;
15611
+ }
15612
+ let end = index;
15613
+ while (end < text.length && !stops.test(text[end] ?? ""))
15614
+ end += 1;
15615
+ const value = text.slice(index, end).trim();
15616
+ index = end;
15617
+ if (!value || value.includes("#"))
15618
+ refuse("an empty or commented flow element");
15619
+ return plain(value);
15620
+ };
15621
+ for (;; ) {
15622
+ skip();
15623
+ if (index >= text.length)
15624
+ refuse("a flow collection spans lines");
15625
+ if (text[index] === close)
15626
+ return {
15627
+ node: close === "]" ? { kind: "seq", items } : { kind: "map", entries },
15628
+ end: index + 1
15629
+ };
15630
+ if (close === "]")
15631
+ items.push(element(/[,\]]/u));
15632
+ else {
15633
+ const key = element(/[:,}]/u);
15634
+ skip();
15635
+ if (text[index] !== ":" || key.kind !== "scalar")
15636
+ refuse("a flow mapping without a value");
15637
+ index += 1;
15638
+ const value = element(/[,}]/u);
15639
+ const name = key.kind === "scalar" ? key.text : "";
15640
+ if (entries.has(name))
15641
+ refuse("a duplicate key");
15642
+ entries.set(name, value);
15643
+ }
15644
+ skip();
15645
+ if (text[index] === ",")
15646
+ index += 1;
15647
+ else if (text[index] !== close)
15648
+ refuse("a malformed flow collection");
15649
+ }
15650
+ }
15651
+ var isItem = (text) => text === "-" || text.startsWith("- ");
15652
+ function splitKey(text) {
15653
+ if (text[0] === '"' || text[0] === "'") {
15654
+ const read = quoted(text, 0);
15655
+ const after = text.slice(read.end);
15656
+ const match = /^\s*:(?:\s+|$)/u.exec(after);
15657
+ return match ? { key: read.value, rest: after.slice(match[0].length) } : null;
15658
+ }
15659
+ const match = /:(?:\s|$)/u.exec(text);
15660
+ if (!match || INDICATOR.test(text))
15661
+ return null;
15662
+ const key = text.slice(0, match.index).trimEnd();
15663
+ if (!key || key.includes(" #"))
15664
+ return null;
15665
+ return { key, rest: text.slice(match.index + 1).trimStart() };
15666
+ }
15667
+
15668
+ class Reader {
15669
+ lines;
15670
+ pos = 0;
15671
+ constructor(text) {
15672
+ const normal = text.replace(/\r\n/gu, `
15673
+ `);
15674
+ if (normal.includes("\r") || normal.charCodeAt(0) === 65279)
15675
+ refuse("an odd line break or BOM");
15676
+ this.lines = normal.split(`
15677
+ `);
15678
+ const first = this.lines.findIndex((line) => line.trim() && !line.trimStart().startsWith("#"));
15679
+ if (first >= 0 && /^---\s*(?:#.*)?$/u.test(this.lines[first] ?? ""))
15680
+ this.lines[first] = "";
15681
+ }
15682
+ next() {
15683
+ while (this.pos < this.lines.length) {
15684
+ const raw = this.lines[this.pos] ?? "";
15685
+ const text = raw.trimStart();
15686
+ if (text === "" || text.startsWith("#")) {
15687
+ this.pos += 1;
15688
+ continue;
15689
+ }
15690
+ const indent = raw.length - text.length;
15691
+ if (raw.slice(0, indent).includes("\t"))
15692
+ refuse("a tab indents a line");
15693
+ if (indent === 0 && /^(?:---|\.\.\.)(?:\s|$)|^%/u.test(text))
15694
+ refuse("several documents");
15695
+ return { indent, text: text.trimEnd() };
15696
+ }
15697
+ return null;
15698
+ }
15699
+ document() {
15700
+ const root = this.block(0);
15701
+ if (this.next())
15702
+ refuse("content after the document");
15703
+ return root;
15704
+ }
15705
+ block(min) {
15706
+ const line = this.next();
15707
+ if (!line || line.indent < min)
15708
+ return scalar("", false);
15709
+ return isItem(line.text) ? this.sequence(line.indent) : this.mapping(line.indent);
15710
+ }
15711
+ mapping(indent) {
15712
+ const entries = new Map;
15713
+ for (let line = this.next();line && line.indent >= indent; line = this.next()) {
15714
+ if (line.indent > indent || isItem(line.text))
15715
+ refuse("bad indentation");
15716
+ const split = splitKey(line.text) ?? refuse("a line that is no mapping entry");
15717
+ if (entries.has(split.key))
15718
+ refuse("a duplicate key");
15719
+ this.pos += 1;
15720
+ entries.set(split.key, this.value(split.rest, indent, true));
15721
+ }
15722
+ return { kind: "map", entries };
15723
+ }
15724
+ sequence(indent) {
15725
+ const items = [];
15726
+ for (let line = this.next();line && line.indent === indent && isItem(line.text); line = this.next()) {
15727
+ const rest = line.text.slice(1).trimStart();
15728
+ const offset = indent + line.text.length - rest.length;
15729
+ if (isItem(rest))
15730
+ refuse("a sequence inside a sequence item");
15731
+ if (rest && !/^[|>[{]/u.test(rest) && splitKey(rest)) {
15732
+ this.lines[this.pos] = " ".repeat(offset) + rest;
15733
+ items.push(this.mapping(offset));
15734
+ } else {
15735
+ this.pos += 1;
15736
+ items.push(this.value(rest, indent, false));
15737
+ }
15738
+ }
15739
+ const line = this.next();
15740
+ if (line && line.indent > indent)
15741
+ refuse("bad indentation");
15742
+ return { kind: "seq", items };
15743
+ }
15744
+ value(rest, indent, inMapping) {
15745
+ if (rest === "" || rest.startsWith("#")) {
15746
+ const line = this.next();
15747
+ if (line && line.indent > indent)
15748
+ return this.block(line.indent);
15749
+ if (inMapping && line?.indent === indent && isItem(line.text))
15750
+ return this.sequence(indent);
15751
+ return scalar("", false);
15752
+ }
15753
+ let node;
15754
+ if (rest[0] === "|" || rest[0] === ">")
15755
+ return this.blockScalar(rest, indent);
15756
+ if (rest[0] === '"' || rest[0] === "'") {
15757
+ const read = quoted(rest, 0);
15758
+ trailing(rest, read.end);
15759
+ node = scalar(read.value, true);
15760
+ } else if (rest[0] === "[" || rest[0] === "{") {
15761
+ const read = flow(rest, 0);
15762
+ trailing(rest, read.end);
15763
+ node = read.node;
15764
+ } else
15765
+ node = plain(rest);
15766
+ const line = this.next();
15767
+ if (line && line.indent > indent)
15768
+ refuse("a value continues on the next line");
15769
+ return node;
15770
+ }
15771
+ blockScalar(header, indent) {
15772
+ const match = /^([|>])(?:([-+])([1-9])?|([1-9])([-+])?)?\s*(?:#.*)?$/u.exec(header);
15773
+ if (!match)
15774
+ return refuse("a bad block scalar header");
15775
+ const chomp = match[2] ?? match[5] ?? "";
15776
+ const indicator = match[3] ?? match[4];
15777
+ let column = indicator ? indent + Number(indicator) : null;
15778
+ const body = [];
15779
+ while (this.pos < this.lines.length) {
15780
+ const raw = this.lines[this.pos] ?? "";
15781
+ if (raw.trim() === "") {
15782
+ body.push(column !== null && raw.length > column ? raw.slice(column) : "");
15783
+ this.pos += 1;
15784
+ continue;
15785
+ }
15786
+ const lead = raw.length - raw.trimStart().length;
15787
+ if (column === null) {
15788
+ if (lead <= indent)
15789
+ break;
15790
+ column = lead;
15791
+ }
15792
+ if (lead < column) {
15793
+ if (lead > indent)
15794
+ refuse("an under-indented block line");
15795
+ break;
15796
+ }
15797
+ if (raw.slice(0, column).includes("\t"))
15798
+ refuse("a tab indents a line");
15799
+ body.push(raw.slice(column));
15800
+ this.pos += 1;
15801
+ }
15802
+ let end = body.length;
15803
+ while (end > 0 && body[end - 1] === "")
15804
+ end -= 1;
15805
+ const content = body.slice(0, end).join(`
15806
+ `);
15807
+ const text = chomp === "+" ? `${body.join(`
15808
+ `)}
15809
+ ` : chomp === "-" || !content ? content : `${content}
15810
+ `;
15811
+ return scalar(text, true, match[1] === ">");
15812
+ }
15813
+ }
15814
+ function parseWorkflowYaml(text) {
15815
+ try {
15816
+ return new Reader(text).document();
15817
+ } catch (error) {
15818
+ if (error instanceof Unparsed)
15819
+ return null;
15820
+ throw error;
15821
+ }
15822
+ }
15823
+ var isWorkflowFile = (file) => /^\.github\/workflows\/[^/]+\.ya?ml$/u.test(file);
15824
+ var GUARDED = new Set(["permissions", "secrets", "on", "uses", "environment", "if"]);
15825
+ var pathText = (keys) => keys.join(".").replaceAll(".[", "[");
15826
+ var WORD2 = /[\w./:@=+,-]+/uy;
15827
+ var QUOTED = /"[^"$`\\]*"/uy;
15828
+ var COMMAND = /^[\w.+][\w./+-]*$/u;
15829
+ 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(" "));
15830
+ var FALLBACK = new Set(["echo", "true"]);
15831
+ var FORM = 'more than && <command> or && (<command> || echo "<text>")';
15832
+ var OUTSIDE = '(outside plain words and "double-quoted text")';
15833
+ var COMMAND_INPUT = /(?:^|[-_])(?:commands?|cmd|script)$/iu;
15834
+ function tokens2(text) {
15835
+ const out = [];
15836
+ let index = 0;
15837
+ while (index < text.length) {
15838
+ const char = text[index] ?? "";
15839
+ if (char === " " || char === "\t")
15840
+ index += 1;
15841
+ else if (char === "(" || char === ")") {
15842
+ out.push({ op: char });
15843
+ index += 1;
15844
+ } else if ((char === "&" || char === "|") && text[index + 1] === char) {
15845
+ out.push({ op: char + char });
15846
+ index += 2;
15847
+ } else {
15848
+ const pattern = char === '"' ? QUOTED : WORD2;
15849
+ pattern.lastIndex = index;
15850
+ const match = pattern.exec(text);
15851
+ if (!match)
15852
+ return char === '"' ? 'a "quoted text" left open or holding $, a backtick or a backslash' : `the character ${char} ${OUTSIDE}`;
15853
+ index += match[0].length;
15854
+ const next = text[index] ?? " ";
15855
+ if (!" \t)&|".includes(next))
15856
+ return `the character ${next} ${OUTSIDE}`;
15857
+ out.push(char === '"' ? { quoted: match[0] } : { word: match[0] });
15858
+ }
15859
+ }
15860
+ return out;
15861
+ }
15862
+ function masking(before, appended) {
15863
+ if (appended.includes("${{"))
15864
+ return "an expression";
15865
+ if (/[\n\r]/u.test(appended))
15866
+ return "a new line";
15867
+ if (!before.trim())
15868
+ return "a command where none ran before";
15869
+ if (before.endsWith("\\"))
15870
+ return "a command after a trailing backslash";
15871
+ if (!appended.trimStart().startsWith("&&"))
15872
+ return "a command not chained with a leading &&";
15873
+ const list = tokens2(appended);
15874
+ if (typeof list === "string")
15875
+ return list;
15876
+ let index = 0;
15877
+ const op = (text) => {
15878
+ const token = list[index];
15879
+ if (!token || !("op" in token) || token.op !== text)
15880
+ return false;
15881
+ index += 1;
15882
+ return true;
15883
+ };
15884
+ const command = (names) => {
15885
+ const name = list[index];
15886
+ if (!name || !("word" in name) || !COMMAND.test(name.word))
15887
+ return FORM;
15888
+ if (names ? !names.has(name.word) : SHELL_STATE.has(name.word.toLowerCase()))
15889
+ return names ? FORM : `the shell command ${name.word}`;
15890
+ index += 1;
15891
+ for (let token = list[index];token && !("op" in token); token = list[index])
15892
+ index += 1;
15893
+ return null;
15894
+ };
15895
+ while (index < list.length) {
15896
+ if (!op("&&"))
15897
+ return FORM;
15898
+ const group = op("(");
15899
+ const bad = command() ?? (group && op("||") ? command(FALLBACK) : null);
15900
+ if (bad)
15901
+ return bad;
15902
+ if (group && !op(")"))
15903
+ return FORM;
15904
+ }
15905
+ return null;
15906
+ }
15907
+ function compare(before, after, at, room, out) {
15908
+ if (before.kind === "scalar" && after.kind === "scalar") {
15909
+ if (before.text === after.text && before.string === after.string)
15910
+ return;
15911
+ const grown = room !== null && before.string && after.string && before.folded === after.folded && after.text.length > before.text.length && after.text.startsWith(before.text);
15912
+ const masks = grown ? masking(before.text, after.text.slice(before.text.length)) : null;
15913
+ if (masks)
15914
+ out.refused.push({ path: at, what: `appends ${masks} to ${pathText(at)}` });
15915
+ else if (grown)
15916
+ out.allowed.push(`${pathText(at)} appended`);
15917
+ else
15918
+ out.refused.push({ path: at, what: `changes ${pathText(at)}` });
15919
+ return;
15920
+ }
15921
+ if (before.kind === "seq" && after.kind === "seq") {
15922
+ if (before.items.length !== after.items.length) {
15923
+ const fewer = after.items.length < before.items.length;
15924
+ const noun = at.at(-1) === "steps" ? "a step" : "an item";
15925
+ out.refused.push({
15926
+ path: at,
15927
+ what: `${fewer ? "removes" : "adds"} ${noun} ${fewer ? "from" : "to"} ${pathText(at)}`
15928
+ });
15929
+ return;
15930
+ }
15931
+ before.items.forEach((item, index) => compare(item, after.items[index], [...at, `[${index}]`], null, out));
15932
+ return;
15933
+ }
15934
+ if (before.kind === "map" && after.kind === "map") {
15935
+ const step = at.at(-2) === "steps";
15936
+ const job = at.length === 2 && at[0] === "jobs";
15937
+ const usesBoth = before.entries.has("uses") && after.entries.has("uses");
15938
+ for (const [key, value] of before.entries) {
15939
+ const next = after.entries.get(key);
15940
+ if (!next) {
15941
+ out.refused.push({
15942
+ path: [...at, key],
15943
+ what: at.length === 1 && at[0] === "jobs" ? `removes the job ${key}` : `removes ${pathText([...at, key])}`
15944
+ });
15945
+ continue;
15946
+ }
15947
+ if (key === "with" && job && usesBoth && value.kind === "map" && next.kind === "map")
15948
+ compareInputs(value, next, [...at, key], out);
15949
+ else
15950
+ compare(value, next, [...at, key], key === "run" && step ? "run" : null, out);
15951
+ }
15952
+ for (const [key] of after.entries)
15953
+ if (!before.entries.has(key))
15954
+ out.refused.push({ path: [...at, key], what: `adds ${pathText([...at, key])}` });
15955
+ return;
15956
+ }
15957
+ out.refused.push({ path: at, what: `changes the shape of ${pathText(at) || "the file"}` });
15958
+ }
15959
+ function compareInputs(before, after, at, out) {
15960
+ for (const [key, value] of before.entries) {
15961
+ const next = after.entries.get(key);
15962
+ if (next)
15963
+ compare(value, next, [...at, key], COMMAND_INPUT.test(key) ? "with" : null, out);
15964
+ else
15965
+ out.refused.push({ path: [...at, key], what: `removes ${pathText([...at, key])}` });
15966
+ }
15967
+ for (const [key] of after.entries)
15968
+ if (!before.entries.has(key))
15969
+ out.refused.push({ path: [...at, key], what: `adds the input ${pathText([...at, key])}` });
15970
+ }
15971
+ function decisive(refused) {
15972
+ for (const change of refused) {
15973
+ const key = change.path.find((part) => GUARDED.has(part));
15974
+ if (key === "uses")
15975
+ return `moves a uses: ref (${pathText(change.path)})`;
15976
+ if (key)
15977
+ return `changes ${key}: (${pathText(change.path)})`;
15978
+ }
15979
+ return (refused.find((change) => change.what.startsWith("removes")) ?? refused[0])?.what ?? "changes it";
15980
+ }
15981
+ function workflowEdit(before, after) {
15982
+ const old = parseWorkflowYaml(before);
15983
+ const now = parseWorkflowYaml(after);
15984
+ if (!old || !now)
15985
+ return { additive: false, detail: "does not parse as plain workflow YAML" };
15986
+ const out = { allowed: [], refused: [] };
15987
+ compare(old, now, [], null, out);
15988
+ if (out.refused.length)
15989
+ return { additive: false, detail: decisive(out.refused) };
15990
+ if (!out.allowed.length)
15991
+ return { additive: false, detail: "changes only comments or layout, read as code" };
15992
+ return {
15993
+ additive: true,
15994
+ detail: out.allowed.slice(0, 3).join(", ") + (out.allowed.length > 3 ? ", …" : "")
15995
+ };
15996
+ }
15997
+
15324
15998
  // packages/workit-core/src/core/policy/lane.ts
15325
15999
  var LANE_THRESHOLDS = {
15326
16000
  selfMaxLines: 100,
@@ -15381,15 +16055,16 @@ var DOC_EXT = /\.(?:md|mdx|markdown|rst|adoc)$/iu;
15381
16055
  var DOC_NAMES = /^(?:license|licence|notice|authors|changelog|changes|contributors)$/iu;
15382
16056
  var INSTRUCTIONS = /(?:^|\/)(?:AGENTS|CLAUDE|GEMINI|SKILL)\.md$|(?:^|\/)(?:skills|agents|commands|rules|prompts)\/[^/]+/iu;
15383
16057
  var TEST_PATH = /(?:^|\/)(?:test|tests|__tests__)\/|\.(?:test|spec)\.[^/]+$|_test\.[^/]+$/iu;
16058
+ var DEPENDENCY_BUMP_EVIDENCE = "green CI on the head";
15384
16059
  var plural = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
15385
- var basename = (file) => file.slice(file.lastIndexOf("/") + 1);
15386
- var isDoc = (file) => !INSTRUCTIONS.test(file) && (DOC_EXT.test(file) || DOC_NAMES.test(basename(file)));
16060
+ var basename2 = (file) => file.slice(file.lastIndexOf("/") + 1);
16061
+ var isDoc = (file) => !INSTRUCTIONS.test(file) && (DOC_EXT.test(file) || DOC_NAMES.test(basename2(file)));
15387
16062
  function kindOf(file) {
15388
16063
  if (file.binary)
15389
16064
  return "behavior";
15390
16065
  if (file.generated)
15391
16066
  return "generated";
15392
- if (LOCKFILES.has(basename(file.path)))
16067
+ if (LOCKFILES.has(basename2(file.path)))
15393
16068
  return "lockfile";
15394
16069
  if (isDoc(file.path))
15395
16070
  return "doc";
@@ -15422,7 +16097,7 @@ function globMatch(pattern, file) {
15422
16097
  function isRiskPath(file, extra = []) {
15423
16098
  if (extra.some((pattern) => globMatch(pattern, file)))
15424
16099
  return true;
15425
- if (RISK_FILES.has(file) || RISK_NAMES.has(basename(file)))
16100
+ if (RISK_FILES.has(file) || RISK_NAMES.has(basename2(file)))
15426
16101
  return true;
15427
16102
  if (TEST_PATH.test(file) || isDoc(file))
15428
16103
  return false;
@@ -15430,8 +16105,41 @@ function isRiskPath(file, extra = []) {
15430
16105
  }
15431
16106
  var parseRiskPaths = (text) => text.split(`
15432
16107
  `).map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.replace(/^\//u, ""));
16108
+ function additiveWorkflow(file, extra) {
16109
+ if (file.workflow?.additive !== true || file.binary || !isWorkflowFile(file.path))
16110
+ return false;
16111
+ if (extra.some((pattern) => globMatch(pattern, file.path)))
16112
+ return false;
16113
+ return !isRiskPath(file.path.replace(/^\.github\/workflows\//u, ".github/"), extra);
16114
+ }
16115
+ var ADDITIVE_CI_FLOOR = "an additive workflow edit needs a non-author verdict unless it rides a dependency bump";
16116
+ var CHANGELOG = /^(?:changelog|changes)(?:\.[^.]+)?$/iu;
16117
+ function dependencyBump(files, additive) {
16118
+ const manifests = files.filter((file) => file.manifest?.pins && !file.binary);
16119
+ if (!manifests.some((file) => (file.manifest?.bumped ?? 0) > 0))
16120
+ return null;
16121
+ const locks = [];
16122
+ for (const file of files) {
16123
+ if (additive.has(file.path) || manifests.includes(file))
16124
+ continue;
16125
+ if (LOCKFILES.has(basename2(file.path)))
16126
+ locks.push(file.path);
16127
+ else if (file.binary || !(isDoc(file.path) && CHANGELOG.test(basename2(file.path))))
16128
+ return null;
16129
+ }
16130
+ const bumped = manifests.reduce((sum, file) => sum + (file.manifest?.bumped ?? 0), 0);
16131
+ const scripts = manifests.flatMap((file) => file.manifest?.scripts ?? []);
16132
+ const list = (paths) => `${paths.slice(0, 3).join(", ")}${paths.length > 3 ? ", …" : ""}`;
16133
+ 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`;
16134
+ }
15433
16135
  function computeLane(input) {
15434
- const riskFiles = input.files.filter((file) => isRiskPath(file.path, input.riskPaths)).map((file) => file.path);
16136
+ const extra = input.riskPaths ?? [];
16137
+ const additive = input.files.filter((file) => additiveWorkflow(file, extra));
16138
+ const relaxed = new Set(additive.map((file) => file.path));
16139
+ const workflowNote = additive.length ? [
16140
+ `additive workflow edit: ${additive.slice(0, 3).map((file) => `${file.path} (${file.workflow?.detail ?? ""})`).join(", ")}${additive.length > 3 ? ", …" : ""}`
16141
+ ] : [];
16142
+ const riskFiles = input.files.filter((file) => isRiskPath(file.path, extra) && !relaxed.has(file.path)).map((file) => file.path);
15435
16143
  const risky = new Set(riskFiles);
15436
16144
  const kinds = input.files.map((file) => ({
15437
16145
  file,
@@ -15442,20 +16150,30 @@ function computeLane(input) {
15442
16150
  const opaque = behavior.filter((entry) => entry.kind === "lockfile" || entry.file.binary);
15443
16151
  const diffLines = input.files.reduce((sum, file) => sum + file.added + file.deleted, 0);
15444
16152
  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)`;
15445
- const result = (lane, reasons) => ({
15446
- lane,
15447
- reasons,
15448
- lines,
15449
- files: behavior.length,
15450
- riskFiles
15451
- });
16153
+ const result = (lane, reasons, classification) => {
16154
+ const floor = additive.length > 0 && !classification && (lane === "none" || lane === "self");
16155
+ return {
16156
+ lane: floor ? "focused" : lane,
16157
+ reasons: [...floor ? [ADDITIVE_CI_FLOOR] : [], ...reasons, ...workflowNote],
16158
+ lines,
16159
+ files: behavior.length,
16160
+ riskFiles,
16161
+ ...classification ? { classification } : {}
16162
+ };
16163
+ };
15452
16164
  const { selfMaxLines, selfMaxFiles, fullMinLines } = LANE_THRESHOLDS;
15453
16165
  if (input.riskTier === "high")
15454
16166
  return result("full", ["the task judgment records high risk"]);
15455
16167
  if (riskFiles.length)
15456
16168
  return result("full", [
15457
- `touches a risk path: ${riskFiles.slice(0, 3).join(", ")}${riskFiles.length > 3 ? ", …" : ""}`
16169
+ `touches a risk path: ${riskFiles.slice(0, 3).map((file) => {
16170
+ const refused = input.files.find((entry) => entry.path === file)?.workflow;
16171
+ return refused && !refused.additive ? `${file} (${refused.detail})` : file;
16172
+ }).join(", ")}${riskFiles.length > 3 ? ", …" : ""}`
15458
16173
  ]);
16174
+ const bump = dependencyBump(input.files, relaxed);
16175
+ if (bump && lines < fullMinLines)
16176
+ return result("self", [bump], "dependency-bump");
15459
16177
  if (!behavior.length)
15460
16178
  return result("none", [
15461
16179
  input.files.length ? "only docs, comments, formatting or generated copies changed" : "no changes"
@@ -15502,6 +16220,7 @@ function cosmeticFiles(cwd, fork, head) {
15502
16220
  return null;
15503
16221
  const out = new Set;
15504
16222
  const opaque = new Set;
16223
+ const facts = new Map;
15505
16224
  for (const entry of candidates) {
15506
16225
  const before = blobs.get(entry.oldBlob);
15507
16226
  let after = blobs.get(entry.newBlob);
@@ -15511,12 +16230,20 @@ function cosmeticFiles(cwd, fork, head) {
15511
16230
  } catch {
15512
16231
  after = undefined;
15513
16232
  }
16233
+ if (before && after && isWorkflowFile(entry.path))
16234
+ facts.set(entry.path, {
16235
+ workflow: workflowEdit(before.toString("utf8"), after.toString("utf8"))
16236
+ });
16237
+ else if (before && after && isManifest(entry.path))
16238
+ facts.set(entry.path, {
16239
+ manifest: manifestEdit(entry.path, before.toString("utf8"), after.toString("utf8"))
16240
+ });
15514
16241
  if (before && after && cosmeticChange(entry.path, before, after))
15515
16242
  out.add(entry.path);
15516
16243
  else if ([before, after].some((bytes) => bytes && hasOpaqueLineBreak(bytes.toString("utf8"))))
15517
16244
  opaque.add(entry.path);
15518
16245
  }
15519
- return { cosmetic: out, opaque };
16246
+ return { cosmetic: out, opaque, facts };
15520
16247
  }
15521
16248
  function generatedAt(cwd, fork, paths) {
15522
16249
  const files = treeFilesNamed(cwd, fork, ".gitattributes");
@@ -15541,7 +16268,8 @@ function laneFiles(cwd, fork, head, attributesAt = fork) {
15541
16268
  ...stats.map((entry) => ({
15542
16269
  ...entry,
15543
16270
  ...cosmetic.opaque.has(entry.path) ? { binary: true } : {},
15544
- cosmetic: !entry.binary && cosmetic.cosmetic.has(entry.path)
16271
+ cosmetic: !entry.binary && cosmetic.cosmetic.has(entry.path),
16272
+ ...cosmetic.facts.get(entry.path)
15545
16273
  })),
15546
16274
  ...head === null ? untrackedFiles(cwd).map((file) => untrackedStat(cwd, file)) : []
15547
16275
  ];
@@ -16046,10 +16774,10 @@ function appendObserved(cwd, row, options = {}) {
16046
16774
  function appendHookObserved(cwd, row) {
16047
16775
  return appendRaw(cwd, { ...row, observer: "host_hook" }, {});
16048
16776
  }
16049
- var isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
16777
+ var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
16050
16778
  var str2 = (value) => typeof value === "string" ? value : null;
16051
16779
  var normalizeActor = (value) => {
16052
- const actor = isRecord3(value) ? value : {};
16780
+ const actor = isRecord4(value) ? value : {};
16053
16781
  return {
16054
16782
  host: str2(actor.host) ?? "unknown",
16055
16783
  session: str2(actor.session),
@@ -16113,7 +16841,7 @@ function readLedgerAt(cwd, file, options) {
16113
16841
  skipped += 1;
16114
16842
  continue;
16115
16843
  }
16116
- if (!isRecord3(parsed) || !str2(parsed.id) || !str2(parsed.type) || !str2(parsed.at)) {
16844
+ if (!isRecord4(parsed) || !str2(parsed.id) || !str2(parsed.type) || !str2(parsed.at)) {
16117
16845
  skipped += 1;
16118
16846
  continue;
16119
16847
  }
@@ -18995,14 +19723,14 @@ var SCOPE_FIELDS = new Set([
18995
19723
 
18996
19724
  // packages/workit-core/src/core/release-packages.ts
18997
19725
  var KNOWN_FIELDS2 = new Set(["tagNamespace", "changelogPath"]);
18998
- var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
19726
+ var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
18999
19727
  var NAMESPACE = /^[A-Za-z@][\w.@/+-]*$/u;
19000
19728
  var validTagNamespace = (value) => NAMESPACE.test(value) && !value.includes("..") && !value.includes("@{") && !value.includes("//") && !value.endsWith(".lock") && !/\d$/u.test(value);
19001
19729
  function readReleasePackages(raw) {
19002
19730
  const out = { packages: [], issues: [] };
19003
19731
  if (raw === undefined || raw === null)
19004
19732
  return out;
19005
- if (!isRecord4(raw)) {
19733
+ if (!isRecord5(raw)) {
19006
19734
  out.issues.push("releasePackages is not an object; ignored");
19007
19735
  return out;
19008
19736
  }
@@ -19013,7 +19741,7 @@ function readReleasePackages(raw) {
19013
19741
  out.issues.push(`${label}: a blank or padded name; ignored`);
19014
19742
  continue;
19015
19743
  }
19016
- if (!isRecord4(entry)) {
19744
+ if (!isRecord5(entry)) {
19017
19745
  out.issues.push(`${label} is not an object; ignored`);
19018
19746
  continue;
19019
19747
  }
@@ -25082,7 +25810,7 @@ var readText3 = (file) => {
25082
25810
  throw error;
25083
25811
  }
25084
25812
  };
25085
- var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
25813
+ var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
25086
25814
  function parseJsonc(text) {
25087
25815
  let out = "";
25088
25816
  for (let index = 0;index < text.length; index += 1) {
@@ -25156,12 +25884,12 @@ function claudeRules(cwd, env = process.env) {
25156
25884
  if (text === null)
25157
25885
  continue;
25158
25886
  const value = JSON.parse(text);
25159
- if (!isRecord5(value))
25887
+ if (!isRecord6(value))
25160
25888
  return "unreadable";
25161
25889
  const permissions = value.permissions;
25162
25890
  if (permissions === undefined)
25163
25891
  continue;
25164
- if (!isRecord5(permissions))
25892
+ if (!isRecord6(permissions))
25165
25893
  return "unreadable";
25166
25894
  for (const [key, bucket] of [
25167
25895
  ["deny", rules.deny],
@@ -25195,7 +25923,7 @@ var opencodePermission = (permission, rules) => {
25195
25923
  (permission === "allow" ? rules.allow : rules.deny).push("");
25196
25924
  return ["allow", "ask", "deny"].includes(permission);
25197
25925
  }
25198
- if (!isRecord5(permission))
25926
+ if (!isRecord6(permission))
25199
25927
  return false;
25200
25928
  for (const key of ["bash", "shell"]) {
25201
25929
  const value = permission[key];
@@ -25207,7 +25935,7 @@ var opencodePermission = (permission, rules) => {
25207
25935
  (value === "allow" ? rules.allow : rules.deny).push("");
25208
25936
  continue;
25209
25937
  }
25210
- if (!isRecord5(value))
25938
+ if (!isRecord6(value))
25211
25939
  return false;
25212
25940
  for (const [pattern, action] of Object.entries(value)) {
25213
25941
  if (action !== "allow" && action !== "ask" && action !== "deny")
@@ -25225,7 +25953,7 @@ var opencodeRuleset = (ruleset, rules) => {
25225
25953
  if (!Array.isArray(ruleset))
25226
25954
  return false;
25227
25955
  for (const rule of ruleset) {
25228
- if (!isRecord5(rule))
25956
+ if (!isRecord6(rule))
25229
25957
  return false;
25230
25958
  const { action, resource, effect } = rule;
25231
25959
  if (typeof action !== "string" || typeof resource !== "string")
@@ -25240,11 +25968,11 @@ var opencodeRuleset = (ruleset, rules) => {
25240
25968
  var opencodeAgents = (agents, read) => {
25241
25969
  if (agents === undefined)
25242
25970
  return true;
25243
- if (!isRecord5(agents))
25971
+ if (!isRecord6(agents))
25244
25972
  return false;
25245
- return Object.values(agents).every((agent) => isRecord5(agent) && read(agent));
25973
+ return Object.values(agents).every((agent) => isRecord6(agent) && read(agent));
25246
25974
  };
25247
- var opencodeConfig = (value, rules) => isRecord5(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));
25975
+ 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));
25248
25976
  function opencodeRules(cwd, env = process.env) {
25249
25977
  const rules = EMPTY2();
25250
25978
  try {
@@ -25333,11 +26061,11 @@ function cursorRules(cwd, env = process.env) {
25333
26061
  if (text === null)
25334
26062
  continue;
25335
26063
  const value = JSON.parse(text);
25336
- if (!isRecord5(value))
26064
+ if (!isRecord6(value))
25337
26065
  return "unreadable";
25338
26066
  if (value.permissions === undefined)
25339
26067
  continue;
25340
- if (!isRecord5(value.permissions))
26068
+ if (!isRecord6(value.permissions))
25341
26069
  return "unreadable";
25342
26070
  for (const [key, bucket] of [
25343
26071
  ["deny", rules.deny],
@@ -25762,11 +26490,11 @@ var readJson = (file) => {
25762
26490
  return;
25763
26491
  }
25764
26492
  };
25765
- var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
26493
+ var isRecord7 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
25766
26494
  var stringList = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
25767
26495
  function machinePatterns(env) {
25768
26496
  const value = readJson(heavyCommandsFile(env));
25769
- return isRecord6(value) ? stringList(value.patterns) : [];
26497
+ return isRecord7(value) ? stringList(value.patterns) : [];
25770
26498
  }
25771
26499
  function repoPatterns(cwd) {
25772
26500
  return repoHeavyCommands(gitTop(cwd) ?? path38.resolve(cwd));
@@ -28061,11 +28789,11 @@ var workitSkillOf = (name) => {
28061
28789
  const skill = bare.replace(/^workit:/, "workit-");
28062
28790
  return WORKIT_METHOD_SKILLS.includes(skill) ? skill : null;
28063
28791
  };
28064
- var QUOTED = /```[\s\S]*?```|["`“][^"`”\n]*["`”]|\B'[^'\n]*'\B/g;
28792
+ var QUOTED2 = /```[\s\S]*?```|["`“][^"`”\n]*["`”]|\B'[^'\n]*'\B/g;
28065
28793
  var COMPLAINT = /\b(why \w+ you|you keep|stop \w+ing)\b.*?(?=\b(and|but)\b|[?.,;\n]|$)/gi;
28066
28794
  var promptTrigger = (prompt) => {
28067
28795
  let asking = false;
28068
- const text = prompt.slice(0, 4000).replace(QUOTED, " ").replace(COMPLAINT, (clause) => (asking ||= /ask|quest/i.test(clause), " "));
28796
+ const text = prompt.slice(0, 4000).replace(QUOTED2, " ").replace(COMPLAINT, (clause) => (asking ||= /ask|quest/i.test(clause), " "));
28069
28797
  for (const [skill, pattern] of PROMPT_INTENTS) {
28070
28798
  const match = !(asking && skill === "workit-shape") && pattern.exec(text);
28071
28799
  if (match)
@@ -28186,7 +28914,7 @@ ${line}` };
28186
28914
  };
28187
28915
  var shellNudge = (input, command) => withContextLine(rawGitPre(input, command), shipNudge(input, command));
28188
28916
  // packages/workit-core/src/hooks/hosts/fields.ts
28189
- var isRecord7 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
28917
+ var isRecord8 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
28190
28918
  var nonEmpty2 = (value) => typeof value === "string" && value.trim() !== "";
28191
28919
  var SHELLS2 = new Set(["sh", "bash", "zsh", "dash", "pwsh", "powershell", "cmd"]);
28192
28920
  var WRITE_TOOLS = new Set([
@@ -28211,7 +28939,7 @@ var WRITE_TOOLS = new Set([
28211
28939
  var PATH_KEYS = ["file_path", "filePath", "notebook_path", "path", "target_file", "file"];
28212
28940
  var PATCH_HEADER = /^[ \t]*\*\*\* (?:(?:Add|Update|Delete) File|Move to): (.+)$/gm;
28213
28941
  var writePaths = (input) => {
28214
- if (!isRecord7(input))
28942
+ if (!isRecord8(input))
28215
28943
  return [];
28216
28944
  const paths = PATH_KEYS.map((key) => input[key]).filter(nonEmpty2);
28217
28945
  for (const value of Object.values(input))
@@ -32343,9 +33071,9 @@ import { randomUUID as randomUUID5 } from "node:crypto";
32343
33071
  // packages/workit-pi/src/worker-protocol.ts
32344
33072
  var MAX_WORKER_LINE_BYTES = 64 * 1024;
32345
33073
  var MAX_WORKER_STDERR_BYTES = 64 * 1024;
32346
- var isRecord8 = (value) => typeof value === "object" && value !== null;
33074
+ var isRecord9 = (value) => typeof value === "object" && value !== null;
32347
33075
  var parseEvent2 = (value) => {
32348
- if (!isRecord8(value) || typeof value.type !== "string")
33076
+ if (!isRecord9(value) || typeof value.type !== "string")
32349
33077
  return null;
32350
33078
  if (value.type === "workit_worker_ready") {
32351
33079
  if (typeof value.workerId !== "string" || typeof value.sessionId !== "string")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/pi",
3
- "version": "2.19.0",
3
+ "version": "2.20.1",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",