@vibgrate/cli 2026.807.1 → 2026.814.1

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 (127) hide show
  1. package/NOTICE +7 -0
  2. package/dist/agent-2ZISYEQF.js +26 -0
  3. package/dist/{agent-K3J6EHLI.js.map → agent-2ZISYEQF.js.map} +1 -1
  4. package/dist/approvals-DOZ5RWJP.js +9 -0
  5. package/dist/approvals-DOZ5RWJP.js.map +1 -0
  6. package/dist/baseline-AGX42TZM.js +9 -0
  7. package/dist/{baseline-IAFWF2ET.js.map → baseline-AGX42TZM.js.map} +1 -1
  8. package/dist/{checkpoint-4WFZMKEO.js → checkpoint-UYMYMMQO.js} +6 -3
  9. package/dist/checkpoint-UYMYMMQO.js.map +1 -0
  10. package/dist/{chunk-N5EP5ZR2.js → chunk-2HNPL4OB.js} +5 -5
  11. package/dist/{chunk-N5EP5ZR2.js.map → chunk-2HNPL4OB.js.map} +1 -1
  12. package/dist/{chunk-2HAJCW7Z.js → chunk-2W3GBKSV.js} +5 -5
  13. package/dist/{chunk-2HAJCW7Z.js.map → chunk-2W3GBKSV.js.map} +1 -1
  14. package/dist/{chunk-XSHGXGVJ.js → chunk-5KY5UCDJ.js} +4 -4
  15. package/dist/{chunk-XSHGXGVJ.js.map → chunk-5KY5UCDJ.js.map} +1 -1
  16. package/dist/{chunk-NWX4VUFS.js → chunk-6OP5U55G.js} +8 -8
  17. package/dist/{chunk-NWX4VUFS.js.map → chunk-6OP5U55G.js.map} +1 -1
  18. package/dist/{chunk-KEIMMCS5.js → chunk-7CDW25VY.js} +4 -4
  19. package/dist/{chunk-KEIMMCS5.js.map → chunk-7CDW25VY.js.map} +1 -1
  20. package/dist/chunk-A4F7ESUR.js +174 -0
  21. package/dist/chunk-A4F7ESUR.js.map +1 -0
  22. package/dist/chunk-AJS4EL2C.js +266 -0
  23. package/dist/chunk-AJS4EL2C.js.map +1 -0
  24. package/dist/{chunk-5ESL76CM.js → chunk-BTYFZ3NM.js} +9 -8
  25. package/dist/chunk-BTYFZ3NM.js.map +1 -0
  26. package/dist/{chunk-JFCCJWXD.js → chunk-BXPWVTGS.js} +4 -3
  27. package/dist/chunk-BXPWVTGS.js.map +1 -0
  28. package/dist/{chunk-7CYFCSY2.js → chunk-EBUTRJHX.js} +24 -6
  29. package/dist/chunk-EBUTRJHX.js.map +1 -0
  30. package/dist/{chunk-EXOYSXH6.js → chunk-HYC3A2AT.js} +3 -3
  31. package/dist/{chunk-EXOYSXH6.js.map → chunk-HYC3A2AT.js.map} +1 -1
  32. package/dist/{chunk-G4KO5W6H.js → chunk-J3IDTLF4.js} +19 -9
  33. package/dist/chunk-J3IDTLF4.js.map +1 -0
  34. package/dist/chunk-JYY6G46J.js +64 -0
  35. package/dist/chunk-JYY6G46J.js.map +1 -0
  36. package/dist/{chunk-2M6B5V2U.js → chunk-K7MONYIM.js} +30 -66
  37. package/dist/chunk-K7MONYIM.js.map +1 -0
  38. package/dist/{chunk-ADP6ITGF.js → chunk-N3XFY3PX.js} +68 -11
  39. package/dist/chunk-N3XFY3PX.js.map +1 -0
  40. package/dist/{chunk-INIULQEP.js → chunk-N6ZMZ5AI.js} +11 -2
  41. package/dist/chunk-N6ZMZ5AI.js.map +1 -0
  42. package/dist/{chunk-QXIWQ2WG.js → chunk-NXDYWBZB.js} +4 -4
  43. package/dist/{chunk-QXIWQ2WG.js.map → chunk-NXDYWBZB.js.map} +1 -1
  44. package/dist/{chunk-GQ2EQXBG.js → chunk-QFCJY6FQ.js} +6 -5
  45. package/dist/chunk-QFCJY6FQ.js.map +1 -0
  46. package/dist/chunk-QIUQH2ND.js +6 -0
  47. package/dist/{chunk-ITY2NPIQ.js.map → chunk-QIUQH2ND.js.map} +1 -1
  48. package/dist/{chunk-FOKURZL3.js → chunk-RBBP4SP7.js} +12 -10
  49. package/dist/chunk-RBBP4SP7.js.map +1 -0
  50. package/dist/{chunk-VNAOFA6X.js → chunk-RNZP2XAL.js} +8 -8
  51. package/dist/chunk-RNZP2XAL.js.map +1 -0
  52. package/dist/{chunk-Y4JO6LYP.js → chunk-TFAXW7VM.js} +302 -11
  53. package/dist/chunk-TFAXW7VM.js.map +1 -0
  54. package/dist/{chunk-LS7GZBKP.js → chunk-UJAOCFQQ.js} +19 -9
  55. package/dist/chunk-UJAOCFQQ.js.map +1 -0
  56. package/dist/{chunk-PT2XQTSK.js → chunk-VD6TVFGA.js} +7 -6
  57. package/dist/chunk-VD6TVFGA.js.map +1 -0
  58. package/dist/{chunk-VQVLY63G.js → chunk-WN2AAB5O.js} +212 -59
  59. package/dist/chunk-WN2AAB5O.js.map +1 -0
  60. package/dist/{chunk-EJUMV5HU.js → chunk-XEI7UU6G.js} +3 -3
  61. package/dist/{chunk-EJUMV5HU.js.map → chunk-XEI7UU6G.js.map} +1 -1
  62. package/dist/cli.js +1179 -511
  63. package/dist/cli.js.map +1 -1
  64. package/dist/embed-worker-main.js +4 -3
  65. package/dist/embed-worker-main.js.map +1 -1
  66. package/dist/{ensure-map-TYMYYIJE.js → ensure-map-EURJPSAK.js} +15 -14
  67. package/dist/{ensure-map-TYMYYIJE.js.map → ensure-map-EURJPSAK.js.map} +1 -1
  68. package/dist/fastembed-S6YEJYQV.js +292 -0
  69. package/dist/fastembed-S6YEJYQV.js.map +1 -0
  70. package/dist/graph-backend-VUW2QWPI.js +14 -0
  71. package/dist/{graph-backend-5YOWNHHG.js.map → graph-backend-VUW2QWPI.js.map} +1 -1
  72. package/dist/index.d.ts +4 -3
  73. package/dist/index.js +14 -13
  74. package/dist/index.js.map +1 -1
  75. package/dist/{interactive-YEMXHGBO.js → interactive-WRA477OW.js} +32 -30
  76. package/dist/interactive-WRA477OW.js.map +1 -0
  77. package/dist/load-XZV5LEGA.js +10 -0
  78. package/dist/{load-IIWVYUN7.js.map → load-XZV5LEGA.js.map} +1 -1
  79. package/dist/{run-outcome-2JO55QCC.js → run-outcome-X5KS6AUE.js} +6 -5
  80. package/dist/run-outcome-X5KS6AUE.js.map +1 -0
  81. package/dist/runtime-session-J7GDVRFU.js +21 -0
  82. package/dist/{runtime-session-HFKGKQV7.js.map → runtime-session-J7GDVRFU.js.map} +1 -1
  83. package/dist/session-3R34WA5S.js +16 -0
  84. package/dist/{session-5LFX4U2E.js.map → session-3R34WA5S.js.map} +1 -1
  85. package/dist/session-store-AQUORKWB.js +4 -0
  86. package/dist/{session-store-KGONLWHN.js.map → session-store-AQUORKWB.js.map} +1 -1
  87. package/dist/{stream-json-DUCFTBUF.js → stream-json-LKVPDKXP.js} +76 -24
  88. package/dist/stream-json-LKVPDKXP.js.map +1 -0
  89. package/dist/version-55TOTJTF.js +4 -0
  90. package/dist/version-55TOTJTF.js.map +1 -0
  91. package/dist/{vg-mcp-bridge-4KPDQUFN.js → vg-mcp-bridge-ZPJAHP7T.js} +11 -10
  92. package/dist/vg-mcp-bridge-ZPJAHP7T.js.map +1 -0
  93. package/dist/{vgd-LFHQ4GWC.js → vgd-UIFH5TTW.js} +12 -11
  94. package/dist/vgd-UIFH5TTW.js.map +1 -0
  95. package/dist/worktree-session-D575IQWM.js +82 -0
  96. package/dist/worktree-session-D575IQWM.js.map +1 -0
  97. package/package.json +9 -7
  98. package/dist/agent-K3J6EHLI.js +0 -24
  99. package/dist/baseline-IAFWF2ET.js +0 -9
  100. package/dist/checkpoint-4WFZMKEO.js.map +0 -1
  101. package/dist/chunk-2M6B5V2U.js.map +0 -1
  102. package/dist/chunk-5ESL76CM.js.map +0 -1
  103. package/dist/chunk-7CYFCSY2.js.map +0 -1
  104. package/dist/chunk-ADP6ITGF.js.map +0 -1
  105. package/dist/chunk-FOKURZL3.js.map +0 -1
  106. package/dist/chunk-G4KO5W6H.js.map +0 -1
  107. package/dist/chunk-GQ2EQXBG.js.map +0 -1
  108. package/dist/chunk-INIULQEP.js.map +0 -1
  109. package/dist/chunk-ITY2NPIQ.js +0 -6
  110. package/dist/chunk-JFCCJWXD.js.map +0 -1
  111. package/dist/chunk-LS7GZBKP.js.map +0 -1
  112. package/dist/chunk-PT2XQTSK.js.map +0 -1
  113. package/dist/chunk-VNAOFA6X.js.map +0 -1
  114. package/dist/chunk-VQVLY63G.js.map +0 -1
  115. package/dist/chunk-Y4JO6LYP.js.map +0 -1
  116. package/dist/chunk-Z7FM3ETS.js +0 -126
  117. package/dist/chunk-Z7FM3ETS.js.map +0 -1
  118. package/dist/graph-backend-5YOWNHHG.js +0 -13
  119. package/dist/interactive-YEMXHGBO.js.map +0 -1
  120. package/dist/load-IIWVYUN7.js +0 -9
  121. package/dist/run-outcome-2JO55QCC.js.map +0 -1
  122. package/dist/runtime-session-HFKGKQV7.js +0 -20
  123. package/dist/session-5LFX4U2E.js +0 -15
  124. package/dist/session-store-KGONLWHN.js +0 -4
  125. package/dist/stream-json-DUCFTBUF.js.map +0 -1
  126. package/dist/vg-mcp-bridge-4KPDQUFN.js.map +0 -1
  127. package/dist/vgd-LFHQ4GWC.js.map +0 -1
