@morphllm/morphsdk 0.2.124 → 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.
- package/dist/{chunk-M6VWLSL4.js → chunk-37ZZ24IX.js} +3 -12
- package/dist/chunk-37ZZ24IX.js.map +1 -0
- package/dist/{chunk-BFJAFWMR.js → chunk-3NLCSADX.js} +2 -2
- package/dist/{chunk-KQRX2K2W.js → chunk-5CIUBER5.js} +2 -2
- package/dist/{chunk-STPK3AAF.js → chunk-6722FXFI.js} +2 -2
- package/dist/{chunk-3ZO2UAYM.js → chunk-6Y2LHEJJ.js} +2 -2
- package/dist/{chunk-27BLOUAR.js → chunk-76PPJZWV.js} +3 -12
- package/dist/chunk-76PPJZWV.js.map +1 -0
- package/dist/{chunk-OTOVGCG6.js → chunk-AXYGFPEJ.js} +3 -3
- package/dist/chunk-AXYGFPEJ.js.map +1 -0
- package/dist/{chunk-S4RLT56A.js → chunk-C26M3TWM.js} +6 -6
- package/dist/{chunk-F7VTQZH7.js → chunk-CPZKCBED.js} +2 -2
- package/dist/{chunk-SGRNIWJD.js → chunk-CYVV5X5K.js} +3 -3
- package/dist/{chunk-SGRNIWJD.js.map → chunk-CYVV5X5K.js.map} +1 -1
- package/dist/{chunk-5PNMAWLC.js → chunk-DKODF3YG.js} +2 -2
- package/dist/{chunk-5PNMAWLC.js.map → chunk-DKODF3YG.js.map} +1 -1
- package/dist/{chunk-W4PYHVIJ.js → chunk-EB656RG6.js} +2 -2
- package/dist/{chunk-A2OVRHEW.js → chunk-FAH4YGRN.js} +3 -3
- package/dist/{chunk-DUJ32DHI.js → chunk-GISRJI5P.js} +2 -2
- package/dist/{chunk-EF7ZYLA2.js → chunk-HZOTLGJH.js} +19 -12
- package/dist/chunk-HZOTLGJH.js.map +1 -0
- package/dist/{chunk-VKQLHW6G.js → chunk-IYZX6EYC.js} +2 -2
- package/dist/{chunk-3MLWXJTJ.js → chunk-K2FXHDX2.js} +15 -10
- package/dist/chunk-K2FXHDX2.js.map +1 -0
- package/dist/{chunk-Z7U7ZRMP.js → chunk-K6GLBQBV.js} +2 -2
- package/dist/{chunk-ZVVCJGNL.js → chunk-KJVFYRXY.js} +15 -15
- package/dist/{chunk-WG5E7MMA.js → chunk-KUABSLVR.js} +2 -2
- package/dist/{chunk-PUGSTXLO.js → chunk-NF2QWJDY.js} +6 -7
- package/dist/chunk-NF2QWJDY.js.map +1 -0
- package/dist/{chunk-ICLIJKYL.js → chunk-QK5RNORE.js} +3 -3
- package/dist/chunk-QK5RNORE.js.map +1 -0
- package/dist/{chunk-V3HLOZK2.js → chunk-QLBRTLEI.js} +1 -1
- package/dist/{chunk-V3HLOZK2.js.map → chunk-QLBRTLEI.js.map} +1 -1
- package/dist/chunk-QRXG5CAZ.js +27 -0
- package/dist/chunk-QRXG5CAZ.js.map +1 -0
- package/dist/{chunk-KAI2DLL5.js → chunk-R74NP2D4.js} +2 -2
- package/dist/{chunk-N6YX3M4I.js → chunk-TREVNTLA.js} +2 -2
- package/dist/{chunk-EIJAUTHH.js → chunk-ULZOJQ2W.js} +2 -2
- package/dist/chunk-VCKJ22DX.js +131 -0
- package/dist/chunk-VCKJ22DX.js.map +1 -0
- package/dist/{chunk-ZD5PEXNS.js → chunk-VYJUGQUR.js} +1 -1
- package/dist/{chunk-HHRHUUGN.js → chunk-W7WUZMKZ.js} +18 -23
- package/dist/chunk-W7WUZMKZ.js.map +1 -0
- package/dist/{chunk-34UAUD5I.js → chunk-YHZRHPJI.js} +2 -2
- package/dist/{client-JHPwle1Z.d.ts → client-s3_iDem0.d.ts} +0 -4
- package/dist/client.cjs +146 -573
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +1 -2
- package/dist/client.js +27 -28
- package/dist/edge.cjs +2 -2
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.js +4 -4
- package/dist/{finish-pPJfB0uO.d.ts → finish-DBKuo8yj.d.ts} +2 -0
- package/dist/index.cjs +146 -573
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +29 -30
- package/dist/modelrouter/core.cjs +2 -2
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.js +3 -3
- package/dist/modelrouter/index.cjs +2 -2
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.js +3 -3
- package/dist/tools/browser/anthropic.cjs +2 -2
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +5 -5
- package/dist/tools/browser/core.cjs +2 -2
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.js +4 -4
- package/dist/tools/browser/index.cjs +2 -2
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.js +7 -7
- package/dist/tools/browser/openai.cjs +2 -2
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.js +5 -5
- package/dist/tools/browser/profiles/core.cjs +2 -2
- package/dist/tools/browser/profiles/core.cjs.map +1 -1
- package/dist/tools/browser/profiles/core.js +3 -3
- package/dist/tools/browser/profiles/index.cjs +2 -2
- package/dist/tools/browser/profiles/index.cjs.map +1 -1
- package/dist/tools/browser/profiles/index.js +3 -3
- package/dist/tools/browser/vercel.cjs +2 -2
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.js +5 -5
- package/dist/tools/codebase_search/anthropic.cjs +2 -2
- package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
- package/dist/tools/codebase_search/anthropic.js +4 -4
- package/dist/tools/codebase_search/core.cjs +2 -2
- package/dist/tools/codebase_search/core.cjs.map +1 -1
- package/dist/tools/codebase_search/core.js +3 -3
- package/dist/tools/codebase_search/index.cjs +2 -2
- package/dist/tools/codebase_search/index.cjs.map +1 -1
- package/dist/tools/codebase_search/index.js +6 -6
- package/dist/tools/codebase_search/openai.cjs +2 -2
- package/dist/tools/codebase_search/openai.cjs.map +1 -1
- package/dist/tools/codebase_search/openai.js +4 -4
- package/dist/tools/codebase_search/vercel.cjs +2 -2
- package/dist/tools/codebase_search/vercel.cjs.map +1 -1
- package/dist/tools/codebase_search/vercel.js +4 -4
- package/dist/tools/fastapply/anthropic.cjs +2 -2
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +4 -4
- package/dist/tools/fastapply/apply.cjs +2 -2
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +2 -2
- package/dist/tools/fastapply/core.cjs +2 -2
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.js +3 -3
- package/dist/tools/fastapply/index.cjs +2 -2
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.js +6 -6
- package/dist/tools/fastapply/openai.cjs +2 -2
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +4 -4
- package/dist/tools/fastapply/vercel.cjs +2 -2
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +4 -4
- package/dist/tools/index.cjs +2 -2
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +6 -6
- package/dist/tools/utils/resilience.cjs +2 -2
- package/dist/tools/utils/resilience.cjs.map +1 -1
- package/dist/tools/utils/resilience.js +2 -2
- package/dist/tools/warp_grep/agent/config.cjs +1 -1
- package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/config.d.ts +1 -1
- package/dist/tools/warp_grep/agent/config.js +1 -1
- package/dist/tools/warp_grep/agent/formatter.cjs +3 -74
- package/dist/tools/warp_grep/agent/formatter.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/formatter.d.ts +1 -5
- package/dist/tools/warp_grep/agent/formatter.js +1 -1
- package/dist/tools/warp_grep/agent/parser.cjs +91 -242
- package/dist/tools/warp_grep/agent/parser.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/parser.d.ts +0 -8
- package/dist/tools/warp_grep/agent/parser.js +1 -1
- package/dist/tools/warp_grep/agent/runner.cjs +122 -543
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +6 -7
- package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/types.d.ts +2 -0
- package/dist/tools/warp_grep/anthropic.cjs +145 -568
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +0 -3
- package/dist/tools/warp_grep/anthropic.js +11 -15
- package/dist/tools/warp_grep/client.cjs +143 -558
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.js +9 -10
- package/dist/tools/warp_grep/gemini.cjs +145 -568
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.d.ts +0 -3
- package/dist/tools/warp_grep/gemini.js +10 -20
- package/dist/tools/warp_grep/gemini.js.map +1 -1
- package/dist/tools/warp_grep/harness.cjs +124 -540
- package/dist/tools/warp_grep/harness.cjs.map +1 -1
- package/dist/tools/warp_grep/harness.d.ts +4 -5
- package/dist/tools/warp_grep/harness.js +5 -11
- package/dist/tools/warp_grep/harness.js.map +1 -1
- package/dist/tools/warp_grep/index.cjs +145 -564
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +1 -2
- package/dist/tools/warp_grep/index.js +14 -20
- package/dist/tools/warp_grep/openai.cjs +145 -568
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +0 -3
- package/dist/tools/warp_grep/openai.js +11 -15
- package/dist/tools/warp_grep/providers/local.cjs +17 -10
- package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/local.d.ts +6 -1
- package/dist/tools/warp_grep/providers/local.js +2 -2
- package/dist/tools/warp_grep/providers/remote.cjs +4 -5
- package/dist/tools/warp_grep/providers/remote.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/remote.js +2 -2
- package/dist/tools/warp_grep/providers/types.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/types.d.ts +2 -0
- package/dist/tools/warp_grep/vercel.cjs +145 -562
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +0 -1
- package/dist/tools/warp_grep/vercel.js +11 -15
- package/dist/version.cjs +2 -2
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-27BLOUAR.js.map +0 -1
- package/dist/chunk-3MLWXJTJ.js.map +0 -1
- package/dist/chunk-APP75CBN.js +0 -98
- package/dist/chunk-APP75CBN.js.map +0 -1
- package/dist/chunk-EF7ZYLA2.js.map +0 -1
- package/dist/chunk-FMLHRJDF.js +0 -207
- package/dist/chunk-FMLHRJDF.js.map +0 -1
- package/dist/chunk-GHGJAQSJ.js +0 -282
- package/dist/chunk-GHGJAQSJ.js.map +0 -1
- package/dist/chunk-HHRHUUGN.js.map +0 -1
- package/dist/chunk-ICLIJKYL.js.map +0 -1
- package/dist/chunk-M6VWLSL4.js.map +0 -1
- package/dist/chunk-OTOVGCG6.js.map +0 -1
- package/dist/chunk-PUGSTXLO.js.map +0 -1
- package/dist/tools/warp_grep/agent/prompt.cjs +0 -232
- package/dist/tools/warp_grep/agent/prompt.cjs.map +0 -1
- package/dist/tools/warp_grep/agent/prompt.d.ts +0 -4
- package/dist/tools/warp_grep/agent/prompt.js +0 -10
- package/dist/tools/warp_grep/agent/prompt.js.map +0 -1
- /package/dist/{chunk-BFJAFWMR.js.map → chunk-3NLCSADX.js.map} +0 -0
- /package/dist/{chunk-KQRX2K2W.js.map → chunk-5CIUBER5.js.map} +0 -0
- /package/dist/{chunk-STPK3AAF.js.map → chunk-6722FXFI.js.map} +0 -0
- /package/dist/{chunk-3ZO2UAYM.js.map → chunk-6Y2LHEJJ.js.map} +0 -0
- /package/dist/{chunk-S4RLT56A.js.map → chunk-C26M3TWM.js.map} +0 -0
- /package/dist/{chunk-F7VTQZH7.js.map → chunk-CPZKCBED.js.map} +0 -0
- /package/dist/{chunk-W4PYHVIJ.js.map → chunk-EB656RG6.js.map} +0 -0
- /package/dist/{chunk-A2OVRHEW.js.map → chunk-FAH4YGRN.js.map} +0 -0
- /package/dist/{chunk-DUJ32DHI.js.map → chunk-GISRJI5P.js.map} +0 -0
- /package/dist/{chunk-VKQLHW6G.js.map → chunk-IYZX6EYC.js.map} +0 -0
- /package/dist/{chunk-Z7U7ZRMP.js.map → chunk-K6GLBQBV.js.map} +0 -0
- /package/dist/{chunk-ZVVCJGNL.js.map → chunk-KJVFYRXY.js.map} +0 -0
- /package/dist/{chunk-WG5E7MMA.js.map → chunk-KUABSLVR.js.map} +0 -0
- /package/dist/{chunk-KAI2DLL5.js.map → chunk-R74NP2D4.js.map} +0 -0
- /package/dist/{chunk-N6YX3M4I.js.map → chunk-TREVNTLA.js.map} +0 -0
- /package/dist/{chunk-EIJAUTHH.js.map → chunk-ULZOJQ2W.js.map} +0 -0
- /package/dist/{chunk-ZD5PEXNS.js.map → chunk-VYJUGQUR.js.map} +0 -0
- /package/dist/{chunk-34UAUD5I.js.map → chunk-YHZRHPJI.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-
|
|
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
|
-
|
|
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
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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(`...
|
|
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();
|
|
@@ -578,7 +585,6 @@ __export(vercel_exports, {
|
|
|
578
585
|
default: () => vercel_default,
|
|
579
586
|
execute: () => execute,
|
|
580
587
|
formatResult: () => formatResult,
|
|
581
|
-
getSystemPrompt: () => getSystemPrompt,
|
|
582
588
|
warpGrepJsonSchema: () => warpGrepJsonSchema
|
|
583
589
|
});
|
|
584
590
|
module.exports = __toCommonJS(vercel_exports);
|
|
@@ -588,483 +594,130 @@ var import_zod = require("zod");
|
|
|
588
594
|
// tools/warp_grep/agent/runner.ts
|
|
589
595
|
init_config();
|
|
590
596
|
|
|
591
|
-
// tools/warp_grep/agent/prompt.ts
|
|
592
|
-
var SYSTEM_PROMPT = `You are a code search agent. Your task is to find all relevant code for a given search_string.
|
|
593
|
-
|
|
594
|
-
### workflow
|
|
595
|
-
You have exactly 4 turns. The 4th turn MUST be a \`finish\` call. Each turn allows up to 8 parallel tool calls.
|
|
596
|
-
|
|
597
|
-
- Turn 1: Map the territory OR dive deep (based on search_string specificity)
|
|
598
|
-
- Turn 2-3: Refine based on findings
|
|
599
|
-
- Turn 4: MUST call \`finish\` with all relevant code locations
|
|
600
|
-
- You MAY call \`finish\` early if confident\u2014but never before at least 1 search turn.
|
|
601
|
-
- The user strongly prefers if you can call the finish tool early, but you must be correct
|
|
602
|
-
|
|
603
|
-
Remember, if the task feels easy to you, it is strongly desirable to call 'finish' early using fewer turns, but quality over speed
|
|
604
|
-
|
|
605
|
-
### tools
|
|
606
|
-
Tool calls use nested XML elements:
|
|
607
|
-
\`\`\`xml
|
|
608
|
-
<tool_name>
|
|
609
|
-
<parameter>value</parameter>
|
|
610
|
-
</tool_name>
|
|
611
|
-
\`\`\`
|
|
612
|
-
|
|
613
|
-
### \`list_directory\`
|
|
614
|
-
Directory tree view. Shows structure of a path, optionally filtered by regex pattern.
|
|
615
|
-
|
|
616
|
-
Elements:
|
|
617
|
-
- \`<path>\` (required): Directory path to list (use \`.\` for repo root)
|
|
618
|
-
- \`<pattern>\` (optional): Regex to filter results
|
|
619
|
-
|
|
620
|
-
Examples:
|
|
621
|
-
\`\`\`
|
|
622
|
-
<list_directory>
|
|
623
|
-
<path>src/services</path>
|
|
624
|
-
</list_directory>
|
|
625
|
-
|
|
626
|
-
<list_directory>
|
|
627
|
-
<path>lib/utils</path>
|
|
628
|
-
<pattern>.*\\.(ts|js)$</pattern>
|
|
629
|
-
</list_directory>
|
|
630
|
-
\`\`\`
|
|
631
|
-
|
|
632
|
-
### \`read\`
|
|
633
|
-
Read file contents. Supports multiple line ranges.
|
|
634
|
-
- Returns numbered lines for easy reference
|
|
635
|
-
- ALWAYS include import statements (usually lines 1-20). Better to over-include than miss context.
|
|
636
|
-
|
|
637
|
-
Elements:
|
|
638
|
-
- \`<path>\` (required): File path to read
|
|
639
|
-
- \`<lines>\` (optional): Line ranges like "1-50,75-80,100-120" (omit to read entire file)
|
|
640
|
-
|
|
641
|
-
Examples:
|
|
642
|
-
\`\`\`
|
|
643
|
-
<read>
|
|
644
|
-
<path>src/main.py</path>
|
|
645
|
-
</read>
|
|
646
|
-
|
|
647
|
-
<read>
|
|
648
|
-
<path>src/auth.py</path>
|
|
649
|
-
<lines>1-20,45-80,150-200</lines>
|
|
650
|
-
</read>
|
|
651
|
-
\`\`\`
|
|
652
|
-
|
|
653
|
-
### \`grep\`
|
|
654
|
-
Search for pattern matches across files. Returns matches with 1 line of context above and below.
|
|
655
|
-
- Match lines use \`:\` separator \u2192 \`filepath:linenum:content\`
|
|
656
|
-
- Context lines use \`-\` separator \u2192 \`filepath-linenum-content\`
|
|
657
|
-
|
|
658
|
-
Elements:
|
|
659
|
-
- \`<pattern>\` (required): Search pattern (regex). Use \`(a|b)\` for OR patterns.
|
|
660
|
-
- \`<sub_dir>\` (optional): Subdirectory to search in (defaults to \`.\`)
|
|
661
|
-
- \`<glob>\` (optional): File pattern filter like \`*.py\` or \`*.{ts,tsx}\`
|
|
662
|
-
|
|
663
|
-
Examples:
|
|
664
|
-
\`\`\`
|
|
665
|
-
<grep>
|
|
666
|
-
<pattern>(authenticate|authorize|login)</pattern>
|
|
667
|
-
<sub_dir>src/auth/</sub_dir>
|
|
668
|
-
</grep>
|
|
669
|
-
|
|
670
|
-
<grep>
|
|
671
|
-
<pattern>class.*(Service|Controller)</pattern>
|
|
672
|
-
<glob>*.{ts,js}</glob>
|
|
673
|
-
</grep>
|
|
674
|
-
|
|
675
|
-
<grep>
|
|
676
|
-
<pattern>(DB_HOST|DATABASE_URL|connection)</pattern>
|
|
677
|
-
<glob>*.{py,yaml,env}</glob>
|
|
678
|
-
<sub_dir>lib/</sub_dir>
|
|
679
|
-
</grep>
|
|
680
|
-
\`\`\`
|
|
681
|
-
|
|
682
|
-
### \`finish\`
|
|
683
|
-
Submit final answer with all relevant code locations. Uses nested \`<file>\` elements.
|
|
684
|
-
|
|
685
|
-
File elements:
|
|
686
|
-
- \`<path>\` (required): File path
|
|
687
|
-
- \`<lines>\` (optional): Line ranges like "1-50,75-80" (\`*\` for entire file)
|
|
688
|
-
|
|
689
|
-
ALWAYS include import statements (usually lines 1-20). Better to over-include than miss context.
|
|
690
|
-
|
|
691
|
-
Examples:
|
|
692
|
-
\`\`\`
|
|
693
|
-
<finish>
|
|
694
|
-
<file>
|
|
695
|
-
<path>src/auth.py</path>
|
|
696
|
-
<lines>1-15,25-50,75-80</lines>
|
|
697
|
-
</file>
|
|
698
|
-
<file>
|
|
699
|
-
<path>src/models/user.py</path>
|
|
700
|
-
<lines>*</lines>
|
|
701
|
-
</file>
|
|
702
|
-
</finish>
|
|
703
|
-
\`\`\`
|
|
704
|
-
</tools>
|
|
705
|
-
|
|
706
|
-
<strategy>
|
|
707
|
-
**Before your first tool call, classify the search_string:**
|
|
708
|
-
|
|
709
|
-
| Search_string Type | Round 1 Strategy | Early Finish? |
|
|
710
|
-
|------------|------------------|---------------|
|
|
711
|
-
| **Specific** (function name, error string, unique identifier) | 8 parallel greps on likely paths | Often by round 2 |
|
|
712
|
-
| **Conceptual** (how does X work, where is Y handled) | list_directory + 2-3 broad greps | Rarely early |
|
|
713
|
-
| **Exploratory** (find all tests, list API endpoints) | list_directory at multiple depths | Usually needs 3 rounds |
|
|
714
|
-
|
|
715
|
-
**Parallel call patterns:**
|
|
716
|
-
- **Shotgun grep**: Same pattern, 8 different directories\u2014fast coverage
|
|
717
|
-
- **Variant grep**: 8 pattern variations (synonyms, naming conventions)\u2014catches inconsistent codebases
|
|
718
|
-
- **Funnel**: 1 list_directory + 7 greps\u2014orient and search simultaneously
|
|
719
|
-
- **Deep read**: 8 reads on files you already identified\u2014gather full context fast
|
|
720
|
-
|
|
721
|
-
**Tool call expectations:**
|
|
722
|
-
- 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.
|
|
723
|
-
- 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.
|
|
724
|
-
- 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.
|
|
725
|
-
- 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.
|
|
726
|
-
</strategy>
|
|
727
|
-
|
|
728
|
-
<output_format>
|
|
729
|
-
EVERY response MUST follow this exact format:
|
|
730
|
-
|
|
731
|
-
1. First, wrap your reasoning in \`<think>...</think>\` tags containing:
|
|
732
|
-
- Search_string classification (specific/conceptual/exploratory)
|
|
733
|
-
- Confidence estimate (can I finish in 1-2 rounds?)
|
|
734
|
-
- This round's parallel strategy
|
|
735
|
-
- What signals would let me finish early?
|
|
736
|
-
|
|
737
|
-
2. Then, output up to 8 tool calls using nested XML elements.
|
|
738
|
-
|
|
739
|
-
Example:
|
|
740
|
-
\`\`\`
|
|
741
|
-
<think>
|
|
742
|
-
This is a specific search_string about authentication. I'll grep for auth-related patterns.
|
|
743
|
-
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
|
|
744
|
-
Strategy: Shotgun grep across likely directories.
|
|
745
|
-
</think>
|
|
746
|
-
<grep>
|
|
747
|
-
<pattern>(authenticate|login|session)</pattern>
|
|
748
|
-
<sub_dir>src/auth/</sub_dir>
|
|
749
|
-
</grep>
|
|
750
|
-
<grep>
|
|
751
|
-
<pattern>(middleware|interceptor)</pattern>
|
|
752
|
-
<glob>*.{ts,js}</glob>
|
|
753
|
-
</grep>
|
|
754
|
-
<list_directory>
|
|
755
|
-
<path>src/auth</path>
|
|
756
|
-
</list_directory>
|
|
757
|
-
\`\`\`
|
|
758
|
-
|
|
759
|
-
Finishing example:
|
|
760
|
-
\`\`\`
|
|
761
|
-
<think>
|
|
762
|
-
I think I have a rough idea, but this is my last turn so I must call the finish tool regardless.
|
|
763
|
-
</think>
|
|
764
|
-
<finish>
|
|
765
|
-
<file>
|
|
766
|
-
<path>src/auth/login.py</path>
|
|
767
|
-
<lines>1-50</lines>
|
|
768
|
-
</file>
|
|
769
|
-
<file>
|
|
770
|
-
<path>src/middleware/session.py</path>
|
|
771
|
-
<lines>10-80</lines>
|
|
772
|
-
</file>
|
|
773
|
-
</finish>
|
|
774
|
-
\`\`\`
|
|
775
|
-
|
|
776
|
-
No commentary outside \`<think>\`. No explanations after tool calls.
|
|
777
|
-
</output_format>
|
|
778
|
-
|
|
779
|
-
use as all 8 tool calls to be optimal
|
|
780
|
-
|
|
781
|
-
<finishing_requirements>
|
|
782
|
-
When calling \`finish\`:
|
|
783
|
-
- Include the import section (typically lines 1-20) of each file
|
|
784
|
-
- Include all function/class definitions that are relevant
|
|
785
|
-
- Include any type definitions, interfaces, or constants used
|
|
786
|
-
- Better to over-include than leave the user missing context
|
|
787
|
-
- If unsure about boundaries, include more rather than less
|
|
788
|
-
</finishing_requirements>`;
|
|
789
|
-
function getSystemPrompt() {
|
|
790
|
-
return SYSTEM_PROMPT;
|
|
791
|
-
}
|
|
792
|
-
|
|
793
597
|
// tools/warp_grep/agent/parser.ts
|
|
794
|
-
var VALID_COMMANDS = ["list_directory", "
|
|
598
|
+
var VALID_COMMANDS = ["list_directory", "ripgrep", "read", "finish"];
|
|
795
599
|
function isValidCommand(name) {
|
|
796
600
|
return VALID_COMMANDS.includes(name);
|
|
797
601
|
}
|
|
798
|
-
function
|
|
799
|
-
const regex = new RegExp(`<${tagName}>([\\s\\S]*?)</${tagName}>`, "i");
|
|
800
|
-
const match = xml.match(regex);
|
|
801
|
-
return match ? match[1].trim() : null;
|
|
802
|
-
}
|
|
803
|
-
function parseNestedXmlTools(text) {
|
|
602
|
+
function parseQwen3ToolCalls(text) {
|
|
804
603
|
const tools = [];
|
|
805
|
-
const
|
|
604
|
+
const toolCallRegex = /<tool_call>\s*<function=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/function>\s*<\/tool_call>/gi;
|
|
806
605
|
let match;
|
|
807
|
-
while ((match =
|
|
808
|
-
const
|
|
809
|
-
const
|
|
810
|
-
if (!isValidCommand(
|
|
811
|
-
const
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
606
|
+
while ((match = toolCallRegex.exec(text)) !== null) {
|
|
607
|
+
const funcName = match[1].toLowerCase();
|
|
608
|
+
const body = match[2];
|
|
609
|
+
if (!isValidCommand(funcName)) continue;
|
|
610
|
+
const params = {};
|
|
611
|
+
const paramRegex = /<parameter=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/parameter>/gi;
|
|
612
|
+
let paramMatch;
|
|
613
|
+
while ((paramMatch = paramRegex.exec(body)) !== null) {
|
|
614
|
+
params[paramMatch[1].toLowerCase()] = paramMatch[2].trim();
|
|
615
|
+
}
|
|
616
|
+
if (funcName === "ripgrep") {
|
|
617
|
+
const pattern = params.pattern;
|
|
618
|
+
if (!pattern) continue;
|
|
619
|
+
const args = {
|
|
620
|
+
pattern,
|
|
621
|
+
path: params.path || ".",
|
|
622
|
+
...params.glob && { glob: params.glob },
|
|
623
|
+
...params.context_lines && { context_lines: parseInt(params.context_lines, 10) },
|
|
624
|
+
...params.case_sensitive && { case_sensitive: params.case_sensitive === "true" }
|
|
625
|
+
};
|
|
626
|
+
tools.push({ name: "grep", arguments: args });
|
|
627
|
+
} else if (funcName === "list_directory") {
|
|
628
|
+
const command = params.command;
|
|
629
|
+
const directPath = params.path;
|
|
630
|
+
let dirPath = directPath || ".";
|
|
631
|
+
if (!directPath && command) {
|
|
632
|
+
const tokens = command.trim().split(/\s+/);
|
|
633
|
+
const pathTokens = tokens.slice(1).filter((t) => !t.startsWith("-") && !t.startsWith("|") && !t.startsWith("\\("));
|
|
634
|
+
if (pathTokens.length > 0) {
|
|
635
|
+
dirPath = pathTokens[0];
|
|
636
|
+
}
|
|
817
637
|
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
const
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
638
|
+
tools.push({ name: "list_directory", arguments: { path: dirPath, pattern: params.pattern || null } });
|
|
639
|
+
} else if (funcName === "read") {
|
|
640
|
+
const filePath = params.path;
|
|
641
|
+
if (!filePath) continue;
|
|
642
|
+
const args = { path: filePath };
|
|
643
|
+
const linesStr = params.lines;
|
|
644
|
+
if (linesStr) {
|
|
645
|
+
const ranges = [];
|
|
646
|
+
for (const rangeStr of linesStr.split(",")) {
|
|
647
|
+
const trimmed = rangeStr.trim();
|
|
648
|
+
if (!trimmed) continue;
|
|
649
|
+
const [s, e] = trimmed.split("-").map((v) => parseInt(v.trim(), 10));
|
|
650
|
+
if (Number.isFinite(s) && Number.isFinite(e)) {
|
|
651
|
+
ranges.push([s, e]);
|
|
652
|
+
} else if (Number.isFinite(s)) {
|
|
653
|
+
ranges.push([s, s]);
|
|
829
654
|
}
|
|
830
|
-
}
|
|
655
|
+
}
|
|
656
|
+
if (ranges.length === 1) {
|
|
657
|
+
args.start = ranges[0][0];
|
|
658
|
+
args.end = ranges[0][1];
|
|
659
|
+
} else if (ranges.length > 1) {
|
|
660
|
+
args.lines = ranges;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
tools.push({ name: "read", arguments: args });
|
|
664
|
+
} else if (funcName === "finish") {
|
|
665
|
+
if (params.result && !params.files) {
|
|
666
|
+
tools.push({ name: "finish", arguments: { files: [], textResult: params.result } });
|
|
667
|
+
continue;
|
|
831
668
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
669
|
+
const filesStr = params.files;
|
|
670
|
+
if (!filesStr) {
|
|
671
|
+
tools.push({ name: "finish", arguments: { files: [], textResult: "No relevant code found." } });
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
const files = [];
|
|
675
|
+
for (const line of filesStr.split("\n")) {
|
|
676
|
+
const trimmed = line.trim();
|
|
677
|
+
if (!trimmed) continue;
|
|
678
|
+
const colonIdx = trimmed.indexOf(":");
|
|
679
|
+
if (colonIdx === -1) {
|
|
680
|
+
files.push({ path: trimmed, lines: "*" });
|
|
681
|
+
} else {
|
|
682
|
+
const filePath = trimmed.slice(0, colonIdx);
|
|
683
|
+
const rangesPart = trimmed.slice(colonIdx + 1);
|
|
838
684
|
const ranges = [];
|
|
839
|
-
for (const rangeStr of
|
|
840
|
-
const
|
|
841
|
-
if (!
|
|
842
|
-
|
|
685
|
+
for (const rangeStr of rangesPart.split(",")) {
|
|
686
|
+
const rt = rangeStr.trim();
|
|
687
|
+
if (!rt || rt === "*") {
|
|
688
|
+
files.push({ path: filePath, lines: "*" });
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
const [s, e] = rt.split("-").map((v) => parseInt(v.trim(), 10));
|
|
843
692
|
if (Number.isFinite(s) && Number.isFinite(e)) {
|
|
844
693
|
ranges.push([s, e]);
|
|
845
694
|
} else if (Number.isFinite(s)) {
|
|
846
695
|
ranges.push([s, s]);
|
|
847
696
|
}
|
|
848
697
|
}
|
|
849
|
-
if (ranges.length
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
} else if (ranges.length > 1) {
|
|
853
|
-
args.lines = ranges;
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
tools.push({ name: "read", arguments: args });
|
|
857
|
-
}
|
|
858
|
-
} else if (toolName === "finish") {
|
|
859
|
-
const fileRegex = /<file>([\s\S]*?)<\/file>/gi;
|
|
860
|
-
const files = [];
|
|
861
|
-
let fileMatch;
|
|
862
|
-
while ((fileMatch = fileRegex.exec(content)) !== null) {
|
|
863
|
-
const fileContent = fileMatch[1];
|
|
864
|
-
const filePath = getXmlElementText(fileContent, "path");
|
|
865
|
-
const linesStr = getXmlElementText(fileContent, "lines");
|
|
866
|
-
if (filePath) {
|
|
867
|
-
if (!linesStr || linesStr.trim() === "*") {
|
|
698
|
+
if (ranges.length > 0) {
|
|
699
|
+
files.push({ path: filePath, lines: ranges });
|
|
700
|
+
} else if (!files.some((f) => f.path === filePath)) {
|
|
868
701
|
files.push({ path: filePath, lines: "*" });
|
|
869
|
-
} else {
|
|
870
|
-
const ranges = [];
|
|
871
|
-
for (const rangeStr of linesStr.split(",")) {
|
|
872
|
-
const [s, e] = rangeStr.split("-").map((v) => parseInt(v.trim(), 10));
|
|
873
|
-
if (Number.isFinite(s) && Number.isFinite(e)) {
|
|
874
|
-
ranges.push([s, e]);
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
if (ranges.length > 0) {
|
|
878
|
-
files.push({ path: filePath, lines: ranges });
|
|
879
|
-
} else {
|
|
880
|
-
files.push({ path: filePath, lines: "*" });
|
|
881
|
-
}
|
|
882
702
|
}
|
|
883
703
|
}
|
|
884
704
|
}
|
|
885
705
|
if (files.length > 0) {
|
|
886
706
|
tools.push({ name: "finish", arguments: { files } });
|
|
887
707
|
} else {
|
|
888
|
-
|
|
889
|
-
const textResult = !raw || raw === "*" ? "No relevant code found." : raw;
|
|
890
|
-
tools.push({ name: "finish", arguments: { files: [], textResult } });
|
|
708
|
+
tools.push({ name: "finish", arguments: { files: [], textResult: filesStr } });
|
|
891
709
|
}
|
|
892
710
|
}
|
|
893
711
|
}
|
|
894
|
-
if (tools.length === 0) {
|
|
895
|
-
const fnFinishMatch = text.match(/<function=finish>([\s\S]*?)<\/function>/i);
|
|
896
|
-
if (fnFinishMatch) {
|
|
897
|
-
const inner = fnFinishMatch[1];
|
|
898
|
-
const paramMatch = inner.match(/<parameter=result>([\s\S]*?)<\/parameter>/i);
|
|
899
|
-
const raw = (paramMatch ? paramMatch[1] : inner).trim();
|
|
900
|
-
const textResult = !raw || raw === "*" ? "No relevant code found." : raw;
|
|
901
|
-
tools.push({ name: "finish", arguments: { files: [], textResult } });
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
712
|
return tools;
|
|
905
713
|
}
|
|
906
|
-
function preprocessText(text) {
|
|
907
|
-
const processed = text.replace(/<think>[\s\S]*?<\/think>/gi, "").replace(/<\/?tool_call>/gi, "");
|
|
908
|
-
const nestedTools = parseNestedXmlTools(processed);
|
|
909
|
-
const toolCallLines = [];
|
|
910
|
-
const allLines = processed.split(/\r?\n/).map((l) => l.trim());
|
|
911
|
-
for (const line of allLines) {
|
|
912
|
-
if (!line) continue;
|
|
913
|
-
if (line.startsWith("<")) continue;
|
|
914
|
-
const firstWord = line.split(/\s/)[0];
|
|
915
|
-
if (VALID_COMMANDS.includes(firstWord)) {
|
|
916
|
-
if (!toolCallLines.includes(line)) {
|
|
917
|
-
toolCallLines.push(line);
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
return { lines: toolCallLines, nestedTools };
|
|
922
|
-
}
|
|
923
714
|
var LLMResponseParser = class {
|
|
924
|
-
finishSpecSplitRe = /,(?=[^,\s]+:)/;
|
|
925
715
|
parse(text) {
|
|
926
716
|
if (typeof text !== "string") {
|
|
927
717
|
throw new TypeError("Command text must be a string.");
|
|
928
718
|
}
|
|
929
|
-
const
|
|
930
|
-
|
|
931
|
-
let finishAccumulator = null;
|
|
932
|
-
lines.forEach((line) => {
|
|
933
|
-
if (!line || line.startsWith("#")) return;
|
|
934
|
-
const parts = this.splitLine(line);
|
|
935
|
-
if (parts.length === 0) return;
|
|
936
|
-
const cmd = parts[0];
|
|
937
|
-
switch (cmd) {
|
|
938
|
-
case "list_directory":
|
|
939
|
-
this.handleListDirectory(parts, line, commands);
|
|
940
|
-
break;
|
|
941
|
-
case "grep":
|
|
942
|
-
this.handleGrep(parts, line, commands);
|
|
943
|
-
break;
|
|
944
|
-
case "read":
|
|
945
|
-
this.handleRead(parts, line, commands);
|
|
946
|
-
break;
|
|
947
|
-
case "finish":
|
|
948
|
-
finishAccumulator = this.handleFinish(parts, line, commands, finishAccumulator);
|
|
949
|
-
break;
|
|
950
|
-
default:
|
|
951
|
-
break;
|
|
952
|
-
}
|
|
953
|
-
});
|
|
954
|
-
if (finishAccumulator) {
|
|
955
|
-
const map = finishAccumulator;
|
|
956
|
-
const entries = [...map.entries()];
|
|
957
|
-
const filesPayload = entries.map(([path5, ranges]) => ({
|
|
958
|
-
path: path5,
|
|
959
|
-
lines: [...ranges].sort((a, b) => a[0] - b[0])
|
|
960
|
-
}));
|
|
961
|
-
commands.push({ name: "finish", arguments: { files: filesPayload } });
|
|
962
|
-
}
|
|
963
|
-
return commands;
|
|
964
|
-
}
|
|
965
|
-
splitLine(line) {
|
|
966
|
-
const parts = [];
|
|
967
|
-
let current = "";
|
|
968
|
-
let inSingle = false;
|
|
969
|
-
for (let i = 0; i < line.length; i++) {
|
|
970
|
-
const ch = line[i];
|
|
971
|
-
if (ch === "'" && line[i - 1] !== "\\") {
|
|
972
|
-
inSingle = !inSingle;
|
|
973
|
-
current += ch;
|
|
974
|
-
} else if (!inSingle && /\s/.test(ch)) {
|
|
975
|
-
if (current) {
|
|
976
|
-
parts.push(current);
|
|
977
|
-
current = "";
|
|
978
|
-
}
|
|
979
|
-
} else {
|
|
980
|
-
current += ch;
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
if (current) parts.push(current);
|
|
984
|
-
return parts;
|
|
985
|
-
}
|
|
986
|
-
/** Helper to create a _skip tool call with an error message */
|
|
987
|
-
skip(message) {
|
|
988
|
-
return { name: "_skip", arguments: { message } };
|
|
989
|
-
}
|
|
990
|
-
handleListDirectory(parts, rawLine, commands) {
|
|
991
|
-
if (parts.length < 2) {
|
|
992
|
-
commands.push(this.skip(
|
|
993
|
-
`[SKIPPED] Your command "${rawLine}" is missing a path. Correct format: list_directory <path> [pattern]. Example: list_directory src/`
|
|
994
|
-
));
|
|
995
|
-
return;
|
|
996
|
-
}
|
|
997
|
-
const path5 = parts[1];
|
|
998
|
-
const pattern = parts[2]?.replace(/^"|"$/g, "") ?? null;
|
|
999
|
-
commands.push({ name: "list_directory", arguments: { path: path5, pattern } });
|
|
1000
|
-
}
|
|
1001
|
-
handleGrep(parts, rawLine, commands) {
|
|
1002
|
-
if (parts.length < 3) {
|
|
1003
|
-
commands.push(this.skip(
|
|
1004
|
-
`[SKIPPED] Your command "${rawLine}" is missing arguments. Correct format: grep '<pattern>' <path>. Example: grep 'TODO' src/`
|
|
1005
|
-
));
|
|
1006
|
-
return;
|
|
1007
|
-
}
|
|
1008
|
-
let pat = parts[1];
|
|
1009
|
-
if (pat.startsWith("'") && pat.endsWith("'")) {
|
|
1010
|
-
pat = pat.slice(1, -1);
|
|
1011
|
-
}
|
|
1012
|
-
if (!pat) {
|
|
1013
|
-
commands.push(this.skip(
|
|
1014
|
-
`[SKIPPED] Your command "${rawLine}" has an empty pattern. Provide a non-empty search pattern. Example: grep 'function' src/`
|
|
1015
|
-
));
|
|
1016
|
-
return;
|
|
1017
|
-
}
|
|
1018
|
-
commands.push({ name: "grep", arguments: { pattern: pat, path: parts[2] } });
|
|
1019
|
-
}
|
|
1020
|
-
handleRead(parts, rawLine, commands) {
|
|
1021
|
-
if (parts.length < 2) {
|
|
1022
|
-
commands.push(this.skip(
|
|
1023
|
-
`[SKIPPED] Your command "${rawLine}" is missing a path. Correct format: read <path> or read <path>:<start>-<end>. Example: read src/index.ts:1-50`
|
|
1024
|
-
));
|
|
1025
|
-
return;
|
|
1026
|
-
}
|
|
1027
|
-
const spec = parts[1];
|
|
1028
|
-
const rangeIdx = spec.indexOf(":");
|
|
1029
|
-
if (rangeIdx === -1) {
|
|
1030
|
-
commands.push({ name: "read", arguments: { path: spec } });
|
|
1031
|
-
return;
|
|
1032
|
-
}
|
|
1033
|
-
const filePath = spec.slice(0, rangeIdx);
|
|
1034
|
-
const range = spec.slice(rangeIdx + 1);
|
|
1035
|
-
const [s, e] = range.split("-").map((v) => parseInt(v, 10));
|
|
1036
|
-
if (!Number.isFinite(s) || !Number.isFinite(e)) {
|
|
1037
|
-
commands.push({ name: "read", arguments: { path: filePath } });
|
|
1038
|
-
return;
|
|
1039
|
-
}
|
|
1040
|
-
commands.push({ name: "read", arguments: { path: filePath, start: s, end: e } });
|
|
1041
|
-
}
|
|
1042
|
-
handleFinish(parts, rawLine, commands, acc) {
|
|
1043
|
-
const map = acc ?? /* @__PURE__ */ new Map();
|
|
1044
|
-
const args = parts.slice(1);
|
|
1045
|
-
for (const token of args) {
|
|
1046
|
-
const [filePath, rangesText] = token.split(":", 2);
|
|
1047
|
-
if (!filePath || !rangesText) {
|
|
1048
|
-
commands.push(this.skip(
|
|
1049
|
-
`[SKIPPED] Invalid finish token "${token}". Correct format: finish <path>:<start>-<end>. Example: finish src/index.ts:1-50`
|
|
1050
|
-
));
|
|
1051
|
-
continue;
|
|
1052
|
-
}
|
|
1053
|
-
const rangeSpecs = rangesText.split(",").filter(Boolean);
|
|
1054
|
-
for (const spec of rangeSpecs) {
|
|
1055
|
-
const [s, e] = spec.split("-").map((v) => parseInt(v, 10));
|
|
1056
|
-
if (!Number.isFinite(s) || !Number.isFinite(e) || e < s) {
|
|
1057
|
-
commands.push(this.skip(
|
|
1058
|
-
`[SKIPPED] Invalid range "${spec}" in "${token}". Ranges must be <start>-<end> where start <= end. Example: 1-50`
|
|
1059
|
-
));
|
|
1060
|
-
continue;
|
|
1061
|
-
}
|
|
1062
|
-
const arr = map.get(filePath) ?? [];
|
|
1063
|
-
arr.push([s, e]);
|
|
1064
|
-
map.set(filePath, arr);
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
return map;
|
|
719
|
+
const withoutThink = text.replace(/<think>[\s\S]*?<\/think>/gi, "");
|
|
720
|
+
return parseQwen3ToolCalls(withoutThink);
|
|
1068
721
|
}
|
|
1069
722
|
};
|
|
1070
723
|
|
|
@@ -1134,14 +787,12 @@ async function toolListDirectory(provider, args) {
|
|
|
1134
787
|
}
|
|
1135
788
|
const { entries: list } = await getListRecursive(initialDepth);
|
|
1136
789
|
if (!list.length) return "empty";
|
|
1137
|
-
|
|
1138
|
-
return "query not specific enough, tool called tried to return too much context and failed";
|
|
1139
|
-
}
|
|
1140
|
-
return list.map((e) => {
|
|
790
|
+
const tree = list.map((e) => {
|
|
1141
791
|
const indent = " ".repeat(e.depth);
|
|
1142
792
|
const name = e.type === "dir" ? `${e.name}/` : e.name;
|
|
1143
793
|
return `${indent}${name}`;
|
|
1144
794
|
}).join("\n");
|
|
795
|
+
return tree;
|
|
1145
796
|
}
|
|
1146
797
|
|
|
1147
798
|
// tools/warp_grep/agent/tools/finish.ts
|
|
@@ -1204,90 +855,19 @@ function mergeRanges(ranges) {
|
|
|
1204
855
|
|
|
1205
856
|
// tools/warp_grep/agent/formatter.ts
|
|
1206
857
|
var ToolOutputFormatter = class {
|
|
1207
|
-
format(toolName,
|
|
858
|
+
format(toolName, _args, output, options = {}) {
|
|
1208
859
|
const name = (toolName ?? "").trim();
|
|
1209
860
|
if (!name) {
|
|
1210
861
|
return "";
|
|
1211
862
|
}
|
|
1212
863
|
const payload = output?.toString?.()?.trim?.() ?? "";
|
|
1213
864
|
const isError = Boolean(options.isError);
|
|
1214
|
-
const safeArgs = args ?? {};
|
|
1215
865
|
if (!payload && !isError) {
|
|
1216
866
|
return "";
|
|
1217
867
|
}
|
|
1218
|
-
|
|
1219
|
-
case "read":
|
|
1220
|
-
return this.formatRead(safeArgs, payload, isError);
|
|
1221
|
-
case "list_directory":
|
|
1222
|
-
return this.formatListDirectory(safeArgs, payload, isError);
|
|
1223
|
-
case "grep":
|
|
1224
|
-
return this.formatGrep(safeArgs, payload, isError);
|
|
1225
|
-
default:
|
|
1226
|
-
return payload ? `<tool_output>
|
|
868
|
+
return `<tool_response>
|
|
1227
869
|
${payload}
|
|
1228
|
-
</
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
formatRead(args, payload, isError) {
|
|
1232
|
-
if (isError) {
|
|
1233
|
-
return payload;
|
|
1234
|
-
}
|
|
1235
|
-
const path5 = this.asString(args.path) || "...";
|
|
1236
|
-
const start = args.start;
|
|
1237
|
-
const end = args.end;
|
|
1238
|
-
const linesArray = args.lines;
|
|
1239
|
-
const attributes = [`path="${path5}"`];
|
|
1240
|
-
if (linesArray && linesArray.length > 0) {
|
|
1241
|
-
const rangeStr = linesArray.map(([s, e]) => `${s}-${e}`).join(",");
|
|
1242
|
-
attributes.push(`lines="${rangeStr}"`);
|
|
1243
|
-
} else if (start !== void 0 && end !== void 0) {
|
|
1244
|
-
attributes.push(`lines="${start}-${end}"`);
|
|
1245
|
-
}
|
|
1246
|
-
return `<read ${attributes.join(" ")}>
|
|
1247
|
-
${payload}
|
|
1248
|
-
</read>`;
|
|
1249
|
-
}
|
|
1250
|
-
formatListDirectory(args, payload, isError) {
|
|
1251
|
-
const path5 = this.asString(args.path) || ".";
|
|
1252
|
-
const pattern = this.asString(args.pattern);
|
|
1253
|
-
const attributes = [`path="${path5}"`];
|
|
1254
|
-
if (pattern) {
|
|
1255
|
-
attributes.push(`pattern="${pattern}"`);
|
|
1256
|
-
}
|
|
1257
|
-
if (isError) {
|
|
1258
|
-
attributes.push('status="error"');
|
|
1259
|
-
}
|
|
1260
|
-
return `<list_directory ${attributes.join(" ")}>
|
|
1261
|
-
${payload}
|
|
1262
|
-
</list_directory>`;
|
|
1263
|
-
}
|
|
1264
|
-
formatGrep(args, payload, isError) {
|
|
1265
|
-
const pattern = this.asString(args.pattern);
|
|
1266
|
-
const subDir = this.asString(args.path);
|
|
1267
|
-
const glob = this.asString(args.glob);
|
|
1268
|
-
const attributes = [];
|
|
1269
|
-
if (pattern !== void 0) {
|
|
1270
|
-
attributes.push(`pattern="${pattern}"`);
|
|
1271
|
-
}
|
|
1272
|
-
if (subDir !== void 0) {
|
|
1273
|
-
attributes.push(`sub_dir="${subDir}"`);
|
|
1274
|
-
}
|
|
1275
|
-
if (glob !== void 0) {
|
|
1276
|
-
attributes.push(`glob="${glob}"`);
|
|
1277
|
-
}
|
|
1278
|
-
if (isError) {
|
|
1279
|
-
attributes.push('status="error"');
|
|
1280
|
-
}
|
|
1281
|
-
const attrText = attributes.length ? ` ${attributes.join(" ")}` : "";
|
|
1282
|
-
return `<grep${attrText}>
|
|
1283
|
-
${payload}
|
|
1284
|
-
</grep>`;
|
|
1285
|
-
}
|
|
1286
|
-
asString(value) {
|
|
1287
|
-
if (value === null || value === void 0) {
|
|
1288
|
-
return void 0;
|
|
1289
|
-
}
|
|
1290
|
-
return String(value);
|
|
870
|
+
</tool_response>`;
|
|
1291
871
|
}
|
|
1292
872
|
};
|
|
1293
873
|
var sharedFormatter = new ToolOutputFormatter();
|
|
@@ -1316,12 +896,15 @@ function calculateContextBudget(messages) {
|
|
|
1316
896
|
const maxK = Math.round(maxChars / 1e3);
|
|
1317
897
|
return `<context_budget>${percent}% (${usedK}K/${maxK}K chars)</context_budget>`;
|
|
1318
898
|
}
|
|
1319
|
-
async function buildInitialState(repoRoot, query, provider) {
|
|
899
|
+
async function buildInitialState(repoRoot, query, provider, options) {
|
|
900
|
+
const budget = calculateContextBudget([]);
|
|
901
|
+
const turnTag = `Turn 0/${AGENT_CONFIG.MAX_TURNS}`;
|
|
902
|
+
const treeDepth = options?.query_type === "node_modules" ? 1 : 2;
|
|
1320
903
|
try {
|
|
1321
904
|
const entries = await provider.listDirectory({
|
|
1322
905
|
path: ".",
|
|
1323
906
|
maxResults: AGENT_CONFIG.MAX_OUTPUT_LINES,
|
|
1324
|
-
maxDepth:
|
|
907
|
+
maxDepth: treeDepth
|
|
1325
908
|
});
|
|
1326
909
|
const treeLines = entries.map((e) => {
|
|
1327
910
|
const indent = " ".repeat(e.depth);
|
|
@@ -1337,7 +920,9 @@ ${treeOutput}
|
|
|
1337
920
|
|
|
1338
921
|
<search_string>
|
|
1339
922
|
${query}
|
|
1340
|
-
</search_string
|
|
923
|
+
</search_string>
|
|
924
|
+
${budget}
|
|
925
|
+
${turnTag}`;
|
|
1341
926
|
} catch {
|
|
1342
927
|
const repoName = import_path.default.basename(repoRoot);
|
|
1343
928
|
return `<repo_structure>
|
|
@@ -1346,7 +931,9 @@ ${repoName}/
|
|
|
1346
931
|
|
|
1347
932
|
<search_string>
|
|
1348
933
|
${query}
|
|
1349
|
-
</search_string
|
|
934
|
+
</search_string>
|
|
935
|
+
${budget}
|
|
936
|
+
${turnTag}`;
|
|
1350
937
|
}
|
|
1351
938
|
}
|
|
1352
939
|
function enforceContextLimit(messages, maxChars = AGENT_CONFIG.MAX_CONTEXT_CHARS) {
|
|
@@ -1382,7 +969,7 @@ var import_openai = __toESM(require("openai"), 1);
|
|
|
1382
969
|
// package.json
|
|
1383
970
|
var package_default = {
|
|
1384
971
|
name: "@morphllm/morphsdk",
|
|
1385
|
-
version: "0.2.
|
|
972
|
+
version: "0.2.126",
|
|
1386
973
|
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
1387
974
|
type: "module",
|
|
1388
975
|
main: "./dist/index.cjs",
|
|
@@ -1524,7 +1111,7 @@ var package_default = {
|
|
|
1524
1111
|
"!dist/**/*.test.*"
|
|
1525
1112
|
],
|
|
1526
1113
|
scripts: {
|
|
1527
|
-
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/
|
|
1114
|
+
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",
|
|
1528
1115
|
prepare: "npm run build",
|
|
1529
1116
|
typecheck: "tsc --noEmit",
|
|
1530
1117
|
lint: "eslint .",
|
|
@@ -1661,14 +1248,13 @@ async function runWarpGrep(config) {
|
|
|
1661
1248
|
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1662
1249
|
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
1663
1250
|
const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
|
|
1251
|
+
const model = config.model || DEFAULT_MODEL;
|
|
1664
1252
|
const messages = [];
|
|
1665
|
-
|
|
1253
|
+
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1666
1254
|
const initialStateStart = Date.now();
|
|
1667
|
-
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
1255
|
+
const initialState = await buildInitialState(repoRoot, config.query, config.provider, { query_type: config.query_type });
|
|
1668
1256
|
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1669
1257
|
messages.push({ role: "user", content: initialState });
|
|
1670
|
-
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1671
|
-
const model = config.model || DEFAULT_MODEL;
|
|
1672
1258
|
const provider = config.provider;
|
|
1673
1259
|
const errors = [];
|
|
1674
1260
|
let finishMeta;
|
|
@@ -1718,7 +1304,7 @@ async function runWarpGrep(config) {
|
|
|
1718
1304
|
const args = c.arguments ?? {};
|
|
1719
1305
|
allPromises.push(
|
|
1720
1306
|
toolGrep(provider, args).then(
|
|
1721
|
-
({ output }) => formatAgentToolOutput("grep", args, output
|
|
1307
|
+
({ output }) => formatAgentToolOutput("grep", args, output),
|
|
1722
1308
|
(err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
|
|
1723
1309
|
)
|
|
1724
1310
|
);
|
|
@@ -1727,7 +1313,7 @@ async function runWarpGrep(config) {
|
|
|
1727
1313
|
const args = c.arguments ?? {};
|
|
1728
1314
|
allPromises.push(
|
|
1729
1315
|
toolListDirectory(provider, args).then(
|
|
1730
|
-
(p) => formatAgentToolOutput("list_directory", args, p
|
|
1316
|
+
(p) => formatAgentToolOutput("list_directory", args, p),
|
|
1731
1317
|
(err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
|
|
1732
1318
|
)
|
|
1733
1319
|
);
|
|
@@ -1736,7 +1322,7 @@ async function runWarpGrep(config) {
|
|
|
1736
1322
|
const args = c.arguments ?? {};
|
|
1737
1323
|
allPromises.push(
|
|
1738
1324
|
toolRead(provider, args).then(
|
|
1739
|
-
(p) => formatAgentToolOutput("read", args, p
|
|
1325
|
+
(p) => formatAgentToolOutput("read", args, p),
|
|
1740
1326
|
(err) => formatAgentToolOutput("read", args, String(err), { isError: true })
|
|
1741
1327
|
)
|
|
1742
1328
|
);
|
|
@@ -1820,14 +1406,13 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1820
1406
|
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1821
1407
|
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
1822
1408
|
const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
|
|
1409
|
+
const model = config.model || DEFAULT_MODEL;
|
|
1823
1410
|
const messages = [];
|
|
1824
|
-
|
|
1411
|
+
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1825
1412
|
const initialStateStart = Date.now();
|
|
1826
|
-
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
1413
|
+
const initialState = await buildInitialState(repoRoot, config.query, config.provider, { query_type: config.query_type });
|
|
1827
1414
|
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1828
1415
|
messages.push({ role: "user", content: initialState });
|
|
1829
|
-
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1830
|
-
const model = config.model || DEFAULT_MODEL;
|
|
1831
1416
|
const provider = config.provider;
|
|
1832
1417
|
const errors = [];
|
|
1833
1418
|
let finishMeta;
|
|
@@ -1884,7 +1469,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1884
1469
|
const args = c.arguments ?? {};
|
|
1885
1470
|
allPromises.push(
|
|
1886
1471
|
toolGrep(provider, args).then(
|
|
1887
|
-
({ output }) => formatAgentToolOutput("grep", args, output
|
|
1472
|
+
({ output }) => formatAgentToolOutput("grep", args, output),
|
|
1888
1473
|
(err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
|
|
1889
1474
|
)
|
|
1890
1475
|
);
|
|
@@ -1893,7 +1478,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1893
1478
|
const args = c.arguments ?? {};
|
|
1894
1479
|
allPromises.push(
|
|
1895
1480
|
toolListDirectory(provider, args).then(
|
|
1896
|
-
(p) => formatAgentToolOutput("list_directory", args, p
|
|
1481
|
+
(p) => formatAgentToolOutput("list_directory", args, p),
|
|
1897
1482
|
(err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
|
|
1898
1483
|
)
|
|
1899
1484
|
);
|
|
@@ -1902,7 +1487,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1902
1487
|
const args = c.arguments ?? {};
|
|
1903
1488
|
allPromises.push(
|
|
1904
1489
|
toolRead(provider, args).then(
|
|
1905
|
-
(p) => formatAgentToolOutput("read", args, p
|
|
1490
|
+
(p) => formatAgentToolOutput("read", args, p),
|
|
1906
1491
|
(err) => formatAgentToolOutput("read", args, String(err), { isError: true })
|
|
1907
1492
|
)
|
|
1908
1493
|
);
|
|
@@ -2080,10 +1665,9 @@ var RemoteCommandsProvider = class {
|
|
|
2080
1665
|
const stdout = await this.commands.grep(params.pattern, params.path, params.glob);
|
|
2081
1666
|
const lines = (stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
2082
1667
|
if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
};
|
|
1668
|
+
const truncated = lines.slice(0, AGENT_CONFIG.MAX_OUTPUT_LINES);
|
|
1669
|
+
truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);
|
|
1670
|
+
return { lines: truncated };
|
|
2087
1671
|
}
|
|
2088
1672
|
return { lines };
|
|
2089
1673
|
} catch (error) {
|
|
@@ -2113,7 +1697,7 @@ var RemoteCommandsProvider = class {
|
|
|
2113
1697
|
const lines = contentLines.map((content, idx) => `${start + idx}|${content}`);
|
|
2114
1698
|
if (lines.length > AGENT_CONFIG.MAX_READ_LINES) {
|
|
2115
1699
|
const truncated = lines.slice(0, AGENT_CONFIG.MAX_READ_LINES);
|
|
2116
|
-
truncated.push(`...
|
|
1700
|
+
truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_READ_LINES} of ${lines.length} lines)`);
|
|
2117
1701
|
return { lines: truncated };
|
|
2118
1702
|
}
|
|
2119
1703
|
return { lines };
|
|
@@ -2459,9 +2043,9 @@ function formatResult(result) {
|
|
|
2459
2043
|
|
|
2460
2044
|
// tools/warp_grep/prompts.ts
|
|
2461
2045
|
var WARP_GREP_DESCRIPTION = 'IMPORTANT: If you need to explore the codebase to gather context, and the task does not involve a single file or function which is provided by name, you should ALWAYS use the warpgrep codebase search tool first instead of running search commands. When the task requires exploration beyond a single known file, invoke warpgrep first with a natural-language query describing the target functionality, bug, or architectural concern. Warp Grep is a fast and accurate tool that can search for all relevant context in a codebase. Keep queries action-oriented (e.g., "Find where billing invoices are generated and emailed"), and after reviewing the summarized results, you may verify important findings with other search tools or direct file reads to ensure completeness. Warp Grep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. When a task requires exploration beyond a single known file, ALWAYS default to warpgrep codebase search before other search mechanisms.';
|
|
2462
|
-
var GITHUB_WARP_GREP_SEARCH_DESCRIPTION = 'IMPORTANT: If you need to explore the codebase of a public GitHub repository (not your local workspace), use warpgrep_github_search instead of warpgrep_codebase_search.
|
|
2046
|
+
var GITHUB_WARP_GREP_SEARCH_DESCRIPTION = 'IMPORTANT: If you need to explore the codebase of a public GitHub repository (not your local workspace), use warpgrep_github_search instead of warpgrep_codebase_search. ONLY use this tool when the task requires understanding code in an external repo, and invoke warpgrep_github_search with a GitHub URL or owner/repo shorthand (e.g., vercel/next.js) and a natural-language query describing the target functionality, bug, or architectural concern. DO NOT use this tool when the task requires understanding code in your local workspace. Use warpgrep_codebase_search instead.Useful when you suspect a library or framework is being used in a way that is not documented, or if you suspect an update or a bug in the library or framework.WarpGrep searches GitHub repos the same way it searches local codebases: fast and accurate. Keep queries action-oriented (e.g., "Find where how the new use workflow directive works"), and after reviewing the results, you may verify important findings with other tools or direct file reads. WarpGrep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. When a task involves exploring code in an external public repo, ALWAYS use warpgrep_github_search.';
|
|
2463
2047
|
var GITHUB_SEARCH_DESCRIPTION = GITHUB_WARP_GREP_SEARCH_DESCRIPTION;
|
|
2464
|
-
var GITHUB_READ_FILE_DESCRIPTION = "Read a single file (or a line range) from a public GitHub repository.
|
|
2048
|
+
var GITHUB_READ_FILE_DESCRIPTION = "Read a single file (or a line range) from a public GitHub repository. ONLY USE THIS WHEN YOU ALREADY KNOW THE EXACT FILE PATH YOU WANT TO READ, for example after finding it via warpgrep_github_search results. Takes owner/repo shorthand and the file path within the repo. Optionally specify startLine and endLine (1-based) to read a specific range. Returns the file content with line numbers.";
|
|
2465
2049
|
|
|
2466
2050
|
// tools/warp_grep/vercel.ts
|
|
2467
2051
|
var warpGrepJsonSchema = {
|
|
@@ -2559,7 +2143,6 @@ var vercel_default = createWarpGrepTool;
|
|
|
2559
2143
|
createWarpGrepTool,
|
|
2560
2144
|
execute,
|
|
2561
2145
|
formatResult,
|
|
2562
|
-
getSystemPrompt,
|
|
2563
2146
|
warpGrepJsonSchema
|
|
2564
2147
|
});
|
|
2565
2148
|
//# sourceMappingURL=vercel.cjs.map
|