pybao-cli 1.3.52 → 1.3.54

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 (132) hide show
  1. package/dist/REPL-R45FYDIH.js +42 -0
  2. package/dist/{acp-2OTYSBBZ.js → acp-RKHYCDNN.js} +26 -26
  3. package/dist/{agentsValidate-674LM3SD.js → agentsValidate-O7UVE36O.js} +7 -7
  4. package/dist/{ask-YXBBQGUE.js → ask-BD4EI3NU.js} +25 -25
  5. package/dist/{autoUpdater-J7VXOOPN.js → autoUpdater-ZYBLYLN3.js} +3 -3
  6. package/dist/{chunk-L5IDOJJJ.js → chunk-24ZHA7Y6.js} +3 -3
  7. package/dist/{chunk-ATJCQ3LJ.js → chunk-6FELR65K.js} +3 -3
  8. package/dist/{chunk-45CWC3JW.js → chunk-AD5SXLOX.js} +1 -1
  9. package/dist/{chunk-HZY4TS6I.js → chunk-AGRH2PYY.js} +3 -3
  10. package/dist/{chunk-2DTFPGL3.js → chunk-AQD5PXW6.js} +3 -3
  11. package/dist/{chunk-MWPM3ESW.js → chunk-BSHNOPUX.js} +3 -3
  12. package/dist/{chunk-KIQ5WDBQ.js → chunk-CTDRGXVN.js} +2 -2
  13. package/dist/{chunk-GQVZF5YT.js → chunk-CXAAFWX6.js} +2 -2
  14. package/dist/{chunk-LR5UHV7J.js → chunk-EX4CINNF.js} +272 -30
  15. package/dist/chunk-EX4CINNF.js.map +7 -0
  16. package/dist/{chunk-5ZEYM76M.js → chunk-GBLM3Z32.js} +3 -3
  17. package/dist/{chunk-FEPW6LM2.js → chunk-GFIOWE6Y.js} +2 -2
  18. package/dist/{chunk-J3G6PUC4.js → chunk-IK6CQQR7.js} +1 -1
  19. package/dist/{chunk-VNN3AASK.js → chunk-ISB6223U.js} +2 -2
  20. package/dist/{chunk-BEXQOYPD.js → chunk-J2LVBW2F.js} +1 -1
  21. package/dist/{chunk-D2ACSVOB.js → chunk-JYGKQP6W.js} +4 -4
  22. package/dist/{chunk-2T5RFGJ2.js → chunk-MMT6FJI2.js} +2 -2
  23. package/dist/{chunk-H6TRG6XP.js → chunk-ORJUE22Z.js} +1 -1
  24. package/dist/{chunk-VNKJNO7F.js → chunk-QFFNOAQC.js} +1 -1
  25. package/dist/{chunk-WADIOYER.js → chunk-QUFE2RKU.js} +4 -4
  26. package/dist/{chunk-74D2ZU54.js → chunk-QZOP7ZRC.js} +43 -32
  27. package/dist/{chunk-74D2ZU54.js.map → chunk-QZOP7ZRC.js.map} +2 -2
  28. package/dist/{chunk-KCGULRGJ.js → chunk-RX7KHSRR.js} +1 -1
  29. package/dist/{chunk-WIPSF6IY.js → chunk-UHBE6Z4U.js} +1 -1
  30. package/dist/{chunk-UH2HA3JE.js → chunk-VC2SEKFU.js} +1 -1
  31. package/dist/{chunk-7ZR4BQXJ.js → chunk-VVY7D4O6.js} +1 -1
  32. package/dist/{chunk-7ZR4BQXJ.js.map → chunk-VVY7D4O6.js.map} +1 -1
  33. package/dist/{chunk-VEKNSDD5.js → chunk-WP6HFJBC.js} +3 -3
  34. package/dist/{chunk-ZFTWJ7YB.js → chunk-ZNTAAH36.js} +1 -1
  35. package/dist/{chunk-E7MXJ3E4.js → chunk-ZNV4TPXH.js} +2 -2
  36. package/dist/{cli-YFEQ4IR3.js → cli-H755ESGH.js} +77 -77
  37. package/dist/commands-Q73J25KY.js +46 -0
  38. package/dist/{config-7BPAGJNA.js → config-P4S5OVNI.js} +4 -4
  39. package/dist/{context-53ZMKBDQ.js → context-CLIF55DC.js} +5 -5
  40. package/dist/{customCommands-NYBEDT2N.js → customCommands-ANBFOZ5H.js} +4 -4
  41. package/dist/{env-XXLFUQZ6.js → env-WWPQUY6R.js} +2 -2
  42. package/dist/index.js +3 -3
  43. package/dist/{llm-CKECJ2WO.js → llm-N36CUF2S.js} +26 -26
  44. package/dist/{llmLazy-4INKR64U.js → llmLazy-JCTBA26R.js} +1 -1
  45. package/dist/{loader-RQOEGPQK.js → loader-FYWGHILU.js} +4 -4
  46. package/dist/{mcp-GBJKTMWB.js → mcp-YAOSEBWF.js} +7 -7
  47. package/dist/{mentionProcessor-3AQ4KZ3G.js → mentionProcessor-WLCP5LRF.js} +5 -5
  48. package/dist/{messages-XX77D3M7.js → messages-FEH5H4RK.js} +1 -1
  49. package/dist/{model-SDRZBVMG.js → model-BBJMG6RX.js} +5 -5
  50. package/dist/{openai-BVRQWJJP.js → openai-3MMRU2SY.js} +5 -5
  51. package/dist/{outputStyles-EGFV466C.js → outputStyles-YTGRHGMD.js} +4 -4
  52. package/dist/{pluginRuntime-CQZJOVSM.js → pluginRuntime-WNI4RTXJ.js} +6 -6
  53. package/dist/{pluginValidation-3WNRJQ5V.js → pluginValidation-H5Y5TDUW.js} +6 -6
  54. package/dist/prompts-ZWF5ATO6.js +48 -0
  55. package/dist/{pybAgentSessionLoad-V3VW4RHA.js → pybAgentSessionLoad-P3AZATOH.js} +4 -4
  56. package/dist/{pybAgentSessionResume-IZ3K2PUS.js → pybAgentSessionResume-LTN62YGZ.js} +4 -4
  57. package/dist/{pybAgentStreamJsonSession-MHANTHJW.js → pybAgentStreamJsonSession-IQ5FZ62V.js} +1 -1
  58. package/dist/{pybHooks-TPWYDEWJ.js → pybHooks-YMAOFH6E.js} +4 -4
  59. package/dist/query-OBWM4FDK.js +50 -0
  60. package/dist/{ripgrep-YSUMONVZ.js → ripgrep-6BTYBGAN.js} +3 -3
  61. package/dist/{skillMarketplace-RJJKOZMF.js → skillMarketplace-MMF67C5A.js} +3 -3
  62. package/dist/{state-Z6HXOQM7.js → state-EYS5CCSJ.js} +2 -2
  63. package/dist/{theme-JPEBHNFS.js → theme-3YHXLBIA.js} +5 -5
  64. package/dist/{toolPermissionSettings-QXKPU5MT.js → toolPermissionSettings-JHDMHHEC.js} +6 -6
  65. package/dist/tools-P6CKBP5A.js +47 -0
  66. package/dist/{userInput-WJKAJ6K2.js → userInput-IAAUYOQQ.js} +27 -27
  67. package/package.json +1 -1
  68. package/dist/REPL-P567LKWL.js +0 -42
  69. package/dist/chunk-LR5UHV7J.js.map +0 -7
  70. package/dist/commands-6VC24OZG.js +0 -46
  71. package/dist/prompts-7U77OFMD.js +0 -48
  72. package/dist/query-C4CJGUGT.js +0 -50
  73. package/dist/tools-RBYPUHBD.js +0 -47
  74. /package/dist/{REPL-P567LKWL.js.map → REPL-R45FYDIH.js.map} +0 -0
  75. /package/dist/{acp-2OTYSBBZ.js.map → acp-RKHYCDNN.js.map} +0 -0
  76. /package/dist/{agentsValidate-674LM3SD.js.map → agentsValidate-O7UVE36O.js.map} +0 -0
  77. /package/dist/{ask-YXBBQGUE.js.map → ask-BD4EI3NU.js.map} +0 -0
  78. /package/dist/{autoUpdater-J7VXOOPN.js.map → autoUpdater-ZYBLYLN3.js.map} +0 -0
  79. /package/dist/{chunk-L5IDOJJJ.js.map → chunk-24ZHA7Y6.js.map} +0 -0
  80. /package/dist/{chunk-ATJCQ3LJ.js.map → chunk-6FELR65K.js.map} +0 -0
  81. /package/dist/{chunk-45CWC3JW.js.map → chunk-AD5SXLOX.js.map} +0 -0
  82. /package/dist/{chunk-HZY4TS6I.js.map → chunk-AGRH2PYY.js.map} +0 -0
  83. /package/dist/{chunk-2DTFPGL3.js.map → chunk-AQD5PXW6.js.map} +0 -0
  84. /package/dist/{chunk-MWPM3ESW.js.map → chunk-BSHNOPUX.js.map} +0 -0
  85. /package/dist/{chunk-KIQ5WDBQ.js.map → chunk-CTDRGXVN.js.map} +0 -0
  86. /package/dist/{chunk-GQVZF5YT.js.map → chunk-CXAAFWX6.js.map} +0 -0
  87. /package/dist/{chunk-5ZEYM76M.js.map → chunk-GBLM3Z32.js.map} +0 -0
  88. /package/dist/{chunk-FEPW6LM2.js.map → chunk-GFIOWE6Y.js.map} +0 -0
  89. /package/dist/{chunk-J3G6PUC4.js.map → chunk-IK6CQQR7.js.map} +0 -0
  90. /package/dist/{chunk-VNN3AASK.js.map → chunk-ISB6223U.js.map} +0 -0
  91. /package/dist/{chunk-BEXQOYPD.js.map → chunk-J2LVBW2F.js.map} +0 -0
  92. /package/dist/{chunk-D2ACSVOB.js.map → chunk-JYGKQP6W.js.map} +0 -0
  93. /package/dist/{chunk-2T5RFGJ2.js.map → chunk-MMT6FJI2.js.map} +0 -0
  94. /package/dist/{chunk-H6TRG6XP.js.map → chunk-ORJUE22Z.js.map} +0 -0
  95. /package/dist/{chunk-VNKJNO7F.js.map → chunk-QFFNOAQC.js.map} +0 -0
  96. /package/dist/{chunk-WADIOYER.js.map → chunk-QUFE2RKU.js.map} +0 -0
  97. /package/dist/{chunk-KCGULRGJ.js.map → chunk-RX7KHSRR.js.map} +0 -0
  98. /package/dist/{chunk-WIPSF6IY.js.map → chunk-UHBE6Z4U.js.map} +0 -0
  99. /package/dist/{chunk-UH2HA3JE.js.map → chunk-VC2SEKFU.js.map} +0 -0
  100. /package/dist/{chunk-VEKNSDD5.js.map → chunk-WP6HFJBC.js.map} +0 -0
  101. /package/dist/{chunk-ZFTWJ7YB.js.map → chunk-ZNTAAH36.js.map} +0 -0
  102. /package/dist/{chunk-E7MXJ3E4.js.map → chunk-ZNV4TPXH.js.map} +0 -0
  103. /package/dist/{cli-YFEQ4IR3.js.map → cli-H755ESGH.js.map} +0 -0
  104. /package/dist/{commands-6VC24OZG.js.map → commands-Q73J25KY.js.map} +0 -0
  105. /package/dist/{config-7BPAGJNA.js.map → config-P4S5OVNI.js.map} +0 -0
  106. /package/dist/{context-53ZMKBDQ.js.map → context-CLIF55DC.js.map} +0 -0
  107. /package/dist/{customCommands-NYBEDT2N.js.map → customCommands-ANBFOZ5H.js.map} +0 -0
  108. /package/dist/{env-XXLFUQZ6.js.map → env-WWPQUY6R.js.map} +0 -0
  109. /package/dist/{llm-CKECJ2WO.js.map → llm-N36CUF2S.js.map} +0 -0
  110. /package/dist/{llmLazy-4INKR64U.js.map → llmLazy-JCTBA26R.js.map} +0 -0
  111. /package/dist/{loader-RQOEGPQK.js.map → loader-FYWGHILU.js.map} +0 -0
  112. /package/dist/{mcp-GBJKTMWB.js.map → mcp-YAOSEBWF.js.map} +0 -0
  113. /package/dist/{mentionProcessor-3AQ4KZ3G.js.map → mentionProcessor-WLCP5LRF.js.map} +0 -0
  114. /package/dist/{messages-XX77D3M7.js.map → messages-FEH5H4RK.js.map} +0 -0
  115. /package/dist/{model-SDRZBVMG.js.map → model-BBJMG6RX.js.map} +0 -0
  116. /package/dist/{openai-BVRQWJJP.js.map → openai-3MMRU2SY.js.map} +0 -0
  117. /package/dist/{outputStyles-EGFV466C.js.map → outputStyles-YTGRHGMD.js.map} +0 -0
  118. /package/dist/{pluginRuntime-CQZJOVSM.js.map → pluginRuntime-WNI4RTXJ.js.map} +0 -0
  119. /package/dist/{pluginValidation-3WNRJQ5V.js.map → pluginValidation-H5Y5TDUW.js.map} +0 -0
  120. /package/dist/{prompts-7U77OFMD.js.map → prompts-ZWF5ATO6.js.map} +0 -0
  121. /package/dist/{pybAgentSessionLoad-V3VW4RHA.js.map → pybAgentSessionLoad-P3AZATOH.js.map} +0 -0
  122. /package/dist/{pybAgentSessionResume-IZ3K2PUS.js.map → pybAgentSessionResume-LTN62YGZ.js.map} +0 -0
  123. /package/dist/{pybAgentStreamJsonSession-MHANTHJW.js.map → pybAgentStreamJsonSession-IQ5FZ62V.js.map} +0 -0
  124. /package/dist/{pybHooks-TPWYDEWJ.js.map → pybHooks-YMAOFH6E.js.map} +0 -0
  125. /package/dist/{query-C4CJGUGT.js.map → query-OBWM4FDK.js.map} +0 -0
  126. /package/dist/{ripgrep-YSUMONVZ.js.map → ripgrep-6BTYBGAN.js.map} +0 -0
  127. /package/dist/{skillMarketplace-RJJKOZMF.js.map → skillMarketplace-MMF67C5A.js.map} +0 -0
  128. /package/dist/{state-Z6HXOQM7.js.map → state-EYS5CCSJ.js.map} +0 -0
  129. /package/dist/{theme-JPEBHNFS.js.map → theme-3YHXLBIA.js.map} +0 -0
  130. /package/dist/{toolPermissionSettings-QXKPU5MT.js.map → toolPermissionSettings-JHDMHHEC.js.map} +0 -0
  131. /package/dist/{tools-RBYPUHBD.js.map → tools-P6CKBP5A.js.map} +0 -0
  132. /package/dist/{userInput-WJKAJ6K2.js.map → userInput-IAAUYOQQ.js.map} +0 -0
