@workit-dev/codex 2.18.1 → 2.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7358,6 +7358,7 @@ var workspaceConfigSchema = object({
7358
7358
  trailers: boolean2().optional().describe("Whether commits get the `Workit-Session:` trailer (default true). With false, authorship lives in the ledger only."),
7359
7359
  deleteBranch: boolean2().optional().describe("Whether `workit pr merge` deletes the head branch after a merge (default true); `--keep-branch` opts out for one merge."),
7360
7360
  cleanup: unknown().optional().describe("What happens when work finishes: `auto` (default) removes the delivered branch's clean Workit worktree and local branch, switches a clean checkout on it back to the trunk, and stops the processes registered inside them; `keep` removes and stops nothing. A value Workit does not know reads as `keep`."),
7361
+ feedback: unknown().optional().describe('`workit feedback` for this workspace: `off` hides its contract line and makes the verb refuse; `{ "account": "<login>" }` names the GitHub login it posts with; workspaces inside this one inherit it.'),
7361
7362
  liveSessionGuard: boolean2().optional().describe("Whether the live-session guard denies edits in a checkout another live agent session owns (default true)."),
7362
7363
  fanout: object({
7363
7364
  tierModels: unknown().optional().describe("The model per slice TIER (mundane, standard, hard), as one name or per host.")
@@ -7400,7 +7401,10 @@ var workspaceConfigSchema = object({
7400
7401
  });
7401
7402
  var workspacesFileSchema = object({
7402
7403
  workspaces: array(workspaceConfigSchema).optional().describe("Workspace entries, each mapping a path glob to its forge, policies and grants."),
7403
- models: object({ roles: modelRoles }).passthrough().optional().describe("The global default model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false).")
7404
+ models: object({ roles: modelRoles }).passthrough().optional().describe("The global default model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false)."),
7405
+ feedback: object({
7406
+ account: nonBlank.optional().describe("The GitHub login `workit feedback --post` uses when no workspace names one; never the workspace's work account by default.")
7407
+ }).passthrough().optional().describe("`workit feedback` defaults for every workspace.")
7404
7408
  }).passthrough().superRefine((file, context) => {
7405
7409
  const names = new Set;
7406
7410
  for (const [index, workspace] of (file.workspaces ?? []).entries()) {
@@ -7845,6 +7849,12 @@ var workspaceTrailers = (cwd, dir) => {
7845
7849
  };
7846
7850
  };
7847
7851
  var workspaceLiveSessionGuard = (cwd, dir) => inheritedSetting(cwd, dir, (entry) => typeof entry.liveSessionGuard === "boolean")?.source?.liveSessionGuard !== false;
7852
+ var feedbackSetting = (cwd, dir) => {
7853
+ const found = inheritedSetting(cwd, dir, (entry) => entry.feedback !== undefined);
7854
+ const value = found?.source?.feedback;
7855
+ return { found, value, off: value === "off" };
7856
+ };
7857
+ var workspaceFeedbackOff = (cwd, dir) => feedbackSetting(cwd, dir).off;
7848
7858
  var changelogPathOf = (value) => {
7849
7859
  if (typeof value !== "string")
7850
7860
  return null;
@@ -9182,6 +9192,7 @@ function selectMethods(policy, capabilities) {
9182
9192
  return [{ id, reason: reasons.join("; "), assurance: capability.assurance }];
9183
9193
  });
9184
9194
  }
9195
+ var FEEDBACK_LINE = "Workit friction: offer `workit feedback` once per problem; keep working.";
9185
9196
  var BOOTSTRAP = `
9186
9197
  Workit is optional coordination and proof tooling: you decide what and
9187
9198
  whether, the CLI does how and records what it observed.
@@ -9236,6 +9247,7 @@ effect before a retry.
9236
9247
  Mid-task: never silently drop or resume an objective (workit-continue).
9237
9248
  Notes, drafts, logs, resume files: \`workit dir notes|handoffs\` (outside the
9238
9249
  repo), never the repo tree.
9250
+ FEEDBACK_LINE
9239
9251
 
9240
9252
  Skills: load the skill, never act from memory.
9241
9253
  - brainstorm, plan, spec, grill, should we: workit-shape
@@ -9253,9 +9265,13 @@ Skills: load the skill, never act from memory.
9253
9265
  - architecture, deepen modules (user-invoked; offer it): workit-architecture
9254
9266
  `.trim();
9255
9267
  var invariantBootstrap = (session = null) => {
9268
+ const feedbackOff = session !== null && workspaceFeedbackOff(session.cwd);
9269
+ const bootstrap = BOOTSTRAP.replace(`FEEDBACK_LINE
9270
+ `, () => feedbackOff ? "" : `${FEEDBACK_LINE}
9271
+ `);
9256
9272
  const table = session && hostFamily(session.host) === "claude_code" ? claudeSpawnTable(session.cwd) : null;
9257
- return table ? `${BOOTSTRAP}
9258
- ${table}` : BOOTSTRAP;
9273
+ return table ? `${bootstrap}
9274
+ ${table}` : bootstrap;
9259
9275
  };
9260
9276
 
9261
9277
  // packages/workit-core/src/store/paths.ts
@@ -12525,6 +12541,203 @@ function generatedByAttributes(files, paths) {
12525
12541
  return out;
12526
12542
  }
12527
12543
 
12544
+ // packages/workit-core/src/core/policy/dep-bump.ts
12545
+ var MANIFESTS = new Set(["package.json", "go.mod", "Cargo.toml", "pyproject.toml"]);
12546
+ var basename = (file) => file.slice(file.lastIndexOf("/") + 1);
12547
+ var isManifest = (file) => MANIFESTS.has(basename(file));
12548
+ var refused = (why) => ({ pins: false, bumped: 0, scripts: [], why });
12549
+ var pinned = (bumped, scripts = []) => ({
12550
+ pins: true,
12551
+ bumped,
12552
+ scripts,
12553
+ why: ""
12554
+ });
12555
+ var DEP_FIELDS = new Set([
12556
+ "dependencies",
12557
+ "devDependencies",
12558
+ "peerDependencies",
12559
+ "optionalDependencies"
12560
+ ]);
12561
+ var NPM_COMPARATOR = /^(?:[~^]|[<>]=?|=)?v?\d+(?:\.(?:\d+|x|\*)){0,2}(?:-[\da-z.-]+)?(?:\+[\da-z.-]+)?$/iu;
12562
+ function npmVersion(spec) {
12563
+ if (spec.length > 256)
12564
+ return false;
12565
+ return spec.split("||").every((set) => {
12566
+ const tokens = set.trim().replace(/([<>]=?|=|[~^])\s+/gu, "$1").split(/\s+/u);
12567
+ if (tokens.length === 3 && tokens[1] === "-")
12568
+ return NPM_COMPARATOR.test(tokens[0] ?? "") && NPM_COMPARATOR.test(tokens[2] ?? "");
12569
+ return tokens.every((token) => NPM_COMPARATOR.test(token));
12570
+ });
12571
+ }
12572
+ var HOOK_SCRIPT = /^(?:pre|post)|^(?:install|uninstall|prepare|publish|pack|version|dependencies|start|stop|restart|test)$/u;
12573
+ var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
12574
+ var same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
12575
+ function packageJson(before, after) {
12576
+ let old;
12577
+ let now;
12578
+ try {
12579
+ old = JSON.parse(before);
12580
+ now = JSON.parse(after);
12581
+ } catch {
12582
+ return refused("does not parse");
12583
+ }
12584
+ if (!isRecord2(old) || !isRecord2(now))
12585
+ return refused("is no JSON object");
12586
+ let bumped = 0;
12587
+ const scripts = [];
12588
+ for (const field of new Set([...Object.keys(old), ...Object.keys(now)])) {
12589
+ const a = old[field];
12590
+ const b = now[field];
12591
+ if (same(a, b))
12592
+ continue;
12593
+ if (DEP_FIELDS.has(field)) {
12594
+ if (!isRecord2(a) || !isRecord2(b))
12595
+ return refused(`changes ${field}`);
12596
+ for (const name of new Set([...Object.keys(a), ...Object.keys(b)])) {
12597
+ if (a[name] === b[name])
12598
+ continue;
12599
+ if (!(name in a))
12600
+ return refused(`adds the dependency ${name}`);
12601
+ if (!(name in b))
12602
+ return refused(`removes the dependency ${name}`);
12603
+ const from = a[name];
12604
+ const to = b[name];
12605
+ if (typeof from !== "string" || typeof to !== "string")
12606
+ return refused(`changes ${field}.${name}`);
12607
+ if (!npmVersion(from.trim()) || !npmVersion(to.trim()))
12608
+ return refused(`changes the source of ${name}`);
12609
+ bumped += 1;
12610
+ }
12611
+ } else if (field === "scripts") {
12612
+ if (!isRecord2(a) || !isRecord2(b))
12613
+ return refused("changes scripts");
12614
+ for (const name of Object.keys(a))
12615
+ if (a[name] !== b[name])
12616
+ return refused(`changes the script ${name}`);
12617
+ for (const name of Object.keys(b)) {
12618
+ if (name in a)
12619
+ continue;
12620
+ if (HOOK_SCRIPT.test(name))
12621
+ return refused(`adds the lifecycle script ${name}`);
12622
+ if (name.startsWith("pnpm:"))
12623
+ return refused(`adds the pnpm: script ${name}`);
12624
+ const runner = Object.entries(a).find(([, command]) => typeof command === "string" && runsByGlob(command, name));
12625
+ if (runner)
12626
+ return refused(`adds the script ${name}, which the script ${runner[0]} runs by glob`);
12627
+ scripts.push(name);
12628
+ }
12629
+ } else
12630
+ return refused(`changes ${field}`);
12631
+ }
12632
+ return pinned(bumped, scripts);
12633
+ }
12634
+ function runsByGlob(command, name) {
12635
+ const tokens = command.split(/\s+/u).map((token) => token.replace(/^--filter=/u, "").replaceAll(/^["']|["']$/gu, "").replace(/^(?:npm|pnpm|yarn|bun):/u, ""));
12636
+ if (/\bpnpm\b/u.test(command) && tokens.some((token) => /^\/.+\/$/u.test(token)))
12637
+ return true;
12638
+ return tokens.filter((token) => token.includes("*")).some((glob) => new RegExp(`^${glob.split(/\*+/u).map((part) => part.replaceAll(/[.+?^${}()|[\]\\]/gu, "\\$&")).join(".*")}$`, "u").test(name));
12639
+ }
12640
+ function goDirectives(text) {
12641
+ const out = [];
12642
+ let block = null;
12643
+ for (const raw of text.split(`
12644
+ `)) {
12645
+ const indirect = /\/\/\s*indirect\s*$/u.test(raw);
12646
+ const line = raw.replace(/\/\/.*$/u, "").trim();
12647
+ if (!line)
12648
+ continue;
12649
+ if (block !== null) {
12650
+ if (line === ")")
12651
+ block = null;
12652
+ else
12653
+ out.push({ verb: block, args: line.replace(/\s+/gu, " "), indirect });
12654
+ continue;
12655
+ }
12656
+ const match = /^(\S+)\s*(.*)$/u.exec(line);
12657
+ if (!match)
12658
+ return null;
12659
+ const [, verb = "", rest = ""] = match;
12660
+ if (rest === "(")
12661
+ block = verb;
12662
+ else
12663
+ out.push({ verb, args: rest.replace(/\s+/gu, " "), indirect });
12664
+ }
12665
+ return block === null ? out : null;
12666
+ }
12667
+ var GO_VERSION = /^v\d+\.\d+\.\d+(?:-[\w.-]+)?(?:\+incompatible)?$/u;
12668
+ function goMod(before, after) {
12669
+ const old = goDirectives(before);
12670
+ const now = goDirectives(after);
12671
+ if (!old || !now)
12672
+ return refused("does not parse");
12673
+ if (old.length !== now.length)
12674
+ return refused("adds or removes a directive");
12675
+ let bumped = 0;
12676
+ for (const [index, a] of old.entries()) {
12677
+ const b = now[index];
12678
+ if (a.verb === b.verb && a.args === b.args && a.indirect === b.indirect)
12679
+ continue;
12680
+ if (a.verb !== "require" || b.verb !== "require" || a.indirect !== b.indirect)
12681
+ return refused(`changes ${a.verb}`);
12682
+ const [module, from, extra] = a.args.split(" ");
12683
+ const [moduleAfter, to, extraAfter] = b.args.split(" ");
12684
+ if (module !== moduleAfter || extra !== undefined || extraAfter !== undefined)
12685
+ return refused(`changes require ${module ?? ""}`);
12686
+ if (!GO_VERSION.test(from ?? "") || !GO_VERSION.test(to ?? ""))
12687
+ return refused(`changes the source of ${module ?? ""}`);
12688
+ bumped += 1;
12689
+ }
12690
+ return pinned(bumped);
12691
+ }
12692
+ var CARGO_TABLE = /^(?:workspace\.)?(?:target\..+\.)?(?:dev-|build-)?dependencies(?:\.[^.]+)?$/u;
12693
+ var PYPROJECT_TABLE = /^(?:project\.optional-dependencies|dependency-groups|tool\.poetry\.(?:dev-)?dependencies|tool\.poetry\.group\.[^.]+\.dependencies)$/u;
12694
+ var OTHER_SOURCE = /\b(?:git|rev|branch|tag|path|url|registry|package)\s*=|@|:\/\//u;
12695
+ var VERSION_TOKEN = /(?<=[\s"'=<>~^!,*v])\d+(?:\.\d+)*(?:[a-z]+\d*)?(?:\.(?:post|dev)\d+)?/giu;
12696
+ function tomlPins(before, after, cargo) {
12697
+ const old = before.split(`
12698
+ `);
12699
+ const now = after.split(`
12700
+ `);
12701
+ if (old.length !== now.length)
12702
+ return refused("adds or removes lines");
12703
+ let table = "";
12704
+ let inArray = false;
12705
+ let bumped = 0;
12706
+ for (const [index, a] of old.entries()) {
12707
+ const b = now[index] ?? "";
12708
+ const header = /^\s*\[\[?([^\]]+)\]\]?\s*(?:#.*)?$/u.exec(a);
12709
+ if (header) {
12710
+ table = (header[1] ?? "").replace(/\s+/gu, "");
12711
+ inArray = false;
12712
+ } else if (!cargo && table === "project" && /^\s*dependencies\s*=\s*\[\s*(?:#.*)?$/u.test(a))
12713
+ inArray = true;
12714
+ else if (inArray && /^\s*\]/u.test(a))
12715
+ inArray = false;
12716
+ if (a === b)
12717
+ continue;
12718
+ const listed = cargo ? CARGO_TABLE.test(table) : PYPROJECT_TABLE.test(table) || inArray || table === "project" && /^\s*dependencies\s*=/u.test(a);
12719
+ if (header || !listed)
12720
+ return refused(`changes line ${index + 1} outside a dependency table`);
12721
+ if (OTHER_SOURCE.test(a) || OTHER_SOURCE.test(b))
12722
+ return refused(`changes a dependency source on line ${index + 1}`);
12723
+ const key = (line) => /^\s*("?[\w.[\],-]+"?)/u.exec(line)?.[1] ?? "";
12724
+ const versionless = (line) => line.replace(VERSION_TOKEN, "V");
12725
+ const names = (line) => cargo ? "" : [...line.matchAll(/"([A-Za-z_][\w.-]*)/gu)].map((match) => match[1]).join(",");
12726
+ if (key(a) !== key(b) || names(a) !== names(b) || versionless(a) !== versionless(b))
12727
+ return refused(`changes more than a version on line ${index + 1}`);
12728
+ bumped += 1;
12729
+ }
12730
+ return pinned(bumped);
12731
+ }
12732
+ function manifestEdit(file, before, after) {
12733
+ const name = basename(file);
12734
+ if (name === "package.json")
12735
+ return packageJson(before, after);
12736
+ if (name === "go.mod")
12737
+ return goMod(before, after);
12738
+ return tomlPins(before, after, name === "Cargo.toml");
12739
+ }
12740
+
12528
12741
  // packages/workit-core/src/core/policy/substance.ts
12529
12742
  var SLASH_BLOCK = [["/*", "*/"]];
12530
12743
  var C_LIKE = { line: ["//"], block: SLASH_BLOCK, quotes: `"'` };
@@ -12843,6 +13056,483 @@ function cosmeticChange(file, before, after) {
12843
13056
  return a !== null && a === substanceOf(file, right);
12844
13057
  }
12845
13058
 
13059
+ // packages/workit-core/src/core/policy/workflow-edit.ts
13060
+ class Unparsed extends Error {
13061
+ }
13062
+ var refuse = (why) => {
13063
+ throw new Unparsed(why);
13064
+ };
13065
+ 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;
13066
+ var HEX_DIGITS = { x: 2, u: 4, U: 8 };
13067
+ var ESCAPES = {
13068
+ n: `
13069
+ `,
13070
+ t: "\t",
13071
+ r: "\r",
13072
+ "0": "\x00",
13073
+ '"': '"',
13074
+ "\\": "\\",
13075
+ "/": "/",
13076
+ " ": " "
13077
+ };
13078
+ var scalar = (text, string, folded = false) => ({
13079
+ kind: "scalar",
13080
+ text,
13081
+ string,
13082
+ folded
13083
+ });
13084
+ function quoted(text, start) {
13085
+ const quote = text[start];
13086
+ let out = "";
13087
+ for (let index = start + 1;index < text.length; index += 1) {
13088
+ const char = text[index] ?? "";
13089
+ if (quote === "'" && char === "'") {
13090
+ if (text[index + 1] !== "'")
13091
+ return { value: out, end: index + 1 };
13092
+ out += "'";
13093
+ index += 1;
13094
+ } else if (quote === '"' && char === '"')
13095
+ return { value: out, end: index + 1 };
13096
+ else if (quote === '"' && char === "\\") {
13097
+ const next = text[index + 1] ?? "";
13098
+ const hex = HEX_DIGITS[next];
13099
+ if (hex) {
13100
+ const digits = text.slice(index + 2, index + 2 + hex);
13101
+ if (!/^[\da-f]+$/iu.test(digits) || digits.length !== hex)
13102
+ refuse("a bad escape");
13103
+ out += String.fromCodePoint(Number.parseInt(digits, 16));
13104
+ index += 1 + hex;
13105
+ } else {
13106
+ out += ESCAPES[next] ?? refuse("an unknown escape");
13107
+ index += 1;
13108
+ }
13109
+ } else
13110
+ out += char;
13111
+ }
13112
+ return refuse("a quoted scalar spans lines");
13113
+ }
13114
+ function trailing(text, end) {
13115
+ const rest = text.slice(end);
13116
+ if (rest.trim() && !/^\s+#/u.test(rest))
13117
+ refuse("text after a value");
13118
+ }
13119
+ var INDICATOR = /^[&*!%@`|>,[\]{}?:#-]/u;
13120
+ function plain(text) {
13121
+ const value = text.replace(/\s+#.*$/u, "").trimEnd();
13122
+ if (INDICATOR.test(value) && !/^-[^\s]/u.test(value))
13123
+ refuse("an indicator starts a scalar");
13124
+ if (/:\s|:$/u.test(value))
13125
+ refuse("a mapping inside a scalar");
13126
+ return scalar(value, !NON_STRING.test(value));
13127
+ }
13128
+ function flow(text, start) {
13129
+ const close = text[start] === "[" ? "]" : "}";
13130
+ const items = [];
13131
+ const entries = new Map;
13132
+ let index = start + 1;
13133
+ const skip = () => {
13134
+ while (text[index] === " ")
13135
+ index += 1;
13136
+ };
13137
+ const element = (stops) => {
13138
+ skip();
13139
+ const char = text[index];
13140
+ if (char === '"' || char === "'") {
13141
+ const read = quoted(text, index);
13142
+ index = read.end;
13143
+ return scalar(read.value, true);
13144
+ }
13145
+ if (char === "[" || char === "{") {
13146
+ const read = flow(text, index);
13147
+ index = read.end;
13148
+ return read.node;
13149
+ }
13150
+ let end = index;
13151
+ while (end < text.length && !stops.test(text[end] ?? ""))
13152
+ end += 1;
13153
+ const value = text.slice(index, end).trim();
13154
+ index = end;
13155
+ if (!value || value.includes("#"))
13156
+ refuse("an empty or commented flow element");
13157
+ return plain(value);
13158
+ };
13159
+ for (;; ) {
13160
+ skip();
13161
+ if (index >= text.length)
13162
+ refuse("a flow collection spans lines");
13163
+ if (text[index] === close)
13164
+ return {
13165
+ node: close === "]" ? { kind: "seq", items } : { kind: "map", entries },
13166
+ end: index + 1
13167
+ };
13168
+ if (close === "]")
13169
+ items.push(element(/[,\]]/u));
13170
+ else {
13171
+ const key = element(/[:,}]/u);
13172
+ skip();
13173
+ if (text[index] !== ":" || key.kind !== "scalar")
13174
+ refuse("a flow mapping without a value");
13175
+ index += 1;
13176
+ const value = element(/[,}]/u);
13177
+ const name = key.kind === "scalar" ? key.text : "";
13178
+ if (entries.has(name))
13179
+ refuse("a duplicate key");
13180
+ entries.set(name, value);
13181
+ }
13182
+ skip();
13183
+ if (text[index] === ",")
13184
+ index += 1;
13185
+ else if (text[index] !== close)
13186
+ refuse("a malformed flow collection");
13187
+ }
13188
+ }
13189
+ var isItem = (text) => text === "-" || text.startsWith("- ");
13190
+ function splitKey(text) {
13191
+ if (text[0] === '"' || text[0] === "'") {
13192
+ const read = quoted(text, 0);
13193
+ const after = text.slice(read.end);
13194
+ const match = /^\s*:(?:\s+|$)/u.exec(after);
13195
+ return match ? { key: read.value, rest: after.slice(match[0].length) } : null;
13196
+ }
13197
+ const match = /:(?:\s|$)/u.exec(text);
13198
+ if (!match || INDICATOR.test(text))
13199
+ return null;
13200
+ const key = text.slice(0, match.index).trimEnd();
13201
+ if (!key || key.includes(" #"))
13202
+ return null;
13203
+ return { key, rest: text.slice(match.index + 1).trimStart() };
13204
+ }
13205
+
13206
+ class Reader {
13207
+ lines;
13208
+ pos = 0;
13209
+ constructor(text) {
13210
+ const normal = text.replace(/\r\n/gu, `
13211
+ `);
13212
+ if (normal.includes("\r") || normal.charCodeAt(0) === 65279)
13213
+ refuse("an odd line break or BOM");
13214
+ this.lines = normal.split(`
13215
+ `);
13216
+ const first = this.lines.findIndex((line) => line.trim() && !line.trimStart().startsWith("#"));
13217
+ if (first >= 0 && /^---\s*(?:#.*)?$/u.test(this.lines[first] ?? ""))
13218
+ this.lines[first] = "";
13219
+ }
13220
+ next() {
13221
+ while (this.pos < this.lines.length) {
13222
+ const raw = this.lines[this.pos] ?? "";
13223
+ const text = raw.trimStart();
13224
+ if (text === "" || text.startsWith("#")) {
13225
+ this.pos += 1;
13226
+ continue;
13227
+ }
13228
+ const indent = raw.length - text.length;
13229
+ if (raw.slice(0, indent).includes("\t"))
13230
+ refuse("a tab indents a line");
13231
+ if (indent === 0 && /^(?:---|\.\.\.)(?:\s|$)|^%/u.test(text))
13232
+ refuse("several documents");
13233
+ return { indent, text: text.trimEnd() };
13234
+ }
13235
+ return null;
13236
+ }
13237
+ document() {
13238
+ const root = this.block(0);
13239
+ if (this.next())
13240
+ refuse("content after the document");
13241
+ return root;
13242
+ }
13243
+ block(min) {
13244
+ const line = this.next();
13245
+ if (!line || line.indent < min)
13246
+ return scalar("", false);
13247
+ return isItem(line.text) ? this.sequence(line.indent) : this.mapping(line.indent);
13248
+ }
13249
+ mapping(indent) {
13250
+ const entries = new Map;
13251
+ for (let line = this.next();line && line.indent >= indent; line = this.next()) {
13252
+ if (line.indent > indent || isItem(line.text))
13253
+ refuse("bad indentation");
13254
+ const split = splitKey(line.text) ?? refuse("a line that is no mapping entry");
13255
+ if (entries.has(split.key))
13256
+ refuse("a duplicate key");
13257
+ this.pos += 1;
13258
+ entries.set(split.key, this.value(split.rest, indent, true));
13259
+ }
13260
+ return { kind: "map", entries };
13261
+ }
13262
+ sequence(indent) {
13263
+ const items = [];
13264
+ for (let line = this.next();line && line.indent === indent && isItem(line.text); line = this.next()) {
13265
+ const rest = line.text.slice(1).trimStart();
13266
+ const offset = indent + line.text.length - rest.length;
13267
+ if (isItem(rest))
13268
+ refuse("a sequence inside a sequence item");
13269
+ if (rest && !/^[|>[{]/u.test(rest) && splitKey(rest)) {
13270
+ this.lines[this.pos] = " ".repeat(offset) + rest;
13271
+ items.push(this.mapping(offset));
13272
+ } else {
13273
+ this.pos += 1;
13274
+ items.push(this.value(rest, indent, false));
13275
+ }
13276
+ }
13277
+ const line = this.next();
13278
+ if (line && line.indent > indent)
13279
+ refuse("bad indentation");
13280
+ return { kind: "seq", items };
13281
+ }
13282
+ value(rest, indent, inMapping) {
13283
+ if (rest === "" || rest.startsWith("#")) {
13284
+ const line = this.next();
13285
+ if (line && line.indent > indent)
13286
+ return this.block(line.indent);
13287
+ if (inMapping && line?.indent === indent && isItem(line.text))
13288
+ return this.sequence(indent);
13289
+ return scalar("", false);
13290
+ }
13291
+ let node;
13292
+ if (rest[0] === "|" || rest[0] === ">")
13293
+ return this.blockScalar(rest, indent);
13294
+ if (rest[0] === '"' || rest[0] === "'") {
13295
+ const read = quoted(rest, 0);
13296
+ trailing(rest, read.end);
13297
+ node = scalar(read.value, true);
13298
+ } else if (rest[0] === "[" || rest[0] === "{") {
13299
+ const read = flow(rest, 0);
13300
+ trailing(rest, read.end);
13301
+ node = read.node;
13302
+ } else
13303
+ node = plain(rest);
13304
+ const line = this.next();
13305
+ if (line && line.indent > indent)
13306
+ refuse("a value continues on the next line");
13307
+ return node;
13308
+ }
13309
+ blockScalar(header, indent) {
13310
+ const match = /^([|>])(?:([-+])([1-9])?|([1-9])([-+])?)?\s*(?:#.*)?$/u.exec(header);
13311
+ if (!match)
13312
+ return refuse("a bad block scalar header");
13313
+ const chomp = match[2] ?? match[5] ?? "";
13314
+ const indicator = match[3] ?? match[4];
13315
+ let column = indicator ? indent + Number(indicator) : null;
13316
+ const body = [];
13317
+ while (this.pos < this.lines.length) {
13318
+ const raw = this.lines[this.pos] ?? "";
13319
+ if (raw.trim() === "") {
13320
+ body.push(column !== null && raw.length > column ? raw.slice(column) : "");
13321
+ this.pos += 1;
13322
+ continue;
13323
+ }
13324
+ const lead = raw.length - raw.trimStart().length;
13325
+ if (column === null) {
13326
+ if (lead <= indent)
13327
+ break;
13328
+ column = lead;
13329
+ }
13330
+ if (lead < column) {
13331
+ if (lead > indent)
13332
+ refuse("an under-indented block line");
13333
+ break;
13334
+ }
13335
+ if (raw.slice(0, column).includes("\t"))
13336
+ refuse("a tab indents a line");
13337
+ body.push(raw.slice(column));
13338
+ this.pos += 1;
13339
+ }
13340
+ let end = body.length;
13341
+ while (end > 0 && body[end - 1] === "")
13342
+ end -= 1;
13343
+ const content = body.slice(0, end).join(`
13344
+ `);
13345
+ const text = chomp === "+" ? `${body.join(`
13346
+ `)}
13347
+ ` : chomp === "-" || !content ? content : `${content}
13348
+ `;
13349
+ return scalar(text, true, match[1] === ">");
13350
+ }
13351
+ }
13352
+ function parseWorkflowYaml(text) {
13353
+ try {
13354
+ return new Reader(text).document();
13355
+ } catch (error) {
13356
+ if (error instanceof Unparsed)
13357
+ return null;
13358
+ throw error;
13359
+ }
13360
+ }
13361
+ var isWorkflowFile = (file) => /^\.github\/workflows\/[^/]+\.ya?ml$/u.test(file);
13362
+ var GUARDED = new Set(["permissions", "secrets", "on", "uses", "environment", "if"]);
13363
+ var pathText = (keys) => keys.join(".").replaceAll(".[", "[");
13364
+ var WORD2 = /[\w./:@=+,-]+/uy;
13365
+ var QUOTED = /"[^"$`\\]*"/uy;
13366
+ var COMMAND = /^[\w.+][\w./+-]*$/u;
13367
+ 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(" "));
13368
+ var FALLBACK = new Set(["echo", "true"]);
13369
+ var FORM = 'more than && <command> or && (<command> || echo "<text>")';
13370
+ var OUTSIDE = '(outside plain words and "double-quoted text")';
13371
+ var COMMAND_INPUT = /(?:^|[-_])(?:commands?|cmd|script)$/iu;
13372
+ function tokens2(text) {
13373
+ const out = [];
13374
+ let index = 0;
13375
+ while (index < text.length) {
13376
+ const char = text[index] ?? "";
13377
+ if (char === " " || char === "\t")
13378
+ index += 1;
13379
+ else if (char === "(" || char === ")") {
13380
+ out.push({ op: char });
13381
+ index += 1;
13382
+ } else if ((char === "&" || char === "|") && text[index + 1] === char) {
13383
+ out.push({ op: char + char });
13384
+ index += 2;
13385
+ } else {
13386
+ const pattern = char === '"' ? QUOTED : WORD2;
13387
+ pattern.lastIndex = index;
13388
+ const match = pattern.exec(text);
13389
+ if (!match)
13390
+ return char === '"' ? 'a "quoted text" left open or holding $, a backtick or a backslash' : `the character ${char} ${OUTSIDE}`;
13391
+ index += match[0].length;
13392
+ const next = text[index] ?? " ";
13393
+ if (!" \t)&|".includes(next))
13394
+ return `the character ${next} ${OUTSIDE}`;
13395
+ out.push(char === '"' ? { quoted: match[0] } : { word: match[0] });
13396
+ }
13397
+ }
13398
+ return out;
13399
+ }
13400
+ function masking(before, appended) {
13401
+ if (appended.includes("${{"))
13402
+ return "an expression";
13403
+ if (/[\n\r]/u.test(appended))
13404
+ return "a new line";
13405
+ if (!before.trim())
13406
+ return "a command where none ran before";
13407
+ if (before.endsWith("\\"))
13408
+ return "a command after a trailing backslash";
13409
+ if (!appended.trimStart().startsWith("&&"))
13410
+ return "a command not chained with a leading &&";
13411
+ const list = tokens2(appended);
13412
+ if (typeof list === "string")
13413
+ return list;
13414
+ let index = 0;
13415
+ const op = (text) => {
13416
+ const token = list[index];
13417
+ if (!token || !("op" in token) || token.op !== text)
13418
+ return false;
13419
+ index += 1;
13420
+ return true;
13421
+ };
13422
+ const command = (names) => {
13423
+ const name = list[index];
13424
+ if (!name || !("word" in name) || !COMMAND.test(name.word))
13425
+ return FORM;
13426
+ if (names ? !names.has(name.word) : SHELL_STATE.has(name.word.toLowerCase()))
13427
+ return names ? FORM : `the shell command ${name.word}`;
13428
+ index += 1;
13429
+ for (let token = list[index];token && !("op" in token); token = list[index])
13430
+ index += 1;
13431
+ return null;
13432
+ };
13433
+ while (index < list.length) {
13434
+ if (!op("&&"))
13435
+ return FORM;
13436
+ const group = op("(");
13437
+ const bad = command() ?? (group && op("||") ? command(FALLBACK) : null);
13438
+ if (bad)
13439
+ return bad;
13440
+ if (group && !op(")"))
13441
+ return FORM;
13442
+ }
13443
+ return null;
13444
+ }
13445
+ function compare(before, after, at, room, out) {
13446
+ if (before.kind === "scalar" && after.kind === "scalar") {
13447
+ if (before.text === after.text && before.string === after.string)
13448
+ return;
13449
+ const grown = room !== null && before.string && after.string && before.folded === after.folded && after.text.length > before.text.length && after.text.startsWith(before.text);
13450
+ const masks = grown ? masking(before.text, after.text.slice(before.text.length)) : null;
13451
+ if (masks)
13452
+ out.refused.push({ path: at, what: `appends ${masks} to ${pathText(at)}` });
13453
+ else if (grown)
13454
+ out.allowed.push(`${pathText(at)} appended`);
13455
+ else
13456
+ out.refused.push({ path: at, what: `changes ${pathText(at)}` });
13457
+ return;
13458
+ }
13459
+ if (before.kind === "seq" && after.kind === "seq") {
13460
+ if (before.items.length !== after.items.length) {
13461
+ const fewer = after.items.length < before.items.length;
13462
+ const noun = at.at(-1) === "steps" ? "a step" : "an item";
13463
+ out.refused.push({
13464
+ path: at,
13465
+ what: `${fewer ? "removes" : "adds"} ${noun} ${fewer ? "from" : "to"} ${pathText(at)}`
13466
+ });
13467
+ return;
13468
+ }
13469
+ before.items.forEach((item, index) => compare(item, after.items[index], [...at, `[${index}]`], null, out));
13470
+ return;
13471
+ }
13472
+ if (before.kind === "map" && after.kind === "map") {
13473
+ const step = at.at(-2) === "steps";
13474
+ const job = at.length === 2 && at[0] === "jobs";
13475
+ const usesBoth = before.entries.has("uses") && after.entries.has("uses");
13476
+ for (const [key, value] of before.entries) {
13477
+ const next = after.entries.get(key);
13478
+ if (!next) {
13479
+ out.refused.push({
13480
+ path: [...at, key],
13481
+ what: at.length === 1 && at[0] === "jobs" ? `removes the job ${key}` : `removes ${pathText([...at, key])}`
13482
+ });
13483
+ continue;
13484
+ }
13485
+ if (key === "with" && job && usesBoth && value.kind === "map" && next.kind === "map")
13486
+ compareInputs(value, next, [...at, key], out);
13487
+ else
13488
+ compare(value, next, [...at, key], key === "run" && step ? "run" : null, out);
13489
+ }
13490
+ for (const [key] of after.entries)
13491
+ if (!before.entries.has(key))
13492
+ out.refused.push({ path: [...at, key], what: `adds ${pathText([...at, key])}` });
13493
+ return;
13494
+ }
13495
+ out.refused.push({ path: at, what: `changes the shape of ${pathText(at) || "the file"}` });
13496
+ }
13497
+ function compareInputs(before, after, at, out) {
13498
+ for (const [key, value] of before.entries) {
13499
+ const next = after.entries.get(key);
13500
+ if (next)
13501
+ compare(value, next, [...at, key], COMMAND_INPUT.test(key) ? "with" : null, out);
13502
+ else
13503
+ out.refused.push({ path: [...at, key], what: `removes ${pathText([...at, key])}` });
13504
+ }
13505
+ for (const [key] of after.entries)
13506
+ if (!before.entries.has(key))
13507
+ out.refused.push({ path: [...at, key], what: `adds the input ${pathText([...at, key])}` });
13508
+ }
13509
+ function decisive(refused) {
13510
+ for (const change of refused) {
13511
+ const key = change.path.find((part) => GUARDED.has(part));
13512
+ if (key === "uses")
13513
+ return `moves a uses: ref (${pathText(change.path)})`;
13514
+ if (key)
13515
+ return `changes ${key}: (${pathText(change.path)})`;
13516
+ }
13517
+ return (refused.find((change) => change.what.startsWith("removes")) ?? refused[0])?.what ?? "changes it";
13518
+ }
13519
+ function workflowEdit(before, after) {
13520
+ const old = parseWorkflowYaml(before);
13521
+ const now = parseWorkflowYaml(after);
13522
+ if (!old || !now)
13523
+ return { additive: false, detail: "does not parse as plain workflow YAML" };
13524
+ const out = { allowed: [], refused: [] };
13525
+ compare(old, now, [], null, out);
13526
+ if (out.refused.length)
13527
+ return { additive: false, detail: decisive(out.refused) };
13528
+ if (!out.allowed.length)
13529
+ return { additive: false, detail: "changes only comments or layout, read as code" };
13530
+ return {
13531
+ additive: true,
13532
+ detail: out.allowed.slice(0, 3).join(", ") + (out.allowed.length > 3 ? ", …" : "")
13533
+ };
13534
+ }
13535
+
12846
13536
  // packages/workit-core/src/core/policy/lane.ts
12847
13537
  var LANE_THRESHOLDS = {
12848
13538
  selfMaxLines: 100,
@@ -12903,15 +13593,16 @@ var DOC_EXT = /\.(?:md|mdx|markdown|rst|adoc)$/iu;
12903
13593
  var DOC_NAMES = /^(?:license|licence|notice|authors|changelog|changes|contributors)$/iu;
12904
13594
  var INSTRUCTIONS = /(?:^|\/)(?:AGENTS|CLAUDE|GEMINI|SKILL)\.md$|(?:^|\/)(?:skills|agents|commands|rules|prompts)\/[^/]+/iu;
12905
13595
  var TEST_PATH = /(?:^|\/)(?:test|tests|__tests__)\/|\.(?:test|spec)\.[^/]+$|_test\.[^/]+$/iu;
13596
+ var DEPENDENCY_BUMP_EVIDENCE = "green CI on the head";
12906
13597
  var plural = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
12907
- var basename = (file) => file.slice(file.lastIndexOf("/") + 1);
12908
- var isDoc = (file) => !INSTRUCTIONS.test(file) && (DOC_EXT.test(file) || DOC_NAMES.test(basename(file)));
13598
+ var basename2 = (file) => file.slice(file.lastIndexOf("/") + 1);
13599
+ var isDoc = (file) => !INSTRUCTIONS.test(file) && (DOC_EXT.test(file) || DOC_NAMES.test(basename2(file)));
12909
13600
  function kindOf(file) {
12910
13601
  if (file.binary)
12911
13602
  return "behavior";
12912
13603
  if (file.generated)
12913
13604
  return "generated";
12914
- if (LOCKFILES.has(basename(file.path)))
13605
+ if (LOCKFILES.has(basename2(file.path)))
12915
13606
  return "lockfile";
12916
13607
  if (isDoc(file.path))
12917
13608
  return "doc";
@@ -12944,7 +13635,7 @@ function globMatch(pattern, file) {
12944
13635
  function isRiskPath(file, extra = []) {
12945
13636
  if (extra.some((pattern) => globMatch(pattern, file)))
12946
13637
  return true;
12947
- if (RISK_FILES.has(file) || RISK_NAMES.has(basename(file)))
13638
+ if (RISK_FILES.has(file) || RISK_NAMES.has(basename2(file)))
12948
13639
  return true;
12949
13640
  if (TEST_PATH.test(file) || isDoc(file))
12950
13641
  return false;
@@ -12952,8 +13643,41 @@ function isRiskPath(file, extra = []) {
12952
13643
  }
12953
13644
  var parseRiskPaths = (text) => text.split(`
12954
13645
  `).map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.replace(/^\//u, ""));
13646
+ function additiveWorkflow(file, extra) {
13647
+ if (file.workflow?.additive !== true || file.binary || !isWorkflowFile(file.path))
13648
+ return false;
13649
+ if (extra.some((pattern) => globMatch(pattern, file.path)))
13650
+ return false;
13651
+ return !isRiskPath(file.path.replace(/^\.github\/workflows\//u, ".github/"), extra);
13652
+ }
13653
+ var ADDITIVE_CI_FLOOR = "an additive workflow edit needs a non-author verdict unless it rides a dependency bump";
13654
+ var CHANGELOG = /^(?:changelog|changes)(?:\.[^.]+)?$/iu;
13655
+ function dependencyBump(files, additive) {
13656
+ const manifests = files.filter((file) => file.manifest?.pins && !file.binary);
13657
+ if (!manifests.some((file) => (file.manifest?.bumped ?? 0) > 0))
13658
+ return null;
13659
+ const locks = [];
13660
+ for (const file of files) {
13661
+ if (additive.has(file.path) || manifests.includes(file))
13662
+ continue;
13663
+ if (LOCKFILES.has(basename2(file.path)))
13664
+ locks.push(file.path);
13665
+ else if (file.binary || !(isDoc(file.path) && CHANGELOG.test(basename2(file.path))))
13666
+ return null;
13667
+ }
13668
+ const bumped = manifests.reduce((sum, file) => sum + (file.manifest?.bumped ?? 0), 0);
13669
+ const scripts = manifests.flatMap((file) => file.manifest?.scripts ?? []);
13670
+ const list = (paths) => `${paths.slice(0, 3).join(", ")}${paths.length > 3 ? ", …" : ""}`;
13671
+ 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`;
13672
+ }
12955
13673
  function computeLane(input) {
12956
- const riskFiles = input.files.filter((file) => isRiskPath(file.path, input.riskPaths)).map((file) => file.path);
13674
+ const extra = input.riskPaths ?? [];
13675
+ const additive = input.files.filter((file) => additiveWorkflow(file, extra));
13676
+ const relaxed = new Set(additive.map((file) => file.path));
13677
+ const workflowNote = additive.length ? [
13678
+ `additive workflow edit: ${additive.slice(0, 3).map((file) => `${file.path} (${file.workflow?.detail ?? ""})`).join(", ")}${additive.length > 3 ? ", …" : ""}`
13679
+ ] : [];
13680
+ const riskFiles = input.files.filter((file) => isRiskPath(file.path, extra) && !relaxed.has(file.path)).map((file) => file.path);
12957
13681
  const risky = new Set(riskFiles);
12958
13682
  const kinds = input.files.map((file) => ({
12959
13683
  file,
@@ -12964,20 +13688,30 @@ function computeLane(input) {
12964
13688
  const opaque = behavior.filter((entry) => entry.kind === "lockfile" || entry.file.binary);
12965
13689
  const diffLines = input.files.reduce((sum, file) => sum + file.added + file.deleted, 0);
12966
13690
  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)`;
12967
- const result = (lane, reasons) => ({
12968
- lane,
12969
- reasons,
12970
- lines,
12971
- files: behavior.length,
12972
- riskFiles
12973
- });
13691
+ const result = (lane, reasons, classification) => {
13692
+ const floor = additive.length > 0 && !classification && (lane === "none" || lane === "self");
13693
+ return {
13694
+ lane: floor ? "focused" : lane,
13695
+ reasons: [...floor ? [ADDITIVE_CI_FLOOR] : [], ...reasons, ...workflowNote],
13696
+ lines,
13697
+ files: behavior.length,
13698
+ riskFiles,
13699
+ ...classification ? { classification } : {}
13700
+ };
13701
+ };
12974
13702
  const { selfMaxLines, selfMaxFiles, fullMinLines } = LANE_THRESHOLDS;
12975
13703
  if (input.riskTier === "high")
12976
13704
  return result("full", ["the task judgment records high risk"]);
12977
13705
  if (riskFiles.length)
12978
13706
  return result("full", [
12979
- `touches a risk path: ${riskFiles.slice(0, 3).join(", ")}${riskFiles.length > 3 ? ", …" : ""}`
13707
+ `touches a risk path: ${riskFiles.slice(0, 3).map((file) => {
13708
+ const refused = input.files.find((entry) => entry.path === file)?.workflow;
13709
+ return refused && !refused.additive ? `${file} (${refused.detail})` : file;
13710
+ }).join(", ")}${riskFiles.length > 3 ? ", …" : ""}`
12980
13711
  ]);
13712
+ const bump = dependencyBump(input.files, relaxed);
13713
+ if (bump && lines < fullMinLines)
13714
+ return result("self", [bump], "dependency-bump");
12981
13715
  if (!behavior.length)
12982
13716
  return result("none", [
12983
13717
  input.files.length ? "only docs, comments, formatting or generated copies changed" : "no changes"
@@ -13024,6 +13758,7 @@ function cosmeticFiles(cwd, fork, head) {
13024
13758
  return null;
13025
13759
  const out = new Set;
13026
13760
  const opaque = new Set;
13761
+ const facts = new Map;
13027
13762
  for (const entry of candidates) {
13028
13763
  const before = blobs.get(entry.oldBlob);
13029
13764
  let after = blobs.get(entry.newBlob);
@@ -13033,12 +13768,20 @@ function cosmeticFiles(cwd, fork, head) {
13033
13768
  } catch {
13034
13769
  after = undefined;
13035
13770
  }
13771
+ if (before && after && isWorkflowFile(entry.path))
13772
+ facts.set(entry.path, {
13773
+ workflow: workflowEdit(before.toString("utf8"), after.toString("utf8"))
13774
+ });
13775
+ else if (before && after && isManifest(entry.path))
13776
+ facts.set(entry.path, {
13777
+ manifest: manifestEdit(entry.path, before.toString("utf8"), after.toString("utf8"))
13778
+ });
13036
13779
  if (before && after && cosmeticChange(entry.path, before, after))
13037
13780
  out.add(entry.path);
13038
13781
  else if ([before, after].some((bytes) => bytes && hasOpaqueLineBreak(bytes.toString("utf8"))))
13039
13782
  opaque.add(entry.path);
13040
13783
  }
13041
- return { cosmetic: out, opaque };
13784
+ return { cosmetic: out, opaque, facts };
13042
13785
  }
13043
13786
  function generatedAt(cwd, fork, paths) {
13044
13787
  const files = treeFilesNamed(cwd, fork, ".gitattributes");
@@ -13063,7 +13806,8 @@ function laneFiles(cwd, fork, head, attributesAt = fork) {
13063
13806
  ...stats.map((entry) => ({
13064
13807
  ...entry,
13065
13808
  ...cosmetic.opaque.has(entry.path) ? { binary: true } : {},
13066
- cosmetic: !entry.binary && cosmetic.cosmetic.has(entry.path)
13809
+ cosmetic: !entry.binary && cosmetic.cosmetic.has(entry.path),
13810
+ ...cosmetic.facts.get(entry.path)
13067
13811
  })),
13068
13812
  ...head === null ? untrackedFiles(cwd).map((file) => untrackedStat(cwd, file)) : []
13069
13813
  ];
@@ -13646,10 +14390,10 @@ function appendRaw(cwd, row, options) {
13646
14390
  function appendHookObserved(cwd, row) {
13647
14391
  return appendRaw(cwd, { ...row, observer: "host_hook" }, {});
13648
14392
  }
13649
- var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
14393
+ var isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
13650
14394
  var str = (value) => typeof value === "string" ? value : null;
13651
14395
  var normalizeActor = (value) => {
13652
- const actor = isRecord2(value) ? value : {};
14396
+ const actor = isRecord3(value) ? value : {};
13653
14397
  return {
13654
14398
  host: str(actor.host) ?? "unknown",
13655
14399
  session: str(actor.session),
@@ -13713,7 +14457,7 @@ function readLedgerAt(cwd, file, options) {
13713
14457
  skipped += 1;
13714
14458
  continue;
13715
14459
  }
13716
- if (!isRecord2(parsed) || !str(parsed.id) || !str(parsed.type) || !str(parsed.at)) {
14460
+ if (!isRecord3(parsed) || !str(parsed.id) || !str(parsed.type) || !str(parsed.at)) {
13717
14461
  skipped += 1;
13718
14462
  continue;
13719
14463
  }
@@ -16072,14 +16816,14 @@ var SCOPE_FIELDS = new Set([
16072
16816
 
16073
16817
  // packages/workit-core/src/core/release-packages.ts
16074
16818
  var KNOWN_FIELDS2 = new Set(["tagNamespace", "changelogPath"]);
16075
- var isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
16819
+ var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
16076
16820
  var NAMESPACE = /^[A-Za-z@][\w.@/+-]*$/u;
16077
16821
  var validTagNamespace = (value) => NAMESPACE.test(value) && !value.includes("..") && !value.includes("@{") && !value.includes("//") && !value.endsWith(".lock") && !/\d$/u.test(value);
16078
16822
  function readReleasePackages(raw) {
16079
16823
  const out = { packages: [], issues: [] };
16080
16824
  if (raw === undefined || raw === null)
16081
16825
  return out;
16082
- if (!isRecord3(raw)) {
16826
+ if (!isRecord4(raw)) {
16083
16827
  out.issues.push("releasePackages is not an object; ignored");
16084
16828
  return out;
16085
16829
  }
@@ -16090,7 +16834,7 @@ function readReleasePackages(raw) {
16090
16834
  out.issues.push(`${label}: a blank or padded name; ignored`);
16091
16835
  continue;
16092
16836
  }
16093
- if (!isRecord3(entry)) {
16837
+ if (!isRecord4(entry)) {
16094
16838
  out.issues.push(`${label} is not an object; ignored`);
16095
16839
  continue;
16096
16840
  }
@@ -18674,7 +19418,8 @@ var WORKIT_USER_ONLY = [
18674
19418
  ["install"],
18675
19419
  ["workspace", "seal"]
18676
19420
  ];
18677
- var USER_ONLY_WORD = new RegExp(`\\b(?:${[...new Set(WORKIT_USER_ONLY.map((words) => words[0]))].join("|")})\\b`);
19421
+ var WORKIT_ASKED_VERBS = ["feedback"];
19422
+ var USER_ONLY_WORD = new RegExp(`\\b(?:${[...new Set([...WORKIT_USER_ONLY.map((words) => words[0]), ...WORKIT_ASKED_VERBS])].join("|")})\\b`);
18678
19423
  var mayRunUserOnly = (text) => {
18679
19424
  const joined = text.replace(/\\\r?\n/g, "");
18680
19425
  const bare = joined.replace(/['"\\]/g, "");
@@ -18743,6 +19488,37 @@ var userOnlyWorkitCall = (command, dialect = "posix") => {
18743
19488
  }
18744
19489
  return null;
18745
19490
  };
19491
+ var askedWorkitCall = (command, dialect = "posix") => {
19492
+ if (!mayRunUserOnly(command))
19493
+ return null;
19494
+ for (const segment of segmentsOf(command, dialect)) {
19495
+ if (segment.unanalyzable)
19496
+ continue;
19497
+ const start = segment.words.findIndex(isWorkitWord);
19498
+ if (start < 0)
19499
+ continue;
19500
+ const words = segment.words.slice(start + 1);
19501
+ let at = 0;
19502
+ for (;; ) {
19503
+ const word = words[at];
19504
+ if (word === "--json")
19505
+ at += 1;
19506
+ else if (word === "--cwd" || word === "--session")
19507
+ at += 2;
19508
+ else if (word?.startsWith("--cwd="))
19509
+ at += 1;
19510
+ else
19511
+ break;
19512
+ }
19513
+ const verb = WORKIT_ASKED_VERBS.find((name) => words[at] === name);
19514
+ if (verb && !helpOnly(words.slice(at), [verb]))
19515
+ return {
19516
+ verb,
19517
+ plain: at === 0 && start === 0 && segment.words[0] === "workit"
19518
+ };
19519
+ }
19520
+ return null;
19521
+ };
18746
19522
  // packages/workit-core/src/core/heavy-rules.ts
18747
19523
  import fs17 from "node:fs";
18748
19524
  import os6 from "node:os";
@@ -18757,7 +19533,7 @@ var readText3 = (file) => {
18757
19533
  throw error;
18758
19534
  }
18759
19535
  };
18760
- var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
19536
+ var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
18761
19537
  function parseJsonc(text) {
18762
19538
  let out = "";
18763
19539
  for (let index = 0;index < text.length; index += 1) {
@@ -18831,12 +19607,12 @@ function claudeRules(cwd, env = process.env) {
18831
19607
  if (text === null)
18832
19608
  continue;
18833
19609
  const value = JSON.parse(text);
18834
- if (!isRecord4(value))
19610
+ if (!isRecord5(value))
18835
19611
  return "unreadable";
18836
19612
  const permissions = value.permissions;
18837
19613
  if (permissions === undefined)
18838
19614
  continue;
18839
- if (!isRecord4(permissions))
19615
+ if (!isRecord5(permissions))
18840
19616
  return "unreadable";
18841
19617
  for (const [key, bucket] of [
18842
19618
  ["deny", rules.deny],
@@ -18870,7 +19646,7 @@ var opencodePermission = (permission, rules) => {
18870
19646
  (permission === "allow" ? rules.allow : rules.deny).push("");
18871
19647
  return ["allow", "ask", "deny"].includes(permission);
18872
19648
  }
18873
- if (!isRecord4(permission))
19649
+ if (!isRecord5(permission))
18874
19650
  return false;
18875
19651
  for (const key of ["bash", "shell"]) {
18876
19652
  const value = permission[key];
@@ -18882,7 +19658,7 @@ var opencodePermission = (permission, rules) => {
18882
19658
  (value === "allow" ? rules.allow : rules.deny).push("");
18883
19659
  continue;
18884
19660
  }
18885
- if (!isRecord4(value))
19661
+ if (!isRecord5(value))
18886
19662
  return false;
18887
19663
  for (const [pattern, action] of Object.entries(value)) {
18888
19664
  if (action !== "allow" && action !== "ask" && action !== "deny")
@@ -18900,7 +19676,7 @@ var opencodeRuleset = (ruleset, rules) => {
18900
19676
  if (!Array.isArray(ruleset))
18901
19677
  return false;
18902
19678
  for (const rule of ruleset) {
18903
- if (!isRecord4(rule))
19679
+ if (!isRecord5(rule))
18904
19680
  return false;
18905
19681
  const { action, resource, effect } = rule;
18906
19682
  if (typeof action !== "string" || typeof resource !== "string")
@@ -18915,11 +19691,11 @@ var opencodeRuleset = (ruleset, rules) => {
18915
19691
  var opencodeAgents = (agents, read) => {
18916
19692
  if (agents === undefined)
18917
19693
  return true;
18918
- if (!isRecord4(agents))
19694
+ if (!isRecord5(agents))
18919
19695
  return false;
18920
- return Object.values(agents).every((agent) => isRecord4(agent) && read(agent));
19696
+ return Object.values(agents).every((agent) => isRecord5(agent) && read(agent));
18921
19697
  };
18922
- var opencodeConfig = (value, rules) => isRecord4(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));
19698
+ 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));
18923
19699
  function opencodeRules(cwd, env = process.env) {
18924
19700
  const rules = EMPTY2();
18925
19701
  try {
@@ -19008,11 +19784,11 @@ function cursorRules(cwd, env = process.env) {
19008
19784
  if (text === null)
19009
19785
  continue;
19010
19786
  const value = JSON.parse(text);
19011
- if (!isRecord4(value))
19787
+ if (!isRecord5(value))
19012
19788
  return "unreadable";
19013
19789
  if (value.permissions === undefined)
19014
19790
  continue;
19015
- if (!isRecord4(value.permissions))
19791
+ if (!isRecord5(value.permissions))
19016
19792
  return "unreadable";
19017
19793
  for (const [key, bucket] of [
19018
19794
  ["deny", rules.deny],
@@ -19437,11 +20213,11 @@ var readJson = (file) => {
19437
20213
  return;
19438
20214
  }
19439
20215
  };
19440
- var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
20216
+ var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
19441
20217
  var stringList = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
19442
20218
  function machinePatterns(env) {
19443
20219
  const value = readJson(heavyCommandsFile(env));
19444
- return isRecord5(value) ? stringList(value.patterns) : [];
20220
+ return isRecord6(value) ? stringList(value.patterns) : [];
19445
20221
  }
19446
20222
  function repoPatterns(cwd) {
19447
20223
  return repoHeavyCommands(gitTop(cwd) ?? path27.resolve(cwd));
@@ -21687,11 +22463,11 @@ var workitSkillOf = (name) => {
21687
22463
  const skill = bare.replace(/^workit:/, "workit-");
21688
22464
  return WORKIT_METHOD_SKILLS.includes(skill) ? skill : null;
21689
22465
  };
21690
- var QUOTED = /```[\s\S]*?```|["`“][^"`”\n]*["`”]|\B'[^'\n]*'\B/g;
22466
+ var QUOTED2 = /```[\s\S]*?```|["`“][^"`”\n]*["`”]|\B'[^'\n]*'\B/g;
21691
22467
  var COMPLAINT = /\b(why \w+ you|you keep|stop \w+ing)\b.*?(?=\b(and|but)\b|[?.,;\n]|$)/gi;
21692
22468
  var promptTrigger = (prompt) => {
21693
22469
  let asking = false;
21694
- const text = prompt.slice(0, 4000).replace(QUOTED, " ").replace(COMPLAINT, (clause) => (asking ||= /ask|quest/i.test(clause), " "));
22470
+ const text = prompt.slice(0, 4000).replace(QUOTED2, " ").replace(COMPLAINT, (clause) => (asking ||= /ask|quest/i.test(clause), " "));
21695
22471
  for (const [skill, pattern] of PROMPT_INTENTS) {
21696
22472
  const match = !(asking && skill === "workit-shape") && pattern.exec(text);
21697
22473
  if (match)
@@ -21813,7 +22589,7 @@ ${line}` };
21813
22589
  // packages/workit-core/src/hooks/hosts/fields.ts
21814
22590
  import { existsSync as existsSync13, realpathSync as realpathSync9, statSync as statSync4 } from "node:fs";
21815
22591
  import path31 from "node:path";
21816
- var isRecord6 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
22592
+ var isRecord7 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
21817
22593
  var nonEmpty2 = (value) => typeof value === "string" && value.trim() !== "";
21818
22594
  var optionalText = (value) => typeof value === "string" ? value : null;
21819
22595
  var existingDirectory = (value) => {
@@ -21870,7 +22646,7 @@ var isWriteTool = (name) => typeof name === "string" && WRITE_TOOLS.has(name.toL
21870
22646
  var PATH_KEYS = ["file_path", "filePath", "notebook_path", "path", "target_file", "file"];
21871
22647
  var PATCH_HEADER = /^[ \t]*\*\*\* (?:(?:Add|Update|Delete) File|Move to): (.+)$/gm;
21872
22648
  var writePaths = (input) => {
21873
- if (!isRecord6(input))
22649
+ if (!isRecord7(input))
21874
22650
  return [];
21875
22651
  const paths = PATH_KEYS.map((key) => input[key]).filter(nonEmpty2);
21876
22652
  for (const value of Object.values(input))
@@ -22180,7 +22956,7 @@ var SHELL_TOOLS2 = new Set(["bash", "unified-exec"]);
22180
22956
  var isShellTool = (name) => SHELL_TOOLS2.has(String(name).toLowerCase());
22181
22957
  var SOURCES2 = new Set(["startup", "resume", "clear", "compact", "fork"]);
22182
22958
  var parseCodexHookInput = (value) => {
22183
- if (!isRecord6(value) || !Object.hasOwn(EVENTS, String(value.hook_event_name)))
22959
+ if (!isRecord7(value) || !Object.hasOwn(EVENTS, String(value.hook_event_name)))
22184
22960
  return { ok: false, error: "hook_event_name is required" };
22185
22961
  const event = value.hook_event_name;
22186
22962
  const cwd = existingDirectory(value.cwd);
@@ -22189,7 +22965,7 @@ var parseCodexHookInput = (value) => {
22189
22965
  const toolEvent = event === "PreToolUse" || event === "PostToolUse";
22190
22966
  if (toolEvent && !nonEmpty2(value.tool_name))
22191
22967
  return { ok: false, error: "tool_name is required" };
22192
- const command = isRecord6(value.tool_input) ? commandText(value.tool_input.command) : null;
22968
+ const command = isRecord7(value.tool_input) ? commandText(value.tool_input.command) : null;
22193
22969
  if (toolEvent && isShellTool(value.tool_name) && !command)
22194
22970
  return { ok: false, error: "tool_input.command is required for shell tools" };
22195
22971
  if (event === "SubagentStart" && !nonEmpty2(value.agent_id))
@@ -22304,7 +23080,7 @@ var codexAdapter = {
22304
23080
  const host = detectCodexSurface(env);
22305
23081
  const parsed = parseCodexHookInput(raw);
22306
23082
  if (!parsed.ok) {
22307
- const native = isRecord6(raw) && Object.hasOwn(EVENTS, String(raw.hook_event_name)) ? raw.hook_event_name : null;
23083
+ const native = isRecord7(raw) && Object.hasOwn(EVENTS, String(raw.hook_event_name)) ? raw.hook_event_name : null;
22308
23084
  return { ok: false, error: parsed.error, native, event: native ? EVENTS[native] : null };
22309
23085
  }
22310
23086
  const input = parsed.data;
@@ -24965,6 +25741,18 @@ function decide(input, deps) {
24965
25741
  unblock: null
24966
25742
  };
24967
25743
  }
25744
+ const asked = askedWorkitCall(event.command, event.dialect);
25745
+ if (asked && input.host === "claude_code")
25746
+ return {
25747
+ kind: "ask",
25748
+ reason: `\`workit ${asked.verb}\` reports to the Workit tracker: the user decides this call.`
25749
+ };
25750
+ if (asked && !asked.plain && canDeny && ["codex_cli", "codex_desktop"].includes(input.host))
25751
+ return {
25752
+ kind: "deny",
25753
+ reason: `Run \`workit ${asked.verb} …\` with nothing before the verb (no env, wrapper or global option), so Codex asks the user.`,
25754
+ unblock: null
25755
+ };
24968
25756
  const role = canDeny ? agentRole(input, descriptor) : null;
24969
25757
  if (role) {
24970
25758
  const confined = (role === "implementer" ? confineImplementerShell : confineJudgeShell)(input, event.command, event.dialect);