@workit-dev/pi 2.18.1 → 2.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.js CHANGED
@@ -7406,6 +7406,7 @@ var workspaceConfigSchema = object({
7406
7406
  trailers: boolean2().optional().describe("Whether commits get the `Workit-Session:` trailer (default true). With false, authorship lives in the ledger only."),
7407
7407
  deleteBranch: boolean2().optional().describe("Whether `workit pr merge` deletes the head branch after a merge (default true); `--keep-branch` opts out for one merge."),
7408
7408
  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`."),
7409
+ 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.'),
7409
7410
  liveSessionGuard: boolean2().optional().describe("Whether the live-session guard denies edits in a checkout another live agent session owns (default true)."),
7410
7411
  fanout: object({
7411
7412
  tierModels: unknown().optional().describe("The model per slice TIER (mundane, standard, hard), as one name or per host.")
@@ -7448,7 +7449,10 @@ var workspaceConfigSchema = object({
7448
7449
  });
7449
7450
  var workspacesFileSchema = object({
7450
7451
  workspaces: array(workspaceConfigSchema).optional().describe("Workspace entries, each mapping a path glob to its forge, policies and grants."),
7451
- 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).")
7452
+ 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)."),
7453
+ feedback: object({
7454
+ account: nonBlank.optional().describe("The GitHub login `workit feedback --post` uses when no workspace names one; never the workspace's work account by default.")
7455
+ }).passthrough().optional().describe("`workit feedback` defaults for every workspace.")
7452
7456
  }).passthrough().superRefine((file, context) => {
7453
7457
  const names = new Set;
7454
7458
  for (const [index, workspace] of (file.workspaces ?? []).entries()) {
@@ -8168,6 +8172,15 @@ import { createHash as createHash3, randomBytes } from "node:crypto";
8168
8172
  import fs7 from "node:fs";
8169
8173
  import path10 from "node:path";
8170
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
+
8171
8184
  // packages/workit-core/src/core/policy/substance.ts
8172
8185
  var SLASH_BLOCK = [["/*", "*/"]];
8173
8186
  var C_LIKE = { line: ["//"], block: SLASH_BLOCK, quotes: `"'` };
@@ -8210,6 +8223,11 @@ var REGEX_KEYWORDS = new Set([
8210
8223
  ]);
8211
8224
  var decoder = new TextDecoder("utf-8", { fatal: true });
8212
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
+
8213
8231
  // packages/workit-core/src/core/policy/lane.ts
8214
8232
  var RISK_TOKENS = new Set([
8215
8233
  "auth",
@@ -8891,6 +8909,7 @@ effect before a retry.
8891
8909
  Mid-task: never silently drop or resume an objective (workit-continue).
8892
8910
  Notes, drafts, logs, resume files: \`workit dir notes|handoffs\` (outside the
8893
8911
  repo), never the repo tree.
8912
+ FEEDBACK_LINE
8894
8913
 
8895
8914
  Skills: load the skill, never act from memory.
8896
8915
  - brainstorm, plan, spec, grill, should we: workit-shape
package/dist/workit.js CHANGED
@@ -9170,6 +9170,7 @@ var workspaceConfigSchema = object({
9170
9170
  trailers: boolean2().optional().describe("Whether commits get the `Workit-Session:` trailer (default true). With false, authorship lives in the ledger only."),
9171
9171
  deleteBranch: boolean2().optional().describe("Whether `workit pr merge` deletes the head branch after a merge (default true); `--keep-branch` opts out for one merge."),
9172
9172
  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`."),
9173
+ 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.'),
9173
9174
  liveSessionGuard: boolean2().optional().describe("Whether the live-session guard denies edits in a checkout another live agent session owns (default true)."),
9174
9175
  fanout: object({
9175
9176
  tierModels: unknown().optional().describe("The model per slice TIER (mundane, standard, hard), as one name or per host.")
@@ -9212,7 +9213,10 @@ var workspaceConfigSchema = object({
9212
9213
  });
9213
9214
  var workspacesFileSchema = object({
9214
9215
  workspaces: array(workspaceConfigSchema).optional().describe("Workspace entries, each mapping a path glob to its forge, policies and grants."),
9215
- 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).")
9216
+ 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)."),
9217
+ feedback: object({
9218
+ account: nonBlank.optional().describe("The GitHub login `workit feedback --post` uses when no workspace names one; never the workspace's work account by default.")
9219
+ }).passthrough().optional().describe("`workit feedback` defaults for every workspace.")
9216
9220
  }).passthrough().superRefine((file, context) => {
9217
9221
  const names = new Set;
9218
9222
  for (const [index, workspace] of (file.workspaces ?? []).entries()) {
@@ -9657,6 +9661,12 @@ var workspaceTrailers = (cwd, dir) => {
9657
9661
  };
9658
9662
  };
9659
9663
  var workspaceLiveSessionGuard = (cwd, dir) => inheritedSetting(cwd, dir, (entry) => typeof entry.liveSessionGuard === "boolean")?.source?.liveSessionGuard !== false;
9664
+ var feedbackSetting = (cwd, dir) => {
9665
+ const found = inheritedSetting(cwd, dir, (entry) => entry.feedback !== undefined);
9666
+ const value = found?.source?.feedback;
9667
+ return { found, value, off: value === "off" };
9668
+ };
9669
+ var workspaceFeedbackOff = (cwd, dir) => feedbackSetting(cwd, dir).off;
9660
9670
  var changelogPathOf = (value) => {
9661
9671
  if (typeof value !== "string")
9662
9672
  return null;
@@ -14993,6 +15003,203 @@ function generatedByAttributes(files, paths) {
14993
15003
  return out;
14994
15004
  }
14995
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
+
14996
15203
  // packages/workit-core/src/core/policy/substance.ts
14997
15204
  var SLASH_BLOCK = [["/*", "*/"]];
14998
15205
  var C_LIKE = { line: ["//"], block: SLASH_BLOCK, quotes: `"'` };
@@ -15311,6 +15518,483 @@ function cosmeticChange(file, before, after) {
15311
15518
  return a !== null && a === substanceOf(file, right);
15312
15519
  }
15313
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
+
15314
15998
  // packages/workit-core/src/core/policy/lane.ts
15315
15999
  var LANE_THRESHOLDS = {
15316
16000
  selfMaxLines: 100,
@@ -15371,15 +16055,16 @@ var DOC_EXT = /\.(?:md|mdx|markdown|rst|adoc)$/iu;
15371
16055
  var DOC_NAMES = /^(?:license|licence|notice|authors|changelog|changes|contributors)$/iu;
15372
16056
  var INSTRUCTIONS = /(?:^|\/)(?:AGENTS|CLAUDE|GEMINI|SKILL)\.md$|(?:^|\/)(?:skills|agents|commands|rules|prompts)\/[^/]+/iu;
15373
16057
  var TEST_PATH = /(?:^|\/)(?:test|tests|__tests__)\/|\.(?:test|spec)\.[^/]+$|_test\.[^/]+$/iu;
16058
+ var DEPENDENCY_BUMP_EVIDENCE = "green CI on the head";
15374
16059
  var plural = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
15375
- var basename = (file) => file.slice(file.lastIndexOf("/") + 1);
15376
- 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)));
15377
16062
  function kindOf(file) {
15378
16063
  if (file.binary)
15379
16064
  return "behavior";
15380
16065
  if (file.generated)
15381
16066
  return "generated";
15382
- if (LOCKFILES.has(basename(file.path)))
16067
+ if (LOCKFILES.has(basename2(file.path)))
15383
16068
  return "lockfile";
15384
16069
  if (isDoc(file.path))
15385
16070
  return "doc";
@@ -15412,7 +16097,7 @@ function globMatch(pattern, file) {
15412
16097
  function isRiskPath(file, extra = []) {
15413
16098
  if (extra.some((pattern) => globMatch(pattern, file)))
15414
16099
  return true;
15415
- if (RISK_FILES.has(file) || RISK_NAMES.has(basename(file)))
16100
+ if (RISK_FILES.has(file) || RISK_NAMES.has(basename2(file)))
15416
16101
  return true;
15417
16102
  if (TEST_PATH.test(file) || isDoc(file))
15418
16103
  return false;
@@ -15420,8 +16105,41 @@ function isRiskPath(file, extra = []) {
15420
16105
  }
15421
16106
  var parseRiskPaths = (text) => text.split(`
15422
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
+ }
15423
16135
  function computeLane(input) {
15424
- 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);
15425
16143
  const risky = new Set(riskFiles);
15426
16144
  const kinds = input.files.map((file) => ({
15427
16145
  file,
@@ -15432,20 +16150,30 @@ function computeLane(input) {
15432
16150
  const opaque = behavior.filter((entry) => entry.kind === "lockfile" || entry.file.binary);
15433
16151
  const diffLines = input.files.reduce((sum, file) => sum + file.added + file.deleted, 0);
15434
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)`;
15435
- const result = (lane, reasons) => ({
15436
- lane,
15437
- reasons,
15438
- lines,
15439
- files: behavior.length,
15440
- riskFiles
15441
- });
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
+ };
15442
16164
  const { selfMaxLines, selfMaxFiles, fullMinLines } = LANE_THRESHOLDS;
15443
16165
  if (input.riskTier === "high")
15444
16166
  return result("full", ["the task judgment records high risk"]);
15445
16167
  if (riskFiles.length)
15446
16168
  return result("full", [
15447
- `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 ? ", …" : ""}`
15448
16173
  ]);
16174
+ const bump = dependencyBump(input.files, relaxed);
16175
+ if (bump && lines < fullMinLines)
16176
+ return result("self", [bump], "dependency-bump");
15449
16177
  if (!behavior.length)
15450
16178
  return result("none", [
15451
16179
  input.files.length ? "only docs, comments, formatting or generated copies changed" : "no changes"
@@ -15492,6 +16220,7 @@ function cosmeticFiles(cwd, fork, head) {
15492
16220
  return null;
15493
16221
  const out = new Set;
15494
16222
  const opaque = new Set;
16223
+ const facts = new Map;
15495
16224
  for (const entry of candidates) {
15496
16225
  const before = blobs.get(entry.oldBlob);
15497
16226
  let after = blobs.get(entry.newBlob);
@@ -15501,12 +16230,20 @@ function cosmeticFiles(cwd, fork, head) {
15501
16230
  } catch {
15502
16231
  after = undefined;
15503
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
+ });
15504
16241
  if (before && after && cosmeticChange(entry.path, before, after))
15505
16242
  out.add(entry.path);
15506
16243
  else if ([before, after].some((bytes) => bytes && hasOpaqueLineBreak(bytes.toString("utf8"))))
15507
16244
  opaque.add(entry.path);
15508
16245
  }
15509
- return { cosmetic: out, opaque };
16246
+ return { cosmetic: out, opaque, facts };
15510
16247
  }
15511
16248
  function generatedAt(cwd, fork, paths) {
15512
16249
  const files = treeFilesNamed(cwd, fork, ".gitattributes");
@@ -15531,7 +16268,8 @@ function laneFiles(cwd, fork, head, attributesAt = fork) {
15531
16268
  ...stats.map((entry) => ({
15532
16269
  ...entry,
15533
16270
  ...cosmetic.opaque.has(entry.path) ? { binary: true } : {},
15534
- cosmetic: !entry.binary && cosmetic.cosmetic.has(entry.path)
16271
+ cosmetic: !entry.binary && cosmetic.cosmetic.has(entry.path),
16272
+ ...cosmetic.facts.get(entry.path)
15535
16273
  })),
15536
16274
  ...head === null ? untrackedFiles(cwd).map((file) => untrackedStat(cwd, file)) : []
15537
16275
  ];
@@ -16036,10 +16774,10 @@ function appendObserved(cwd, row, options = {}) {
16036
16774
  function appendHookObserved(cwd, row) {
16037
16775
  return appendRaw(cwd, { ...row, observer: "host_hook" }, {});
16038
16776
  }
16039
- var isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
16777
+ var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
16040
16778
  var str2 = (value) => typeof value === "string" ? value : null;
16041
16779
  var normalizeActor = (value) => {
16042
- const actor = isRecord3(value) ? value : {};
16780
+ const actor = isRecord4(value) ? value : {};
16043
16781
  return {
16044
16782
  host: str2(actor.host) ?? "unknown",
16045
16783
  session: str2(actor.session),
@@ -16103,7 +16841,7 @@ function readLedgerAt(cwd, file, options) {
16103
16841
  skipped += 1;
16104
16842
  continue;
16105
16843
  }
16106
- 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)) {
16107
16845
  skipped += 1;
16108
16846
  continue;
16109
16847
  }
@@ -18165,6 +18903,7 @@ function selectMethods(policy, capabilities) {
18165
18903
  return [{ id, reason: reasons.join("; "), assurance: capability.assurance }];
18166
18904
  });
18167
18905
  }
18906
+ var FEEDBACK_LINE = "Workit friction: offer `workit feedback` once per problem; keep working.";
18168
18907
  var BOOTSTRAP = `
18169
18908
  Workit is optional coordination and proof tooling: you decide what and
18170
18909
  whether, the CLI does how and records what it observed.
@@ -18219,6 +18958,7 @@ effect before a retry.
18219
18958
  Mid-task: never silently drop or resume an objective (workit-continue).
18220
18959
  Notes, drafts, logs, resume files: \`workit dir notes|handoffs\` (outside the
18221
18960
  repo), never the repo tree.
18961
+ FEEDBACK_LINE
18222
18962
 
18223
18963
  Skills: load the skill, never act from memory.
18224
18964
  - brainstorm, plan, spec, grill, should we: workit-shape
@@ -18236,9 +18976,13 @@ Skills: load the skill, never act from memory.
18236
18976
  - architecture, deepen modules (user-invoked; offer it): workit-architecture
18237
18977
  `.trim();
18238
18978
  var invariantBootstrap = (session = null) => {
18979
+ const feedbackOff = session !== null && workspaceFeedbackOff(session.cwd);
18980
+ const bootstrap = BOOTSTRAP.replace(`FEEDBACK_LINE
18981
+ `, () => feedbackOff ? "" : `${FEEDBACK_LINE}
18982
+ `);
18239
18983
  const table = session && hostFamily(session.host) === "claude_code" ? claudeSpawnTable(session.cwd) : null;
18240
- return table ? `${BOOTSTRAP}
18241
- ${table}` : BOOTSTRAP;
18984
+ return table ? `${bootstrap}
18985
+ ${table}` : bootstrap;
18242
18986
  };
18243
18987
 
18244
18988
  // packages/workit-core/src/core/task-context.ts
@@ -18979,14 +19723,14 @@ var SCOPE_FIELDS = new Set([
18979
19723
 
18980
19724
  // packages/workit-core/src/core/release-packages.ts
18981
19725
  var KNOWN_FIELDS2 = new Set(["tagNamespace", "changelogPath"]);
18982
- var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
19726
+ var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
18983
19727
  var NAMESPACE = /^[A-Za-z@][\w.@/+-]*$/u;
18984
19728
  var validTagNamespace = (value) => NAMESPACE.test(value) && !value.includes("..") && !value.includes("@{") && !value.includes("//") && !value.endsWith(".lock") && !/\d$/u.test(value);
18985
19729
  function readReleasePackages(raw) {
18986
19730
  const out = { packages: [], issues: [] };
18987
19731
  if (raw === undefined || raw === null)
18988
19732
  return out;
18989
- if (!isRecord4(raw)) {
19733
+ if (!isRecord5(raw)) {
18990
19734
  out.issues.push("releasePackages is not an object; ignored");
18991
19735
  return out;
18992
19736
  }
@@ -18997,7 +19741,7 @@ function readReleasePackages(raw) {
18997
19741
  out.issues.push(`${label}: a blank or padded name; ignored`);
18998
19742
  continue;
18999
19743
  }
19000
- if (!isRecord4(entry)) {
19744
+ if (!isRecord5(entry)) {
19001
19745
  out.issues.push(`${label} is not an object; ignored`);
19002
19746
  continue;
19003
19747
  }
@@ -24951,7 +25695,8 @@ var WORKIT_USER_ONLY = [
24951
25695
  ["install"],
24952
25696
  ["workspace", "seal"]
24953
25697
  ];
24954
- var USER_ONLY_WORD = new RegExp(`\\b(?:${[...new Set(WORKIT_USER_ONLY.map((words) => words[0]))].join("|")})\\b`);
25698
+ var WORKIT_ASKED_VERBS = ["feedback"];
25699
+ var USER_ONLY_WORD = new RegExp(`\\b(?:${[...new Set([...WORKIT_USER_ONLY.map((words) => words[0]), ...WORKIT_ASKED_VERBS])].join("|")})\\b`);
24955
25700
  var mayRunUserOnly = (text) => {
24956
25701
  const joined = text.replace(/\\\r?\n/g, "");
24957
25702
  const bare = joined.replace(/['"\\]/g, "");
@@ -25020,6 +25765,37 @@ var userOnlyWorkitCall = (command, dialect = "posix") => {
25020
25765
  }
25021
25766
  return null;
25022
25767
  };
25768
+ var askedWorkitCall = (command, dialect = "posix") => {
25769
+ if (!mayRunUserOnly(command))
25770
+ return null;
25771
+ for (const segment of segmentsOf(command, dialect)) {
25772
+ if (segment.unanalyzable)
25773
+ continue;
25774
+ const start = segment.words.findIndex(isWorkitWord);
25775
+ if (start < 0)
25776
+ continue;
25777
+ const words = segment.words.slice(start + 1);
25778
+ let at = 0;
25779
+ for (;; ) {
25780
+ const word = words[at];
25781
+ if (word === "--json")
25782
+ at += 1;
25783
+ else if (word === "--cwd" || word === "--session")
25784
+ at += 2;
25785
+ else if (word?.startsWith("--cwd="))
25786
+ at += 1;
25787
+ else
25788
+ break;
25789
+ }
25790
+ const verb = WORKIT_ASKED_VERBS.find((name) => words[at] === name);
25791
+ if (verb && !helpOnly(words.slice(at), [verb]))
25792
+ return {
25793
+ verb,
25794
+ plain: at === 0 && start === 0 && segment.words[0] === "workit"
25795
+ };
25796
+ }
25797
+ return null;
25798
+ };
25023
25799
  // packages/workit-core/src/core/heavy-rules.ts
25024
25800
  import fs24 from "node:fs";
25025
25801
  import os7 from "node:os";
@@ -25034,7 +25810,7 @@ var readText3 = (file) => {
25034
25810
  throw error;
25035
25811
  }
25036
25812
  };
25037
- var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
25813
+ var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
25038
25814
  function parseJsonc(text) {
25039
25815
  let out = "";
25040
25816
  for (let index = 0;index < text.length; index += 1) {
@@ -25108,12 +25884,12 @@ function claudeRules(cwd, env = process.env) {
25108
25884
  if (text === null)
25109
25885
  continue;
25110
25886
  const value = JSON.parse(text);
25111
- if (!isRecord5(value))
25887
+ if (!isRecord6(value))
25112
25888
  return "unreadable";
25113
25889
  const permissions = value.permissions;
25114
25890
  if (permissions === undefined)
25115
25891
  continue;
25116
- if (!isRecord5(permissions))
25892
+ if (!isRecord6(permissions))
25117
25893
  return "unreadable";
25118
25894
  for (const [key, bucket] of [
25119
25895
  ["deny", rules.deny],
@@ -25147,7 +25923,7 @@ var opencodePermission = (permission, rules) => {
25147
25923
  (permission === "allow" ? rules.allow : rules.deny).push("");
25148
25924
  return ["allow", "ask", "deny"].includes(permission);
25149
25925
  }
25150
- if (!isRecord5(permission))
25926
+ if (!isRecord6(permission))
25151
25927
  return false;
25152
25928
  for (const key of ["bash", "shell"]) {
25153
25929
  const value = permission[key];
@@ -25159,7 +25935,7 @@ var opencodePermission = (permission, rules) => {
25159
25935
  (value === "allow" ? rules.allow : rules.deny).push("");
25160
25936
  continue;
25161
25937
  }
25162
- if (!isRecord5(value))
25938
+ if (!isRecord6(value))
25163
25939
  return false;
25164
25940
  for (const [pattern, action] of Object.entries(value)) {
25165
25941
  if (action !== "allow" && action !== "ask" && action !== "deny")
@@ -25177,7 +25953,7 @@ var opencodeRuleset = (ruleset, rules) => {
25177
25953
  if (!Array.isArray(ruleset))
25178
25954
  return false;
25179
25955
  for (const rule of ruleset) {
25180
- if (!isRecord5(rule))
25956
+ if (!isRecord6(rule))
25181
25957
  return false;
25182
25958
  const { action, resource, effect } = rule;
25183
25959
  if (typeof action !== "string" || typeof resource !== "string")
@@ -25192,11 +25968,11 @@ var opencodeRuleset = (ruleset, rules) => {
25192
25968
  var opencodeAgents = (agents, read) => {
25193
25969
  if (agents === undefined)
25194
25970
  return true;
25195
- if (!isRecord5(agents))
25971
+ if (!isRecord6(agents))
25196
25972
  return false;
25197
- return Object.values(agents).every((agent) => isRecord5(agent) && read(agent));
25973
+ return Object.values(agents).every((agent) => isRecord6(agent) && read(agent));
25198
25974
  };
25199
- 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));
25200
25976
  function opencodeRules(cwd, env = process.env) {
25201
25977
  const rules = EMPTY2();
25202
25978
  try {
@@ -25285,11 +26061,11 @@ function cursorRules(cwd, env = process.env) {
25285
26061
  if (text === null)
25286
26062
  continue;
25287
26063
  const value = JSON.parse(text);
25288
- if (!isRecord5(value))
26064
+ if (!isRecord6(value))
25289
26065
  return "unreadable";
25290
26066
  if (value.permissions === undefined)
25291
26067
  continue;
25292
- if (!isRecord5(value.permissions))
26068
+ if (!isRecord6(value.permissions))
25293
26069
  return "unreadable";
25294
26070
  for (const [key, bucket] of [
25295
26071
  ["deny", rules.deny],
@@ -25714,11 +26490,11 @@ var readJson = (file) => {
25714
26490
  return;
25715
26491
  }
25716
26492
  };
25717
- var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
26493
+ var isRecord7 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
25718
26494
  var stringList = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
25719
26495
  function machinePatterns(env) {
25720
26496
  const value = readJson(heavyCommandsFile(env));
25721
- return isRecord6(value) ? stringList(value.patterns) : [];
26497
+ return isRecord7(value) ? stringList(value.patterns) : [];
25722
26498
  }
25723
26499
  function repoPatterns(cwd) {
25724
26500
  return repoHeavyCommands(gitTop(cwd) ?? path38.resolve(cwd));
@@ -28013,11 +28789,11 @@ var workitSkillOf = (name) => {
28013
28789
  const skill = bare.replace(/^workit:/, "workit-");
28014
28790
  return WORKIT_METHOD_SKILLS.includes(skill) ? skill : null;
28015
28791
  };
28016
- var QUOTED = /```[\s\S]*?```|["`“][^"`”\n]*["`”]|\B'[^'\n]*'\B/g;
28792
+ var QUOTED2 = /```[\s\S]*?```|["`“][^"`”\n]*["`”]|\B'[^'\n]*'\B/g;
28017
28793
  var COMPLAINT = /\b(why \w+ you|you keep|stop \w+ing)\b.*?(?=\b(and|but)\b|[?.,;\n]|$)/gi;
28018
28794
  var promptTrigger = (prompt) => {
28019
28795
  let asking = false;
28020
- 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), " "));
28021
28797
  for (const [skill, pattern] of PROMPT_INTENTS) {
28022
28798
  const match = !(asking && skill === "workit-shape") && pattern.exec(text);
28023
28799
  if (match)
@@ -28138,7 +28914,7 @@ ${line}` };
28138
28914
  };
28139
28915
  var shellNudge = (input, command) => withContextLine(rawGitPre(input, command), shipNudge(input, command));
28140
28916
  // packages/workit-core/src/hooks/hosts/fields.ts
28141
- var isRecord7 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
28917
+ var isRecord8 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
28142
28918
  var nonEmpty2 = (value) => typeof value === "string" && value.trim() !== "";
28143
28919
  var SHELLS2 = new Set(["sh", "bash", "zsh", "dash", "pwsh", "powershell", "cmd"]);
28144
28920
  var WRITE_TOOLS = new Set([
@@ -28163,7 +28939,7 @@ var WRITE_TOOLS = new Set([
28163
28939
  var PATH_KEYS = ["file_path", "filePath", "notebook_path", "path", "target_file", "file"];
28164
28940
  var PATCH_HEADER = /^[ \t]*\*\*\* (?:(?:Add|Update|Delete) File|Move to): (.+)$/gm;
28165
28941
  var writePaths = (input) => {
28166
- if (!isRecord7(input))
28942
+ if (!isRecord8(input))
28167
28943
  return [];
28168
28944
  const paths = PATH_KEYS.map((key) => input[key]).filter(nonEmpty2);
28169
28945
  for (const value of Object.values(input))
@@ -31588,6 +32364,18 @@ function decide(input, deps) {
31588
32364
  unblock: null
31589
32365
  };
31590
32366
  }
32367
+ const asked = askedWorkitCall(event.command, event.dialect);
32368
+ if (asked && input.host === "claude_code")
32369
+ return {
32370
+ kind: "ask",
32371
+ reason: `\`workit ${asked.verb}\` reports to the Workit tracker: the user decides this call.`
32372
+ };
32373
+ if (asked && !asked.plain && canDeny && ["codex_cli", "codex_desktop"].includes(input.host))
32374
+ return {
32375
+ kind: "deny",
32376
+ reason: `Run \`workit ${asked.verb} …\` with nothing before the verb (no env, wrapper or global option), so Codex asks the user.`,
32377
+ unblock: null
32378
+ };
31591
32379
  const role = canDeny ? agentRole(input, descriptor) : null;
31592
32380
  if (role) {
31593
32381
  const confined = (role === "implementer" ? confineImplementerShell : confineJudgeShell)(input, event.command, event.dialect);
@@ -31843,7 +32631,7 @@ var noteModelSelect = (event, ctx) => {
31843
32631
  if (next && previous && next !== previous)
31844
32632
  switchedSessions.add(ctx.sessionManager.getSessionId());
31845
32633
  };
31846
- var modelSwitchContract = (ctx) => switchedSessions.delete(ctx.sessionManager.getSessionId()) && ctx.isProjectTrusted() ? contractBlock(null) : null;
32634
+ var modelSwitchContract = (ctx) => switchedSessions.delete(ctx.sessionManager.getSessionId()) && ctx.isProjectTrusted() ? contractBlock(ctx.cwd, null) : null;
31847
32635
  var turnContext = (ctx) => taskTurnContext(ctx);
31848
32636
  var turnInput = (ctx) => ({
31849
32637
  host: "pi",
@@ -31871,15 +32659,15 @@ var budgetNotice = (ctx) => {
31871
32659
  const session = process.env.WORKIT_PI_WORKER_SESSION && process.env.WORKIT_SESSION_ID?.trim() || ctx.sessionManager.getSessionId();
31872
32660
  return tickBudget(ctx.cwd, session, null) ? budgetLine(ctx.cwd, session, null) : null;
31873
32661
  };
31874
- var contractBlock = (addendum) => `<workit-contract>
31875
- ${invariantBootstrap()}${addendum ? `
32662
+ var contractBlock = (cwd, addendum) => `<workit-contract>
32663
+ ${invariantBootstrap({ cwd, host: "pi" })}${addendum ? `
31876
32664
  ${addendum}` : ""}
31877
32665
  </workit-contract>`;
31878
32666
  var workitContext = (ctx, taskContext = taskTurnContext(ctx)) => {
31879
32667
  const session = ctx.sessionManager.getSessionId();
31880
32668
  if (!ctx.isProjectTrusted())
31881
- return contractBlock(`Native Pi session: ${session}. Project-local Workit state is unavailable until Pi trusts this project.`);
31882
- return contractBlock(`Native Pi session: ${session}.${taskContext ? `
32669
+ return contractBlock(ctx.cwd, `Native Pi session: ${session}. Project-local Workit state is unavailable until Pi trusts this project.`);
32670
+ return contractBlock(ctx.cwd, `Native Pi session: ${session}.${taskContext ? `
31883
32671
  ${taskContext}` : ""}`);
31884
32672
  };
31885
32673
  var unfinishedTaskOffer2 = (ctx) => {
@@ -32283,9 +33071,9 @@ import { randomUUID as randomUUID5 } from "node:crypto";
32283
33071
  // packages/workit-pi/src/worker-protocol.ts
32284
33072
  var MAX_WORKER_LINE_BYTES = 64 * 1024;
32285
33073
  var MAX_WORKER_STDERR_BYTES = 64 * 1024;
32286
- var isRecord8 = (value) => typeof value === "object" && value !== null;
33074
+ var isRecord9 = (value) => typeof value === "object" && value !== null;
32287
33075
  var parseEvent2 = (value) => {
32288
- if (!isRecord8(value) || typeof value.type !== "string")
33076
+ if (!isRecord9(value) || typeof value.type !== "string")
32289
33077
  return null;
32290
33078
  if (value.type === "workit_worker_ready") {
32291
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.18.1",
3
+ "version": "2.20.0",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",
@@ -42,7 +42,7 @@ proposes and stops. Nothing changes until the user approves.
42
42
  agent behaviour, becomes an issue or PR on BrainerVirus/workit, not a host
43
43
  memory (one host reads it). Never fork a local copy. Use a minimal synthetic
44
44
  repro: no private repo name, path, code, ledger text, PR, thread or transcript.
45
- Paste the exact draft; once approved: `workit issue create --repo BrainerVirus/workit`.
45
+ Paste the whole `workit feedback "<title>" --body-file -` draft; `--post` once approved.
46
46
  6. **Bloat guards.** AGENTS.md stays within 8 KB: each addition names what it
47
47
  removes. Create `CODING_STANDARDS.md` or `GLOSSARY.md` only in the same
48
48
  edit as its first real entry, never as a scaffold. Edit steering text by