@morphllm/morphsdk 0.2.125 → 0.2.127

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 (219) hide show
  1. package/dist/{chunk-DGYWACHC.js → chunk-3ZA7Y66U.js} +2 -2
  2. package/dist/{chunk-5L3TPS6A.js → chunk-6DRIR7AI.js} +5 -4
  3. package/dist/chunk-6DRIR7AI.js.map +1 -0
  4. package/dist/{chunk-G5YJDK5S.js → chunk-ADHGSV2D.js} +2 -2
  5. package/dist/{chunk-5PNMAWLC.js → chunk-DKODF3YG.js} +2 -2
  6. package/dist/{chunk-5PNMAWLC.js.map → chunk-DKODF3YG.js.map} +1 -1
  7. package/dist/{chunk-BQO3WODX.js → chunk-DS7YL4V3.js} +8 -13
  8. package/dist/chunk-DS7YL4V3.js.map +1 -0
  9. package/dist/{chunk-FEQJCZJQ.js → chunk-EGOCFCAH.js} +2 -2
  10. package/dist/{chunk-TFK4UOUE.js → chunk-EL6CCK7C.js} +6 -6
  11. package/dist/{chunk-IB4MEIQG.js → chunk-GDCVK6SP.js} +2 -2
  12. package/dist/{chunk-UGSV5LPO.js → chunk-GVF4Q75N.js} +2 -2
  13. package/dist/{chunk-TS3E6IRI.js → chunk-GWKCMFD6.js} +2 -2
  14. package/dist/{chunk-WZAZFW77.js → chunk-HZK5TEUK.js} +1 -1
  15. package/dist/{chunk-EF7ZYLA2.js → chunk-HZOTLGJH.js} +19 -12
  16. package/dist/chunk-HZOTLGJH.js.map +1 -0
  17. package/dist/{chunk-3MLWXJTJ.js → chunk-K2FXHDX2.js} +15 -10
  18. package/dist/chunk-K2FXHDX2.js.map +1 -0
  19. package/dist/{chunk-FAZO2LNY.js → chunk-K6YSD3DR.js} +2 -2
  20. package/dist/{chunk-ACHEU2V3.js → chunk-LX34ZO3N.js} +2 -2
  21. package/dist/{chunk-OFQRY3RM.js → chunk-LXBIP5FI.js} +18 -23
  22. package/dist/chunk-LXBIP5FI.js.map +1 -0
  23. package/dist/{chunk-F6HNFC2H.js → chunk-MJHAVXFK.js} +2 -2
  24. package/dist/{chunk-PUGSTXLO.js → chunk-NF2QWJDY.js} +6 -7
  25. package/dist/chunk-NF2QWJDY.js.map +1 -0
  26. package/dist/{chunk-6TH3VNCF.js → chunk-NQQS5BZZ.js} +3 -3
  27. package/dist/{chunk-V3HLOZK2.js → chunk-QLBRTLEI.js} +1 -1
  28. package/dist/{chunk-V3HLOZK2.js.map → chunk-QLBRTLEI.js.map} +1 -1
  29. package/dist/{chunk-57PXQ6IS.js → chunk-QOE522DB.js} +15 -15
  30. package/dist/chunk-QRXG5CAZ.js +27 -0
  31. package/dist/chunk-QRXG5CAZ.js.map +1 -0
  32. package/dist/{chunk-7RTJCQWB.js → chunk-QUULFOWB.js} +10 -5
  33. package/dist/chunk-QUULFOWB.js.map +1 -0
  34. package/dist/{chunk-33CP5QCC.js → chunk-R5IFI552.js} +3 -3
  35. package/dist/{chunk-33CP5QCC.js.map → chunk-R5IFI552.js.map} +1 -1
  36. package/dist/{chunk-IRNUW2DB.js → chunk-REJNS3OW.js} +8 -13
  37. package/dist/chunk-REJNS3OW.js.map +1 -0
  38. package/dist/{chunk-2S7ZQFIB.js → chunk-U73OIAJC.js} +2 -2
  39. package/dist/{chunk-OQGX4RZP.js → chunk-UAQ7UWZB.js} +2 -2
  40. package/dist/chunk-VCKJ22DX.js +131 -0
  41. package/dist/chunk-VCKJ22DX.js.map +1 -0
  42. package/dist/{chunk-2MK64KK4.js → chunk-YTUQEDWH.js} +2 -2
  43. package/dist/{chunk-H6KT7IXW.js → chunk-ZVAXTR2V.js} +2 -2
  44. package/dist/{chunk-BGL35LL6.js → chunk-ZYD2SEQK.js} +2 -2
  45. package/dist/{client-JHPwle1Z.d.ts → client-CNYzlN_6.d.ts} +6 -7
  46. package/dist/client.cjs +166 -579
  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 +166 -579
  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 +152 -570
  142. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  143. package/dist/tools/warp_grep/anthropic.d.ts +2 -4
  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 +152 -570
  149. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  150. package/dist/tools/warp_grep/gemini.d.ts +2 -4
  151. package/dist/tools/warp_grep/gemini.js +18 -23
  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 +147 -565
  159. package/dist/tools/warp_grep/index.cjs.map +1 -1
  160. package/dist/tools/warp_grep/index.d.ts +7 -4
  161. package/dist/tools/warp_grep/index.js +14 -20
  162. package/dist/tools/warp_grep/openai.cjs +152 -570
  163. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  164. package/dist/tools/warp_grep/openai.d.ts +2 -4
  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 +151 -563
  176. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  177. package/dist/tools/warp_grep/vercel.d.ts +2 -2
  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-5L3TPS6A.js.map +0 -1
  185. package/dist/chunk-7RTJCQWB.js.map +0 -1
  186. package/dist/chunk-APP75CBN.js +0 -98
  187. package/dist/chunk-APP75CBN.js.map +0 -1
  188. package/dist/chunk-BQO3WODX.js.map +0 -1
  189. package/dist/chunk-EF7ZYLA2.js.map +0 -1
  190. package/dist/chunk-FMLHRJDF.js +0 -207
  191. package/dist/chunk-FMLHRJDF.js.map +0 -1
  192. package/dist/chunk-GHGJAQSJ.js +0 -282
  193. package/dist/chunk-GHGJAQSJ.js.map +0 -1
  194. package/dist/chunk-IRNUW2DB.js.map +0 -1
  195. package/dist/chunk-OFQRY3RM.js.map +0 -1
  196. package/dist/chunk-PUGSTXLO.js.map +0 -1
  197. package/dist/tools/warp_grep/agent/prompt.cjs +0 -232
  198. package/dist/tools/warp_grep/agent/prompt.cjs.map +0 -1
  199. package/dist/tools/warp_grep/agent/prompt.d.ts +0 -4
  200. package/dist/tools/warp_grep/agent/prompt.js +0 -10
  201. package/dist/tools/warp_grep/agent/prompt.js.map +0 -1
  202. /package/dist/{chunk-DGYWACHC.js.map → chunk-3ZA7Y66U.js.map} +0 -0
  203. /package/dist/{chunk-G5YJDK5S.js.map → chunk-ADHGSV2D.js.map} +0 -0
  204. /package/dist/{chunk-FEQJCZJQ.js.map → chunk-EGOCFCAH.js.map} +0 -0
  205. /package/dist/{chunk-TFK4UOUE.js.map → chunk-EL6CCK7C.js.map} +0 -0
  206. /package/dist/{chunk-IB4MEIQG.js.map → chunk-GDCVK6SP.js.map} +0 -0
  207. /package/dist/{chunk-UGSV5LPO.js.map → chunk-GVF4Q75N.js.map} +0 -0
  208. /package/dist/{chunk-TS3E6IRI.js.map → chunk-GWKCMFD6.js.map} +0 -0
  209. /package/dist/{chunk-WZAZFW77.js.map → chunk-HZK5TEUK.js.map} +0 -0
  210. /package/dist/{chunk-FAZO2LNY.js.map → chunk-K6YSD3DR.js.map} +0 -0
  211. /package/dist/{chunk-ACHEU2V3.js.map → chunk-LX34ZO3N.js.map} +0 -0
  212. /package/dist/{chunk-F6HNFC2H.js.map → chunk-MJHAVXFK.js.map} +0 -0
  213. /package/dist/{chunk-6TH3VNCF.js.map → chunk-NQQS5BZZ.js.map} +0 -0
  214. /package/dist/{chunk-57PXQ6IS.js.map → chunk-QOE522DB.js.map} +0 -0
  215. /package/dist/{chunk-2S7ZQFIB.js.map → chunk-U73OIAJC.js.map} +0 -0
  216. /package/dist/{chunk-OQGX4RZP.js.map → chunk-UAQ7UWZB.js.map} +0 -0
  217. /package/dist/{chunk-2MK64KK4.js.map → chunk-YTUQEDWH.js.map} +0 -0
  218. /package/dist/{chunk-H6KT7IXW.js.map → chunk-ZVAXTR2V.js.map} +0 -0
  219. /package/dist/{chunk-BGL35LL6.js.map → chunk-ZYD2SEQK.js.map} +0 -0
