@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();
|
|
@@ -578,7 +585,6 @@ __export(openai_exports, {
|
|
|
578
585
|
default: () => openai_default,
|
|
579
586
|
execute: () => execute,
|
|
580
587
|
formatResult: () => formatResult,
|
|
581
|
-
getSystemPrompt: () => getSystemPrompt,
|
|
582
588
|
warpGrepTool: () => warpGrepTool
|
|
583
589
|
});
|
|
584
590
|
module.exports = __toCommonJS(openai_exports);
|
|
@@ -586,483 +592,130 @@ module.exports = __toCommonJS(openai_exports);
|
|
|
586
592
|
// tools/warp_grep/agent/runner.ts
|
|
587
593
|
init_config();
|
|
588
594
|
|
|
589
|
-
// tools/warp_grep/agent/prompt.ts
|
|
590
|
-
var SYSTEM_PROMPT = `You are a code search agent. Your task is to find all relevant code for a given search_string.
|
|
591
|
-
|
|
592
|
-
### workflow
|
|
593
|
-
You have exactly 4 turns. The 4th turn MUST be a \`finish\` call. Each turn allows up to 8 parallel tool calls.
|
|
594
|
-
|
|
595
|
-
- Turn 1: Map the territory OR dive deep (based on search_string specificity)
|
|
596
|
-
- Turn 2-3: Refine based on findings
|
|
597
|
-
- Turn 4: MUST call \`finish\` with all relevant code locations
|
|
598
|
-
- You MAY call \`finish\` early if confident\u2014but never before at least 1 search turn.
|
|
599
|
-
- The user strongly prefers if you can call the finish tool early, but you must be correct
|
|
600
|
-
|
|
601
|
-
Remember, if the task feels easy to you, it is strongly desirable to call 'finish' early using fewer turns, but quality over speed
|
|
602
|
-
|
|
603
|
-
### tools
|
|
604
|
-
Tool calls use nested XML elements:
|
|
605
|
-
\`\`\`xml
|
|
606
|
-
<tool_name>
|
|
607
|
-
<parameter>value</parameter>
|
|
608
|
-
</tool_name>
|
|
609
|
-
\`\`\`
|
|
610
|
-
|
|
611
|
-
### \`list_directory\`
|
|
612
|
-
Directory tree view. Shows structure of a path, optionally filtered by regex pattern.
|
|
613
|
-
|
|
614
|
-
Elements:
|
|
615
|
-
- \`<path>\` (required): Directory path to list (use \`.\` for repo root)
|
|
616
|
-
- \`<pattern>\` (optional): Regex to filter results
|
|
617
|
-
|
|
618
|
-
Examples:
|
|
619
|
-
\`\`\`
|
|
620
|
-
<list_directory>
|
|
621
|
-
<path>src/services</path>
|
|
622
|
-
</list_directory>
|
|
623
|
-
|
|
624
|
-
<list_directory>
|
|
625
|
-
<path>lib/utils</path>
|
|
626
|
-
<pattern>.*\\.(ts|js)$</pattern>
|
|
627
|
-
</list_directory>
|
|
628
|
-
\`\`\`
|
|
629
|
-
|
|
630
|
-
### \`read\`
|
|
631
|
-
Read file contents. Supports multiple line ranges.
|
|
632
|
-
- Returns numbered lines for easy reference
|
|
633
|
-
- ALWAYS include import statements (usually lines 1-20). Better to over-include than miss context.
|
|
634
|
-
|
|
635
|
-
Elements:
|
|
636
|
-
- \`<path>\` (required): File path to read
|
|
637
|
-
- \`<lines>\` (optional): Line ranges like "1-50,75-80,100-120" (omit to read entire file)
|
|
638
|
-
|
|
639
|
-
Examples:
|
|
640
|
-
\`\`\`
|
|
641
|
-
<read>
|
|
642
|
-
<path>src/main.py</path>
|
|
643
|
-
</read>
|
|
644
|
-
|
|
645
|
-
<read>
|
|
646
|
-
<path>src/auth.py</path>
|
|
647
|
-
<lines>1-20,45-80,150-200</lines>
|
|
648
|
-
</read>
|
|
649
|
-
\`\`\`
|
|
650
|
-
|
|
651
|
-
### \`grep\`
|
|
652
|
-
Search for pattern matches across files. Returns matches with 1 line of context above and below.
|
|
653
|
-
- Match lines use \`:\` separator \u2192 \`filepath:linenum:content\`
|
|
654
|
-
- Context lines use \`-\` separator \u2192 \`filepath-linenum-content\`
|
|
655
|
-
|
|
656
|
-
Elements:
|
|
657
|
-
- \`<pattern>\` (required): Search pattern (regex). Use \`(a|b)\` for OR patterns.
|
|
658
|
-
- \`<sub_dir>\` (optional): Subdirectory to search in (defaults to \`.\`)
|
|
659
|
-
- \`<glob>\` (optional): File pattern filter like \`*.py\` or \`*.{ts,tsx}\`
|
|
660
|
-
|
|
661
|
-
Examples:
|
|
662
|
-
\`\`\`
|
|
663
|
-
<grep>
|
|
664
|
-
<pattern>(authenticate|authorize|login)</pattern>
|
|
665
|
-
<sub_dir>src/auth/</sub_dir>
|
|
666
|
-
</grep>
|
|
667
|
-
|
|
668
|
-
<grep>
|
|
669
|
-
<pattern>class.*(Service|Controller)</pattern>
|
|
670
|
-
<glob>*.{ts,js}</glob>
|
|
671
|
-
</grep>
|
|
672
|
-
|
|
673
|
-
<grep>
|
|
674
|
-
<pattern>(DB_HOST|DATABASE_URL|connection)</pattern>
|
|
675
|
-
<glob>*.{py,yaml,env}</glob>
|
|
676
|
-
<sub_dir>lib/</sub_dir>
|
|
677
|
-
</grep>
|
|
678
|
-
\`\`\`
|
|
679
|
-
|
|
680
|
-
### \`finish\`
|
|
681
|
-
Submit final answer with all relevant code locations. Uses nested \`<file>\` elements.
|
|
682
|
-
|
|
683
|
-
File elements:
|
|
684
|
-
- \`<path>\` (required): File path
|
|
685
|
-
- \`<lines>\` (optional): Line ranges like "1-50,75-80" (\`*\` for entire file)
|
|
686
|
-
|
|
687
|
-
ALWAYS include import statements (usually lines 1-20). Better to over-include than miss context.
|
|
688
|
-
|
|
689
|
-
Examples:
|
|
690
|
-
\`\`\`
|
|
691
|
-
<finish>
|
|
692
|
-
<file>
|
|
693
|
-
<path>src/auth.py</path>
|
|
694
|
-
<lines>1-15,25-50,75-80</lines>
|
|
695
|
-
</file>
|
|
696
|
-
<file>
|
|
697
|
-
<path>src/models/user.py</path>
|
|
698
|
-
<lines>*</lines>
|
|
699
|
-
</file>
|
|
700
|
-
</finish>
|
|
701
|
-
\`\`\`
|
|
702
|
-
</tools>
|
|
703
|
-
|
|
704
|
-
<strategy>
|
|
705
|
-
**Before your first tool call, classify the search_string:**
|
|
706
|
-
|
|
707
|
-
| Search_string Type | Round 1 Strategy | Early Finish? |
|
|
708
|
-
|------------|------------------|---------------|
|
|
709
|
-
| **Specific** (function name, error string, unique identifier) | 8 parallel greps on likely paths | Often by round 2 |
|
|
710
|
-
| **Conceptual** (how does X work, where is Y handled) | list_directory + 2-3 broad greps | Rarely early |
|
|
711
|
-
| **Exploratory** (find all tests, list API endpoints) | list_directory at multiple depths | Usually needs 3 rounds |
|
|
712
|
-
|
|
713
|
-
**Parallel call patterns:**
|
|
714
|
-
- **Shotgun grep**: Same pattern, 8 different directories\u2014fast coverage
|
|
715
|
-
- **Variant grep**: 8 pattern variations (synonyms, naming conventions)\u2014catches inconsistent codebases
|
|
716
|
-
- **Funnel**: 1 list_directory + 7 greps\u2014orient and search simultaneously
|
|
717
|
-
- **Deep read**: 8 reads on files you already identified\u2014gather full context fast
|
|
718
|
-
|
|
719
|
-
**Tool call expectations:**
|
|
720
|
-
- 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.
|
|
721
|
-
- 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.
|
|
722
|
-
- 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.
|
|
723
|
-
- 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.
|
|
724
|
-
</strategy>
|
|
725
|
-
|
|
726
|
-
<output_format>
|
|
727
|
-
EVERY response MUST follow this exact format:
|
|
728
|
-
|
|
729
|
-
1. First, wrap your reasoning in \`<think>...</think>\` tags containing:
|
|
730
|
-
- Search_string classification (specific/conceptual/exploratory)
|
|
731
|
-
- Confidence estimate (can I finish in 1-2 rounds?)
|
|
732
|
-
- This round's parallel strategy
|
|
733
|
-
- What signals would let me finish early?
|
|
734
|
-
|
|
735
|
-
2. Then, output up to 8 tool calls using nested XML elements.
|
|
736
|
-
|
|
737
|
-
Example:
|
|
738
|
-
\`\`\`
|
|
739
|
-
<think>
|
|
740
|
-
This is a specific search_string about authentication. I'll grep for auth-related patterns.
|
|
741
|
-
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
|
|
742
|
-
Strategy: Shotgun grep across likely directories.
|
|
743
|
-
</think>
|
|
744
|
-
<grep>
|
|
745
|
-
<pattern>(authenticate|login|session)</pattern>
|
|
746
|
-
<sub_dir>src/auth/</sub_dir>
|
|
747
|
-
</grep>
|
|
748
|
-
<grep>
|
|
749
|
-
<pattern>(middleware|interceptor)</pattern>
|
|
750
|
-
<glob>*.{ts,js}</glob>
|
|
751
|
-
</grep>
|
|
752
|
-
<list_directory>
|
|
753
|
-
<path>src/auth</path>
|
|
754
|
-
</list_directory>
|
|
755
|
-
\`\`\`
|
|
756
|
-
|
|
757
|
-
Finishing example:
|
|
758
|
-
\`\`\`
|
|
759
|
-
<think>
|
|
760
|
-
I think I have a rough idea, but this is my last turn so I must call the finish tool regardless.
|
|
761
|
-
</think>
|
|
762
|
-
<finish>
|
|
763
|
-
<file>
|
|
764
|
-
<path>src/auth/login.py</path>
|
|
765
|
-
<lines>1-50</lines>
|
|
766
|
-
</file>
|
|
767
|
-
<file>
|
|
768
|
-
<path>src/middleware/session.py</path>
|
|
769
|
-
<lines>10-80</lines>
|
|
770
|
-
</file>
|
|
771
|
-
</finish>
|
|
772
|
-
\`\`\`
|
|
773
|
-
|
|
774
|
-
No commentary outside \`<think>\`. No explanations after tool calls.
|
|
775
|
-
</output_format>
|
|
776
|
-
|
|
777
|
-
use as all 8 tool calls to be optimal
|
|
778
|
-
|
|
779
|
-
<finishing_requirements>
|
|
780
|
-
When calling \`finish\`:
|
|
781
|
-
- Include the import section (typically lines 1-20) of each file
|
|
782
|
-
- Include all function/class definitions that are relevant
|
|
783
|
-
- Include any type definitions, interfaces, or constants used
|
|
784
|
-
- Better to over-include than leave the user missing context
|
|
785
|
-
- If unsure about boundaries, include more rather than less
|
|
786
|
-
</finishing_requirements>`;
|
|
787
|
-
function getSystemPrompt() {
|
|
788
|
-
return SYSTEM_PROMPT;
|
|
789
|
-
}
|
|
790
|
-
|
|
791
595
|
// tools/warp_grep/agent/parser.ts
|
|
792
|
-
var VALID_COMMANDS = ["list_directory", "
|
|
596
|
+
var VALID_COMMANDS = ["list_directory", "ripgrep", "read", "finish"];
|
|
793
597
|
function isValidCommand(name) {
|
|
794
598
|
return VALID_COMMANDS.includes(name);
|
|
795
599
|
}
|
|
796
|
-
function
|
|
797
|
-
const regex = new RegExp(`<${tagName}>([\\s\\S]*?)</${tagName}>`, "i");
|
|
798
|
-
const match = xml.match(regex);
|
|
799
|
-
return match ? match[1].trim() : null;
|
|
800
|
-
}
|
|
801
|
-
function parseNestedXmlTools(text) {
|
|
600
|
+
function parseQwen3ToolCalls(text) {
|
|
802
601
|
const tools = [];
|
|
803
|
-
const
|
|
602
|
+
const toolCallRegex = /<tool_call>\s*<function=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/function>\s*<\/tool_call>/gi;
|
|
804
603
|
let match;
|
|
805
|
-
while ((match =
|
|
806
|
-
const
|
|
807
|
-
const
|
|
808
|
-
if (!isValidCommand(
|
|
809
|
-
const
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
604
|
+
while ((match = toolCallRegex.exec(text)) !== null) {
|
|
605
|
+
const funcName = match[1].toLowerCase();
|
|
606
|
+
const body = match[2];
|
|
607
|
+
if (!isValidCommand(funcName)) continue;
|
|
608
|
+
const params = {};
|
|
609
|
+
const paramRegex = /<parameter=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/parameter>/gi;
|
|
610
|
+
let paramMatch;
|
|
611
|
+
while ((paramMatch = paramRegex.exec(body)) !== null) {
|
|
612
|
+
params[paramMatch[1].toLowerCase()] = paramMatch[2].trim();
|
|
613
|
+
}
|
|
614
|
+
if (funcName === "ripgrep") {
|
|
615
|
+
const pattern = params.pattern;
|
|
616
|
+
if (!pattern) continue;
|
|
617
|
+
const args = {
|
|
618
|
+
pattern,
|
|
619
|
+
path: params.path || ".",
|
|
620
|
+
...params.glob && { glob: params.glob },
|
|
621
|
+
...params.context_lines && { context_lines: parseInt(params.context_lines, 10) },
|
|
622
|
+
...params.case_sensitive && { case_sensitive: params.case_sensitive === "true" }
|
|
623
|
+
};
|
|
624
|
+
tools.push({ name: "grep", arguments: args });
|
|
625
|
+
} else if (funcName === "list_directory") {
|
|
626
|
+
const command = params.command;
|
|
627
|
+
const directPath = params.path;
|
|
628
|
+
let dirPath = directPath || ".";
|
|
629
|
+
if (!directPath && command) {
|
|
630
|
+
const tokens = command.trim().split(/\s+/);
|
|
631
|
+
const pathTokens = tokens.slice(1).filter((t) => !t.startsWith("-") && !t.startsWith("|") && !t.startsWith("\\("));
|
|
632
|
+
if (pathTokens.length > 0) {
|
|
633
|
+
dirPath = pathTokens[0];
|
|
634
|
+
}
|
|
815
635
|
}
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
const
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
636
|
+
tools.push({ name: "list_directory", arguments: { path: dirPath, pattern: params.pattern || null } });
|
|
637
|
+
} else if (funcName === "read") {
|
|
638
|
+
const filePath = params.path;
|
|
639
|
+
if (!filePath) continue;
|
|
640
|
+
const args = { path: filePath };
|
|
641
|
+
const linesStr = params.lines;
|
|
642
|
+
if (linesStr) {
|
|
643
|
+
const ranges = [];
|
|
644
|
+
for (const rangeStr of linesStr.split(",")) {
|
|
645
|
+
const trimmed = rangeStr.trim();
|
|
646
|
+
if (!trimmed) continue;
|
|
647
|
+
const [s, e] = trimmed.split("-").map((v) => parseInt(v.trim(), 10));
|
|
648
|
+
if (Number.isFinite(s) && Number.isFinite(e)) {
|
|
649
|
+
ranges.push([s, e]);
|
|
650
|
+
} else if (Number.isFinite(s)) {
|
|
651
|
+
ranges.push([s, s]);
|
|
827
652
|
}
|
|
828
|
-
}
|
|
653
|
+
}
|
|
654
|
+
if (ranges.length === 1) {
|
|
655
|
+
args.start = ranges[0][0];
|
|
656
|
+
args.end = ranges[0][1];
|
|
657
|
+
} else if (ranges.length > 1) {
|
|
658
|
+
args.lines = ranges;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
tools.push({ name: "read", arguments: args });
|
|
662
|
+
} else if (funcName === "finish") {
|
|
663
|
+
if (params.result && !params.files) {
|
|
664
|
+
tools.push({ name: "finish", arguments: { files: [], textResult: params.result } });
|
|
665
|
+
continue;
|
|
666
|
+
}
|
|
667
|
+
const filesStr = params.files;
|
|
668
|
+
if (!filesStr) {
|
|
669
|
+
tools.push({ name: "finish", arguments: { files: [], textResult: "No relevant code found." } });
|
|
670
|
+
continue;
|
|
829
671
|
}
|
|
830
|
-
|
|
831
|
-
const
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
const
|
|
835
|
-
if (
|
|
672
|
+
const files = [];
|
|
673
|
+
for (const line of filesStr.split("\n")) {
|
|
674
|
+
const trimmed = line.trim();
|
|
675
|
+
if (!trimmed) continue;
|
|
676
|
+
const colonIdx = trimmed.indexOf(":");
|
|
677
|
+
if (colonIdx === -1) {
|
|
678
|
+
files.push({ path: trimmed, lines: "*" });
|
|
679
|
+
} else {
|
|
680
|
+
const filePath = trimmed.slice(0, colonIdx);
|
|
681
|
+
const rangesPart = trimmed.slice(colonIdx + 1);
|
|
836
682
|
const ranges = [];
|
|
837
|
-
for (const rangeStr of
|
|
838
|
-
const
|
|
839
|
-
if (!
|
|
840
|
-
|
|
683
|
+
for (const rangeStr of rangesPart.split(",")) {
|
|
684
|
+
const rt = rangeStr.trim();
|
|
685
|
+
if (!rt || rt === "*") {
|
|
686
|
+
files.push({ path: filePath, lines: "*" });
|
|
687
|
+
break;
|
|
688
|
+
}
|
|
689
|
+
const [s, e] = rt.split("-").map((v) => parseInt(v.trim(), 10));
|
|
841
690
|
if (Number.isFinite(s) && Number.isFinite(e)) {
|
|
842
691
|
ranges.push([s, e]);
|
|
843
692
|
} else if (Number.isFinite(s)) {
|
|
844
693
|
ranges.push([s, s]);
|
|
845
694
|
}
|
|
846
695
|
}
|
|
847
|
-
if (ranges.length
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
} else if (ranges.length > 1) {
|
|
851
|
-
args.lines = ranges;
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
tools.push({ name: "read", arguments: args });
|
|
855
|
-
}
|
|
856
|
-
} else if (toolName === "finish") {
|
|
857
|
-
const fileRegex = /<file>([\s\S]*?)<\/file>/gi;
|
|
858
|
-
const files = [];
|
|
859
|
-
let fileMatch;
|
|
860
|
-
while ((fileMatch = fileRegex.exec(content)) !== null) {
|
|
861
|
-
const fileContent = fileMatch[1];
|
|
862
|
-
const filePath = getXmlElementText(fileContent, "path");
|
|
863
|
-
const linesStr = getXmlElementText(fileContent, "lines");
|
|
864
|
-
if (filePath) {
|
|
865
|
-
if (!linesStr || linesStr.trim() === "*") {
|
|
696
|
+
if (ranges.length > 0) {
|
|
697
|
+
files.push({ path: filePath, lines: ranges });
|
|
698
|
+
} else if (!files.some((f) => f.path === filePath)) {
|
|
866
699
|
files.push({ path: filePath, lines: "*" });
|
|
867
|
-
} else {
|
|
868
|
-
const ranges = [];
|
|
869
|
-
for (const rangeStr of linesStr.split(",")) {
|
|
870
|
-
const [s, e] = rangeStr.split("-").map((v) => parseInt(v.trim(), 10));
|
|
871
|
-
if (Number.isFinite(s) && Number.isFinite(e)) {
|
|
872
|
-
ranges.push([s, e]);
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
if (ranges.length > 0) {
|
|
876
|
-
files.push({ path: filePath, lines: ranges });
|
|
877
|
-
} else {
|
|
878
|
-
files.push({ path: filePath, lines: "*" });
|
|
879
|
-
}
|
|
880
700
|
}
|
|
881
701
|
}
|
|
882
702
|
}
|
|
883
703
|
if (files.length > 0) {
|
|
884
704
|
tools.push({ name: "finish", arguments: { files } });
|
|
885
705
|
} else {
|
|
886
|
-
|
|
887
|
-
const textResult = !raw || raw === "*" ? "No relevant code found." : raw;
|
|
888
|
-
tools.push({ name: "finish", arguments: { files: [], textResult } });
|
|
706
|
+
tools.push({ name: "finish", arguments: { files: [], textResult: filesStr } });
|
|
889
707
|
}
|
|
890
708
|
}
|
|
891
709
|
}
|
|
892
|
-
if (tools.length === 0) {
|
|
893
|
-
const fnFinishMatch = text.match(/<function=finish>([\s\S]*?)<\/function>/i);
|
|
894
|
-
if (fnFinishMatch) {
|
|
895
|
-
const inner = fnFinishMatch[1];
|
|
896
|
-
const paramMatch = inner.match(/<parameter=result>([\s\S]*?)<\/parameter>/i);
|
|
897
|
-
const raw = (paramMatch ? paramMatch[1] : inner).trim();
|
|
898
|
-
const textResult = !raw || raw === "*" ? "No relevant code found." : raw;
|
|
899
|
-
tools.push({ name: "finish", arguments: { files: [], textResult } });
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
710
|
return tools;
|
|
903
711
|
}
|
|
904
|
-
function preprocessText(text) {
|
|
905
|
-
const processed = text.replace(/<think>[\s\S]*?<\/think>/gi, "").replace(/<\/?tool_call>/gi, "");
|
|
906
|
-
const nestedTools = parseNestedXmlTools(processed);
|
|
907
|
-
const toolCallLines = [];
|
|
908
|
-
const allLines = processed.split(/\r?\n/).map((l) => l.trim());
|
|
909
|
-
for (const line of allLines) {
|
|
910
|
-
if (!line) continue;
|
|
911
|
-
if (line.startsWith("<")) continue;
|
|
912
|
-
const firstWord = line.split(/\s/)[0];
|
|
913
|
-
if (VALID_COMMANDS.includes(firstWord)) {
|
|
914
|
-
if (!toolCallLines.includes(line)) {
|
|
915
|
-
toolCallLines.push(line);
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
return { lines: toolCallLines, nestedTools };
|
|
920
|
-
}
|
|
921
712
|
var LLMResponseParser = class {
|
|
922
|
-
finishSpecSplitRe = /,(?=[^,\s]+:)/;
|
|
923
713
|
parse(text) {
|
|
924
714
|
if (typeof text !== "string") {
|
|
925
715
|
throw new TypeError("Command text must be a string.");
|
|
926
716
|
}
|
|
927
|
-
const
|
|
928
|
-
|
|
929
|
-
let finishAccumulator = null;
|
|
930
|
-
lines.forEach((line) => {
|
|
931
|
-
if (!line || line.startsWith("#")) return;
|
|
932
|
-
const parts = this.splitLine(line);
|
|
933
|
-
if (parts.length === 0) return;
|
|
934
|
-
const cmd = parts[0];
|
|
935
|
-
switch (cmd) {
|
|
936
|
-
case "list_directory":
|
|
937
|
-
this.handleListDirectory(parts, line, commands);
|
|
938
|
-
break;
|
|
939
|
-
case "grep":
|
|
940
|
-
this.handleGrep(parts, line, commands);
|
|
941
|
-
break;
|
|
942
|
-
case "read":
|
|
943
|
-
this.handleRead(parts, line, commands);
|
|
944
|
-
break;
|
|
945
|
-
case "finish":
|
|
946
|
-
finishAccumulator = this.handleFinish(parts, line, commands, finishAccumulator);
|
|
947
|
-
break;
|
|
948
|
-
default:
|
|
949
|
-
break;
|
|
950
|
-
}
|
|
951
|
-
});
|
|
952
|
-
if (finishAccumulator) {
|
|
953
|
-
const map = finishAccumulator;
|
|
954
|
-
const entries = [...map.entries()];
|
|
955
|
-
const filesPayload = entries.map(([path5, ranges]) => ({
|
|
956
|
-
path: path5,
|
|
957
|
-
lines: [...ranges].sort((a, b) => a[0] - b[0])
|
|
958
|
-
}));
|
|
959
|
-
commands.push({ name: "finish", arguments: { files: filesPayload } });
|
|
960
|
-
}
|
|
961
|
-
return commands;
|
|
962
|
-
}
|
|
963
|
-
splitLine(line) {
|
|
964
|
-
const parts = [];
|
|
965
|
-
let current = "";
|
|
966
|
-
let inSingle = false;
|
|
967
|
-
for (let i = 0; i < line.length; i++) {
|
|
968
|
-
const ch = line[i];
|
|
969
|
-
if (ch === "'" && line[i - 1] !== "\\") {
|
|
970
|
-
inSingle = !inSingle;
|
|
971
|
-
current += ch;
|
|
972
|
-
} else if (!inSingle && /\s/.test(ch)) {
|
|
973
|
-
if (current) {
|
|
974
|
-
parts.push(current);
|
|
975
|
-
current = "";
|
|
976
|
-
}
|
|
977
|
-
} else {
|
|
978
|
-
current += ch;
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
if (current) parts.push(current);
|
|
982
|
-
return parts;
|
|
983
|
-
}
|
|
984
|
-
/** Helper to create a _skip tool call with an error message */
|
|
985
|
-
skip(message) {
|
|
986
|
-
return { name: "_skip", arguments: { message } };
|
|
987
|
-
}
|
|
988
|
-
handleListDirectory(parts, rawLine, commands) {
|
|
989
|
-
if (parts.length < 2) {
|
|
990
|
-
commands.push(this.skip(
|
|
991
|
-
`[SKIPPED] Your command "${rawLine}" is missing a path. Correct format: list_directory <path> [pattern]. Example: list_directory src/`
|
|
992
|
-
));
|
|
993
|
-
return;
|
|
994
|
-
}
|
|
995
|
-
const path5 = parts[1];
|
|
996
|
-
const pattern = parts[2]?.replace(/^"|"$/g, "") ?? null;
|
|
997
|
-
commands.push({ name: "list_directory", arguments: { path: path5, pattern } });
|
|
998
|
-
}
|
|
999
|
-
handleGrep(parts, rawLine, commands) {
|
|
1000
|
-
if (parts.length < 3) {
|
|
1001
|
-
commands.push(this.skip(
|
|
1002
|
-
`[SKIPPED] Your command "${rawLine}" is missing arguments. Correct format: grep '<pattern>' <path>. Example: grep 'TODO' src/`
|
|
1003
|
-
));
|
|
1004
|
-
return;
|
|
1005
|
-
}
|
|
1006
|
-
let pat = parts[1];
|
|
1007
|
-
if (pat.startsWith("'") && pat.endsWith("'")) {
|
|
1008
|
-
pat = pat.slice(1, -1);
|
|
1009
|
-
}
|
|
1010
|
-
if (!pat) {
|
|
1011
|
-
commands.push(this.skip(
|
|
1012
|
-
`[SKIPPED] Your command "${rawLine}" has an empty pattern. Provide a non-empty search pattern. Example: grep 'function' src/`
|
|
1013
|
-
));
|
|
1014
|
-
return;
|
|
1015
|
-
}
|
|
1016
|
-
commands.push({ name: "grep", arguments: { pattern: pat, path: parts[2] } });
|
|
1017
|
-
}
|
|
1018
|
-
handleRead(parts, rawLine, commands) {
|
|
1019
|
-
if (parts.length < 2) {
|
|
1020
|
-
commands.push(this.skip(
|
|
1021
|
-
`[SKIPPED] Your command "${rawLine}" is missing a path. Correct format: read <path> or read <path>:<start>-<end>. Example: read src/index.ts:1-50`
|
|
1022
|
-
));
|
|
1023
|
-
return;
|
|
1024
|
-
}
|
|
1025
|
-
const spec = parts[1];
|
|
1026
|
-
const rangeIdx = spec.indexOf(":");
|
|
1027
|
-
if (rangeIdx === -1) {
|
|
1028
|
-
commands.push({ name: "read", arguments: { path: spec } });
|
|
1029
|
-
return;
|
|
1030
|
-
}
|
|
1031
|
-
const filePath = spec.slice(0, rangeIdx);
|
|
1032
|
-
const range = spec.slice(rangeIdx + 1);
|
|
1033
|
-
const [s, e] = range.split("-").map((v) => parseInt(v, 10));
|
|
1034
|
-
if (!Number.isFinite(s) || !Number.isFinite(e)) {
|
|
1035
|
-
commands.push({ name: "read", arguments: { path: filePath } });
|
|
1036
|
-
return;
|
|
1037
|
-
}
|
|
1038
|
-
commands.push({ name: "read", arguments: { path: filePath, start: s, end: e } });
|
|
1039
|
-
}
|
|
1040
|
-
handleFinish(parts, rawLine, commands, acc) {
|
|
1041
|
-
const map = acc ?? /* @__PURE__ */ new Map();
|
|
1042
|
-
const args = parts.slice(1);
|
|
1043
|
-
for (const token of args) {
|
|
1044
|
-
const [filePath, rangesText] = token.split(":", 2);
|
|
1045
|
-
if (!filePath || !rangesText) {
|
|
1046
|
-
commands.push(this.skip(
|
|
1047
|
-
`[SKIPPED] Invalid finish token "${token}". Correct format: finish <path>:<start>-<end>. Example: finish src/index.ts:1-50`
|
|
1048
|
-
));
|
|
1049
|
-
continue;
|
|
1050
|
-
}
|
|
1051
|
-
const rangeSpecs = rangesText.split(",").filter(Boolean);
|
|
1052
|
-
for (const spec of rangeSpecs) {
|
|
1053
|
-
const [s, e] = spec.split("-").map((v) => parseInt(v, 10));
|
|
1054
|
-
if (!Number.isFinite(s) || !Number.isFinite(e) || e < s) {
|
|
1055
|
-
commands.push(this.skip(
|
|
1056
|
-
`[SKIPPED] Invalid range "${spec}" in "${token}". Ranges must be <start>-<end> where start <= end. Example: 1-50`
|
|
1057
|
-
));
|
|
1058
|
-
continue;
|
|
1059
|
-
}
|
|
1060
|
-
const arr = map.get(filePath) ?? [];
|
|
1061
|
-
arr.push([s, e]);
|
|
1062
|
-
map.set(filePath, arr);
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
return map;
|
|
717
|
+
const withoutThink = text.replace(/<think>[\s\S]*?<\/think>/gi, "");
|
|
718
|
+
return parseQwen3ToolCalls(withoutThink);
|
|
1066
719
|
}
|
|
1067
720
|
};
|
|
1068
721
|
|
|
@@ -1132,14 +785,12 @@ async function toolListDirectory(provider, args) {
|
|
|
1132
785
|
}
|
|
1133
786
|
const { entries: list } = await getListRecursive(initialDepth);
|
|
1134
787
|
if (!list.length) return "empty";
|
|
1135
|
-
|
|
1136
|
-
return "query not specific enough, tool called tried to return too much context and failed";
|
|
1137
|
-
}
|
|
1138
|
-
return list.map((e) => {
|
|
788
|
+
const tree = list.map((e) => {
|
|
1139
789
|
const indent = " ".repeat(e.depth);
|
|
1140
790
|
const name = e.type === "dir" ? `${e.name}/` : e.name;
|
|
1141
791
|
return `${indent}${name}`;
|
|
1142
792
|
}).join("\n");
|
|
793
|
+
return tree;
|
|
1143
794
|
}
|
|
1144
795
|
|
|
1145
796
|
// tools/warp_grep/agent/tools/finish.ts
|
|
@@ -1202,90 +853,19 @@ function mergeRanges(ranges) {
|
|
|
1202
853
|
|
|
1203
854
|
// tools/warp_grep/agent/formatter.ts
|
|
1204
855
|
var ToolOutputFormatter = class {
|
|
1205
|
-
format(toolName,
|
|
856
|
+
format(toolName, _args, output, options = {}) {
|
|
1206
857
|
const name = (toolName ?? "").trim();
|
|
1207
858
|
if (!name) {
|
|
1208
859
|
return "";
|
|
1209
860
|
}
|
|
1210
861
|
const payload = output?.toString?.()?.trim?.() ?? "";
|
|
1211
862
|
const isError = Boolean(options.isError);
|
|
1212
|
-
const safeArgs = args ?? {};
|
|
1213
863
|
if (!payload && !isError) {
|
|
1214
864
|
return "";
|
|
1215
865
|
}
|
|
1216
|
-
|
|
1217
|
-
case "read":
|
|
1218
|
-
return this.formatRead(safeArgs, payload, isError);
|
|
1219
|
-
case "list_directory":
|
|
1220
|
-
return this.formatListDirectory(safeArgs, payload, isError);
|
|
1221
|
-
case "grep":
|
|
1222
|
-
return this.formatGrep(safeArgs, payload, isError);
|
|
1223
|
-
default:
|
|
1224
|
-
return payload ? `<tool_output>
|
|
866
|
+
return `<tool_response>
|
|
1225
867
|
${payload}
|
|
1226
|
-
</
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
formatRead(args, payload, isError) {
|
|
1230
|
-
if (isError) {
|
|
1231
|
-
return payload;
|
|
1232
|
-
}
|
|
1233
|
-
const path5 = this.asString(args.path) || "...";
|
|
1234
|
-
const start = args.start;
|
|
1235
|
-
const end = args.end;
|
|
1236
|
-
const linesArray = args.lines;
|
|
1237
|
-
const attributes = [`path="${path5}"`];
|
|
1238
|
-
if (linesArray && linesArray.length > 0) {
|
|
1239
|
-
const rangeStr = linesArray.map(([s, e]) => `${s}-${e}`).join(",");
|
|
1240
|
-
attributes.push(`lines="${rangeStr}"`);
|
|
1241
|
-
} else if (start !== void 0 && end !== void 0) {
|
|
1242
|
-
attributes.push(`lines="${start}-${end}"`);
|
|
1243
|
-
}
|
|
1244
|
-
return `<read ${attributes.join(" ")}>
|
|
1245
|
-
${payload}
|
|
1246
|
-
</read>`;
|
|
1247
|
-
}
|
|
1248
|
-
formatListDirectory(args, payload, isError) {
|
|
1249
|
-
const path5 = this.asString(args.path) || ".";
|
|
1250
|
-
const pattern = this.asString(args.pattern);
|
|
1251
|
-
const attributes = [`path="${path5}"`];
|
|
1252
|
-
if (pattern) {
|
|
1253
|
-
attributes.push(`pattern="${pattern}"`);
|
|
1254
|
-
}
|
|
1255
|
-
if (isError) {
|
|
1256
|
-
attributes.push('status="error"');
|
|
1257
|
-
}
|
|
1258
|
-
return `<list_directory ${attributes.join(" ")}>
|
|
1259
|
-
${payload}
|
|
1260
|
-
</list_directory>`;
|
|
1261
|
-
}
|
|
1262
|
-
formatGrep(args, payload, isError) {
|
|
1263
|
-
const pattern = this.asString(args.pattern);
|
|
1264
|
-
const subDir = this.asString(args.path);
|
|
1265
|
-
const glob = this.asString(args.glob);
|
|
1266
|
-
const attributes = [];
|
|
1267
|
-
if (pattern !== void 0) {
|
|
1268
|
-
attributes.push(`pattern="${pattern}"`);
|
|
1269
|
-
}
|
|
1270
|
-
if (subDir !== void 0) {
|
|
1271
|
-
attributes.push(`sub_dir="${subDir}"`);
|
|
1272
|
-
}
|
|
1273
|
-
if (glob !== void 0) {
|
|
1274
|
-
attributes.push(`glob="${glob}"`);
|
|
1275
|
-
}
|
|
1276
|
-
if (isError) {
|
|
1277
|
-
attributes.push('status="error"');
|
|
1278
|
-
}
|
|
1279
|
-
const attrText = attributes.length ? ` ${attributes.join(" ")}` : "";
|
|
1280
|
-
return `<grep${attrText}>
|
|
1281
|
-
${payload}
|
|
1282
|
-
</grep>`;
|
|
1283
|
-
}
|
|
1284
|
-
asString(value) {
|
|
1285
|
-
if (value === null || value === void 0) {
|
|
1286
|
-
return void 0;
|
|
1287
|
-
}
|
|
1288
|
-
return String(value);
|
|
868
|
+
</tool_response>`;
|
|
1289
869
|
}
|
|
1290
870
|
};
|
|
1291
871
|
var sharedFormatter = new ToolOutputFormatter();
|
|
@@ -1314,12 +894,15 @@ function calculateContextBudget(messages) {
|
|
|
1314
894
|
const maxK = Math.round(maxChars / 1e3);
|
|
1315
895
|
return `<context_budget>${percent}% (${usedK}K/${maxK}K chars)</context_budget>`;
|
|
1316
896
|
}
|
|
1317
|
-
async function buildInitialState(repoRoot, query, provider) {
|
|
897
|
+
async function buildInitialState(repoRoot, query, provider, options) {
|
|
898
|
+
const budget = calculateContextBudget([]);
|
|
899
|
+
const turnTag = `Turn 0/${AGENT_CONFIG.MAX_TURNS}`;
|
|
900
|
+
const treeDepth = options?.query_type === "node_modules" ? 1 : 2;
|
|
1318
901
|
try {
|
|
1319
902
|
const entries = await provider.listDirectory({
|
|
1320
903
|
path: ".",
|
|
1321
904
|
maxResults: AGENT_CONFIG.MAX_OUTPUT_LINES,
|
|
1322
|
-
maxDepth:
|
|
905
|
+
maxDepth: treeDepth
|
|
1323
906
|
});
|
|
1324
907
|
const treeLines = entries.map((e) => {
|
|
1325
908
|
const indent = " ".repeat(e.depth);
|
|
@@ -1335,7 +918,9 @@ ${treeOutput}
|
|
|
1335
918
|
|
|
1336
919
|
<search_string>
|
|
1337
920
|
${query}
|
|
1338
|
-
</search_string
|
|
921
|
+
</search_string>
|
|
922
|
+
${budget}
|
|
923
|
+
${turnTag}`;
|
|
1339
924
|
} catch {
|
|
1340
925
|
const repoName = import_path.default.basename(repoRoot);
|
|
1341
926
|
return `<repo_structure>
|
|
@@ -1344,7 +929,9 @@ ${repoName}/
|
|
|
1344
929
|
|
|
1345
930
|
<search_string>
|
|
1346
931
|
${query}
|
|
1347
|
-
</search_string
|
|
932
|
+
</search_string>
|
|
933
|
+
${budget}
|
|
934
|
+
${turnTag}`;
|
|
1348
935
|
}
|
|
1349
936
|
}
|
|
1350
937
|
function enforceContextLimit(messages, maxChars = AGENT_CONFIG.MAX_CONTEXT_CHARS) {
|
|
@@ -1380,7 +967,7 @@ var import_openai = __toESM(require("openai"), 1);
|
|
|
1380
967
|
// package.json
|
|
1381
968
|
var package_default = {
|
|
1382
969
|
name: "@morphllm/morphsdk",
|
|
1383
|
-
version: "0.2.
|
|
970
|
+
version: "0.2.126",
|
|
1384
971
|
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
1385
972
|
type: "module",
|
|
1386
973
|
main: "./dist/index.cjs",
|
|
@@ -1522,7 +1109,7 @@ var package_default = {
|
|
|
1522
1109
|
"!dist/**/*.test.*"
|
|
1523
1110
|
],
|
|
1524
1111
|
scripts: {
|
|
1525
|
-
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/
|
|
1112
|
+
build: "tsup version.ts index.ts edge.ts client.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/providers/code_storage_http.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/github.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts git/index.ts git/client.ts git/config.ts git/types.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/utils/resilience.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve",
|
|
1526
1113
|
prepare: "npm run build",
|
|
1527
1114
|
typecheck: "tsc --noEmit",
|
|
1528
1115
|
lint: "eslint .",
|
|
@@ -1659,14 +1246,13 @@ async function runWarpGrep(config) {
|
|
|
1659
1246
|
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1660
1247
|
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
1661
1248
|
const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
|
|
1249
|
+
const model = config.model || DEFAULT_MODEL;
|
|
1662
1250
|
const messages = [];
|
|
1663
|
-
|
|
1251
|
+
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1664
1252
|
const initialStateStart = Date.now();
|
|
1665
|
-
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
1253
|
+
const initialState = await buildInitialState(repoRoot, config.query, config.provider, { query_type: config.query_type });
|
|
1666
1254
|
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1667
1255
|
messages.push({ role: "user", content: initialState });
|
|
1668
|
-
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1669
|
-
const model = config.model || DEFAULT_MODEL;
|
|
1670
1256
|
const provider = config.provider;
|
|
1671
1257
|
const errors = [];
|
|
1672
1258
|
let finishMeta;
|
|
@@ -1716,7 +1302,7 @@ async function runWarpGrep(config) {
|
|
|
1716
1302
|
const args = c.arguments ?? {};
|
|
1717
1303
|
allPromises.push(
|
|
1718
1304
|
toolGrep(provider, args).then(
|
|
1719
|
-
({ output }) => formatAgentToolOutput("grep", args, output
|
|
1305
|
+
({ output }) => formatAgentToolOutput("grep", args, output),
|
|
1720
1306
|
(err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
|
|
1721
1307
|
)
|
|
1722
1308
|
);
|
|
@@ -1725,7 +1311,7 @@ async function runWarpGrep(config) {
|
|
|
1725
1311
|
const args = c.arguments ?? {};
|
|
1726
1312
|
allPromises.push(
|
|
1727
1313
|
toolListDirectory(provider, args).then(
|
|
1728
|
-
(p) => formatAgentToolOutput("list_directory", args, p
|
|
1314
|
+
(p) => formatAgentToolOutput("list_directory", args, p),
|
|
1729
1315
|
(err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
|
|
1730
1316
|
)
|
|
1731
1317
|
);
|
|
@@ -1734,7 +1320,7 @@ async function runWarpGrep(config) {
|
|
|
1734
1320
|
const args = c.arguments ?? {};
|
|
1735
1321
|
allPromises.push(
|
|
1736
1322
|
toolRead(provider, args).then(
|
|
1737
|
-
(p) => formatAgentToolOutput("read", args, p
|
|
1323
|
+
(p) => formatAgentToolOutput("read", args, p),
|
|
1738
1324
|
(err) => formatAgentToolOutput("read", args, String(err), { isError: true })
|
|
1739
1325
|
)
|
|
1740
1326
|
);
|
|
@@ -1818,14 +1404,13 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1818
1404
|
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1819
1405
|
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
1820
1406
|
const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
|
|
1407
|
+
const model = config.model || DEFAULT_MODEL;
|
|
1821
1408
|
const messages = [];
|
|
1822
|
-
|
|
1409
|
+
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1823
1410
|
const initialStateStart = Date.now();
|
|
1824
|
-
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
1411
|
+
const initialState = await buildInitialState(repoRoot, config.query, config.provider, { query_type: config.query_type });
|
|
1825
1412
|
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1826
1413
|
messages.push({ role: "user", content: initialState });
|
|
1827
|
-
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1828
|
-
const model = config.model || DEFAULT_MODEL;
|
|
1829
1414
|
const provider = config.provider;
|
|
1830
1415
|
const errors = [];
|
|
1831
1416
|
let finishMeta;
|
|
@@ -1882,7 +1467,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1882
1467
|
const args = c.arguments ?? {};
|
|
1883
1468
|
allPromises.push(
|
|
1884
1469
|
toolGrep(provider, args).then(
|
|
1885
|
-
({ output }) => formatAgentToolOutput("grep", args, output
|
|
1470
|
+
({ output }) => formatAgentToolOutput("grep", args, output),
|
|
1886
1471
|
(err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
|
|
1887
1472
|
)
|
|
1888
1473
|
);
|
|
@@ -1891,7 +1476,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1891
1476
|
const args = c.arguments ?? {};
|
|
1892
1477
|
allPromises.push(
|
|
1893
1478
|
toolListDirectory(provider, args).then(
|
|
1894
|
-
(p) => formatAgentToolOutput("list_directory", args, p
|
|
1479
|
+
(p) => formatAgentToolOutput("list_directory", args, p),
|
|
1895
1480
|
(err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
|
|
1896
1481
|
)
|
|
1897
1482
|
);
|
|
@@ -1900,7 +1485,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1900
1485
|
const args = c.arguments ?? {};
|
|
1901
1486
|
allPromises.push(
|
|
1902
1487
|
toolRead(provider, args).then(
|
|
1903
|
-
(p) => formatAgentToolOutput("read", args, p
|
|
1488
|
+
(p) => formatAgentToolOutput("read", args, p),
|
|
1904
1489
|
(err) => formatAgentToolOutput("read", args, String(err), { isError: true })
|
|
1905
1490
|
)
|
|
1906
1491
|
);
|
|
@@ -2078,10 +1663,9 @@ var RemoteCommandsProvider = class {
|
|
|
2078
1663
|
const stdout = await this.commands.grep(params.pattern, params.path, params.glob);
|
|
2079
1664
|
const lines = (stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
2080
1665
|
if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
};
|
|
1666
|
+
const truncated = lines.slice(0, AGENT_CONFIG.MAX_OUTPUT_LINES);
|
|
1667
|
+
truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);
|
|
1668
|
+
return { lines: truncated };
|
|
2085
1669
|
}
|
|
2086
1670
|
return { lines };
|
|
2087
1671
|
} catch (error) {
|
|
@@ -2111,7 +1695,7 @@ var RemoteCommandsProvider = class {
|
|
|
2111
1695
|
const lines = contentLines.map((content, idx) => `${start + idx}|${content}`);
|
|
2112
1696
|
if (lines.length > AGENT_CONFIG.MAX_READ_LINES) {
|
|
2113
1697
|
const truncated = lines.slice(0, AGENT_CONFIG.MAX_READ_LINES);
|
|
2114
|
-
truncated.push(`...
|
|
1698
|
+
truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_READ_LINES} of ${lines.length} lines)`);
|
|
2115
1699
|
return { lines: truncated };
|
|
2116
1700
|
}
|
|
2117
1701
|
return { lines };
|
|
@@ -2529,9 +2113,6 @@ function createWarpGrepTool(config) {
|
|
|
2529
2113
|
},
|
|
2530
2114
|
formatResult: (result) => {
|
|
2531
2115
|
return formatResult(result);
|
|
2532
|
-
},
|
|
2533
|
-
getSystemPrompt: () => {
|
|
2534
|
-
return getSystemPrompt();
|
|
2535
2116
|
}
|
|
2536
2117
|
});
|
|
2537
2118
|
}
|
|
@@ -2551,9 +2132,6 @@ function createGitHubSearchTool(config) {
|
|
|
2551
2132
|
},
|
|
2552
2133
|
formatResult: (result) => {
|
|
2553
2134
|
return formatResult(result);
|
|
2554
|
-
},
|
|
2555
|
-
getSystemPrompt: () => {
|
|
2556
|
-
return getSystemPrompt();
|
|
2557
2135
|
}
|
|
2558
2136
|
});
|
|
2559
2137
|
}
|
|
@@ -2583,7 +2161,6 @@ var openai_default = warpGrepTool;
|
|
|
2583
2161
|
createWarpGrepTool,
|
|
2584
2162
|
execute,
|
|
2585
2163
|
formatResult,
|
|
2586
|
-
getSystemPrompt,
|
|
2587
2164
|
warpGrepTool
|
|
2588
2165
|
});
|
|
2589
2166
|
//# sourceMappingURL=openai.cjs.map
|