@morphllm/morphsdk 0.2.125 → 0.2.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-BQO3WODX.js → chunk-37ZZ24IX.js} +3 -12
- package/dist/chunk-37ZZ24IX.js.map +1 -0
- package/dist/{chunk-OQGX4RZP.js → chunk-3NLCSADX.js} +2 -2
- package/dist/{chunk-UGSV5LPO.js → chunk-5CIUBER5.js} +2 -2
- package/dist/{chunk-2S7ZQFIB.js → chunk-6722FXFI.js} +2 -2
- package/dist/{chunk-FAZO2LNY.js → chunk-6Y2LHEJJ.js} +2 -2
- package/dist/{chunk-IRNUW2DB.js → chunk-76PPJZWV.js} +3 -12
- package/dist/chunk-76PPJZWV.js.map +1 -0
- package/dist/{chunk-5L3TPS6A.js → chunk-AXYGFPEJ.js} +1 -1
- package/dist/{chunk-5L3TPS6A.js.map → chunk-AXYGFPEJ.js.map} +1 -1
- package/dist/{chunk-TFK4UOUE.js → chunk-C26M3TWM.js} +6 -6
- package/dist/{chunk-TS3E6IRI.js → chunk-CPZKCBED.js} +2 -2
- package/dist/{chunk-33CP5QCC.js → chunk-CYVV5X5K.js} +3 -3
- package/dist/{chunk-33CP5QCC.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-IB4MEIQG.js → chunk-EB656RG6.js} +2 -2
- package/dist/{chunk-6TH3VNCF.js → chunk-FAH4YGRN.js} +3 -3
- package/dist/{chunk-DGYWACHC.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-FEQJCZJQ.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-F6HNFC2H.js → chunk-K6GLBQBV.js} +2 -2
- package/dist/{chunk-57PXQ6IS.js → chunk-KJVFYRXY.js} +15 -15
- package/dist/{chunk-2MK64KK4.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-7RTJCQWB.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-ACHEU2V3.js → chunk-R74NP2D4.js} +2 -2
- package/dist/{chunk-H6KT7IXW.js → chunk-TREVNTLA.js} +2 -2
- package/dist/{chunk-G5YJDK5S.js → chunk-ULZOJQ2W.js} +2 -2
- package/dist/chunk-VCKJ22DX.js +131 -0
- package/dist/chunk-VCKJ22DX.js.map +1 -0
- package/dist/{chunk-WZAZFW77.js → chunk-VYJUGQUR.js} +1 -1
- package/dist/{chunk-OFQRY3RM.js → chunk-W7WUZMKZ.js} +18 -23
- package/dist/chunk-W7WUZMKZ.js.map +1 -0
- package/dist/{chunk-BGL35LL6.js → chunk-YHZRHPJI.js} +2 -2
- package/dist/{client-JHPwle1Z.d.ts → client-s3_iDem0.d.ts} +0 -4
- package/dist/client.cjs +145 -572
- 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 +145 -572
- 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 +143 -566
- 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 +143 -566
- 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 +143 -562
- 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 +143 -566
- 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 +143 -560
- 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-3MLWXJTJ.js.map +0 -1
- package/dist/chunk-7RTJCQWB.js.map +0 -1
- package/dist/chunk-APP75CBN.js +0 -98
- package/dist/chunk-APP75CBN.js.map +0 -1
- package/dist/chunk-BQO3WODX.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-IRNUW2DB.js.map +0 -1
- package/dist/chunk-OFQRY3RM.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-OQGX4RZP.js.map → chunk-3NLCSADX.js.map} +0 -0
- /package/dist/{chunk-UGSV5LPO.js.map → chunk-5CIUBER5.js.map} +0 -0
- /package/dist/{chunk-2S7ZQFIB.js.map → chunk-6722FXFI.js.map} +0 -0
- /package/dist/{chunk-FAZO2LNY.js.map → chunk-6Y2LHEJJ.js.map} +0 -0
- /package/dist/{chunk-TFK4UOUE.js.map → chunk-C26M3TWM.js.map} +0 -0
- /package/dist/{chunk-TS3E6IRI.js.map → chunk-CPZKCBED.js.map} +0 -0
- /package/dist/{chunk-IB4MEIQG.js.map → chunk-EB656RG6.js.map} +0 -0
- /package/dist/{chunk-6TH3VNCF.js.map → chunk-FAH4YGRN.js.map} +0 -0
- /package/dist/{chunk-DGYWACHC.js.map → chunk-GISRJI5P.js.map} +0 -0
- /package/dist/{chunk-FEQJCZJQ.js.map → chunk-IYZX6EYC.js.map} +0 -0
- /package/dist/{chunk-F6HNFC2H.js.map → chunk-K6GLBQBV.js.map} +0 -0
- /package/dist/{chunk-57PXQ6IS.js.map → chunk-KJVFYRXY.js.map} +0 -0
- /package/dist/{chunk-2MK64KK4.js.map → chunk-KUABSLVR.js.map} +0 -0
- /package/dist/{chunk-ACHEU2V3.js.map → chunk-R74NP2D4.js.map} +0 -0
- /package/dist/{chunk-H6KT7IXW.js.map → chunk-TREVNTLA.js.map} +0 -0
- /package/dist/{chunk-G5YJDK5S.js.map → chunk-ULZOJQ2W.js.map} +0 -0
- /package/dist/{chunk-WZAZFW77.js.map → chunk-VYJUGQUR.js.map} +0 -0
- /package/dist/{chunk-BGL35LL6.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();
|
|
@@ -581,7 +588,6 @@ __export(warp_grep_exports, {
|
|
|
581
588
|
LocalRipgrepProvider: () => LocalRipgrepProvider,
|
|
582
589
|
RemoteCommandsProvider: () => RemoteCommandsProvider,
|
|
583
590
|
WARP_GREP_DESCRIPTION: () => WARP_GREP_DESCRIPTION,
|
|
584
|
-
WARP_GREP_SYSTEM_PROMPT: () => SYSTEM_PROMPT,
|
|
585
591
|
WARP_GREP_TOOL_NAME: () => WARP_GREP_TOOL_NAME,
|
|
586
592
|
WarpGrepClient: () => WarpGrepClient,
|
|
587
593
|
createCodeStorageHttpCommands: () => createCodeStorageHttpCommands,
|
|
@@ -591,7 +597,6 @@ __export(warp_grep_exports, {
|
|
|
591
597
|
fixPathRepetition: () => fixPathRepetition,
|
|
592
598
|
formatGitHubReadFileResult: () => formatGitHubReadFileResult,
|
|
593
599
|
formatResult: () => formatResult,
|
|
594
|
-
getSystemPrompt: () => getSystemPrompt,
|
|
595
600
|
normalizeFinishFiles: () => normalizeFinishFiles,
|
|
596
601
|
readFinishFiles: () => readFinishFiles,
|
|
597
602
|
runWarpGrep: () => runWarpGrep,
|
|
@@ -607,483 +612,130 @@ var import_zod = require("zod");
|
|
|
607
612
|
// tools/warp_grep/agent/runner.ts
|
|
608
613
|
init_config();
|
|
609
614
|
|
|
610
|
-
// tools/warp_grep/agent/prompt.ts
|
|
611
|
-
var SYSTEM_PROMPT = `You are a code search agent. Your task is to find all relevant code for a given search_string.
|
|
612
|
-
|
|
613
|
-
### workflow
|
|
614
|
-
You have exactly 4 turns. The 4th turn MUST be a \`finish\` call. Each turn allows up to 8 parallel tool calls.
|
|
615
|
-
|
|
616
|
-
- Turn 1: Map the territory OR dive deep (based on search_string specificity)
|
|
617
|
-
- Turn 2-3: Refine based on findings
|
|
618
|
-
- Turn 4: MUST call \`finish\` with all relevant code locations
|
|
619
|
-
- You MAY call \`finish\` early if confident\u2014but never before at least 1 search turn.
|
|
620
|
-
- The user strongly prefers if you can call the finish tool early, but you must be correct
|
|
621
|
-
|
|
622
|
-
Remember, if the task feels easy to you, it is strongly desirable to call 'finish' early using fewer turns, but quality over speed
|
|
623
|
-
|
|
624
|
-
### tools
|
|
625
|
-
Tool calls use nested XML elements:
|
|
626
|
-
\`\`\`xml
|
|
627
|
-
<tool_name>
|
|
628
|
-
<parameter>value</parameter>
|
|
629
|
-
</tool_name>
|
|
630
|
-
\`\`\`
|
|
631
|
-
|
|
632
|
-
### \`list_directory\`
|
|
633
|
-
Directory tree view. Shows structure of a path, optionally filtered by regex pattern.
|
|
634
|
-
|
|
635
|
-
Elements:
|
|
636
|
-
- \`<path>\` (required): Directory path to list (use \`.\` for repo root)
|
|
637
|
-
- \`<pattern>\` (optional): Regex to filter results
|
|
638
|
-
|
|
639
|
-
Examples:
|
|
640
|
-
\`\`\`
|
|
641
|
-
<list_directory>
|
|
642
|
-
<path>src/services</path>
|
|
643
|
-
</list_directory>
|
|
644
|
-
|
|
645
|
-
<list_directory>
|
|
646
|
-
<path>lib/utils</path>
|
|
647
|
-
<pattern>.*\\.(ts|js)$</pattern>
|
|
648
|
-
</list_directory>
|
|
649
|
-
\`\`\`
|
|
650
|
-
|
|
651
|
-
### \`read\`
|
|
652
|
-
Read file contents. Supports multiple line ranges.
|
|
653
|
-
- Returns numbered lines for easy reference
|
|
654
|
-
- ALWAYS include import statements (usually lines 1-20). Better to over-include than miss context.
|
|
655
|
-
|
|
656
|
-
Elements:
|
|
657
|
-
- \`<path>\` (required): File path to read
|
|
658
|
-
- \`<lines>\` (optional): Line ranges like "1-50,75-80,100-120" (omit to read entire file)
|
|
659
|
-
|
|
660
|
-
Examples:
|
|
661
|
-
\`\`\`
|
|
662
|
-
<read>
|
|
663
|
-
<path>src/main.py</path>
|
|
664
|
-
</read>
|
|
665
|
-
|
|
666
|
-
<read>
|
|
667
|
-
<path>src/auth.py</path>
|
|
668
|
-
<lines>1-20,45-80,150-200</lines>
|
|
669
|
-
</read>
|
|
670
|
-
\`\`\`
|
|
671
|
-
|
|
672
|
-
### \`grep\`
|
|
673
|
-
Search for pattern matches across files. Returns matches with 1 line of context above and below.
|
|
674
|
-
- Match lines use \`:\` separator \u2192 \`filepath:linenum:content\`
|
|
675
|
-
- Context lines use \`-\` separator \u2192 \`filepath-linenum-content\`
|
|
676
|
-
|
|
677
|
-
Elements:
|
|
678
|
-
- \`<pattern>\` (required): Search pattern (regex). Use \`(a|b)\` for OR patterns.
|
|
679
|
-
- \`<sub_dir>\` (optional): Subdirectory to search in (defaults to \`.\`)
|
|
680
|
-
- \`<glob>\` (optional): File pattern filter like \`*.py\` or \`*.{ts,tsx}\`
|
|
681
|
-
|
|
682
|
-
Examples:
|
|
683
|
-
\`\`\`
|
|
684
|
-
<grep>
|
|
685
|
-
<pattern>(authenticate|authorize|login)</pattern>
|
|
686
|
-
<sub_dir>src/auth/</sub_dir>
|
|
687
|
-
</grep>
|
|
688
|
-
|
|
689
|
-
<grep>
|
|
690
|
-
<pattern>class.*(Service|Controller)</pattern>
|
|
691
|
-
<glob>*.{ts,js}</glob>
|
|
692
|
-
</grep>
|
|
693
|
-
|
|
694
|
-
<grep>
|
|
695
|
-
<pattern>(DB_HOST|DATABASE_URL|connection)</pattern>
|
|
696
|
-
<glob>*.{py,yaml,env}</glob>
|
|
697
|
-
<sub_dir>lib/</sub_dir>
|
|
698
|
-
</grep>
|
|
699
|
-
\`\`\`
|
|
700
|
-
|
|
701
|
-
### \`finish\`
|
|
702
|
-
Submit final answer with all relevant code locations. Uses nested \`<file>\` elements.
|
|
703
|
-
|
|
704
|
-
File elements:
|
|
705
|
-
- \`<path>\` (required): File path
|
|
706
|
-
- \`<lines>\` (optional): Line ranges like "1-50,75-80" (\`*\` for entire file)
|
|
707
|
-
|
|
708
|
-
ALWAYS include import statements (usually lines 1-20). Better to over-include than miss context.
|
|
709
|
-
|
|
710
|
-
Examples:
|
|
711
|
-
\`\`\`
|
|
712
|
-
<finish>
|
|
713
|
-
<file>
|
|
714
|
-
<path>src/auth.py</path>
|
|
715
|
-
<lines>1-15,25-50,75-80</lines>
|
|
716
|
-
</file>
|
|
717
|
-
<file>
|
|
718
|
-
<path>src/models/user.py</path>
|
|
719
|
-
<lines>*</lines>
|
|
720
|
-
</file>
|
|
721
|
-
</finish>
|
|
722
|
-
\`\`\`
|
|
723
|
-
</tools>
|
|
724
|
-
|
|
725
|
-
<strategy>
|
|
726
|
-
**Before your first tool call, classify the search_string:**
|
|
727
|
-
|
|
728
|
-
| Search_string Type | Round 1 Strategy | Early Finish? |
|
|
729
|
-
|------------|------------------|---------------|
|
|
730
|
-
| **Specific** (function name, error string, unique identifier) | 8 parallel greps on likely paths | Often by round 2 |
|
|
731
|
-
| **Conceptual** (how does X work, where is Y handled) | list_directory + 2-3 broad greps | Rarely early |
|
|
732
|
-
| **Exploratory** (find all tests, list API endpoints) | list_directory at multiple depths | Usually needs 3 rounds |
|
|
733
|
-
|
|
734
|
-
**Parallel call patterns:**
|
|
735
|
-
- **Shotgun grep**: Same pattern, 8 different directories\u2014fast coverage
|
|
736
|
-
- **Variant grep**: 8 pattern variations (synonyms, naming conventions)\u2014catches inconsistent codebases
|
|
737
|
-
- **Funnel**: 1 list_directory + 7 greps\u2014orient and search simultaneously
|
|
738
|
-
- **Deep read**: 8 reads on files you already identified\u2014gather full context fast
|
|
739
|
-
|
|
740
|
-
**Tool call expectations:**
|
|
741
|
-
- 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.
|
|
742
|
-
- 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.
|
|
743
|
-
- 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.
|
|
744
|
-
- 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.
|
|
745
|
-
</strategy>
|
|
746
|
-
|
|
747
|
-
<output_format>
|
|
748
|
-
EVERY response MUST follow this exact format:
|
|
749
|
-
|
|
750
|
-
1. First, wrap your reasoning in \`<think>...</think>\` tags containing:
|
|
751
|
-
- Search_string classification (specific/conceptual/exploratory)
|
|
752
|
-
- Confidence estimate (can I finish in 1-2 rounds?)
|
|
753
|
-
- This round's parallel strategy
|
|
754
|
-
- What signals would let me finish early?
|
|
755
|
-
|
|
756
|
-
2. Then, output up to 8 tool calls using nested XML elements.
|
|
757
|
-
|
|
758
|
-
Example:
|
|
759
|
-
\`\`\`
|
|
760
|
-
<think>
|
|
761
|
-
This is a specific search_string about authentication. I'll grep for auth-related patterns.
|
|
762
|
-
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
|
|
763
|
-
Strategy: Shotgun grep across likely directories.
|
|
764
|
-
</think>
|
|
765
|
-
<grep>
|
|
766
|
-
<pattern>(authenticate|login|session)</pattern>
|
|
767
|
-
<sub_dir>src/auth/</sub_dir>
|
|
768
|
-
</grep>
|
|
769
|
-
<grep>
|
|
770
|
-
<pattern>(middleware|interceptor)</pattern>
|
|
771
|
-
<glob>*.{ts,js}</glob>
|
|
772
|
-
</grep>
|
|
773
|
-
<list_directory>
|
|
774
|
-
<path>src/auth</path>
|
|
775
|
-
</list_directory>
|
|
776
|
-
\`\`\`
|
|
777
|
-
|
|
778
|
-
Finishing example:
|
|
779
|
-
\`\`\`
|
|
780
|
-
<think>
|
|
781
|
-
I think I have a rough idea, but this is my last turn so I must call the finish tool regardless.
|
|
782
|
-
</think>
|
|
783
|
-
<finish>
|
|
784
|
-
<file>
|
|
785
|
-
<path>src/auth/login.py</path>
|
|
786
|
-
<lines>1-50</lines>
|
|
787
|
-
</file>
|
|
788
|
-
<file>
|
|
789
|
-
<path>src/middleware/session.py</path>
|
|
790
|
-
<lines>10-80</lines>
|
|
791
|
-
</file>
|
|
792
|
-
</finish>
|
|
793
|
-
\`\`\`
|
|
794
|
-
|
|
795
|
-
No commentary outside \`<think>\`. No explanations after tool calls.
|
|
796
|
-
</output_format>
|
|
797
|
-
|
|
798
|
-
use as all 8 tool calls to be optimal
|
|
799
|
-
|
|
800
|
-
<finishing_requirements>
|
|
801
|
-
When calling \`finish\`:
|
|
802
|
-
- Include the import section (typically lines 1-20) of each file
|
|
803
|
-
- Include all function/class definitions that are relevant
|
|
804
|
-
- Include any type definitions, interfaces, or constants used
|
|
805
|
-
- Better to over-include than leave the user missing context
|
|
806
|
-
- If unsure about boundaries, include more rather than less
|
|
807
|
-
</finishing_requirements>`;
|
|
808
|
-
function getSystemPrompt() {
|
|
809
|
-
return SYSTEM_PROMPT;
|
|
810
|
-
}
|
|
811
|
-
|
|
812
615
|
// tools/warp_grep/agent/parser.ts
|
|
813
|
-
var VALID_COMMANDS = ["list_directory", "
|
|
616
|
+
var VALID_COMMANDS = ["list_directory", "ripgrep", "read", "finish"];
|
|
814
617
|
function isValidCommand(name) {
|
|
815
618
|
return VALID_COMMANDS.includes(name);
|
|
816
619
|
}
|
|
817
|
-
function
|
|
818
|
-
const regex = new RegExp(`<${tagName}>([\\s\\S]*?)</${tagName}>`, "i");
|
|
819
|
-
const match = xml.match(regex);
|
|
820
|
-
return match ? match[1].trim() : null;
|
|
821
|
-
}
|
|
822
|
-
function parseNestedXmlTools(text) {
|
|
620
|
+
function parseQwen3ToolCalls(text) {
|
|
823
621
|
const tools = [];
|
|
824
|
-
const
|
|
622
|
+
const toolCallRegex = /<tool_call>\s*<function=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/function>\s*<\/tool_call>/gi;
|
|
825
623
|
let match;
|
|
826
|
-
while ((match =
|
|
827
|
-
const
|
|
828
|
-
const
|
|
829
|
-
if (!isValidCommand(
|
|
830
|
-
const
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
624
|
+
while ((match = toolCallRegex.exec(text)) !== null) {
|
|
625
|
+
const funcName = match[1].toLowerCase();
|
|
626
|
+
const body = match[2];
|
|
627
|
+
if (!isValidCommand(funcName)) continue;
|
|
628
|
+
const params = {};
|
|
629
|
+
const paramRegex = /<parameter=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/parameter>/gi;
|
|
630
|
+
let paramMatch;
|
|
631
|
+
while ((paramMatch = paramRegex.exec(body)) !== null) {
|
|
632
|
+
params[paramMatch[1].toLowerCase()] = paramMatch[2].trim();
|
|
633
|
+
}
|
|
634
|
+
if (funcName === "ripgrep") {
|
|
635
|
+
const pattern = params.pattern;
|
|
636
|
+
if (!pattern) continue;
|
|
637
|
+
const args = {
|
|
638
|
+
pattern,
|
|
639
|
+
path: params.path || ".",
|
|
640
|
+
...params.glob && { glob: params.glob },
|
|
641
|
+
...params.context_lines && { context_lines: parseInt(params.context_lines, 10) },
|
|
642
|
+
...params.case_sensitive && { case_sensitive: params.case_sensitive === "true" }
|
|
643
|
+
};
|
|
644
|
+
tools.push({ name: "grep", arguments: args });
|
|
645
|
+
} else if (funcName === "list_directory") {
|
|
646
|
+
const command = params.command;
|
|
647
|
+
const directPath = params.path;
|
|
648
|
+
let dirPath = directPath || ".";
|
|
649
|
+
if (!directPath && command) {
|
|
650
|
+
const tokens = command.trim().split(/\s+/);
|
|
651
|
+
const pathTokens = tokens.slice(1).filter((t) => !t.startsWith("-") && !t.startsWith("|") && !t.startsWith("\\("));
|
|
652
|
+
if (pathTokens.length > 0) {
|
|
653
|
+
dirPath = pathTokens[0];
|
|
654
|
+
}
|
|
836
655
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
const
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
656
|
+
tools.push({ name: "list_directory", arguments: { path: dirPath, pattern: params.pattern || null } });
|
|
657
|
+
} else if (funcName === "read") {
|
|
658
|
+
const filePath = params.path;
|
|
659
|
+
if (!filePath) continue;
|
|
660
|
+
const args = { path: filePath };
|
|
661
|
+
const linesStr = params.lines;
|
|
662
|
+
if (linesStr) {
|
|
663
|
+
const ranges = [];
|
|
664
|
+
for (const rangeStr of linesStr.split(",")) {
|
|
665
|
+
const trimmed = rangeStr.trim();
|
|
666
|
+
if (!trimmed) continue;
|
|
667
|
+
const [s, e] = trimmed.split("-").map((v) => parseInt(v.trim(), 10));
|
|
668
|
+
if (Number.isFinite(s) && Number.isFinite(e)) {
|
|
669
|
+
ranges.push([s, e]);
|
|
670
|
+
} else if (Number.isFinite(s)) {
|
|
671
|
+
ranges.push([s, s]);
|
|
848
672
|
}
|
|
849
|
-
}
|
|
673
|
+
}
|
|
674
|
+
if (ranges.length === 1) {
|
|
675
|
+
args.start = ranges[0][0];
|
|
676
|
+
args.end = ranges[0][1];
|
|
677
|
+
} else if (ranges.length > 1) {
|
|
678
|
+
args.lines = ranges;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
tools.push({ name: "read", arguments: args });
|
|
682
|
+
} else if (funcName === "finish") {
|
|
683
|
+
if (params.result && !params.files) {
|
|
684
|
+
tools.push({ name: "finish", arguments: { files: [], textResult: params.result } });
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
const filesStr = params.files;
|
|
688
|
+
if (!filesStr) {
|
|
689
|
+
tools.push({ name: "finish", arguments: { files: [], textResult: "No relevant code found." } });
|
|
690
|
+
continue;
|
|
850
691
|
}
|
|
851
|
-
|
|
852
|
-
const
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
const
|
|
856
|
-
if (
|
|
692
|
+
const files = [];
|
|
693
|
+
for (const line of filesStr.split("\n")) {
|
|
694
|
+
const trimmed = line.trim();
|
|
695
|
+
if (!trimmed) continue;
|
|
696
|
+
const colonIdx = trimmed.indexOf(":");
|
|
697
|
+
if (colonIdx === -1) {
|
|
698
|
+
files.push({ path: trimmed, lines: "*" });
|
|
699
|
+
} else {
|
|
700
|
+
const filePath = trimmed.slice(0, colonIdx);
|
|
701
|
+
const rangesPart = trimmed.slice(colonIdx + 1);
|
|
857
702
|
const ranges = [];
|
|
858
|
-
for (const rangeStr of
|
|
859
|
-
const
|
|
860
|
-
if (!
|
|
861
|
-
|
|
703
|
+
for (const rangeStr of rangesPart.split(",")) {
|
|
704
|
+
const rt = rangeStr.trim();
|
|
705
|
+
if (!rt || rt === "*") {
|
|
706
|
+
files.push({ path: filePath, lines: "*" });
|
|
707
|
+
break;
|
|
708
|
+
}
|
|
709
|
+
const [s, e] = rt.split("-").map((v) => parseInt(v.trim(), 10));
|
|
862
710
|
if (Number.isFinite(s) && Number.isFinite(e)) {
|
|
863
711
|
ranges.push([s, e]);
|
|
864
712
|
} else if (Number.isFinite(s)) {
|
|
865
713
|
ranges.push([s, s]);
|
|
866
714
|
}
|
|
867
715
|
}
|
|
868
|
-
if (ranges.length
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
} else if (ranges.length > 1) {
|
|
872
|
-
args.lines = ranges;
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
tools.push({ name: "read", arguments: args });
|
|
876
|
-
}
|
|
877
|
-
} else if (toolName === "finish") {
|
|
878
|
-
const fileRegex = /<file>([\s\S]*?)<\/file>/gi;
|
|
879
|
-
const files = [];
|
|
880
|
-
let fileMatch;
|
|
881
|
-
while ((fileMatch = fileRegex.exec(content)) !== null) {
|
|
882
|
-
const fileContent = fileMatch[1];
|
|
883
|
-
const filePath = getXmlElementText(fileContent, "path");
|
|
884
|
-
const linesStr = getXmlElementText(fileContent, "lines");
|
|
885
|
-
if (filePath) {
|
|
886
|
-
if (!linesStr || linesStr.trim() === "*") {
|
|
716
|
+
if (ranges.length > 0) {
|
|
717
|
+
files.push({ path: filePath, lines: ranges });
|
|
718
|
+
} else if (!files.some((f) => f.path === filePath)) {
|
|
887
719
|
files.push({ path: filePath, lines: "*" });
|
|
888
|
-
} else {
|
|
889
|
-
const ranges = [];
|
|
890
|
-
for (const rangeStr of linesStr.split(",")) {
|
|
891
|
-
const [s, e] = rangeStr.split("-").map((v) => parseInt(v.trim(), 10));
|
|
892
|
-
if (Number.isFinite(s) && Number.isFinite(e)) {
|
|
893
|
-
ranges.push([s, e]);
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
if (ranges.length > 0) {
|
|
897
|
-
files.push({ path: filePath, lines: ranges });
|
|
898
|
-
} else {
|
|
899
|
-
files.push({ path: filePath, lines: "*" });
|
|
900
|
-
}
|
|
901
720
|
}
|
|
902
721
|
}
|
|
903
722
|
}
|
|
904
723
|
if (files.length > 0) {
|
|
905
724
|
tools.push({ name: "finish", arguments: { files } });
|
|
906
725
|
} else {
|
|
907
|
-
|
|
908
|
-
const textResult = !raw || raw === "*" ? "No relevant code found." : raw;
|
|
909
|
-
tools.push({ name: "finish", arguments: { files: [], textResult } });
|
|
726
|
+
tools.push({ name: "finish", arguments: { files: [], textResult: filesStr } });
|
|
910
727
|
}
|
|
911
728
|
}
|
|
912
729
|
}
|
|
913
|
-
if (tools.length === 0) {
|
|
914
|
-
const fnFinishMatch = text.match(/<function=finish>([\s\S]*?)<\/function>/i);
|
|
915
|
-
if (fnFinishMatch) {
|
|
916
|
-
const inner = fnFinishMatch[1];
|
|
917
|
-
const paramMatch = inner.match(/<parameter=result>([\s\S]*?)<\/parameter>/i);
|
|
918
|
-
const raw = (paramMatch ? paramMatch[1] : inner).trim();
|
|
919
|
-
const textResult = !raw || raw === "*" ? "No relevant code found." : raw;
|
|
920
|
-
tools.push({ name: "finish", arguments: { files: [], textResult } });
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
730
|
return tools;
|
|
924
731
|
}
|
|
925
|
-
function preprocessText(text) {
|
|
926
|
-
const processed = text.replace(/<think>[\s\S]*?<\/think>/gi, "").replace(/<\/?tool_call>/gi, "");
|
|
927
|
-
const nestedTools = parseNestedXmlTools(processed);
|
|
928
|
-
const toolCallLines = [];
|
|
929
|
-
const allLines = processed.split(/\r?\n/).map((l) => l.trim());
|
|
930
|
-
for (const line of allLines) {
|
|
931
|
-
if (!line) continue;
|
|
932
|
-
if (line.startsWith("<")) continue;
|
|
933
|
-
const firstWord = line.split(/\s/)[0];
|
|
934
|
-
if (VALID_COMMANDS.includes(firstWord)) {
|
|
935
|
-
if (!toolCallLines.includes(line)) {
|
|
936
|
-
toolCallLines.push(line);
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
return { lines: toolCallLines, nestedTools };
|
|
941
|
-
}
|
|
942
732
|
var LLMResponseParser = class {
|
|
943
|
-
finishSpecSplitRe = /,(?=[^,\s]+:)/;
|
|
944
733
|
parse(text) {
|
|
945
734
|
if (typeof text !== "string") {
|
|
946
735
|
throw new TypeError("Command text must be a string.");
|
|
947
736
|
}
|
|
948
|
-
const
|
|
949
|
-
|
|
950
|
-
let finishAccumulator = null;
|
|
951
|
-
lines.forEach((line) => {
|
|
952
|
-
if (!line || line.startsWith("#")) return;
|
|
953
|
-
const parts = this.splitLine(line);
|
|
954
|
-
if (parts.length === 0) return;
|
|
955
|
-
const cmd = parts[0];
|
|
956
|
-
switch (cmd) {
|
|
957
|
-
case "list_directory":
|
|
958
|
-
this.handleListDirectory(parts, line, commands);
|
|
959
|
-
break;
|
|
960
|
-
case "grep":
|
|
961
|
-
this.handleGrep(parts, line, commands);
|
|
962
|
-
break;
|
|
963
|
-
case "read":
|
|
964
|
-
this.handleRead(parts, line, commands);
|
|
965
|
-
break;
|
|
966
|
-
case "finish":
|
|
967
|
-
finishAccumulator = this.handleFinish(parts, line, commands, finishAccumulator);
|
|
968
|
-
break;
|
|
969
|
-
default:
|
|
970
|
-
break;
|
|
971
|
-
}
|
|
972
|
-
});
|
|
973
|
-
if (finishAccumulator) {
|
|
974
|
-
const map = finishAccumulator;
|
|
975
|
-
const entries = [...map.entries()];
|
|
976
|
-
const filesPayload = entries.map(([path5, ranges]) => ({
|
|
977
|
-
path: path5,
|
|
978
|
-
lines: [...ranges].sort((a, b) => a[0] - b[0])
|
|
979
|
-
}));
|
|
980
|
-
commands.push({ name: "finish", arguments: { files: filesPayload } });
|
|
981
|
-
}
|
|
982
|
-
return commands;
|
|
983
|
-
}
|
|
984
|
-
splitLine(line) {
|
|
985
|
-
const parts = [];
|
|
986
|
-
let current = "";
|
|
987
|
-
let inSingle = false;
|
|
988
|
-
for (let i = 0; i < line.length; i++) {
|
|
989
|
-
const ch = line[i];
|
|
990
|
-
if (ch === "'" && line[i - 1] !== "\\") {
|
|
991
|
-
inSingle = !inSingle;
|
|
992
|
-
current += ch;
|
|
993
|
-
} else if (!inSingle && /\s/.test(ch)) {
|
|
994
|
-
if (current) {
|
|
995
|
-
parts.push(current);
|
|
996
|
-
current = "";
|
|
997
|
-
}
|
|
998
|
-
} else {
|
|
999
|
-
current += ch;
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
if (current) parts.push(current);
|
|
1003
|
-
return parts;
|
|
1004
|
-
}
|
|
1005
|
-
/** Helper to create a _skip tool call with an error message */
|
|
1006
|
-
skip(message) {
|
|
1007
|
-
return { name: "_skip", arguments: { message } };
|
|
1008
|
-
}
|
|
1009
|
-
handleListDirectory(parts, rawLine, commands) {
|
|
1010
|
-
if (parts.length < 2) {
|
|
1011
|
-
commands.push(this.skip(
|
|
1012
|
-
`[SKIPPED] Your command "${rawLine}" is missing a path. Correct format: list_directory <path> [pattern]. Example: list_directory src/`
|
|
1013
|
-
));
|
|
1014
|
-
return;
|
|
1015
|
-
}
|
|
1016
|
-
const path5 = parts[1];
|
|
1017
|
-
const pattern = parts[2]?.replace(/^"|"$/g, "") ?? null;
|
|
1018
|
-
commands.push({ name: "list_directory", arguments: { path: path5, pattern } });
|
|
1019
|
-
}
|
|
1020
|
-
handleGrep(parts, rawLine, commands) {
|
|
1021
|
-
if (parts.length < 3) {
|
|
1022
|
-
commands.push(this.skip(
|
|
1023
|
-
`[SKIPPED] Your command "${rawLine}" is missing arguments. Correct format: grep '<pattern>' <path>. Example: grep 'TODO' src/`
|
|
1024
|
-
));
|
|
1025
|
-
return;
|
|
1026
|
-
}
|
|
1027
|
-
let pat = parts[1];
|
|
1028
|
-
if (pat.startsWith("'") && pat.endsWith("'")) {
|
|
1029
|
-
pat = pat.slice(1, -1);
|
|
1030
|
-
}
|
|
1031
|
-
if (!pat) {
|
|
1032
|
-
commands.push(this.skip(
|
|
1033
|
-
`[SKIPPED] Your command "${rawLine}" has an empty pattern. Provide a non-empty search pattern. Example: grep 'function' src/`
|
|
1034
|
-
));
|
|
1035
|
-
return;
|
|
1036
|
-
}
|
|
1037
|
-
commands.push({ name: "grep", arguments: { pattern: pat, path: parts[2] } });
|
|
1038
|
-
}
|
|
1039
|
-
handleRead(parts, rawLine, commands) {
|
|
1040
|
-
if (parts.length < 2) {
|
|
1041
|
-
commands.push(this.skip(
|
|
1042
|
-
`[SKIPPED] Your command "${rawLine}" is missing a path. Correct format: read <path> or read <path>:<start>-<end>. Example: read src/index.ts:1-50`
|
|
1043
|
-
));
|
|
1044
|
-
return;
|
|
1045
|
-
}
|
|
1046
|
-
const spec = parts[1];
|
|
1047
|
-
const rangeIdx = spec.indexOf(":");
|
|
1048
|
-
if (rangeIdx === -1) {
|
|
1049
|
-
commands.push({ name: "read", arguments: { path: spec } });
|
|
1050
|
-
return;
|
|
1051
|
-
}
|
|
1052
|
-
const filePath = spec.slice(0, rangeIdx);
|
|
1053
|
-
const range = spec.slice(rangeIdx + 1);
|
|
1054
|
-
const [s, e] = range.split("-").map((v) => parseInt(v, 10));
|
|
1055
|
-
if (!Number.isFinite(s) || !Number.isFinite(e)) {
|
|
1056
|
-
commands.push({ name: "read", arguments: { path: filePath } });
|
|
1057
|
-
return;
|
|
1058
|
-
}
|
|
1059
|
-
commands.push({ name: "read", arguments: { path: filePath, start: s, end: e } });
|
|
1060
|
-
}
|
|
1061
|
-
handleFinish(parts, rawLine, commands, acc) {
|
|
1062
|
-
const map = acc ?? /* @__PURE__ */ new Map();
|
|
1063
|
-
const args = parts.slice(1);
|
|
1064
|
-
for (const token of args) {
|
|
1065
|
-
const [filePath, rangesText] = token.split(":", 2);
|
|
1066
|
-
if (!filePath || !rangesText) {
|
|
1067
|
-
commands.push(this.skip(
|
|
1068
|
-
`[SKIPPED] Invalid finish token "${token}". Correct format: finish <path>:<start>-<end>. Example: finish src/index.ts:1-50`
|
|
1069
|
-
));
|
|
1070
|
-
continue;
|
|
1071
|
-
}
|
|
1072
|
-
const rangeSpecs = rangesText.split(",").filter(Boolean);
|
|
1073
|
-
for (const spec of rangeSpecs) {
|
|
1074
|
-
const [s, e] = spec.split("-").map((v) => parseInt(v, 10));
|
|
1075
|
-
if (!Number.isFinite(s) || !Number.isFinite(e) || e < s) {
|
|
1076
|
-
commands.push(this.skip(
|
|
1077
|
-
`[SKIPPED] Invalid range "${spec}" in "${token}". Ranges must be <start>-<end> where start <= end. Example: 1-50`
|
|
1078
|
-
));
|
|
1079
|
-
continue;
|
|
1080
|
-
}
|
|
1081
|
-
const arr = map.get(filePath) ?? [];
|
|
1082
|
-
arr.push([s, e]);
|
|
1083
|
-
map.set(filePath, arr);
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
return map;
|
|
737
|
+
const withoutThink = text.replace(/<think>[\s\S]*?<\/think>/gi, "");
|
|
738
|
+
return parseQwen3ToolCalls(withoutThink);
|
|
1087
739
|
}
|
|
1088
740
|
};
|
|
1089
741
|
|
|
@@ -1153,14 +805,12 @@ async function toolListDirectory(provider, args) {
|
|
|
1153
805
|
}
|
|
1154
806
|
const { entries: list } = await getListRecursive(initialDepth);
|
|
1155
807
|
if (!list.length) return "empty";
|
|
1156
|
-
|
|
1157
|
-
return "query not specific enough, tool called tried to return too much context and failed";
|
|
1158
|
-
}
|
|
1159
|
-
return list.map((e) => {
|
|
808
|
+
const tree = list.map((e) => {
|
|
1160
809
|
const indent = " ".repeat(e.depth);
|
|
1161
810
|
const name = e.type === "dir" ? `${e.name}/` : e.name;
|
|
1162
811
|
return `${indent}${name}`;
|
|
1163
812
|
}).join("\n");
|
|
813
|
+
return tree;
|
|
1164
814
|
}
|
|
1165
815
|
|
|
1166
816
|
// tools/warp_grep/agent/tools/finish.ts
|
|
@@ -1231,90 +881,19 @@ function mergeRanges(ranges) {
|
|
|
1231
881
|
|
|
1232
882
|
// tools/warp_grep/agent/formatter.ts
|
|
1233
883
|
var ToolOutputFormatter = class {
|
|
1234
|
-
format(toolName,
|
|
884
|
+
format(toolName, _args, output, options = {}) {
|
|
1235
885
|
const name = (toolName ?? "").trim();
|
|
1236
886
|
if (!name) {
|
|
1237
887
|
return "";
|
|
1238
888
|
}
|
|
1239
889
|
const payload = output?.toString?.()?.trim?.() ?? "";
|
|
1240
890
|
const isError = Boolean(options.isError);
|
|
1241
|
-
const safeArgs = args ?? {};
|
|
1242
891
|
if (!payload && !isError) {
|
|
1243
892
|
return "";
|
|
1244
893
|
}
|
|
1245
|
-
|
|
1246
|
-
case "read":
|
|
1247
|
-
return this.formatRead(safeArgs, payload, isError);
|
|
1248
|
-
case "list_directory":
|
|
1249
|
-
return this.formatListDirectory(safeArgs, payload, isError);
|
|
1250
|
-
case "grep":
|
|
1251
|
-
return this.formatGrep(safeArgs, payload, isError);
|
|
1252
|
-
default:
|
|
1253
|
-
return payload ? `<tool_output>
|
|
1254
|
-
${payload}
|
|
1255
|
-
</tool_output>` : "";
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
formatRead(args, payload, isError) {
|
|
1259
|
-
if (isError) {
|
|
1260
|
-
return payload;
|
|
1261
|
-
}
|
|
1262
|
-
const path5 = this.asString(args.path) || "...";
|
|
1263
|
-
const start = args.start;
|
|
1264
|
-
const end = args.end;
|
|
1265
|
-
const linesArray = args.lines;
|
|
1266
|
-
const attributes = [`path="${path5}"`];
|
|
1267
|
-
if (linesArray && linesArray.length > 0) {
|
|
1268
|
-
const rangeStr = linesArray.map(([s, e]) => `${s}-${e}`).join(",");
|
|
1269
|
-
attributes.push(`lines="${rangeStr}"`);
|
|
1270
|
-
} else if (start !== void 0 && end !== void 0) {
|
|
1271
|
-
attributes.push(`lines="${start}-${end}"`);
|
|
1272
|
-
}
|
|
1273
|
-
return `<read ${attributes.join(" ")}>
|
|
1274
|
-
${payload}
|
|
1275
|
-
</read>`;
|
|
1276
|
-
}
|
|
1277
|
-
formatListDirectory(args, payload, isError) {
|
|
1278
|
-
const path5 = this.asString(args.path) || ".";
|
|
1279
|
-
const pattern = this.asString(args.pattern);
|
|
1280
|
-
const attributes = [`path="${path5}"`];
|
|
1281
|
-
if (pattern) {
|
|
1282
|
-
attributes.push(`pattern="${pattern}"`);
|
|
1283
|
-
}
|
|
1284
|
-
if (isError) {
|
|
1285
|
-
attributes.push('status="error"');
|
|
1286
|
-
}
|
|
1287
|
-
return `<list_directory ${attributes.join(" ")}>
|
|
1288
|
-
${payload}
|
|
1289
|
-
</list_directory>`;
|
|
1290
|
-
}
|
|
1291
|
-
formatGrep(args, payload, isError) {
|
|
1292
|
-
const pattern = this.asString(args.pattern);
|
|
1293
|
-
const subDir = this.asString(args.path);
|
|
1294
|
-
const glob = this.asString(args.glob);
|
|
1295
|
-
const attributes = [];
|
|
1296
|
-
if (pattern !== void 0) {
|
|
1297
|
-
attributes.push(`pattern="${pattern}"`);
|
|
1298
|
-
}
|
|
1299
|
-
if (subDir !== void 0) {
|
|
1300
|
-
attributes.push(`sub_dir="${subDir}"`);
|
|
1301
|
-
}
|
|
1302
|
-
if (glob !== void 0) {
|
|
1303
|
-
attributes.push(`glob="${glob}"`);
|
|
1304
|
-
}
|
|
1305
|
-
if (isError) {
|
|
1306
|
-
attributes.push('status="error"');
|
|
1307
|
-
}
|
|
1308
|
-
const attrText = attributes.length ? ` ${attributes.join(" ")}` : "";
|
|
1309
|
-
return `<grep${attrText}>
|
|
894
|
+
return `<tool_response>
|
|
1310
895
|
${payload}
|
|
1311
|
-
</
|
|
1312
|
-
}
|
|
1313
|
-
asString(value) {
|
|
1314
|
-
if (value === null || value === void 0) {
|
|
1315
|
-
return void 0;
|
|
1316
|
-
}
|
|
1317
|
-
return String(value);
|
|
896
|
+
</tool_response>`;
|
|
1318
897
|
}
|
|
1319
898
|
};
|
|
1320
899
|
var sharedFormatter = new ToolOutputFormatter();
|
|
@@ -1343,12 +922,15 @@ function calculateContextBudget(messages) {
|
|
|
1343
922
|
const maxK = Math.round(maxChars / 1e3);
|
|
1344
923
|
return `<context_budget>${percent}% (${usedK}K/${maxK}K chars)</context_budget>`;
|
|
1345
924
|
}
|
|
1346
|
-
async function buildInitialState(repoRoot, query, provider) {
|
|
925
|
+
async function buildInitialState(repoRoot, query, provider, options) {
|
|
926
|
+
const budget = calculateContextBudget([]);
|
|
927
|
+
const turnTag = `Turn 0/${AGENT_CONFIG.MAX_TURNS}`;
|
|
928
|
+
const treeDepth = options?.query_type === "node_modules" ? 1 : 2;
|
|
1347
929
|
try {
|
|
1348
930
|
const entries = await provider.listDirectory({
|
|
1349
931
|
path: ".",
|
|
1350
932
|
maxResults: AGENT_CONFIG.MAX_OUTPUT_LINES,
|
|
1351
|
-
maxDepth:
|
|
933
|
+
maxDepth: treeDepth
|
|
1352
934
|
});
|
|
1353
935
|
const treeLines = entries.map((e) => {
|
|
1354
936
|
const indent = " ".repeat(e.depth);
|
|
@@ -1364,7 +946,9 @@ ${treeOutput}
|
|
|
1364
946
|
|
|
1365
947
|
<search_string>
|
|
1366
948
|
${query}
|
|
1367
|
-
</search_string
|
|
949
|
+
</search_string>
|
|
950
|
+
${budget}
|
|
951
|
+
${turnTag}`;
|
|
1368
952
|
} catch {
|
|
1369
953
|
const repoName = import_path.default.basename(repoRoot);
|
|
1370
954
|
return `<repo_structure>
|
|
@@ -1373,7 +957,9 @@ ${repoName}/
|
|
|
1373
957
|
|
|
1374
958
|
<search_string>
|
|
1375
959
|
${query}
|
|
1376
|
-
</search_string
|
|
960
|
+
</search_string>
|
|
961
|
+
${budget}
|
|
962
|
+
${turnTag}`;
|
|
1377
963
|
}
|
|
1378
964
|
}
|
|
1379
965
|
function enforceContextLimit(messages, maxChars = AGENT_CONFIG.MAX_CONTEXT_CHARS) {
|
|
@@ -1409,7 +995,7 @@ var import_openai = __toESM(require("openai"), 1);
|
|
|
1409
995
|
// package.json
|
|
1410
996
|
var package_default = {
|
|
1411
997
|
name: "@morphllm/morphsdk",
|
|
1412
|
-
version: "0.2.
|
|
998
|
+
version: "0.2.126",
|
|
1413
999
|
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
1414
1000
|
type: "module",
|
|
1415
1001
|
main: "./dist/index.cjs",
|
|
@@ -1551,7 +1137,7 @@ var package_default = {
|
|
|
1551
1137
|
"!dist/**/*.test.*"
|
|
1552
1138
|
],
|
|
1553
1139
|
scripts: {
|
|
1554
|
-
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/
|
|
1140
|
+
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",
|
|
1555
1141
|
prepare: "npm run build",
|
|
1556
1142
|
typecheck: "tsc --noEmit",
|
|
1557
1143
|
lint: "eslint .",
|
|
@@ -1688,14 +1274,13 @@ async function runWarpGrep(config) {
|
|
|
1688
1274
|
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1689
1275
|
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
1690
1276
|
const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
|
|
1277
|
+
const model = config.model || DEFAULT_MODEL;
|
|
1691
1278
|
const messages = [];
|
|
1692
|
-
|
|
1279
|
+
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1693
1280
|
const initialStateStart = Date.now();
|
|
1694
|
-
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
1281
|
+
const initialState = await buildInitialState(repoRoot, config.query, config.provider, { query_type: config.query_type });
|
|
1695
1282
|
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1696
1283
|
messages.push({ role: "user", content: initialState });
|
|
1697
|
-
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1698
|
-
const model = config.model || DEFAULT_MODEL;
|
|
1699
1284
|
const provider = config.provider;
|
|
1700
1285
|
const errors = [];
|
|
1701
1286
|
let finishMeta;
|
|
@@ -1745,7 +1330,7 @@ async function runWarpGrep(config) {
|
|
|
1745
1330
|
const args = c.arguments ?? {};
|
|
1746
1331
|
allPromises.push(
|
|
1747
1332
|
toolGrep(provider, args).then(
|
|
1748
|
-
({ output }) => formatAgentToolOutput("grep", args, output
|
|
1333
|
+
({ output }) => formatAgentToolOutput("grep", args, output),
|
|
1749
1334
|
(err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
|
|
1750
1335
|
)
|
|
1751
1336
|
);
|
|
@@ -1754,7 +1339,7 @@ async function runWarpGrep(config) {
|
|
|
1754
1339
|
const args = c.arguments ?? {};
|
|
1755
1340
|
allPromises.push(
|
|
1756
1341
|
toolListDirectory(provider, args).then(
|
|
1757
|
-
(p) => formatAgentToolOutput("list_directory", args, p
|
|
1342
|
+
(p) => formatAgentToolOutput("list_directory", args, p),
|
|
1758
1343
|
(err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
|
|
1759
1344
|
)
|
|
1760
1345
|
);
|
|
@@ -1763,7 +1348,7 @@ async function runWarpGrep(config) {
|
|
|
1763
1348
|
const args = c.arguments ?? {};
|
|
1764
1349
|
allPromises.push(
|
|
1765
1350
|
toolRead(provider, args).then(
|
|
1766
|
-
(p) => formatAgentToolOutput("read", args, p
|
|
1351
|
+
(p) => formatAgentToolOutput("read", args, p),
|
|
1767
1352
|
(err) => formatAgentToolOutput("read", args, String(err), { isError: true })
|
|
1768
1353
|
)
|
|
1769
1354
|
);
|
|
@@ -1847,14 +1432,13 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1847
1432
|
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1848
1433
|
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
1849
1434
|
const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
|
|
1435
|
+
const model = config.model || DEFAULT_MODEL;
|
|
1850
1436
|
const messages = [];
|
|
1851
|
-
|
|
1437
|
+
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1852
1438
|
const initialStateStart = Date.now();
|
|
1853
|
-
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
1439
|
+
const initialState = await buildInitialState(repoRoot, config.query, config.provider, { query_type: config.query_type });
|
|
1854
1440
|
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1855
1441
|
messages.push({ role: "user", content: initialState });
|
|
1856
|
-
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1857
|
-
const model = config.model || DEFAULT_MODEL;
|
|
1858
1442
|
const provider = config.provider;
|
|
1859
1443
|
const errors = [];
|
|
1860
1444
|
let finishMeta;
|
|
@@ -1911,7 +1495,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1911
1495
|
const args = c.arguments ?? {};
|
|
1912
1496
|
allPromises.push(
|
|
1913
1497
|
toolGrep(provider, args).then(
|
|
1914
|
-
({ output }) => formatAgentToolOutput("grep", args, output
|
|
1498
|
+
({ output }) => formatAgentToolOutput("grep", args, output),
|
|
1915
1499
|
(err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
|
|
1916
1500
|
)
|
|
1917
1501
|
);
|
|
@@ -1920,7 +1504,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1920
1504
|
const args = c.arguments ?? {};
|
|
1921
1505
|
allPromises.push(
|
|
1922
1506
|
toolListDirectory(provider, args).then(
|
|
1923
|
-
(p) => formatAgentToolOutput("list_directory", args, p
|
|
1507
|
+
(p) => formatAgentToolOutput("list_directory", args, p),
|
|
1924
1508
|
(err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
|
|
1925
1509
|
)
|
|
1926
1510
|
);
|
|
@@ -1929,7 +1513,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1929
1513
|
const args = c.arguments ?? {};
|
|
1930
1514
|
allPromises.push(
|
|
1931
1515
|
toolRead(provider, args).then(
|
|
1932
|
-
(p) => formatAgentToolOutput("read", args, p
|
|
1516
|
+
(p) => formatAgentToolOutput("read", args, p),
|
|
1933
1517
|
(err) => formatAgentToolOutput("read", args, String(err), { isError: true })
|
|
1934
1518
|
)
|
|
1935
1519
|
);
|
|
@@ -2107,10 +1691,9 @@ var RemoteCommandsProvider = class {
|
|
|
2107
1691
|
const stdout = await this.commands.grep(params.pattern, params.path, params.glob);
|
|
2108
1692
|
const lines = (stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
2109
1693
|
if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
};
|
|
1694
|
+
const truncated = lines.slice(0, AGENT_CONFIG.MAX_OUTPUT_LINES);
|
|
1695
|
+
truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);
|
|
1696
|
+
return { lines: truncated };
|
|
2114
1697
|
}
|
|
2115
1698
|
return { lines };
|
|
2116
1699
|
} catch (error) {
|
|
@@ -2140,7 +1723,7 @@ var RemoteCommandsProvider = class {
|
|
|
2140
1723
|
const lines = contentLines.map((content, idx) => `${start + idx}|${content}`);
|
|
2141
1724
|
if (lines.length > AGENT_CONFIG.MAX_READ_LINES) {
|
|
2142
1725
|
const truncated = lines.slice(0, AGENT_CONFIG.MAX_READ_LINES);
|
|
2143
|
-
truncated.push(`...
|
|
1726
|
+
truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_READ_LINES} of ${lines.length} lines)`);
|
|
2144
1727
|
return { lines: truncated };
|
|
2145
1728
|
}
|
|
2146
1729
|
return { lines };
|
|
@@ -2555,7 +2138,6 @@ var warpGrepInputSchema = import_zod.z.object({
|
|
|
2555
2138
|
LocalRipgrepProvider,
|
|
2556
2139
|
RemoteCommandsProvider,
|
|
2557
2140
|
WARP_GREP_DESCRIPTION,
|
|
2558
|
-
WARP_GREP_SYSTEM_PROMPT,
|
|
2559
2141
|
WARP_GREP_TOOL_NAME,
|
|
2560
2142
|
WarpGrepClient,
|
|
2561
2143
|
createCodeStorageHttpCommands,
|
|
@@ -2565,7 +2147,6 @@ var warpGrepInputSchema = import_zod.z.object({
|
|
|
2565
2147
|
fixPathRepetition,
|
|
2566
2148
|
formatGitHubReadFileResult,
|
|
2567
2149
|
formatResult,
|
|
2568
|
-
getSystemPrompt,
|
|
2569
2150
|
normalizeFinishFiles,
|
|
2570
2151
|
readFinishFiles,
|
|
2571
2152
|
runWarpGrep,
|