@pushary/agent-hooks 1.9.118 → 1.9.120

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 (133) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/data/cursor-plugin/scripts/pushary-gate.mjs +13 -2
  3. package/data/vscode-plugin/scripts/pushary-gate.mjs +12 -1
  4. package/dist/{api-Q2HBBRLT.js → api-QFUMNTEQ.js} +11 -11
  5. package/dist/bin/pushary-audit.js +3 -3
  6. package/dist/bin/pushary-bell-hook.js +27 -27
  7. package/dist/bin/pushary-bell.js +10 -10
  8. package/dist/bin/pushary-claude.js +25 -25
  9. package/dist/bin/pushary-clean.js +34 -34
  10. package/dist/bin/pushary-codex-bridge.js +21 -21
  11. package/dist/bin/pushary-codex-hook.js +34 -34
  12. package/dist/bin/pushary-codex-session.js +8 -8
  13. package/dist/bin/pushary-codex.js +15 -15
  14. package/dist/bin/pushary-connect.js +28 -28
  15. package/dist/bin/pushary-cowork.js +5 -5
  16. package/dist/bin/pushary-daemon.js +42 -42
  17. package/dist/bin/pushary-disconnect.js +27 -27
  18. package/dist/bin/pushary-display-hook.js +17 -17
  19. package/dist/bin/pushary-doctor.js +42 -42
  20. package/dist/bin/pushary-elicitation-hook.js +27 -27
  21. package/dist/bin/pushary-gemini-bridge.js +15 -15
  22. package/dist/bin/pushary-gemini-hook.js +31 -31
  23. package/dist/bin/pushary-hook.js +33 -33
  24. package/dist/bin/pushary-login.js +21 -21
  25. package/dist/bin/pushary-logout.js +26 -26
  26. package/dist/bin/pushary-mcp.js +12 -12
  27. package/dist/bin/pushary-mode.js +15 -15
  28. package/dist/bin/pushary-notification-hook.js +26 -26
  29. package/dist/bin/pushary-opencode-hook.js +30 -30
  30. package/dist/bin/pushary-permission-denied-hook.js +33 -33
  31. package/dist/bin/pushary-permission-hook.js +33 -33
  32. package/dist/bin/pushary-post-hook.js +26 -26
  33. package/dist/bin/pushary-prompt-hook.js +26 -26
  34. package/dist/bin/pushary-session-end-hook.js +26 -26
  35. package/dist/bin/pushary-session-start-hook.js +35 -35
  36. package/dist/bin/pushary-setup.js +49 -49
  37. package/dist/bin/pushary-stats.js +5 -5
  38. package/dist/bin/pushary-status.js +32 -32
  39. package/dist/bin/pushary-stop-hook.js +26 -26
  40. package/dist/bin/pushary-stopfailure-hook.js +26 -26
  41. package/dist/bin/pushary-suggestions.js +15 -15
  42. package/dist/bin/pushary-transcript-register.js +17 -17
  43. package/dist/bin/pushary-transcripts.js +25 -25
  44. package/dist/bin/pushary-upgrade.js +40 -40
  45. package/dist/bin/pushary-wait.js +15 -15
  46. package/dist/bin/pushary.js +7 -7
  47. package/dist/{chunk-AN6AKKHO.js → chunk-2AMSWODQ.js} +2 -2
  48. package/dist/{chunk-GX3QCU32.js → chunk-2ZT4XV4I.js} +6 -6
  49. package/dist/{chunk-MTG3JLMP.js → chunk-33NEYAK2.js} +4 -4
  50. package/dist/{chunk-WELDACYF.js → chunk-363YZ5WJ.js} +1 -1
  51. package/dist/{chunk-BQVB563P.js → chunk-3DD44QTA.js} +5 -5
  52. package/dist/{chunk-LWY2U7NZ.js → chunk-3GFJ7CXQ.js} +4 -4
  53. package/dist/{chunk-7K6DZPYV.js → chunk-47HCNA5U.js} +1 -1
  54. package/dist/{chunk-XWVEAAZO.js → chunk-4DSJF5JD.js} +3 -3
  55. package/dist/{chunk-4PXJ2LBU.js → chunk-4FLMGGWB.js} +2 -2
  56. package/dist/{chunk-SMBFZFVN.js → chunk-5JZCFZUT.js} +8 -8
  57. package/dist/{chunk-D3PHTY54.js → chunk-5KCUQ3B7.js} +3 -3
  58. package/dist/{chunk-VIR7SCIQ.js → chunk-5NHWNILG.js} +5 -5
  59. package/dist/{chunk-H6YES2DS.js → chunk-6CJ7D6EQ.js} +5 -5
  60. package/dist/{chunk-A2TAWW5L.js → chunk-6FR5ZYMS.js} +1 -1
  61. package/dist/{chunk-CKR43BBJ.js → chunk-7VRL6XYM.js} +1 -1
  62. package/dist/{chunk-CVIJBTGE.js → chunk-7YRKM4AB.js} +6 -6
  63. package/dist/{chunk-K5H4YAMZ.js → chunk-A5YOWKPR.js} +10 -10
  64. package/dist/{chunk-TOUMNM7M.js → chunk-AIABYHHZ.js} +6 -6
  65. package/dist/{chunk-46ZIEQGC.js → chunk-B4M2XZNQ.js} +2 -2
  66. package/dist/{chunk-UKCCVMI2.js → chunk-BYP2R2PF.js} +1 -1
  67. package/dist/{chunk-WLXXEFHA.js → chunk-BZ6N5DDZ.js} +60 -16
  68. package/dist/{chunk-JBWEGNKE.js → chunk-CPBS6LS3.js} +3 -3
  69. package/dist/{chunk-B6HPULOG.js → chunk-EDNCFLR7.js} +3 -3
  70. package/dist/{chunk-7YQPI4UE.js → chunk-EG2E2562.js} +1 -1
  71. package/dist/{chunk-NJSCVQ6S.js → chunk-EU4NV7SS.js} +2 -2
  72. package/dist/{chunk-WCSPOQ5W.js → chunk-F24QURGP.js} +4 -4
  73. package/dist/{chunk-FLBMCN45.js → chunk-H4LCCX7W.js} +6 -6
  74. package/dist/{chunk-OP2ZDOBR.js → chunk-HHZSB6KL.js} +151 -6
  75. package/dist/{chunk-QASBFNVD.js → chunk-HSFTTGOB.js} +2 -2
  76. package/dist/{chunk-GAYUSL24.js → chunk-HVGN7TRN.js} +1 -1
  77. package/dist/{chunk-WZZHWX7Q.js → chunk-INKDRMSK.js} +5 -5
  78. package/dist/{chunk-FNT4VWXV.js → chunk-IYUAMUO6.js} +1 -1
  79. package/dist/{chunk-RPW7LX2L.js → chunk-J4AJVM5F.js} +3 -3
  80. package/dist/{chunk-R4BBSIUK.js → chunk-J6ACLE2A.js} +2 -2
  81. package/dist/{chunk-MG5WFAND.js → chunk-K4RIBZ32.js} +1 -1
  82. package/dist/{chunk-NPMVVR6I.js → chunk-KESS6HAK.js} +2 -2
  83. package/dist/{chunk-YQVZQM53.js → chunk-KG7UZSCD.js} +6 -6
  84. package/dist/{chunk-XSUNHOAP.js → chunk-L37Q4BR6.js} +4 -4
  85. package/dist/{chunk-KOEQIRDA.js → chunk-MZX35RFX.js} +1 -1
  86. package/dist/{chunk-P2H6TDL4.js → chunk-NBKH6SKN.js} +1 -1
  87. package/dist/{chunk-TUQ6R6DD.js → chunk-NVOQBKIL.js} +4 -4
  88. package/dist/{chunk-5FJPEDMZ.js → chunk-NXWQZBOK.js} +3 -3
  89. package/dist/{chunk-IKX4X4LJ.js → chunk-ODXZPMKN.js} +3 -3
  90. package/dist/{chunk-5UIRDDJN.js → chunk-PEMESJZY.js} +3 -3
  91. package/dist/{chunk-F5C6XZZ7.js → chunk-PTONPJWL.js} +4 -4
  92. package/dist/{chunk-CTBNVQND.js → chunk-RHTAI4XP.js} +10 -10
  93. package/dist/{chunk-M2PLZ5V3.js → chunk-RM7MNCCA.js} +5 -5
  94. package/dist/{chunk-FAL7WRMM.js → chunk-RWS4DRFK.js} +3 -3
  95. package/dist/{chunk-UJ6UCGY4.js → chunk-SJPH24TK.js} +4 -4
  96. package/dist/{chunk-UXVCDVPL.js → chunk-SSTO42XS.js} +1 -1
  97. package/dist/{chunk-CUQOWRYT.js → chunk-SUI5JE6T.js} +1 -1
  98. package/dist/{chunk-2WCARUXQ.js → chunk-T57CIR6H.js} +1 -1
  99. package/dist/{chunk-C664L36M.js → chunk-TAHUCUY3.js} +2 -2
  100. package/dist/{chunk-KWDQI7TI.js → chunk-UFRRAAYD.js} +4 -4
  101. package/dist/{chunk-PZLNBKMS.js → chunk-UZL3VQCE.js} +5 -5
  102. package/dist/{chunk-H7B6LLP4.js → chunk-VKRRUT45.js} +13 -6
  103. package/dist/{chunk-6UN3AUIS.js → chunk-W4MZBZU3.js} +3 -3
  104. package/dist/{chunk-I7LP4DKM.js → chunk-W744DTUT.js} +341 -37
  105. package/dist/{chunk-SAISSZZA.js → chunk-WFHUECGB.js} +6 -6
  106. package/dist/{chunk-UNXVORET.js → chunk-XOPOX5QY.js} +47 -29
  107. package/dist/{chunk-FEP7FXBP.js → chunk-XRRY45XB.js} +3 -3
  108. package/dist/{chunk-EJYLQNMC.js → chunk-XSSG5JLJ.js} +1 -1
  109. package/dist/{chunk-QO6SWGLH.js → chunk-XUAGV5VH.js} +2 -2
  110. package/dist/{chunk-BUNRL7QV.js → chunk-YOSATSUD.js} +2 -2
  111. package/dist/{chunk-Q64D24NF.js → chunk-YQGPBLIT.js} +2 -2
  112. package/dist/{chunk-BBLXVKW2.js → chunk-YQUJQGJU.js} +4 -4
  113. package/dist/{chunk-T5N42XDU.js → chunk-YZORQXN7.js} +1 -1
  114. package/dist/{chunk-RMUKFMT3.js → chunk-ZMKZ5WHS.js} +1 -1
  115. package/dist/{chunk-ZGYLMVNB.js → chunk-ZR35L635.js} +2 -2
  116. package/dist/{chunk-A23GIPWY.js → chunk-ZRTUS6WD.js} +12 -5
  117. package/dist/{chunk-QQ24SUBD.js → chunk-ZV7G73KH.js} +3 -3
  118. package/dist/{chunk-X4UWBBFI.js → chunk-ZWUVJ3DV.js} +3 -3
  119. package/dist/{codex-app-cards-switch-45UK7FRY.js → codex-app-cards-switch-545ISCGQ.js} +11 -11
  120. package/dist/{codex-card-routing-7B77ISR2.js → codex-card-routing-IKNAEEMC.js} +2 -2
  121. package/dist/{codex-desktop-launch-DWC7Q5A6.js → codex-desktop-launch-VQNI4GUS.js} +1 -1
  122. package/dist/{codex-session-launch-MK2CXFRQ.js → codex-session-launch-OGOGHTM7.js} +18 -18
  123. package/dist/{config-OHLNHWP4.js → config-VGWGOR2V.js} +3 -3
  124. package/dist/{global-upgrade-KKFYAQVO.js → global-upgrade-GUHXKJPO.js} +9 -9
  125. package/dist/{identity-AKGGBW3A.js → identity-FORDJUYW.js} +4 -4
  126. package/dist/{live-capabilities-O6MAYZZS.js → live-capabilities-VA3VXZOZ.js} +4 -4
  127. package/dist/{paths-5XEJTZAS.js → paths-5XZPI4LD.js} +3 -3
  128. package/dist/{reapply-VQFRLS3P.js → reapply-77JJ3QV2.js} +28 -28
  129. package/dist/src/index.d.ts +1 -1
  130. package/dist/src/index.js +32 -32
  131. package/dist/{upgrade-lock-6HGNG7RT.js → upgrade-lock-EEPLQBLA.js} +4 -4
  132. package/dist/{usage-ATA2A3TZ.js → usage-27IDH6UH.js} +3 -3
  133. package/package.json +2 -2
