@brainervirus/workit-pi 8.21.0 → 8.22.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.
Files changed (2) hide show
  1. package/dist/workit.js +43 -4
  2. package/package.json +1 -1
package/dist/workit.js CHANGED
@@ -16563,6 +16563,9 @@ Autonomy contract:
16563
16563
  CLI first: if a step has one right answer, use the \`workit\` verb instead of
16564
16564
  hand-running git, gh or glab (\`workit git|pr|ci|check|help\`;
16565
16565
  else \`npx -y @brainervirus/workit-cli\`).
16566
+ Other checkout: \`workit --cwd <dir> <verb>\` (Codex: \`<verb> --cwd <dir>\`); one workit
16567
+ verb per shell call, never \`cd <dir> && workit\`. zsh-safe: no \`echo =====\`
16568
+ (\`printf '%s\\n' ---\`), quote globs and URLs, no variable named \`status\` or \`path\`.
16566
16569
  Add Co-Authored-By via \`workit git commit --trailer "K: v" -- <paths>\`, never
16567
16570
  an amend.
16568
16571
  The task families (task, policy, evidence, finding, decision, worker, state)
@@ -24145,6 +24148,40 @@ var standingDelta = (input) => {
24145
24148
  }
24146
24149
  };
24147
24150
  var sinceStart = new Map;
24151
+ // packages/workit-core/src/hooks/cwd-normalize.ts
24152
+ var COMPOUND = /^\s*cd\s+([A-Za-z0-9_./@%+:,=-]+|'[^'$`\\\n]*'|"[^"$`\\!\n]*")\s*&&\s*(workit(?:\s[\s\S]*)?)$/u;
24153
+ var FILTERS = new Set(["tail", "head", "grep"]);
24154
+ var stdinOnly = (words) => {
24155
+ const [name, ...args] = words;
24156
+ const operands = args.filter((w) => !w.startsWith("-"));
24157
+ if (name === "grep")
24158
+ return operands.length <= 1 && !args.some((w) => /^-[^-]*[rRf]|^--(recursive|file)/u.test(w));
24159
+ return operands.every((w) => /^\d+$/u.test(w)) && !args.some((w) => w.startsWith("--output"));
24160
+ };
24161
+ var cwdRewrite = (command) => {
24162
+ const match = COMPOUND.exec(command);
24163
+ const dir = match?.[1];
24164
+ const rest = match?.[2];
24165
+ if (!dir || !rest || dir.startsWith("-"))
24166
+ return null;
24167
+ if (/[&;<>`\n]/u.test(rest.replaceAll("2>&1", "")))
24168
+ return null;
24169
+ const segments = segmentsOf(rest);
24170
+ const [head, ...filters] = segments;
24171
+ if (!head || head.words[0] !== "workit")
24172
+ return null;
24173
+ if (head.words.some((w) => w === "--cwd" || w.startsWith("--cwd=")))
24174
+ return null;
24175
+ const clean = (s) => !s.unanalyzable && !s.group && !s.subs?.length && !s.stdin?.length && !s.redirects.length;
24176
+ if (!segments.every(clean))
24177
+ return null;
24178
+ if (!segments.slice(0, -1).every((s) => s.pipe))
24179
+ return null;
24180
+ if (!filters.every((s) => FILTERS.has(s.words[0] ?? "") && stdinOnly(s.words)))
24181
+ return null;
24182
+ return `workit --cwd ${dir} ${rest.slice("workit".length).trimStart()}`.trimEnd();
24183
+ };
24184
+
24148
24185
  // packages/workit-core/src/hooks/handle.ts
24149
24186
  var usable2 = (value) => value === "native" || value === "partial";
24150
24187
  var NONE5 = { kind: "none" };
@@ -24254,19 +24291,21 @@ function decide(input, deps) {
24254
24291
  if (plan.kind === "rewrite" && !rewrites && canDeny)
24255
24292
  return heavyDenial(event.command, plan);
24256
24293
  const lease = plan.kind === "rewrite" && rewrites ? plan : null;
24294
+ const cwdCommand = !lease && rewrites && input.host === "claude_code" ? cwdRewrite(event.command) : null;
24257
24295
  const aside = plan.kind === "passthrough" ? plan.note : null;
24258
24296
  noteRawCommit(input, event.command, postTool ? callKey(event.toolUseId, event.command) : NEXT_COMMAND);
24259
- const rewritten = (text) => lease ? {
24297
+ const rewrittenTo = lease?.command ?? cwdCommand;
24298
+ const rewritten = (text) => rewrittenTo ? {
24260
24299
  kind: "rewrite",
24261
- command: lease.command,
24262
- input: event.toolInput ? { ...event.toolInput, command: lease.command } : null,
24300
+ command: rewrittenTo,
24301
+ input: event.toolInput ? { ...event.toolInput, command: rewrittenTo } : null,
24263
24302
  text
24264
24303
  } : NONE5;
24265
24304
  if (descriptor.transport !== "hook-process")
24266
24305
  return rewritten(null);
24267
24306
  const nudged = withContextLine(withContextLine(canDeny ? rawGitPre(input, event.command) : NONE5, aside), shipNudge(input, event.command));
24268
24307
  if (!lease)
24269
- return nudged;
24308
+ return cwdCommand && nudged.kind !== "deny" ? rewritten(nudged.kind === "context" ? nudged.text : null) : nudged;
24270
24309
  return rewritten([rewriteNote(lease), nudged.kind === "context" ? nudged.text : null].filter(Boolean).join(`
24271
24310
  `));
24272
24311
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brainervirus/workit-pi",
3
- "version": "8.21.0",
3
+ "version": "8.22.0",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",