@workit-dev/pi 2.18.0 → 2.19.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()) {
@@ -8891,6 +8895,7 @@ effect before a retry.
8891
8895
  Mid-task: never silently drop or resume an objective (workit-continue).
8892
8896
  Notes, drafts, logs, resume files: \`workit dir notes|handoffs\` (outside the
8893
8897
  repo), never the repo tree.
8898
+ FEEDBACK_LINE
8894
8899
 
8895
8900
  Skills: load the skill, never act from memory.
8896
8901
  - 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;
@@ -18165,6 +18175,7 @@ function selectMethods(policy, capabilities) {
18165
18175
  return [{ id, reason: reasons.join("; "), assurance: capability.assurance }];
18166
18176
  });
18167
18177
  }
18178
+ var FEEDBACK_LINE = "Workit friction: offer `workit feedback` once per problem; keep working.";
18168
18179
  var BOOTSTRAP = `
18169
18180
  Workit is optional coordination and proof tooling: you decide what and
18170
18181
  whether, the CLI does how and records what it observed.
@@ -18219,6 +18230,7 @@ effect before a retry.
18219
18230
  Mid-task: never silently drop or resume an objective (workit-continue).
18220
18231
  Notes, drafts, logs, resume files: \`workit dir notes|handoffs\` (outside the
18221
18232
  repo), never the repo tree.
18233
+ FEEDBACK_LINE
18222
18234
 
18223
18235
  Skills: load the skill, never act from memory.
18224
18236
  - brainstorm, plan, spec, grill, should we: workit-shape
@@ -18236,9 +18248,13 @@ Skills: load the skill, never act from memory.
18236
18248
  - architecture, deepen modules (user-invoked; offer it): workit-architecture
18237
18249
  `.trim();
18238
18250
  var invariantBootstrap = (session = null) => {
18251
+ const feedbackOff = session !== null && workspaceFeedbackOff(session.cwd);
18252
+ const bootstrap = BOOTSTRAP.replace(`FEEDBACK_LINE
18253
+ `, () => feedbackOff ? "" : `${FEEDBACK_LINE}
18254
+ `);
18239
18255
  const table = session && hostFamily(session.host) === "claude_code" ? claudeSpawnTable(session.cwd) : null;
18240
- return table ? `${BOOTSTRAP}
18241
- ${table}` : BOOTSTRAP;
18256
+ return table ? `${bootstrap}
18257
+ ${table}` : bootstrap;
18242
18258
  };
18243
18259
 
18244
18260
  // packages/workit-core/src/core/task-context.ts
@@ -24951,7 +24967,8 @@ var WORKIT_USER_ONLY = [
24951
24967
  ["install"],
24952
24968
  ["workspace", "seal"]
24953
24969
  ];
24954
- var USER_ONLY_WORD = new RegExp(`\\b(?:${[...new Set(WORKIT_USER_ONLY.map((words) => words[0]))].join("|")})\\b`);
24970
+ var WORKIT_ASKED_VERBS = ["feedback"];
24971
+ var USER_ONLY_WORD = new RegExp(`\\b(?:${[...new Set([...WORKIT_USER_ONLY.map((words) => words[0]), ...WORKIT_ASKED_VERBS])].join("|")})\\b`);
24955
24972
  var mayRunUserOnly = (text) => {
24956
24973
  const joined = text.replace(/\\\r?\n/g, "");
24957
24974
  const bare = joined.replace(/['"\\]/g, "");
@@ -25020,6 +25037,37 @@ var userOnlyWorkitCall = (command, dialect = "posix") => {
25020
25037
  }
25021
25038
  return null;
25022
25039
  };
25040
+ var askedWorkitCall = (command, dialect = "posix") => {
25041
+ if (!mayRunUserOnly(command))
25042
+ return null;
25043
+ for (const segment of segmentsOf(command, dialect)) {
25044
+ if (segment.unanalyzable)
25045
+ continue;
25046
+ const start = segment.words.findIndex(isWorkitWord);
25047
+ if (start < 0)
25048
+ continue;
25049
+ const words = segment.words.slice(start + 1);
25050
+ let at = 0;
25051
+ for (;; ) {
25052
+ const word = words[at];
25053
+ if (word === "--json")
25054
+ at += 1;
25055
+ else if (word === "--cwd" || word === "--session")
25056
+ at += 2;
25057
+ else if (word?.startsWith("--cwd="))
25058
+ at += 1;
25059
+ else
25060
+ break;
25061
+ }
25062
+ const verb = WORKIT_ASKED_VERBS.find((name) => words[at] === name);
25063
+ if (verb && !helpOnly(words.slice(at), [verb]))
25064
+ return {
25065
+ verb,
25066
+ plain: at === 0 && start === 0 && segment.words[0] === "workit"
25067
+ };
25068
+ }
25069
+ return null;
25070
+ };
25023
25071
  // packages/workit-core/src/core/heavy-rules.ts
25024
25072
  import fs24 from "node:fs";
25025
25073
  import os7 from "node:os";
@@ -25787,7 +25835,7 @@ function heavyPlan(command, options) {
25787
25835
  };
25788
25836
  }
25789
25837
  if (single) {
25790
- const rewrite = leaseRewrite(command);
25838
+ const rewrite = leaseRewrite(command.trim().replace(TAIL_FILTER, ""));
25791
25839
  return rewrite ? { kind: "rewrite", command: rewrite, reason: single.reason } : { kind: "none" };
25792
25840
  }
25793
25841
  const parts = heavy.map((match) => leaseCommand(match.line));
@@ -25832,6 +25880,7 @@ function workitOnPath2(env = process.env) {
25832
25880
  }
25833
25881
  return false;
25834
25882
  }
25883
+ var TAIL_FILTER = /(?:\s+2>&1)?\s*\|\s*(?:tail|head)(?:\s+[\w=.+-]+)*\s*$/u;
25835
25884
  var ASSIGNMENTS = /^\s*((?:[A-Za-z_]\w*=(?:'[^']*'|"(?:[^"\\]|\\.)*"|[^\s'"])*\s+)*)/u;
25836
25885
  function leaseRewrite(command) {
25837
25886
  const text = command.trim();
@@ -31327,6 +31376,96 @@ Retry as: ${retry}` : ""}`,
31327
31376
  };
31328
31377
  };
31329
31378
 
31379
+ // packages/workit-core/src/hooks/exit-pipe.ts
31380
+ var EXIT_VERBS = [
31381
+ ["ci", "wait"],
31382
+ ["check"],
31383
+ ["pr", "merge"],
31384
+ ["release"],
31385
+ ["verify-delivery"]
31386
+ ];
31387
+ var base2 = (word = "") => word.split(/[\\/]/u).at(-1) ?? "";
31388
+ var quote4 = (word) => /^[\w@%+=:,./-]+$/u.test(word) ? word : `'${word.replaceAll("'", `'\\''`)}'`;
31389
+ var verbPath = (words) => {
31390
+ const path = [];
31391
+ for (let at = 0;at < words.length && path.length < 2; at += 1) {
31392
+ const word = words[at];
31393
+ if (word === "--")
31394
+ break;
31395
+ if (word === "--cwd")
31396
+ at += 1;
31397
+ else if (!word.startsWith("-"))
31398
+ path.push(word);
31399
+ }
31400
+ return path;
31401
+ };
31402
+ var exitCall = (words) => {
31403
+ let at = 0;
31404
+ while (at < words.length && /^[A-Za-z_]\w*=/u.test(words[at]))
31405
+ at += 1;
31406
+ if (!/^workit(?:-cli)?$/u.test(base2(words[at])))
31407
+ return null;
31408
+ const path = verbPath(words.slice(at + 1));
31409
+ return EXIT_VERBS.some((verb) => verb.every((word, index) => path[index] === word)) ? words.slice(at) : null;
31410
+ };
31411
+ var setsPipefail = (words) => words[0] === "set" && words.some((word, at) => word === "pipefail" && /^-[a-z]*o$/u.test(words[at - 1] ?? ""));
31412
+ var retryOf = ({ call, dir }) => {
31413
+ const at = call[1]?.startsWith("-") ? 1 : 2;
31414
+ const words = dir && !call.includes("--cwd") ? [...call.slice(0, at), "--cwd", dir, ...call.slice(at)] : call;
31415
+ return ["workit", ...words.slice(1)].map(quote4).join(" ");
31416
+ };
31417
+ function exitPipeGate(command, dialect = "posix") {
31418
+ if (!/\bworkit/u.test(command) || !/\b(?:tail|head)\b/u.test(command))
31419
+ return null;
31420
+ const subshellPiped = /\)\s*(?:\d*>&?\d*\s*)*\|(?!\|)/u.test(command);
31421
+ const groups = [];
31422
+ let carry = null;
31423
+ let pipefail = false;
31424
+ let dir = null;
31425
+ for (const segment of segmentsOf(command, dialect)) {
31426
+ if (segment.unanalyzable)
31427
+ return null;
31428
+ let words = segment.words;
31429
+ let closes = segment.group === "close";
31430
+ if (segment.group === "open") {
31431
+ groups.push(null);
31432
+ continue;
31433
+ }
31434
+ if (words[0] === "{") {
31435
+ groups.push(null);
31436
+ words = words.slice(1);
31437
+ } else if (words[0] === "}") {
31438
+ closes = true;
31439
+ words = words.slice(1);
31440
+ }
31441
+ if (closes) {
31442
+ const inner = groups.pop() ?? null;
31443
+ const piped = segment.pipe === true || segment.group === "close" && subshellPiped;
31444
+ carry = piped ? inner ?? carry : null;
31445
+ continue;
31446
+ }
31447
+ if (setsPipefail(words))
31448
+ pipefail = true;
31449
+ const filter = base2(words[0]);
31450
+ if (carry && !pipefail && (filter === "tail" || filter === "head")) {
31451
+ const retry = retryOf(carry);
31452
+ return {
31453
+ kind: "deny",
31454
+ reason: `workit exit-pipe: piping \`workit ${verbPath(carry.call.slice(1)).join(" ")}\` into ${filter} hides its exit code.
31455
+ Retry as: ${retry}`,
31456
+ unblock: retry
31457
+ };
31458
+ }
31459
+ const call = exitCall(words);
31460
+ const found = call ? { call, dir } : null;
31461
+ if (found && groups.length)
31462
+ groups[groups.length - 1] = found;
31463
+ carry = segment.pipe ? found ?? carry : null;
31464
+ dir = words.length === 2 && words[0] === "cd" && !segment.expands?.length ? words[1] : null;
31465
+ }
31466
+ return null;
31467
+ }
31468
+
31330
31469
  // packages/workit-core/src/hooks/handle.ts
