@morphllm/morphsdk 0.2.121 → 0.2.123
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-L4PK4VC7.js → chunk-5OJE7GH4.js} +2 -2
- package/dist/chunk-63VHBANJ.js +22 -0
- package/dist/chunk-63VHBANJ.js.map +1 -0
- package/dist/{chunk-BDKXYMU2.js → chunk-ANPZFWYV.js} +2 -2
- package/dist/{chunk-DL3Y3R6A.js → chunk-BJ2764MK.js} +2 -2
- package/dist/{chunk-JBIFS33U.js → chunk-DBSOONOY.js} +2 -2
- package/dist/chunk-ETTCJWJK.js +113 -0
- package/dist/chunk-ETTCJWJK.js.map +1 -0
- package/dist/{chunk-EJYFE73S.js → chunk-FMKJ72KT.js} +3 -3
- package/dist/{chunk-EJYFE73S.js.map → chunk-FMKJ72KT.js.map} +1 -1
- package/dist/{chunk-7QZFNYOH.js → chunk-GXFJLL5O.js} +2 -2
- package/dist/chunk-H3U7J5RI.js +98 -0
- package/dist/chunk-H3U7J5RI.js.map +1 -0
- package/dist/{chunk-MAAULSSQ.js → chunk-HVBJ4UO6.js} +2 -2
- package/dist/{chunk-3HBZXN6E.js → chunk-K74GLGST.js} +2 -2
- package/dist/{chunk-EZFXR52Q.js → chunk-KL3AMLGL.js} +2 -2
- package/dist/{chunk-YMOTJ6ZP.js → chunk-L426IMZD.js} +2 -2
- package/dist/{chunk-C3BQUIFE.js → chunk-MXSGTN7R.js} +145 -9
- package/dist/chunk-MXSGTN7R.js.map +1 -0
- package/dist/{chunk-266SWRHK.js → chunk-OFJYDTQI.js} +2 -2
- package/dist/chunk-OTOVGCG6.js +42 -0
- package/dist/chunk-OTOVGCG6.js.map +1 -0
- package/dist/{chunk-W37KJB25.js → chunk-QD7KPI7A.js} +2 -2
- package/dist/chunk-QGRFAVGK.js +112 -0
- package/dist/chunk-QGRFAVGK.js.map +1 -0
- package/dist/{chunk-WEBUKGPK.js → chunk-UHL2ZEWG.js} +3 -3
- package/dist/{chunk-CIFPLFBQ.js → chunk-UJS3AIWS.js} +2 -2
- package/dist/{chunk-FV3R3JGV.js → chunk-UX65IRCX.js} +2 -2
- package/dist/{chunk-L5C6E32T.js → chunk-V3HLOZK2.js} +1 -1
- package/dist/{chunk-L5C6E32T.js.map → chunk-V3HLOZK2.js.map} +1 -1
- package/dist/{chunk-7IZUNRPZ.js → chunk-V4KBK66V.js} +54 -15
- package/dist/{chunk-7IZUNRPZ.js.map → chunk-V4KBK66V.js.map} +1 -1
- package/dist/{chunk-AI3ZCOCT.js → chunk-WE75QX2B.js} +1 -1
- package/dist/chunk-WYYR2EU6.js +29 -0
- package/dist/chunk-WYYR2EU6.js.map +1 -0
- package/dist/{chunk-GNRMDXJA.js → chunk-XXL62KSJ.js} +2 -2
- package/dist/{chunk-QDGB6FLI.js → chunk-ZZCMAFN7.js} +5 -5
- package/dist/chunk-ZZCMAFN7.js.map +1 -0
- package/dist/{client-Bp3MRcJc.d.ts → client-JHPwle1Z.d.ts} +46 -1
- package/dist/client.cjs +287 -12
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +23 -21
- package/dist/edge.cjs +2 -2
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.js +4 -4
- package/dist/index.cjs +287 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +24 -22
- 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/runner.cjs +5 -5
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +2 -2
- package/dist/tools/warp_grep/anthropic.cjs +476 -5
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +62 -2
- package/dist/tools/warp_grep/anthropic.js +11 -5
- package/dist/tools/warp_grep/client.cjs +187 -12
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.d.ts +58 -2
- package/dist/tools/warp_grep/client.js +9 -3
- package/dist/tools/warp_grep/gemini.cjs +475 -5
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.d.ts +62 -2
- package/dist/tools/warp_grep/gemini.js +69 -4
- package/dist/tools/warp_grep/gemini.js.map +1 -1
- package/dist/tools/warp_grep/index.cjs +228 -12
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +52 -3
- package/dist/tools/warp_grep/index.js +26 -5
- package/dist/tools/warp_grep/openai.cjs +482 -5
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +62 -2
- package/dist/tools/warp_grep/openai.js +11 -5
- package/dist/tools/warp_grep/providers/code_storage_http.cjs +53 -0
- package/dist/tools/warp_grep/providers/code_storage_http.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/code_storage_http.d.ts +23 -0
- package/dist/tools/warp_grep/providers/code_storage_http.js +8 -0
- package/dist/tools/warp_grep/providers/code_storage_http.js.map +1 -0
- package/dist/tools/warp_grep/providers/remote.d.ts +1 -1
- package/dist/tools/warp_grep/utils/github.cjs +46 -0
- package/dist/tools/warp_grep/utils/github.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/github.d.ts +13 -0
- package/dist/tools/warp_grep/utils/github.js +8 -0
- package/dist/tools/warp_grep/utils/github.js.map +1 -0
- package/dist/tools/warp_grep/vercel.cjs +245 -5
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +60 -2
- package/dist/tools/warp_grep/vercel.js +11 -5
- package/dist/{types-D5p8QErL.d.ts → types-DY_hq2eZ.d.ts} +53 -1
- 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-C3BQUIFE.js.map +0 -1
- package/dist/chunk-CXP63PHW.js +0 -61
- package/dist/chunk-CXP63PHW.js.map +0 -1
- package/dist/chunk-KW7OEGZK.js +0 -9
- package/dist/chunk-KW7OEGZK.js.map +0 -1
- package/dist/chunk-QDGB6FLI.js.map +0 -1
- package/dist/chunk-U5UDFQXK.js +0 -66
- package/dist/chunk-U5UDFQXK.js.map +0 -1
- package/dist/chunk-XERAWJ3H.js +0 -53
- package/dist/chunk-XERAWJ3H.js.map +0 -1
- /package/dist/{chunk-L4PK4VC7.js.map → chunk-5OJE7GH4.js.map} +0 -0
- /package/dist/{chunk-BDKXYMU2.js.map → chunk-ANPZFWYV.js.map} +0 -0
- /package/dist/{chunk-DL3Y3R6A.js.map → chunk-BJ2764MK.js.map} +0 -0
- /package/dist/{chunk-JBIFS33U.js.map → chunk-DBSOONOY.js.map} +0 -0
- /package/dist/{chunk-7QZFNYOH.js.map → chunk-GXFJLL5O.js.map} +0 -0
- /package/dist/{chunk-MAAULSSQ.js.map → chunk-HVBJ4UO6.js.map} +0 -0
- /package/dist/{chunk-3HBZXN6E.js.map → chunk-K74GLGST.js.map} +0 -0
- /package/dist/{chunk-EZFXR52Q.js.map → chunk-KL3AMLGL.js.map} +0 -0
- /package/dist/{chunk-YMOTJ6ZP.js.map → chunk-L426IMZD.js.map} +0 -0
- /package/dist/{chunk-266SWRHK.js.map → chunk-OFJYDTQI.js.map} +0 -0
- /package/dist/{chunk-W37KJB25.js.map → chunk-QD7KPI7A.js.map} +0 -0
- /package/dist/{chunk-WEBUKGPK.js.map → chunk-UHL2ZEWG.js.map} +0 -0
- /package/dist/{chunk-CIFPLFBQ.js.map → chunk-UJS3AIWS.js.map} +0 -0
- /package/dist/{chunk-FV3R3JGV.js.map → chunk-UX65IRCX.js.map} +0 -0
- /package/dist/{chunk-AI3ZCOCT.js.map → chunk-WE75QX2B.js.map} +0 -0
- /package/dist/{chunk-GNRMDXJA.js.map → chunk-XXL62KSJ.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WarpGrepStep } from './agent/types.js';
|
|
2
|
-
import { W as WarpGrepClientConfig, a as WarpGrepInput, b as WarpGrepResult, d as WarpGrepToolConfig } from '../../types-
|
|
2
|
+
import { W as WarpGrepClientConfig, a as WarpGrepInput, b as WarpGrepResult, G as GitHubSearchInput, e as GitHubReadFileInput, f as GitHubReadFileResult, d as WarpGrepToolConfig } from '../../types-DY_hq2eZ.js';
|
|
3
3
|
import '../utils/resilience.js';
|
|
4
4
|
import './providers/types.js';
|
|
5
5
|
|
|
@@ -72,6 +72,52 @@ declare class WarpGrepClient {
|
|
|
72
72
|
execute(input: WarpGrepInput & {
|
|
73
73
|
streamSteps?: false | undefined;
|
|
74
74
|
}): Promise<WarpGrepResult>;
|
|
75
|
+
/**
|
|
76
|
+
* Search a public GitHub repository
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* // Simple usage
|
|
81
|
+
* const result = await client.searchGitHub({
|
|
82
|
+
* query: 'Find authentication middleware',
|
|
83
|
+
* github: 'vercel/next.js',
|
|
84
|
+
* });
|
|
85
|
+
*
|
|
86
|
+
* // With streaming
|
|
87
|
+
* const stream = client.searchGitHub({
|
|
88
|
+
* query: 'Find auth middleware',
|
|
89
|
+
* github: 'https://github.com/vercel/next.js',
|
|
90
|
+
* streamSteps: true,
|
|
91
|
+
* });
|
|
92
|
+
* for await (const step of stream) {
|
|
93
|
+
* console.log(`Turn ${step.turn}:`, step.toolCalls);
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
searchGitHub(input: GitHubSearchInput & {
|
|
98
|
+
streamSteps: true;
|
|
99
|
+
}): AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined>;
|
|
100
|
+
searchGitHub(input: GitHubSearchInput & {
|
|
101
|
+
streamSteps?: false | undefined;
|
|
102
|
+
}): Promise<WarpGrepResult>;
|
|
103
|
+
/**
|
|
104
|
+
* Read a single file from a public GitHub repository
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const result = await client.readGitHubFile({
|
|
109
|
+
* github: 'vercel/next.js',
|
|
110
|
+
* path: 'src/server/app-render/index.tsx',
|
|
111
|
+
* startLine: 1,
|
|
112
|
+
* endLine: 50,
|
|
113
|
+
* });
|
|
114
|
+
* if (result.success) console.log(result.content);
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
readGitHubFile(input: GitHubReadFileInput): Promise<GitHubReadFileResult>;
|
|
118
|
+
private _resolveGitHubRepo;
|
|
119
|
+
private _searchGitHubAsync;
|
|
120
|
+
private _searchGitHubStreaming;
|
|
75
121
|
}
|
|
76
122
|
/**
|
|
77
123
|
* Execute a warp grep search directly
|
|
@@ -115,6 +161,16 @@ declare function executeToolCall(input: {
|
|
|
115
161
|
declare function executeToolCallStreaming(input: {
|
|
116
162
|
query: string;
|
|
117
163
|
} | string, config: WarpGrepToolConfig): AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined>;
|
|
164
|
+
/**
|
|
165
|
+
* Read a single file (or line range) from a public GitHub repository
|
|
166
|
+
*/
|
|
167
|
+
declare function executeGitHubReadFile(input: GitHubReadFileInput, config?: {
|
|
168
|
+
timeout?: number;
|
|
169
|
+
}): Promise<GitHubReadFileResult>;
|
|
170
|
+
/**
|
|
171
|
+
* Format a GitHub read file result for display or tool responses
|
|
172
|
+
*/
|
|
173
|
+
declare function formatGitHubReadFileResult(result: GitHubReadFileResult): string;
|
|
118
174
|
/**
|
|
119
175
|
* Format warp grep results for display or tool responses
|
|
120
176
|
*
|
|
@@ -123,4 +179,4 @@ declare function executeToolCallStreaming(input: {
|
|
|
123
179
|
*/
|
|
124
180
|
declare function formatResult(result: WarpGrepResult): string;
|
|
125
181
|
|
|
126
|
-
export { WarpGrepClient, executeToolCall, executeToolCallStreaming, executeWarpGrep, formatResult };
|
|
182
|
+
export { WarpGrepClient, executeGitHubReadFile, executeToolCall, executeToolCallStreaming, executeWarpGrep, formatGitHubReadFileResult, formatResult };
|
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WarpGrepClient,
|
|
3
|
+
executeGitHubReadFile,
|
|
3
4
|
executeToolCall,
|
|
4
5
|
executeToolCallStreaming,
|
|
5
6
|
executeWarpGrep,
|
|
7
|
+
formatGitHubReadFileResult,
|
|
6
8
|
formatResult
|
|
7
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-MXSGTN7R.js";
|
|
10
|
+
import "../../chunk-WYYR2EU6.js";
|
|
8
11
|
import "../../chunk-PUGSTXLO.js";
|
|
9
|
-
import "../../chunk-
|
|
12
|
+
import "../../chunk-63VHBANJ.js";
|
|
13
|
+
import "../../chunk-ZZCMAFN7.js";
|
|
10
14
|
import "../../chunk-3MLWXJTJ.js";
|
|
11
15
|
import "../../chunk-5PNMAWLC.js";
|
|
12
16
|
import "../../chunk-APP75CBN.js";
|
|
13
17
|
import "../../chunk-GHGJAQSJ.js";
|
|
14
18
|
import "../../chunk-FMLHRJDF.js";
|
|
15
|
-
import "../../chunk-
|
|
19
|
+
import "../../chunk-FMKJ72KT.js";
|
|
16
20
|
import "../../chunk-PZ5AY32C.js";
|
|
17
21
|
export {
|
|
18
22
|
WarpGrepClient,
|
|
23
|
+
executeGitHubReadFile,
|
|
19
24
|
executeToolCall,
|
|
20
25
|
executeToolCallStreaming,
|
|
21
26
|
executeWarpGrep,
|
|
27
|
+
formatGitHubReadFileResult,
|
|
22
28
|
formatResult
|
|
23
29
|
};
|
|
24
30
|
//# sourceMappingURL=client.js.map
|
|
@@ -572,6 +572,8 @@ Details: ${res.stderr}` : ""}`
|
|
|
572
572
|
// tools/warp_grep/gemini.ts
|
|
573
573
|
var gemini_exports = {};
|
|
574
574
|
__export(gemini_exports, {
|
|
575
|
+
createGitHubReadFileTool: () => createGitHubReadFileTool,
|
|
576
|
+
createGitHubSearchTool: () => createGitHubSearchTool,
|
|
575
577
|
createMorphWarpGrepTool: () => createMorphWarpGrepTool,
|
|
576
578
|
createWarpGrepTool: () => createWarpGrepTool,
|
|
577
579
|
default: () => gemini_default,
|
|
@@ -1379,7 +1381,7 @@ var import_openai = __toESM(require("openai"), 1);
|
|
|
1379
1381
|
// package.json
|
|
1380
1382
|
var package_default = {
|
|
1381
1383
|
name: "@morphllm/morphsdk",
|
|
1382
|
-
version: "0.2.
|
|
1384
|
+
version: "0.2.123",
|
|
1383
1385
|
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
1384
1386
|
type: "module",
|
|
1385
1387
|
main: "./dist/index.cjs",
|
|
@@ -1521,7 +1523,7 @@ var package_default = {
|
|
|
1521
1523
|
"!dist/**/*.test.*"
|
|
1522
1524
|
],
|
|
1523
1525
|
scripts: {
|
|
1524
|
-
build: "tsup version.ts index.ts edge.ts client.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/prompt.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/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/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
|
+
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/prompt.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/providers/code_storage_http.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/github.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts git/index.ts git/client.ts git/config.ts git/types.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/utils/resilience.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve",
|
|
1525
1527
|
prepare: "npm run build",
|
|
1526
1528
|
typecheck: "tsc --noEmit",
|
|
1527
1529
|
lint: "eslint .",
|
|
@@ -1629,9 +1631,9 @@ async function callModel(messages, model, options = {}) {
|
|
|
1629
1631
|
});
|
|
1630
1632
|
} catch (error) {
|
|
1631
1633
|
if (error instanceof import_openai.default.APIError && error.status === 404) {
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
);
|
|
1634
|
+
const defaultMsg = "The endpoint you are trying to call is likely deprecated. Please update with: npm cache clean --force && npx -y @morphllm/morphmcp@latest or visit: https://morphllm.com/mcp";
|
|
1635
|
+
const errorText = error.message?.trim();
|
|
1636
|
+
throw new Error(errorText || defaultMsg);
|
|
1635
1637
|
}
|
|
1636
1638
|
throw error;
|
|
1637
1639
|
}
|
|
@@ -1812,6 +1814,171 @@ async function runWarpGrep(config) {
|
|
|
1812
1814
|
timings
|
|
1813
1815
|
};
|
|
1814
1816
|
}
|
|
1817
|
+
async function* runWarpGrepStreaming(config) {
|
|
1818
|
+
const totalStart = Date.now();
|
|
1819
|
+
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1820
|
+
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
1821
|
+
const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
|
|
1822
|
+
const messages = [];
|
|
1823
|
+
messages.push({ role: "system", content: getSystemPrompt() });
|
|
1824
|
+
const initialStateStart = Date.now();
|
|
1825
|
+
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
1826
|
+
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1827
|
+
messages.push({ role: "user", content: initialState });
|
|
1828
|
+
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1829
|
+
const model = config.model || DEFAULT_MODEL;
|
|
1830
|
+
const provider = config.provider;
|
|
1831
|
+
const errors = [];
|
|
1832
|
+
let finishMeta;
|
|
1833
|
+
let terminationReason = "terminated";
|
|
1834
|
+
for (let turn = 1; turn <= maxTurns; turn += 1) {
|
|
1835
|
+
const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
|
|
1836
|
+
enforceContextLimit(messages);
|
|
1837
|
+
const modelCallStart = Date.now();
|
|
1838
|
+
const assistantContent = await callModel(messages, model, {
|
|
1839
|
+
morphApiKey: config.morphApiKey,
|
|
1840
|
+
morphApiUrl: config.morphApiUrl,
|
|
1841
|
+
retryConfig: config.retryConfig,
|
|
1842
|
+
timeout: timeoutMs
|
|
1843
|
+
}).catch((e) => {
|
|
1844
|
+
const errMsg = e instanceof Error ? e.message : String(e);
|
|
1845
|
+
console.error(`[warp_grep:stream] Morph API call failed on turn ${turn}:`, errMsg);
|
|
1846
|
+
errors.push({ message: errMsg });
|
|
1847
|
+
return "";
|
|
1848
|
+
});
|
|
1849
|
+
turnMetrics.morph_api_ms = Date.now() - modelCallStart;
|
|
1850
|
+
if (!assistantContent) {
|
|
1851
|
+
console.error(`[warp_grep:stream] Empty response from Morph API on turn ${turn}. Errors so far:`, errors);
|
|
1852
|
+
timings.turns.push(turnMetrics);
|
|
1853
|
+
break;
|
|
1854
|
+
}
|
|
1855
|
+
messages.push({ role: "assistant", content: assistantContent });
|
|
1856
|
+
const toolCalls = parser.parse(assistantContent);
|
|
1857
|
+
if (toolCalls.length === 0) {
|
|
1858
|
+
console.error(`[warp_grep:stream] No tool calls parsed on turn ${turn}. Assistant content (first 500 chars):`, assistantContent.slice(0, 500));
|
|
1859
|
+
errors.push({ message: "No tool calls produced by the model. Your MCP is likely out of date! Update it by running: rm -rf ~/.npm/_npx && npm cache clean --force && npx -y @morphllm/morphmcp@latest" });
|
|
1860
|
+
terminationReason = "terminated";
|
|
1861
|
+
timings.turns.push(turnMetrics);
|
|
1862
|
+
break;
|
|
1863
|
+
}
|
|
1864
|
+
yield {
|
|
1865
|
+
turn,
|
|
1866
|
+
toolCalls: toolCalls.map((c) => ({
|
|
1867
|
+
name: c.name,
|
|
1868
|
+
arguments: c.arguments ?? {}
|
|
1869
|
+
}))
|
|
1870
|
+
};
|
|
1871
|
+
const finishCalls = toolCalls.filter((c) => c.name === "finish");
|
|
1872
|
+
const grepCalls = toolCalls.filter((c) => c.name === "grep");
|
|
1873
|
+
const listDirCalls = toolCalls.filter((c) => c.name === "list_directory");
|
|
1874
|
+
const readCalls = toolCalls.filter((c) => c.name === "read");
|
|
1875
|
+
const skipCalls = toolCalls.filter((c) => c.name === "_skip");
|
|
1876
|
+
const formatted = [];
|
|
1877
|
+
for (const c of skipCalls) {
|
|
1878
|
+
const msg = c.arguments?.message || "Command skipped due to parsing error";
|
|
1879
|
+
formatted.push(msg);
|
|
1880
|
+
}
|
|
1881
|
+
const allPromises = [];
|
|
1882
|
+
for (const c of grepCalls) {
|
|
1883
|
+
const args = c.arguments ?? {};
|
|
1884
|
+
allPromises.push(
|
|
1885
|
+
toolGrep(provider, args).then(
|
|
1886
|
+
({ output }) => formatAgentToolOutput("grep", args, output, { isError: false }),
|
|
1887
|
+
(err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
|
|
1888
|
+
)
|
|
1889
|
+
);
|
|
1890
|
+
}
|
|
1891
|
+
for (const c of listDirCalls) {
|
|
1892
|
+
const args = c.arguments ?? {};
|
|
1893
|
+
allPromises.push(
|
|
1894
|
+
toolListDirectory(provider, args).then(
|
|
1895
|
+
(p) => formatAgentToolOutput("list_directory", args, p, { isError: false }),
|
|
1896
|
+
(err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
|
|
1897
|
+
)
|
|
1898
|
+
);
|
|
1899
|
+
}
|
|
1900
|
+
for (const c of readCalls) {
|
|
1901
|
+
const args = c.arguments ?? {};
|
|
1902
|
+
allPromises.push(
|
|
1903
|
+
toolRead(provider, args).then(
|
|
1904
|
+
(p) => formatAgentToolOutput("read", args, p, { isError: false }),
|
|
1905
|
+
(err) => formatAgentToolOutput("read", args, String(err), { isError: true })
|
|
1906
|
+
)
|
|
1907
|
+
);
|
|
1908
|
+
}
|
|
1909
|
+
const toolExecStart = Date.now();
|
|
1910
|
+
const allResults = await Promise.all(allPromises);
|
|
1911
|
+
turnMetrics.local_tools_ms = Date.now() - toolExecStart;
|
|
1912
|
+
for (const result of allResults) {
|
|
1913
|
+
formatted.push(result);
|
|
1914
|
+
}
|
|
1915
|
+
if (formatted.length > 0) {
|
|
1916
|
+
const turnMessage = formatTurnMessage(turn, maxTurns);
|
|
1917
|
+
const contextBudget = calculateContextBudget(messages);
|
|
1918
|
+
messages.push({ role: "user", content: formatted.join("\n") + turnMessage + "\n" + contextBudget });
|
|
1919
|
+
}
|
|
1920
|
+
timings.turns.push(turnMetrics);
|
|
1921
|
+
if (finishCalls.length) {
|
|
1922
|
+
const fc = finishCalls[0];
|
|
1923
|
+
const files = fc.arguments?.files ?? [];
|
|
1924
|
+
const textResult = fc.arguments?.textResult;
|
|
1925
|
+
finishMeta = { files };
|
|
1926
|
+
terminationReason = "completed";
|
|
1927
|
+
if (files.length === 0) {
|
|
1928
|
+
const payload2 = textResult || "No relevant code found.";
|
|
1929
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1930
|
+
return {
|
|
1931
|
+
terminationReason: "completed",
|
|
1932
|
+
messages,
|
|
1933
|
+
finish: { payload: payload2, metadata: finishMeta },
|
|
1934
|
+
timings
|
|
1935
|
+
};
|
|
1936
|
+
}
|
|
1937
|
+
break;
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
if (terminationReason !== "completed" || !finishMeta) {
|
|
1941
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1942
|
+
return { terminationReason, messages, errors, timings };
|
|
1943
|
+
}
|
|
1944
|
+
const parts = ["Relevant context found:"];
|
|
1945
|
+
for (const f of finishMeta.files) {
|
|
1946
|
+
const ranges = f.lines === "*" ? "*" : Array.isArray(f.lines) ? f.lines.map(([s, e]) => `${s}-${e}`).join(", ") : "*";
|
|
1947
|
+
parts.push(`- ${f.path}: ${ranges}`);
|
|
1948
|
+
}
|
|
1949
|
+
const payload = parts.join("\n");
|
|
1950
|
+
const finishResolutionStart = Date.now();
|
|
1951
|
+
const fileReadErrors = [];
|
|
1952
|
+
const resolved = await readFinishFiles(
|
|
1953
|
+
repoRoot,
|
|
1954
|
+
finishMeta.files,
|
|
1955
|
+
async (p, s, e) => {
|
|
1956
|
+
try {
|
|
1957
|
+
const rr = await provider.read({ path: p, start: s, end: e });
|
|
1958
|
+
return rr.lines.map((l) => {
|
|
1959
|
+
const idx = l.indexOf("|");
|
|
1960
|
+
return idx >= 0 ? l.slice(idx + 1) : l;
|
|
1961
|
+
});
|
|
1962
|
+
} catch (err) {
|
|
1963
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
1964
|
+
fileReadErrors.push({ path: p, error: errorMsg });
|
|
1965
|
+
console.error(`[warp_grep] Failed to read file: ${p} - ${errorMsg}`);
|
|
1966
|
+
return [`[couldn't find: ${p}]`];
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
);
|
|
1970
|
+
timings.finish_resolution_ms = Date.now() - finishResolutionStart;
|
|
1971
|
+
if (fileReadErrors.length > 0) {
|
|
1972
|
+
errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
|
|
1973
|
+
}
|
|
1974
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1975
|
+
return {
|
|
1976
|
+
terminationReason: "completed",
|
|
1977
|
+
messages,
|
|
1978
|
+
finish: { payload, metadata: finishMeta, resolved },
|
|
1979
|
+
timings
|
|
1980
|
+
};
|
|
1981
|
+
}
|
|
1815
1982
|
|
|
1816
1983
|
// tools/warp_grep/providers/remote.ts
|
|
1817
1984
|
init_config();
|
|
@@ -1994,11 +2161,153 @@ var RemoteCommandsProvider = class {
|
|
|
1994
2161
|
}
|
|
1995
2162
|
};
|
|
1996
2163
|
|
|
2164
|
+
// tools/warp_grep/providers/code_storage_http.ts
|
|
2165
|
+
async function post(url, body, op) {
|
|
2166
|
+
const res = await fetch(url, {
|
|
2167
|
+
method: "POST",
|
|
2168
|
+
headers: { "Content-Type": "application/json" },
|
|
2169
|
+
body: JSON.stringify(body)
|
|
2170
|
+
});
|
|
2171
|
+
if (!res.ok) {
|
|
2172
|
+
const text = await res.text().catch(() => res.statusText);
|
|
2173
|
+
throw new Error(`${op} failed (${res.status}): ${text}`);
|
|
2174
|
+
}
|
|
2175
|
+
const data = await res.json();
|
|
2176
|
+
if (data.error) throw new Error(data.error);
|
|
2177
|
+
return data.stdout;
|
|
2178
|
+
}
|
|
2179
|
+
function createCodeStorageHttpCommands(config) {
|
|
2180
|
+
const { baseUrl, repoId, branch } = config;
|
|
2181
|
+
const encodedRepoId = encodeURIComponent(repoId);
|
|
2182
|
+
return {
|
|
2183
|
+
grep: (pattern, path5, glob) => post(`${baseUrl}/api/code-search/${encodedRepoId}/grep`, { pattern, path: path5, glob, branch }, "grep"),
|
|
2184
|
+
read: (path5, start, end) => post(`${baseUrl}/api/code-search/${encodedRepoId}/read`, { path: path5, start, end, branch }, "read"),
|
|
2185
|
+
listDir: (path5, maxDepth) => post(`${baseUrl}/api/code-search/${encodedRepoId}/list`, { path: path5, maxDepth, branch }, "list")
|
|
2186
|
+
};
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
// tools/warp_grep/utils/github.ts
|
|
2190
|
+
function parseGitHubUrl(input) {
|
|
2191
|
+
input = input.trim();
|
|
2192
|
+
const urlPattern = /^(?:https?:\/\/)?github\.com\/([^\/]+)\/([^\/\?\#]+)/;
|
|
2193
|
+
const match = input.match(urlPattern);
|
|
2194
|
+
if (match) {
|
|
2195
|
+
return { owner: match[1], repo: match[2].replace(/\.git$/, "") };
|
|
2196
|
+
}
|
|
2197
|
+
const shortPattern = /^([^\/]+)\/([^\/]+)$/;
|
|
2198
|
+
const shortMatch = input.match(shortPattern);
|
|
2199
|
+
if (shortMatch && !shortMatch[1].includes(".")) {
|
|
2200
|
+
return { owner: shortMatch[1], repo: shortMatch[2].replace(/\.git$/, "") };
|
|
2201
|
+
}
|
|
2202
|
+
throw new Error(
|
|
2203
|
+
`Invalid GitHub URL or shorthand: "${input}". Expected "owner/repo" or "https://github.com/owner/repo"`
|
|
2204
|
+
);
|
|
2205
|
+
}
|
|
2206
|
+
|
|
1997
2207
|
// tools/warp_grep/client.ts
|
|
2208
|
+
var DEFAULT_CODE_SEARCH_URL = "https://morphllm.com";
|
|
1998
2209
|
async function getLocalProvider(repoRoot, excludes) {
|
|
1999
2210
|
const { LocalRipgrepProvider: LocalRipgrepProvider2 } = await Promise.resolve().then(() => (init_local(), local_exports));
|
|
2000
2211
|
return new LocalRipgrepProvider2(repoRoot, excludes);
|
|
2001
2212
|
}
|
|
2213
|
+
var WarpGrepClient = class {
|
|
2214
|
+
config;
|
|
2215
|
+
constructor(config = {}) {
|
|
2216
|
+
this.config = { ...config };
|
|
2217
|
+
}
|
|
2218
|
+
execute(input) {
|
|
2219
|
+
const toolConfig = {
|
|
2220
|
+
repoRoot: input.repoRoot,
|
|
2221
|
+
remoteCommands: input.remoteCommands,
|
|
2222
|
+
provider: input.provider,
|
|
2223
|
+
excludes: input.excludes,
|
|
2224
|
+
includes: input.includes,
|
|
2225
|
+
debug: input.debug ?? this.config.debug,
|
|
2226
|
+
morphApiKey: this.config.morphApiKey,
|
|
2227
|
+
morphApiUrl: this.config.morphApiUrl,
|
|
2228
|
+
retryConfig: this.config.retryConfig,
|
|
2229
|
+
timeout: this.config.timeout
|
|
2230
|
+
};
|
|
2231
|
+
if (input.streamSteps) {
|
|
2232
|
+
return executeToolCallStreaming({ query: input.query }, toolConfig);
|
|
2233
|
+
}
|
|
2234
|
+
return executeToolCall({ query: input.query }, toolConfig);
|
|
2235
|
+
}
|
|
2236
|
+
searchGitHub(input) {
|
|
2237
|
+
if (input.streamSteps) {
|
|
2238
|
+
return this._searchGitHubStreaming(input);
|
|
2239
|
+
}
|
|
2240
|
+
return this._searchGitHubAsync(input);
|
|
2241
|
+
}
|
|
2242
|
+
/**
|
|
2243
|
+
* Read a single file from a public GitHub repository
|
|
2244
|
+
*
|
|
2245
|
+
* @example
|
|
2246
|
+
* ```typescript
|
|
2247
|
+
* const result = await client.readGitHubFile({
|
|
2248
|
+
* github: 'vercel/next.js',
|
|
2249
|
+
* path: 'src/server/app-render/index.tsx',
|
|
2250
|
+
* startLine: 1,
|
|
2251
|
+
* endLine: 50,
|
|
2252
|
+
* });
|
|
2253
|
+
* if (result.success) console.log(result.content);
|
|
2254
|
+
* ```
|
|
2255
|
+
*/
|
|
2256
|
+
async readGitHubFile(input) {
|
|
2257
|
+
return executeGitHubReadFile(input, { timeout: this.config.timeout });
|
|
2258
|
+
}
|
|
2259
|
+
async _resolveGitHubRepo(input) {
|
|
2260
|
+
const { owner, repo } = parseGitHubUrl(input.github);
|
|
2261
|
+
const baseUrl = this.config.codeSearchUrl || DEFAULT_CODE_SEARCH_URL;
|
|
2262
|
+
const importRes = await fetch(`${baseUrl}/api/code-search/get-or-create?url=${encodeURIComponent(`${owner}/${repo}`)}`);
|
|
2263
|
+
if (!importRes.ok) {
|
|
2264
|
+
const text = await importRes.text().catch(() => importRes.statusText);
|
|
2265
|
+
throw new Error(`Failed to import repo ${owner}/${repo}: ${text}`);
|
|
2266
|
+
}
|
|
2267
|
+
const { repoId, defaultBranch } = await importRes.json();
|
|
2268
|
+
return {
|
|
2269
|
+
repo,
|
|
2270
|
+
remoteCommands: createCodeStorageHttpCommands({ baseUrl, repoId, branch: input.branch || defaultBranch })
|
|
2271
|
+
};
|
|
2272
|
+
}
|
|
2273
|
+
async _searchGitHubAsync(input) {
|
|
2274
|
+
try {
|
|
2275
|
+
const { repo, remoteCommands } = await this._resolveGitHubRepo(input);
|
|
2276
|
+
return this.execute({
|
|
2277
|
+
query: input.query,
|
|
2278
|
+
repoRoot: repo,
|
|
2279
|
+
remoteCommands
|
|
2280
|
+
});
|
|
2281
|
+
} catch (error) {
|
|
2282
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
async *_searchGitHubStreaming(input) {
|
|
2286
|
+
let repo;
|
|
2287
|
+
let remoteCommands;
|
|
2288
|
+
try {
|
|
2289
|
+
({ repo, remoteCommands } = await this._resolveGitHubRepo(input));
|
|
2290
|
+
} catch (error) {
|
|
2291
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
2292
|
+
}
|
|
2293
|
+
const generator = this.execute({
|
|
2294
|
+
query: input.query,
|
|
2295
|
+
repoRoot: repo,
|
|
2296
|
+
remoteCommands,
|
|
2297
|
+
streamSteps: true
|
|
2298
|
+
});
|
|
2299
|
+
let result;
|
|
2300
|
+
for (; ; ) {
|
|
2301
|
+
const { value, done } = await generator.next();
|
|
2302
|
+
if (done) {
|
|
2303
|
+
result = value;
|
|
2304
|
+
break;
|
|
2305
|
+
}
|
|
2306
|
+
yield value;
|
|
2307
|
+
}
|
|
2308
|
+
return result;
|
|
2309
|
+
}
|
|
2310
|
+
};
|
|
2002
2311
|
async function executeToolCall(input, config) {
|
|
2003
2312
|
const parsed = typeof input === "string" ? JSON.parse(input) : input;
|
|
2004
2313
|
const provider = config.remoteCommands ? new RemoteCommandsProvider(config.repoRoot, config.remoteCommands) : config.provider ?? await getLocalProvider(config.repoRoot, config.excludes);
|
|
@@ -2027,6 +2336,105 @@ async function executeToolCall(input, config) {
|
|
|
2027
2336
|
}));
|
|
2028
2337
|
return { success: true, contexts, summary: finish.payload };
|
|
2029
2338
|
}
|
|
2339
|
+
function processAgentResult(result) {
|
|
2340
|
+
const finish = result.finish;
|
|
2341
|
+
if (result.terminationReason !== "completed" || !finish?.metadata) {
|
|
2342
|
+
const errorDetails = result.errors?.map((e) => e.message).join("; ") || "unknown reason";
|
|
2343
|
+
console.error(`[warp_grep] processAgentResult failed. Reason: ${result.terminationReason}. Errors: ${errorDetails}. Turns: ${result.timings?.turns?.length ?? 0}`);
|
|
2344
|
+
return { success: false, error: `Search did not complete: ${errorDetails}` };
|
|
2345
|
+
}
|
|
2346
|
+
const contexts = (finish.resolved ?? []).map((r) => ({
|
|
2347
|
+
file: r.path,
|
|
2348
|
+
content: r.content,
|
|
2349
|
+
lines: r.ranges
|
|
2350
|
+
}));
|
|
2351
|
+
return { success: true, contexts, summary: finish.payload };
|
|
2352
|
+
}
|
|
2353
|
+
async function* executeToolCallStreaming(input, config) {
|
|
2354
|
+
const parsed = typeof input === "string" ? JSON.parse(input) : input;
|
|
2355
|
+
const provider = config.remoteCommands ? new RemoteCommandsProvider(config.repoRoot, config.remoteCommands) : config.provider ?? await getLocalProvider(config.repoRoot, config.excludes);
|
|
2356
|
+
const generator = runWarpGrepStreaming({
|
|
2357
|
+
query: parsed.query,
|
|
2358
|
+
repoRoot: config.repoRoot,
|
|
2359
|
+
provider,
|
|
2360
|
+
excludes: config.excludes,
|
|
2361
|
+
includes: config.includes,
|
|
2362
|
+
debug: config.debug ?? false,
|
|
2363
|
+
morphApiKey: config.morphApiKey,
|
|
2364
|
+
morphApiUrl: config.morphApiUrl,
|
|
2365
|
+
retryConfig: config.retryConfig,
|
|
2366
|
+
timeout: config.timeout
|
|
2367
|
+
});
|
|
2368
|
+
let agentResult;
|
|
2369
|
+
for (; ; ) {
|
|
2370
|
+
const { value, done } = await generator.next();
|
|
2371
|
+
if (done) {
|
|
2372
|
+
agentResult = value;
|
|
2373
|
+
break;
|
|
2374
|
+
}
|
|
2375
|
+
yield value;
|
|
2376
|
+
}
|
|
2377
|
+
return processAgentResult(agentResult);
|
|
2378
|
+
}
|
|
2379
|
+
async function fetchRawGitHubFile(owner, repo, filePath, branch, timeout) {
|
|
2380
|
+
const branches = branch ? [branch] : ["HEAD"];
|
|
2381
|
+
const fallbacks = ["main", "master", "develop"];
|
|
2382
|
+
const fetchWithTimeout = (url) => timeout ? fetch(url, { signal: AbortSignal.timeout(timeout) }) : fetch(url);
|
|
2383
|
+
for (const b of branches) {
|
|
2384
|
+
const url = `https://raw.githubusercontent.com/${owner}/${repo}/${b}/${filePath}`;
|
|
2385
|
+
const res = await fetchWithTimeout(url);
|
|
2386
|
+
if (res.ok) return { content: await res.text(), branch: b };
|
|
2387
|
+
}
|
|
2388
|
+
for (const fb of fallbacks) {
|
|
2389
|
+
if (branch && fb === branch) continue;
|
|
2390
|
+
const url = `https://raw.githubusercontent.com/${owner}/${repo}/${fb}/${filePath}`;
|
|
2391
|
+
const res = await fetchWithTimeout(url);
|
|
2392
|
+
if (res.ok) return { content: await res.text(), branch: fb };
|
|
2393
|
+
}
|
|
2394
|
+
throw new Error(`File not found: ${owner}/${repo}/${filePath}`);
|
|
2395
|
+
}
|
|
2396
|
+
async function executeGitHubReadFile(input, config) {
|
|
2397
|
+
try {
|
|
2398
|
+
const { owner, repo } = parseGitHubUrl(input.github);
|
|
2399
|
+
const { content: raw, branch } = await fetchRawGitHubFile(
|
|
2400
|
+
owner,
|
|
2401
|
+
repo,
|
|
2402
|
+
input.path,
|
|
2403
|
+
input.branch,
|
|
2404
|
+
config?.timeout
|
|
2405
|
+
);
|
|
2406
|
+
const allLines = raw.split("\n");
|
|
2407
|
+
const totalLines = allLines.length;
|
|
2408
|
+
const start = Math.max(1, input.startLine ?? 1);
|
|
2409
|
+
const end = Math.min(totalLines, input.endLine ?? totalLines);
|
|
2410
|
+
const selected = allLines.slice(start - 1, end);
|
|
2411
|
+
const padWidth = String(end).length;
|
|
2412
|
+
const numbered = selected.map((line, i) => `${String(start + i).padStart(padWidth)}|${line}`).join("\n");
|
|
2413
|
+
return {
|
|
2414
|
+
success: true,
|
|
2415
|
+
content: numbered,
|
|
2416
|
+
path: input.path,
|
|
2417
|
+
github: `${owner}/${repo}`,
|
|
2418
|
+
branch,
|
|
2419
|
+
lineRange: [start, end],
|
|
2420
|
+
totalLines
|
|
2421
|
+
};
|
|
2422
|
+
} catch (error) {
|
|
2423
|
+
return {
|
|
2424
|
+
success: false,
|
|
2425
|
+
error: error instanceof Error ? error.message : String(error)
|
|
2426
|
+
};
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
function formatGitHubReadFileResult(result) {
|
|
2430
|
+
if (!result.success) {
|
|
2431
|
+
return `Failed to read file: ${result.error}`;
|
|
2432
|
+
}
|
|
2433
|
+
const rangeStr = result.lineRange ? ` (lines ${result.lineRange[0]}-${result.lineRange[1]} of ${result.totalLines})` : "";
|
|
2434
|
+
return `File: ${result.github}/${result.path}${rangeStr}
|
|
2435
|
+
|
|
2436
|
+
${result.content}`;
|
|
2437
|
+
}
|
|
2030
2438
|
function formatResult(result) {
|
|
2031
2439
|
if (!result.success) {
|
|
2032
2440
|
return `Search failed: ${result.error}`;
|
|
@@ -2055,6 +2463,12 @@ function formatResult(result) {
|
|
|
2055
2463
|
// tools/warp_grep/prompts.ts
|
|
2056
2464
|
var WARP_GREP_TOOL_NAME = "warpgrep_codebase_search";
|
|
2057
2465
|
var WARP_GREP_DESCRIPTION = 'IMPORTANT: If you need to explore the codebase to gather context, and the task does not involve a single file or function which is provided by name, you should ALWAYS use the warpgrep codebase search tool first instead of running search commands. When the task requires exploration beyond a single known file, invoke warpgrep first with a natural-language query describing the target functionality, bug, or architectural concern. Warp Grep is a fast and accurate tool that can search for all relevant context in a codebase. Keep queries action-oriented (e.g., "Find where billing invoices are generated and emailed"), and after reviewing the summarized results, you may verify important findings with other search tools or direct file reads to ensure completeness. Warp Grep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. When a task requires exploration beyond a single known file, ALWAYS default to warpgrep codebase search before other search mechanisms.';
|
|
2466
|
+
var GITHUB_WARP_GREP_SEARCH_TOOL_NAME = "warpgrep_github_search";
|
|
2467
|
+
var GITHUB_WARP_GREP_SEARCH_DESCRIPTION = 'IMPORTANT: If you need to explore the codebase of a public GitHub repository (not your local workspace), use warpgrep_github_search instead of warpgrep_codebase_search. When the task requires understanding code in an external repo, invoke warpgrep_github_search with a GitHub URL or owner/repo shorthand (e.g., vercel/next.js) and a natural-language query describing the target functionality, bug, or architectural concern. WarpGrep searches GitHub repos the same way it searches local codebases: fast and accurate. Keep queries action-oriented (e.g., "Find where how the new use workflow directive works"), and after reviewing the results, you may verify important findings with other tools or direct file reads. WarpGrep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. When a task involves exploring code in an external public repo, ALWAYS use warpgrep_github_search.';
|
|
2468
|
+
var GITHUB_SEARCH_TOOL_NAME = GITHUB_WARP_GREP_SEARCH_TOOL_NAME;
|
|
2469
|
+
var GITHUB_SEARCH_DESCRIPTION = GITHUB_WARP_GREP_SEARCH_DESCRIPTION;
|
|
2470
|
+
var GITHUB_READ_FILE_TOOL_NAME = "readfile_github_search";
|
|
2471
|
+
var GITHUB_READ_FILE_DESCRIPTION = "Read a single file (or a line range) from a public GitHub repository. Use this when you already know the exact file path you want to read, for example after finding it via warpgrep_github_search results. Takes owner/repo shorthand and the file path within the repo. Optionally specify startLine and endLine (1-based) to read a specific range. Returns the file content with line numbers.";
|
|
2058
2472
|
|
|
2059
2473
|
// tools/warp_grep/gemini.ts
|
|
2060
2474
|
var TOOL_PARAMETERS = {
|
|
@@ -2094,9 +2508,65 @@ function createWarpGrepTool(config) {
|
|
|
2094
2508
|
});
|
|
2095
2509
|
}
|
|
2096
2510
|
var createMorphWarpGrepTool = createWarpGrepTool;
|
|
2511
|
+
var GITHUB_SEARCH_PARAMETERS = {
|
|
2512
|
+
type: "OBJECT",
|
|
2513
|
+
properties: {
|
|
2514
|
+
query: { type: "STRING", description: "Natural language search query" },
|
|
2515
|
+
github: { type: "STRING", description: 'GitHub URL or "owner/repo" shorthand' },
|
|
2516
|
+
branch: { type: "STRING", description: "Branch to search (defaults to repo default branch)" }
|
|
2517
|
+
},
|
|
2518
|
+
required: ["query", "github"]
|
|
2519
|
+
};
|
|
2520
|
+
function createGitHubSearchTool(config) {
|
|
2521
|
+
const client = new WarpGrepClient(config);
|
|
2522
|
+
const declaration = {
|
|
2523
|
+
name: GITHUB_SEARCH_TOOL_NAME,
|
|
2524
|
+
description: GITHUB_SEARCH_DESCRIPTION,
|
|
2525
|
+
parameters: GITHUB_SEARCH_PARAMETERS
|
|
2526
|
+
};
|
|
2527
|
+
return Object.assign(declaration, {
|
|
2528
|
+
execute: async (input) => {
|
|
2529
|
+
return client.searchGitHub(input);
|
|
2530
|
+
},
|
|
2531
|
+
formatResult: (result) => {
|
|
2532
|
+
return formatResult(result);
|
|
2533
|
+
},
|
|
2534
|
+
getSystemPrompt: () => {
|
|
2535
|
+
return getSystemPrompt();
|
|
2536
|
+
}
|
|
2537
|
+
});
|
|
2538
|
+
}
|
|
2539
|
+
var GITHUB_READ_FILE_PARAMETERS = {
|
|
2540
|
+
type: "OBJECT",
|
|
2541
|
+
properties: {
|
|
2542
|
+
github: { type: "STRING", description: 'owner/repo shorthand (e.g., "vercel/next.js")' },
|
|
2543
|
+
path: { type: "STRING", description: "File path within the repository" },
|
|
2544
|
+
startLine: { type: "NUMBER", description: "Start line number (1-based)" },
|
|
2545
|
+
endLine: { type: "NUMBER", description: "End line number (1-based, inclusive)" },
|
|
2546
|
+
branch: { type: "STRING", description: "Branch to read from (defaults to repo default branch)" }
|
|
2547
|
+
},
|
|
2548
|
+
required: ["github", "path"]
|
|
2549
|
+
};
|
|
2550
|
+
function createGitHubReadFileTool(config) {
|
|
2551
|
+
const declaration = {
|
|
2552
|
+
name: GITHUB_READ_FILE_TOOL_NAME,
|
|
2553
|
+
description: GITHUB_READ_FILE_DESCRIPTION,
|
|
2554
|
+
parameters: GITHUB_READ_FILE_PARAMETERS
|
|
2555
|
+
};
|
|
2556
|
+
return Object.assign(declaration, {
|
|
2557
|
+
execute: async (input) => {
|
|
2558
|
+
return executeGitHubReadFile(input, config);
|
|
2559
|
+
},
|
|
2560
|
+
formatResult: (result) => {
|
|
2561
|
+
return formatGitHubReadFileResult(result);
|
|
2562
|
+
}
|
|
2563
|
+
});
|
|
2564
|
+
}
|
|
2097
2565
|
var gemini_default = warpGrepFunctionDeclaration;
|
|
2098
2566
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2099
2567
|
0 && (module.exports = {
|
|
2568
|
+
createGitHubReadFileTool,
|
|
2569
|
+
createGitHubSearchTool,
|
|
2100
2570
|
createMorphWarpGrepTool,
|
|
2101
2571
|
createWarpGrepTool,
|
|
2102
2572
|
execute,
|