@workit-dev/pi 2.4.4 → 2.5.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
@@ -9172,6 +9172,17 @@ import path14 from "node:path";
9172
9172
  var REQUEST_TTL_MS = 30 * 60000;
9173
9173
  var GRANT_TTL_MS = 15 * 60000;
9174
9174
  var ASKING_HOSTS = new Set(["claude_code", "pi"]);
9175
+ var INLINE_ASK_TTL_MS = 2 * 60000;
9176
+
9177
+ // packages/workit-core/src/approvals/youtrack-ask.ts
9178
+ var TIME = "markdown file minutes text date";
9179
+ var FLAGS = {
9180
+ note: TIME,
9181
+ time: TIME,
9182
+ meeting: TIME,
9183
+ update: `${TIME} attach state command`,
9184
+ create: "project summary description file attach command"
9185
+ };
9175
9186
 
9176
9187
  // packages/workit-core/src/hooks/hosts/fields.ts
9177
9188
  var SHELLS2 = new Set(["sh", "bash", "zsh", "dash", "pwsh", "powershell", "cmd"]);
@@ -9302,7 +9313,7 @@ var CONTEXT_EVENTS = new Set([
9302
9313
  "PreToolUse",
9303
9314
  "PostToolUse"
9304
9315
  ]);
9305
- var ASKING_MODES = new Set(["default", "acceptEdits", "plan"]);
9316
+ var ASKING_MODES = new Set(["default", "acceptEdits", "plan", "auto"]);
9306
9317
 
9307
9318
  // packages/workit-core/src/hooks/hosts/codex.ts