31331
31470
  var usable2 = (value) => value === "native" || value === "partial";
31332
31471
  var NONE6 = { kind: "none" };
@@ -31470,6 +31609,9 @@ function decide(input, deps) {
31470
31609
  const ytrack = canDeny ? ytrackGate(input.cwd, event.command, event.dialect ?? "posix", input.host === "claude_code") : null;
31471
31610
  if (ytrack)
31472
31611
  return ytrack;
31612
+ const piped = canDeny ? exitPipeGate(event.command, event.dialect) : null;
31613
+ if (piped)
31614
+ return piped;
31473
31615
  const split = canDeny ? cdWorkitSplit(event.command) : null;
31474
31616
  if (split)
31475
31617
  return {
@@ -31494,6 +31636,18 @@ function decide(input, deps) {
31494
31636
  unblock: null
31495
31637
  };
31496
31638
  }
31639
+ const asked = askedWorkitCall(event.command, event.dialect);
31640
+ if (asked && input.host === "claude_code")
31641
+ return {
31642
+ kind: "ask",
31643
+ reason: `\`workit ${asked.verb}\` reports to the Workit tracker: the user decides this call.`
31644
+ };
31645
+ if (asked && !asked.plain && canDeny && ["codex_cli", "codex_desktop"].includes(input.host))
31646
+ return {
31647
+ kind: "deny",
31648
+ reason: `Run \`workit ${asked.verb} …\` with nothing before the verb (no env, wrapper or global option), so Codex asks the user.`,
31649
+ unblock: null
31650
+ };
31497
31651
  const role = canDeny ? agentRole(input, descriptor) : null;
31498
31652
  if (role) {
31499
31653
  const confined = (role === "implementer" ? confineImplementerShell : confineJudgeShell)(input, event.command, event.dialect);
@@ -31749,7 +31903,7 @@ var noteModelSelect = (event, ctx) => {
31749
31903
  if (next && previous && next !== previous)
31750
31904
  switchedSessions.add(ctx.sessionManager.getSessionId());
31751
31905
  };
31752
- var modelSwitchContract = (ctx) => switchedSessions.delete(ctx.sessionManager.getSessionId()) && ctx.isProjectTrusted() ? contractBlock(null) : null;
31906
+ var modelSwitchContract = (ctx) => switchedSessions.delete(ctx.sessionManager.getSessionId()) && ctx.isProjectTrusted() ? contractBlock(ctx.cwd, null) : null;
31753
31907
  var turnContext = (ctx) => taskTurnContext(ctx);
31754
31908
  var turnInput = (ctx) => ({
31755
31909
  host: "pi",
@@ -31777,15 +31931,15 @@ var budgetNotice = (ctx) => {
31777
31931
  const session = process.env.WORKIT_PI_WORKER_SESSION && process.env.WORKIT_SESSION_ID?.trim() || ctx.sessionManager.getSessionId();
31778
31932
  return tickBudget(ctx.cwd, session, null) ? budgetLine(ctx.cwd, session, null) : null;
31779
31933
  };
31780
- var contractBlock = (addendum) => `<workit-contract>
31781
- ${invariantBootstrap()}${addendum ? `
31934
+ var contractBlock = (cwd, addendum) => `<workit-contract>
31935
+ ${invariantBootstrap({ cwd, host: "pi" })}${addendum ? `
31782
31936
  ${addendum}` : ""}
31783
31937
  </workit-contract>`;
31784
31938
  var workitContext = (ctx, taskContext = taskTurnContext(ctx)) => {
31785
31939
  const session = ctx.sessionManager.getSessionId();
31786
31940
  if (!ctx.isProjectTrusted())
31787
- return contractBlock(`Native Pi session: ${session}. Project-local Workit state is unavailable until Pi trusts this project.`);
31788
- return contractBlock(`Native Pi session: ${session}.${taskContext ? `
31941
+ return contractBlock(ctx.cwd, `Native Pi session: ${session}. Project-local Workit state is unavailable until Pi trusts this project.`);
31942
+ return contractBlock(ctx.cwd, `Native Pi session: ${session}.${taskContext ? `
31789
31943
  ${taskContext}` : ""}`);
31790
31944
  };
31791
31945
  var unfinishedTaskOffer2 = (ctx) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/pi",
3
- "version": "2.18.0",
3
+ "version": "2.19.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
@@ -53,7 +53,7 @@ the same check. Fix round and recheck both failed: the decider agent (read the `
53
53
  with `workit check`, fix the root cause, batch every fix in one push, one focused commit per fix (unrelated hunks in one file: `workit git stage --patch <file>`, then `workit git commit -m "<msg>" --staged`). A tool warning is a finding: fix it in this PR in the right layer, or record the false positive with evidence; pre-existing ones get their own PR.
54
54
  6. **Verified.** The lane in `workit pr status` decides: none, no verdict; self, your `--self` verdict; focused or full (or `verification: self|independent`), one non-author verifier per PR after the last push, never per push (read the `workit-review` skill's SKILL.md and follow it), on Claude Code with the `model` and `effort` of `workit models show --role verifier`. A docs-only push (or test-only under a unit verdict) keeps the verdict (`carried`); `reverify: focused` re-checks only the new diff, reusing green CI; one verdict at a stack's top covers its unchanged lower PRs. Land only when
55
55
  granted: `workit stack land` or `workit pr merge`; `--unverified --reason` if user-asked.
56
- Never pipe a delivery verb through `grep`: read its exit code, or use `--json`.
56
+ Never pipe a delivery verb through `grep`, `tail` or `head`: read its exit code, or use `--json`. Trunk CI after a merge: `workit ci wait --branch <trunk>`.
57
57
  7. **Observe it landed:** `workit verify-delivery pr` or `merge`. After a failed
58
58
  verdict or a check red 3+ times, at any endpoint: offer `/wk-retro` in one
59
59
  line of the final or stop report; never pause the babysit loop for it.