@morphllm/morphsdk 0.2.125 → 0.2.126

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 (218) hide show
  1. package/dist/{chunk-BQO3WODX.js → chunk-37ZZ24IX.js} +3 -12
  2. package/dist/chunk-37ZZ24IX.js.map +1 -0
  3. package/dist/{chunk-OQGX4RZP.js → chunk-3NLCSADX.js} +2 -2
  4. package/dist/{chunk-UGSV5LPO.js → chunk-5CIUBER5.js} +2 -2
  5. package/dist/{chunk-2S7ZQFIB.js → chunk-6722FXFI.js} +2 -2
  6. package/dist/{chunk-FAZO2LNY.js → chunk-6Y2LHEJJ.js} +2 -2
  7. package/dist/{chunk-IRNUW2DB.js → chunk-76PPJZWV.js} +3 -12
  8. package/dist/chunk-76PPJZWV.js.map +1 -0
  9. package/dist/{chunk-5L3TPS6A.js → chunk-AXYGFPEJ.js} +1 -1
  10. package/dist/{chunk-5L3TPS6A.js.map → chunk-AXYGFPEJ.js.map} +1 -1
  11. package/dist/{chunk-TFK4UOUE.js → chunk-C26M3TWM.js} +6 -6
  12. package/dist/{chunk-TS3E6IRI.js → chunk-CPZKCBED.js} +2 -2
  13. package/dist/{chunk-33CP5QCC.js → chunk-CYVV5X5K.js} +3 -3
  14. package/dist/{chunk-33CP5QCC.js.map → chunk-CYVV5X5K.js.map} +1 -1
  15. package/dist/{chunk-5PNMAWLC.js → chunk-DKODF3YG.js} +2 -2
  16. package/dist/{chunk-5PNMAWLC.js.map → chunk-DKODF3YG.js.map} +1 -1
  17. package/dist/{chunk-IB4MEIQG.js → chunk-EB656RG6.js} +2 -2
  18. package/dist/{chunk-6TH3VNCF.js → chunk-FAH4YGRN.js} +3 -3
  19. package/dist/{chunk-DGYWACHC.js → chunk-GISRJI5P.js} +2 -2
  20. package/dist/{chunk-EF7ZYLA2.js → chunk-HZOTLGJH.js} +19 -12
  21. package/dist/chunk-HZOTLGJH.js.map +1 -0
  22. package/dist/{chunk-FEQJCZJQ.js → chunk-IYZX6EYC.js} +2 -2
  23. package/dist/{chunk-3MLWXJTJ.js → chunk-K2FXHDX2.js} +15 -10
  24. package/dist/chunk-K2FXHDX2.js.map +1 -0
  25. package/dist/{chunk-F6HNFC2H.js → chunk-K6GLBQBV.js} +2 -2
  26. package/dist/{chunk-57PXQ6IS.js → chunk-KJVFYRXY.js} +15 -15
  27. package/dist/{chunk-2MK64KK4.js → chunk-KUABSLVR.js} +2 -2
  28. package/dist/{chunk-PUGSTXLO.js → chunk-NF2QWJDY.js} +6 -7
  29. package/dist/chunk-NF2QWJDY.js.map +1 -0
  30. package/dist/{chunk-7RTJCQWB.js → chunk-QK5RNORE.js} +3 -3
  31. package/dist/chunk-QK5RNORE.js.map +1 -0
  32. package/dist/{chunk-V3HLOZK2.js → chunk-QLBRTLEI.js} +1 -1
  33. package/dist/{chunk-V3HLOZK2.js.map → chunk-QLBRTLEI.js.map} +1 -1
  34. package/dist/chunk-QRXG5CAZ.js +27 -0
  35. package/dist/chunk-QRXG5CAZ.js.map +1 -0
  36. package/dist/{chunk-ACHEU2V3.js → chunk-R74NP2D4.js} +2 -2
  37. package/dist/{chunk-H6KT7IXW.js → chunk-TREVNTLA.js} +2 -2
  38. package/dist/{chunk-G5YJDK5S.js → chunk-ULZOJQ2W.js} +2 -2
  39. package/dist/chunk-VCKJ22DX.js +131 -0
  40. package/dist/chunk-VCKJ22DX.js.map +1 -0
  41. package/dist/{chunk-WZAZFW77.js → chunk-VYJUGQUR.js} +1 -1
  42. package/dist/{chunk-OFQRY3RM.js → chunk-W7WUZMKZ.js} +18 -23
  43. package/dist/chunk-W7WUZMKZ.js.map +1 -0
  44. package/dist/{chunk-BGL35LL6.js → chunk-YHZRHPJI.js} +2 -2
  45. package/dist/{client-JHPwle1Z.d.ts → client-s3_iDem0.d.ts} +0 -4
  46. package/dist/client.cjs +145 -572
  47. package/dist/client.cjs.map +1 -1
  48. package/dist/client.d.ts +1 -2
  49. package/dist/client.js +27 -28
  50. package/dist/edge.cjs +2 -2
  51. package/dist/edge.cjs.map +1 -1
  52. package/dist/edge.js +4 -4
  53. package/dist/{finish-pPJfB0uO.d.ts → finish-DBKuo8yj.d.ts} +2 -0
  54. package/dist/index.cjs +145 -572
  55. package/dist/index.cjs.map +1 -1
  56. package/dist/index.d.ts +1 -2
  57. package/dist/index.js +29 -30
  58. package/dist/modelrouter/core.cjs +2 -2
  59. package/dist/modelrouter/core.cjs.map +1 -1
  60. package/dist/modelrouter/core.js +3 -3
  61. package/dist/modelrouter/index.cjs +2 -2
  62. package/dist/modelrouter/index.cjs.map +1 -1
  63. package/dist/modelrouter/index.js +3 -3
  64. package/dist/tools/browser/anthropic.cjs +2 -2
  65. package/dist/tools/browser/anthropic.cjs.map +1 -1
  66. package/dist/tools/browser/anthropic.js +5 -5
  67. package/dist/tools/browser/core.cjs +2 -2
  68. package/dist/tools/browser/core.cjs.map +1 -1
  69. package/dist/tools/browser/core.js +4 -4
  70. package/dist/tools/browser/index.cjs +2 -2
  71. package/dist/tools/browser/index.cjs.map +1 -1
  72. package/dist/tools/browser/index.js +7 -7
  73. package/dist/tools/browser/openai.cjs +2 -2
  74. package/dist/tools/browser/openai.cjs.map +1 -1
  75. package/dist/tools/browser/openai.js +5 -5
  76. package/dist/tools/browser/profiles/core.cjs +2 -2
  77. package/dist/tools/browser/profiles/core.cjs.map +1 -1
  78. package/dist/tools/browser/profiles/core.js +3 -3
  79. package/dist/tools/browser/profiles/index.cjs +2 -2
  80. package/dist/tools/browser/profiles/index.cjs.map +1 -1
  81. package/dist/tools/browser/profiles/index.js +3 -3
  82. package/dist/tools/browser/vercel.cjs +2 -2
  83. package/dist/tools/browser/vercel.cjs.map +1 -1
  84. package/dist/tools/browser/vercel.js +5 -5
  85. package/dist/tools/codebase_search/anthropic.cjs +2 -2
  86. package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
  87. package/dist/tools/codebase_search/anthropic.js +4 -4
  88. package/dist/tools/codebase_search/core.cjs +2 -2
  89. package/dist/tools/codebase_search/core.cjs.map +1 -1
  90. package/dist/tools/codebase_search/core.js +3 -3
  91. package/dist/tools/codebase_search/index.cjs +2 -2
  92. package/dist/tools/codebase_search/index.cjs.map +1 -1
  93. package/dist/tools/codebase_search/index.js +6 -6
  94. package/dist/tools/codebase_search/openai.cjs +2 -2
  95. package/dist/tools/codebase_search/openai.cjs.map +1 -1
  96. package/dist/tools/codebase_search/openai.js +4 -4
  97. package/dist/tools/codebase_search/vercel.cjs +2 -2
  98. package/dist/tools/codebase_search/vercel.cjs.map +1 -1
  99. package/dist/tools/codebase_search/vercel.js +4 -4
  100. package/dist/tools/fastapply/anthropic.cjs +2 -2
  101. package/dist/tools/fastapply/anthropic.cjs.map +1 -1
  102. package/dist/tools/fastapply/anthropic.js +4 -4
  103. package/dist/tools/fastapply/apply.cjs +2 -2
  104. package/dist/tools/fastapply/apply.cjs.map +1 -1
  105. package/dist/tools/fastapply/apply.js +2 -2
  106. package/dist/tools/fastapply/core.cjs +2 -2
  107. package/dist/tools/fastapply/core.cjs.map +1 -1
  108. package/dist/tools/fastapply/core.js +3 -3
  109. package/dist/tools/fastapply/index.cjs +2 -2
  110. package/dist/tools/fastapply/index.cjs.map +1 -1
  111. package/dist/tools/fastapply/index.js +6 -6
  112. package/dist/tools/fastapply/openai.cjs +2 -2
  113. package/dist/tools/fastapply/openai.cjs.map +1 -1
  114. package/dist/tools/fastapply/openai.js +4 -4
  115. package/dist/tools/fastapply/vercel.cjs +2 -2
  116. package/dist/tools/fastapply/vercel.cjs.map +1 -1
  117. package/dist/tools/fastapply/vercel.js +4 -4
  118. package/dist/tools/index.cjs +2 -2
  119. package/dist/tools/index.cjs.map +1 -1
  120. package/dist/tools/index.js +6 -6
  121. package/dist/tools/utils/resilience.cjs +2 -2
  122. package/dist/tools/utils/resilience.cjs.map +1 -1
  123. package/dist/tools/utils/resilience.js +2 -2
  124. package/dist/tools/warp_grep/agent/config.cjs +1 -1
  125. package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
  126. package/dist/tools/warp_grep/agent/config.d.ts +1 -1
  127. package/dist/tools/warp_grep/agent/config.js +1 -1
  128. package/dist/tools/warp_grep/agent/formatter.cjs +3 -74
  129. package/dist/tools/warp_grep/agent/formatter.cjs.map +1 -1
  130. package/dist/tools/warp_grep/agent/formatter.d.ts +1 -5
  131. package/dist/tools/warp_grep/agent/formatter.js +1 -1
  132. package/dist/tools/warp_grep/agent/parser.cjs +91 -242
  133. package/dist/tools/warp_grep/agent/parser.cjs.map +1 -1
  134. package/dist/tools/warp_grep/agent/parser.d.ts +0 -8
  135. package/dist/tools/warp_grep/agent/parser.js +1 -1
  136. package/dist/tools/warp_grep/agent/runner.cjs +122 -543
  137. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  138. package/dist/tools/warp_grep/agent/runner.js +6 -7
  139. package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
  140. package/dist/tools/warp_grep/agent/types.d.ts +2 -0
  141. package/dist/tools/warp_grep/anthropic.cjs +143 -566
  142. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  143. package/dist/tools/warp_grep/anthropic.d.ts +0 -3
  144. package/dist/tools/warp_grep/anthropic.js +11 -15
  145. package/dist/tools/warp_grep/client.cjs +143 -558
  146. package/dist/tools/warp_grep/client.cjs.map +1 -1
  147. package/dist/tools/warp_grep/client.js +9 -10
  148. package/dist/tools/warp_grep/gemini.cjs +143 -566
  149. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  150. package/dist/tools/warp_grep/gemini.d.ts +0 -3
  151. package/dist/tools/warp_grep/gemini.js +10 -20
  152. package/dist/tools/warp_grep/gemini.js.map +1 -1
  153. package/dist/tools/warp_grep/harness.cjs +124 -540
  154. package/dist/tools/warp_grep/harness.cjs.map +1 -1
  155. package/dist/tools/warp_grep/harness.d.ts +4 -5
  156. package/dist/tools/warp_grep/harness.js +5 -11
  157. package/dist/tools/warp_grep/harness.js.map +1 -1
  158. package/dist/tools/warp_grep/index.cjs +143 -562
  159. package/dist/tools/warp_grep/index.cjs.map +1 -1
  160. package/dist/tools/warp_grep/index.d.ts +1 -2
  161. package/dist/tools/warp_grep/index.js +14 -20
  162. package/dist/tools/warp_grep/openai.cjs +143 -566
  163. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  164. package/dist/tools/warp_grep/openai.d.ts +0 -3
  165. package/dist/tools/warp_grep/openai.js +11 -15
  166. package/dist/tools/warp_grep/providers/local.cjs +17 -10
  167. package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
  168. package/dist/tools/warp_grep/providers/local.d.ts +6 -1
  169. package/dist/tools/warp_grep/providers/local.js +2 -2
  170. package/dist/tools/warp_grep/providers/remote.cjs +4 -5
  171. package/dist/tools/warp_grep/providers/remote.cjs.map +1 -1
  172. package/dist/tools/warp_grep/providers/remote.js +2 -2
  173. package/dist/tools/warp_grep/providers/types.cjs.map +1 -1
  174. package/dist/tools/warp_grep/providers/types.d.ts +2 -0
  175. package/dist/tools/warp_grep/vercel.cjs +143 -560
  176. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  177. package/dist/tools/warp_grep/vercel.d.ts +0 -1
  178. package/dist/tools/warp_grep/vercel.js +11 -15
  179. package/dist/version.cjs +2 -2
  180. package/dist/version.cjs.map +1 -1
  181. package/dist/version.js +1 -1
  182. package/package.json +2 -2
  183. package/dist/chunk-3MLWXJTJ.js.map +0 -1
  184. package/dist/chunk-7RTJCQWB.js.map +0 -1
  185. package/dist/chunk-APP75CBN.js +0 -98
  186. package/dist/chunk-APP75CBN.js.map +0 -1
  187. package/dist/chunk-BQO3WODX.js.map +0 -1
  188. package/dist/chunk-EF7ZYLA2.js.map +0 -1
  189. package/dist/chunk-FMLHRJDF.js +0 -207
  190. package/dist/chunk-FMLHRJDF.js.map +0 -1
  191. package/dist/chunk-GHGJAQSJ.js +0 -282
  192. package/dist/chunk-GHGJAQSJ.js.map +0 -1
  193. package/dist/chunk-IRNUW2DB.js.map +0 -1
  194. package/dist/chunk-OFQRY3RM.js.map +0 -1
  195. package/dist/chunk-PUGSTXLO.js.map +0 -1
  196. package/dist/tools/warp_grep/agent/prompt.cjs +0 -232
  197. package/dist/tools/warp_grep/agent/prompt.cjs.map +0 -1
  198. package/dist/tools/warp_grep/agent/prompt.d.ts +0 -4
  199. package/dist/tools/warp_grep/agent/prompt.js +0 -10
  200. package/dist/tools/warp_grep/agent/prompt.js.map +0 -1
  201. /package/dist/{chunk-OQGX4RZP.js.map → chunk-3NLCSADX.js.map} +0 -0
  202. /package/dist/{chunk-UGSV5LPO.js.map → chunk-5CIUBER5.js.map} +0 -0
  203. /package/dist/{chunk-2S7ZQFIB.js.map → chunk-6722FXFI.js.map} +0 -0
  204. /package/dist/{chunk-FAZO2LNY.js.map → chunk-6Y2LHEJJ.js.map} +0 -0
  205. /package/dist/{chunk-TFK4UOUE.js.map → chunk-C26M3TWM.js.map} +0 -0
  206. /package/dist/{chunk-TS3E6IRI.js.map → chunk-CPZKCBED.js.map} +0 -0
  207. /package/dist/{chunk-IB4MEIQG.js.map → chunk-EB656RG6.js.map} +0 -0
  208. /package/dist/{chunk-6TH3VNCF.js.map → chunk-FAH4YGRN.js.map} +0 -0
  209. /package/dist/{chunk-DGYWACHC.js.map → chunk-GISRJI5P.js.map} +0 -0
  210. /package/dist/{chunk-FEQJCZJQ.js.map → chunk-IYZX6EYC.js.map} +0 -0
  211. /package/dist/{chunk-F6HNFC2H.js.map → chunk-K6GLBQBV.js.map} +0 -0
  212. /package/dist/{chunk-57PXQ6IS.js.map → chunk-KJVFYRXY.js.map} +0 -0
  213. /package/dist/{chunk-2MK64KK4.js.map → chunk-KUABSLVR.js.map} +0 -0
  214. /package/dist/{chunk-ACHEU2V3.js.map → chunk-R74NP2D4.js.map} +0 -0
  215. /package/dist/{chunk-H6KT7IXW.js.map → chunk-TREVNTLA.js.map} +0 -0
  216. /package/dist/{chunk-G5YJDK5S.js.map → chunk-ULZOJQ2W.js.map} +0 -0
  217. /package/dist/{chunk-WZAZFW77.js.map → chunk-VYJUGQUR.js.map} +0 -0
  218. /package/dist/{chunk-BGL35LL6.js.map → chunk-YHZRHPJI.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -36,7 +36,7 @@ var init_package = __esm({
36
36
  "package.json"() {
37
37
  package_default = {
38
38
  name: "@morphllm/morphsdk",
39
- version: "0.2.125",
39
+ version: "0.2.126",
40
40
  description: "TypeScript SDK and CLI for Morph Fast Apply integration",
41
41
  type: "module",
42
42
  main: "./dist/index.cjs",
@@ -178,7 +178,7 @@ var init_package = __esm({
178
178
  "!dist/**/*.test.*"
179
179
  ],
180
180
  scripts: {
181
- build: "tsup version.ts index.ts edge.ts client.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/prompt.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/providers/code_storage_http.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/github.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts git/index.ts git/client.ts git/config.ts git/types.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/utils/resilience.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve",
181
+ build: "tsup version.ts index.ts edge.ts client.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/providers/code_storage_http.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/github.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts git/index.ts git/client.ts git/config.ts git/types.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/utils/resilience.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve",
182
182
  prepare: "npm run build",
183
183
  typecheck: "tsc --noEmit",
184
184
  lint: "eslint .",
@@ -490,7 +490,7 @@ var init_config = __esm({
490
490
  ".*"
491
491
  ];
492
492
  DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || "").split(",").map((s) => s.trim()).filter(Boolean).concat(BUILTIN_EXCLUDES);
493
- DEFAULT_MODEL = "morph-warp-grep-v1";
493
+ DEFAULT_MODEL = "morph-warp-grep-v2";
494
494
  }
495
495
  });
496
496
 
@@ -645,7 +645,8 @@ var local_exports = {};
645
645
  __export(local_exports, {
646
646
  LocalRipgrepProvider: () => LocalRipgrepProvider
647
647
  });
648
- function shouldSkip2(name) {
648
+ function shouldSkip2(name, allowNames) {
649
+ if (allowNames?.has(name)) return false;
649
650
  if (SKIP_NAMES2.has(name)) return true;
650
651
  if (name.startsWith(".")) return true;
651
652
  for (const ext of SKIP_EXTENSIONS2) {
@@ -740,10 +741,14 @@ var init_local = __esm({
740
741
  ".js.map"
741
742
  ]);
742
743
  LocalRipgrepProvider = class {
743
- constructor(repoRoot, excludes = DEFAULT_EXCLUDES) {
744
+ constructor(repoRoot, excludes = DEFAULT_EXCLUDES, options) {
744
745
  this.repoRoot = repoRoot;
745
746
  this.excludes = excludes;
747
+ if (options?.allowNames?.length) {
748
+ this.allowNames = new Set(options.allowNames);
749
+ }
746
750
  }
751
+ allowNames;
747
752
  async grep(params) {
748
753
  let abs;
749
754
  try {
@@ -757,6 +762,7 @@ var init_local = __esm({
757
762
  const stat = await import_promises2.default.stat(abs).catch(() => null);
758
763
  if (!stat) return { lines: [] };
759
764
  const targetArg = abs === import_path5.default.resolve(this.repoRoot) ? "." : toRepoRelative(this.repoRoot, abs);
765
+ const contextLines = params.context_lines !== void 0 ? String(params.context_lines) : "1";
760
766
  const args = [
761
767
  "--no-config",
762
768
  "--no-heading",
@@ -766,9 +772,10 @@ var init_local = __esm({
766
772
  "--trim",
767
773
  "--max-columns=400",
768
774
  "-C",
769
- "1",
775
+ contextLines,
776
+ ...params.case_sensitive === false ? ["--ignore-case"] : [],
770
777
  ...params.glob ? ["--glob", params.glob] : [],
771
- ...this.excludes.flatMap((e) => ["-g", `!${e}`]),
778
+ ...this.excludes.filter((e) => !this.allowNames?.has(e)).flatMap((e) => ["-g", `!${e}`]),
772
779
  params.pattern,
773
780
  targetArg || "."
774
781
  ];
@@ -793,10 +800,9 @@ Details: ${res.stderr}` : ""}`
793
800
  }
794
801
  const lines = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
795
802
  if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {
796
- return {
797
- lines: [],
798
- error: "query not specific enough, tool tried to return too much context and failed"
799
- };
803
+ const truncated = lines.slice(0, AGENT_CONFIG.MAX_OUTPUT_LINES);
804
+ truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);
805
+ return { lines: truncated };
800
806
  }
801
807
  return { lines };
802
808
  }
@@ -870,7 +876,7 @@ Details: ${res.stderr}` : ""}`
870
876
  }
871
877
  if (out.length > AGENT_CONFIG.MAX_READ_LINES) {
872
878
  const truncated = out.slice(0, AGENT_CONFIG.MAX_READ_LINES);
873
- truncated.push(`... [truncated: showing ${AGENT_CONFIG.MAX_READ_LINES} of ${out.length} lines]`);
879
+ truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_READ_LINES} of ${out.length} lines)`);
874
880
  return { lines: truncated };
875
881
  }
876
882
  return { lines: out };
@@ -890,6 +896,7 @@ Details: ${res.stderr}` : ""}`
890
896
  const maxDepth = params.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;
891
897
  const regex = params.pattern ? new RegExp(params.pattern) : null;
892
898
  const repoRoot = this.repoRoot;
899
+ const allowNames = this.allowNames;
893
900
  const results = [];
894
901
  let timedOut = false;
895
902
  const startTime = Date.now();
@@ -907,7 +914,7 @@ Details: ${res.stderr}` : ""}`
907
914
  }
908
915
  for (const entry of entries) {
909
916
  if (timedOut || results.length >= maxResults) break;
910
- if (shouldSkip2(entry.name)) continue;
917
+ if (shouldSkip2(entry.name, allowNames)) continue;
911
918
  if (regex && !regex.test(entry.name)) continue;
912
919
  const full = import_path5.default.join(dir, entry.name);
913
920
  const isDir = entry.isDirectory();
@@ -2492,483 +2499,130 @@ async function checkHealth(config = {}) {
2492
2499
  // tools/warp_grep/agent/runner.ts
2493
2500
  init_config();
2494
2501
 
2495
- // tools/warp_grep/agent/prompt.ts
2496
- var SYSTEM_PROMPT = `You are a code search agent. Your task is to find all relevant code for a given search_string.
2497
-
2498
- ### workflow
2499
- You have exactly 4 turns. The 4th turn MUST be a \`finish\` call. Each turn allows up to 8 parallel tool calls.
2500
-
2501
- - Turn 1: Map the territory OR dive deep (based on search_string specificity)
2502
- - Turn 2-3: Refine based on findings
2503
- - Turn 4: MUST call \`finish\` with all relevant code locations
2504
- - You MAY call \`finish\` early if confident\u2014but never before at least 1 search turn.
2505
- - The user strongly prefers if you can call the finish tool early, but you must be correct
2506
-
2507
- Remember, if the task feels easy to you, it is strongly desirable to call 'finish' early using fewer turns, but quality over speed
2508
-
2509
- ### tools
2510
- Tool calls use nested XML elements:
2511
- \`\`\`xml
2512
- <tool_name>
2513
- <parameter>value</parameter>
2514
- </tool_name>
2515
- \`\`\`
2516
-
2517
- ### \`list_directory\`
2518
- Directory tree view. Shows structure of a path, optionally filtered by regex pattern.
2519
-
2520
- Elements:
2521
- - \`<path>\` (required): Directory path to list (use \`.\` for repo root)
2522
- - \`<pattern>\` (optional): Regex to filter results
2523
-
2524
- Examples:
2525
- \`\`\`
2526
- <list_directory>
2527
- <path>src/services</path>
2528
- </list_directory>
2529
-
2530
- <list_directory>
2531
- <path>lib/utils</path>
2532
- <pattern>.*\\.(ts|js)$</pattern>
2533
- </list_directory>
2534
- \`\`\`
2535
-
2536
- ### \`read\`
2537
- Read file contents. Supports multiple line ranges.
2538
- - Returns numbered lines for easy reference
2539
- - ALWAYS include import statements (usually lines 1-20). Better to over-include than miss context.
2540
-
2541
- Elements:
2542
- - \`<path>\` (required): File path to read
2543
- - \`<lines>\` (optional): Line ranges like "1-50,75-80,100-120" (omit to read entire file)
2544
-
2545
- Examples:
2546
- \`\`\`
2547
- <read>
2548
- <path>src/main.py</path>
2549
- </read>
2550
-
2551
- <read>
2552
- <path>src/auth.py</path>
2553
- <lines>1-20,45-80,150-200</lines>
2554
- </read>
2555
- \`\`\`
2556
-
2557
- ### \`grep\`
2558
- Search for pattern matches across files. Returns matches with 1 line of context above and below.
2559
- - Match lines use \`:\` separator \u2192 \`filepath:linenum:content\`
2560
- - Context lines use \`-\` separator \u2192 \`filepath-linenum-content\`
2561
-
2562
- Elements:
2563
- - \`<pattern>\` (required): Search pattern (regex). Use \`(a|b)\` for OR patterns.
2564
- - \`<sub_dir>\` (optional): Subdirectory to search in (defaults to \`.\`)
2565
- - \`<glob>\` (optional): File pattern filter like \`*.py\` or \`*.{ts,tsx}\`
2566
-
2567
- Examples:
2568
- \`\`\`
2569
- <grep>
2570
- <pattern>(authenticate|authorize|login)</pattern>
2571
- <sub_dir>src/auth/</sub_dir>
2572
- </grep>
2573
-
2574
- <grep>
2575
- <pattern>class.*(Service|Controller)</pattern>
2576
- <glob>*.{ts,js}</glob>
2577
- </grep>
2578
-
2579
- <grep>
2580
- <pattern>(DB_HOST|DATABASE_URL|connection)</pattern>
2581
- <glob>*.{py,yaml,env}</glob>
2582
- <sub_dir>lib/</sub_dir>
2583
- </grep>
2584
- \`\`\`
2585
-
2586
- ### \`finish\`
2587
- Submit final answer with all relevant code locations. Uses nested \`<file>\` elements.
2588
-
2589
- File elements:
2590
- - \`<path>\` (required): File path
2591
- - \`<lines>\` (optional): Line ranges like "1-50,75-80" (\`*\` for entire file)
2592
-
2593
- ALWAYS include import statements (usually lines 1-20). Better to over-include than miss context.
2594
-
2595
- Examples:
2596
- \`\`\`
2597
- <finish>
2598
- <file>
2599
- <path>src/auth.py</path>
2600
- <lines>1-15,25-50,75-80</lines>
2601
- </file>
2602
- <file>
2603
- <path>src/models/user.py</path>
2604
- <lines>*</lines>
2605
- </file>
2606
- </finish>
2607
- \`\`\`
2608
- </tools>
2609
-
2610
- <strategy>
2611
- **Before your first tool call, classify the search_string:**
2612
-
2613
- | Search_string Type | Round 1 Strategy | Early Finish? |
2614
- |------------|------------------|---------------|
2615
- | **Specific** (function name, error string, unique identifier) | 8 parallel greps on likely paths | Often by round 2 |
2616
- | **Conceptual** (how does X work, where is Y handled) | list_directory + 2-3 broad greps | Rarely early |
2617
- | **Exploratory** (find all tests, list API endpoints) | list_directory at multiple depths | Usually needs 3 rounds |
2618
-
2619
- **Parallel call patterns:**
2620
- - **Shotgun grep**: Same pattern, 8 different directories\u2014fast coverage
2621
- - **Variant grep**: 8 pattern variations (synonyms, naming conventions)\u2014catches inconsistent codebases
2622
- - **Funnel**: 1 list_directory + 7 greps\u2014orient and search simultaneously
2623
- - **Deep read**: 8 reads on files you already identified\u2014gather full context fast
2624
-
2625
- **Tool call expectations:**
2626
- - Low quality tool calls are ones that give back sparse information. This either means they are not well thought out and are not educated guesses OR, they are too broad and give back too many results.
2627
- - High quality tool calls strike a balance between complexity in the tool call to exclude results we know we don't want, and how wide the search space is so that we don't miss anything. It is ok to start off with wider search spaces, but is imperative that you use your intuition from there on out and seek high quality tool calls only.
2628
- - You are not starting blind, you have some information about root level repo structure going in, so use that to prevent making trivial repo wide queries.
2629
- - The grep tool shows you which file path and line numbers the pattern was found in, use this information smartly when trying to read the file.
2630
- </strategy>
2631
-
2632
- <output_format>
2633
- EVERY response MUST follow this exact format:
2634
-
2635
- 1. First, wrap your reasoning in \`<think>...</think>\` tags containing:
2636
- - Search_string classification (specific/conceptual/exploratory)
2637
- - Confidence estimate (can I finish in 1-2 rounds?)
2638
- - This round's parallel strategy
2639
- - What signals would let me finish early?
2640
-
2641
- 2. Then, output up to 8 tool calls using nested XML elements.
2642
-
2643
- Example:
2644
- \`\`\`
2645
- <think>
2646
- This is a specific search_string about authentication. I'll grep for auth-related patterns.
2647
- High confidence I can finish in 2 rounds if I find the auth module. I have already been shown the repo's structure at root
2648
- Strategy: Shotgun grep across likely directories.
2649
- </think>
2650
- <grep>
2651
- <pattern>(authenticate|login|session)</pattern>
2652
- <sub_dir>src/auth/</sub_dir>
2653
- </grep>
2654
- <grep>
2655
- <pattern>(middleware|interceptor)</pattern>
2656
- <glob>*.{ts,js}</glob>
2657
- </grep>
2658
- <list_directory>
2659
- <path>src/auth</path>
2660
- </list_directory>
2661
- \`\`\`
2662
-
2663
- Finishing example:
2664
- \`\`\`
2665
- <think>
2666
- I think I have a rough idea, but this is my last turn so I must call the finish tool regardless.
2667
- </think>
2668
- <finish>
2669
- <file>
2670
- <path>src/auth/login.py</path>
2671
- <lines>1-50</lines>
2672
- </file>
2673
- <file>
2674
- <path>src/middleware/session.py</path>
2675
- <lines>10-80</lines>
2676
- </file>
2677
- </finish>
2678
- \`\`\`
2679
-
2680
- No commentary outside \`<think>\`. No explanations after tool calls.
2681
- </output_format>
2682
-
2683
- use as all 8 tool calls to be optimal
2684
-
2685
- <finishing_requirements>
2686
- When calling \`finish\`:
2687
- - Include the import section (typically lines 1-20) of each file
2688
- - Include all function/class definitions that are relevant
2689
- - Include any type definitions, interfaces, or constants used
2690
- - Better to over-include than leave the user missing context
2691
- - If unsure about boundaries, include more rather than less
2692
- </finishing_requirements>`;
2693
- function getSystemPrompt() {
2694
- return SYSTEM_PROMPT;
2695
- }
2696
-
2697
2502
  // tools/warp_grep/agent/parser.ts
2698
- var VALID_COMMANDS = ["list_directory", "grep", "read", "finish"];
2503
+ var VALID_COMMANDS = ["list_directory", "ripgrep", "read", "finish"];
2699
2504
  function isValidCommand(name) {
2700
2505
  return VALID_COMMANDS.includes(name);
2701
2506
  }
2702
- function getXmlElementText(xml, tagName) {
2703
- const regex = new RegExp(`<${tagName}>([\\s\\S]*?)</${tagName}>`, "i");
2704
- const match = xml.match(regex);
2705
- return match ? match[1].trim() : null;
2706
- }
2707
- function parseNestedXmlTools(text) {
2507
+ function parseQwen3ToolCalls(text) {
2708
2508
  const tools = [];
2709
- const toolRegex = /<([a-z_][a-z0-9_]*)>([\s\S]*?)<\/\1>/gi;
2509
+ const toolCallRegex = /<tool_call>\s*<function=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/function>\s*<\/tool_call>/gi;
2710
2510
  let match;
2711
- while ((match = toolRegex.exec(text)) !== null) {
2712
- const rawToolName = match[1].toLowerCase();
2713
- const content = match[2];
2714
- if (!isValidCommand(rawToolName)) continue;
2715
- const toolName = rawToolName;
2716
- if (toolName === "list_directory") {
2717
- const path5 = getXmlElementText(content, "path");
2718
- const pattern = getXmlElementText(content, "pattern");
2719
- if (path5) {
2720
- tools.push({ name: "list_directory", arguments: { path: path5, pattern } });
2511
+ while ((match = toolCallRegex.exec(text)) !== null) {
2512
+ const funcName = match[1].toLowerCase();
2513
+ const body = match[2];
2514
+ if (!isValidCommand(funcName)) continue;
2515
+ const params = {};
2516
+ const paramRegex = /<parameter=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/parameter>/gi;
2517
+ let paramMatch;
2518
+ while ((paramMatch = paramRegex.exec(body)) !== null) {
2519
+ params[paramMatch[1].toLowerCase()] = paramMatch[2].trim();
2520
+ }
2521
+ if (funcName === "ripgrep") {
2522
+ const pattern = params.pattern;
2523
+ if (!pattern) continue;
2524
+ const args = {
2525
+ pattern,
2526
+ path: params.path || ".",
2527
+ ...params.glob && { glob: params.glob },
2528
+ ...params.context_lines && { context_lines: parseInt(params.context_lines, 10) },
2529
+ ...params.case_sensitive && { case_sensitive: params.case_sensitive === "true" }
2530
+ };
2531
+ tools.push({ name: "grep", arguments: args });
2532
+ } else if (funcName === "list_directory") {
2533
+ const command = params.command;
2534
+ const directPath = params.path;
2535
+ let dirPath = directPath || ".";
2536
+ if (!directPath && command) {
2537
+ const tokens = command.trim().split(/\s+/);
2538
+ const pathTokens = tokens.slice(1).filter((t) => !t.startsWith("-") && !t.startsWith("|") && !t.startsWith("\\("));
2539
+ if (pathTokens.length > 0) {
2540
+ dirPath = pathTokens[0];
2541
+ }
2721
2542
  }
2722
- } else if (toolName === "grep") {
2723
- const pattern = getXmlElementText(content, "pattern");
2724
- const subDir = getXmlElementText(content, "sub_dir");
2725
- const glob = getXmlElementText(content, "glob");
2726
- if (pattern) {
2727
- tools.push({
2728
- name: "grep",
2729
- arguments: {
2730
- pattern,
2731
- path: subDir || ".",
2732
- ...glob && { glob }
2543
+ tools.push({ name: "list_directory", arguments: { path: dirPath, pattern: params.pattern || null } });
2544
+ } else if (funcName === "read") {
2545
+ const filePath = params.path;
2546
+ if (!filePath) continue;
2547
+ const args = { path: filePath };
2548
+ const linesStr = params.lines;
2549
+ if (linesStr) {
2550
+ const ranges = [];
2551
+ for (const rangeStr of linesStr.split(",")) {
2552
+ const trimmed = rangeStr.trim();
2553
+ if (!trimmed) continue;
2554
+ const [s, e] = trimmed.split("-").map((v) => parseInt(v.trim(), 10));
2555
+ if (Number.isFinite(s) && Number.isFinite(e)) {
2556
+ ranges.push([s, e]);
2557
+ } else if (Number.isFinite(s)) {
2558
+ ranges.push([s, s]);
2733
2559
  }
2734
- });
2560
+ }
2561
+ if (ranges.length === 1) {
2562
+ args.start = ranges[0][0];
2563
+ args.end = ranges[0][1];
2564
+ } else if (ranges.length > 1) {
2565
+ args.lines = ranges;
2566
+ }
2567
+ }
2568
+ tools.push({ name: "read", arguments: args });
2569
+ } else if (funcName === "finish") {
2570
+ if (params.result && !params.files) {
2571
+ tools.push({ name: "finish", arguments: { files: [], textResult: params.result } });
2572
+ continue;
2573
+ }
2574
+ const filesStr = params.files;
2575
+ if (!filesStr) {
2576
+ tools.push({ name: "finish", arguments: { files: [], textResult: "No relevant code found." } });
2577
+ continue;
2735
2578
  }
2736
- } else if (toolName === "read") {
2737
- const path5 = getXmlElementText(content, "path");
2738
- const linesStr = getXmlElementText(content, "lines");
2739
- if (path5) {
2740
- const args = { path: path5 };
2741
- if (linesStr) {
2579
+ const files = [];
2580
+ for (const line of filesStr.split("\n")) {
2581
+ const trimmed = line.trim();
2582
+ if (!trimmed) continue;
2583
+ const colonIdx = trimmed.indexOf(":");
2584
+ if (colonIdx === -1) {
2585
+ files.push({ path: trimmed, lines: "*" });
2586
+ } else {
2587
+ const filePath = trimmed.slice(0, colonIdx);
2588
+ const rangesPart = trimmed.slice(colonIdx + 1);
2742
2589
  const ranges = [];
2743
- for (const rangeStr of linesStr.split(",")) {
2744
- const trimmed = rangeStr.trim();
2745
- if (!trimmed) continue;
2746
- const [s, e] = trimmed.split("-").map((v) => parseInt(v.trim(), 10));
2590
+ for (const rangeStr of rangesPart.split(",")) {
2591
+ const rt = rangeStr.trim();
2592
+ if (!rt || rt === "*") {
2593
+ files.push({ path: filePath, lines: "*" });
2594
+ break;
2595
+ }
2596
+ const [s, e] = rt.split("-").map((v) => parseInt(v.trim(), 10));
2747
2597
  if (Number.isFinite(s) && Number.isFinite(e)) {
2748
2598
  ranges.push([s, e]);
2749
2599
  } else if (Number.isFinite(s)) {
2750
2600
  ranges.push([s, s]);
2751
2601
  }
2752
2602
  }
2753
- if (ranges.length === 1) {
2754
- args.start = ranges[0][0];
2755
- args.end = ranges[0][1];
2756
- } else if (ranges.length > 1) {
2757
- args.lines = ranges;
2758
- }
2759
- }
2760
- tools.push({ name: "read", arguments: args });
2761
- }
2762
- } else if (toolName === "finish") {
2763
- const fileRegex = /<file>([\s\S]*?)<\/file>/gi;
2764
- const files = [];
2765
- let fileMatch;
2766
- while ((fileMatch = fileRegex.exec(content)) !== null) {
2767
- const fileContent = fileMatch[1];
2768
- const filePath = getXmlElementText(fileContent, "path");
2769
- const linesStr = getXmlElementText(fileContent, "lines");
2770
- if (filePath) {
2771
- if (!linesStr || linesStr.trim() === "*") {
2603
+ if (ranges.length > 0) {
2604
+ files.push({ path: filePath, lines: ranges });
2605
+ } else if (!files.some((f) => f.path === filePath)) {
2772
2606
  files.push({ path: filePath, lines: "*" });
2773
- } else {
2774
- const ranges = [];
2775
- for (const rangeStr of linesStr.split(",")) {
2776
- const [s, e] = rangeStr.split("-").map((v) => parseInt(v.trim(), 10));
2777
- if (Number.isFinite(s) && Number.isFinite(e)) {
2778
- ranges.push([s, e]);
2779
- }
2780
- }
2781
- if (ranges.length > 0) {
2782
- files.push({ path: filePath, lines: ranges });
2783
- } else {
2784
- files.push({ path: filePath, lines: "*" });
2785
- }
2786
2607
  }
2787
2608
  }
2788
2609
  }
2789
2610
  if (files.length > 0) {
2790
2611
  tools.push({ name: "finish", arguments: { files } });
2791
2612
  } else {
2792
- const raw = content.replace(/<[^>]*>/g, "").trim();
2793
- const textResult = !raw || raw === "*" ? "No relevant code found." : raw;
2794
- tools.push({ name: "finish", arguments: { files: [], textResult } });
2613
+ tools.push({ name: "finish", arguments: { files: [], textResult: filesStr } });
2795
2614
  }
2796
2615
  }
2797
2616
  }
2798
- if (tools.length === 0) {
2799
- const fnFinishMatch = text.match(/<function=finish>([\s\S]*?)<\/function>/i);
2800
- if (fnFinishMatch) {
2801
- const inner = fnFinishMatch[1];
2802
- const paramMatch = inner.match(/<parameter=result>([\s\S]*?)<\/parameter>/i);
2803
- const raw = (paramMatch ? paramMatch[1] : inner).trim();
2804
- const textResult = !raw || raw === "*" ? "No relevant code found." : raw;
2805
- tools.push({ name: "finish", arguments: { files: [], textResult } });
2806
- }
2807
- }
2808
2617
  return tools;
2809
2618
  }
2810
- function preprocessText(text) {
2811
- const processed = text.replace(/<think>[\s\S]*?<\/think>/gi, "").replace(/<\/?tool_call>/gi, "");
2812
- const nestedTools = parseNestedXmlTools(processed);
2813
- const toolCallLines = [];
2814
- const allLines = processed.split(/\r?\n/).map((l) => l.trim());
2815
- for (const line of allLines) {
2816
- if (!line) continue;
2817
- if (line.startsWith("<")) continue;
2818
- const firstWord = line.split(/\s/)[0];
2819
- if (VALID_COMMANDS.includes(firstWord)) {
2820
- if (!toolCallLines.includes(line)) {
2821
- toolCallLines.push(line);
2822
- }
2823
- }
2824
- }
2825
- return { lines: toolCallLines, nestedTools };
2826
- }
2827
2619
  var LLMResponseParser = class {
2828
- finishSpecSplitRe = /,(?=[^,\s]+:)/;
2829
2620
  parse(text) {
2830
2621
  if (typeof text !== "string") {
2831
2622
  throw new TypeError("Command text must be a string.");
2832
2623
  }
2833
- const { lines, nestedTools } = preprocessText(text);
2834
- const commands = [...nestedTools];
2835
- let finishAccumulator = null;
2836
- lines.forEach((line) => {
2837
- if (!line || line.startsWith("#")) return;
2838
- const parts = this.splitLine(line);
2839
- if (parts.length === 0) return;
2840
- const cmd = parts[0];
2841
- switch (cmd) {
2842
- case "list_directory":
2843
- this.handleListDirectory(parts, line, commands);
2844
- break;
2845
- case "grep":
2846
- this.handleGrep(parts, line, commands);
2847
- break;
2848
- case "read":
2849
- this.handleRead(parts, line, commands);
2850
- break;
2851
- case "finish":
2852
- finishAccumulator = this.handleFinish(parts, line, commands, finishAccumulator);
2853
- break;
2854
- default:
2855
- break;
2856
- }
2857
- });
2858
- if (finishAccumulator) {
2859
- const map = finishAccumulator;
2860
- const entries = [...map.entries()];
2861
- const filesPayload = entries.map(([path5, ranges]) => ({
2862
- path: path5,
2863
- lines: [...ranges].sort((a, b) => a[0] - b[0])
2864
- }));
2865
- commands.push({ name: "finish", arguments: { files: filesPayload } });
2866
- }
2867
- return commands;
2868
- }
2869
- splitLine(line) {
2870
- const parts = [];
2871
- let current = "";
2872
- let inSingle = false;
2873
- for (let i = 0; i < line.length; i++) {
2874
- const ch = line[i];
2875
- if (ch === "'" && line[i - 1] !== "\\") {
2876
- inSingle = !inSingle;
2877
- current += ch;
2878
- } else if (!inSingle && /\s/.test(ch)) {
2879
- if (current) {
2880
- parts.push(current);
2881
- current = "";
2882
- }
2883
- } else {
2884
- current += ch;
2885
- }
2886
- }
2887
- if (current) parts.push(current);
2888
- return parts;
2889
- }
2890
- /** Helper to create a _skip tool call with an error message */
2891
- skip(message) {
2892
- return { name: "_skip", arguments: { message } };
2893
- }
2894
- handleListDirectory(parts, rawLine, commands) {
2895
- if (parts.length < 2) {
2896
- commands.push(this.skip(
2897
- `[SKIPPED] Your command "${rawLine}" is missing a path. Correct format: list_directory <path> [pattern]. Example: list_directory src/`
2898
- ));
2899
- return;
2900
- }
2901
- const path5 = parts[1];
2902
- const pattern = parts[2]?.replace(/^"|"$/g, "") ?? null;
2903
- commands.push({ name: "list_directory", arguments: { path: path5, pattern } });
2904
- }
2905
- handleGrep(parts, rawLine, commands) {
2906
- if (parts.length < 3) {
2907
- commands.push(this.skip(
2908
- `[SKIPPED] Your command "${rawLine}" is missing arguments. Correct format: grep '<pattern>' <path>. Example: grep 'TODO' src/`
2909
- ));
2910
- return;
2911
- }
2912
- let pat = parts[1];
2913
- if (pat.startsWith("'") && pat.endsWith("'")) {
2914
- pat = pat.slice(1, -1);
2915
- }
2916
- if (!pat) {
2917
- commands.push(this.skip(
2918
- `[SKIPPED] Your command "${rawLine}" has an empty pattern. Provide a non-empty search pattern. Example: grep 'function' src/`
2919
- ));
2920
- return;
2921
- }
2922
- commands.push({ name: "grep", arguments: { pattern: pat, path: parts[2] } });
2923
- }
2924
- handleRead(parts, rawLine, commands) {
2925
- if (parts.length < 2) {
2926
- commands.push(this.skip(
2927
- `[SKIPPED] Your command "${rawLine}" is missing a path. Correct format: read <path> or read <path>:<start>-<end>. Example: read src/index.ts:1-50`
2928
- ));
2929
- return;
2930
- }
2931
- const spec = parts[1];
2932
- const rangeIdx = spec.indexOf(":");
2933
- if (rangeIdx === -1) {
2934
- commands.push({ name: "read", arguments: { path: spec } });
2935
- return;
2936
- }
2937
- const filePath = spec.slice(0, rangeIdx);
2938
- const range = spec.slice(rangeIdx + 1);
2939
- const [s, e] = range.split("-").map((v) => parseInt(v, 10));
2940
- if (!Number.isFinite(s) || !Number.isFinite(e)) {
2941
- commands.push({ name: "read", arguments: { path: filePath } });
2942
- return;
2943
- }
2944
- commands.push({ name: "read", arguments: { path: filePath, start: s, end: e } });
2945
- }
2946
- handleFinish(parts, rawLine, commands, acc) {
2947
- const map = acc ?? /* @__PURE__ */ new Map();
2948
- const args = parts.slice(1);
2949
- for (const token of args) {
2950
- const [filePath, rangesText] = token.split(":", 2);
2951
- if (!filePath || !rangesText) {
2952
- commands.push(this.skip(
2953
- `[SKIPPED] Invalid finish token "${token}". Correct format: finish <path>:<start>-<end>. Example: finish src/index.ts:1-50`
2954
- ));
2955
- continue;
2956
- }
2957
- const rangeSpecs = rangesText.split(",").filter(Boolean);
2958
- for (const spec of rangeSpecs) {
2959
- const [s, e] = spec.split("-").map((v) => parseInt(v, 10));
2960
- if (!Number.isFinite(s) || !Number.isFinite(e) || e < s) {
2961
- commands.push(this.skip(
2962
- `[SKIPPED] Invalid range "${spec}" in "${token}". Ranges must be <start>-<end> where start <= end. Example: 1-50`
2963
- ));
2964
- continue;
2965
- }
2966
- const arr = map.get(filePath) ?? [];
2967
- arr.push([s, e]);
2968
- map.set(filePath, arr);
2969
- }
2970
- }
2971
- return map;
2624
+ const withoutThink = text.replace(/<think>[\s\S]*?<\/think>/gi, "");
2625
+ return parseQwen3ToolCalls(withoutThink);
2972
2626
  }
2973
2627
  };
2974
2628
 
@@ -3038,14 +2692,12 @@ async function toolListDirectory(provider, args) {
3038
2692
  }
3039
2693
  const { entries: list } = await getListRecursive(initialDepth);
3040
2694
  if (!list.length) return "empty";
3041
- if (list.length >= maxResults) {
3042
- return "query not specific enough, tool called tried to return too much context and failed";
3043
- }
3044
- return list.map((e) => {
2695
+ const tree = list.map((e) => {
3045
2696
  const indent = " ".repeat(e.depth);
3046
2697
  const name = e.type === "dir" ? `${e.name}/` : e.name;
3047
2698
  return `${indent}${name}`;
3048
2699
  }).join("\n");
2700
+ return tree;
3049
2701
  }
3050
2702
 
3051
2703
  // tools/warp_grep/agent/tools/finish.ts
@@ -3108,90 +2760,19 @@ function mergeRanges(ranges) {
3108
2760
 
3109
2761
  // tools/warp_grep/agent/formatter.ts
3110
2762
  var ToolOutputFormatter = class {
3111
- format(toolName, args, output, options = {}) {
2763
+ format(toolName, _args, output, options = {}) {
3112
2764
  const name = (toolName ?? "").trim();
3113
2765
  if (!name) {
3114
2766
  return "";
3115
2767
  }
3116
2768
  const payload = output?.toString?.()?.trim?.() ?? "";
3117
2769
  const isError = Boolean(options.isError);
3118
- const safeArgs = args ?? {};
3119
2770
  if (!payload && !isError) {
3120
2771
  return "";
3121
2772
  }
3122
- switch (name) {
3123
- case "read":
3124
- return this.formatRead(safeArgs, payload, isError);
3125
- case "list_directory":
3126
- return this.formatListDirectory(safeArgs, payload, isError);
3127
- case "grep":
3128
- return this.formatGrep(safeArgs, payload, isError);
3129
- default:
3130
- return payload ? `<tool_output>
3131
- ${payload}
3132
- </tool_output>` : "";
3133
- }
3134
- }
3135
- formatRead(args, payload, isError) {
3136
- if (isError) {
3137
- return payload;
3138
- }
3139
- const path5 = this.asString(args.path) || "...";
3140
- const start = args.start;
3141
- const end = args.end;
3142
- const linesArray = args.lines;
3143
- const attributes = [`path="${path5}"`];
3144
- if (linesArray && linesArray.length > 0) {
3145
- const rangeStr = linesArray.map(([s, e]) => `${s}-${e}`).join(",");
3146
- attributes.push(`lines="${rangeStr}"`);
3147
- } else if (start !== void 0 && end !== void 0) {
3148
- attributes.push(`lines="${start}-${end}"`);
3149
- }
3150
- return `<read ${attributes.join(" ")}>
3151
- ${payload}
3152
- </read>`;
3153
- }
3154
- formatListDirectory(args, payload, isError) {
3155
- const path5 = this.asString(args.path) || ".";
3156
- const pattern = this.asString(args.pattern);
3157
- const attributes = [`path="${path5}"`];
3158
- if (pattern) {
3159
- attributes.push(`pattern="${pattern}"`);
3160
- }
3161
- if (isError) {
3162
- attributes.push('status="error"');
3163
- }
3164
- return `<list_directory ${attributes.join(" ")}>
2773
+ return `<tool_response>
3165
2774
  ${payload}
3166
- </list_directory>`;
3167
- }
3168
- formatGrep(args, payload, isError) {
3169
- const pattern = this.asString(args.pattern);
3170
- const subDir = this.asString(args.path);
3171
- const glob = this.asString(args.glob);
3172
- const attributes = [];
3173
- if (pattern !== void 0) {
3174
- attributes.push(`pattern="${pattern}"`);
3175
- }
3176
- if (subDir !== void 0) {
3177
- attributes.push(`sub_dir="${subDir}"`);
3178
- }
3179
- if (glob !== void 0) {
3180
- attributes.push(`glob="${glob}"`);
3181
- }
3182
- if (isError) {
3183
- attributes.push('status="error"');
3184
- }
3185
- const attrText = attributes.length ? ` ${attributes.join(" ")}` : "";
3186
- return `<grep${attrText}>
3187
- ${payload}
3188
- </grep>`;
3189
- }
3190
- asString(value) {
3191
- if (value === null || value === void 0) {
3192
- return void 0;
3193
- }
3194
- return String(value);
2775
+ </tool_response>`;
3195
2776
  }
3196
2777
  };
3197
2778
  var sharedFormatter = new ToolOutputFormatter();
@@ -3220,12 +2801,15 @@ function calculateContextBudget(messages) {
3220
2801
  const maxK = Math.round(maxChars / 1e3);
3221
2802
  return `<context_budget>${percent}% (${usedK}K/${maxK}K chars)</context_budget>`;
3222
2803
  }
3223
- async function buildInitialState(repoRoot, query, provider) {
2804
+ async function buildInitialState(repoRoot, query, provider, options) {
2805
+ const budget = calculateContextBudget([]);
2806
+ const turnTag = `Turn 0/${AGENT_CONFIG.MAX_TURNS}`;
2807
+ const treeDepth = options?.query_type === "node_modules" ? 1 : 2;
3224
2808
  try {
3225
2809
  const entries = await provider.listDirectory({
3226
2810
  path: ".",
3227
2811
  maxResults: AGENT_CONFIG.MAX_OUTPUT_LINES,
3228
- maxDepth: 2
2812
+ maxDepth: treeDepth
3229
2813
  });
3230
2814
  const treeLines = entries.map((e) => {
3231
2815
  const indent = " ".repeat(e.depth);
@@ -3241,7 +2825,9 @@ ${treeOutput}
3241
2825
 
3242
2826
  <search_string>
3243
2827
  ${query}
3244
- </search_string>`;
2828
+ </search_string>
2829
+ ${budget}
2830
+ ${turnTag}`;
3245
2831
  } catch {
3246
2832
  const repoName = import_path2.default.basename(repoRoot);
3247
2833
  return `<repo_structure>
@@ -3250,7 +2836,9 @@ ${repoName}/
3250
2836
 
3251
2837
  <search_string>
3252
2838
  ${query}
3253
- </search_string>`;
2839
+ </search_string>
2840
+ ${budget}
2841
+ ${turnTag}`;
3254
2842
  }
3255
2843
  }
3256
2844
  function enforceContextLimit(messages, maxChars = AGENT_CONFIG.MAX_CONTEXT_CHARS) {
@@ -3338,14 +2926,13 @@ async function runWarpGrep(config) {
3338
2926
  const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
3339
2927
  const timings = { turns: [], timeout_ms: timeoutMs };
3340
2928
  const repoRoot = import_path3.default.resolve(config.repoRoot || process.cwd());
2929
+ const model = config.model || DEFAULT_MODEL;
3341
2930
  const messages = [];
3342
- messages.push({ role: "system", content: getSystemPrompt() });
2931
+ const maxTurns = AGENT_CONFIG.MAX_TURNS;
3343
2932
  const initialStateStart = Date.now();
3344
- const initialState = await buildInitialState(repoRoot, config.query, config.provider);
2933
+ const initialState = await buildInitialState(repoRoot, config.query, config.provider, { query_type: config.query_type });
3345
2934
  timings.initial_state_ms = Date.now() - initialStateStart;
3346
2935
  messages.push({ role: "user", content: initialState });
3347
- const maxTurns = AGENT_CONFIG.MAX_TURNS;
3348
- const model = config.model || DEFAULT_MODEL;
3349
2936
  const provider = config.provider;
3350
2937
  const errors = [];
3351
2938
  let finishMeta;
@@ -3395,7 +2982,7 @@ async function runWarpGrep(config) {
3395
2982
  const args = c.arguments ?? {};
3396
2983
  allPromises.push(
3397
2984
  toolGrep(provider, args).then(
3398
- ({ output }) => formatAgentToolOutput("grep", args, output, { isError: false }),
2985
+ ({ output }) => formatAgentToolOutput("grep", args, output),
3399
2986
  (err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
3400
2987
  )
3401
2988
  );
@@ -3404,7 +2991,7 @@ async function runWarpGrep(config) {
3404
2991
  const args = c.arguments ?? {};
3405
2992
  allPromises.push(
3406
2993
  toolListDirectory(provider, args).then(
3407
- (p) => formatAgentToolOutput("list_directory", args, p, { isError: false }),
2994
+ (p) => formatAgentToolOutput("list_directory", args, p),
3408
2995
  (err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
3409
2996
  )
3410
2997
  );
@@ -3413,7 +3000,7 @@ async function runWarpGrep(config) {
3413
3000
  const args = c.arguments ?? {};
3414
3001
  allPromises.push(
3415
3002
  toolRead(provider, args).then(
3416
- (p) => formatAgentToolOutput("read", args, p, { isError: false }),
3003
+ (p) => formatAgentToolOutput("read", args, p),
3417
3004
  (err) => formatAgentToolOutput("read", args, String(err), { isError: true })
3418
3005
  )
3419
3006
  );
@@ -3497,14 +3084,13 @@ async function* runWarpGrepStreaming(config) {
3497
3084
  const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
3498
3085
  const timings = { turns: [], timeout_ms: timeoutMs };
3499
3086
  const repoRoot = import_path3.default.resolve(config.repoRoot || process.cwd());
3087
+ const model = config.model || DEFAULT_MODEL;
3500
3088
  const messages = [];
3501
- messages.push({ role: "system", content: getSystemPrompt() });
3089
+ const maxTurns = AGENT_CONFIG.MAX_TURNS;
3502
3090
  const initialStateStart = Date.now();
3503
- const initialState = await buildInitialState(repoRoot, config.query, config.provider);
3091
+ const initialState = await buildInitialState(repoRoot, config.query, config.provider, { query_type: config.query_type });
3504
3092
  timings.initial_state_ms = Date.now() - initialStateStart;
3505
3093
  messages.push({ role: "user", content: initialState });
3506
- const maxTurns = AGENT_CONFIG.MAX_TURNS;
3507
- const model = config.model || DEFAULT_MODEL;
3508
3094
  const provider = config.provider;
3509
3095
  const errors = [];
3510
3096
  let finishMeta;
@@ -3561,7 +3147,7 @@ async function* runWarpGrepStreaming(config) {
3561
3147
  const args = c.arguments ?? {};
3562
3148
  allPromises.push(
3563
3149
  toolGrep(provider, args).then(
3564
- ({ output }) => formatAgentToolOutput("grep", args, output, { isError: false }),
3150
+ ({ output }) => formatAgentToolOutput("grep", args, output),
3565
3151
  (err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
3566
3152
  )
3567
3153
  );
@@ -3570,7 +3156,7 @@ async function* runWarpGrepStreaming(config) {
3570
3156
  const args = c.arguments ?? {};
3571
3157
  allPromises.push(
3572
3158
  toolListDirectory(provider, args).then(
3573
- (p) => formatAgentToolOutput("list_directory", args, p, { isError: false }),
3159
+ (p) => formatAgentToolOutput("list_directory", args, p),
3574
3160
  (err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
3575
3161
  )
3576
3162
  );
@@ -3579,7 +3165,7 @@ async function* runWarpGrepStreaming(config) {
3579
3165
  const args = c.arguments ?? {};
3580
3166
  allPromises.push(
3581
3167
  toolRead(provider, args).then(
3582
- (p) => formatAgentToolOutput("read", args, p, { isError: false }),
3168
+ (p) => formatAgentToolOutput("read", args, p),
3583
3169
  (err) => formatAgentToolOutput("read", args, String(err), { isError: true })
3584
3170
  )
3585
3171
  );
@@ -3757,10 +3343,9 @@ var RemoteCommandsProvider = class {
3757
3343
  const stdout = await this.commands.grep(params.pattern, params.path, params.glob);
3758
3344
  const lines = (stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
3759
3345
  if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {
3760
- return {
3761
- lines: [],
3762
- error: "Query not specific enough - too many results returned. Try a more specific pattern."
3763
- };
3346
+ const truncated = lines.slice(0, AGENT_CONFIG.MAX_OUTPUT_LINES);
3347
+ truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);
3348
+ return { lines: truncated };
3764
3349
  }
3765
3350
  return { lines };
3766
3351
  } catch (error) {
@@ -3790,7 +3375,7 @@ var RemoteCommandsProvider = class {
3790
3375
  const lines = contentLines.map((content, idx) => `${start + idx}|${content}`);
3791
3376
  if (lines.length > AGENT_CONFIG.MAX_READ_LINES) {
3792
3377
  const truncated = lines.slice(0, AGENT_CONFIG.MAX_READ_LINES);
3793
- truncated.push(`... [truncated: showing ${AGENT_CONFIG.MAX_READ_LINES} of ${lines.length} lines]`);
3378
+ truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_READ_LINES} of ${lines.length} lines)`);
3794
3379
  return { lines: truncated };
3795
3380
  }
3796
3381
  return { lines };
@@ -5341,9 +4926,6 @@ function createWarpGrepTool(config) {
5341
4926
  },
5342
4927
  formatResult: (result) => {
5343
4928
  return formatResult(result);
5344
- },
5345
- getSystemPrompt: () => {
5346
- return getSystemPrompt();
5347
4929
  }
5348
4930
  });
5349
4931
  }
@@ -5363,9 +4945,6 @@ function createGitHubSearchTool(config) {
5363
4945
  },
5364
4946
  formatResult: (result) => {
5365
4947
  return formatResult(result);
5366
- },
5367
- getSystemPrompt: () => {
5368
- return getSystemPrompt();
5369
4948
  }
5370
4949
  });
5371
4950
  }
@@ -5538,7 +5117,7 @@ var editFileTool = {
5538
5117
  async function execute(input, config) {
5539
5118
  return executeEditFile(input, config);
5540
5119
  }
5541
- function getSystemPrompt2() {
5120
+ function getSystemPrompt() {
5542
5121
  return EDIT_FILE_SYSTEM_PROMPT;
5543
5122
  }
5544
5123
  function formatResult3(result) {
@@ -5567,7 +5146,7 @@ function createEditFileTool(config = {}) {
5567
5146
  return formatResult3(result);
5568
5147
  },
5569
5148
  getSystemPrompt: () => {
5570
- return getSystemPrompt2();
5149
+ return getSystemPrompt();
5571
5150
  }
5572
5151
  });
5573
5152
  }
@@ -5647,9 +5226,6 @@ function createWarpGrepTool2(config) {
5647
5226
  },
5648
5227
  formatResult: (result) => {
5649
5228
  return formatResult(result);
5650
- },
5651
- getSystemPrompt: () => {
5652
- return getSystemPrompt();
5653
5229
  }
5654
5230
  });
5655
5231
  }
@@ -5666,9 +5242,6 @@ function createGitHubSearchTool2(config) {
5666
5242
  },
5667
5243
  formatResult: (result) => {
5668
5244
  return formatResult(result);
5669
- },
5670
- getSystemPrompt: () => {
5671
- return getSystemPrompt();
5672
5245
  }
5673
5246
  });
5674
5247
  }