@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();
|
|
@@ -577,7 +584,6 @@ __export(anthropic_exports, {
|
|
|
577
584
|
createWarpGrepTool: () => createWarpGrepTool,
|
|
578
585
|
execute: () => execute,
|
|
579
586
|
formatResult: () => formatResult,
|
|
580
|
-
getSystemPrompt: () => getSystemPrompt,
|
|
581
587
|
warpGrepTool: () => warpGrepTool
|
|
582
588
|
});
|
|
583
589
|
module.exports = __toCommonJS(anthropic_exports);
|
|
@@ -585,483 +591,130 @@ module.exports = __toCommonJS(anthropic_exports);
|
|
|
585
591
|
// tools/warp_grep/agent/runner.ts
|
|
586
592
|
init_config();
|
|
587
593
|
|
|
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
594
|
// tools/warp_grep/agent/parser.ts
|
|
791
|
-
var VALID_COMMANDS = ["list_directory", "
|
|
595
|
+
var VALID_COMMANDS = ["list_directory", "ripgrep", "read", "finish"];
|
|
792
596
|
function isValidCommand(name) {
|
|
793
597
|
return VALID_COMMANDS.includes(name);
|
|
794
598
|
}
|
|
795
|
-
function
|
|
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) {
|
|
599
|
+
function parseQwen3ToolCalls(text) {
|
|
801
600
|
const tools = [];
|
|
802
|
-
const
|
|
601
|
+
const toolCallRegex = /<tool_call>\s*<function=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/function>\s*<\/tool_call>/gi;
|
|
803
602
|
let match;
|
|
804
|
-
while ((match =
|
|
805
|
-
const
|
|
806
|
-
const
|
|
807
|
-
if (!isValidCommand(
|
|
808
|
-
const
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
603
|
+
while ((match = toolCallRegex.exec(text)) !== null) {
|
|
604
|
+
const funcName = match[1].toLowerCase();
|
|
605
|
+
const body = match[2];
|
|
606
|
+
if (!isValidCommand(funcName)) continue;
|
|
607
|
+
const params = {};
|
|
608
|
+
const paramRegex = /<parameter=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/parameter>/gi;
|
|
609
|
+
let paramMatch;
|
|
610
|
+
while ((paramMatch = paramRegex.exec(body)) !== null) {
|
|
611
|
+
params[paramMatch[1].toLowerCase()] = paramMatch[2].trim();
|
|
612
|
+
}
|
|
613
|
+
if (funcName === "ripgrep") {
|
|
614
|
+
const pattern = params.pattern;
|
|
615
|
+
if (!pattern) continue;
|
|
616
|
+
const args = {
|
|
617
|
+
pattern,
|
|
618
|
+
path: params.path || ".",
|
|
619
|
+
...params.glob && { glob: params.glob },
|
|
620
|
+
...params.context_lines && { context_lines: parseInt(params.context_lines, 10) },
|
|
621
|
+
...params.case_sensitive && { case_sensitive: params.case_sensitive === "true" }
|
|
622
|
+
};
|
|
623
|
+
tools.push({ name: "grep", arguments: args });
|
|
624
|
+
} else if (funcName === "list_directory") {
|
|
625
|
+
const command = params.command;
|
|
626
|
+
const directPath = params.path;
|
|
627
|
+
let dirPath = directPath || ".";
|
|
628
|
+
if (!directPath && command) {
|
|
629
|
+
const tokens = command.trim().split(/\s+/);
|
|
630
|
+
const pathTokens = tokens.slice(1).filter((t) => !t.startsWith("-") && !t.startsWith("|") && !t.startsWith("\\("));
|
|
631
|
+
if (pathTokens.length > 0) {
|
|
632
|
+
dirPath = pathTokens[0];
|
|
633
|
+
}
|
|
814
634
|
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
635
|
+
tools.push({ name: "list_directory", arguments: { path: dirPath, pattern: params.pattern || null } });
|
|
636
|
+
} else if (funcName === "read") {
|
|
637
|
+
const filePath = params.path;
|
|
638
|
+
if (!filePath) continue;
|
|
639
|
+
const args = { path: filePath };
|
|
640
|
+
const linesStr = params.lines;
|
|
641
|
+
if (linesStr) {
|
|
642
|
+
const ranges = [];
|
|
643
|
+
for (const rangeStr of linesStr.split(",")) {
|
|
644
|
+
const trimmed = rangeStr.trim();
|
|
645
|
+
if (!trimmed) continue;
|
|
646
|
+
const [s, e] = trimmed.split("-").map((v) => parseInt(v.trim(), 10));
|
|
647
|
+
if (Number.isFinite(s) && Number.isFinite(e)) {
|
|
648
|
+
ranges.push([s, e]);
|
|
649
|
+
} else if (Number.isFinite(s)) {
|
|
650
|
+
ranges.push([s, s]);
|
|
826
651
|
}
|
|
827
|
-
}
|
|
652
|
+
}
|
|
653
|
+
if (ranges.length === 1) {
|
|
654
|
+
args.start = ranges[0][0];
|
|
655
|
+
args.end = ranges[0][1];
|
|
656
|
+
} else if (ranges.length > 1) {
|
|
657
|
+
args.lines = ranges;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
tools.push({ name: "read", arguments: args });
|
|
661
|
+
} else if (funcName === "finish") {
|
|
662
|
+
if (params.result && !params.files) {
|
|
663
|
+
tools.push({ name: "finish", arguments: { files: [], textResult: params.result } });
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
666
|
+
const filesStr = params.files;
|
|
667
|
+
if (!filesStr) {
|
|
668
|
+
tools.push({ name: "finish", arguments: { files: [], textResult: "No relevant code found." } });
|
|
669
|
+
continue;
|
|
828
670
|
}
|
|
829
|
-
|
|
830
|
-
const
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
const
|
|
834
|
-
if (
|
|
671
|
+
const files = [];
|
|
672
|
+
for (const line of filesStr.split("\n")) {
|
|
673
|
+
const trimmed = line.trim();
|
|
674
|
+
if (!trimmed) continue;
|
|
675
|
+
const colonIdx = trimmed.indexOf(":");
|
|
676
|
+
if (colonIdx === -1) {
|
|
677
|
+
files.push({ path: trimmed, lines: "*" });
|
|
678
|
+
} else {
|
|
679
|
+
const filePath = trimmed.slice(0, colonIdx);
|
|
680
|
+
const rangesPart = trimmed.slice(colonIdx + 1);
|
|
835
681
|
const ranges = [];
|
|
836
|
-
for (const rangeStr of
|
|
837
|
-
const
|
|
838
|
-
if (!
|
|
839
|
-
|
|
682
|
+
for (const rangeStr of rangesPart.split(",")) {
|
|
683
|
+
const rt = rangeStr.trim();
|
|
684
|
+
if (!rt || rt === "*") {
|
|
685
|
+
files.push({ path: filePath, lines: "*" });
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
const [s, e] = rt.split("-").map((v) => parseInt(v.trim(), 10));
|
|
840
689
|
if (Number.isFinite(s) && Number.isFinite(e)) {
|
|
841
690
|
ranges.push([s, e]);
|
|
842
691
|
} else if (Number.isFinite(s)) {
|
|
843
692
|
ranges.push([s, s]);
|
|
844
693
|
}
|
|
845
694
|
}
|
|
846
|
-
if (ranges.length
|
|
847
|
-
|
|
848
|
-
|
|
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() === "*") {
|
|
695
|
+
if (ranges.length > 0) {
|
|
696
|
+
files.push({ path: filePath, lines: ranges });
|
|
697
|
+
} else if (!files.some((f) => f.path === filePath)) {
|
|
865
698
|
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
699
|
}
|
|
880
700
|
}
|
|
881
701
|
}
|
|
882
702
|
if (files.length > 0) {
|
|
883
703
|
tools.push({ name: "finish", arguments: { files } });
|
|
884
704
|
} else {
|
|
885
|
-
|
|
886
|
-
const textResult = !raw || raw === "*" ? "No relevant code found." : raw;
|
|
887
|
-
tools.push({ name: "finish", arguments: { files: [], textResult } });
|
|
705
|
+
tools.push({ name: "finish", arguments: { files: [], textResult: filesStr } });
|
|
888
706
|
}
|
|
889
707
|
}
|
|
890
708
|
}
|
|
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
709
|
return tools;
|
|
902
710
|
}
|
|
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
711
|
var LLMResponseParser = class {
|
|
921
|
-
finishSpecSplitRe = /,(?=[^,\s]+:)/;
|
|
922
712
|
parse(text) {
|
|
923
713
|
if (typeof text !== "string") {
|
|
924
714
|
throw new TypeError("Command text must be a string.");
|
|
925
715
|
}
|
|
926
|
-
const
|
|
927
|
-
|
|
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;
|
|
716
|
+
const withoutThink = text.replace(/<think>[\s\S]*?<\/think>/gi, "");
|
|
717
|
+
return parseQwen3ToolCalls(withoutThink);
|
|
1065
718
|
}
|
|
1066
719
|
};
|
|
1067
720
|
|
|
@@ -1131,14 +784,12 @@ async function toolListDirectory(provider, args) {
|
|
|
1131
784
|
}
|
|
1132
785
|
const { entries: list } = await getListRecursive(initialDepth);
|
|
1133
786
|
if (!list.length) return "empty";
|
|
1134
|
-
|
|
1135
|
-
return "query not specific enough, tool called tried to return too much context and failed";
|
|
1136
|
-
}
|
|
1137
|
-
return list.map((e) => {
|
|
787
|
+
const tree = list.map((e) => {
|
|
1138
788
|
const indent = " ".repeat(e.depth);
|
|
1139
789
|
const name = e.type === "dir" ? `${e.name}/` : e.name;
|
|
1140
790
|
return `${indent}${name}`;
|
|
1141
791
|
}).join("\n");
|
|
792
|
+
return tree;
|
|
1142
793
|
}
|
|
1143
794
|
|
|
1144
795
|
// tools/warp_grep/agent/tools/finish.ts
|
|
@@ -1201,90 +852,19 @@ function mergeRanges(ranges) {
|
|
|
1201
852
|
|
|
1202
853
|
// tools/warp_grep/agent/formatter.ts
|
|
1203
854
|
var ToolOutputFormatter = class {
|
|
1204
|
-
format(toolName,
|
|
855
|
+
format(toolName, _args, output, options = {}) {
|
|
1205
856
|
const name = (toolName ?? "").trim();
|
|
1206
857
|
if (!name) {
|
|
1207
858
|
return "";
|
|
1208
859
|
}
|
|
1209
860
|
const payload = output?.toString?.()?.trim?.() ?? "";
|
|
1210
861
|
const isError = Boolean(options.isError);
|
|
1211
|
-
const safeArgs = args ?? {};
|
|
1212
862
|
if (!payload && !isError) {
|
|
1213
863
|
return "";
|
|
1214
864
|
}
|
|
1215
|
-
|
|
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>
|
|
865
|
+
return `<tool_response>
|
|
1224
866
|
${payload}
|
|
1225
|
-
</
|
|
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}>
|
|
1280
|
-
${payload}
|
|
1281
|
-
</grep>`;
|
|
1282
|
-
}
|
|
1283
|
-
asString(value) {
|
|
1284
|
-
if (value === null || value === void 0) {
|
|
1285
|
-
return void 0;
|
|
1286
|
-
}
|
|
1287
|
-
return String(value);
|
|
867
|
+
</tool_response>`;
|
|
1288
868
|
}
|
|
1289
869
|
};
|
|
1290
870
|
var sharedFormatter = new ToolOutputFormatter();
|
|
@@ -1313,12 +893,15 @@ function calculateContextBudget(messages) {
|
|
|
1313
893
|
const maxK = Math.round(maxChars / 1e3);
|
|
1314
894
|
return `<context_budget>${percent}% (${usedK}K/${maxK}K chars)</context_budget>`;
|
|
1315
895
|
}
|
|
1316
|
-
async function buildInitialState(repoRoot, query, provider) {
|
|
896
|
+
async function buildInitialState(repoRoot, query, provider, options) {
|
|
897
|
+
const budget = calculateContextBudget([]);
|
|
898
|
+
const turnTag = `Turn 0/${AGENT_CONFIG.MAX_TURNS}`;
|
|
899
|
+
const treeDepth = options?.query_type === "node_modules" ? 1 : 2;
|
|
1317
900
|
try {
|
|
1318
901
|
const entries = await provider.listDirectory({
|
|
1319
902
|
path: ".",
|
|
1320
903
|
maxResults: AGENT_CONFIG.MAX_OUTPUT_LINES,
|
|
1321
|
-
maxDepth:
|
|
904
|
+
maxDepth: treeDepth
|
|
1322
905
|
});
|
|
1323
906
|
const treeLines = entries.map((e) => {
|
|
1324
907
|
const indent = " ".repeat(e.depth);
|
|
@@ -1334,7 +917,9 @@ ${treeOutput}
|
|
|
1334
917
|
|
|
1335
918
|
<search_string>
|
|
1336
919
|
${query}
|
|
1337
|
-
</search_string
|
|
920
|
+
</search_string>
|
|
921
|
+
${budget}
|
|
922
|
+
${turnTag}`;
|
|
1338
923
|
} catch {
|
|
1339
924
|
const repoName = import_path.default.basename(repoRoot);
|
|
1340
925
|
return `<repo_structure>
|
|
@@ -1343,7 +928,9 @@ ${repoName}/
|
|
|
1343
928
|
|
|
1344
929
|
<search_string>
|
|
1345
930
|
${query}
|
|
1346
|
-
</search_string
|
|
931
|
+
</search_string>
|
|
932
|
+
${budget}
|
|
933
|
+
${turnTag}`;
|
|
1347
934
|
}
|
|
1348
935
|
}
|
|
1349
936
|
function enforceContextLimit(messages, maxChars = AGENT_CONFIG.MAX_CONTEXT_CHARS) {
|
|
@@ -1379,7 +966,7 @@ var import_openai = __toESM(require("openai"), 1);
|
|
|
1379
966
|
// package.json
|
|
1380
967
|
var package_default = {
|
|
1381
968
|
name: "@morphllm/morphsdk",
|
|
1382
|
-
version: "0.2.
|
|
969
|
+
version: "0.2.126",
|
|
1383
970
|
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
1384
971
|
type: "module",
|
|
1385
972
|
main: "./dist/index.cjs",
|
|
@@ -1521,7 +1108,7 @@ var package_default = {
|
|
|
1521
1108
|
"!dist/**/*.test.*"
|
|
1522
1109
|
],
|
|
1523
1110
|
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/
|
|
1111
|
+
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
1112
|
prepare: "npm run build",
|
|
1526
1113
|
typecheck: "tsc --noEmit",
|
|
1527
1114
|
lint: "eslint .",
|
|
@@ -1658,14 +1245,13 @@ async function runWarpGrep(config) {
|
|
|
1658
1245
|
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1659
1246
|
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
1660
1247
|
const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
|
|
1248
|
+
const model = config.model || DEFAULT_MODEL;
|
|
1661
1249
|
const messages = [];
|
|
1662
|
-
|
|
1250
|
+
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1663
1251
|
const initialStateStart = Date.now();
|
|
1664
|
-
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
1252
|
+
const initialState = await buildInitialState(repoRoot, config.query, config.provider, { query_type: config.query_type });
|
|
1665
1253
|
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1666
1254
|
messages.push({ role: "user", content: initialState });
|
|
1667
|
-
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1668
|
-
const model = config.model || DEFAULT_MODEL;
|
|
1669
1255
|
const provider = config.provider;
|
|
1670
1256
|
const errors = [];
|
|
1671
1257
|
let finishMeta;
|
|
@@ -1715,7 +1301,7 @@ async function runWarpGrep(config) {
|
|
|
1715
1301
|
const args = c.arguments ?? {};
|
|
1716
1302
|
allPromises.push(
|
|
1717
1303
|
toolGrep(provider, args).then(
|
|
1718
|
-
({ output }) => formatAgentToolOutput("grep", args, output
|
|
1304
|
+
({ output }) => formatAgentToolOutput("grep", args, output),
|
|
1719
1305
|
(err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
|
|
1720
1306
|
)
|
|
1721
1307
|
);
|
|
@@ -1724,7 +1310,7 @@ async function runWarpGrep(config) {
|
|
|
1724
1310
|
const args = c.arguments ?? {};
|
|
1725
1311
|
allPromises.push(
|
|
1726
1312
|
toolListDirectory(provider, args).then(
|
|
1727
|
-
(p) => formatAgentToolOutput("list_directory", args, p
|
|
1313
|
+
(p) => formatAgentToolOutput("list_directory", args, p),
|
|
1728
1314
|
(err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
|
|
1729
1315
|
)
|
|
1730
1316
|
);
|
|
@@ -1733,7 +1319,7 @@ async function runWarpGrep(config) {
|
|
|
1733
1319
|
const args = c.arguments ?? {};
|
|
1734
1320
|
allPromises.push(
|
|
1735
1321
|
toolRead(provider, args).then(
|
|
1736
|
-
(p) => formatAgentToolOutput("read", args, p
|
|
1322
|
+
(p) => formatAgentToolOutput("read", args, p),
|
|
1737
1323
|
(err) => formatAgentToolOutput("read", args, String(err), { isError: true })
|
|
1738
1324
|
)
|
|
1739
1325
|
);
|
|
@@ -1817,14 +1403,13 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1817
1403
|
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1818
1404
|
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
1819
1405
|
const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
|
|
1406
|
+
const model = config.model || DEFAULT_MODEL;
|
|
1820
1407
|
const messages = [];
|
|
1821
|
-
|
|
1408
|
+
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1822
1409
|
const initialStateStart = Date.now();
|
|
1823
|
-
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
1410
|
+
const initialState = await buildInitialState(repoRoot, config.query, config.provider, { query_type: config.query_type });
|
|
1824
1411
|
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1825
1412
|
messages.push({ role: "user", content: initialState });
|
|
1826
|
-
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1827
|
-
const model = config.model || DEFAULT_MODEL;
|
|
1828
1413
|
const provider = config.provider;
|
|
1829
1414
|
const errors = [];
|
|
1830
1415
|
let finishMeta;
|
|
@@ -1881,7 +1466,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1881
1466
|
const args = c.arguments ?? {};
|
|
1882
1467
|
allPromises.push(
|
|
1883
1468
|
toolGrep(provider, args).then(
|
|
1884
|
-
({ output }) => formatAgentToolOutput("grep", args, output
|
|
1469
|
+
({ output }) => formatAgentToolOutput("grep", args, output),
|
|
1885
1470
|
(err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
|
|
1886
1471
|
)
|
|
1887
1472
|
);
|
|
@@ -1890,7 +1475,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1890
1475
|
const args = c.arguments ?? {};
|
|
1891
1476
|
allPromises.push(
|
|
1892
1477
|
toolListDirectory(provider, args).then(
|
|
1893
|
-
(p) => formatAgentToolOutput("list_directory", args, p
|
|
1478
|
+
(p) => formatAgentToolOutput("list_directory", args, p),
|
|
1894
1479
|
(err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
|
|
1895
1480
|
)
|
|
1896
1481
|
);
|
|
@@ -1899,7 +1484,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1899
1484
|
const args = c.arguments ?? {};
|
|
1900
1485
|
allPromises.push(
|
|
1901
1486
|
toolRead(provider, args).then(
|
|
1902
|
-
(p) => formatAgentToolOutput("read", args, p
|
|
1487
|
+
(p) => formatAgentToolOutput("read", args, p),
|
|
1903
1488
|
(err) => formatAgentToolOutput("read", args, String(err), { isError: true })
|
|
1904
1489
|
)
|
|
1905
1490
|
);
|
|
@@ -2077,10 +1662,9 @@ var RemoteCommandsProvider = class {
|
|
|
2077
1662
|
const stdout = await this.commands.grep(params.pattern, params.path, params.glob);
|
|
2078
1663
|
const lines = (stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
2079
1664
|
if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
};
|
|
1665
|
+
const truncated = lines.slice(0, AGENT_CONFIG.MAX_OUTPUT_LINES);
|
|
1666
|
+
truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);
|
|
1667
|
+
return { lines: truncated };
|
|
2084
1668
|
}
|
|
2085
1669
|
return { lines };
|
|
2086
1670
|
} catch (error) {
|
|
@@ -2110,7 +1694,7 @@ var RemoteCommandsProvider = class {
|
|
|
2110
1694
|
const lines = contentLines.map((content, idx) => `${start + idx}|${content}`);
|
|
2111
1695
|
if (lines.length > AGENT_CONFIG.MAX_READ_LINES) {
|
|
2112
1696
|
const truncated = lines.slice(0, AGENT_CONFIG.MAX_READ_LINES);
|
|
2113
|
-
truncated.push(`...
|
|
1697
|
+
truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_READ_LINES} of ${lines.length} lines)`);
|
|
2114
1698
|
return { lines: truncated };
|
|
2115
1699
|
}
|
|
2116
1700
|
return { lines };
|
|
@@ -2467,7 +2051,7 @@ function formatResult(result) {
|
|
|
2467
2051
|
var WARP_GREP_TOOL_NAME = "warpgrep_codebase_search";
|
|
2468
2052
|
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.';
|
|
2469
2053
|
var GITHUB_WARP_GREP_SEARCH_TOOL_NAME = "warpgrep_github_search";
|
|
2470
|
-
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.
|
|
2054
|
+
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.';
|
|
2471
2055
|
var GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA = {
|
|
2472
2056
|
type: "object",
|
|
2473
2057
|
properties: {
|
|
@@ -2481,7 +2065,7 @@ var GITHUB_SEARCH_TOOL_NAME = GITHUB_WARP_GREP_SEARCH_TOOL_NAME;
|
|
|
2481
2065
|
var GITHUB_SEARCH_DESCRIPTION = GITHUB_WARP_GREP_SEARCH_DESCRIPTION;
|
|
2482
2066
|
var GITHUB_SEARCH_INPUT_SCHEMA = GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA;
|
|
2483
2067
|
var GITHUB_READ_FILE_TOOL_NAME = "readfile_github_search";
|
|
2484
|
-
var GITHUB_READ_FILE_DESCRIPTION = "Read a single file (or a line range) from a public GitHub repository.
|
|
2068
|
+
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.";
|
|
2485
2069
|
var GITHUB_READ_FILE_INPUT_SCHEMA = {
|
|
2486
2070
|
type: "object",
|
|
2487
2071
|
properties: {
|
|
@@ -2522,9 +2106,6 @@ function createWarpGrepTool(config) {
|
|
|
2522
2106
|
},
|
|
2523
2107
|
formatResult: (result) => {
|
|
2524
2108
|
return formatResult(result);
|
|
2525
|
-
},
|
|
2526
|
-
getSystemPrompt: () => {
|
|
2527
|
-
return getSystemPrompt();
|
|
2528
2109
|
}
|
|
2529
2110
|
});
|
|
2530
2111
|
}
|
|
@@ -2541,9 +2122,6 @@ function createGitHubSearchTool(config) {
|
|
|
2541
2122
|
},
|
|
2542
2123
|
formatResult: (result) => {
|
|
2543
2124
|
return formatResult(result);
|
|
2544
|
-
},
|
|
2545
|
-
getSystemPrompt: () => {
|
|
2546
|
-
return getSystemPrompt();
|
|
2547
2125
|
}
|
|
2548
2126
|
});
|
|
2549
2127
|
}
|
|
@@ -2569,7 +2147,6 @@ function createGitHubReadFileTool(config) {
|
|
|
2569
2147
|
createWarpGrepTool,
|
|
2570
2148
|
execute,
|
|
2571
2149
|
formatResult,
|
|
2572
|
-
getSystemPrompt,
|
|
2573
2150
|
warpGrepTool
|
|
2574
2151
|
});
|
|
2575
2152
|
//# sourceMappingURL=anthropic.cjs.map
|