9308
9319
  var CODEX_DESCRIPTOR = {
package/dist/workit.js CHANGED
@@ -27971,11 +27971,11 @@ var writePaths = (input) => {
27971
27971
  };
27972
27972
  // packages/workit-core/src/hooks/standing.ts
27973
27973
  import fs30 from "node:fs";
27974
- import path45 from "node:path";
27974
+ import path46 from "node:path";
27975
27975
 
27976
27976
  // packages/workit-core/src/approvals/store.ts
27977
27977
  import { createHash as createHash19, randomBytes as randomBytes4 } from "node:crypto";
27978
- import { mkdirSync as mkdirSync6, readdirSync as readdirSync6, readFileSync as readFileSync13 } from "node:fs";
27978
+ import { mkdirSync as mkdirSync6, readdirSync as readdirSync6, readFileSync as readFileSync13, rmSync as rmSync3 } from "node:fs";
27979
27979
  import path43 from "node:path";
27980
27980
  var REQUEST_TTL_MS = 30 * 60000;
27981
27981
  var GRANT_TTL_MS = 15 * 60000;
@@ -28006,6 +28006,13 @@ var write = (file, value) => {
28006
28006
  `);
28007
28007
  };
28008
28008
  var live = (expires, now) => Date.parse(expires) > now.getTime();
28009
+ var names2 = (part) => {
28010
+ try {
28011
+ return readdirSync6(dirOf(part)).filter((name) => name.endsWith(".json"));
28012
+ } catch {
28013
+ return [];
28014
+ }
28015
+ };
28009
28016
  var later = (now, ms) => new Date(now.getTime() + ms).toISOString();
28010
28017
  var readApprovalRequest = (id) => {
28011
28018
  if (!isApprovalId(id))
@@ -28037,12 +28044,21 @@ var liveApprovalRequest = (id, now = new Date) => {
28037
28044
  };
28038
28045
  return { ok: true, request };
28039
28046
  };
28040
- var subjectLine = (subject) => Object.entries(subject).map(([key, value]) => `${key}: ${typeof value === "string" ? value : JSON.stringify(value)}`).join("; ");
28047
+ var SHOWN_LINES = 60;
28048
+ var shownText = (text, indent = " ") => {
28049
+ const lines = text.trimEnd().split(/\r?\n/u);
28050
+ const more = lines.length - SHOWN_LINES;
28051
+ if (more > 0)
28052
+ lines.splice(SHOWN_LINES, more, `… ${more} more lines`);
28053
+ return lines.map((line) => indent + line);
28054
+ };
28055
+ var subjectLines = (subject) => Object.entries(subject).flatMap(([key, value]) => typeof value === "string" && value.includes(`
28056
+ `) ? [` ${key}:`, ...shownText(value)] : [` ${key}: ${typeof value === "string" ? value : JSON.stringify(value)}`]);
28041
28057
  var renderApprovalRequest = (request) => [
28042
28058
  `${request.id} (${request.kind}): ${request.action}`,
28043
28059
  ` target: ${Object.entries(request.target).map(([key, value]) => `${key} ${value}`).join(", ")}`,
28044
28060
  ` effect: ${request.effect}`,
28045
- ` subject: ${subjectLine(request.subject)}`,
28061
+ ...subjectLines(request.subject),
28046
28062
  ` hash: ${request.hash.slice(0, 12)} expires: ${request.expires}`
28047
28063
  ].join(`
28048
28064
  `);
@@ -28104,6 +28120,31 @@ var recordApprovalRejected = (input, now = new Date) => {
28104
28120
  write(fileOf("rejected", input.id), { ...input, at: now.toISOString() });
28105
28121
  };
28106
28122
  var ASKING_HOSTS = new Set(["claude_code", "pi"]);
28123
+ var INLINE_ASK_TTL_MS = 2 * 60000;
28124
+ var INLINE_TICKET_ENV = "WORKIT_APPROVAL_TICKET";
28125
+ var namesTicket = (text) => /WORKIT_APPROVAL_(?:TICKET|UNASKED)/u.test(text.replace(/['"\\]/gu, ""));
28126
+ var TICKET_DENY = "Only the host's prompt adds an approval ticket.";
28127
+ var dropInline = (drop) => {
28128
+ for (const name of names2("inline")) {
28129
+ const file = path43.join(dirOf("inline"), name);
28130
+ const row = readJson3(file);
28131
+ if (!row || drop(row))
28132
+ rmSync3(file, { force: true });
28133
+ }
28134
+ };
28135
+ var sha = (text) => createHash19("sha256").update(text).digest("hex");
28136
+ var recordInlineAsk = (input, now = new Date, ttlMs = INLINE_ASK_TTL_MS) => {
28137
+ dropInline((row) => row.argvHash === input.argvHash && row.contentHash === input.contentHash);
28138
+ const ticket = randomBytes4(24).toString("base64url");
28139
+ const asked = {
28140
+ ...input,
28141
+ ticketHash: sha(ticket),
28142
+ at: now.toISOString(),
28143
+ expires: later(now, ttlMs)
28144
+ };
28145
+ write(fileOf("inline", asked.ticketHash), asked);
28146
+ return { ticket, asked };
28147
+ };
28107
28148
 
28108
28149
  // packages/workit-core/src/approvals/call.ts
28109
28150
  var isWorkitWord2 = (word) => /^(?:.*[\\/])?workit(?:-cli)?$/u.test(word);
@@ -28146,6 +28187,139 @@ var approveCallIn = (command, dialect = "posix") => {
28146
28187
  };
28147
28188
  var approveCallDeny = (fix) => `Run \`${fix}\` as its own call: no chain, pipe, substitution, leading cd, env prefix or redirect around it, so the host can show the request and record the user's answer.`;
28148
28189
 
28190
+ // packages/workit-core/src/approvals/youtrack-ask.ts
28191
+ import { createHash as createHash20 } from "node:crypto";
28192
+ import { readFileSync as readFileSync14, realpathSync as realpathSync11 } from "node:fs";
28193
+ import path44 from "node:path";
28194
+ var TIME = "markdown file minutes text date";
28195
+ var FLAGS = {
28196
+ note: TIME,
28197
+ time: TIME,
28198
+ meeting: TIME,
28199
+ update: `${TIME} attach state command`,
28200
+ create: "project summary description file attach command"
28201
+ };
28202
+ var isYouTrackWriteVerb = (word) => Object.hasOwn(FLAGS, word ?? "");
28203
+ var sha2563 = (data) => createHash20("sha256").update(data).digest("hex");
28204
+ var youTrackAsk = (args, cwd, load = readFileSync14) => {
28205
+ const [verb = "", ...rest] = args;
28206
+ if (!isYouTrackWriteVerb(verb))
28207
+ return null;
28208
+ const known = FLAGS[verb]?.split(" ") ?? [];
28209
+ const values = {};
28210
+ const attach = [];
28211
+ const positionals = [];
28212
+ for (let index = 0;index < rest.length; index += 1) {
28213
+ const arg = rest[index] ?? "";
28214
+ if (arg === "--") {
28215
+ positionals.push(...rest.slice(index + 1));
28216
+ break;
28217
+ }
28218
+ if (arg === "--json")
28219
+ continue;
28220
+ if (!arg.startsWith("--")) {
28221
+ positionals.push(arg);
28222
+ continue;
28223
+ }
28224
+ const eq = arg.indexOf("=");
28225
+ const name = arg.slice(2, eq < 0 ? undefined : eq);
28226
+ const value = eq >= 0 ? arg.slice(eq + 1) : rest[++index];
28227
+ if (!known.includes(name) || !value || eq < 0 && value.startsWith("--"))
28228
+ return null;
28229
+ if (name === "attach")
28230
+ attach.push(value);
28231
+ else
28232
+ values[name] = value;
28233
+ }
28234
+ const files = [];
28235
+ const read = (file) => {
28236
+ try {
28237
+ const named = path44.resolve(cwd, file);
28238
+ const content = load(named);
28239
+ files.push([realpathSync11(named), sha2563(content)]);
28240
+ return content;
28241
+ } catch {
28242
+ return null;
28243
+ }
28244
+ };
28245
+ const fromFile = values.file === undefined ? undefined : read(values.file);
28246
+ if (fromFile === null)
28247
+ return null;
28248
+ const lines = [];
28249
+ const text = fromFile?.toString("utf8") ?? values.markdown ?? values.description;
28250
+ const [target, extra] = positionals;
28251
+ let action = `workit youtrack ${verb} ${target}`;
28252
+ if (verb === "create") {
28253
+ if (!values.project || !values.summary?.trim() || target !== undefined)
28254
+ return null;
28255
+ action = `workit youtrack create --project ${values.project}`;
28256
+ lines.push(`new ${values.project} issue: ${values.summary.trim()}`);
28257
+ if (text !== undefined)
28258
+ lines.push("description:", ...shownText(text));
28259
+ } else {
28260
+ if (!target || !/^[A-Z][A-Z0-9_]*-\d+$/u.test(target) || extra !== undefined)
28261
+ return null;
28262
+ if (text !== undefined)
28263
+ lines.push("comment:", ...shownText(text));
28264
+ if (values.minutes)
28265
+ lines.push(`time: ${values.minutes}m on ${values.date ?? "today"}${values.text === undefined ? "" : ` ("${values.text}")`}`);
28266
+ if (values.state)
28267
+ lines.push(`state: ${values.state}`);
28268
+ }
28269
+ if (values.command)
28270
+ lines.push(`command: ${values.command}`);
28271
+ for (const file of attach) {
28272
+ const content = read(file);
28273
+ if (!content)
28274
+ return null;
28275
+ lines.push(`attach: ${path44.basename(file)} (${content.length} bytes)`);
28276
+ }
28277
+ if (!lines.length)
28278
+ return null;
28279
+ return {
28280
+ kind: "youtrack-write",
28281
+ action,
28282
+ text: [`Yes runs ${action} once:`, ...lines].join(`
28283
+ `),
28284
+ argvHash: sha2563(canonicalJson(args)),
28285
+ contentHash: sha2563(canonicalJson({ args, files }))
28286
+ };
28287
+ };
28288
+
28289
+ // packages/workit-core/src/approvals/inline.ts
28290
+ var asked = (words) => words[0] === "youtrack" && isYouTrackWriteVerb(words[1]);
28291
+ var quote2 = (word) => /^[\w@%+=:,./-]+$/u.test(word) ? word : `'${word.replaceAll("'", `'\\''`)}'`;
28292
+ var inlineCallIn = (command, dialect = "posix") => {
28293
+ if (!/\bworkit\b/u.test(command))
28294
+ return null;
28295
+ const segments = segmentsOf(command, dialect);
28296
+ for (const segment of segments) {
28297
+ if (segment.unanalyzable)
28298
+ continue;
28299
+ const { words } = segment;
28300
+ const script = (words[0] ?? "").endsWith("sh") ? words.find((word) => /\bworkit\s+youtrack\s/u.test(word)) : undefined;
28301
+ if (script)
28302
+ return { plain: false, fix: script.trim() };
28303
+ const start = words.findIndex(isWorkitWord2);
28304
+ if (start < 0)
28305
+ continue;
28306
+ const at = verbIndex(words, start + 1);
28307
+ const call = words.slice(at);
28308
+ if (!asked(call))
28309
+ continue;
28310
+ const plain = segments.length === 1 && start === 0 && words[0] === "workit" && at === 1 && !segment.redirects.length && !segment.subs?.length && !segment.stdin?.length && !segment.expands?.length && !segment.group;
28311
+ if (plain)
28312
+ return { plain: true, words: call };
28313
+ return {
28314
+ plain: false,
28315
+ fix: `workit ${call.map(quote2).join(" ")}`
28316
+ };
28317
+ }
28318
+ return null;
28319
+ };
28320
+ var inlineAskFor = (words, cwd) => asked(words) && youTrackWritesMode(cwd) !== "auto" ? youTrackAsk(words.slice(1), cwd) : null;
28321
+ var inlineCallDeny = (fix) => `Run \`${fix}\` as its own call so the host can ask the user.`;
28322
+
28149
28323
  // packages/workit-core/src/hooks/hosts/claude-code.ts
28150
28324
  var CLAUDE_CODE_DESCRIPTOR = {
28151
28325
  host: "claude_code",
@@ -28253,7 +28427,7 @@ var CONTEXT_EVENTS = new Set([
28253
28427
  "PreToolUse",
28254
28428
  "PostToolUse"
28255
28429
  ]);
28256
- var ASKING_MODES = new Set(["default", "acceptEdits", "plan"]);
28430
+ var ASKING_MODES = new Set(["default", "acceptEdits", "plan", "auto"]);
28257
28431
 
28258
28432
  // packages/workit-core/src/hooks/hosts/codex.ts
28259
28433
  var CODEX_DESCRIPTOR = {
@@ -28619,37 +28793,37 @@ function neededChecks(lane, configured) {
28619
28793
  }
28620
28794
 
28621
28795
  // packages/workit-core/src/hooks/worktree-confine.ts
28622
- import { createHash as createHash20 } from "node:crypto";
28796
+ import { createHash as createHash21 } from "node:crypto";
28623
28797
  import fs29 from "node:fs";
28624
- import path44 from "node:path";
28798
+ import path45 from "node:path";
28625
28799
  var FANOUT_TOKEN_FILE = "workit-fanout-token";
28626
28800
  var NONE5 = { kind: "none" };
28627
28801
  var CASE_INSENSITIVE2 = process.platform === "darwin" || process.platform === "win32";
28628
28802
  var realOf = (file) => {
28629
28803
  let rest = "";
28630
- for (let dir = file;; dir = path44.dirname(dir)) {
28804
+ for (let dir = file;; dir = path45.dirname(dir)) {
28631
28805
  try {
28632
- return path44.join(fs29.realpathSync.native(dir), rest);
28806
+ return path45.join(fs29.realpathSync.native(dir), rest);
28633
28807
  } catch {
28634
- if (path44.dirname(dir) === dir)
28808
+ if (path45.dirname(dir) === dir)
28635
28809
  return file;
28636
- rest = rest ? path44.join(path44.basename(dir), rest) : path44.basename(dir);
28810
+ rest = rest ? path45.join(path45.basename(dir), rest) : path45.basename(dir);
28637
28811
  }
28638
28812
  }
28639
28813
  };
28640
28814
  var canonical5 = (file, hops = { chain: 40, total: 1000 }) => {
28641
- const start = path44.isAbsolute(file) ? file : `${process.cwd()}${path44.sep}${file}`;
28642
- const { root } = path44.parse(start);
28815
+ const start = path45.isAbsolute(file) ? file : `${process.cwd()}${path45.sep}${file}`;
28816
+ const { root } = path45.parse(start);
28643
28817
  let at = root;
28644
28818
  let missing = false;
28645
28819
  for (const part of start.slice(root.length).split(/[\\/]+/)) {
28646
28820
  if (part === "" || part === ".")
28647
28821
  continue;
28648
28822
  if (part === "..") {
28649
- at = path44.dirname(at);
28823
+ at = path45.dirname(at);
28650
28824
  continue;
28651
28825
  }
28652
- const next = path44.join(at, part);
28826
+ const next = path45.join(at, part);
28653
28827
  let link = null;
28654
28828
  if (!missing)
28655
28829
  try {
@@ -28661,25 +28835,25 @@ var canonical5 = (file, hops = { chain: 40, total: 1000 }) => {
28661
28835
  at = next;
28662
28836
  hops.chain = 40;
28663
28837
  } else if (hops.chain-- > 0 && hops.total-- > 0)
28664
- at = canonical5(path44.isAbsolute(link) ? link : `${at}${path44.sep}${link}`, hops);
28838
+ at = canonical5(path45.isAbsolute(link) ? link : `${at}${path45.sep}${link}`, hops);
28665
28839
  else
28666
- return path44.resolve(file);
28840
+ return path45.resolve(file);
28667
28841
  }
28668
28842
  return realOf(at);
28669
28843
  };
28670
28844
  var within = (child, parent) => {
28671
28845
  const fold = (value) => CASE_INSENSITIVE2 ? value.toLowerCase() : value;
28672
- const relative = path44.relative(fold(parent), fold(child));
28673
- return relative === "" || !relative.startsWith("..") && !path44.isAbsolute(relative);
28846
+ const relative = path45.relative(fold(parent), fold(child));
28847
+ return relative === "" || !relative.startsWith("..") && !path45.isAbsolute(relative);
28674
28848
  };
28675
28849
  var checkoutOf2 = (file) => {
28676
- for (let dir = canonical5(file);; dir = path44.dirname(dir)) {
28677
- const dotGit = path44.join(dir, ".git");
28850
+ for (let dir = canonical5(file);; dir = path45.dirname(dir)) {
28851
+ const dotGit = path45.join(dir, ".git");
28678
28852
  if (fs29.existsSync(dotGit)) {
28679
28853
  const admin = fs29.statSync(dotGit).isFile() ? gitDirsAt(dir, null, false)?.[0] : undefined;
28680
- return { root: dir, workit: !!admin && fs29.existsSync(path44.join(admin, FANOUT_TOKEN_FILE)) };
28854
+ return { root: dir, workit: !!admin && fs29.existsSync(path45.join(admin, FANOUT_TOKEN_FILE)) };
28681
28855
  }
28682
- if (path44.dirname(dir) === dir)
28856
+ if (path45.dirname(dir) === dir)
28683
28857
  return null;
28684
28858
  }
28685
28859
  };
@@ -28691,8 +28865,8 @@ var workitWorktreeOf = (file) => {
28691
28865
  return null;
28692
28866
  }
28693
28867
  };
28694
- var bindingDir = () => path44.join(resolveStateDir(), "worktree-bind");
28695
- var bindingFile = (session, agentId) => path44.join(bindingDir(), `${createHash20("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
28868
+ var bindingDir = () => path45.join(resolveStateDir(), "worktree-bind");
28869
+ var bindingFile = (session, agentId) => path45.join(bindingDir(), `${createHash21("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
28696
28870
  var readBinding = (file) => {
28697
28871
  try {
28698
28872
  const value = JSON.parse(fs29.readFileSync(file, "utf8"));
@@ -28717,7 +28891,7 @@ var bind = (input, worktree) => {
28717
28891
  agentId,
28718
28892
  at: new Date().toISOString()
28719
28893
  };
28720
- fs29.mkdirSync(path44.dirname(file), { recursive: true });
28894
+ fs29.mkdirSync(path45.dirname(file), { recursive: true });
28721
28895
  fs29.writeFileSync(file, JSON.stringify(binding));
28722
28896
  try {
28723
28897
  if (inWorkitWorkspace(input.cwd))
@@ -28736,26 +28910,26 @@ var hostIsolated = (cwd, agentId) => {
28736
28910
  const checkout = checkoutOf2(cwd);
28737
28911
  if (!checkout)
28738
28912
  return false;
28739
- const dotGit = path44.join(checkout.root, ".git");
28913
+ const dotGit = path45.join(checkout.root, ".git");
28740
28914
  if (!fs29.statSync(dotGit).isFile())
28741
28915
  return false;
28742
28916
  const [adminDir, gitDir] = gitDirsAt(checkout.root, null, false) ?? [];
28743
- const back = fs29.readFileSync(path44.join(adminDir, "gitdir"), "utf8").trim();
28744
- if (path44.relative(canonical5(path44.resolve(adminDir, back)), canonical5(dotGit)) !== "")
28917
+ const back = fs29.readFileSync(path45.join(adminDir, "gitdir"), "utf8").trim();
28918
+ if (path45.relative(canonical5(path45.resolve(adminDir, back)), canonical5(dotGit)) !== "")
28745
28919
  return false;
28746
- const expected = path44.join(path44.dirname(gitDir), ".claude", "worktrees", `agent-${agentId}`);
28747
- return path44.relative(canonical5(expected), checkout.root) === "";
28920
+ const expected = path45.join(path45.dirname(gitDir), ".claude", "worktrees", `agent-${agentId}`);
28921
+ return path45.relative(canonical5(expected), checkout.root) === "";
28748
28922
  } catch {
28749
28923
  return false;
28750
28924
  }
28751
28925
  };
28752
28926
  var runnerAt = (target) => {
28753
- const base = path44.basename(target);
28927
+ const base = path45.basename(target);
28754
28928
  return base.startsWith(OPAQUE_TARGET) ? decodeURIComponent(base.slice(OPAQUE_TARGET.length)) : null;
28755
28929
  };
28756
28930
  var shown = (target) => {
28757
- const named = /^\.workit-(?:live-target$|runs-)/.test(path44.basename(target)) ? path44.dirname(target) : target;
28758
- return path44.sep === "\\" ? named.replaceAll("/", "\\") : named;
28931
+ const named = /^\.workit-(?:live-target$|runs-)/.test(path45.basename(target)) ? path45.dirname(target) : target;
28932
+ return path45.sep === "\\" ? named.replaceAll("/", "\\") : named;
28759
28933
  };
28760
28934
  var unboundDeny = (input, target) => {
28761
28935
  const unblock = "Work only in the worktree your brief names, which the lead made with `workit fanout worktree create <slice>`: edit files under it and run one verb per call against it (`workit git --cwd <worktree> commit -m … -- <paths>`, `workit check --cwd <worktree> <name>`). If your brief names no worktree, stop and report that to the lead.";
@@ -28794,7 +28968,7 @@ var literalForm = (command, refs) => {
28794
28968
  };
28795
28969
  var unknownVarDeny = (input, worktree, targets, command) => {
28796
28970
  const refs = [
28797
- ...new Set(targets.flatMap((target) => path44.relative(UNKNOWN_VAR, path44.resolve(target)).split(path44.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
28971
+ ...new Set(targets.flatMap((target) => path45.relative(UNKNOWN_VAR, path45.resolve(target)).split(path45.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
28798
28972
  ];
28799
28973
  let text = command ?? "";
28800
28974
  const first = [];
@@ -28823,10 +28997,10 @@ function confineImplementer(input, targets, command) {
28823
28997
  try {
28824
28998
  if (!input.session.agentId || hostIsolated(input.cwd, input.session.agentId))
28825
28999
  return NONE5;
28826
- const unresolved = targets.filter((target) => within(path44.resolve(target), UNKNOWN_VAR));
29000
+ const unresolved = targets.filter((target) => within(path45.resolve(target), UNKNOWN_VAR));
28827
29001
  if (unresolved.length > 0)
28828
29002
  return unknownVarDeny(input, boundWorktree(input), unresolved, command);
28829
- if (targets.some((target) => within(path44.resolve(target), UNKNOWN_DIR)))
29003
+ if (targets.some((target) => within(path45.resolve(target), UNKNOWN_DIR)))
28830
29004
  return unknownDirDeny(input, boundWorktree(input));
28831
29005
  const bindings = canonical5(bindingDir());
28832
29006
  const judged = targets.map((named) => ({ named, real: canonical5(named) })).filter(({ real }) => within(real, bindings) || checkoutOf2(real) !== null);
@@ -28937,10 +29111,10 @@ var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/
28937
29111
  var VALUED = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
28938
29112
  var commonDir = (root) => gitDirsAt(root, null, false)?.[1] ?? "";
28939
29113
  var inScratch = (real, repo) => {
28940
- for (let dir = real;path44.dirname(dir) !== dir; dir = path44.dirname(dir)) {
28941
- if (path44.basename(dir) !== SCRATCH)
29114
+ for (let dir = real;path45.dirname(dir) !== dir; dir = path45.dirname(dir)) {
29115
+ if (path45.basename(dir) !== SCRATCH)
28942
29116
  continue;
28943
- const root = path44.dirname(dir);
29117
+ const root = path45.dirname(dir);
28944
29118
  if (checkoutOf2(root)?.root === root && (repo === null || commonDir(root) === repo))
28945
29119
  return true;
28946
29120
  }
@@ -28949,7 +29123,7 @@ var inScratch = (real, repo) => {
28949
29123
  var inGitDir = (real) => real.split(/[\\/]/).includes(".git");
28950
29124
  var SAFE_KEY = /^(?:core\.(?:repositoryformatversion|filemode|bare|logallrefupdates|ignorecase|precomposeunicode|symlinks)|user\..*|init\.defaultbranch|commit\.gpgsign|extensions\.(?:objectformat|refstorage)|branch\..*\.(?:remote|merge)|remote\..*\.fetch)$/;
28951
29125
  var literalIn = (value, repo, checkout = false) => {
28952
- if (/[$`]/.test(value) || !path44.isAbsolute(value))
29126
+ if (/[$`]/.test(value) || !path45.isAbsolute(value))
28953
29127
  return false;
28954
29128
  const real = canonical5(value);
28955
29129
  const root = checkout ? checkoutOf2(real)?.root : undefined;
@@ -28970,8 +29144,8 @@ var configEntries = (text) => {
28970
29144
  return entries;
28971
29145
  };
28972
29146
  function gitDirsAt(dir, repo, scan = true) {
28973
- for (let at = dir;; at = path44.dirname(at)) {
28974
- const dotGit = path44.join(at, ".git");
29147
+ for (let at = dir;; at = path45.dirname(at)) {
29148
+ const dotGit = path45.join(at, ".git");
28975
29149
  let gitDir = null;
28976
29150
  try {
28977
29151
  if (fs29.statSync(dotGit).isDirectory())
@@ -28980,19 +29154,19 @@ function gitDirsAt(dir, repo, scan = true) {
28980
29154
  const named = /^gitdir:\s*(.+?)\s*$/mu.exec(fs29.readFileSync(dotGit, "utf8"))?.[1];
28981
29155
  if (!named)
28982
29156
  return null;
28983
- gitDir = canonical5(path44.resolve(at, named));
29157
+ gitDir = canonical5(path45.resolve(at, named));
28984
29158
  }
28985
29159
  } catch (error) {
28986
29160
  if (error.code !== "ENOENT")
28987
29161
  return null;
28988
- if (["HEAD", "objects", "refs"].every((name) => fs29.existsSync(path44.join(at, name))))
29162
+ if (["HEAD", "objects", "refs"].every((name) => fs29.existsSync(path45.join(at, name))))
28989
29163
  gitDir = canonical5(at);
28990
29164
  }
28991
29165
  if (gitDir !== null) {
28992
- const common = path44.join(gitDir, "commondir");
28993
- const shared = fs29.existsSync(common) ? canonical5(path44.resolve(gitDir, fs29.readFileSync(common, "utf8").trim())) : gitDir;
29166
+ const common = path45.join(gitDir, "commondir");
29167
+ const shared = fs29.existsSync(common) ? canonical5(path45.resolve(gitDir, fs29.readFileSync(common, "utf8").trim())) : gitDir;
28994
29168
  const dirs = [gitDir, shared];
28995
- for (const config of scan ? new Set([path44.join(gitDir, "config"), path44.join(shared, "config")]) : []) {
29169
+ for (const config of scan ? new Set([path45.join(gitDir, "config"), path45.join(shared, "config")]) : []) {
28996
29170
  let text = "";
28997
29171
  try {
28998
29172
  text = fs29.readFileSync(config, "utf8");
@@ -29001,14 +29175,14 @@ function gitDirsAt(dir, repo, scan = true) {
29001
29175
  }
29002
29176
  for (const [key, value] of configEntries(text)) {
29003
29177
  if (key === "core.worktree")
29004
- dirs.push(canonical5(path44.resolve(gitDir, value)));
29178
+ dirs.push(canonical5(path45.resolve(gitDir, value)));
29005
29179
  else if (/^remote\..*\.url$/.test(key) ? !literalIn(value, repo, true) : !SAFE_KEY.test(key))
29006
29180
  return null;
29007
29181
  }
29008
29182
  }
29009
29183
  return dirs;
29010
29184
  }
29011
- if (path44.dirname(at) === at)
29185
+ if (path45.dirname(at) === at)
29012
29186
  return [];
29013
29187
  }
29014
29188
  }
@@ -29148,10 +29322,10 @@ var gitKind = (args, local = () => true) => {
29148
29322
  };
29149
29323
  var JUDGE_GIT = `a judge runs git ${Object.keys(GIT_VERBS).join(" ")} with the options each documents (no abbreviations), writing only in a scratch repo; no -c, no wrapper but timeout, nice, time, command, no env but PAGER=cat, GIT_PAGER=cat, GIT_OPTIONAL_LOCKS=0, LC_*, LANG, TZ; status outside scratch needs --no-optional-locks`;
29150
29324
  var remoteIn = (dir, name, repo) => {
29151
- const shared = path44.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo, false)?.[1] : undefined;
29325
+ const shared = path45.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo, false)?.[1] : undefined;
29152
29326
  if (!shared)
29153
29327
  return false;
29154
- const url = configEntries(fs29.readFileSync(path44.join(shared, "config"), "utf8")).find(([key]) => key === `remote.${name}.url`.toLowerCase())?.[1];
29328
+ const url = configEntries(fs29.readFileSync(path45.join(shared, "config"), "utf8")).find(([key]) => key === `remote.${name}.url`.toLowerCase())?.[1];
29155
29329
  return url !== undefined && literalIn(url, repo, true);
29156
29330
  };
29157
29331
  var judgeGit = (command, repo, depth = 0) => {
@@ -29165,7 +29339,7 @@ var judgeGit = (command, repo, depth = 0) => {
29165
29339
  const lead = [];
29166
29340
  while (/^\w+\+?=/.test(words[at] ?? ""))
29167
29341
  lead.push(words[at++]);
29168
- const name = path44.basename(words[at] ?? "");
29342
+ const name = path45.basename(words[at] ?? "");
29169
29343
  let start = words.findIndex((word) => /(?:^|[\\/])git(?:\.exe)?(?:=|$)/.test(word));
29170
29344
  if (start > at) {
29171
29345
  if (/^(?:grep|egrep|rg|echo|printf|ls|wc|head|tail|cat|which|type|test|\[|cd|mkdir)$/.test(name) || name === "command" && /^-[vV]$/.test(words[at + 1] ?? ""))
@@ -29176,7 +29350,7 @@ var judgeGit = (command, repo, depth = 0) => {
29176
29350
  if (start >= 0 && words[start].includes("="))
29177
29351
  why = "git is redefined";
29178
29352
  const run = words[start] ?? "";
29179
- if (run.includes("/") && (!path44.isAbsolute(run) || literalIn(run, repo, true)))
29353
+ if (run.includes("/") && (!path45.isAbsolute(run) || literalIn(run, repo, true)))
29180
29354
  why ??= `\`${run}\` is not the system git`;
29181
29355
  if (segment.expands?.includes(at) && name !== "[" || /\{[^}]*,/.test(words[at] ?? ""))
29182
29356
  why = "the command's name is expanded by the shell";
@@ -29206,12 +29380,12 @@ var judgeGit = (command, repo, depth = 0) => {
29206
29380
  if (!gitKind(args, local))
29207
29381
  why = `\`git ${args.slice(0, 2).join(" ")}\` is not allowed`;
29208
29382
  else if (args[0] === "status" && !unlocked) {
29209
- const dirs = path44.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo) : null;
29383
+ const dirs = path45.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo) : null;
29210
29384
  if (!dirs?.length || !dirs.every((gitDir) => inScratch(gitDir, repo)))
29211
29385
  why = "`git status` refreshes the index outside scratch: add --no-optional-locks";
29212
29386
  }
29213
29387
  }
29214
- const shell = /^(?:grep|egrep|rg|echo|printf|cat)$/.test(name) ? -1 : words.findIndex((word) => /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/.test(path44.basename(word)));
29388
+ const shell = /^(?:grep|egrep|rg|echo|printf|cat)$/.test(name) ? -1 : words.findIndex((word) => /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/.test(path45.basename(word)));
29215
29389
  const scripts = [
29216
29390
  ...words.filter((_, after) => shell >= 0 && after > shell && /^-[a-zA-Z]*c[a-zA-Z]*$/.test(words[after - 1])),
29217
29391
  ...shell < 0 ? [] : segment.stdin ?? []
@@ -29252,7 +29426,7 @@ var judgeVerbRefused = (args) => {
29252
29426
  var CLI_RUNNERS = /^(?:npx|bunx|pnpx|npm|pnpm|yarn|bun|node|nodejs|deno|tsx|ts-node)$/;
29253
29427
  var CLI_ENTRY = /(?:^|[=\\/])(?:workit(?:\.(?:exe|cmd|[cm]?js))?|@workit-dev\/cli(?:@\S*)?)$|(?:workit-cli|@workit-dev[\\/]cli)[\\/](?:src[\\/](?:index|main)|dist[\\/]index)\.[cm]?[jt]sx?$/;
29254
29428
  var workitCalls = (command, depth = 0, aliases = new Map) => depth > 4 ? [] : commandLines(command).flatMap((words) => {
29255
- const name = path44.basename(words[0] ?? "").toLowerCase();
29429
+ const name = path45.basename(words[0] ?? "").toLowerCase();
29256
29430
  if (name === "alias")
29257
29431
  return words.flatMap((word) => {
29258
29432
  const set = /^([\w-]+)=(.*)$/s.exec(word);
@@ -29282,11 +29456,11 @@ var judgeRefusal = (command, fed, depth = 0) => {
29282
29456
  return why;
29283
29457
  }
29284
29458
  const { words } = segment;
29285
- const runs = (word = "") => RUNS.test(path44.basename(word).toLowerCase());
29459
+ const runs = (word = "") => RUNS.test(path45.basename(word).toLowerCase());
29286
29460
  let at = 0;
29287
29461
  while (at < words.length && (LEADS.test(words[at]) || /^-\w$/.test(words[at - 1] ?? "") && !runs(words[at])))
29288
29462
  at++;
29289
- const name = path44.basename(words[at] ?? "").toLowerCase();
29463
+ const name = path45.basename(words[at] ?? "").toLowerCase();
29290
29464
  const args = words.slice(at + 1);
29291
29465
  const unseen = `\`${words.join(" ").slice(0, 80)}\` runs a script Workit cannot read (piped, on stdin, a process substitution or eval): write the case to a file in ${SCRATCH} and dispatch it from a test instead`;
29292
29466
  if (/^(?:cd|chdir|pushd|popd)$/.test(name))
@@ -29365,8 +29539,8 @@ var judgeDeny = (input, what, target) => {
29365
29539
  const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
29366
29540
  const root = checkoutOf2(input.cwd)?.root;
29367
29541
  const candidate = target ? checkoutOf2(target)?.root : undefined;
29368
- const also = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? ` or ${path44.join(candidate, SCRATCH)}` : "";
29369
- const scratch = root ? `${path44.join(root, SCRATCH)}${also}` : `${SCRATCH}/ at the root of the checkout you judge`;
29542
+ const also = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? ` or ${path45.join(candidate, SCRATCH)}` : "";
29543
+ const scratch = root ? `${path45.join(root, SCRATCH)}${also}` : `${SCRATCH}/ at the root of the checkout you judge`;
29370
29544
  const unblock = `Write only under ${scratch} (mkdir -p it): put a generated case in a file there with a quoted heredoc (<<'EOF') and never run it in the shell. Reads, \`workit check\` and \`workit ledger verdict|finding\` stay allowed; a change the candidate needs is a finding, not an edit.`;
29371
29545
  return {
29372
29546
  kind: "deny",
@@ -29381,12 +29555,12 @@ function confineJudge(input, targets, placeholders = placeholdersOf(targets)) {
29381
29555
  const judged = checkoutOf2(input.cwd);
29382
29556
  const repo = judged ? commonDir(judged.root) : null;
29383
29557
  for (const target of targets) {
29384
- const resolved = path44.resolve(target);
29558
+ const resolved = path45.resolve(target);
29385
29559
  if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
29386
29560
  return judgeDeny(input, "it writes to a path Workit cannot resolve (a variable, a command substitution or `cd -`): spell the path out");
29387
29561
  const real = canonical5(target);
29388
- const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(path44.basename(target));
29389
- const gitDirs = runsGit ? gitDirsAt(path44.dirname(real), repo) : [];
29562
+ const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(path45.basename(target));
29563
+ const gitDirs = runsGit ? gitDirsAt(path45.dirname(real), repo) : [];
29390
29564
  if (gitDirs === null)
29391
29565
  return judgeDeny(input, `git in ${shown(target)} uses a git dir or config Workit cannot check`);
29392
29566
  if (runsGit ? gitDirs.length > 0 ? gitDirs.every((dir) => inScratch(dir, repo)) : inScratch(real, repo) : inScratch(real, repo) && !inGitDir(real))
@@ -29427,7 +29601,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
29427
29601
  let git = [];
29428
29602
  try {
29429
29603
  git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args) || gitKind(args) === "write" && !/^(?:init|clone)$/.test(args[0])) ? [
29430
- path44.join(dir === undefined ? UNKNOWN_DIR : path44.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
29604
+ path45.join(dir === undefined ? UNKNOWN_DIR : path45.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
29431
29605
  ] : []);
29432
29606
  } catch {}
29433
29607
  const lists = [
@@ -29472,7 +29646,7 @@ var judgeChecksLine = (cwd) => {
29472
29646
 
29473
29647
  // packages/workit-core/src/hooks/standing.ts
29474
29648
  var readPlans = (store) => {
29475
- const dir = path45.join(store, "fanouts");
29649
+ const dir = path46.join(store, "fanouts");
29476
29650
  let names;
29477
29651
  try {
29478
29652
  names = fs30.readdirSync(dir).filter((name) => name.endsWith(".json"));
@@ -29482,7 +29656,7 @@ var readPlans = (store) => {
29482
29656
  const plans = [];
29483
29657
  for (const name of names) {
29484
29658
  try {
29485
- const raw = JSON.parse(fs30.readFileSync(path45.join(dir, name), "utf8"));
29659
+ const raw = JSON.parse(fs30.readFileSync(path46.join(dir, name), "utf8"));
29486
29660
  if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
29487
29661
  continue;
29488
29662
  const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
@@ -29693,7 +29867,7 @@ var cdWorkitSplit = (command) => {
29693
29867
  // packages/workit-core/src/hooks/model-limit.ts
29694
29868
  import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync7, readSync, statSync as statSync5 } from "node:fs";
29695
29869
  import os10 from "node:os";
29696
- import path46 from "node:path";
29870
+ import path47 from "node:path";
29697
29871
  var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
29698
29872
  var WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
29699
29873
  var TIME_WORD = String.raw`(?:\d|(?:in|at|on|later|tomorrow|soon)\b|(?:${[...WEEKDAYS, ...MONTHS].join("|")})[a-z]*\b)`;
@@ -29891,17 +30065,17 @@ var firstPrompt = (file) => {
29891
30065
  var claudeProjectSlug = (cwd) => cwd.replace(/[^A-Za-z0-9]/gu, "-");
29892
30066
  var listDir = (dir) => {
29893
30067
  try {
29894
- return readdirSync7(dir).map((name) => path46.join(dir, name));
30068
+ return readdirSync7(dir).map((name) => path47.join(dir, name));
29895
30069
  } catch {
29896
30070
  return [];
29897
30071
  }
29898
30072
  };
29899
30073
  var SCAN_MS = 30 * 60000;
29900
30074
  var scanClaudeTranscripts = (cwd, env, now = new Date) => {
29901
- const projects = path46.join(env.CLAUDE_CONFIG_DIR || path46.join(env.HOME || os10.homedir(), ".claude"), "projects");
29902
- const project = path46.join(projects, claudeProjectSlug(cwd));
30075
+ const projects = path47.join(env.CLAUDE_CONFIG_DIR || path47.join(env.HOME || os10.homedir(), ".claude"), "projects");
30076
+ const project = path47.join(projects, claudeProjectSlug(cwd));
29903
30077
  const notes = [];
29904
- const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path46.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
30078
+ const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path47.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
29905
30079
  for (const { file, worker } of files)
29906
30080
  try {
29907
30081
  const stat = statSync5(file);
@@ -29916,7 +30090,7 @@ var scanClaudeTranscripts = (cwd, env, now = new Date) => {
29916
30090
  if (!seen)
29917
30091
  continue;
29918
30092
  notes.push(worker ? redispatchNote(seen, {
29919
- label: `worker ${path46.basename(file, ".jsonl")}`,
30093
+ label: `worker ${path47.basename(file, ".jsonl")}`,
29920
30094
  prompt: firstPrompt(file)
29921
30095
  }, now) : `Workit: this session hit a usage limit (${seen.reason}); ${seen.key} is marked exhausted until ${shortTime(seen.until)}. Claude Code runs only Anthropic models: Workit cannot switch this session, so continue on another host or after the reset.`);
29922
30096
  } catch {}
@@ -30049,7 +30223,7 @@ var namesYtrack = (text) => {
30049
30223
 
30050
30224
  // packages/workit-core/src/hooks/ytrack-guard.ts
30051
30225
  var name2 = (word = "") => (word.split(/[\\/]/).at(-1) ?? "").toLowerCase().replace(/\.(?:exe|cmd)$|@.*$/g, "");
30052
- var quote2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", `'\\''`)}'`;
30226
+ var quote3 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", `'\\''`)}'`;
30053
30227
  var minutesOf = (text = "") => {
30054
30228
  if (/^\d+$/.test(text.trim()))
30055
30229
  return Number(text) > 0 ? Number(text) : null;
@@ -30141,7 +30315,7 @@ var combine = (effects) => {
30141
30315
  delete out.attach;
30142
30316
  return out;
30143
30317
  };
30144
- var pair = (flag, value) => value.startsWith("-") ? `${flag}=${quote2(value)}` : `${flag} ${quote2(value)}`;
30318
+ var pair = (flag, value) => value.startsWith("-") ? `${flag}=${quote3(value)}` : `${flag} ${quote3(value)}`;
30145
30319
  var mapWrite = (verb, args) => {
30146
30320
  const values = {};
30147
30321
  const attach = [];
@@ -30340,12 +30514,18 @@ var SHELLS3 = /^(?:sh|bash|zsh|dash|ksh|ash|mksh|yash|fish)$/;
30340
30514
  var MAX_DEPTH2 = 4;
30341
30515
  var READ = new Map;
30342
30516
  var NOT_PLAIN = gap("a ytrack call that is not a plain command of its own (a wrapper, loop, substitution or script around it can change or repeat it)");
30343
- var ungrant = (write) => write.workit ? { command: write.command, ...NOT_PLAIN } : write;
30517
+ var timeOnly = (effect) => effect?.minutes !== undefined && Object.keys(effect).every((key) => /^(?:issue|minutes|text|date)$/u.test(key));
30518
+ var ungrant = (write) => write.workit ? {
30519
+ command: write.command,
30520
+ ...NOT_PLAIN,
30521
+ ...timeOnly(write.effect) ? { hint: write.workit } : {}
30522
+ } : write;
30523
+ var hinted = (write) => write.hint ? { command: write.command, workit: write.hint } : write;
30344
30524
  var ytrackArgs = (line, found, depth, names, plain) => {
30345
30525
  const inner = (script) => void found.push(...ytrackWrites(script, "posix", depth + 1, plain));
30346
30526
  const tail = workitCheckTail(line);
30347
30527
  if (tail) {
30348
- inner("script" in tail ? tail.script : tail.argv.map(quote2).join(" "));
30528
+ inner("script" in tail ? tail.script : tail.argv.map(quote3).join(" "));
30349
30529
  return true;
30350
30530
  }
30351
30531
  const flag = SHELLS3.test(name2(line[0])) ? line.findIndex((word, index) => index > 0 && /^-[a-zA-Z]*c[a-zA-Z]*$/.test(word)) : -1;
@@ -30375,7 +30555,7 @@ var ytrackArgs = (line, found, depth, names, plain) => {
30375
30555
  const argv = [...alias ?? [], ...line.slice(at + 1)];
30376
30556
  const write = classify2(argv);
30377
30557
  if (write) {
30378
- const one = { command: ["ytrack", ...argv].map(quote2).join(" "), ...write };
30558
+ const one = { command: ["ytrack", ...argv].map(quote3).join(" "), ...write };
30379
30559
  found.push(plain ? one : ungrant(one));
30380
30560
  }
30381
30561
  return true;
@@ -30474,6 +30654,7 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
30474
30654
  found = [];
30475
30655
  for (const line of commandLines(command, dialect))
30476
30656
  ytrackArgs(line, found, depth, aliases(command), false);
30657
+ found = found.map(hinted);
30477
30658
  }
30478
30659
  READ.set(key, found);
30479
30660
  if (READ.size > 64)
@@ -30481,6 +30662,8 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
30481
30662
  return found;
30482
30663
  };
30483
30664
  var ytrackGate = (cwd, command, dialect, ask) => {
30665
+ if (namesTicket(command))
30666
+ return { kind: "deny", reason: TICKET_DENY, unblock: null };
30484
30667
  let writes;
30485
30668
  try {
30486
30669
  const merged = new Map;
@@ -30508,8 +30691,8 @@ var ytrackGate = (cwd, command, dialect, ask) => {
30508
30691
  reason: `${bare.join(", ")} writes to YouTrack: the user decides this call (#780).`
30509
30692
  };
30510
30693
  const why = `A raw ytrack write posts to YouTrack without the user's yes (#780).`;
30511
- const run = calls.length ? ` Run ${calls.join(", then ")} instead: it asks the user first. When it answers approval_needed, run exactly the \`workit approve <id>\` it names, now, with nothing around it (no 2>&1, pipe or echo), so the host asks the user; then rerun the workit call once.` : "";
30512
- const user = bare.length ? ` For ${bare.join(", ")}, the user decides: ask the user, and if they agree they run it in their own terminal.` : "";
30694
+ const run = calls.length ? ` Run ${calls.join(", then ")} instead, each as its own plain call: it asks the user first.` : "";
30695
+ const user = bare.length ? ask ? ` For ${bare.join(", ")}, run it as its own plain call: the host asks the user.` : ` For ${bare.join(", ")}, the user decides: ask the user, and if they agree they run it in their own terminal.` : "";
30513
30696
  const rerun = writes.some((write) => write.gap === NOT_PLAIN.gap) ? " To get the named workit youtrack call instead, rerun the ytrack call as one plain command, with no wrapper, loop, substitution or script around it." : "";
30514
30697
  return {
30515
30698
  kind: "deny",
@@ -30727,6 +30910,8 @@ function decide(input, deps) {
30727
30910
  case "write.pre": {
30728
30911
  if (!usable2(descriptor.events["write.pre"].support))
30729
30912
  return NONE6;
30913
+ if (event.text && namesTicket(event.text))
30914
+ return { kind: "deny", reason: TICKET_DENY, unblock: null };
30730
30915
  const role = agentRole(input, descriptor);
30731
30916
  if (role) {
30732
30917
  const targets = liveTargets(input.cwd, event.paths);
@@ -30805,12 +30990,12 @@ var modelKey = (model) => {
30805
30990
  };
30806
30991
 
30807
30992
  // packages/workit-core/src/hooks/budget-signal.ts
30808
- import { createHash as createHash21 } from "node:crypto";
30993
+ import { createHash as createHash22 } from "node:crypto";
30809
30994
  import fs31 from "node:fs";
30810
- import path47 from "node:path";
30811
- var hash2 = (text) => createHash21("sha256").update(text).digest("hex").slice(0, 32);
30812
- var budgetDir = (store) => path47.join(store, "budget");
30813
- var agentBase = (store, session, agentId) => path47.join(budgetDir(store), hash2(`${session}\x00${agentId ?? ""}`));
30995
+ import path48 from "node:path";
30996
+ var hash2 = (text) => createHash22("sha256").update(text).digest("hex").slice(0, 32);
30997
+ var budgetDir = (store) => path48.join(store, "budget");
30998
+ var agentBase = (store, session, agentId) => path48.join(budgetDir(store), hash2(`${session}\x00${agentId ?? ""}`));
30814
30999
  var spawnBudget = (prompt) => {
30815
31000
  const found = /^TIMEBOX:[^\n]*?\b(\d+)\s+tool calls\b/mu.exec(prompt);
30816
31001
  const n = found ? Number(found[1]) : NaN;
@@ -30830,8 +31015,8 @@ var startBudget = (store, session, agentId, n) => {
30830
31015
  const cutoff = Date.now() - 604800000;
30831
31016
  for (const name of fs31.readdirSync(dir))
30832
31017
  try {
30833
- if (fs31.statSync(path47.join(dir, name)).mtimeMs < cutoff)
30834
- fs31.rmSync(path47.join(dir, name));
31018
+ if (fs31.statSync(path48.join(dir, name)).mtimeMs < cutoff)
31019
+ fs31.rmSync(path48.join(dir, name));
30835
31020
  } catch {}
30836
31021
  const base = agentBase(store, session, agentId);
30837
31022
  fs31.writeFileSync(`${base}.json`, JSON.stringify({ limit: n, told: 0 }));
@@ -30970,11 +31155,11 @@ var unfinishedTaskOffer2 = (ctx) => {
30970
31155
  };
30971
31156
 
30972
31157
  // packages/workit-core/src/hooks/repeat-failure.ts
30973
- import { createHash as createHash22 } from "node:crypto";
31158
+ import { createHash as createHash23 } from "node:crypto";
30974
31159
  var SAME_CALL_FAILED = "Same call failed twice:";
30975
31160
  var MAX_SESSIONS = 256;
30976
31161
  var stable = (value) => JSON.stringify(value, (_key, entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? Object.fromEntries(Object.entries(entry).toSorted(([a], [b]) => a.localeCompare(b))) : entry) ?? "null";
30977
- var hashOf = (call) => createHash22("sha256").update(call).digest("hex").slice(0, 32);
31162
+ var hashOf = (call) => createHash23("sha256").update(call).digest("hex").slice(0, 32);
30978
31163
  var record2 = (memo, sessionId, call, failed, next) => {
30979
31164
  const previous = memo.get(sessionId);
30980
31165
  memo.delete(sessionId);
@@ -31167,6 +31352,32 @@ ${shown.join(`
31167
31352
  };
31168
31353
  }
31169
31354
  };
31355
+ var askInline = async (words, command, event, ctx) => {
31356
+ try {
31357
+ const ask = inlineAskFor(words, ctx.cwd);
31358
+ if (!ask)
31359
+ return;
31360
+ const choice = await ctx.ui.select(ask.text, [APPROVE, REJECT]);
31361
+ if (choice !== APPROVE)
31362
+ return {
31363
+ block: true,
31364
+ reason: choice === REJECT ? `The user rejected ${ask.action}: nothing was posted. Do not retry it; report that it was not approved.` : `The user dismissed the dialog for ${ask.action}: nothing was posted.`
31365
+ };
31366
+ const { ticket } = recordInlineAsk({
31367
+ kind: ask.kind,
31368
+ argvHash: ask.argvHash,
31369
+ contentHash: ask.contentHash,
31370
+ host: "pi",
31371
+ session: ctx.sessionManager?.getSessionId() || null,
31372
+ agent: null,
31373
+ toolUseId: event.toolCallId ?? null
31374
+ });
31375
+ event.input.command = `${INLINE_TICKET_ENV}=${ticket} ${command}`;
31376
+ return;
31377
+ } catch (error) {
31378
+ return { block: true, reason: `Workit could not record the approval: ${String(error)}` };
31379
+ }
31380
+ };
31170
31381
  var enforceToolPolicy = (event, ctx) => {
31171
31382
  const gate = (hookEvent) => {
31172
31383
  const decision = handleHook(hookInput(ctx, hookEvent), {
@@ -31184,6 +31395,17 @@ var enforceToolPolicy = (event, ctx) => {
31184
31395
  return { block: true, reason: approveCallDeny(approve.fix) };
31185
31396
  if (approve?.plain && ctx.mode === "tui" && ctx.hasUI)
31186
31397
  return approveInDialog(approve.ids, event, ctx);
31398
+ const inline = typeof command === "string" ? inlineCallIn(command) : null;
31399
+ if (inline && !inline.plain)
31400
+ return { block: true, reason: inlineCallDeny(inline.fix) };
31401
+ if (inline?.plain && ctx.mode === "tui" && ctx.hasUI) {
31402
+ const gated = gate({
31403
+ kind: "shell.pre",
31404
+ command,
31405
+ toolUseId: event.toolCallId ?? null
31406
+ });
31407
+ return gated ?? askInline(inline.words, command, event, ctx);
31408
+ }
31187
31409
  return typeof command === "string" ? gate({
31188
31410
  kind: "shell.pre",
31189
31411
  command,
@@ -31205,7 +31427,8 @@ var enforceToolPolicy = (event, ctx) => {
31205
31427
  kind: "write.pre",
31206
31428
  tool: event.toolName,
31207
31429
  paths: writePaths(event.input),
31208
- toolUseId: null
31430
+ toolUseId: null,
31431
+ text: JSON.stringify(event.input ?? {})
31209
31432
  });
31210
31433
  };
31211
31434
  var observeToolResult = (event, ctx) => {
@@ -31245,14 +31468,14 @@ var observeToolResult = (event, ctx) => {
31245
31468
  var skillPromptNudge = (prompt, ctx) => process.env.WORKIT_PI_WORKER_SESSION ? null : promptNudge(hookInput(ctx, { kind: "context.turn", prompt }), prompt);
31246
31469
 
31247
31470
  // packages/workit-pi/src/launches.ts
31248
- import { mkdirSync as mkdirSync7, readFileSync as readFileSync14, readdirSync as readdirSync8, rmSync as rmSync3, writeFileSync as writeFileSync6 } from "node:fs";
31471
+ import { mkdirSync as mkdirSync7, readFileSync as readFileSync15, readdirSync as readdirSync8, rmSync as rmSync4, writeFileSync as writeFileSync6 } from "node:fs";
31249
31472
  import os11 from "node:os";
31250
- import path48 from "node:path";
31473
+ import path49 from "node:path";
31251
31474
  var launchDir = (root) => {
31252
31475
  const location = resolveStore(root);
31253
- return location instanceof Error ? null : path48.join(location.dir, "pi-launches");
31476
+ return location instanceof Error ? null : path49.join(location.dir, "pi-launches");
31254
31477
  };
31255
- var fileFor = (dir, workerId) => path48.join(dir, `${workerId.replace(/[^A-Za-z0-9-]/g, "_")}.json`);
31478
+ var fileFor = (dir, workerId) => path49.join(dir, `${workerId.replace(/[^A-Za-z0-9-]/g, "_")}.json`);
31256
31479
  var recordLaunch = (root, attempt) => {
31257
31480
  const dir = launchDir(root);
31258
31481
  if (!dir)
@@ -31273,7 +31496,7 @@ var recordLaunch = (root, attempt) => {
31273
31496
  var clearLaunch = (root, workerId) => {
31274
31497
  const dir = launchDir(root);
31275
31498
  if (dir)
31276
- rmSync3(fileFor(dir, workerId), { force: true });
31499
+ rmSync4(fileFor(dir, workerId), { force: true });
31277
31500
  };
31278
31501
  var alive = (attempt) => {
31279
31502
  if (attempt.host !== os11.hostname())
@@ -31298,7 +31521,7 @@ var abandonedLaunches = (root) => {
31298
31521
  const found = [];
31299
31522
  for (const name of names) {
31300
31523
  try {
31301
- const attempt = JSON.parse(readFileSync14(path48.join(dir, name), "utf8"));
31524
+ const attempt = JSON.parse(readFileSync15(path49.join(dir, name), "utf8"));
31302
31525
  if (typeof attempt.workerId === "string" && typeof attempt.session === "string") {
31303
31526
  if (!alive(attempt))
31304
31527
  found.push(attempt);
@@ -31311,17 +31534,17 @@ var cancelHint = (workerId) => `cancel it first: workit_worker {"action":"cancel
31311
31534
 
31312
31535
  // packages/workit-core/src/core/cli-locate.ts
31313
31536
  import { closeSync as closeSync4, existsSync as existsSync15, openSync as openSync4, readSync as readSync2 } from "node:fs";
31314
- import path49 from "node:path";
31537
+ import path50 from "node:path";
31315
31538
  var LAUNCHER_MARKER = "workit-owned-launcher";
31316
31539
  var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
31317
31540
  var installRoot = (env, platform = process.platform) => {
31318
31541
  if (env.WORKIT_INSTALL_ROOT)
31319
31542
  return env.WORKIT_INSTALL_ROOT;
31320
31543
  const data = dataDir(env, platform);
31321
- return platform === "win32" ? path49.join(data, "install") : data;
31544
+ return platform === "win32" ? path50.join(data, "install") : data;
31322
31545
  };
31323
- var ownedLauncherPath = (env, platform = process.platform) => path49.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
31324
- var ownedCurrentEntry = (env, platform = process.platform) => path49.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
31546
+ var ownedLauncherPath = (env, platform = process.platform) => path50.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
31547
+ var ownedCurrentEntry = (env, platform = process.platform) => path50.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
31325
31548
  var head = (file) => {
31326
31549
  let fd;
31327
31550
  try {
@@ -31348,7 +31571,7 @@ var locateWorkitCli = (options = {}) => {
31348
31571
  source: "owned-launcher",
31349
31572
  command: launcher,
31350
31573
  args: [],
31351
- binDir: path49.dirname(launcher)
31574
+ binDir: path50.dirname(launcher)
31352
31575
  };
31353
31576
  const current = ownedCurrentEntry(env, platform);
31354
31577
  if (exists(current))
@@ -31377,7 +31600,7 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
31377
31600
  if (located.binDir) {
31378
31601
  const key = pathKey(env);
31379
31602
  const delimiter = platform === "win32" ? ";" : ":";
31380
- const same = (dir) => platform === "win32" ? path49.win32.normalize(dir).toLowerCase() === path49.win32.normalize(located.binDir).toLowerCase() : path49.posix.normalize(dir) === path49.posix.normalize(located.binDir);
31603
+ const same = (dir) => platform === "win32" ? path50.win32.normalize(dir).toLowerCase() === path50.win32.normalize(located.binDir).toLowerCase() : path50.posix.normalize(dir) === path50.posix.normalize(located.binDir);
31381
31604
  const rest = (env[key] ?? "").split(delimiter).filter((dir) => dir && !same(dir));
31382
31605
  patch[key] = [located.binDir, ...rest].join(delimiter);
31383
31606
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/pi",
3
- "version": "2.4.4",
3
+ "version": "2.5.0",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",