@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
package/dist/client.cjs
CHANGED
|
@@ -36,7 +36,7 @@ var init_package = __esm({
|
|
|
36
36
|
"package.json"() {
|
|
37
37
|
package_default = {
|
|
38
38
|
name: "@morphllm/morphsdk",
|
|
39
|
-
version: "0.2.
|
|
39
|
+
version: "0.2.126",
|
|
40
40
|
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
41
41
|
type: "module",
|
|
42
42
|
main: "./dist/index.cjs",
|
|
@@ -178,7 +178,7 @@ var init_package = __esm({
|
|
|
178
178
|
"!dist/**/*.test.*"
|
|
179
179
|
],
|
|
180
180
|
scripts: {
|
|
181
|
-
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/
|
|
181
|
+
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",
|
|
182
182
|
prepare: "npm run build",
|
|
183
183
|
typecheck: "tsc --noEmit",
|
|
184
184
|
lint: "eslint .",
|
|
@@ -490,7 +490,7 @@ var init_config = __esm({
|
|
|
490
490
|
".*"
|
|
491
491
|
];
|
|
492
492
|
DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || "").split(",").map((s) => s.trim()).filter(Boolean).concat(BUILTIN_EXCLUDES);
|
|
493
|
-
DEFAULT_MODEL = "morph-warp-grep-
|
|
493
|
+
DEFAULT_MODEL = "morph-warp-grep-v2";
|
|
494
494
|
}
|
|
495
495
|
});
|
|
496
496
|
|
|
@@ -645,7 +645,8 @@ var local_exports = {};
|
|
|
645
645
|
__export(local_exports, {
|
|
646
646
|
LocalRipgrepProvider: () => LocalRipgrepProvider
|
|
647
647
|
});
|
|
648
|
-
function shouldSkip2(name) {
|
|
648
|
+
function shouldSkip2(name, allowNames) {
|
|
649
|
+
if (allowNames?.has(name)) return false;
|
|
649
650
|
if (SKIP_NAMES2.has(name)) return true;
|
|
650
651
|
if (name.startsWith(".")) return true;
|
|
651
652
|
for (const ext of SKIP_EXTENSIONS2) {
|
|
@@ -740,10 +741,14 @@ var init_local = __esm({
|
|
|
740
741
|
".js.map"
|
|
741
742
|
]);
|
|
742
743
|
LocalRipgrepProvider = class {
|
|
743
|
-
constructor(repoRoot, excludes = DEFAULT_EXCLUDES) {
|
|
744
|
+
constructor(repoRoot, excludes = DEFAULT_EXCLUDES, options) {
|
|
744
745
|
this.repoRoot = repoRoot;
|
|
745
746
|
this.excludes = excludes;
|
|
747
|
+
if (options?.allowNames?.length) {
|
|
748
|
+
this.allowNames = new Set(options.allowNames);
|
|
749
|
+
}
|
|
746
750
|
}
|
|
751
|
+
allowNames;
|
|
747
752
|
async grep(params) {
|
|
748
753
|
let abs;
|
|
749
754
|
try {
|
|
@@ -757,6 +762,7 @@ var init_local = __esm({
|
|
|
757
762
|
const stat = await import_promises2.default.stat(abs).catch(() => null);
|
|
758
763
|
if (!stat) return { lines: [] };
|
|
759
764
|
const targetArg = abs === import_path5.default.resolve(this.repoRoot) ? "." : toRepoRelative(this.repoRoot, abs);
|
|
765
|
+
const contextLines = params.context_lines !== void 0 ? String(params.context_lines) : "1";
|
|
760
766
|
const args = [
|
|
761
767
|
"--no-config",
|
|
762
768
|
"--no-heading",
|
|
@@ -766,9 +772,10 @@ var init_local = __esm({
|
|
|
766
772
|
"--trim",
|
|
767
773
|
"--max-columns=400",
|
|
768
774
|
"-C",
|
|
769
|
-
|
|
775
|
+
contextLines,
|
|
776
|
+
...params.case_sensitive === false ? ["--ignore-case"] : [],
|
|
770
777
|
...params.glob ? ["--glob", params.glob] : [],
|
|
771
|
-
...this.excludes.flatMap((e) => ["-g", `!${e}`]),
|
|
778
|
+
...this.excludes.filter((e) => !this.allowNames?.has(e)).flatMap((e) => ["-g", `!${e}`]),
|
|
772
779
|
params.pattern,
|
|
773
780
|
targetArg || "."
|
|
774
781
|
];
|
|
@@ -793,10 +800,9 @@ Details: ${res.stderr}` : ""}`
|
|
|
793
800
|
}
|
|
794
801
|
const lines = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
795
802
|
if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
};
|
|
803
|
+
const truncated = lines.slice(0, AGENT_CONFIG.MAX_OUTPUT_LINES);
|
|
804
|
+
truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);
|
|
805
|
+
return { lines: truncated };
|
|
800
806
|
}
|
|
801
807
|
return { lines };
|
|
802
808
|
}
|
|
@@ -870,7 +876,7 @@ Details: ${res.stderr}` : ""}`
|
|
|
870
876
|
}
|
|
871
877
|
if (out.length > AGENT_CONFIG.MAX_READ_LINES) {
|
|
872
878
|
const truncated = out.slice(0, AGENT_CONFIG.MAX_READ_LINES);
|
|
873
|
-
truncated.push(`...
|
|
879
|
+
truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_READ_LINES} of ${out.length} lines)`);
|
|
874
880
|
return { lines: truncated };
|
|
875
881
|
}
|
|
876
882
|
return { lines: out };
|
|
@@ -890,6 +896,7 @@ Details: ${res.stderr}` : ""}`
|
|
|
890
896
|
const maxDepth = params.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;
|
|
891
897
|
const regex = params.pattern ? new RegExp(params.pattern) : null;
|
|
892
898
|
const repoRoot = this.repoRoot;
|
|
899
|
+
const allowNames = this.allowNames;
|
|
893
900
|
const results = [];
|
|
894
901
|
let timedOut = false;
|
|
895
902
|
const startTime = Date.now();
|
|
@@ -907,7 +914,7 @@ Details: ${res.stderr}` : ""}`
|
|
|
907
914
|
}
|
|
908
915
|
for (const entry of entries) {
|
|
909
916
|
if (timedOut || results.length >= maxResults) break;
|
|
910
|
-
if (shouldSkip2(entry.name)) continue;
|
|
917
|
+
if (shouldSkip2(entry.name, allowNames)) continue;
|
|
911
918
|
if (regex && !regex.test(entry.name)) continue;
|
|
912
919
|
const full = import_path5.default.join(dir, entry.name);
|
|
913
920
|
const isDir = entry.isDirectory();
|
|
@@ -2470,483 +2477,130 @@ async function checkHealth(config = {}) {
|
|
|
2470
2477
|
// tools/warp_grep/agent/runner.ts
|
|
2471
2478
|
init_config();
|
|
2472
2479
|
|
|
2473
|
-
// tools/warp_grep/agent/prompt.ts
|
|
2474
|
-
var SYSTEM_PROMPT = `You are a code search agent. Your task is to find all relevant code for a given search_string.
|
|
2475
|
-
|
|
2476
|
-
### workflow
|
|
2477
|
-
You have exactly 4 turns. The 4th turn MUST be a \`finish\` call. Each turn allows up to 8 parallel tool calls.
|
|
2478
|
-
|
|
2479
|
-
- Turn 1: Map the territory OR dive deep (based on search_string specificity)
|
|
2480
|
-
- Turn 2-3: Refine based on findings
|
|
2481
|
-
- Turn 4: MUST call \`finish\` with all relevant code locations
|
|
2482
|
-
- You MAY call \`finish\` early if confident\u2014but never before at least 1 search turn.
|
|
2483
|
-
- The user strongly prefers if you can call the finish tool early, but you must be correct
|
|
2484
|
-
|
|
2485
|
-
Remember, if the task feels easy to you, it is strongly desirable to call 'finish' early using fewer turns, but quality over speed
|
|
2486
|
-
|
|
2487
|
-
### tools
|
|
2488
|
-
Tool calls use nested XML elements:
|
|
2489
|
-
\`\`\`xml
|
|
2490
|
-
<tool_name>
|
|
2491
|
-
<parameter>value</parameter>
|
|
2492
|
-
</tool_name>
|
|
2493
|
-
\`\`\`
|
|
2494
|
-
|
|
2495
|
-
### \`list_directory\`
|
|
2496
|
-
Directory tree view. Shows structure of a path, optionally filtered by regex pattern.
|
|
2497
|
-
|
|
2498
|
-
Elements:
|
|
2499
|
-
- \`<path>\` (required): Directory path to list (use \`.\` for repo root)
|
|
2500
|
-
- \`<pattern>\` (optional): Regex to filter results
|
|
2501
|
-
|
|
2502
|
-
Examples:
|
|
2503
|
-
\`\`\`
|
|
2504
|
-
<list_directory>
|
|
2505
|
-
<path>src/services</path>
|
|
2506
|
-
</list_directory>
|
|
2507
|
-
|
|
2508
|
-
<list_directory>
|
|
2509
|
-
<path>lib/utils</path>
|
|
2510
|
-
<pattern>.*\\.(ts|js)$</pattern>
|
|
2511
|
-
</list_directory>
|
|
2512
|
-
\`\`\`
|
|
2513
|
-
|
|
2514
|
-
### \`read\`
|
|
2515
|
-
Read file contents. Supports multiple line ranges.
|
|
2516
|
-
- Returns numbered lines for easy reference
|
|
2517
|
-
- ALWAYS include import statements (usually lines 1-20). Better to over-include than miss context.
|
|
2518
|
-
|
|
2519
|
-
Elements:
|
|
2520
|
-
- \`<path>\` (required): File path to read
|
|
2521
|
-
- \`<lines>\` (optional): Line ranges like "1-50,75-80,100-120" (omit to read entire file)
|
|
2522
|
-
|
|
2523
|
-
Examples:
|
|
2524
|
-
\`\`\`
|
|
2525
|
-
<read>
|
|
2526
|
-
<path>src/main.py</path>
|
|
2527
|
-
</read>
|
|
2528
|
-
|
|
2529
|
-
<read>
|
|
2530
|
-
<path>src/auth.py</path>
|
|
2531
|
-
<lines>1-20,45-80,150-200</lines>
|
|
2532
|
-
</read>
|
|
2533
|
-
\`\`\`
|
|
2534
|
-
|
|
2535
|
-
### \`grep\`
|
|
2536
|
-
Search for pattern matches across files. Returns matches with 1 line of context above and below.
|
|
2537
|
-
- Match lines use \`:\` separator \u2192 \`filepath:linenum:content\`
|
|
2538
|
-
- Context lines use \`-\` separator \u2192 \`filepath-linenum-content\`
|
|
2539
|
-
|
|
2540
|
-
Elements:
|
|
2541
|
-
- \`<pattern>\` (required): Search pattern (regex). Use \`(a|b)\` for OR patterns.
|
|
2542
|
-
- \`<sub_dir>\` (optional): Subdirectory to search in (defaults to \`.\`)
|
|
2543
|
-
- \`<glob>\` (optional): File pattern filter like \`*.py\` or \`*.{ts,tsx}\`
|
|
2544
|
-
|
|
2545
|
-
Examples:
|
|
2546
|
-
\`\`\`
|
|
2547
|
-
<grep>
|
|
2548
|
-
<pattern>(authenticate|authorize|login)</pattern>
|
|
2549
|
-
<sub_dir>src/auth/</sub_dir>
|
|
2550
|
-
</grep>
|
|
2551
|
-
|
|
2552
|
-
<grep>
|
|
2553
|
-
<pattern>class.*(Service|Controller)</pattern>
|
|
2554
|
-
<glob>*.{ts,js}</glob>
|
|
2555
|
-
</grep>
|
|
2556
|
-
|
|
2557
|
-
<grep>
|
|
2558
|
-
<pattern>(DB_HOST|DATABASE_URL|connection)</pattern>
|
|
2559
|
-
<glob>*.{py,yaml,env}</glob>
|
|
2560
|
-
<sub_dir>lib/</sub_dir>
|
|
2561
|
-
</grep>
|
|
2562
|
-
\`\`\`
|
|
2563
|
-
|
|
2564
|
-
### \`finish\`
|
|
2565
|
-
Submit final answer with all relevant code locations. Uses nested \`<file>\` elements.
|
|
2566
|
-
|
|
2567
|
-
File elements:
|
|
2568
|
-
- \`<path>\` (required): File path
|
|
2569
|
-
- \`<lines>\` (optional): Line ranges like "1-50,75-80" (\`*\` for entire file)
|
|
2570
|
-
|
|
2571
|
-
ALWAYS include import statements (usually lines 1-20). Better to over-include than miss context.
|
|
2572
|
-
|
|
2573
|
-
Examples:
|
|
2574
|
-
\`\`\`
|
|
2575
|
-
<finish>
|
|
2576
|
-
<file>
|
|
2577
|
-
<path>src/auth.py</path>
|
|
2578
|
-
<lines>1-15,25-50,75-80</lines>
|
|
2579
|
-
</file>
|
|
2580
|
-
<file>
|
|
2581
|
-
<path>src/models/user.py</path>
|
|
2582
|
-
<lines>*</lines>
|
|
2583
|
-
</file>
|
|
2584
|
-
</finish>
|
|
2585
|
-
\`\`\`
|
|
2586
|
-
</tools>
|
|
2587
|
-
|
|
2588
|
-
<strategy>
|
|
2589
|
-
**Before your first tool call, classify the search_string:**
|
|
2590
|
-
|
|
2591
|
-
| Search_string Type | Round 1 Strategy | Early Finish? |
|
|
2592
|
-
|------------|------------------|---------------|
|
|
2593
|
-
| **Specific** (function name, error string, unique identifier) | 8 parallel greps on likely paths | Often by round 2 |
|
|
2594
|
-
| **Conceptual** (how does X work, where is Y handled) | list_directory + 2-3 broad greps | Rarely early |
|
|
2595
|
-
| **Exploratory** (find all tests, list API endpoints) | list_directory at multiple depths | Usually needs 3 rounds |
|
|
2596
|
-
|
|
2597
|
-
**Parallel call patterns:**
|
|
2598
|
-
- **Shotgun grep**: Same pattern, 8 different directories\u2014fast coverage
|
|
2599
|
-
- **Variant grep**: 8 pattern variations (synonyms, naming conventions)\u2014catches inconsistent codebases
|
|
2600
|
-
- **Funnel**: 1 list_directory + 7 greps\u2014orient and search simultaneously
|
|
2601
|
-
- **Deep read**: 8 reads on files you already identified\u2014gather full context fast
|
|
2602
|
-
|
|
2603
|
-
**Tool call expectations:**
|
|
2604
|
-
- 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.
|
|
2605
|
-
- 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.
|
|
2606
|
-
- 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.
|
|
2607
|
-
- 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.
|
|
2608
|
-
</strategy>
|
|
2609
|
-
|
|
2610
|
-
<output_format>
|
|
2611
|
-
EVERY response MUST follow this exact format:
|
|
2612
|
-
|
|
2613
|
-
1. First, wrap your reasoning in \`<think>...</think>\` tags containing:
|
|
2614
|
-
- Search_string classification (specific/conceptual/exploratory)
|
|
2615
|
-
- Confidence estimate (can I finish in 1-2 rounds?)
|
|
2616
|
-
- This round's parallel strategy
|
|
2617
|
-
- What signals would let me finish early?
|
|
2618
|
-
|
|
2619
|
-
2. Then, output up to 8 tool calls using nested XML elements.
|
|
2620
|
-
|
|
2621
|
-
Example:
|
|
2622
|
-
\`\`\`
|
|
2623
|
-
<think>
|
|
2624
|
-
This is a specific search_string about authentication. I'll grep for auth-related patterns.
|
|
2625
|
-
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
|
|
2626
|
-
Strategy: Shotgun grep across likely directories.
|
|
2627
|
-
</think>
|
|
2628
|
-
<grep>
|
|
2629
|
-
<pattern>(authenticate|login|session)</pattern>
|
|
2630
|
-
<sub_dir>src/auth/</sub_dir>
|
|
2631
|
-
</grep>
|
|
2632
|
-
<grep>
|
|
2633
|
-
<pattern>(middleware|interceptor)</pattern>
|
|
2634
|
-
<glob>*.{ts,js}</glob>
|
|
2635
|
-
</grep>
|
|
2636
|
-
<list_directory>
|
|
2637
|
-
<path>src/auth</path>
|
|
2638
|
-
</list_directory>
|
|
2639
|
-
\`\`\`
|
|
2640
|
-
|
|
2641
|
-
Finishing example:
|
|
2642
|
-
\`\`\`
|
|
2643
|
-
<think>
|
|
2644
|
-
I think I have a rough idea, but this is my last turn so I must call the finish tool regardless.
|
|
2645
|
-
</think>
|
|
2646
|
-
<finish>
|
|
2647
|
-
<file>
|
|
2648
|
-
<path>src/auth/login.py</path>
|
|
2649
|
-
<lines>1-50</lines>
|
|
2650
|
-
</file>
|
|
2651
|
-
<file>
|
|
2652
|
-
<path>src/middleware/session.py</path>
|
|
2653
|
-
<lines>10-80</lines>
|
|
2654
|
-
</file>
|
|
2655
|
-
</finish>
|
|
2656
|
-
\`\`\`
|
|
2657
|
-
|
|
2658
|
-
No commentary outside \`<think>\`. No explanations after tool calls.
|
|
2659
|
-
</output_format>
|
|
2660
|
-
|
|
2661
|
-
use as all 8 tool calls to be optimal
|
|
2662
|
-
|
|
2663
|
-
<finishing_requirements>
|
|
2664
|
-
When calling \`finish\`:
|
|
2665
|
-
- Include the import section (typically lines 1-20) of each file
|
|
2666
|
-
- Include all function/class definitions that are relevant
|
|
2667
|
-
- Include any type definitions, interfaces, or constants used
|
|
2668
|
-
- Better to over-include than leave the user missing context
|
|
2669
|
-
- If unsure about boundaries, include more rather than less
|
|
2670
|
-
</finishing_requirements>`;
|
|
2671
|
-
function getSystemPrompt() {
|
|
2672
|
-
return SYSTEM_PROMPT;
|
|
2673
|
-
}
|
|
2674
|
-
|
|
2675
2480
|
// tools/warp_grep/agent/parser.ts
|
|
2676
|
-
var VALID_COMMANDS = ["list_directory", "
|
|
2481
|
+
var VALID_COMMANDS = ["list_directory", "ripgrep", "read", "finish"];
|
|
2677
2482
|
function isValidCommand(name) {
|
|
2678
2483
|
return VALID_COMMANDS.includes(name);
|
|
2679
2484
|
}
|
|
2680
|
-
function
|
|
2681
|
-
const regex = new RegExp(`<${tagName}>([\\s\\S]*?)</${tagName}>`, "i");
|
|
2682
|
-
const match = xml.match(regex);
|
|
2683
|
-
return match ? match[1].trim() : null;
|
|
2684
|
-
}
|
|
2685
|
-
function parseNestedXmlTools(text) {
|
|
2485
|
+
function parseQwen3ToolCalls(text) {
|
|
2686
2486
|
const tools = [];
|
|
2687
|
-
const
|
|
2487
|
+
const toolCallRegex = /<tool_call>\s*<function=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/function>\s*<\/tool_call>/gi;
|
|
2688
2488
|
let match;
|
|
2689
|
-
while ((match =
|
|
2690
|
-
const
|
|
2691
|
-
const
|
|
2692
|
-
if (!isValidCommand(
|
|
2693
|
-
const
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2489
|
+
while ((match = toolCallRegex.exec(text)) !== null) {
|
|
2490
|
+
const funcName = match[1].toLowerCase();
|
|
2491
|
+
const body = match[2];
|
|
2492
|
+
if (!isValidCommand(funcName)) continue;
|
|
2493
|
+
const params = {};
|
|
2494
|
+
const paramRegex = /<parameter=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/parameter>/gi;
|
|
2495
|
+
let paramMatch;
|
|
2496
|
+
while ((paramMatch = paramRegex.exec(body)) !== null) {
|
|
2497
|
+
params[paramMatch[1].toLowerCase()] = paramMatch[2].trim();
|
|
2498
|
+
}
|
|
2499
|
+
if (funcName === "ripgrep") {
|
|
2500
|
+
const pattern = params.pattern;
|
|
2501
|
+
if (!pattern) continue;
|
|
2502
|
+
const args = {
|
|
2503
|
+
pattern,
|
|
2504
|
+
path: params.path || ".",
|
|
2505
|
+
...params.glob && { glob: params.glob },
|
|
2506
|
+
...params.context_lines && { context_lines: parseInt(params.context_lines, 10) },
|
|
2507
|
+
...params.case_sensitive && { case_sensitive: params.case_sensitive === "true" }
|
|
2508
|
+
};
|
|
2509
|
+
tools.push({ name: "grep", arguments: args });
|
|
2510
|
+
} else if (funcName === "list_directory") {
|
|
2511
|
+
const command = params.command;
|
|
2512
|
+
const directPath = params.path;
|
|
2513
|
+
let dirPath = directPath || ".";
|
|
2514
|
+
if (!directPath && command) {
|
|
2515
|
+
const tokens = command.trim().split(/\s+/);
|
|
2516
|
+
const pathTokens = tokens.slice(1).filter((t) => !t.startsWith("-") && !t.startsWith("|") && !t.startsWith("\\("));
|
|
2517
|
+
if (pathTokens.length > 0) {
|
|
2518
|
+
dirPath = pathTokens[0];
|
|
2519
|
+
}
|
|
2699
2520
|
}
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
const
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2521
|
+
tools.push({ name: "list_directory", arguments: { path: dirPath, pattern: params.pattern || null } });
|
|
2522
|
+
} else if (funcName === "read") {
|
|
2523
|
+
const filePath = params.path;
|
|
2524
|
+
if (!filePath) continue;
|
|
2525
|
+
const args = { path: filePath };
|
|
2526
|
+
const linesStr = params.lines;
|
|
2527
|
+
if (linesStr) {
|
|
2528
|
+
const ranges = [];
|
|
2529
|
+
for (const rangeStr of linesStr.split(",")) {
|
|
2530
|
+
const trimmed = rangeStr.trim();
|
|
2531
|
+
if (!trimmed) continue;
|
|
2532
|
+
const [s, e] = trimmed.split("-").map((v) => parseInt(v.trim(), 10));
|
|
2533
|
+
if (Number.isFinite(s) && Number.isFinite(e)) {
|
|
2534
|
+
ranges.push([s, e]);
|
|
2535
|
+
} else if (Number.isFinite(s)) {
|
|
2536
|
+
ranges.push([s, s]);
|
|
2711
2537
|
}
|
|
2712
|
-
}
|
|
2538
|
+
}
|
|
2539
|
+
if (ranges.length === 1) {
|
|
2540
|
+
args.start = ranges[0][0];
|
|
2541
|
+
args.end = ranges[0][1];
|
|
2542
|
+
} else if (ranges.length > 1) {
|
|
2543
|
+
args.lines = ranges;
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
tools.push({ name: "read", arguments: args });
|
|
2547
|
+
} else if (funcName === "finish") {
|
|
2548
|
+
if (params.result && !params.files) {
|
|
2549
|
+
tools.push({ name: "finish", arguments: { files: [], textResult: params.result } });
|
|
2550
|
+
continue;
|
|
2551
|
+
}
|
|
2552
|
+
const filesStr = params.files;
|
|
2553
|
+
if (!filesStr) {
|
|
2554
|
+
tools.push({ name: "finish", arguments: { files: [], textResult: "No relevant code found." } });
|
|
2555
|
+
continue;
|
|
2713
2556
|
}
|
|
2714
|
-
|
|
2715
|
-
const
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
const
|
|
2719
|
-
if (
|
|
2557
|
+
const files = [];
|
|
2558
|
+
for (const line of filesStr.split("\n")) {
|
|
2559
|
+
const trimmed = line.trim();
|
|
2560
|
+
if (!trimmed) continue;
|
|
2561
|
+
const colonIdx = trimmed.indexOf(":");
|
|
2562
|
+
if (colonIdx === -1) {
|
|
2563
|
+
files.push({ path: trimmed, lines: "*" });
|
|
2564
|
+
} else {
|
|
2565
|
+
const filePath = trimmed.slice(0, colonIdx);
|
|
2566
|
+
const rangesPart = trimmed.slice(colonIdx + 1);
|
|
2720
2567
|
const ranges = [];
|
|
2721
|
-
for (const rangeStr of
|
|
2722
|
-
const
|
|
2723
|
-
if (!
|
|
2724
|
-
|
|
2568
|
+
for (const rangeStr of rangesPart.split(",")) {
|
|
2569
|
+
const rt = rangeStr.trim();
|
|
2570
|
+
if (!rt || rt === "*") {
|
|
2571
|
+
files.push({ path: filePath, lines: "*" });
|
|
2572
|
+
break;
|
|
2573
|
+
}
|
|
2574
|
+
const [s, e] = rt.split("-").map((v) => parseInt(v.trim(), 10));
|
|
2725
2575
|
if (Number.isFinite(s) && Number.isFinite(e)) {
|
|
2726
2576
|
ranges.push([s, e]);
|
|
2727
2577
|
} else if (Number.isFinite(s)) {
|
|
2728
2578
|
ranges.push([s, s]);
|
|
2729
2579
|
}
|
|
2730
2580
|
}
|
|
2731
|
-
if (ranges.length
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
} else if (ranges.length > 1) {
|
|
2735
|
-
args.lines = ranges;
|
|
2736
|
-
}
|
|
2737
|
-
}
|
|
2738
|
-
tools.push({ name: "read", arguments: args });
|
|
2739
|
-
}
|
|
2740
|
-
} else if (toolName === "finish") {
|
|
2741
|
-
const fileRegex = /<file>([\s\S]*?)<\/file>/gi;
|
|
2742
|
-
const files = [];
|
|
2743
|
-
let fileMatch;
|
|
2744
|
-
while ((fileMatch = fileRegex.exec(content)) !== null) {
|
|
2745
|
-
const fileContent = fileMatch[1];
|
|
2746
|
-
const filePath = getXmlElementText(fileContent, "path");
|
|
2747
|
-
const linesStr = getXmlElementText(fileContent, "lines");
|
|
2748
|
-
if (filePath) {
|
|
2749
|
-
if (!linesStr || linesStr.trim() === "*") {
|
|
2581
|
+
if (ranges.length > 0) {
|
|
2582
|
+
files.push({ path: filePath, lines: ranges });
|
|
2583
|
+
} else if (!files.some((f) => f.path === filePath)) {
|
|
2750
2584
|
files.push({ path: filePath, lines: "*" });
|
|
2751
|
-
} else {
|
|
2752
|
-
const ranges = [];
|
|
2753
|
-
for (const rangeStr of linesStr.split(",")) {
|
|
2754
|
-
const [s, e] = rangeStr.split("-").map((v) => parseInt(v.trim(), 10));
|
|
2755
|
-
if (Number.isFinite(s) && Number.isFinite(e)) {
|
|
2756
|
-
ranges.push([s, e]);
|
|
2757
|
-
}
|
|
2758
|
-
}
|
|
2759
|
-
if (ranges.length > 0) {
|
|
2760
|
-
files.push({ path: filePath, lines: ranges });
|
|
2761
|
-
} else {
|
|
2762
|
-
files.push({ path: filePath, lines: "*" });
|
|
2763
|
-
}
|
|
2764
2585
|
}
|
|
2765
2586
|
}
|
|
2766
2587
|
}
|
|
2767
2588
|
if (files.length > 0) {
|
|
2768
2589
|
tools.push({ name: "finish", arguments: { files } });
|
|
2769
2590
|
} else {
|
|
2770
|
-
|
|
2771
|
-
const textResult = !raw || raw === "*" ? "No relevant code found." : raw;
|
|
2772
|
-
tools.push({ name: "finish", arguments: { files: [], textResult } });
|
|
2591
|
+
tools.push({ name: "finish", arguments: { files: [], textResult: filesStr } });
|
|
2773
2592
|
}
|
|
2774
2593
|
}
|
|
2775
2594
|
}
|
|
2776
|
-
if (tools.length === 0) {
|
|
2777
|
-
const fnFinishMatch = text.match(/<function=finish>([\s\S]*?)<\/function>/i);
|
|
2778
|
-
if (fnFinishMatch) {
|
|
2779
|
-
const inner = fnFinishMatch[1];
|
|
2780
|
-
const paramMatch = inner.match(/<parameter=result>([\s\S]*?)<\/parameter>/i);
|
|
2781
|
-
const raw = (paramMatch ? paramMatch[1] : inner).trim();
|
|
2782
|
-
const textResult = !raw || raw === "*" ? "No relevant code found." : raw;
|
|
2783
|
-
tools.push({ name: "finish", arguments: { files: [], textResult } });
|
|
2784
|
-
}
|
|
2785
|
-
}
|
|
2786
2595
|
return tools;
|
|
2787
2596
|
}
|
|
2788
|
-
function preprocessText(text) {
|
|
2789
|
-
const processed = text.replace(/<think>[\s\S]*?<\/think>/gi, "").replace(/<\/?tool_call>/gi, "");
|
|
2790
|
-
const nestedTools = parseNestedXmlTools(processed);
|
|
2791
|
-
const toolCallLines = [];
|
|
2792
|
-
const allLines = processed.split(/\r?\n/).map((l) => l.trim());
|
|
2793
|
-
for (const line of allLines) {
|
|
2794
|
-
if (!line) continue;
|
|
2795
|
-
if (line.startsWith("<")) continue;
|
|
2796
|
-
const firstWord = line.split(/\s/)[0];
|
|
2797
|
-
if (VALID_COMMANDS.includes(firstWord)) {
|
|
2798
|
-
if (!toolCallLines.includes(line)) {
|
|
2799
|
-
toolCallLines.push(line);
|
|
2800
|
-
}
|
|
2801
|
-
}
|
|
2802
|
-
}
|
|
2803
|
-
return { lines: toolCallLines, nestedTools };
|
|
2804
|
-
}
|
|
2805
2597
|
var LLMResponseParser = class {
|
|
2806
|
-
finishSpecSplitRe = /,(?=[^,\s]+:)/;
|
|
2807
2598
|
parse(text) {
|
|
2808
2599
|
if (typeof text !== "string") {
|
|
2809
2600
|
throw new TypeError("Command text must be a string.");
|
|
2810
2601
|
}
|
|
2811
|
-
const
|
|
2812
|
-
|
|
2813
|
-
let finishAccumulator = null;
|
|
2814
|
-
lines.forEach((line) => {
|
|
2815
|
-
if (!line || line.startsWith("#")) return;
|
|
2816
|
-
const parts = this.splitLine(line);
|
|
2817
|
-
if (parts.length === 0) return;
|
|
2818
|
-
const cmd = parts[0];
|
|
2819
|
-
switch (cmd) {
|
|
2820
|
-
case "list_directory":
|
|
2821
|
-
this.handleListDirectory(parts, line, commands);
|
|
2822
|
-
break;
|
|
2823
|
-
case "grep":
|
|
2824
|
-
this.handleGrep(parts, line, commands);
|
|
2825
|
-
break;
|
|
2826
|
-
case "read":
|
|
2827
|
-
this.handleRead(parts, line, commands);
|
|
2828
|
-
break;
|
|
2829
|
-
case "finish":
|
|
2830
|
-
finishAccumulator = this.handleFinish(parts, line, commands, finishAccumulator);
|
|
2831
|
-
break;
|
|
2832
|
-
default:
|
|
2833
|
-
break;
|
|
2834
|
-
}
|
|
2835
|
-
});
|
|
2836
|
-
if (finishAccumulator) {
|
|
2837
|
-
const map = finishAccumulator;
|
|
2838
|
-
const entries = [...map.entries()];
|
|
2839
|
-
const filesPayload = entries.map(([path5, ranges]) => ({
|
|
2840
|
-
path: path5,
|
|
2841
|
-
lines: [...ranges].sort((a, b) => a[0] - b[0])
|
|
2842
|
-
}));
|
|
2843
|
-
commands.push({ name: "finish", arguments: { files: filesPayload } });
|
|
2844
|
-
}
|
|
2845
|
-
return commands;
|
|
2846
|
-
}
|
|
2847
|
-
splitLine(line) {
|
|
2848
|
-
const parts = [];
|
|
2849
|
-
let current = "";
|
|
2850
|
-
let inSingle = false;
|
|
2851
|
-
for (let i = 0; i < line.length; i++) {
|
|
2852
|
-
const ch = line[i];
|
|
2853
|
-
if (ch === "'" && line[i - 1] !== "\\") {
|
|
2854
|
-
inSingle = !inSingle;
|
|
2855
|
-
current += ch;
|
|
2856
|
-
} else if (!inSingle && /\s/.test(ch)) {
|
|
2857
|
-
if (current) {
|
|
2858
|
-
parts.push(current);
|
|
2859
|
-
current = "";
|
|
2860
|
-
}
|
|
2861
|
-
} else {
|
|
2862
|
-
current += ch;
|
|
2863
|
-
}
|
|
2864
|
-
}
|
|
2865
|
-
if (current) parts.push(current);
|
|
2866
|
-
return parts;
|
|
2867
|
-
}
|
|
2868
|
-
/** Helper to create a _skip tool call with an error message */
|
|
2869
|
-
skip(message) {
|
|
2870
|
-
return { name: "_skip", arguments: { message } };
|
|
2871
|
-
}
|
|
2872
|
-
handleListDirectory(parts, rawLine, commands) {
|
|
2873
|
-
if (parts.length < 2) {
|
|
2874
|
-
commands.push(this.skip(
|
|
2875
|
-
`[SKIPPED] Your command "${rawLine}" is missing a path. Correct format: list_directory <path> [pattern]. Example: list_directory src/`
|
|
2876
|
-
));
|
|
2877
|
-
return;
|
|
2878
|
-
}
|
|
2879
|
-
const path5 = parts[1];
|
|
2880
|
-
const pattern = parts[2]?.replace(/^"|"$/g, "") ?? null;
|
|
2881
|
-
commands.push({ name: "list_directory", arguments: { path: path5, pattern } });
|
|
2882
|
-
}
|
|
2883
|
-
handleGrep(parts, rawLine, commands) {
|
|
2884
|
-
if (parts.length < 3) {
|
|
2885
|
-
commands.push(this.skip(
|
|
2886
|
-
`[SKIPPED] Your command "${rawLine}" is missing arguments. Correct format: grep '<pattern>' <path>. Example: grep 'TODO' src/`
|
|
2887
|
-
));
|
|
2888
|
-
return;
|
|
2889
|
-
}
|
|
2890
|
-
let pat = parts[1];
|
|
2891
|
-
if (pat.startsWith("'") && pat.endsWith("'")) {
|
|
2892
|
-
pat = pat.slice(1, -1);
|
|
2893
|
-
}
|
|
2894
|
-
if (!pat) {
|
|
2895
|
-
commands.push(this.skip(
|
|
2896
|
-
`[SKIPPED] Your command "${rawLine}" has an empty pattern. Provide a non-empty search pattern. Example: grep 'function' src/`
|
|
2897
|
-
));
|
|
2898
|
-
return;
|
|
2899
|
-
}
|
|
2900
|
-
commands.push({ name: "grep", arguments: { pattern: pat, path: parts[2] } });
|
|
2901
|
-
}
|
|
2902
|
-
handleRead(parts, rawLine, commands) {
|
|
2903
|
-
if (parts.length < 2) {
|
|
2904
|
-
commands.push(this.skip(
|
|
2905
|
-
`[SKIPPED] Your command "${rawLine}" is missing a path. Correct format: read <path> or read <path>:<start>-<end>. Example: read src/index.ts:1-50`
|
|
2906
|
-
));
|
|
2907
|
-
return;
|
|
2908
|
-
}
|
|
2909
|
-
const spec = parts[1];
|
|
2910
|
-
const rangeIdx = spec.indexOf(":");
|
|
2911
|
-
if (rangeIdx === -1) {
|
|
2912
|
-
commands.push({ name: "read", arguments: { path: spec } });
|
|
2913
|
-
return;
|
|
2914
|
-
}
|
|
2915
|
-
const filePath = spec.slice(0, rangeIdx);
|
|
2916
|
-
const range = spec.slice(rangeIdx + 1);
|
|
2917
|
-
const [s, e] = range.split("-").map((v) => parseInt(v, 10));
|
|
2918
|
-
if (!Number.isFinite(s) || !Number.isFinite(e)) {
|
|
2919
|
-
commands.push({ name: "read", arguments: { path: filePath } });
|
|
2920
|
-
return;
|
|
2921
|
-
}
|
|
2922
|
-
commands.push({ name: "read", arguments: { path: filePath, start: s, end: e } });
|
|
2923
|
-
}
|
|
2924
|
-
handleFinish(parts, rawLine, commands, acc) {
|
|
2925
|
-
const map = acc ?? /* @__PURE__ */ new Map();
|
|
2926
|
-
const args = parts.slice(1);
|
|
2927
|
-
for (const token of args) {
|
|
2928
|
-
const [filePath, rangesText] = token.split(":", 2);
|
|
2929
|
-
if (!filePath || !rangesText) {
|
|
2930
|
-
commands.push(this.skip(
|
|
2931
|
-
`[SKIPPED] Invalid finish token "${token}". Correct format: finish <path>:<start>-<end>. Example: finish src/index.ts:1-50`
|
|
2932
|
-
));
|
|
2933
|
-
continue;
|
|
2934
|
-
}
|
|
2935
|
-
const rangeSpecs = rangesText.split(",").filter(Boolean);
|
|
2936
|
-
for (const spec of rangeSpecs) {
|
|
2937
|
-
const [s, e] = spec.split("-").map((v) => parseInt(v, 10));
|
|
2938
|
-
if (!Number.isFinite(s) || !Number.isFinite(e) || e < s) {
|
|
2939
|
-
commands.push(this.skip(
|
|
2940
|
-
`[SKIPPED] Invalid range "${spec}" in "${token}". Ranges must be <start>-<end> where start <= end. Example: 1-50`
|
|
2941
|
-
));
|
|
2942
|
-
continue;
|
|
2943
|
-
}
|
|
2944
|
-
const arr = map.get(filePath) ?? [];
|
|
2945
|
-
arr.push([s, e]);
|
|
2946
|
-
map.set(filePath, arr);
|
|
2947
|
-
}
|
|
2948
|
-
}
|
|
2949
|
-
return map;
|
|
2602
|
+
const withoutThink = text.replace(/<think>[\s\S]*?<\/think>/gi, "");
|
|
2603
|
+
return parseQwen3ToolCalls(withoutThink);
|
|
2950
2604
|
}
|
|
2951
2605
|
};
|
|
2952
2606
|
|
|
@@ -3016,14 +2670,12 @@ async function toolListDirectory(provider, args) {
|
|
|
3016
2670
|
}
|
|
3017
2671
|
const { entries: list } = await getListRecursive(initialDepth);
|
|
3018
2672
|
if (!list.length) return "empty";
|
|
3019
|
-
|
|
3020
|
-
return "query not specific enough, tool called tried to return too much context and failed";
|
|
3021
|
-
}
|
|
3022
|
-
return list.map((e) => {
|
|
2673
|
+
const tree = list.map((e) => {
|
|
3023
2674
|
const indent = " ".repeat(e.depth);
|
|
3024
2675
|
const name = e.type === "dir" ? `${e.name}/` : e.name;
|
|
3025
2676
|
return `${indent}${name}`;
|
|
3026
2677
|
}).join("\n");
|
|
2678
|
+
return tree;
|
|
3027
2679
|
}
|
|
3028
2680
|
|
|
3029
2681
|
// tools/warp_grep/agent/tools/finish.ts
|
|
@@ -3086,90 +2738,19 @@ function mergeRanges(ranges) {
|
|
|
3086
2738
|
|
|
3087
2739
|
// tools/warp_grep/agent/formatter.ts
|
|
3088
2740
|
var ToolOutputFormatter = class {
|
|
3089
|
-
format(toolName,
|
|
2741
|
+
format(toolName, _args, output, options = {}) {
|
|
3090
2742
|
const name = (toolName ?? "").trim();
|
|
3091
2743
|
if (!name) {
|
|
3092
2744
|
return "";
|
|
3093
2745
|
}
|
|
3094
2746
|
const payload = output?.toString?.()?.trim?.() ?? "";
|
|
3095
2747
|
const isError = Boolean(options.isError);
|
|
3096
|
-
const safeArgs = args ?? {};
|
|
3097
2748
|
if (!payload && !isError) {
|
|
3098
2749
|
return "";
|
|
3099
2750
|
}
|
|
3100
|
-
|
|
3101
|
-
case "read":
|
|
3102
|
-
return this.formatRead(safeArgs, payload, isError);
|
|
3103
|
-
case "list_directory":
|
|
3104
|
-
return this.formatListDirectory(safeArgs, payload, isError);
|
|
3105
|
-
case "grep":
|
|
3106
|
-
return this.formatGrep(safeArgs, payload, isError);
|
|
3107
|
-
default:
|
|
3108
|
-
return payload ? `<tool_output>
|
|
3109
|
-
${payload}
|
|
3110
|
-
</tool_output>` : "";
|
|
3111
|
-
}
|
|
3112
|
-
}
|
|
3113
|
-
formatRead(args, payload, isError) {
|
|
3114
|
-
if (isError) {
|
|
3115
|
-
return payload;
|
|
3116
|
-
}
|
|
3117
|
-
const path5 = this.asString(args.path) || "...";
|
|
3118
|
-
const start = args.start;
|
|
3119
|
-
const end = args.end;
|
|
3120
|
-
const linesArray = args.lines;
|
|
3121
|
-
const attributes = [`path="${path5}"`];
|
|
3122
|
-
if (linesArray && linesArray.length > 0) {
|
|
3123
|
-
const rangeStr = linesArray.map(([s, e]) => `${s}-${e}`).join(",");
|
|
3124
|
-
attributes.push(`lines="${rangeStr}"`);
|
|
3125
|
-
} else if (start !== void 0 && end !== void 0) {
|
|
3126
|
-
attributes.push(`lines="${start}-${end}"`);
|
|
3127
|
-
}
|
|
3128
|
-
return `<read ${attributes.join(" ")}>
|
|
3129
|
-
${payload}
|
|
3130
|
-
</read>`;
|
|
3131
|
-
}
|
|
3132
|
-
formatListDirectory(args, payload, isError) {
|
|
3133
|
-
const path5 = this.asString(args.path) || ".";
|
|
3134
|
-
const pattern = this.asString(args.pattern);
|
|
3135
|
-
const attributes = [`path="${path5}"`];
|
|
3136
|
-
if (pattern) {
|
|
3137
|
-
attributes.push(`pattern="${pattern}"`);
|
|
3138
|
-
}
|
|
3139
|
-
if (isError) {
|
|
3140
|
-
attributes.push('status="error"');
|
|
3141
|
-
}
|
|
3142
|
-
return `<list_directory ${attributes.join(" ")}>
|
|
2751
|
+
return `<tool_response>
|
|
3143
2752
|
${payload}
|
|
3144
|
-
</
|
|
3145
|
-
}
|
|
3146
|
-
formatGrep(args, payload, isError) {
|
|
3147
|
-
const pattern = this.asString(args.pattern);
|
|
3148
|
-
const subDir = this.asString(args.path);
|
|
3149
|
-
const glob = this.asString(args.glob);
|
|
3150
|
-
const attributes = [];
|
|
3151
|
-
if (pattern !== void 0) {
|
|
3152
|
-
attributes.push(`pattern="${pattern}"`);
|
|
3153
|
-
}
|
|
3154
|
-
if (subDir !== void 0) {
|
|
3155
|
-
attributes.push(`sub_dir="${subDir}"`);
|
|
3156
|
-
}
|
|
3157
|
-
if (glob !== void 0) {
|
|
3158
|
-
attributes.push(`glob="${glob}"`);
|
|
3159
|
-
}
|
|
3160
|
-
if (isError) {
|
|
3161
|
-
attributes.push('status="error"');
|
|
3162
|
-
}
|
|
3163
|
-
const attrText = attributes.length ? ` ${attributes.join(" ")}` : "";
|
|
3164
|
-
return `<grep${attrText}>
|
|
3165
|
-
${payload}
|
|
3166
|
-
</grep>`;
|
|
3167
|
-
}
|
|
3168
|
-
asString(value) {
|
|
3169
|
-
if (value === null || value === void 0) {
|
|
3170
|
-
return void 0;
|
|
3171
|
-
}
|
|
3172
|
-
return String(value);
|
|
2753
|
+
</tool_response>`;
|
|
3173
2754
|
}
|
|
3174
2755
|
};
|
|
3175
2756
|
var sharedFormatter = new ToolOutputFormatter();
|
|
@@ -3198,12 +2779,15 @@ function calculateContextBudget(messages) {
|
|
|
3198
2779
|
const maxK = Math.round(maxChars / 1e3);
|
|
3199
2780
|
return `<context_budget>${percent}% (${usedK}K/${maxK}K chars)</context_budget>`;
|
|
3200
2781
|
}
|
|
3201
|
-
async function buildInitialState(repoRoot, query, provider) {
|
|
2782
|
+
async function buildInitialState(repoRoot, query, provider, options) {
|
|
2783
|
+
const budget = calculateContextBudget([]);
|
|
2784
|
+
const turnTag = `Turn 0/${AGENT_CONFIG.MAX_TURNS}`;
|
|
2785
|
+
const treeDepth = options?.query_type === "node_modules" ? 1 : 2;
|
|
3202
2786
|
try {
|
|
3203
2787
|
const entries = await provider.listDirectory({
|
|
3204
2788
|
path: ".",
|
|
3205
2789
|
maxResults: AGENT_CONFIG.MAX_OUTPUT_LINES,
|
|
3206
|
-
maxDepth:
|
|
2790
|
+
maxDepth: treeDepth
|
|
3207
2791
|
});
|
|
3208
2792
|
const treeLines = entries.map((e) => {
|
|
3209
2793
|
const indent = " ".repeat(e.depth);
|
|
@@ -3219,7 +2803,9 @@ ${treeOutput}
|
|
|
3219
2803
|
|
|
3220
2804
|
<search_string>
|
|
3221
2805
|
${query}
|
|
3222
|
-
</search_string
|
|
2806
|
+
</search_string>
|
|
2807
|
+
${budget}
|
|
2808
|
+
${turnTag}`;
|
|
3223
2809
|
} catch {
|
|
3224
2810
|
const repoName = import_path2.default.basename(repoRoot);
|
|
3225
2811
|
return `<repo_structure>
|
|
@@ -3228,7 +2814,9 @@ ${repoName}/
|
|
|
3228
2814
|
|
|
3229
2815
|
<search_string>
|
|
3230
2816
|
${query}
|
|
3231
|
-
</search_string
|
|
2817
|
+
</search_string>
|
|
2818
|
+
${budget}
|
|
2819
|
+
${turnTag}`;
|
|
3232
2820
|
}
|
|
3233
2821
|
}
|
|
3234
2822
|
function enforceContextLimit(messages, maxChars = AGENT_CONFIG.MAX_CONTEXT_CHARS) {
|
|
@@ -3316,14 +2904,13 @@ async function runWarpGrep(config) {
|
|
|
3316
2904
|
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
3317
2905
|
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
3318
2906
|
const repoRoot = import_path3.default.resolve(config.repoRoot || process.cwd());
|
|
2907
|
+
const model = config.model || DEFAULT_MODEL;
|
|
3319
2908
|
const messages = [];
|
|
3320
|
-
|
|
2909
|
+
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
3321
2910
|
const initialStateStart = Date.now();
|
|
3322
|
-
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
2911
|
+
const initialState = await buildInitialState(repoRoot, config.query, config.provider, { query_type: config.query_type });
|
|
3323
2912
|
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
3324
2913
|
messages.push({ role: "user", content: initialState });
|
|
3325
|
-
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
3326
|
-
const model = config.model || DEFAULT_MODEL;
|
|
3327
2914
|
const provider = config.provider;
|
|
3328
2915
|
const errors = [];
|
|
3329
2916
|
let finishMeta;
|
|
@@ -3373,7 +2960,7 @@ async function runWarpGrep(config) {
|
|
|
3373
2960
|
const args = c.arguments ?? {};
|
|
3374
2961
|
allPromises.push(
|
|
3375
2962
|
toolGrep(provider, args).then(
|
|
3376
|
-
({ output }) => formatAgentToolOutput("grep", args, output
|
|
2963
|
+
({ output }) => formatAgentToolOutput("grep", args, output),
|
|
3377
2964
|
(err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
|
|
3378
2965
|
)
|
|
3379
2966
|
);
|
|
@@ -3382,7 +2969,7 @@ async function runWarpGrep(config) {
|
|
|
3382
2969
|
const args = c.arguments ?? {};
|
|
3383
2970
|
allPromises.push(
|
|
3384
2971
|
toolListDirectory(provider, args).then(
|
|
3385
|
-
(p) => formatAgentToolOutput("list_directory", args, p
|
|
2972
|
+
(p) => formatAgentToolOutput("list_directory", args, p),
|
|
3386
2973
|
(err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
|
|
3387
2974
|
)
|
|
3388
2975
|
);
|
|
@@ -3391,7 +2978,7 @@ async function runWarpGrep(config) {
|
|
|
3391
2978
|
const args = c.arguments ?? {};
|
|
3392
2979
|
allPromises.push(
|
|
3393
2980
|
toolRead(provider, args).then(
|
|
3394
|
-
(p) => formatAgentToolOutput("read", args, p
|
|
2981
|
+
(p) => formatAgentToolOutput("read", args, p),
|
|
3395
2982
|
(err) => formatAgentToolOutput("read", args, String(err), { isError: true })
|
|
3396
2983
|
)
|
|
3397
2984
|
);
|
|
@@ -3475,14 +3062,13 @@ async function* runWarpGrepStreaming(config) {
|
|
|
3475
3062
|
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
3476
3063
|
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
3477
3064
|
const repoRoot = import_path3.default.resolve(config.repoRoot || process.cwd());
|
|
3065
|
+
const model = config.model || DEFAULT_MODEL;
|
|
3478
3066
|
const messages = [];
|
|
3479
|
-
|
|
3067
|
+
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
3480
3068
|
const initialStateStart = Date.now();
|
|
3481
|
-
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
3069
|
+
const initialState = await buildInitialState(repoRoot, config.query, config.provider, { query_type: config.query_type });
|
|
3482
3070
|
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
3483
3071
|
messages.push({ role: "user", content: initialState });
|
|
3484
|
-
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
3485
|
-
const model = config.model || DEFAULT_MODEL;
|
|
3486
3072
|
const provider = config.provider;
|
|
3487
3073
|
const errors = [];
|
|
3488
3074
|
let finishMeta;
|
|
@@ -3539,7 +3125,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
3539
3125
|
const args = c.arguments ?? {};
|
|
3540
3126
|
allPromises.push(
|
|
3541
3127
|
toolGrep(provider, args).then(
|
|
3542
|
-
({ output }) => formatAgentToolOutput("grep", args, output
|
|
3128
|
+
({ output }) => formatAgentToolOutput("grep", args, output),
|
|
3543
3129
|
(err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
|
|
3544
3130
|
)
|
|
3545
3131
|
);
|
|
@@ -3548,7 +3134,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
3548
3134
|
const args = c.arguments ?? {};
|
|
3549
3135
|
allPromises.push(
|
|
3550
3136
|
toolListDirectory(provider, args).then(
|
|
3551
|
-
(p) => formatAgentToolOutput("list_directory", args, p
|
|
3137
|
+
(p) => formatAgentToolOutput("list_directory", args, p),
|
|
3552
3138
|
(err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
|
|
3553
3139
|
)
|
|
3554
3140
|
);
|
|
@@ -3557,7 +3143,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
3557
3143
|
const args = c.arguments ?? {};
|
|
3558
3144
|
allPromises.push(
|
|
3559
3145
|
toolRead(provider, args).then(
|
|
3560
|
-
(p) => formatAgentToolOutput("read", args, p
|
|
3146
|
+
(p) => formatAgentToolOutput("read", args, p),
|
|
3561
3147
|
(err) => formatAgentToolOutput("read", args, String(err), { isError: true })
|
|
3562
3148
|
)
|
|
3563
3149
|
);
|
|
@@ -3735,10 +3321,9 @@ var RemoteCommandsProvider = class {
|
|
|
3735
3321
|
const stdout = await this.commands.grep(params.pattern, params.path, params.glob);
|
|
3736
3322
|
const lines = (stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
3737
3323
|
if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
};
|
|
3324
|
+
const truncated = lines.slice(0, AGENT_CONFIG.MAX_OUTPUT_LINES);
|
|
3325
|
+
truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);
|
|
3326
|
+
return { lines: truncated };
|
|
3742
3327
|
}
|
|
3743
3328
|
return { lines };
|
|
3744
3329
|
} catch (error) {
|
|
@@ -3768,7 +3353,7 @@ var RemoteCommandsProvider = class {
|
|
|
3768
3353
|
const lines = contentLines.map((content, idx) => `${start + idx}|${content}`);
|
|
3769
3354
|
if (lines.length > AGENT_CONFIG.MAX_READ_LINES) {
|
|
3770
3355
|
const truncated = lines.slice(0, AGENT_CONFIG.MAX_READ_LINES);
|
|
3771
|
-
truncated.push(`...
|
|
3356
|
+
truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_READ_LINES} of ${lines.length} lines)`);
|
|
3772
3357
|
return { lines: truncated };
|
|
3773
3358
|
}
|
|
3774
3359
|
return { lines };
|
|
@@ -5319,9 +4904,6 @@ function createWarpGrepTool(config) {
|
|
|
5319
4904
|
},
|
|
5320
4905
|
formatResult: (result) => {
|
|
5321
4906
|
return formatResult(result);
|
|
5322
|
-
},
|
|
5323
|
-
getSystemPrompt: () => {
|
|
5324
|
-
return getSystemPrompt();
|
|
5325
4907
|
}
|
|
5326
4908
|
});
|
|
5327
4909
|
}
|
|
@@ -5341,9 +4923,6 @@ function createGitHubSearchTool(config) {
|
|
|
5341
4923
|
},
|
|
5342
4924
|
formatResult: (result) => {
|
|
5343
4925
|
return formatResult(result);
|
|
5344
|
-
},
|
|
5345
|
-
getSystemPrompt: () => {
|
|
5346
|
-
return getSystemPrompt();
|
|
5347
4926
|
}
|
|
5348
4927
|
});
|
|
5349
4928
|
}
|
|
@@ -5516,7 +5095,7 @@ var editFileTool = {
|
|
|
5516
5095
|
async function execute(input, config) {
|
|
5517
5096
|
return executeEditFile(input, config);
|
|
5518
5097
|
}
|
|
5519
|
-
function
|
|
5098
|
+
function getSystemPrompt() {
|
|
5520
5099
|
return EDIT_FILE_SYSTEM_PROMPT;
|
|
5521
5100
|
}
|
|
5522
5101
|
function formatResult3(result) {
|
|
@@ -5545,7 +5124,7 @@ function createEditFileTool(config = {}) {
|
|
|
5545
5124
|
return formatResult3(result);
|
|
5546
5125
|
},
|
|
5547
5126
|
getSystemPrompt: () => {
|
|
5548
|
-
return
|
|
5127
|
+
return getSystemPrompt();
|
|
5549
5128
|
}
|
|
5550
5129
|
});
|
|
5551
5130
|
}
|
|
@@ -5625,9 +5204,6 @@ function createWarpGrepTool2(config) {
|
|
|
5625
5204
|
},
|
|
5626
5205
|
formatResult: (result) => {
|
|
5627
5206
|
return formatResult(result);
|
|
5628
|
-
},
|
|
5629
|
-
getSystemPrompt: () => {
|
|
5630
|
-
return getSystemPrompt();
|
|
5631
5207
|
}
|
|
5632
5208
|
});
|
|
5633
5209
|
}
|
|
@@ -5644,9 +5220,6 @@ function createGitHubSearchTool2(config) {
|
|
|
5644
5220
|
},
|
|
5645
5221
|
formatResult: (result) => {
|
|
5646
5222
|
return formatResult(result);
|
|
5647
|
-
},
|
|
5648
|
-
getSystemPrompt: () => {
|
|
5649
|
-
return getSystemPrompt();
|
|
5650
5223
|
}
|
|
5651
5224
|
});
|
|
5652
5225
|
}
|