@@ -21,6 +21,7 @@ import {
21
21
  WebSearchTool,
22
22
  applyMarkdown,
23
23
  countTokens,
24
+ fileExistsBun,
24
25
  getAbsolutePath,
25
26
  getAgentPrompt,
26
27
  getMaxThinkingTokens,
@@ -29,45 +30,45 @@ import {
29
30
  hasWritePermission,
30
31
  loadLanguage,
31
32
  query
32
- } from "./chunk-74D2ZU54.js";
33
+ } from "./chunk-QZOP7ZRC.js";
33
34
  import {
34
35
  FallbackToolUseRejectedMessage,
35
36
  MCPTool,
36
37
  getClients,
37
38
  getMCPTools
38
- } from "./chunk-D2ACSVOB.js";
39
+ } from "./chunk-JYGKQP6W.js";
39
40
  import {
40
41
  queryLLM
41
- } from "./chunk-WADIOYER.js";
42
+ } from "./chunk-QUFE2RKU.js";
42
43
  import {
43
44
  tree
44
- } from "./chunk-KCGULRGJ.js";
45
+ } from "./chunk-RX7KHSRR.js";
45
46
  import {
46
47
  generateAgentId
47
- } from "./chunk-GQVZF5YT.js";
48
+ } from "./chunk-CXAAFWX6.js";
48
49
  import {
49
50
  getActiveAgents,
50
51
  getAgentByType,
51
52
  getAvailableAgentTypes
52
- } from "./chunk-2T5RFGJ2.js";
53
+ } from "./chunk-MMT6FJI2.js";
53
54
  import {
54
55
  INTERRUPT_MESSAGE,
55
56
  createAssistantMessage,
56
57
  createUserMessage,
57
58
  getLastAssistantMessageId
58
- } from "./chunk-ZFTWJ7YB.js";
59
+ } from "./chunk-ZNTAAH36.js";
59
60
  import {
60
61
  getModelManager
61
- } from "./chunk-ATJCQ3LJ.js";
62
+ } from "./chunk-6FELR65K.js";
62
63
  import {
63
64
  getContext
64
- } from "./chunk-HZY4TS6I.js";
65
+ } from "./chunk-AGRH2PYY.js";
65
66
  import {
66
67
  getTheme
67
- } from "./chunk-VNKJNO7F.js";
68
+ } from "./chunk-QFFNOAQC.js";
68
69
  import {
69
70
  debug
70
- } from "./chunk-45CWC3JW.js";
71
+ } from "./chunk-AD5SXLOX.js";
71
72
  import {
72
73
  BunShell,
73
74
  getCwd,
@@ -76,7 +77,7 @@ import {
76
77
  logError,
77
78
  overwriteLog,
78
79
  readTaskOutput
79
- } from "./chunk-UH2HA3JE.js";
80
+ } from "./chunk-VC2SEKFU.js";
80
81
  import {
81
82
  formatDuration,
82
83
  formatNumber
@@ -3104,15 +3105,255 @@ var LspTool = {
3104
3105
  }
3105
3106
  };