@@ -1,14 +1,15 @@
1
1
  import { isSecretPath, secretRefusal, secretEgressRefusal, redactText } from './chunk-543E6WDJ.js';
2
- import { buildAgentMessages, redactSecrets, unifiedDiff, applyEdit } from './chunk-ADP6ITGF.js';
3
- import { localGraphBackend } from './chunk-EXOYSXH6.js';
2
+ import { findMatchingRule, ruleLabel } from './chunk-A4F7ESUR.js';
3
+ import { localGraphBackend } from './chunk-HYC3A2AT.js';
4
4
  import { buildIdentifierTrieFromGraph, KvBlockRegistry, graphDraftCandidates, extractIdentifiers, scanIdentifiersAgainstTrie } from './chunk-5HYCB55P.js';
5
- import { summarizeCapsule, CAPSULE_RANKING_VERSION, buildCodeContext, buildTaskCapsule, capsuleToCodeContext, recordCliCall, CLI_TOOL_ALIASES } from './chunk-FOKURZL3.js';
5
+ import { buildAgentMessages, redactSecrets, unifiedDiff, applyEdit } from './chunk-N3XFY3PX.js';
6
6
  import { resolve } from './chunk-VIWZ4QT7.js';
7
- import { searchSymbols, resolveLib, loadCatalog, readDoc, localPackageDocs, resolveVersion } from './chunk-QXIWQ2WG.js';
7
+ import { searchSymbols, resolveLib, loadCatalog, readDoc, localPackageDocs, resolveVersion } from './chunk-NXDYWBZB.js';
8
8
  import { resolveOne } from './chunk-J7LKEB2R.js';