@@ -1378,14 +1378,29 @@ function parseCommitId(value) {
1378
1378
  // ../contracts/src/conversation-text.ts
1379
1379
  var INTERNAL_ENVELOPE = /(^|\n) {0,3}(?:<(total_tokens|task-notification)>[\s\S]*?(?:<\/\2>|$)[\t ]*)+/g;
1380
1380
  var INCOMPLETE_ENVELOPE = /(^|\n) {0,3}<(?:total_tokens|task-notification)$/g;
1381
+ var AGENT_MESSAGE_OPENING = /^ {0,3}<agent-message from=/;
1382
+ var AGENT_MESSAGE_CLOSING = "</agent-message>";
1381
1383
  var SUGGESTION_REQUEST = /^This is an app-generated request for a suggested next user(?: message| prompt)/;
1382
1384
  var visibleProse = (text3) => text3.replace(INTERNAL_ENVELOPE, "$1").replace(INCOMPLETE_ENVELOPE, "$1");
1385
+ var textAfterAgentMessage = (line) => {
1386
+ const closing = line.indexOf(AGENT_MESSAGE_CLOSING);
1387
+ return closing === -1 ? null : line.slice(closing + AGENT_MESSAGE_CLOSING.length);
1388
+ };
1383
1389
  function conversationText(text3) {
1384
1390
  if (SUGGESTION_REQUEST.test(text3.trimStart())) return "";
1385
1391
  const output = [];
1386
1392
  let prose = [];
1387
1393
  let fence = null;
1388
- for (const line of text3.split("\n")) {
1394
+ let insideAgentMessage = false;
1395
+ const lines = text3.split("\n").reverse();
1396
+ while (lines.length > 0) {
1397
+ const line = lines.pop() ?? "";
1398
+ if (insideAgentMessage || !fence && AGENT_MESSAGE_OPENING.test(line)) {
1399
+ const after = textAfterAgentMessage(line);
1400
+ insideAgentMessage = after === null;
1401
+ if (after?.trim()) lines.push(after);
1402
+ continue;
1403
+ }
1389
1404
  const marker = /^ {0,3}(`{3,}|~{3,})/.exec(line)?.[1];
1390
1405
  if (fence) {
1391
1406
  output.push(line);
@@ -1599,6 +1614,65 @@ var SEGMENT_SEPARATORS = /* @__PURE__ */ new Set([";", "\n", "&", "|"]);
1599
1614
  var DOUBLED_SEPARATORS = /* @__PURE__ */ new Set(["&", "|"]);
1600
1615
  var UNDECOMPOSABLE = /* @__PURE__ */ new Set(["`", "<", ">"]);
1601
1616
  var LITERAL_IN_DOUBLE_QUOTES = /* @__PURE__ */ new Set([";", "|", "&", "<", ">", "*", "?", "[", "\\"]);
1617
+ var OPENS_A_WORD_AFTER = /[ \t\n;&|()`]/;
1618
+ var COMMENT_OR_ANSI_C_QUOTE = /#|\$'/;
1619
+ var INERT_ANSI_C_ESCAPE = "__";
1620
+ var runLengthBefore = (text3, index, char) => {
1621
+ let length = 0;
1622
+ while (text3.charAt(index - 1 - length) === char) length += 1;
1623
+ return length;
1624
+ };
1625
+ var opensAnsiCQuote = (text3, index) => {
1626
+ const dollars = runLengthBefore(text3, index, "$");
1627
+ const backslashes = runLengthBefore(text3, index - dollars, "\\");
1628
+ return text3.charAt(index) === "'" && (dollars - backslashes % 2) % 2 === 1;
1629
+ };
1630
+ var readingWithoutCommentsOrAnsiEscapes = (text3) => {
1631
+ if (!COMMENT_OR_ANSI_C_QUOTE.test(text3)) return null;
1632
+ let reading = "";
1633
+ let changed = false;
1634
+ let quote = null;
1635
+ let ansiC = false;
1636
+ let inComment = false;
1637
+ let atWordStart = true;
1638
+ for (let index = 0; index < text3.length; index += 1) {
1639
+ const char = text3.charAt(index);
1640
+ const next = text3.charAt(index + 1);
1641
+ if (inComment && char !== "\n") continue;
1642
+ inComment = false;
1643
+ if (ansiC && char === "\\" && next) {
1644
+ reading += INERT_ANSI_C_ESCAPE;
1645
+ changed = true;
1646
+ index += 1;
1647
+ } else if (char === "\\" && quote !== "'") {
1648
+ reading += char + next;
1649
+ atWordStart = next === "\n" ? atWordStart : false;
1650
+ index += 1;
1651
+ } else if (quote === "'") {
1652
+ reading += char;
1653
+ if (char === quote) {
1654
+ quote = null;
1655
+ ansiC = false;
1656
+ }
1657
+ atWordStart = false;
1658
+ } else if (char === "'" || char === '"') {
1659
+ reading += char;
1660
+ if (quote === char) quote = null;
1661
+ else if (quote === null) {
1662
+ ansiC = opensAnsiCQuote(text3, index);
1663
+ quote = char;
1664
+ }
1665
+ atWordStart = false;
1666
+ } else if (quote === null && atWordStart && char === COMMENT_START) {
1667
+ inComment = true;
1668
+ changed = true;
1669
+ } else {
1670
+ reading += char;
1671
+ atWordStart = quote === null && OPENS_A_WORD_AFTER.test(char);
1672
+ }
1673
+ }
1674
+ return changed ? reading : null;
1675
+ };
1602
1676
  var scanShell = (command) => {
1603
1677
  const lexemes = [];
1604
1678
  let quote = null;
@@ -1642,6 +1716,112 @@ var splitShellSegments = (command) => {
1642
1716
  const present = segments.filter((segment) => segment.text.length > 0);
1643
1717
  return present.length > 0 ? present : null;
1644
1718
  };
1719
+ var COMMAND_POSITION = String.raw`(^[ \t]*|[;&|(` + "`" + String.raw`\n][ \t]*|\b(?:then|do|else|elif|if|while|until)[ \t]+|[{!][ \t]+)`;
1720
+ var COMMAND_PREFIXES = String.raw`(?:[A-Za-z_]\w*=\S*[ \t]+|(?:sudo|env|exec|command|builtin|nohup|time|nice(?:[ \t]+-n[ \t]+\S+)?|timeout[ \t]+\S+)(?:[ \t]+-[^\s<]*){0,4}[ \t]+){0,8}`;
1721
+ var A_SHELL_RUNNING_A_SUBSTITUTION = new RegExp(
1722
+ String.raw`${COMMAND_POSITION}${COMMAND_PREFIXES}(?:[^\s;&|()<>` + "`" + String.raw`]*/)?(?:sh|bash|zsh|dash|ksh|source|\.)(?:[ \t]+-[^\s<]*){0,8}[ \t]+(?:<[ \t]*)?[<=](?=\()`,
1723
+ "g"
1724
+ );
1725
+ var AN_EVAL_THAT_RUNS = new RegExp(String.raw`${COMMAND_POSITION}${COMMAND_PREFIXES}eval[ \t]+`, "g");
1726
+ var CASE_HEAD = /(^|[\s;&|(])case[ \t]+(?:"[^"\n]*"|'[^'\n]*'|\S+)[ \t\n]+in(?=[\s;])/g;
1727
+ var CASE_ARM_OPENING = /;[;&]{0,2}[ \t\n]*\(?[^()\s;][^()\n;]*\)[ \t\n]*/g;
1728
+ var CASE_ARM_ENDING = /;;&?|;&/g;
1729
+ var CASE_WORD = /\bcase\b/;
1730
+ var ESAC_WORD = /\besac\b/g;
1731
+ var COPROC_PREFIX = /(^|[\s;&|(])coproc[ \t]+(?:[A-Za-z_]\w*[ \t]+(?=[{(]))?/g;
1732
+ var A_FUNCTION_WITH_A_SUBSHELL_BODY = /(^|[\s;&|])(?:function[ \t]+[\w.:-]+(?:[ \t]*\(\))?|[\w.:-]+[ \t]*\(\))[ \t\n]*(?=\()/g;
1733
+ var NPX_GIVEN_A_COMMAND_STRING = /(^|[\s;&|(])npx(?:[ \t]+(?:(?:-p|--package)[ \t]+[^\s;&|]+|(?!-c\b|--call\b)-[^\s;&|]+)){0,8}?[ \t]+(?:-c|--call)(?:[ \t]+|=)/g;
1734
+ var SU_GIVEN_A_COMMAND_STRING = /(^|[\s;&|(])su(?:[ \t]+(?!-c\b|--command\b)[^\s;&|]+){0,8}?[ \t]+(?:-c|--command)(?:[ \t]+|=)/g;
1735
+ var PARALLEL_PREFIX = /(^|[\s;&|(])parallel[ \t]+(?=[^-\s])/g;
1736
+ var closingParenthesisOf = (text3, open) => {
1737
+ let depth = 0;
1738
+ let quote = null;
1739
+ for (let index = open; index < text3.length; index += 1) {
1740
+ const char = text3.charAt(index);
1741
+ if (quote === "'") {
1742
+ if (char === "'") quote = null;
1743
+ } else if (char === "\\") {
1744
+ index += 1;
1745
+ } else if (quote === '"') {
1746
+ if (char === '"') quote = null;
1747
+ } else if (char === "'" || char === '"') {
1748
+ quote = char;
1749
+ } else if (char === "(") {
1750
+ depth += 1;
1751
+ } else if (char === ")") {
1752
+ depth -= 1;
1753
+ if (depth === 0) return index;
1754
+ }
1755
+ }
1756
+ return null;
1757
+ };
1758
+ var withSubstitutionsPipedIntoAShell = (text3) => {
1759
+ let reading = "";
1760
+ let from = 0;
1761
+ for (const match of text3.matchAll(A_SHELL_RUNNING_A_SUBSTITUTION)) {
1762
+ const open = match.index + match[0].length;
1763
+ const close = match.index < from ? null : closingParenthesisOf(text3, open);
1764
+ if (close !== null) {
1765
+ reading += `${text3.slice(from, match.index)}${match[1]}${text3.slice(open + 1, close)} | sh`;
1766
+ from = close + 1;
1767
+ }
1768
+ }
1769
+ return reading + text3.slice(from);
1770
+ };
1771
+ var withCaseArmsAsCommands = (text3) => CASE_WORD.test(text3) && text3.search(ESAC_WORD) !== -1 ? text3.replace(CASE_HEAD, "$1true;").replace(CASE_ARM_OPENING, ";").replace(CASE_ARM_ENDING, ";").replace(ESAC_WORD, "true") : text3;
1772
+ var withoutCoprocPrefix = (text3) => text3.replace(COPROC_PREFIX, "$1");
1773
+ var withFunctionSubshellBodiesExposed = (text3) => text3.replace(A_FUNCTION_WITH_A_SUBSHELL_BODY, "$1");
1774
+ var withCommandStringsRunByAShell = (text3) => text3.replace(NPX_GIVEN_A_COMMAND_STRING, "$1sh -c ").replace(SU_GIVEN_A_COMMAND_STRING, "$1sh -c ");
1775
+ var withoutParallelPrefix = (text3) => text3.replace(PARALLEL_PREFIX, "$1");
1776
+ var SHELL_FORM_REWRITES = [
1777
+ withSubstitutionsPipedIntoAShell,
1778
+ withCaseArmsAsCommands,
1779
+ withoutCoprocPrefix,
1780
+ withFunctionSubshellBodiesExposed,
1781
+ withCommandStringsRunByAShell,
1782
+ withoutParallelPrefix
1783
+ ];
1784
+ var readingWithShellFormsSpelledOut = (text3) => {
1785
+ const reading = SHELL_FORM_REWRITES.reduce((current, rewrite) => rewrite(current), text3);
1786
+ return reading === text3 ? null : reading;
1787
+ };
1788
+ var SHELLS_THAT_RUN_A_SCRIPT_ARGUMENT = /* @__PURE__ */ new Set(["sh", "bash", "zsh", "dash", "ksh"]);
1789
+ var SHORT_FLAGS_WITH_THE_COMMAND_FLAG = /^-[A-Za-z]*c[A-Za-z]*$/;
1790
+ var SHELL_LONG_OPTIONS_WITH_A_VALUE = /* @__PURE__ */ new Set(["--rcfile", "--init-file"]);
1791
+ var SHELL_SHORT_FLAGS_ENDING_IN_AN_OPTION_NAME = /^[-+][A-Za-z]*[oO]$/;
1792
+ var SHELL_OPTION_WORD = /^[-+]/;
1793
+ var COMMAND_SEPARATOR_INSIDE_A_WORD = /[;&|()`]/;
1794
+ var DEEPEST_NESTED_SCRIPT_READ = 3;
1795
+ var MOST_SCRIPTS_READ_FROM_ONE_COMMAND = 16;
1796
+ var programNamedBy = (word) => basenameOf(word.split(COMMAND_SEPARATOR_INSIDE_A_WORD).filter((piece) => piece !== "").pop() ?? "");
1797
+ var scriptArgumentOfAShellAt = (words, index) => {
1798
+ if (!SHELLS_THAT_RUN_A_SCRIPT_ARGUMENT.has(programNamedBy(words[index]?.text ?? ""))) return void 0;
1799
+ for (let next = index + 1; SHELL_OPTION_WORD.test(words[next]?.text ?? ""); next += 1) {
1800
+ const option = words[next]?.text ?? "";
1801
+ if (SHORT_FLAGS_WITH_THE_COMMAND_FLAG.test(option)) return words[next + 1]?.text;
1802
+ if (SHELL_LONG_OPTIONS_WITH_A_VALUE.has(option) || SHELL_SHORT_FLAGS_ENDING_IN_AN_OPTION_NAME.test(option)) next += 1;
1803
+ }
1804
+ return void 0;
1805
+ };
1806
+ var scriptsOfShellsIn = (text3) => {
1807
+ const words = shellWordsOf(text3);
1808
+ return words === null ? [] : words.flatMap((_, index) => scriptArgumentOfAShellAt(words, index) ?? []);
1809
+ };
1810
+ var scriptOfAnEvalEndingAt = (text3, end) => {
1811
+ const words = shellWordsOf(text3.slice(end));
1812
+ return words === null ? [] : [words.map((word) => word.text).join(" ")];
1813
+ };
1814
+ var scriptsOfEvalsIn = (text3) => [...text3.matchAll(AN_EVAL_THAT_RUNS)].slice(0, MOST_SCRIPTS_READ_FROM_ONE_COMMAND).flatMap((match) => scriptOfAnEvalEndingAt(text3, match.index + match[0].length));
1815
+ var scriptsDirectlyInside = (text3) => [...scriptsOfEvalsIn(text3), ...scriptsOfShellsIn(text3)];
1816
+ var scriptsPassedToAShell = (text3) => {
1817
+ const found = [];
1818
+ let level = [text3];
1819
+ for (let depth = 0; depth < DEEPEST_NESTED_SCRIPT_READ && level.length > 0 && found.length < MOST_SCRIPTS_READ_FROM_ONE_COMMAND; depth += 1) {
1820
+ level = level.flatMap(scriptsDirectlyInside).slice(0, MOST_SCRIPTS_READ_FROM_ONE_COMMAND - found.length);
1821
+ found.push(...level);
1822
+ }
1823
+ return found;
1824
+ };
1645
1825
  var shellCommandSegments = (command) => splitShellSegments(command)?.map((segment) => segment.text) ?? null;
1646
1826
  var shellSegmentsReadingAPipe = (command) => splitShellSegments(command)?.filter((segment) => segment.readsPipe).map((segment) => segment.text) ?? null;
1647
1827
  var SUBSTITUTION_OPEN = "$(";
@@ -3488,10 +3668,14 @@ var readSetupOutcomeProperties = (body) => {
3488
3668
  // ../contracts/src/policy-capabilities.ts
3489
3669
  var POLICY_REQUEST_CAPABILITIES_HEADER = "x-pushary-policy-capabilities";
3490
3670
  var POLICY_REQUEST_CAPABILITY = {
3491
- readsCommandRunnersAndAVersionedCache: "command-runners-1"
3671
+ readsCommandRunnersAndAVersionedCache: "command-runners-1",
3672
+ readsWhereAPushLands: "push-destinations-1"
3492
3673
  };
3493
3674
  var KNOWN_POLICY_REQUEST_CAPABILITIES = Object.values(POLICY_REQUEST_CAPABILITY);
3494
- var CLI_POLICY_REQUEST_CAPABILITIES = [POLICY_REQUEST_CAPABILITY.readsCommandRunnersAndAVersionedCache];
3675
+ var CLI_POLICY_REQUEST_CAPABILITIES = [
3676
+ POLICY_REQUEST_CAPABILITY.readsCommandRunnersAndAVersionedCache,
3677
+ POLICY_REQUEST_CAPABILITY.readsWhereAPushLands
3678
+ ];
3495
3679
  var POLICY_REQUEST_CAPABILITY_SEPARATOR = ",";
3496
3680
  var policyRequestCapabilitiesHeaderValue = (capabilities) => capabilities.join(POLICY_REQUEST_CAPABILITY_SEPARATOR);
3497
3681
 
@@ -7939,8 +8123,10 @@ var denyReasonFrom = (value, note) => {
7939
8123
  if (trimmed) return `${PHONE_DENIAL_PREFIX}${trimmed}`;
7940
8124
  return value && value !== DENY_ANSWER && value !== APPROVE_ANSWER ? `${PHONE_DENIAL_PREFIX}${value}` : PHONE_DENIAL_REASON;
7941
8125
  };
7942
- var APPROVE_RESPONSES = /* @__PURE__ */ new Set([APPROVE_ANSWER, "approve", "approved"]);
7943
- var DENY_RESPONSES = /* @__PURE__ */ new Set([DENY_ANSWER, "deny", "denied", "reject", "rejected"]);
8126
+ var APPROVE_RESPONSE_WORDS = [APPROVE_ANSWER, "approve", "approved"];
8127
+ var DENY_RESPONSE_WORDS = [DENY_ANSWER, "deny", "denied", "reject", "rejected"];
8128
+ var APPROVE_RESPONSES = new Set(APPROVE_RESPONSE_WORDS);
8129
+ var DENY_RESPONSES = new Set(DENY_RESPONSE_WORDS);
7944
8130
  var DEFER_RESPONSES = /* @__PURE__ */ new Set([DEFER_ANSWER]);
7945
8131
  var classifyConfirmResponse = (response) => {
7946
8132
  const normalized = (response ?? "").trim().toLowerCase();
@@ -8347,6 +8533,14 @@ var GATE_ALLOW_SOURCE = {
8347
8533
  };
8348
8534
  var PUSHARY_TOOL_PREFIX = "mcp__pushary__";
8349
8535
  var isPusharyOwnTool = (toolName) => toolName.startsWith(PUSHARY_TOOL_PREFIX);
8536
+ var PUSHARY_CONNECTOR_TOOL_PREFIXES = ["mcp__claude_ai_Pushary__", "mcp__plugin_pushary_pushary__"];
8537
+ var SERVER_AND_TOOL_SEPARATOR = "__";
8538
+ var namesOneToolAfterPrefix = (toolName, prefix) => {
8539
+ if (!toolName.startsWith(prefix)) return false;
8540
+ const tool = toolName.slice(prefix.length);
8541
+ return tool.length > 0 && !tool.includes(SERVER_AND_TOOL_SEPARATOR);
8542
+ };
8543
+ var isPusharyConnectorTool = (toolName) => PUSHARY_CONNECTOR_TOOL_PREFIXES.some((prefix) => namesOneToolAfterPrefix(toolName, prefix));
8350
8544
  var strictestScopeVerdict = (scope, paths) => {
8351
8545
  if (paths.length === 0) return evaluateScope(scope, void 0);
8352
8546
  let worst = { outcome: "in_scope" };
@@ -8457,6 +8651,10 @@ var PRETOOLUSE_HANDLED_TOOLS = /* @__PURE__ */ new Set([...PRETOOLUSE_GATED_TOOL
8457
8651
  var isPermissionRequestOwnedByPreToolUse = (toolName, permissionMode, defers = shouldDeferToNativeMode) => PRETOOLUSE_HANDLED_TOOLS.has(toolName) && (isAskedInEveryMode(toolName) || !defers(permissionMode, toolName));
8458
8652
  var CLAUDE_PRETOOLUSE_MATCHER = [...PRETOOLUSE_HANDLED_TOOLS].join("|");
8459
8653
  var CLAUDE_MCP_PRETOOLUSE_MATCHER = "mcp__.*";
8654
+ var CLAUDE_REFUSALS_ONLY_TOOLS = ["WebFetch", "Task", "Agent"];
8655
+ var CLAUDE_REFUSALS_ONLY_PRETOOLUSE_MATCHER = `^(${CLAUDE_REFUSALS_ONLY_TOOLS.join("|")})$`;
8656
+ var CLAUDE_SUBAGENT_TOOL_ALIASES = { Task: "Agent", Agent: "Task" };
8657
+ var claudeSubagentToolAliasOf = (toolName) => Object.hasOwn(CLAUDE_SUBAGENT_TOOL_ALIASES, toolName) ? CLAUDE_SUBAGENT_TOOL_ALIASES[toolName] : void 0;
8460
8658
  var LINE_BREAK = /[\r\n]/;
8461
8659
  var bypassModeCovers = (toolName, toolInput) => {
8462
8660
  const arg = extractPolicyArg(toolName, toolInput);
@@ -8473,13 +8671,24 @@ var bypassModeApplies = (input) => isBypassPermissionMode(input.permissionMode)
8473
8671
  var bypassModeAllows = (input) => bypassModeApplies(input) && (bypassStopsOf(input.config) === "nothing" ? !aChosenRuleGovernsInEitherRepository(input, ruleAsksOrRefuses) : bypassModeCoversEveryInput(input));
8474
8672
  var PERMISSIONS_OFF_ASK_REASON = "Permissions are off in your agent, so Pushary only stops for risky steps like this one. You can change this in Settings on pushary.com.";
8475
8673
  var permissionsOffLineAppliesTo = (agentType) => agentType === CLAUDE_CODE_AGENT_TYPE;
8476
- var askAtTheRouteOfAPushOfTheCurrentBranch = (input, repoKey) => {
8674
+ var PATTERN_PREFIX_WILDCARD = /(?::\*|\*)?\)$/;
8675
+ var CONTINUES_A_COMMAND_WORD = /^[ :]/;
8676
+ var ruleNarrowsThePattern = (ruleTool, pattern) => {
8677
+ if (ruleTool === pattern) return false;
8678
+ if (!pattern.includes("(")) return ruleTool.includes("(");
8679
+ const prefix = pattern.replace(PATTERN_PREFIX_WILDCARD, "");
8680
+ return ruleTool.startsWith(prefix) && CONTINUES_A_COMMAND_WORD.test(ruleTool.slice(prefix.length));
8681
+ };
8682
+ var askAtTheRouteOfAPush = (input, repoKey, allowedBy) => {
8477
8683
  const routes = approvalRoutesOf(input.config);
8478
- if (routes === null || input.currentBranch === void 0) return void 0;
8684
+ if (routes === null) return void 0;
8685
+ const askRows = input.config.policies.filter((policy) => restricts(policy) && !isAutoDeny(policy) && appliesToThisCall(policy, repoKey, input.sessionId));
8686
+ const routesWithAnAsk = routes.filter((route) => askRows.some((policy) => policy.tool === route.toolPattern));
8687
+ const routesTheAllowDoesNotNarrow = routesWithAnAsk.filter((route) => !ruleNarrowsThePattern(allowedBy.tool, route.toolPattern));
8688
+ const bestOf = (candidates, spellings) => spellings.length === 0 ? void 0 : findBestRoute(candidates, input.toolName, spellings, repoKey);
8479
8689
  for (const toolInput of input.toolInputs) {
8480
- const pushes = pushesOfTheCurrentBranchIn(input, toolInput);
8481
- const route = pushes.length === 0 ? void 0 : findBestRoute(routes, input.toolName, pushes, repoKey);
8482
- const ask = route && input.config.policies.find((policy) => policy.tool === route.toolPattern && restricts(policy) && !isAutoDeny(policy) && appliesToThisCall(policy, repoKey, input.sessionId));
8690
+ const route = bestOf(routesWithAnAsk, pushesOfTheCurrentBranchIn(input, toolInput)) ?? bestOf(routesTheAllowDoesNotNarrow, pushSpellingsBeyondTheWrittenOnesIn(input, toolInput));
8691
+ const ask = route && askRows.find((policy) => policy.tool === route.toolPattern);
8483
8692
  if (ask) {
8484
8693
  const mode = input.modeState.mode ?? input.config.modeOverride ?? ask.mode;
8485
8694
  return { ...ask, mode };
@@ -8495,7 +8704,30 @@ var policyForScopeQuestion = (policy) => policy.timeoutAction === "approve" ? {
8495
8704
  timeoutAction: "wait",
8496
8705
  pushFirstSeconds: policy.pushFirstSeconds > 0 ? policy.pushFirstSeconds : SCOPE_QUESTION_FIRST_WAIT_SECONDS
8497
8706
  } : policy;
8498
- var resolveGate = (input) => {
8707
+ var isAReading = (reading) => reading !== null && reading.trim() !== "";
8708
+ var extraReadingsOf = (toolInput) => {
8709
+ const { command } = toolInput;
8710
+ if (typeof command !== "string" || command.length > LONGEST_COMMAND_READ_FOR_A_PUSH) return [];
8711
+ const commentFree = readingWithoutCommentsOrAnsiEscapes(command);
8712
+ const spelledOut = [command, commentFree].filter(isAReading).map(readingWithShellFormsSpelledOut);
8713
+ const readings = [
8714
+ commentFree,
8715
+ ...spelledOut,
8716
+ ...[command, commentFree, ...spelledOut].filter(isAReading).flatMap((text3) => scriptsPassedToAShell(text3)).map(readingWithoutCommentsOrAnsiEscapes)
8717
+ ];
8718
+ return readings.filter(isAReading).map((reading) => ({ ...toolInput, command: reading }));
8719
+ };
8720
+ var readingsNotYetJudged = (toolInputs) => {
8721
+ const judged = new Set(toolInputs.map((toolInput) => toolInput.command));
8722
+ return toolInputs.flatMap(extraReadingsOf).filter((reading) => {
8723
+ const isNew = !judged.has(reading.command);
8724
+ judged.add(reading.command);
8725
+ return isNew;
8726
+ });
8727
+ };
8728
+ var withExtraReadings = (input) => shellDialectOf(input.toolName) !== void 0 ? { ...input, toolInputs: [...input.toolInputs, ...readingsNotYetJudged(input.toolInputs)] } : input;
8729
+ var resolveGate = (rawInput) => {
8730
+ const input = withExtraReadings(rawInput);
8499
8731
  const { modeState, config, toolName, toolInputs, cwd, sessionId } = input;
8500
8732
  const repoKey = input.sharedRepoKey ?? input.repoKey;
8501
8733
  if (isPusharyOwnTool(toolName)) {
@@ -8510,31 +8742,34 @@ var resolveGate = (input) => {
8510
8742
  const legacyPolicy = (toolInputs.length ? toolInputs : [void 0]).map((toolInput) => resolvePolicy(config, toolName, modeState.mode, toolInput, cwd, input.repoKey, sessionId)).find((policy2) => policy2.repoKey === input.repoKey && verdictForPolicy(policy2) === "deny");
8511
8743
  if (legacyPolicy) return { kind: "deny", policy: legacyPolicy, reason: `Denied by policy for ${legacyPolicy.tool}` };
8512
8744
  }
8513
- const policy = resolvePolicyAcross(config, toolName, modeState.mode, toolInputs, cwd, repoKey, sessionId);
8745
+ const policy = toolInputs.slice(rawInput.toolInputs.length).map((reading) => resolvePolicy(config, toolName, modeState.mode, reading, cwd, repoKey, sessionId)).reduce(
8746
+ (strictest, reading) => strictestReadingOf(reading, strictest),
8747
+ resolvePolicyAcross(config, toolName, modeState.mode, rawInput.toolInputs, cwd, repoKey, sessionId)
8748
+ );
8514
8749
  const verdict = verdictForPolicy(policy);
8515
8750
  const autoDenies = verdict === "deny";
8516
8751
  const allowedByBypassMode = !autoDenies && verdict !== "allow" && bypassModeAllows(input);
8517
- const askBesideARoutedPush = verdict === "allow" ? askAtTheRouteOfAPushOfTheCurrentBranch(input, repoKey) : void 0;
8752
+ const askBesideARoutedPush = verdict === "allow" ? askAtTheRouteOfAPush(input, repoKey, policy) : void 0;
8518
8753
  const autoApproves = (verdict === "allow" || allowedByBypassMode) && askBesideARoutedPush === void 0;
8519
8754
  const askedPolicy = askBesideARoutedPush ?? policy;
8520
8755
  if (autoDenies) return { kind: "deny", policy, reason: `Denied by policy for ${policy.tool}` };
8521
8756
  if (isAskedInEveryMode(toolName)) return { kind: "gate", policy };
8522
8757
  if (isModeStateDegraded(modeState)) {
8523
8758
  if (autoApproves) {
8524
- return survivesDegraded(config, toolName, toolInputs, cwd, repoKey, sessionId) ? { kind: "allow", policy, source: "allowlist" } : { kind: "defer", policy };
8759
+ return survivesDegraded(config, toolName, rawInput.toolInputs, cwd, repoKey, sessionId) ? { kind: "allow", policy, source: "allowlist" } : { kind: "defer", policy };
8525
8760
  }
8526
8761
  return { kind: "gate", policy: askedPolicy };
8527
8762
  }
8528
8763
  const scopeVerdict = modeState.scope ? strictestScopeVerdict(modeState.scope, input.scopePaths ?? []) : { outcome: "no_contract" };
8529
8764
  if (autoApproves) {
8530
8765
  if (!scopeRequiresHuman(scopeVerdict)) {
8531
- if (config.knownSuperseded === true && !survivesDegraded(config, toolName, toolInputs, cwd, repoKey, sessionId)) {
8766
+ if (config.knownSuperseded === true && !survivesDegraded(config, toolName, rawInput.toolInputs, cwd, repoKey, sessionId)) {
8532
8767
  return { kind: "defer", policy };
8533
8768
  }
8534
8769
  return {
8535
8770
  kind: "allow",
8536
8771
  policy: allowedByBypassMode ? autoApprove(policy.tool) : policy,
8537
- source: toolInputs.length === 1 && resolveAutoResolveOrigin(config, toolName, toolInputs[0], cwd, repoKey, sessionId) === "safe_readonly" ? "allowlist" : "policy"
8772
+ source: rawInput.toolInputs.length === 1 && resolveAutoResolveOrigin(config, toolName, rawInput.toolInputs[0], cwd, repoKey, sessionId) === "safe_readonly" ? "allowlist" : "policy"
8538
8773
  };
8539
8774
  }
8540
8775
  }
@@ -8655,13 +8890,17 @@ var approvalRoutesOf = (config) => {
8655
8890
  const routes = config.approvalRoutes ?? [];
8656
8891
  return Array.isArray(routes) && routes.every(isApprovalRoutePattern) ? routes : null;
8657
8892
  };
8658
- var GIT_PUSH_OPTIONS_WITH_A_VALUE = /* @__PURE__ */ new Set(["-o", "--push-option", "--repo", "--receive-pack", "--exec"]);
8659
- var GIT_PUSH_FLAGS_THAT_PUSH_NO_BRANCH = /* @__PURE__ */ new Set(["--dry-run", "--tags"]);
8660
- var GIT_PUSH_SHORT_FLAGS_WITH_A_DRY_RUN = /^-[A-Za-z]*n[A-Za-z]*$/;
8893
+ var GIT_PUSH_OPTIONS_WITH_A_VALUE = /* @__PURE__ */ new Set(["--push-option", "--repo", "--receive-pack", "--exec", "--recurse-submodules"]);
8894
+ var GIT_PUSH_OPTION_WITH_ITS_VALUE_ATTACHED = /^--(?:push-option|repo|receive-pack|exec|recurse-submodules)=/;
8895
+ var GIT_PUSH_SHORT_FLAGS_ENDING_IN_THE_OPTION_FLAG = /^-[A-Za-np-z]*o$/;
8896
+ var GIT_PUSH_DRY_RUN_FLAG = "--dry-run";
8897
+ var GIT_PUSH_TAGS_FLAG = "--tags";
8898
+ var GIT_PUSH_SHORT_FLAGS_WITH_A_DRY_RUN = /^-[A-Za-mp-z]*n[A-Za-z]*$/;
8661
8899
  var HEAD_REFSPECS = /* @__PURE__ */ new Set(["HEAD", "@"]);
8662
8900
  var MOVES_BEFORE_A_PUSH = /^(?:(?:if|elif|while|until)\s+)?(?:(?:cd|pushd|popd)(?:\s|$)|git\s+(?:checkout|switch)(?:\s|$))/;
8663
8901
  var LONGEST_COMMAND_READ_FOR_A_PUSH = 16 * 1024;
8664
- var pushesNoBranchItself = (word) => GIT_PUSH_FLAGS_THAT_PUSH_NO_BRANCH.has(word) || GIT_PUSH_SHORT_FLAGS_WITH_A_DRY_RUN.test(word);
8902
+ var isADryRunFlag = (word) => word === GIT_PUSH_DRY_RUN_FLAG || GIT_PUSH_SHORT_FLAGS_WITH_A_DRY_RUN.test(word);
8903
+ var takesTheNextWordAsItsValue = (word) => GIT_PUSH_OPTIONS_WITH_A_VALUE.has(word) || GIT_PUSH_SHORT_FLAGS_ENDING_IN_THE_OPTION_FLAG.test(word);
8665
8904
  var pointsGitAtAnotherRepository = (form) => {
8666
8905
  const [program, ...words] = form.split(" ");
8667
8906
  if (program !== "git") return false;
@@ -8672,44 +8911,86 @@ var pointsGitAtAnotherRepository = (form) => {
8672
8911
  }
8673
8912
  return false;
8674
8913
  };
8914
+ var wordsBeforeAComment = (form) => {
8915
+ const words = shellWordsOf(form);
8916
+ if (words === null) return form.split(" ");
8917
+ const firstComment = words.findIndex((word) => word.comment);
8918
+ return (firstComment === -1 ? words : words.slice(0, firstComment)).map((word) => word.text);
8919
+ };
8675
8920
  var gitPushWordsOf = (form) => {
8676
- const [program, subcommand, ...words] = form.split(" ");
8921
+ const [program, subcommand, ...words] = wordsBeforeAComment(form);
8677
8922
  if (program !== "git" || subcommand !== "push") return null;
8678
8923
  const flags = [];
8679
8924
  const operands = [];
8680
8925
  for (let index = 0; index < words.length; index += 1) {
8681
8926
  const word = words[index] ?? "";
8682
- if (pushesNoBranchItself(word)) return null;
8683
- if (GIT_PUSH_OPTIONS_WITH_A_VALUE.has(word)) index += 1;
8684
- else if (word.startsWith("-")) flags.push(word);
8685
- else operands.push(word);
8927
+ if (isADryRunFlag(word)) return null;
8928
+ if (takesTheNextWordAsItsValue(word)) {
8929
+ if (GIT_PUSH_FORCING_FLAG.test(word)) flags.push(word);
8930
+ index += 1;
8931
+ } else if (word.startsWith("-")) {
8932
+ if (!GIT_PUSH_OPTION_WITH_ITS_VALUE_ATTACHED.test(word)) flags.push(word);
8933
+ } else {
8934
+ operands.push(word);
8935
+ }
8686
8936
  }
8687
8937
  return { flags, operands };
8688
8938
  };
8689
8939
  var pushNamesNoBranch = ({ operands }) => operands.length <= 1 || operands.length === 2 && HEAD_REFSPECS.has(operands[1] ?? "");
8940
+ var GIT_PUSH_FORCING_FLAG = /^(?:--force(?:-with-lease|-if-includes)?(?:=.*)?|-[A-Za-z]*f[A-Za-z]*)$/;
8941
+ var GIT_PUSH_FORCE_SPELLINGS = ["--force", "-f"];
8942
+ var FORCED_REFSPEC_MARK = "+";
8943
+ var REFSPEC_SEPARATOR = ":";
8944
+ var BRANCH_REF_PREFIXES = ["refs/heads/", "heads/"];
8945
+ var DEFAULT_PUSH_REMOTE = "origin";
8946
+ var destinationOfRefspec = (refspec) => {
8947
+ const forced = refspec.startsWith(FORCED_REFSPEC_MARK);
8948
+ const spec = forced ? refspec.slice(FORCED_REFSPEC_MARK.length) : refspec;
8949
+ const destination = spec.slice(spec.lastIndexOf(REFSPEC_SEPARATOR) + 1);
8950
+ const prefix = BRANCH_REF_PREFIXES.find((candidate) => destination.startsWith(candidate));
8951
+ return { branch: prefix === void 0 ? destination : destination.slice(prefix.length), forced };
8952
+ };
8953
+ var spellingsOfAPushToADestination = (remote, { branch, forced }, flagsForce) => [
8954
+ `git push ${remote} ${branch}`,
8955
+ ...forced || flagsForce ? GIT_PUSH_FORCE_SPELLINGS.map((flag) => `git push ${flag} ${remote} ${branch}`) : []
8956
+ ];
8957
+ var flagsForceThePush = ({ flags }) => flags.some((flag) => GIT_PUSH_FORCING_FLAG.test(flag));
8958
+ var spellingsOfAPushToItsDestinations = (form) => {
8959
+ const push = gitPushWordsOf(form);
8960
+ if (push === null) return [];
8961
+ const forced = flagsForceThePush(push) ? GIT_PUSH_FORCE_SPELLINGS.map((flag) => `git push ${flag}`) : [];
8962
+ if (pushNamesNoBranch(push)) return forced;
8963
+ const [remote = DEFAULT_PUSH_REMOTE, ...refspecs] = push.operands;
8964
+ return [...forced, ...refspecs.map(destinationOfRefspec).flatMap((destination) => spellingsOfAPushToADestination(remote, destination, flagsForceThePush(push)))];
8965
+ };
8690
8966
  var spellingsOfAPushOfTheBranch = (form, branch) => {
8691
8967
  const push = gitPushWordsOf(form);
8692
- if (push === null || !pushNamesNoBranch(push)) return [];
8693
- const remote = push.operands[0] ?? "origin";
8968
+ if (push === null || push.flags.includes(GIT_PUSH_TAGS_FLAG) || !pushNamesNoBranch(push)) return [];
8969
+ const remote = push.operands[0] ?? DEFAULT_PUSH_REMOTE;
8694
8970
  return [.../* @__PURE__ */ new Set([`git push ${remote} ${branch}`, ["git push", ...push.flags, remote, branch].join(" ")])];
8695
8971
  };
8972
+ var forcedSpellingsOfAPushOfTheBranch = (form, branch) => {
8973
+ const push = gitPushWordsOf(form);
8974
+ if (push === null || !flagsForceThePush(push)) return [];
8975
+ return spellingsOfAPushOfTheBranch(form, branch).length === 0 ? [] : GIT_PUSH_FORCE_SPELLINGS.map((flag) => `git push ${flag} ${push.operands[0] ?? DEFAULT_PUSH_REMOTE} ${branch}`);
8976
+ };
8696
8977
  var commandReadForAPush = (input, toolInput) => {
8697
8978
  const command = POSIX_SHELL_TOOLS.has(input.toolName) ? extractPolicyArg(input.toolName, toolInput) : void 0;
8698
8979
  return command !== void 0 && command.length <= LONGEST_COMMAND_READ_FOR_A_PUSH ? command : void 0;
8699
8980
  };
8700
- var pushesInSegmentsBeforeAMove = (command, branch) => {
8981
+ var pushesInSegmentsBeforeAMove = (command, branch, spellingsOf) => {
8701
8982
  const pushes = [];
8702
8983
  for (const segment of spelledSegmentsOf(command)) {
8703
8984
  const { forms } = commandSpellings(segment.text, SPELLS_COMMAND_RUNNERS_TOO);
8704
8985
  if (forms.some((form) => MOVES_BEFORE_A_PUSH.test(form))) break;
8705
- if (!forms.some(pointsGitAtAnotherRepository)) pushes.push(...forms.flatMap((form) => spellingsOfAPushOfTheBranch(form, branch)));
8986
+ if (!forms.some(pointsGitAtAnotherRepository)) pushes.push(...forms.flatMap((form) => spellingsOf(form, branch)));
8706
8987
  }
8707
8988
  return [...new Set(pushes)];
8708
8989
  };
8709
- var pushesOfTheCurrentBranchIn = (input, toolInput) => {
8990
+ var pushesOfTheCurrentBranchIn = (input, toolInput, spellingsOf = spellingsOfAPushOfTheBranch) => {
8710
8991
  const branch = input.currentBranch;
8711
8992
  const command = branch !== void 0 && isGitBranch(branch) ? commandReadForAPush(input, toolInput) : void 0;
8712
- return branch === void 0 || command === void 0 ? [] : pushesInSegmentsBeforeAMove(command, branch);
8993
+ return branch === void 0 || command === void 0 ? [] : pushesInSegmentsBeforeAMove(command, branch, spellingsOf);
8713
8994
  };
8714
8995
  var MENTIONS_A_GIT_PUSH = /\bgit\b[\s\S]*\bpush\b/;
8715
8996
  var toolInputMayPushTheCurrentBranch = (toolName, toolInput) => {
@@ -8717,13 +8998,20 @@ var toolInputMayPushTheCurrentBranch = (toolName, toolInput) => {
8717
8998
  return command !== void 0 && command.length <= LONGEST_COMMAND_READ_FOR_A_PUSH && MENTIONS_A_GIT_PUSH.test(command);
8718
8999
  };
8719
9000
  var callMayPushTheCurrentBranch = (toolName, toolInputs) => POSIX_SHELL_TOOLS.has(toolName) && toolInputs.some((toolInput) => toolInputMayPushTheCurrentBranch(toolName, toolInput));
8720
- var routeArgumentsOf = (input, toolInput) => [...policyArgForms(input.toolName, toolInput, input.cwd), ...pushesOfTheCurrentBranchIn(input, toolInput)];
9001
+ var pushDestinationSpellingsIn = (input, toolInput) => {
9002
+ const command = commandReadForAPush(input, toolInput);
9003
+ if (command === void 0 || !MENTIONS_A_GIT_PUSH.test(command)) return [];
9004
+ return [...new Set(spelledSegmentsOf(command).flatMap((segment) => commandSpellings(segment.text, SPELLS_COMMAND_RUNNERS_TOO).forms.flatMap(spellingsOfAPushToItsDestinations)))];
9005
+ };
9006
+ var pushSpellingsBeyondTheWrittenOnesIn = (input, toolInput) => [...pushesOfTheCurrentBranchIn(input, toolInput, forcedSpellingsOfAPushOfTheBranch), ...pushDestinationSpellingsIn(input, toolInput)];
9007
+ var writtenRouteArgumentsOf = (input, toolInput) => [...policyArgForms(input.toolName, toolInput, input.cwd), ...pushesOfTheCurrentBranchIn(input, toolInput)];
9008
+ var routeArgumentsOf = (input, toolInput) => [...writtenRouteArgumentsOf(input, toolInput), ...pushSpellingsBeyondTheWrittenOnesIn(input, toolInput)];
8721
9009
  var everyRule = () => true;
8722
9010
  var aChosenRuleGoverns = (input, counts = everyRule) => {
8723
9011
  const chosen = input.config.policies.filter((policy) => !isDefaultRule(policy));
8724
9012
  const routes = approvalRoutesOf(input.config);
8725
9013
  if (routes === null) return true;
8726
- return input.toolInputs.some((toolInput) => {
9014
+ return withExtraReadings(input).toolInputs.some((toolInput) => {
8727
9015
  const args = policyArgForms(input.toolName, toolInput, input.cwd);
8728
9016
  const reading = policyReadingOf(chosen, input.toolName, args, SPELLS_COMMAND_RUNNERS_TOO);
8729
9017
  const governing = governingRuleForReading(chosen, input.toolName, args, reading, input.repoKey, input.sessionId);
@@ -8731,16 +9019,27 @@ var aChosenRuleGoverns = (input, counts = everyRule) => {
8731
9019
  });
8732
9020
  };
8733
9021
  var AUTO_PERMISSION_MODE = "auto";
8734
- var routeDeliveredFor = (input, routes, toolInput) => findBestRoute(routes, input.toolName, routeArgumentsOf(input, toolInput), input.sharedRepoKey ?? input.repoKey);
9022
+ var routeWaitsForSomeoneElse = (route) => route.answeredBySomeoneElse === true;
9023
+ var routeDeliveredFor = (input, routes, toolInput) => {
9024
+ const repoKey = input.sharedRepoKey ?? input.repoKey;
9025
+ const written = writtenRouteArgumentsOf(input, toolInput);
9026
+ const writtenRoute = findBestRoute(routes, input.toolName, written, repoKey);
9027
+ if (writtenRoute?.answeredBySomeoneElse === true) return writtenRoute;
9028
+ const spelled = pushSpellingsBeyondTheWrittenOnesIn(input, toolInput).filter((spelling) => !written.includes(spelling));
9029
+ if (spelled.length === 0) return writtenRoute;
9030
+ const heldSpelledRoute = findBestRoute(routes.filter(routeWaitsForSomeoneElse), input.toolName, spelled, repoKey);
9031
+ if (heldSpelledRoute !== void 0 && heldSpelledRoute.toolPattern.length > (writtenRoute?.toolPattern.length ?? -1)) return heldSpelledRoute;
9032
+ return writtenRoute ?? findBestRoute(routes, input.toolName, spelled, repoKey);
9033
+ };
8735
9034
  var callWaitsForSomeoneElse = (input) => {
8736
9035
  const routes = approvalRoutesOf(input.config);
8737
9036
  if (routes === null) return false;
8738
- return input.toolInputs.some((toolInput) => routeDeliveredFor(input, routes, toolInput)?.answeredBySomeoneElse === true);
9037
+ return withExtraReadings(input).toolInputs.some((toolInput) => routeDeliveredFor(input, routes, toolInput)?.answeredBySomeoneElse === true);
8739
9038
  };
8740
9039
  var namedRouteWaitsForSomeoneElse = (input) => {
8741
9040
  const routes = approvalRoutesOf(input.config);
8742
9041
  if (routes === null) return false;
8743
- return input.toolInputs.some((toolInput) => {
9042
+ return withExtraReadings(input).toolInputs.some((toolInput) => {
8744
9043
  const route = routeDeliveredFor(input, routes, toolInput);
8745
9044
  return route?.answeredBySomeoneElse === true && patternToolName(route.toolPattern) === input.toolName;
8746
9045
  });
@@ -8748,7 +9047,7 @@ var namedRouteWaitsForSomeoneElse = (input) => {
8748
9047
  var matchedRouteOf = (input) => {
8749
9048
  const routes = approvalRoutesOf(input.config);
8750
9049
  if (routes === null) return void 0;
8751
- const matched = input.toolInputs.flatMap((toolInput) => routeDeliveredFor(input, routes, toolInput) ?? []);
9050
+ const matched = withExtraReadings(input).toolInputs.flatMap((toolInput) => routeDeliveredFor(input, routes, toolInput) ?? []);
8752
9051
  const route = matched.find((candidate) => candidate.answeredBySomeoneElse === true) ?? matched[0];
8753
9052
  if (route === void 0) return void 0;
8754
9053
  return route.repoKey ? { toolPattern: route.toolPattern, repoKey: route.repoKey } : { toolPattern: route.toolPattern };
@@ -9277,6 +9576,7 @@ export {
9277
9576
  isTokenCount,
9278
9577
  reportableSessionId,
9279
9578
  TOOL_NAME_MAX_LENGTH,
9579
+ WILDCARD_TOOL_PATTERN,
9280
9580
  normalizeRepoRemote,
9281
9581
  localRepoKey,
9282
9582
  isSafeReadOnlyCommand,
@@ -9301,6 +9601,7 @@ export {
9301
9601
  resolvePolicy,
9302
9602
  KILL_REASON,
9303
9603
  isPusharyOwnTool,
9604
+ isPusharyConnectorTool,
9304
9605
  shouldDeferToNativeMode,
9305
9606
  AGENT_QUESTION_TOOL,
9306
9607
  AGENT_QUESTION_STRATEGY,
@@ -9321,6 +9622,9 @@ export {
9321
9622
  isPermissionRequestOwnedByPreToolUse,
9322
9623
  CLAUDE_PRETOOLUSE_MATCHER,
9323
9624
  CLAUDE_MCP_PRETOOLUSE_MATCHER,
9625
+ CLAUDE_REFUSALS_ONLY_TOOLS,
9626
+ CLAUDE_REFUSALS_ONLY_PRETOOLUSE_MATCHER,
9627
+ claudeSubagentToolAliasOf,
9324
9628
  permissionsOffLineAppliesTo,
9325
9629
  permissionsOffAskReason,
9326
9630
  resolveGate,
@@ -4,19 +4,19 @@ import {
4
4
  } from "./chunk-XHKBHWLX.js";
5
5
  import {
6
6
  getMachineId
7
- } from "./chunk-A2TAWW5L.js";
7
+ } from "./chunk-6FR5ZYMS.js";
8
8
  import {
9
9
  readControlMode
10
- } from "./chunk-JBWEGNKE.js";
10
+ } from "./chunk-CPBS6LS3.js";
11
11
  import {
12
12
  pusharyDir
13
- } from "./chunk-A23GIPWY.js";
13
+ } from "./chunk-ZRTUS6WD.js";
14
14
  import {
15
15
  resolveGlobalBinary
16
- } from "./chunk-IKX4X4LJ.js";
16
+ } from "./chunk-ODXZPMKN.js";
17
17
  import {
18
18
  getApiKey
19
- } from "./chunk-KOEQIRDA.js";
19
+ } from "./chunk-MZX35RFX.js";
20
20
  import {
21
21
  readJsonSafe,
22
22
  writeFileAtomic,
@@ -32,7 +32,7 @@ import {
32
32
  } from "./chunk-ZVU6WMMU.js";
33
33
  import {
34
34
  isRecord
35
- } from "./chunk-I7LP4DKM.js";
35
+ } from "./chunk-W744DTUT.js";
36
36
 
37
37
  // src/daemon-lifecycle.ts
38
38
  import { dirname, join, win32 as win32Path } from "path";