@@ -130,7 +130,7 @@ var init_config = __esm({
130
130
  ".*"
131
131
  ];
132
132
  DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || "").split(",").map((s) => s.trim()).filter(Boolean).concat(BUILTIN_EXCLUDES);
133
- DEFAULT_MODEL = "morph-warp-grep-v1";
133
+ DEFAULT_MODEL = "morph-warp-grep-v2";
134
134
  }
135
135
  });
136
136
 
@@ -285,7 +285,8 @@ var local_exports = {};
285
285
  __export(local_exports, {
286
286
  LocalRipgrepProvider: () => LocalRipgrepProvider
287
287
  });
288
- function shouldSkip2(name) {
288
+ function shouldSkip2(name, allowNames) {
289
+ if (allowNames?.has(name)) return false;
289
290
  if (SKIP_NAMES2.has(name)) return true;
290
291
  if (name.startsWith(".")) return true;
291
292
  for (const ext of SKIP_EXTENSIONS2) {
@@ -380,10 +381,14 @@ var init_local = __esm({
380
381
  ".js.map"
381
382
  ]);
382
383
  LocalRipgrepProvider = class {
383
- constructor(repoRoot, excludes = DEFAULT_EXCLUDES) {
384
+ constructor(repoRoot, excludes = DEFAULT_EXCLUDES, options) {
384
385
  this.repoRoot = repoRoot;
385
386
  this.excludes = excludes;
387
+ if (options?.allowNames?.length) {
388
+ this.allowNames = new Set(options.allowNames);
389
+ }
386
390
  }
391
+ allowNames;
387
392
  async grep(params) {
388
393
  let abs;
389
394
  try {
@@ -397,6 +402,7 @@ var init_local = __esm({
397
402
  const stat = await import_promises2.default.stat(abs).catch(() => null);
398
403
  if (!stat) return { lines: [] };
399
404
  const targetArg = abs === import_path4.default.resolve(this.repoRoot) ? "." : toRepoRelative(this.repoRoot, abs);
405
+ const contextLines = params.context_lines !== void 0 ? String(params.context_lines) : "1";
400
406
  const args = [
401
407
  "--no-config",
402
408
  "--no-heading",
@@ -406,9 +412,10 @@ var init_local = __esm({
406
412
  "--trim",
407
413
  "--max-columns=400",
408
414
  "-C",
409
- "1",
415
+ contextLines,
416
+ ...params.case_sensitive === false ? ["--ignore-case"] : [],
410
417
  ...params.glob ? ["--glob", params.glob] : [],
411
- ...this.excludes.flatMap((e) => ["-g", `!${e}`]),
418
+ ...this.excludes.filter((e) => !this.allowNames?.has(e)).flatMap((e) => ["-g", `!${e}`]),
412
419
  params.pattern,
413
420
  targetArg || "."
414
421
  ];
@@ -433,10 +440,9 @@ Details: ${res.stderr}` : ""}`
433
440
  }
434
441
  const lines = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
435
442
  if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {
436
- return {
437
- lines: [],
438
- error: "query not specific enough, tool tried to return too much context and failed"
439
- };
443
+ const truncated = lines.slice(0, AGENT_CONFIG.MAX_OUTPUT_LINES);
444
+ truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);
445
+ return { lines: truncated };
440
446
  }
441
447
  return { lines };
442
448
  }
@@ -510,7 +516,7 @@ Details: ${res.stderr}` : ""}`
510
516
  }
511
517
  if (out.length > AGENT_CONFIG.MAX_READ_LINES) {
512
518
  const truncated = out.slice(0, AGENT_CONFIG.MAX_READ_LINES);
513
- truncated.push(`... [truncated: showing ${AGENT_CONFIG.MAX_READ_LINES} of ${out.length} lines]`);
519
+ truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_READ_LINES} of ${out.length} lines)`);
514
520
  return { lines: truncated };
515
521
  }
516
522
  return { lines: out };
@@ -530,6 +536,7 @@ Details: ${res.stderr}` : ""}`
530
536
  const maxDepth = params.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;
531
537
  const regex = params.pattern ? new RegExp(params.pattern) : null;
532
538
  const repoRoot = this.repoRoot;
539
+ const allowNames = this.allowNames;
533
540
  const results = [];
534
541
  let timedOut = false;
535
542
  const startTime = Date.now();
@@ -547,7 +554,7 @@ Details: ${res.stderr}` : ""}`
547
554
  }
548
555
  for (const entry of entries) {
549
556
  if (timedOut || results.length >= maxResults) break;
550
- if (shouldSkip2(entry.name)) continue;
557
+ if (shouldSkip2(entry.name, allowNames)) continue;
551
558
  if (regex && !regex.test(entry.name)) continue;
552
559
  const full = import_path4.default.join(dir, entry.name);
553
560
  const isDir = entry.isDirectory();
@@ -585,483 +592,130 @@ module.exports = __toCommonJS(client_exports);
585
592
  // tools/warp_grep/agent/runner.ts
586
593
  init_config();
587
594
 
588
- // tools/warp_grep/agent/prompt.ts
589
- var SYSTEM_PROMPT = `You are a code search agent. Your task is to find all relevant code for a given search_string.
590
-
591
- ### workflow
592
- You have exactly 4 turns. The 4th turn MUST be a \`finish\` call. Each turn allows up to 8 parallel tool calls.
593
-
594
- - Turn 1: Map the territory OR dive deep (based on search_string specificity)
595
- - Turn 2-3: Refine based on findings
596
- - Turn 4: MUST call \`finish\` with all relevant code locations
597
- - You MAY call \`finish\` early if confident\u2014but never before at least 1 search turn.
598
- - The user strongly prefers if you can call the finish tool early, but you must be correct
599
-
600
- Remember, if the task feels easy to you, it is strongly desirable to call 'finish' early using fewer turns, but quality over speed
601
-
602
- ### tools
603
- Tool calls use nested XML elements:
604
- \`\`\`xml
605
- <tool_name>
606
- <parameter>value</parameter>
607
- </tool_name>
608
- \`\`\`
609
-
610
- ### \`list_directory\`
611
- Directory tree view. Shows structure of a path, optionally filtered by regex pattern.
612
-
613
- Elements:
614
- - \`<path>\` (required): Directory path to list (use \`.\` for repo root)
615
- - \`<pattern>\` (optional): Regex to filter results
616
-
617
- Examples:
618
- \`\`\`
619
- <list_directory>
620
- <path>src/services</path>
621
- </list_directory>
622
-
623
- <list_directory>
624
- <path>lib/utils</path>
625
- <pattern>.*\\.(ts|js)$</pattern>
626
- </list_directory>
627
- \`\`\`
628
-
629
- ### \`read\`
630
- Read file contents. Supports multiple line ranges.
631
- - Returns numbered lines for easy reference
632
- - ALWAYS include import statements (usually lines 1-20). Better to over-include than miss context.
633
-
634
- Elements:
635
- - \`<path>\` (required): File path to read
636
- - \`<lines>\` (optional): Line ranges like "1-50,75-80,100-120" (omit to read entire file)
637
-
638
- Examples:
639
- \`\`\`
640
- <read>
641
- <path>src/main.py</path>
642
- </read>
643
-
644
- <read>
645
- <path>src/auth.py</path>
646
- <lines>1-20,45-80,150-200</lines>
647
- </read>
648
- \`\`\`
649
-
650
- ### \`grep\`
651
- Search for pattern matches across files. Returns matches with 1 line of context above and below.
652
- - Match lines use \`:\` separator \u2192 \`filepath:linenum:content\`
653
- - Context lines use \`-\` separator \u2192 \`filepath-linenum-content\`
654
-
655
- Elements:
656
- - \`<pattern>\` (required): Search pattern (regex). Use \`(a|b)\` for OR patterns.
657
- - \`<sub_dir>\` (optional): Subdirectory to search in (defaults to \`.\`)
658
- - \`<glob>\` (optional): File pattern filter like \`*.py\` or \`*.{ts,tsx}\`
659
-
660
- Examples:
661
- \`\`\`
662
- <grep>
663
- <pattern>(authenticate|authorize|login)</pattern>
664
- <sub_dir>src/auth/</sub_dir>
665
- </grep>
666
-
667
- <grep>
668
- <pattern>class.*(Service|Controller)</pattern>
669
- <glob>*.{ts,js}</glob>
670
- </grep>
671
-
672
- <grep>
673
- <pattern>(DB_HOST|DATABASE_URL|connection)</pattern>
674
- <glob>*.{py,yaml,env}</glob>
675
- <sub_dir>lib/</sub_dir>
676
- </grep>
677
- \`\`\`
678
-
679
- ### \`finish\`
680
- Submit final answer with all relevant code locations. Uses nested \`<file>\` elements.
681
-
682
- File elements:
683
- - \`<path>\` (required): File path
684
- - \`<lines>\` (optional): Line ranges like "1-50,75-80" (\`*\` for entire file)
685
-
686
- ALWAYS include import statements (usually lines 1-20). Better to over-include than miss context.
687
-
688
- Examples:
689
- \`\`\`
690
- <finish>
691
- <file>
692
- <path>src/auth.py</path>
693
- <lines>1-15,25-50,75-80</lines>
694
- </file>
695
- <file>
696
- <path>src/models/user.py</path>
697
- <lines>*</lines>
698
- </file>
699
- </finish>
700
- \`\`\`
701
- </tools>
702
-
703
- <strategy>
704
- **Before your first tool call, classify the search_string:**
705
-
706
- | Search_string Type | Round 1 Strategy | Early Finish? |
707
- |------------|------------------|---------------|
708
- | **Specific** (function name, error string, unique identifier) | 8 parallel greps on likely paths | Often by round 2 |
709
- | **Conceptual** (how does X work, where is Y handled) | list_directory + 2-3 broad greps | Rarely early |
710
- | **Exploratory** (find all tests, list API endpoints) | list_directory at multiple depths | Usually needs 3 rounds |
711
-
712
- **Parallel call patterns:**
713
- - **Shotgun grep**: Same pattern, 8 different directories\u2014fast coverage
714
- - **Variant grep**: 8 pattern variations (synonyms, naming conventions)\u2014catches inconsistent codebases
715
- - **Funnel**: 1 list_directory + 7 greps\u2014orient and search simultaneously
716
- - **Deep read**: 8 reads on files you already identified\u2014gather full context fast
717
-
718
- **Tool call expectations:**
719
- - 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.
720
- - 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.
721
- - 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.
722
- - 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.
723
- </strategy>
724
-
725
- <output_format>
726
- EVERY response MUST follow this exact format:
727
-
728
- 1. First, wrap your reasoning in \`<think>...</think>\` tags containing:
729
- - Search_string classification (specific/conceptual/exploratory)
730
- - Confidence estimate (can I finish in 1-2 rounds?)
731
- - This round's parallel strategy
732
- - What signals would let me finish early?
733
-
734
- 2. Then, output up to 8 tool calls using nested XML elements.
735
-
736
- Example:
737
- \`\`\`
738
- <think>
739
- This is a specific search_string about authentication. I'll grep for auth-related patterns.
740
- 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
741
- Strategy: Shotgun grep across likely directories.
742
- </think>
743
- <grep>
744
- <pattern>(authenticate|login|session)</pattern>
745
- <sub_dir>src/auth/</sub_dir>
746
- </grep>
747
- <grep>
748
- <pattern>(middleware|interceptor)</pattern>
749
- <glob>*.{ts,js}</glob>
750
- </grep>
751
- <list_directory>
752
- <path>src/auth</path>
753
- </list_directory>
754
- \`\`\`
755
-
756
- Finishing example:
757
- \`\`\`
758
- <think>
759
- I think I have a rough idea, but this is my last turn so I must call the finish tool regardless.
760
- </think>
761
- <finish>
762
- <file>
763
- <path>src/auth/login.py</path>
764
- <lines>1-50</lines>
765
- </file>
766
- <file>
767
- <path>src/middleware/session.py</path>
768
- <lines>10-80</lines>
769
- </file>
770
- </finish>
771
- \`\`\`
772
-
773
- No commentary outside \`<think>\`. No explanations after tool calls.
774
- </output_format>
775
-
776
- use as all 8 tool calls to be optimal
777
-
778
- <finishing_requirements>
779
- When calling \`finish\`:
780
- - Include the import section (typically lines 1-20) of each file
781
- - Include all function/class definitions that are relevant
782
- - Include any type definitions, interfaces, or constants used
783
- - Better to over-include than leave the user missing context
784
- - If unsure about boundaries, include more rather than less
785
- </finishing_requirements>`;
786
- function getSystemPrompt() {
787
- return SYSTEM_PROMPT;
788
- }
789
-
790
595
  // tools/warp_grep/agent/parser.ts
791
- var VALID_COMMANDS = ["list_directory", "grep", "read", "finish"];
596
+ var VALID_COMMANDS = ["list_directory", "ripgrep", "read", "finish"];
792
597
  function isValidCommand(name) {
793
598
  return VALID_COMMANDS.includes(name);
794
599
  }
795
- function getXmlElementText(xml, tagName) {
796
- const regex = new RegExp(`<${tagName}>([\\s\\S]*?)</${tagName}>`, "i");
797
- const match = xml.match(regex);
798
- return match ? match[1].trim() : null;
799
- }
800
- function parseNestedXmlTools(text) {
600
+ function parseQwen3ToolCalls(text) {
801
601
  const tools = [];
802
- const toolRegex = /<([a-z_][a-z0-9_]*)>([\s\S]*?)<\/\1>/gi;
602
+ const toolCallRegex = /<tool_call>\s*<function=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/function>\s*<\/tool_call>/gi;
803
603
  let match;
804
- while ((match = toolRegex.exec(text)) !== null) {
805
- const rawToolName = match[1].toLowerCase();
806
- const content = match[2];
807
- if (!isValidCommand(rawToolName)) continue;
808
- const toolName = rawToolName;
809
- if (toolName === "list_directory") {
810
- const path5 = getXmlElementText(content, "path");
811
- const pattern = getXmlElementText(content, "pattern");
812
- if (path5) {
813
- tools.push({ name: "list_directory", arguments: { path: path5, pattern } });
604
+ while ((match = toolCallRegex.exec(text)) !== null) {
605
+ const funcName = match[1].toLowerCase();
606
+ const body = match[2];
607
+ if (!isValidCommand(funcName)) continue;
608
+ const params = {};
609
+ const paramRegex = /<parameter=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/parameter>/gi;
610
+ let paramMatch;
611
+ while ((paramMatch = paramRegex.exec(body)) !== null) {
612
+ params[paramMatch[1].toLowerCase()] = paramMatch[2].trim();
613
+ }
614
+ if (funcName === "ripgrep") {
615
+ const pattern = params.pattern;
616
+ if (!pattern) continue;
617
+ const args = {
618
+ pattern,
619
+ path: params.path || ".",
620
+ ...params.glob && { glob: params.glob },
621
+ ...params.context_lines && { context_lines: parseInt(params.context_lines, 10) },
622
+ ...params.case_sensitive && { case_sensitive: params.case_sensitive === "true" }
623
+ };
624
+ tools.push({ name: "grep", arguments: args });
625
+ } else if (funcName === "list_directory") {
626
+ const command = params.command;
627
+ const directPath = params.path;
628
+ let dirPath = directPath || ".";
629
+ if (!directPath && command) {
630
+ const tokens = command.trim().split(/\s+/);
631
+ const pathTokens = tokens.slice(1).filter((t) => !t.startsWith("-") && !t.startsWith("|") && !t.startsWith("\\("));
632
+ if (pathTokens.length > 0) {
633
+ dirPath = pathTokens[0];
634
+ }
814
635
  }
815
- } else if (toolName === "grep") {
816
- const pattern = getXmlElementText(content, "pattern");
817
- const subDir = getXmlElementText(content, "sub_dir");
818
- const glob = getXmlElementText(content, "glob");
819
- if (pattern) {
820
- tools.push({
821
- name: "grep",
822
- arguments: {
823
- pattern,
824
- path: subDir || ".",
825
- ...glob && { glob }
636
+ tools.push({ name: "list_directory", arguments: { path: dirPath, pattern: params.pattern || null } });
637
+ } else if (funcName === "read") {
638
+ const filePath = params.path;
639
+ if (!filePath) continue;
640
+ const args = { path: filePath };
641
+ const linesStr = params.lines;
642
+ if (linesStr) {
643
+ const ranges = [];
644
+ for (const rangeStr of linesStr.split(",")) {
645
+ const trimmed = rangeStr.trim();
646
+ if (!trimmed) continue;
647
+ const [s, e] = trimmed.split("-").map((v) => parseInt(v.trim(), 10));
648
+ if (Number.isFinite(s) && Number.isFinite(e)) {
649
+ ranges.push([s, e]);
650
+ } else if (Number.isFinite(s)) {
651
+ ranges.push([s, s]);
826
652
  }
827
- });
653
+ }
654
+ if (ranges.length === 1) {
655
+ args.start = ranges[0][0];
656
+ args.end = ranges[0][1];
657
+ } else if (ranges.length > 1) {
658
+ args.lines = ranges;
659
+ }
660
+ }
661
+ tools.push({ name: "read", arguments: args });
662
+ } else if (funcName === "finish") {
663
+ if (params.result && !params.files) {
664
+ tools.push({ name: "finish", arguments: { files: [], textResult: params.result } });
665
+ continue;
666
+ }
667
+ const filesStr = params.files;
668
+ if (!filesStr) {
669
+ tools.push({ name: "finish", arguments: { files: [], textResult: "No relevant code found." } });
670
+ continue;
828
671
  }
829
- } else if (toolName === "read") {
830
- const path5 = getXmlElementText(content, "path");
831
- const linesStr = getXmlElementText(content, "lines");
832
- if (path5) {
833
- const args = { path: path5 };
834
- if (linesStr) {
672
+ const files = [];
673
+ for (const line of filesStr.split("\n")) {
674
+ const trimmed = line.trim();
675
+ if (!trimmed) continue;
676
+ const colonIdx = trimmed.indexOf(":");
677
+ if (colonIdx === -1) {
678
+ files.push({ path: trimmed, lines: "*" });
679
+ } else {
680
+ const filePath = trimmed.slice(0, colonIdx);
681
+ const rangesPart = trimmed.slice(colonIdx + 1);
835
682
  const ranges = [];
836
- for (const rangeStr of linesStr.split(",")) {
837
- const trimmed = rangeStr.trim();
838
- if (!trimmed) continue;
839
- const [s, e] = trimmed.split("-").map((v) => parseInt(v.trim(), 10));
683
+ for (const rangeStr of rangesPart.split(",")) {
684
+ const rt = rangeStr.trim();
685
+ if (!rt || rt === "*") {
686
+ files.push({ path: filePath, lines: "*" });
687
+ break;
688
+ }
689
+ const [s, e] = rt.split("-").map((v) => parseInt(v.trim(), 10));
840
690
  if (Number.isFinite(s) && Number.isFinite(e)) {
841
691
  ranges.push([s, e]);
842
692
  } else if (Number.isFinite(s)) {
843
693
  ranges.push([s, s]);
844
694
  }
845
695
  }
846
- if (ranges.length === 1) {
847
- args.start = ranges[0][0];
848
- args.end = ranges[0][1];
849
- } else if (ranges.length > 1) {
850
- args.lines = ranges;
851
- }
852
- }
853
- tools.push({ name: "read", arguments: args });
854
- }
855
- } else if (toolName === "finish") {
856
- const fileRegex = /<file>([\s\S]*?)<\/file>/gi;
857
- const files = [];
858
- let fileMatch;
859
- while ((fileMatch = fileRegex.exec(content)) !== null) {
860
- const fileContent = fileMatch[1];
861
- const filePath = getXmlElementText(fileContent, "path");
862
- const linesStr = getXmlElementText(fileContent, "lines");
863
- if (filePath) {
864
- if (!linesStr || linesStr.trim() === "*") {
696
+ if (ranges.length > 0) {
697
+ files.push({ path: filePath, lines: ranges });
698
+ } else if (!files.some((f) => f.path === filePath)) {
865
699
  files.push({ path: filePath, lines: "*" });
866
- } else {
867
- const ranges = [];
868
- for (const rangeStr of linesStr.split(",")) {
869
- const [s, e] = rangeStr.split("-").map((v) => parseInt(v.trim(), 10));
870
- if (Number.isFinite(s) && Number.isFinite(e)) {
871
- ranges.push([s, e]);
872
- }
873
- }
874
- if (ranges.length > 0) {
875
- files.push({ path: filePath, lines: ranges });
876
- } else {
877
- files.push({ path: filePath, lines: "*" });
878
- }
879
700
  }
880
701
  }
881
702
  }
882
703
  if (files.length > 0) {
883
704
  tools.push({ name: "finish", arguments: { files } });
884
705
  } else {
885
- const raw = content.replace(/<[^>]*>/g, "").trim();
886
- const textResult = !raw || raw === "*" ? "No relevant code found." : raw;
887
- tools.push({ name: "finish", arguments: { files: [], textResult } });
706
+ tools.push({ name: "finish", arguments: { files: [], textResult: filesStr } });
888
707
  }
889
708
  }
890
709
  }
891
- if (tools.length === 0) {
892
- const fnFinishMatch = text.match(/<function=finish>([\s\S]*?)<\/function>/i);
893
- if (fnFinishMatch) {
894
- const inner = fnFinishMatch[1];
895
- const paramMatch = inner.match(/<parameter=result>([\s\S]*?)<\/parameter>/i);
896
- const raw = (paramMatch ? paramMatch[1] : inner).trim();
897
- const textResult = !raw || raw === "*" ? "No relevant code found." : raw;
898
- tools.push({ name: "finish", arguments: { files: [], textResult } });
899
- }
900
- }
901
710
  return tools;
902
711
  }
903
- function preprocessText(text) {
904
- const processed = text.replace(/<think>[\s\S]*?<\/think>/gi, "").replace(/<\/?tool_call>/gi, "");
905
- const nestedTools = parseNestedXmlTools(processed);
906
- const toolCallLines = [];
907
- const allLines = processed.split(/\r?\n/).map((l) => l.trim());
908
- for (const line of allLines) {
909
- if (!line) continue;
910
- if (line.startsWith("<")) continue;
911
- const firstWord = line.split(/\s/)[0];
912
- if (VALID_COMMANDS.includes(firstWord)) {
913
- if (!toolCallLines.includes(line)) {
914
- toolCallLines.push(line);
915
- }
916
- }
917
- }
918
- return { lines: toolCallLines, nestedTools };
919
- }
920
712
  var LLMResponseParser = class {
921
- finishSpecSplitRe = /,(?=[^,\s]+:)/;
922
713
  parse(text) {
923
714
  if (typeof text !== "string") {
924
715
  throw new TypeError("Command text must be a string.");
925
716
  }
926
- const { lines, nestedTools } = preprocessText(text);
927
- const commands = [...nestedTools];
928
- let finishAccumulator = null;
929
- lines.forEach((line) => {
930
- if (!line || line.startsWith("#")) return;
931
- const parts = this.splitLine(line);
932
- if (parts.length === 0) return;
933
- const cmd = parts[0];
934
- switch (cmd) {
935
- case "list_directory":
936
- this.handleListDirectory(parts, line, commands);
937
- break;
938
- case "grep":
939
- this.handleGrep(parts, line, commands);
940
- break;
941
- case "read":
942
- this.handleRead(parts, line, commands);
943
- break;
944
- case "finish":
945
- finishAccumulator = this.handleFinish(parts, line, commands, finishAccumulator);
946
- break;
947
- default:
948
- break;
949
- }
950
- });
951
- if (finishAccumulator) {
952
- const map = finishAccumulator;
953
- const entries = [...map.entries()];
954
- const filesPayload = entries.map(([path5, ranges]) => ({
955
- path: path5,
956
- lines: [...ranges].sort((a, b) => a[0] - b[0])
957
- }));
958
- commands.push({ name: "finish", arguments: { files: filesPayload } });
959
- }
960
- return commands;
961
- }
962
- splitLine(line) {
963
- const parts = [];
964
- let current = "";
965
- let inSingle = false;
966
- for (let i = 0; i < line.length; i++) {
967
- const ch = line[i];
968
- if (ch === "'" && line[i - 1] !== "\\") {
969
- inSingle = !inSingle;
970
- current += ch;
971
- } else if (!inSingle && /\s/.test(ch)) {
972
- if (current) {
973
- parts.push(current);
974
- current = "";
975
- }
976
- } else {
977
- current += ch;
978
- }
979
- }
980
- if (current) parts.push(current);
981
- return parts;
982
- }
983
- /** Helper to create a _skip tool call with an error message */
984
- skip(message) {
985
- return { name: "_skip", arguments: { message } };
986
- }
987
- handleListDirectory(parts, rawLine, commands) {
988
- if (parts.length < 2) {
989
- commands.push(this.skip(
990
- `[SKIPPED] Your command "${rawLine}" is missing a path. Correct format: list_directory <path> [pattern]. Example: list_directory src/`
991
- ));
992
- return;
993
- }
994
- const path5 = parts[1];
995
- const pattern = parts[2]?.replace(/^"|"$/g, "") ?? null;
996
- commands.push({ name: "list_directory", arguments: { path: path5, pattern } });
997
- }
998
- handleGrep(parts, rawLine, commands) {
999
- if (parts.length < 3) {
1000
- commands.push(this.skip(
1001
- `[SKIPPED] Your command "${rawLine}" is missing arguments. Correct format: grep '<pattern>' <path>. Example: grep 'TODO' src/`
1002
- ));
1003
- return;
1004
- }
1005
- let pat = parts[1];
1006
- if (pat.startsWith("'") && pat.endsWith("'")) {
1007
- pat = pat.slice(1, -1);
1008
- }
1009
- if (!pat) {
1010
- commands.push(this.skip(
1011
- `[SKIPPED] Your command "${rawLine}" has an empty pattern. Provide a non-empty search pattern. Example: grep 'function' src/`
1012
- ));
1013
- return;
1014
- }
1015
- commands.push({ name: "grep", arguments: { pattern: pat, path: parts[2] } });
1016
- }
1017
- handleRead(parts, rawLine, commands) {
1018
- if (parts.length < 2) {
1019
- commands.push(this.skip(
1020
- `[SKIPPED] Your command "${rawLine}" is missing a path. Correct format: read <path> or read <path>:<start>-<end>. Example: read src/index.ts:1-50`
1021
- ));
1022
- return;
1023
- }
1024
- const spec = parts[1];
1025
- const rangeIdx = spec.indexOf(":");
1026
- if (rangeIdx === -1) {
1027
- commands.push({ name: "read", arguments: { path: spec } });
1028
- return;
1029
- }
1030
- const filePath = spec.slice(0, rangeIdx);
1031
- const range = spec.slice(rangeIdx + 1);
1032
- const [s, e] = range.split("-").map((v) => parseInt(v, 10));
1033
- if (!Number.isFinite(s) || !Number.isFinite(e)) {
1034
- commands.push({ name: "read", arguments: { path: filePath } });
1035
- return;
1036
- }
1037
- commands.push({ name: "read", arguments: { path: filePath, start: s, end: e } });
1038
- }
1039
- handleFinish(parts, rawLine, commands, acc) {
1040
- const map = acc ?? /* @__PURE__ */ new Map();
1041
- const args = parts.slice(1);
1042
- for (const token of args) {
1043
- const [filePath, rangesText] = token.split(":", 2);
1044
- if (!filePath || !rangesText) {
1045
- commands.push(this.skip(
1046
- `[SKIPPED] Invalid finish token "${token}". Correct format: finish <path>:<start>-<end>. Example: finish src/index.ts:1-50`
1047
- ));
1048
- continue;
1049
- }
1050
- const rangeSpecs = rangesText.split(",").filter(Boolean);
1051
- for (const spec of rangeSpecs) {
1052
- const [s, e] = spec.split("-").map((v) => parseInt(v, 10));
1053
- if (!Number.isFinite(s) || !Number.isFinite(e) || e < s) {
1054
- commands.push(this.skip(
1055
- `[SKIPPED] Invalid range "${spec}" in "${token}". Ranges must be <start>-<end> where start <= end. Example: 1-50`
1056
- ));
1057
- continue;
1058
- }
1059
- const arr = map.get(filePath) ?? [];
1060
- arr.push([s, e]);
1061
- map.set(filePath, arr);
1062
- }
1063
- }
1064
- return map;
717
+ const withoutThink = text.replace(/<think>[\s\S]*?<\/think>/gi, "");
718
+ return parseQwen3ToolCalls(withoutThink);
1065
719
  }
1066
720
  };
1067
721
 
@@ -1131,14 +785,12 @@ async function toolListDirectory(provider, args) {
1131
785
  }
1132
786
  const { entries: list } = await getListRecursive(initialDepth);
1133
787
  if (!list.length) return "empty";
1134
- if (list.length >= maxResults) {
1135
- return "query not specific enough, tool called tried to return too much context and failed";
1136
- }
1137
- return list.map((e) => {
788
+ const tree = list.map((e) => {
1138
789
  const indent = " ".repeat(e.depth);
1139
790
  const name = e.type === "dir" ? `${e.name}/` : e.name;
1140
791
  return `${indent}${name}`;
1141
792
  }).join("\n");
793
+ return tree;
1142
794
  }
1143
795
 
1144
796
  // tools/warp_grep/agent/tools/finish.ts
@@ -1201,90 +853,19 @@ function mergeRanges(ranges) {
1201
853
 
1202
854
  // tools/warp_grep/agent/formatter.ts
1203
855
  var ToolOutputFormatter = class {
1204
- format(toolName, args, output, options = {}) {
856
+ format(toolName, _args, output, options = {}) {
1205
857
  const name = (toolName ?? "").trim();
1206
858
  if (!name) {
1207
859
  return "";
1208
860
  }
1209
861
  const payload = output?.toString?.()?.trim?.() ?? "";
1210
862
  const isError = Boolean(options.isError);
1211
- const safeArgs = args ?? {};
1212
863
  if (!payload && !isError) {
1213
864
  return "";
1214
865
  }
1215
- switch (name) {
1216
- case "read":
1217
- return this.formatRead(safeArgs, payload, isError);
1218
- case "list_directory":
1219
- return this.formatListDirectory(safeArgs, payload, isError);
1220
- case "grep":
1221
- return this.formatGrep(safeArgs, payload, isError);
1222
- default:
1223
- return payload ? `<tool_output>
1224
- ${payload}
1225
- </tool_output>` : "";
1226
- }
1227
- }
1228
- formatRead(args, payload, isError) {
1229
- if (isError) {
1230
- return payload;
1231
- }
1232
- const path5 = this.asString(args.path) || "...";
1233
- const start = args.start;
1234
- const end = args.end;
1235
- const linesArray = args.lines;
1236
- const attributes = [`path="${path5}"`];
1237
- if (linesArray && linesArray.length > 0) {
1238
- const rangeStr = linesArray.map(([s, e]) => `${s}-${e}`).join(",");
1239
- attributes.push(`lines="${rangeStr}"`);
1240
- } else if (start !== void 0 && end !== void 0) {
1241
- attributes.push(`lines="${start}-${end}"`);
1242
- }
1243
- return `<read ${attributes.join(" ")}>
1244
- ${payload}
1245
- </read>`;
1246
- }
1247
- formatListDirectory(args, payload, isError) {
1248
- const path5 = this.asString(args.path) || ".";
1249
- const pattern = this.asString(args.pattern);
1250
- const attributes = [`path="${path5}"`];
1251
- if (pattern) {
1252
- attributes.push(`pattern="${pattern}"`);
1253
- }
1254
- if (isError) {
1255
- attributes.push('status="error"');
1256
- }
1257
- return `<list_directory ${attributes.join(" ")}>
1258
- ${payload}
1259
- </list_directory>`;
1260
- }
1261
- formatGrep(args, payload, isError) {
1262
- const pattern = this.asString(args.pattern);
1263
- const subDir = this.asString(args.path);
1264
- const glob = this.asString(args.glob);
1265
- const attributes = [];
1266
- if (pattern !== void 0) {
1267
- attributes.push(`pattern="${pattern}"`);
1268
- }
1269
- if (subDir !== void 0) {
1270
- attributes.push(`sub_dir="${subDir}"`);
1271
- }
1272
- if (glob !== void 0) {
1273
- attributes.push(`glob="${glob}"`);
1274
- }
1275
- if (isError) {
1276
- attributes.push('status="error"');
1277
- }
1278
- const attrText = attributes.length ? ` ${attributes.join(" ")}` : "";
1279
- return `<grep${attrText}>
866
+ return `<tool_response>
1280
867
  ${payload}
1281
- </grep>`;
1282
- }
1283
- asString(value) {
1284
- if (value === null || value === void 0) {
1285
- return void 0;
1286
- }
1287
- return String(value);
868
+ </tool_response>`;
1288
869
  }
1289
870
  };
1290
871
  var sharedFormatter = new ToolOutputFormatter();
@@ -1313,12 +894,15 @@ function calculateContextBudget(messages) {
1313
894
  const maxK = Math.round(maxChars / 1e3);
1314
895
  return `<context_budget>${percent}% (${usedK}K/${maxK}K chars)</context_budget>`;
1315
896
  }
1316
- async function buildInitialState(repoRoot, query, provider) {
897
+ async function buildInitialState(repoRoot, query, provider, options) {
898
+ const budget = calculateContextBudget([]);
899
+ const turnTag = `Turn 0/${AGENT_CONFIG.MAX_TURNS}`;
900
+ const treeDepth = options?.query_type === "node_modules" ? 1 : 2;
1317
901
  try {
1318
902
  const entries = await provider.listDirectory({
1319
903
  path: ".",
1320
904
  maxResults: AGENT_CONFIG.MAX_OUTPUT_LINES,
1321
- maxDepth: 2
905
+ maxDepth: treeDepth
1322
906
  });
1323
907
  const treeLines = entries.map((e) => {
1324
908
  const indent = " ".repeat(e.depth);
@@ -1334,7 +918,9 @@ ${treeOutput}
1334
918
 
1335
919
  <search_string>
1336
920
  ${query}
1337
- </search_string>`;
921
+ </search_string>
922
+ ${budget}
923
+ ${turnTag}`;
1338
924
  } catch {
1339
925
  const repoName = import_path.default.basename(repoRoot);
1340
926
  return `<repo_structure>
@@ -1343,7 +929,9 @@ ${repoName}/
1343
929
 
1344
930
  <search_string>
1345
931
  ${query}
1346
- </search_string>`;
932
+ </search_string>
933
+ ${budget}
934
+ ${turnTag}`;
1347
935
  }
1348
936
  }
1349
937
  function enforceContextLimit(messages, maxChars = AGENT_CONFIG.MAX_CONTEXT_CHARS) {
@@ -1379,7 +967,7 @@ var import_openai = __toESM(require("openai"), 1);
1379
967
  // package.json
1380
968
  var package_default = {
1381
969
  name: "@morphllm/morphsdk",
1382
- version: "0.2.125",
970
+ version: "0.2.127",
1383
971
  description: "TypeScript SDK and CLI for Morph Fast Apply integration",
1384
972
  type: "module",
1385
973
  main: "./dist/index.cjs",
@@ -1521,7 +1109,7 @@ var package_default = {
1521
1109
  "!dist/**/*.test.*"
1522
1110
  ],
1523
1111
  scripts: {
1524
- 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",
1112
+ 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",
1525
1113
  prepare: "npm run build",
1526
1114
  typecheck: "tsc --noEmit",
1527
1115
  lint: "eslint .",
@@ -1658,14 +1246,13 @@ async function runWarpGrep(config) {
1658
1246
  const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
1659
1247
  const timings = { turns: [], timeout_ms: timeoutMs };
1660
1248
  const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
1249
+ const model = config.model || DEFAULT_MODEL;
1661
1250
  const messages = [];
1662
- messages.push({ role: "system", content: getSystemPrompt() });
1251
+ const maxTurns = AGENT_CONFIG.MAX_TURNS;
1663
1252
  const initialStateStart = Date.now();
1664
- const initialState = await buildInitialState(repoRoot, config.query, config.provider);
1253
+ const initialState = await buildInitialState(repoRoot, config.query, config.provider, { query_type: config.query_type });
1665
1254
  timings.initial_state_ms = Date.now() - initialStateStart;
1666
1255
  messages.push({ role: "user", content: initialState });
1667
- const maxTurns = AGENT_CONFIG.MAX_TURNS;
1668
- const model = config.model || DEFAULT_MODEL;
1669
1256
  const provider = config.provider;
1670
1257
  const errors = [];
1671
1258
  let finishMeta;
@@ -1715,7 +1302,7 @@ async function runWarpGrep(config) {
1715
1302
  const args = c.arguments ?? {};
1716
1303
  allPromises.push(
1717
1304
  toolGrep(provider, args).then(
1718
- ({ output }) => formatAgentToolOutput("grep", args, output, { isError: false }),
1305
+ ({ output }) => formatAgentToolOutput("grep", args, output),
1719
1306
  (err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
1720
1307
  )
1721
1308
  );
@@ -1724,7 +1311,7 @@ async function runWarpGrep(config) {
1724
1311
  const args = c.arguments ?? {};
1725
1312
  allPromises.push(
1726
1313
  toolListDirectory(provider, args).then(
1727
- (p) => formatAgentToolOutput("list_directory", args, p, { isError: false }),
1314
+ (p) => formatAgentToolOutput("list_directory", args, p),
1728
1315
  (err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
1729
1316
  )
1730
1317
  );
@@ -1733,7 +1320,7 @@ async function runWarpGrep(config) {
1733
1320
  const args = c.arguments ?? {};
1734
1321
  allPromises.push(
1735
1322
  toolRead(provider, args).then(
1736
- (p) => formatAgentToolOutput("read", args, p, { isError: false }),
1323
+ (p) => formatAgentToolOutput("read", args, p),
1737
1324
  (err) => formatAgentToolOutput("read", args, String(err), { isError: true })
1738
1325
  )
1739
1326
  );
@@ -1817,14 +1404,13 @@ async function* runWarpGrepStreaming(config) {
1817
1404
  const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
1818
1405
  const timings = { turns: [], timeout_ms: timeoutMs };
1819
1406
  const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
1407
+ const model = config.model || DEFAULT_MODEL;
1820
1408
  const messages = [];
1821
- messages.push({ role: "system", content: getSystemPrompt() });
1409
+ const maxTurns = AGENT_CONFIG.MAX_TURNS;
1822
1410
  const initialStateStart = Date.now();
1823
- const initialState = await buildInitialState(repoRoot, config.query, config.provider);
1411
+ const initialState = await buildInitialState(repoRoot, config.query, config.provider, { query_type: config.query_type });
1824
1412
  timings.initial_state_ms = Date.now() - initialStateStart;
1825
1413
  messages.push({ role: "user", content: initialState });
1826
- const maxTurns = AGENT_CONFIG.MAX_TURNS;
1827
- const model = config.model || DEFAULT_MODEL;
1828
1414
  const provider = config.provider;
1829
1415
  const errors = [];
1830
1416
  let finishMeta;
@@ -1881,7 +1467,7 @@ async function* runWarpGrepStreaming(config) {
1881
1467
  const args = c.arguments ?? {};
1882
1468
  allPromises.push(
1883
1469
  toolGrep(provider, args).then(
1884
- ({ output }) => formatAgentToolOutput("grep", args, output, { isError: false }),
1470
+ ({ output }) => formatAgentToolOutput("grep", args, output),
1885
1471
  (err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
1886
1472
  )
1887
1473
  );
@@ -1890,7 +1476,7 @@ async function* runWarpGrepStreaming(config) {
1890
1476
  const args = c.arguments ?? {};
1891
1477
  allPromises.push(
1892
1478
  toolListDirectory(provider, args).then(
1893
- (p) => formatAgentToolOutput("list_directory", args, p, { isError: false }),
1479
+ (p) => formatAgentToolOutput("list_directory", args, p),
1894
1480
  (err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
1895
1481
  )
1896
1482
  );
@@ -1899,7 +1485,7 @@ async function* runWarpGrepStreaming(config) {
1899
1485
  const args = c.arguments ?? {};
1900
1486
  allPromises.push(
1901
1487
  toolRead(provider, args).then(
1902
- (p) => formatAgentToolOutput("read", args, p, { isError: false }),
1488
+ (p) => formatAgentToolOutput("read", args, p),
1903
1489
  (err) => formatAgentToolOutput("read", args, String(err), { isError: true })
1904
1490
  )
1905
1491
  );
@@ -2077,10 +1663,9 @@ var RemoteCommandsProvider = class {
2077
1663
  const stdout = await this.commands.grep(params.pattern, params.path, params.glob);
2078
1664
  const lines = (stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
2079
1665
  if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {
2080
- return {
2081
- lines: [],
2082
- error: "Query not specific enough - too many results returned. Try a more specific pattern."
2083
- };
1666
+ const truncated = lines.slice(0, AGENT_CONFIG.MAX_OUTPUT_LINES);
1667
+ truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);
1668
+ return { lines: truncated };
2084
1669
  }
2085
1670
  return { lines };
2086
1671
  } catch (error) {
@@ -2110,7 +1695,7 @@ var RemoteCommandsProvider = class {
2110
1695
  const lines = contentLines.map((content, idx) => `${start + idx}|${content}`);
2111
1696
  if (lines.length > AGENT_CONFIG.MAX_READ_LINES) {
2112
1697
  const truncated = lines.slice(0, AGENT_CONFIG.MAX_READ_LINES);
2113
- truncated.push(`... [truncated: showing ${AGENT_CONFIG.MAX_READ_LINES} of ${lines.length} lines]`);
1698
+ truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_READ_LINES} of ${lines.length} lines)`);
2114
1699
  return { lines: truncated };
2115
1700
  }
2116
1701
  return { lines };