9
- import { isLocateOnlyInstruction, extractLiteralNeedles, impactOf } from './chunk-7CYFCSY2.js';
9
+ import { summarizeCapsule, CAPSULE_RANKING_VERSION, buildCodeContext, buildTaskCapsule, capsuleToCodeContext, recordCliCall, CLI_TOOL_ALIASES } from './chunk-RBBP4SP7.js';
10
+ import { userAskFromInstruction, isLocateOnlyInstruction, extractLiteralNeedles, impactOf } from './chunk-EBUTRJHX.js';
10
11
  import { parseSource, langForExtension } from './chunk-UTNNGKKX.js';
11
- import { analyzeQuestion, loadTopicTags } from './chunk-2M6B5V2U.js';
12
+ import { analyzeQuestion, loadTopicTags } from './chunk-K7MONYIM.js';
12
13
  import { repositoryIdFromRoot } from './chunk-BWPBB45M.js';
13
14
  import { hashString, canonicalize } from './chunk-JFGYT6BI.js';
14
15
  import { spawnSync, spawn } from 'child_process';
@@ -24,7 +25,6 @@ function buildCapsuleDelta(previous, next) {
24
25
  const prevPrimary = keySet(previous.primary);
25
26
  const nextPrimary = keySet(next.primary);
26
27
  const prevSupport = keySet(previous.supporting);
27
- keySet(next.supporting);
28
28
  const addedPrimary = next.primary.filter((p) => !prevPrimary.has(symKey(p))).map((p) => ({ qualifiedName: p.qualifiedName, file: p.file, kind: p.kind }));
29
29
  const removedPrimary = previous.primary.filter((p) => !nextPrimary.has(symKey(p))).map((p) => ({ qualifiedName: p.qualifiedName, file: p.file }));
30
30
  const addedSupporting = next.supporting.filter((p) => !prevSupport.has(symKey(p))).map((p) => ({ qualifiedName: p.qualifiedName, file: p.file, kind: p.kind }));
@@ -337,6 +337,154 @@ function normalize2(file) {
337
337
  return file.replace(/\\/g, "/").replace(/^\.\//, "");
338
338
  }
339
339
 
340
+ // src/code/safety.ts
341
+ var DANGEROUS = [
342
+ { pattern: /\brm\s+(-[a-z]*f[a-z]*\s+)?(-[a-z]*r[a-z]*\s+)?(-[a-z]*\s+)*(\/|~|\$HOME|\.)(\s|$)/i, reason: "recursive/forced delete of a root or home path" },
343
+ { pattern: /\brm\s+-[a-z]*r[a-z]*f|\brm\s+-[a-z]*f[a-z]*r/i, reason: "recursive force delete" },
344
+ { pattern: /\bmkfs\b|\bmke2fs\b/i, reason: "formats a filesystem" },
345
+ { pattern: /\bdd\b[^|]*\bof=\/dev\//i, reason: "writes raw to a device" },
346
+ { pattern: />\s*\/dev\/(sd|nvme|hd|disk)/i, reason: "writes raw to a disk device" },
347
+ { pattern: /:\s*\(\s*\)\s*\{[^}]*\}\s*;\s*:/, reason: "fork bomb" },
348
+ { pattern: /\b(curl|wget|fetch)\b[^\n|]*\|\s*(sudo\s+)?(sh|bash|zsh|python|node|ruby|perl)\b/i, reason: "pipes a download straight into a shell/interpreter" },
349
+ { pattern: /\bgit\s+push\b[^\n]*(--force\b|-f\b)/i, reason: "force-push (rewrites remote history)" },
350
+ { pattern: /\bgit\s+(reset\s+--hard|clean\s+-[a-z]*f)/i, reason: "destroys uncommitted work" },
351
+ { pattern: /\b(shutdown|reboot|halt|poweroff)\b/i, reason: "powers off / reboots the machine" },
352
+ { pattern: /\bchmod\s+-R\s+0*777\s+(\/|~)/i, reason: "world-writable on a root/home path" },
353
+ { pattern: /\bsudo\b/i, reason: "runs as root (never automatic)" },
354
+ { pattern: /\beval\b\s+["'`]?\$\(/i, reason: "evaluates dynamically-constructed shell" }
355
+ ];
356
+ function dangerousCommand(command, extraDeny = []) {
357
+ const cmd = command.trim();
358
+ for (const { pattern, reason } of DANGEROUS) {
359
+ if (pattern.test(cmd)) return reason;
360
+ }
361
+ for (const raw of extraDeny) {
362
+ if (!raw) continue;
363
+ try {
364
+ if (new RegExp(raw, "i").test(cmd)) return `matches a project denylist rule (${raw})`;
365
+ } catch {
366
+ if (cmd.toLowerCase().includes(raw.toLowerCase())) return `matches a project denylist rule (${raw})`;
367
+ }
368
+ }
369
+ return null;
370
+ }
371
+ var READ_ONLY_ANY_ARGS = /* @__PURE__ */ new Set([
372
+ "ls",
373
+ "pwd",
374
+ "cat",
375
+ "head",
376
+ "tail",
377
+ "wc",
378
+ "cut",
379
+ "tr",
380
+ "nl",
381
+ "column",
382
+ "grep",
383
+ "egrep",
384
+ "fgrep",
385
+ "rg",
386
+ "file",
387
+ "stat",
388
+ "du",
389
+ "df",
390
+ "tree",
391
+ "which",
392
+ "whereis",
393
+ "whoami",
394
+ "id",
395
+ "uname",
396
+ "hostname",
397
+ "uptime",
398
+ "basename",
399
+ "dirname",
400
+ "realpath",
401
+ "readlink",
402
+ "echo",
403
+ "printf",
404
+ "true",
405
+ "false",
406
+ "diff",
407
+ "cmp",
408
+ "strings",
409
+ "md5sum",
410
+ "sha1sum",
411
+ "sha256sum",
412
+ "shasum",
413
+ "cksum",
414
+ // jq has no write-to-file flag of its own; file writes need a redirect,
415
+ // which the metacharacter screen already disqualifies. Membership here also
416
+ // applies the shared `--output` screen, unlike the old always-true guard.
417
+ "jq"
418
+ ]);
419
+ var GUARDED = {
420
+ // find can write via -exec/-delete/-ok and the f* output actions.
421
+ find: (args) => !args.some((a) => /^-(exec|execdir|ok|okdir|delete|fprint|fprintf|fprint0|fls)$/.test(a)),
422
+ // date -s / --set sets the clock. Prefix match catches the attached getopt
423
+ // form too (`-s2020-01-01`).
424
+ date: (args) => !args.some((a) => a.startsWith("-s") || a.startsWith("--set")),
425
+ // sort -o / --output writes a file — including the attached form (`-oFILE`).
426
+ sort: (args) => !args.some((a) => a.startsWith("-o") || a.startsWith("--output")),
427
+ // uniq's second positional argument is an output file.
428
+ uniq: (args) => args.filter((a) => !a.startsWith("-")).length <= 1
429
+ };
430
+ var GIT_READ_ONLY = /* @__PURE__ */ new Set([
431
+ "status",
432
+ "log",
433
+ "diff",
434
+ "show",
435
+ "blame",
436
+ "shortlog",
437
+ "describe",
438
+ "ls-files",
439
+ "rev-parse",
440
+ "grep",
441
+ "show-ref",
442
+ "cat-file",
443
+ "count-objects",
444
+ "reflog"
445
+ ]);
446
+ var PKG_READ_ONLY = /* @__PURE__ */ new Set(["ls", "list", "ll", "why", "view", "info", "outdated"]);
447
+ function readOnlySegment(segment) {
448
+ const tokens = segment.split(/\s+/).filter(Boolean);
449
+ if (!tokens.length) return false;
450
+ const head = tokens[0];
451
+ const args = tokens.slice(1);
452
+ if (head.includes("=")) return false;
453
+ if (args.length === 1 && /^(--version|--help)$/.test(args[0]) && /^[\w@-][\w.@-]*$/.test(head) && !head.includes("/") && !head.includes("\\")) {
454
+ return true;
455
+ }
456
+ if (READ_ONLY_ANY_ARGS.has(head)) {
457
+ if (args.some((a) => a.startsWith("--output"))) return false;
458
+ return true;
459
+ }
460
+ const guard = GUARDED[head];
461
+ if (guard) return guard(args);
462
+ if (head === "git") {
463
+ const sub = args[0];
464
+ if (!sub || sub.startsWith("-")) return false;
465
+ const rest = args.slice(1);
466
+ if (rest.some((a) => a.startsWith("--output"))) return false;
467
+ if (GIT_READ_ONLY.has(sub)) return true;
468
+ if (sub === "branch") return rest.every((a) => /^(-a|-r|-v|-vv|-l|--list|--all|--verbose)$/.test(a));
469
+ if (sub === "remote") return rest.every((a) => a === "-v" || a === "--verbose");
470
+ if (sub === "tag") return rest.every((a) => /^(-l|--list|-n\d*)$/.test(a));
471
+ if (sub === "stash") return rest[0] === "list" || rest[0] === "show";
472
+ if (sub === "config") return rest[0] === "-l" || rest[0] === "--list" || rest[0] === "--get" || rest[0] === "--get-all" || rest[0] === "--get-regexp";
473
+ return false;
474
+ }
475
+ if (head === "npm" || head === "pnpm" || head === "yarn") {
476
+ const sub = args[0];
477
+ return !!sub && PKG_READ_ONLY.has(sub);
478
+ }
479
+ return false;
480
+ }
481
+ function readOnlyCommand(command) {
482
+ const cmd = command.trim();
483
+ if (!cmd) return false;
484
+ if (/[><;&`\n(){}]|\$\(/.test(cmd)) return false;
485
+ return cmd.split("|").every((seg) => readOnlySegment(seg));
486
+ }
487
+
340
488
  // src/code/patch-ir.ts
341
489
  var PATCH_IR_SCHEMA_VERSION = "patch-ir/0";
342
490
  function patchIRToCodeEdits(patch) {
@@ -593,38 +741,6 @@ function previewSides(before, after) {
593
741
  return { before: b, after: a };
594
742
  }
595
743
 
596
- // src/code/safety.ts
597
- var DANGEROUS = [
598
- { pattern: /\brm\s+(-[a-z]*f[a-z]*\s+)?(-[a-z]*r[a-z]*\s+)?(-[a-z]*\s+)*(\/|~|\$HOME|\.)(\s|$)/i, reason: "recursive/forced delete of a root or home path" },
599
- { pattern: /\brm\s+-[a-z]*r[a-z]*f|\brm\s+-[a-z]*f[a-z]*r/i, reason: "recursive force delete" },
600
- { pattern: /\bmkfs\b|\bmke2fs\b/i, reason: "formats a filesystem" },
601
- { pattern: /\bdd\b[^|]*\bof=\/dev\//i, reason: "writes raw to a device" },
602
- { pattern: />\s*\/dev\/(sd|nvme|hd|disk)/i, reason: "writes raw to a disk device" },
603
- { pattern: /:\s*\(\s*\)\s*\{[^}]*\}\s*;\s*:/, reason: "fork bomb" },
604
- { pattern: /\b(curl|wget|fetch)\b[^\n|]*\|\s*(sudo\s+)?(sh|bash|zsh|python|node|ruby|perl)\b/i, reason: "pipes a download straight into a shell/interpreter" },
605
- { pattern: /\bgit\s+push\b[^\n]*(--force\b|-f\b)/i, reason: "force-push (rewrites remote history)" },
606
- { pattern: /\bgit\s+(reset\s+--hard|clean\s+-[a-z]*f)/i, reason: "destroys uncommitted work" },
607
- { pattern: /\b(shutdown|reboot|halt|poweroff)\b/i, reason: "powers off / reboots the machine" },
608
- { pattern: /\bchmod\s+-R\s+0*777\s+(\/|~)/i, reason: "world-writable on a root/home path" },
609
- { pattern: /\bsudo\b/i, reason: "runs as root (never automatic)" },
610
- { pattern: /\beval\b\s+["'`]?\$\(/i, reason: "evaluates dynamically-constructed shell" }
611
- ];
612
- function dangerousCommand(command, extraDeny = []) {
613
- const cmd = command.trim();
614
- for (const { pattern, reason } of DANGEROUS) {
615
- if (pattern.test(cmd)) return reason;
616
- }
617
- for (const raw of extraDeny) {
618
- if (!raw) continue;
619
- try {
620
- if (new RegExp(raw, "i").test(cmd)) return `matches a project denylist rule (${raw})`;
621
- } catch {
622
- if (cmd.toLowerCase().includes(raw.toLowerCase())) return `matches a project denylist rule (${raw})`;
623
- }
624
- }
625
- return null;
626
- }
627
-
628
744
  // src/code/network-policy.ts
629
745
  var NETWORK_POLICY_SCHEMA_VERSION = "network-policy/0";
630
746
  var NETWORK_POLICY_VERSION = "network-policy@2026.07.0";
@@ -1822,8 +1938,8 @@ async function runSubagent(host, req) {
1822
1938
  text: `Subagent starting${worktreePath ? ` in worktree ${worktreePath}` : " in-place"}\u2026`
1823
1939
  });
1824
1940
  try {
1825
- const { runAgent: runAgent2 } = await import('./agent-K3J6EHLI.js');
1826
- const { nodeCodeFs } = await import('./session-5LFX4U2E.js');
1941
+ const { runAgent: runAgent2 } = await import('./agent-2ZISYEQF.js');
1942
+ const { nodeCodeFs } = await import('./session-3R34WA5S.js');
1827
1943
  const childFs = childRoot === host.root ? host.fsImpl : nodeCodeFs(childRoot);
1828
1944
  const childApprove = async (action) => {
1829
1945
  host.onEvent?.({
@@ -2222,10 +2338,10 @@ async function executeTool(call, ctx) {
2222
2338
  finalSummary: `aborted: ${str(a.reason) || "no reason given"}`
2223
2339
  };
2224
2340
  default:
2225
- return { content: `unknown tool "${call.name}". Available: ${AGENT_TOOLS.map((t) => t.name).join(", ")}`, mutated: false };
2341
+ return { content: `unknown tool "${call.name}". Available: ${AGENT_TOOLS.map((t) => t.name).join(", ")}`, mutated: false, failed: true };
2226
2342
  }
2227
2343
  } catch (e) {
2228
- return { content: `tool ${call.name} failed: ${e.message}`, mutated: false };
2344
+ return { content: `tool ${call.name} failed: ${e.message}`, mutated: false, failed: true };
2229
2345
  }
2230
2346
  }
2231
2347
  async function askUser(ctx, question, options) {
@@ -2317,7 +2433,7 @@ ${lines.join("\n")}`, mutated: false };
2317
2433
  function readFile(ctx, path4, start, end) {
2318
2434
  if (isSecretPath(path4)) return { content: secretRefusal(path4), mutated: false };
2319
2435
  const content = ctx.fsImpl.read(path4);
2320
- if (content === null) return { content: `${path4} not found`, mutated: false };
2436
+ if (content === null) return { content: `${path4} not found`, mutated: false, failed: true };
2321
2437
  const lines = content.split("\n");
2322
2438
  const from = start && start > 0 ? start - 1 : 0;
2323
2439
  const to = end && end > 0 ? end : lines.length;
@@ -2403,7 +2519,7 @@ async function createFile(ctx, path4, content) {
2403
2519
  }
2404
2520
  const existing = ctx.fsImpl.read(path4);
2405
2521
  if (existing !== null) return { content: `${path4} already exists \u2014 use edit_file`, mutated: false };
2406
- if (!await ctx.approve({ kind: "create", file: path4, bytes: Buffer.byteLength(content) })) {
2522
+ if (!await ctx.approve({ kind: "create", file: path4, bytes: Buffer.byteLength(content), sides: previewSides("", content) })) {
2407
2523
  return { content: `creating ${path4} was declined by the user`, mutated: false };
2408
2524
  }
2409
2525
  ctx.fsImpl.write(path4, content);
@@ -2412,7 +2528,7 @@ async function createFile(ctx, path4, content) {
2412
2528
  async function deleteFile(ctx, path4) {
2413
2529
  const before = ctx.fsImpl.read(path4);
2414
2530
  if (before === null) return { content: `${path4} does not exist`, mutated: false };
2415
- if (!await ctx.approve({ kind: "delete", file: path4 })) {
2531
+ if (!await ctx.approve({ kind: "delete", file: path4, sides: previewSides(before, "") })) {
2416
2532
  return { content: `deleting ${path4} was declined by the user`, mutated: false };
2417
2533
  }
2418
2534
  ctx.fsImpl.remove(path4);
@@ -2425,7 +2541,7 @@ async function applyPatchTool(ctx, raw) {
2425
2541
  }
2426
2542
  const structural = validatePatchIR(patch);
2427
2543
  if (!structural.ok) {
2428
- return { content: `invalid PatchIR: ${structural.errors.join("; ")}`, mutated: false };
2544
+ return { content: `invalid PatchIR: ${structural.errors.join("; ")}`, mutated: false, failed: true };
2429
2545
  }
2430
2546
  if (ctx.enforceIdentifiers !== false && ctx.identifierTrie) {
2431
2547
  const idCheck = enforceIdentifiersInPatch(patch, ctx.identifierTrie, {
@@ -2582,7 +2698,7 @@ function readNotebookTool(ctx, filePath, cell) {
2582
2698
  if (!filePath) return { content: "read_notebook needs a path", mutated: false };
2583
2699
  if (isSecretPath(filePath)) return { content: secretRefusal(filePath), mutated: false };
2584
2700
  const raw = ctx.fsImpl.read(filePath);
2585
- if (raw == null) return { content: `file not found: ${filePath}`, mutated: false };
2701
+ if (raw == null) return { content: `file not found: ${filePath}`, mutated: false, failed: true };
2586
2702
  if (cell == null || Number.isNaN(cell)) {
2587
2703
  const sum = summarizeNotebook(raw);
2588
2704
  if (!sum.ok) return { content: sum.error, mutated: false };
@@ -2596,7 +2712,7 @@ async function editNotebookTool(ctx, filePath, cell, source) {
2596
2712
  if (!filePath) return { content: "edit_notebook_cell needs a path", mutated: false };
2597
2713
  if (isSecretPath(filePath)) return { content: secretRefusal(filePath), mutated: false };
2598
2714
  const raw = ctx.fsImpl.read(filePath);
2599
- if (raw == null) return { content: `file not found: ${filePath}`, mutated: false };
2715
+ if (raw == null) return { content: `file not found: ${filePath}`, mutated: false, failed: true };
2600
2716
  const edited = editNotebookCell(raw, cell, source);
2601
2717
  if (!edited.ok) return { content: edited.error, mutated: false };
2602
2718
  const cellPreviewDiff = unifiedDiff(edited.before, edited.after, `${filePath}#cell${cell}`);
@@ -3161,8 +3277,9 @@ function buildRunProvenance(input = {}) {
3161
3277
 
3162
3278
  // src/code/locate-answer.ts
3163
3279
  function primaryLocateNeedle(instruction) {
3164
- const needles = extractLiteralNeedles(instruction);
3165
- if (needles.length === 0) return instruction.trim();
3280
+ const ask = userAskFromInstruction(instruction);
3281
+ const needles = extractLiteralNeedles(ask);
3282
+ if (needles.length === 0) return ask.trim();
3166
3283
  return [...needles].sort((a, b) => b.length - a.length)[0];
3167
3284
  }
3168
3285
  function formatLocateAnswer(needle, hits, total) {
@@ -3366,7 +3483,7 @@ async function runAgent(options) {
3366
3483
  const allowSubagents = options.allowSubagents !== false && !options.plan;
3367
3484
  const agentToolSpecs = allowSubagents ? AGENT_TOOLS : AGENT_TOOLS.filter((t) => t.name !== "spawn_subagent");
3368
3485
  const allTools = [...agentToolSpecs, ...options.externalTools?.specs ?? []];
3369
- const relevance = await analyzeQuestion(instruction);
3486
+ const relevance = await analyzeQuestion(userAskFromInstruction(instruction));
3370
3487
  const topicTags = relevance ? await loadTopicTags(graph, options.root) : null;
3371
3488
  const built = buildAgentContext(graph, instruction, { ...options, fsImpl, budget, relevance, topicTags });
3372
3489
  const context = built.context;
@@ -3480,9 +3597,26 @@ async function runAgent(options) {
3480
3597
  if (action.kind === "patch") return action.files.map((f) => f.file);
3481
3598
  return "file" in action && action.file ? [action.file] : [];
3482
3599
  };
3600
+ const autoApproval = (action) => {
3601
+ if (action.kind === "run" && dangerousCommand(action.command, options.denyCommands)) return null;
3602
+ if (action.kind === "run" && readOnlyCommand(action.command)) return { note: null };
3603
+ const rules = options.approvalRules?.();
3604
+ if (rules?.length) {
3605
+ const rule = findMatchingRule(action, rules);
3606
+ if (rule) return { note: `Auto-approved by standing rule: ${ruleLabel(rule)}` };
3607
+ }
3608
+ return null;
3609
+ };
3483
3610
  const approveAndCheckpoint = async (action) => {
3484
3611
  if (options.plan) return false;
3485
- const approved = await options.approve(action);
3612
+ let approved;
3613
+ const shortCircuit = autoApproval(action);
3614
+ if (shortCircuit) {
3615
+ approved = true;
3616
+ if (shortCircuit.note) onEvent({ type: "notice", text: shortCircuit.note });
3617
+ } else {
3618
+ approved = await options.approve(action);
3619
+ }
3486
3620
  if (!approved || !options.checkpoint) return approved;
3487
3621
  const files = actionFiles(action);
3488
3622
  if (!files.length) return approved;
@@ -3748,6 +3882,15 @@ Fix the failing tests, then call finish again.${verifyRounds === 0 ? " (last ver
3748
3882
  }
3749
3883
  currentStep = step;
3750
3884
  onEvent({ type: "step", n: step });
3885
+ const injected = options.takeInjected?.();
3886
+ if (injected) {
3887
+ onEvent({ type: "injected", text: injected });
3888
+ messages.push({
3889
+ role: "user",
3890
+ content: `[The user sent this while you were working \u2014 factor it in before continuing:]
3891
+ ${injected}`
3892
+ });
3893
+ }
3751
3894
  const compacted = options.llmCompaction ? await compactWithModel(
3752
3895
  messages,
3753
3896
  contextBudget,
@@ -3782,7 +3925,8 @@ Fix the failing tests, then call finish again.${verifyRounds === 0 ? " (last ver
3782
3925
  options.modelProfile,
3783
3926
  identifierTrie,
3784
3927
  draftCandidates,
3785
- promptSegments
3928
+ promptSegments,
3929
+ options.reasoningEffort
3786
3930
  );
3787
3931
  result = c.result;
3788
3932
  providerInfo = { id: c.provider.id, model: c.provider.model, fellBack: c.fellBack };
@@ -3795,7 +3939,12 @@ Fix the failing tests, then call finish again.${verifyRounds === 0 ? " (last ver
3795
3939
  usage.promptTokens += result.usage.promptTokens ?? 0;
3796
3940
  usage.completionTokens += result.usage.completionTokens ?? 0;
3797
3941
  trajectory.recordUsage(result.usage.promptTokens ?? 0, result.usage.completionTokens ?? 0);
3798
- onEvent({ type: "usage", promptTokens: result.usage.promptTokens ?? 0, completionTokens: result.usage.completionTokens ?? 0 });
3942
+ onEvent({
3943
+ type: "usage",
3944
+ promptTokens: result.usage.promptTokens ?? 0,
3945
+ completionTokens: result.usage.completionTokens ?? 0,
3946
+ ...result.usage.cachedPromptTokens !== void 0 ? { cachedPromptTokens: result.usage.cachedPromptTokens } : {}
3947
+ });
3799
3948
  }
3800
3949
  const displayText = sanitizeAgentDisplayText(result.text ?? "");
3801
3950
  if (displayText) onEvent({ type: "assistant", text: displayText });
@@ -3889,7 +4038,7 @@ ${gateNote}`;
3889
4038
  (note: you have called this exact tool call ${n} times with no change \u2014 try a different approach, read more context, or call finish.)`;
3890
4039
  }
3891
4040
  trajectory.recordTool(call.name, step, toolResult.mutated);
3892
- onEvent({ type: "tool-result", name: call.name, content, mutated: toolResult.mutated });
4041
+ onEvent({ type: "tool-result", name: call.name, content, mutated: toolResult.mutated, ...toolResult.failed ? { failed: true } : {} });
3893
4042
  messages.push({ role: "tool", content, toolCallId: call.id, name: call.name });
3894
4043
  if (toolResult.finished) {
3895
4044
  if (await verifyOnFinish() === "retry") break;
@@ -3907,9 +4056,10 @@ ${gateNote}`;
3907
4056
  }
3908
4057
  return finish("max-steps", "reached the step limit before finishing", maxSteps);
3909
4058
  }
3910
- async function complete(providers, messages, tools, onEvent, stream, modelProfile, identifierTrie, draftCandidates, promptSegments) {
4059
+ async function complete(providers, messages, tools, onEvent, stream, modelProfile, identifierTrie, draftCandidates, promptSegments, reasoningEffort) {
3911
4060
  if (providers.length === 0) throw new Error("no model provider available");
3912
4061
  const onToken = stream ? (t) => onEvent({ type: "token", text: t }) : void 0;
4062
+ const onReasoningToken = stream ? (t) => onEvent({ type: "thinking", text: t }) : void 0;
3913
4063
  let lastErr;
3914
4064
  for (let i = 0; i < providers.length; i++) {
3915
4065
  try {
@@ -3918,10 +4068,13 @@ async function complete(providers, messages, tools, onEvent, stream, modelProfil
3918
4068
  tools,
3919
4069
  stream,
3920
4070
  onToken,
4071
+ onReasoningToken,
4072
+ ...reasoningEffort ? { reasoningEffort } : {},
3921
4073
  identifierTrie,
3922
4074
  draftCandidates,
3923
4075
  promptSegments
3924
4076
  });
4077
+ if (!stream && result.reasoning) onEvent({ type: "thinking", text: result.reasoning });
3925
4078
  return { result, provider: providers[i], fellBack: i > 0 };
3926
4079
  } catch (e) {
3927
4080
  lastErr = e;
@@ -4124,5 +4277,5 @@ function buildSpanIndex(graph) {
4124
4277
  }
4125
4278
 
4126
4279
  export { CONTEXT_POLICY_VERSION, DISCOVERY_TOOLS, MUTATION_TOOLS, compact, compactWithModel, computeFcsReport, createTrajectoryCollector, lookupModelCapabilities, renderFcsReportMarkdown, runAgent };
4127
- //# sourceMappingURL=chunk-VQVLY63G.js.map
4128
- //# sourceMappingURL=chunk-VQVLY63G.js.map
4280
+ //# sourceMappingURL=chunk-WN2AAB5O.js.map
4281
+ //# sourceMappingURL=chunk-WN2AAB5O.js.map