3106
3107
 
3108
+ // src/tools/filesystem/PatchTool/PatchTool.tsx
3109
+ import { z as z7 } from "zod";
3110
+
3111
+ // src/utils/diff/patch-manager.ts
3112
+ var PatchManager = class {
3113
+ static parseMultiFileDiff(diff) {
3114
+ const lines = diff.split("\n");
3115
+ const patches = [];
3116
+ let currentPatch = null;
3117
+ let currentHunk = null;
3118
+ for (const line of lines) {
3119
+ if (line.startsWith("---")) {
3120
+ if (currentHunk && currentPatch) {
3121
+ currentPatch.hunks.push(currentHunk);
3122
+ currentHunk = null;
3123
+ }
3124
+ const pathPart = line.substring(3).trim();
3125
+ continue;
3126
+ }
3127
+ if (line.startsWith("+++")) {
3128
+ const pathPart = line.substring(3).trim();
3129
+ let filePath = pathPart;
3130
+ if (filePath.startsWith("b/")) {
3131
+ filePath = filePath.substring(2);
3132
+ } else if (filePath.startsWith("a/")) {
3133
+ filePath = filePath.substring(2);
3134
+ }
3135
+ currentPatch = {
3136
+ filePath,
3137
+ hunks: []
3138
+ };
3139
+ patches.push(currentPatch);
3140
+ continue;
3141
+ }
3142
+ if (line.startsWith("@@")) {
3143
+ if (!currentPatch) {
3144
+ continue;
3145
+ }
3146
+ if (currentHunk) {
3147
+ currentPatch.hunks.push(currentHunk);
3148
+ }
3149
+ currentHunk = {
3150
+ header: line,
3151
+ oldLines: [],
3152
+ newLines: []
3153
+ };
3154
+ continue;
3155
+ }
3156
+ if (currentHunk) {
3157
+ if (line.startsWith(" ")) {
3158
+ currentHunk.oldLines.push(line.slice(1));
3159
+ currentHunk.newLines.push(line.slice(1));
3160
+ } else if (line.startsWith("-")) {
3161
+ currentHunk.oldLines.push(line.slice(1));
3162
+ } else if (line.startsWith("+")) {
3163
+ currentHunk.newLines.push(line.slice(1));
3164
+ }
3165
+ }
3166
+ }
3167
+ if (currentHunk && currentPatch) {
3168
+ currentPatch.hunks.push(currentHunk);
3169
+ }
3170
+ return patches;
3171
+ }
3172
+ static parse(diff) {
3173
+ const patches = this.parseMultiFileDiff(diff);
3174
+ if (patches.length === 0) {
3175
+ return this.parseRawHunks(diff);
3176
+ }
3177
+ return patches.flatMap((p) => p.hunks);
3178
+ }
3179
+ static parseRawHunks(diff) {
3180
+ const lines = diff.split("\n");
3181
+ const hunks = [];
3182
+ let currentHunk = null;
3183
+ for (const line of lines) {
3184
+ if (line.startsWith("---") || line.startsWith("+++")) continue;
3185
+ if (line.startsWith("@@")) {
3186
+ if (currentHunk) hunks.push(currentHunk);
3187
+ currentHunk = { header: line, oldLines: [], newLines: [] };
3188
+ continue;
3189
+ }
3190
+ if (currentHunk) {
3191
+ if (line.startsWith(" ")) {
3192
+ currentHunk.oldLines.push(line.slice(1));
3193
+ currentHunk.newLines.push(line.slice(1));
3194
+ } else if (line.startsWith("-")) {
3195
+ currentHunk.oldLines.push(line.slice(1));
3196
+ } else if (line.startsWith("+")) {
3197
+ currentHunk.newLines.push(line.slice(1));
3198
+ }
3199
+ }
3200
+ }
3201
+ if (currentHunk) hunks.push(currentHunk);
3202
+ return hunks;
3203
+ }
3204
+ static apply(content, hunks) {
3205
+ const lines = content.split("\n");
3206
+ const replacements = [];
3207
+ let searchStartIndex = 0;
3208
+ for (const hunk of hunks) {
3209
+ const matchIndex = this.findContext(lines, hunk.oldLines, searchStartIndex);
3210
+ if (matchIndex === -1) {
3211
+ throw new Error(`Could not find context for hunk: ${hunk.header}`);
3212
+ }
3213
+ replacements.push({
3214
+ start: matchIndex,
3215
+ length: hunk.oldLines.length,
3216
+ newLines: hunk.newLines
3217
+ });
3218
+ searchStartIndex = matchIndex + hunk.oldLines.length;
3219
+ }
3220
+ replacements.sort((a, b) => b.start - a.start);
3221
+ const resultLines = [...lines];
3222
+ for (const rep of replacements) {
3223
+ resultLines.splice(rep.start, rep.length, ...rep.newLines);
3224
+ }
3225
+ return resultLines.join("\n");
3226
+ }
3227
+ static findContext(lines, context, startIndex) {
3228
+ if (context.length === 0) return startIndex;
3229
+ for (let i = startIndex; i <= lines.length - context.length; i++) {
3230
+ let match = true;
3231
+ for (let j = 0; j < context.length; j++) {
3232
+ if (lines[i + j] !== context[j]) {
3233
+ match = false;
3234
+ break;
3235
+ }
3236
+ }
3237
+ if (match) {
3238
+ return i;
3239
+ }
3240
+ }
3241
+ return -1;
3242
+ }
3243
+ };
3244
+
3245
+ // src/tools/filesystem/PatchTool/PatchTool.tsx
3246
+ import { readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
3247
+
3248
+ // src/tools/filesystem/PatchTool/prompt.ts
3249
+ var DESCRIPTION5 = `Apply a unified diff patch to one or more files.
3250
+
3251
+ Usage:
3252
+ - Provide a standard unified diff string (starting with \`--- a/file\` and \`+++ b/file\`).
3253
+ - The tool uses "Smart Patch" logic: it ignores strict line numbers in the diff header (e.g., \`@@ -10,5 +10,5 @@\`) and instead uses the context lines (lines starting with space) to locate the code block.
3254
+ - This allows you to apply patches even if the file has changed slightly (e.g., lines shifted), as long as the context matches.
3255
+ - Supports applying changes to MULTIPLE files in a single atomic operation. If any file fails to patch, NO files will be changed.
3256
+
3257
+ When to use:
3258
+ - Complex refactoring involving multiple files.
3259
+ - Applying changes where you are confident about the context but unsure about exact line numbers.
3260
+ - When you want to ensure atomicity across multiple file edits.
3261
+
3262
+ Example:
3263
+ \`\`\`diff
3264
+ --- src/utils.ts
3265
+ +++ src/utils.ts
3266
+ @@ -10,3 +10,3 @@
3267
+ function add(a, b) {
3268
+ - return a + b;
3269
+ + return a + b + 0;
3270
+ }
3271
+ \`\`\`
3272
+ `;
3273
+
3274
+ // src/tools/filesystem/PatchTool/PatchTool.tsx
3275
+ var inputSchema7 = z7.strictObject({
3276
+ patch: z7.string().describe("The unified diff to apply. Must include file headers (---/+++)")
3277
+ });
3278
+ var PatchTool = {
3279
+ name: "Patch",
3280
+ async description() {
3281
+ return "Apply a unified diff patch to one or more files";
3282
+ },
3283
+ async prompt() {
3284
+ return DESCRIPTION5;
3285
+ },
3286
+ inputSchema: inputSchema7,
3287
+ userFacingName() {
3288
+ return "Patch";
3289
+ },
3290
+ async isEnabled() {
3291
+ return true;
3292
+ },
3293
+ isReadOnly() {
3294
+ return false;
3295
+ },
3296
+ isConcurrencySafe() {
3297
+ return false;
3298
+ },
3299
+ needsPermissions() {
3300
+ return true;
3301
+ },
3302
+ renderToolUseMessage(input, { verbose }) {
3303
+ return `Applying patch...`;
3304
+ },
3305
+ renderToolResultMessage(result) {
3306
+ return `Patch applied successfully to ${result.metadata?.files_changed?.length ?? 0} files.`;
3307
+ },
3308
+ async validateInput({ patch }) {
3309
+ if (!patch || patch.trim().length === 0) {
3310
+ return { result: false, message: "Patch content is required" };
3311
+ }
3312
+ return { result: true };
3313
+ },
3314
+ async execute({ patch }, context) {
3315
+ const hunks = PatchManager.parse(patch);
3316
+ if (hunks.length === 0) {
3317
+ throw new Error("No valid hunks found in patch");
3318
+ }
3319
+ const patches = PatchManager.parseMultiFileDiff(patch);
3320
+ const plan = [];
3321
+ for (const p of patches) {
3322
+ const filePath = p.filePath.trim();
3323
+ if (!fileExistsBun(filePath)) {
3324
+ throw new Error(`File not found: ${filePath}`);
3325
+ }
3326
+ const content = readFileSync4(filePath, "utf-8");
3327
+ try {
3328
+ const newContent = PatchManager.apply(content, p.hunks);
3329
+ plan.push({ filePath, newContent });
3330
+ } catch (e) {
3331
+ throw new Error(`Failed to apply patch to ${filePath}: ${e.message}`);
3332
+ }
3333
+ }
3334
+ const changedFiles = [];
3335
+ for (const item of plan) {
3336
+ writeFileSync2(item.filePath, item.newContent);
3337
+ changedFiles.push(item.filePath);
3338
+ }
3339
+ return {
3340
+ output: `Successfully applied patch to ${changedFiles.length} files.`,
3341
+ metadata: {
3342
+ files_changed: changedFiles
3343
+ }
3344
+ };
3345
+ }
3346
+ };
3347
+
3107
3348
  // src/tools/mcp/ReadMcpResourceTool/ReadMcpResourceTool.tsx
3108
3349
  import { Box as Box7, Text as Text7 } from "ink";
3109
3350
  import React7 from "react";
3110
- import { z as z7 } from "zod";
3351
+ import { z as z8 } from "zod";
3111
3352
  import { ReadResourceResultSchema } from "@modelcontextprotocol/sdk/types.js";
3112
3353
 
3113
3354
  // src/tools/mcp/ReadMcpResourceTool/prompt.ts
3114
3355
  var TOOL_NAME2 = "ReadMcpResourceTool";
3115
- var DESCRIPTION5 = `Reads a specific resource from an MCP server.
3356
+ var DESCRIPTION6 = `Reads a specific resource from an MCP server.
3116
3357
  - server: The name of the MCP server to read from
3117
3358
  - uri: The URI of the resource to read
3118
3359
 
@@ -3125,19 +3366,19 @@ Parameters:
3125
3366
  - uri (required): The URI of the resource to read`;
3126
3367
 
3127
3368
  // src/tools/mcp/ReadMcpResourceTool/ReadMcpResourceTool.tsx
3128
- var inputSchema7 = z7.strictObject({
3129
- server: z7.string().describe("The MCP server name"),
3130
- uri: z7.string().describe("The resource URI to read")
3369
+ var inputSchema8 = z8.strictObject({
3370
+ server: z8.string().describe("The MCP server name"),
3371
+ uri: z8.string().describe("The resource URI to read")
3131
3372
  });
3132
3373
  var ReadMcpResourceTool = {
3133
3374
  name: TOOL_NAME2,
3134
3375
  async description() {
3135
- return DESCRIPTION5;
3376
+ return DESCRIPTION6;
3136
3377
  },
3137
3378
  async prompt() {
3138
3379
  return PROMPT5;
3139
3380
  },
3140
- inputSchema: inputSchema7,
3381
+ inputSchema: inputSchema8,
3141
3382
  userFacingName() {
3142
3383
  return "readMcpResource";
3143
3384
  },
@@ -3239,9 +3480,9 @@ var ReadMcpResourceTool = {
3239
3480
  import { last, memoize } from "lodash-es";
3240
3481
  import React8 from "react";
3241
3482
  import { Box as Box8, Text as Text8 } from "ink";
3242
- import { z as z8 } from "zod";
3483
+ import { z as z9 } from "zod";
3243
3484
  import { randomUUID as randomUUID2 } from "crypto";
3244
- import { existsSync as existsSync6, readFileSync as readFileSync4 } from "fs";
3485
+ import { existsSync as existsSync6, readFileSync as readFileSync5 } from "fs";
3245
3486
 
3246
3487
  // src/utils/agent/transcripts.ts
3247
3488
  var transcripts = /* @__PURE__ */ new Map();
@@ -3337,17 +3578,17 @@ assistant: "I'm going to use the Task tool to launch the with the greeting-respo
3337
3578
  var TOOL_NAME3 = "Task";
3338
3579
 
3339
3580
  // src/tools/agent/TaskTool/TaskTool.tsx
3340
- var inputSchema8 = z8.object({
3341
- description: z8.string().describe("A short (3-5 word) description of the task"),
3342
- prompt: z8.string().describe("The task for the agent to perform"),
3343
- subagent_type: z8.string().describe("The type of specialized agent to use for this task"),
3344
- model: z8.enum(["sonnet", "opus", "haiku"]).optional().describe(
3581
+ var inputSchema9 = z9.object({
3582
+ description: z9.string().describe("A short (3-5 word) description of the task"),
3583
+ prompt: z9.string().describe("The task for the agent to perform"),
3584
+ subagent_type: z9.string().describe("The type of specialized agent to use for this task"),
3585
+ model: z9.enum(["sonnet", "opus", "haiku"]).optional().describe(
3345
3586
  "Optional model to use for this agent. If not specified, inherits from parent. Prefer haiku for quick, straightforward tasks to minimize cost and latency."
3346
3587
  ),
3347
- resume: z8.string().optional().describe(
3588
+ resume: z9.string().optional().describe(
3348
3589
  "Optional agent ID to resume from. If provided, the agent will continue from the previous execution transcript."
3349
3590
  ),
3350
- run_in_background: z8.boolean().optional().describe(
3591
+ run_in_background: z9.boolean().optional().describe(
3351
3592
  "Set to true to run this agent in the background. Use TaskOutput to read the output later."
3352
3593
  )
3353
3594
  });
@@ -3417,7 +3658,7 @@ function applyAgentPermissionMode(base, options) {
3417
3658
  function readJsonArrayFile(path) {
3418
3659
  if (!existsSync6(path)) return null;
3419
3660
  try {
3420
- const raw = readFileSync4(path, "utf8");
3661
+ const raw = readFileSync5(path, "utf8");
3421
3662
  const parsed = JSON.parse(raw);
3422
3663
  return Array.isArray(parsed) ? parsed : null;
3423
3664
  } catch {
@@ -3498,7 +3739,7 @@ function buildForkContextForAgent(options) {
3498
3739
  }
3499
3740
  var TaskTool = {
3500
3741
  name: TOOL_NAME3,
3501
- inputSchema: inputSchema8,
3742
+ inputSchema: inputSchema9,
3502
3743
  async description() {
3503
3744
  return "Launch a new task";
3504
3745
  },
@@ -3948,6 +4189,7 @@ var getAllTools = () => [
3948
4189
  FileWriteTool,
3949
4190
  DeleteTool,
3950
4191
  NotebookEditTool,
4192
+ PatchTool,
3951
4193
  TodoWriteTool,
3952
4194
  WebSearchTool,
3953
4195
  WebFetchTool,