@morphllm/morphsdk 0.2.122 → 0.2.124
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-T3T4LGRD.js → chunk-27BLOUAR.js} +27 -3
- package/dist/chunk-27BLOUAR.js.map +1 -0
- package/dist/{chunk-2MJEULZU.js → chunk-34UAUD5I.js} +2 -2
- package/dist/{chunk-OTGBQEVH.js → chunk-3ZO2UAYM.js} +2 -2
- package/dist/{chunk-L4URLBKV.js → chunk-A2OVRHEW.js} +3 -3
- package/dist/{chunk-7KOUCN6T.js → chunk-BFJAFWMR.js} +2 -2
- package/dist/{chunk-5UUJULLM.js → chunk-DUJ32DHI.js} +2 -2
- package/dist/{chunk-73GZ6KUK.js → chunk-EIJAUTHH.js} +2 -2
- package/dist/{chunk-OWISPSLH.js → chunk-F7VTQZH7.js} +2 -2
- package/dist/{chunk-WYYR2EU6.js → chunk-GVGJIXV2.js} +7 -2
- package/dist/chunk-GVGJIXV2.js.map +1 -0
- package/dist/{chunk-MQWEZJTP.js → chunk-HHRHUUGN.js} +5 -5
- package/dist/chunk-HHRHUUGN.js.map +1 -0
- package/dist/{chunk-TBLMIAIH.js → chunk-ICLIJKYL.js} +25 -3
- package/dist/chunk-ICLIJKYL.js.map +1 -0
- package/dist/{chunk-4GEBF5OH.js → chunk-KAI2DLL5.js} +2 -2
- package/dist/{chunk-GTANVDUZ.js → chunk-KQRX2K2W.js} +2 -2
- package/dist/{chunk-4LA3OT4Q.js → chunk-M6VWLSL4.js} +25 -4
- package/dist/chunk-M6VWLSL4.js.map +1 -0
- package/dist/{chunk-EBROW6GK.js → chunk-N6YX3M4I.js} +2 -2
- package/dist/chunk-OTOVGCG6.js +42 -0
- package/dist/chunk-OTOVGCG6.js.map +1 -0
- package/dist/{chunk-TXT3W4QK.js → chunk-S4RLT56A.js} +81 -3
- package/dist/chunk-S4RLT56A.js.map +1 -0
- package/dist/{chunk-RNKHRNSG.js → chunk-SGRNIWJD.js} +2 -2
- package/dist/{chunk-RNKHRNSG.js.map → chunk-SGRNIWJD.js.map} +1 -1
- package/dist/{chunk-QGE7FGGT.js → chunk-STPK3AAF.js} +2 -2
- package/dist/{chunk-64KNVHR4.js → chunk-V3HLOZK2.js} +1 -1
- package/dist/{chunk-64KNVHR4.js.map → chunk-V3HLOZK2.js.map} +1 -1
- package/dist/{chunk-LE24SVVU.js → chunk-VKQLHW6G.js} +2 -2
- package/dist/{chunk-3PMFQ5AV.js → chunk-W4PYHVIJ.js} +2 -2
- package/dist/{chunk-2AQLRL4U.js → chunk-WG5E7MMA.js} +2 -2
- package/dist/{chunk-4IU2K63O.js → chunk-Z7U7ZRMP.js} +2 -2
- package/dist/{chunk-ZHRT6F72.js → chunk-ZD5PEXNS.js} +1 -1
- package/dist/{chunk-UDGJQBTC.js → chunk-ZVVCJGNL.js} +15 -15
- package/dist/{client-BJrzbMYL.d.ts → client-JHPwle1Z.d.ts} +1 -1
- package/dist/client.cjs +84 -9
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +22 -22
- package/dist/edge.cjs +1 -1
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.js +4 -4
- package/dist/index.cjs +84 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -23
- package/dist/modelrouter/core.cjs +1 -1
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.js +3 -3
- package/dist/modelrouter/index.cjs +1 -1
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.js +3 -3
- package/dist/tools/browser/anthropic.cjs +1 -1
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +5 -5
- package/dist/tools/browser/core.cjs +1 -1
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.js +4 -4
- package/dist/tools/browser/index.cjs +1 -1
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.js +7 -7
- package/dist/tools/browser/openai.cjs +1 -1
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.js +5 -5
- package/dist/tools/browser/profiles/core.cjs +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.js +5 -5
- package/dist/tools/codebase_search/anthropic.cjs +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +4 -4
- package/dist/tools/fastapply/apply.cjs +1 -1
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +2 -2
- package/dist/tools/fastapply/core.cjs +1 -1
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.js +3 -3
- package/dist/tools/fastapply/index.cjs +1 -1
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.js +6 -6
- package/dist/tools/fastapply/openai.cjs +1 -1
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +4 -4
- package/dist/tools/fastapply/vercel.cjs +1 -1
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +4 -4
- package/dist/tools/index.cjs +1 -1
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +6 -6
- package/dist/tools/utils/resilience.cjs +1 -1
- 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 +4 -4
- 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 +123 -9
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +29 -2
- package/dist/tools/warp_grep/anthropic.js +8 -6
- package/dist/tools/warp_grep/client.cjs +90 -5
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.d.ts +27 -2
- package/dist/tools/warp_grep/client.js +8 -4
- package/dist/tools/warp_grep/gemini.cjs +120 -7
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.d.ts +29 -2
- package/dist/tools/warp_grep/gemini.js +36 -5
- package/dist/tools/warp_grep/gemini.js.map +1 -1
- package/dist/tools/warp_grep/index.cjs +116 -9
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +32 -4
- package/dist/tools/warp_grep/index.js +16 -6
- package/dist/tools/warp_grep/openai.cjs +126 -9
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +29 -2
- package/dist/tools/warp_grep/openai.js +8 -6
- package/dist/tools/warp_grep/providers/code_storage_http.cjs +6 -1
- package/dist/tools/warp_grep/providers/code_storage_http.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/code_storage_http.d.ts +1 -1
- package/dist/tools/warp_grep/providers/code_storage_http.js +1 -1
- package/dist/tools/warp_grep/providers/remote.d.ts +1 -1
- package/dist/tools/warp_grep/vercel.cjs +101 -6
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +30 -2
- package/dist/tools/warp_grep/vercel.js +8 -6
- package/dist/{types-CA7989hK.d.ts → types-DY_hq2eZ.d.ts} +37 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-4LA3OT4Q.js.map +0 -1
- package/dist/chunk-KJZMKDDP.js +0 -23
- package/dist/chunk-KJZMKDDP.js.map +0 -1
- package/dist/chunk-MQWEZJTP.js.map +0 -1
- package/dist/chunk-T3T4LGRD.js.map +0 -1
- package/dist/chunk-TBLMIAIH.js.map +0 -1
- package/dist/chunk-TXT3W4QK.js.map +0 -1
- package/dist/chunk-WYYR2EU6.js.map +0 -1
- /package/dist/{chunk-2MJEULZU.js.map → chunk-34UAUD5I.js.map} +0 -0
- /package/dist/{chunk-OTGBQEVH.js.map → chunk-3ZO2UAYM.js.map} +0 -0
- /package/dist/{chunk-L4URLBKV.js.map → chunk-A2OVRHEW.js.map} +0 -0
- /package/dist/{chunk-7KOUCN6T.js.map → chunk-BFJAFWMR.js.map} +0 -0
- /package/dist/{chunk-5UUJULLM.js.map → chunk-DUJ32DHI.js.map} +0 -0
- /package/dist/{chunk-73GZ6KUK.js.map → chunk-EIJAUTHH.js.map} +0 -0
- /package/dist/{chunk-OWISPSLH.js.map → chunk-F7VTQZH7.js.map} +0 -0
- /package/dist/{chunk-4GEBF5OH.js.map → chunk-KAI2DLL5.js.map} +0 -0
- /package/dist/{chunk-GTANVDUZ.js.map → chunk-KQRX2K2W.js.map} +0 -0
- /package/dist/{chunk-EBROW6GK.js.map → chunk-N6YX3M4I.js.map} +0 -0
- /package/dist/{chunk-QGE7FGGT.js.map → chunk-STPK3AAF.js.map} +0 -0
- /package/dist/{chunk-LE24SVVU.js.map → chunk-VKQLHW6G.js.map} +0 -0
- /package/dist/{chunk-3PMFQ5AV.js.map → chunk-W4PYHVIJ.js.map} +0 -0
- /package/dist/{chunk-2AQLRL4U.js.map → chunk-WG5E7MMA.js.map} +0 -0
- /package/dist/{chunk-4IU2K63O.js.map → chunk-Z7U7ZRMP.js.map} +0 -0
- /package/dist/{chunk-ZHRT6F72.js.map → chunk-ZD5PEXNS.js.map} +0 -0
- /package/dist/{chunk-UDGJQBTC.js.map → chunk-ZVVCJGNL.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Tool } from '@anthropic-ai/sdk/resources/messages';
|
|
2
2
|
export { formatResult } from './client.js';
|
|
3
3
|
export { getSystemPrompt } from './agent/prompt.js';
|
|
4
|
-
import { d as WarpGrepToolConfig, b as WarpGrepResult,
|
|
4
|
+
import { d as WarpGrepToolConfig, b as WarpGrepResult, g as GitHubSearchToolConfig, h as GitHubReadFileToolConfig, e as GitHubReadFileInput, f as GitHubReadFileResult } from '../../types-DY_hq2eZ.js';
|
|
5
5
|
import './agent/types.js';
|
|
6
6
|
import '../utils/resilience.js';
|
|
7
7
|
import './providers/types.js';
|
|
@@ -112,5 +112,32 @@ declare function createGitHubSearchTool(config: GitHubSearchToolConfig): Tool &
|
|
|
112
112
|
formatResult: (result: WarpGrepResult) => string;
|
|
113
113
|
getSystemPrompt: () => string;
|
|
114
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* Create a GitHub read file tool for Anthropic SDK
|
|
117
|
+
*
|
|
118
|
+
* @param config - Optional configuration (timeout)
|
|
119
|
+
* @returns Anthropic Tool with execute and formatResult methods
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* import Anthropic from '@anthropic-ai/sdk';
|
|
124
|
+
* import { createGitHubReadFileTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';
|
|
125
|
+
*
|
|
126
|
+
* const tool = createGitHubReadFileTool();
|
|
127
|
+
*
|
|
128
|
+
* const response = await client.messages.create({
|
|
129
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
130
|
+
* tools: [tool],
|
|
131
|
+
* messages: [{ role: 'user', content: 'Read the package.json from vercel/next.js' }]
|
|
132
|
+
* });
|
|
133
|
+
*
|
|
134
|
+
* const result = await tool.execute({ github: 'vercel/next.js', path: 'package.json' });
|
|
135
|
+
* console.log(tool.formatResult(result));
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
declare function createGitHubReadFileTool(config?: GitHubReadFileToolConfig): Tool & {
|
|
139
|
+
execute: (input: GitHubReadFileInput) => Promise<GitHubReadFileResult>;
|
|
140
|
+
formatResult: (result: GitHubReadFileResult) => string;
|
|
141
|
+
};
|
|
115
142
|
|
|
116
|
-
export { createGitHubSearchTool, createWarpGrepTool, execute, warpGrepTool };
|
|
143
|
+
export { createGitHubReadFileTool, createGitHubSearchTool, createWarpGrepTool, execute, warpGrepTool };
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
+
createGitHubReadFileTool,
|
|
2
3
|
createGitHubSearchTool,
|
|
3
4
|
createWarpGrepTool,
|
|
4
5
|
execute,
|
|
5
6
|
warpGrepTool
|
|
6
|
-
} from "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
7
|
+
} from "../../chunk-M6VWLSL4.js";
|
|
8
|
+
import "../../chunk-OTOVGCG6.js";
|
|
8
9
|
import {
|
|
9
10
|
formatResult
|
|
10
|
-
} from "../../chunk-
|
|
11
|
-
import "../../chunk-
|
|
11
|
+
} from "../../chunk-S4RLT56A.js";
|
|
12
|
+
import "../../chunk-GVGJIXV2.js";
|
|
12
13
|
import "../../chunk-PUGSTXLO.js";
|
|
13
14
|
import "../../chunk-63VHBANJ.js";
|
|
14
|
-
import "../../chunk-
|
|
15
|
+
import "../../chunk-HHRHUUGN.js";
|
|
15
16
|
import "../../chunk-3MLWXJTJ.js";
|
|
16
17
|
import "../../chunk-5PNMAWLC.js";
|
|
17
18
|
import "../../chunk-APP75CBN.js";
|
|
@@ -19,9 +20,10 @@ import "../../chunk-GHGJAQSJ.js";
|
|
|
19
20
|
import {
|
|
20
21
|
getSystemPrompt
|
|
21
22
|
} from "../../chunk-FMLHRJDF.js";
|
|
22
|
-
import "../../chunk-
|
|
23
|
+
import "../../chunk-SGRNIWJD.js";
|
|
23
24
|
import "../../chunk-PZ5AY32C.js";
|
|
24
25
|
export {
|
|
26
|
+
createGitHubReadFileTool,
|
|
25
27
|
createGitHubSearchTool,
|
|
26
28
|
createWarpGrepTool,
|
|
27
29
|
execute,
|
|
@@ -573,9 +573,11 @@ Details: ${res.stderr}` : ""}`
|
|
|
573
573
|
var client_exports = {};
|
|
574
574
|
__export(client_exports, {
|
|
575
575
|
WarpGrepClient: () => WarpGrepClient,
|
|
576
|
+
executeGitHubReadFile: () => executeGitHubReadFile,
|
|
576
577
|
executeToolCall: () => executeToolCall,
|
|
577
578
|
executeToolCallStreaming: () => executeToolCallStreaming,
|
|
578
579
|
executeWarpGrep: () => executeWarpGrep,
|
|
580
|
+
formatGitHubReadFileResult: () => formatGitHubReadFileResult,
|
|
579
581
|
formatResult: () => formatResult
|
|
580
582
|
});
|
|
581
583
|
module.exports = __toCommonJS(client_exports);
|
|
@@ -1377,7 +1379,7 @@ var import_openai = __toESM(require("openai"), 1);
|
|
|
1377
1379
|
// package.json
|
|
1378
1380
|
var package_default = {
|
|
1379
1381
|
name: "@morphllm/morphsdk",
|
|
1380
|
-
version: "0.2.
|
|
1382
|
+
version: "0.2.124",
|
|
1381
1383
|
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
1382
1384
|
type: "module",
|
|
1383
1385
|
main: "./dist/index.cjs",
|
|
@@ -1627,9 +1629,9 @@ async function callModel(messages, model, options = {}) {
|
|
|
1627
1629
|
});
|
|
1628
1630
|
} catch (error) {
|
|
1629
1631
|
if (error instanceof import_openai.default.APIError && error.status === 404) {
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
);
|
|
1632
|
+
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";
|
|
1633
|
+
const errorText = error.message?.trim();
|
|
1634
|
+
throw new Error(errorText || defaultMsg);
|
|
1633
1635
|
}
|
|
1634
1636
|
throw error;
|
|
1635
1637
|
}
|
|
@@ -2166,7 +2168,12 @@ async function post(url, body, op) {
|
|
|
2166
2168
|
});
|
|
2167
2169
|
if (!res.ok) {
|
|
2168
2170
|
const text = await res.text().catch(() => res.statusText);
|
|
2169
|
-
|
|
2171
|
+
try {
|
|
2172
|
+
const parsed = JSON.parse(text);
|
|
2173
|
+
if (parsed.error) return `Error: ${parsed.error}`;
|
|
2174
|
+
} catch {
|
|
2175
|
+
}
|
|
2176
|
+
return `Error: ${op} failed (${res.status}): ${text}`;
|
|
2170
2177
|
}
|
|
2171
2178
|
const data = await res.json();
|
|
2172
2179
|
if (data.error) throw new Error(data.error);
|
|
@@ -2235,6 +2242,23 @@ var WarpGrepClient = class {
|
|
|
2235
2242
|
}
|
|
2236
2243
|
return this._searchGitHubAsync(input);
|
|
2237
2244
|
}
|
|
2245
|
+
/**
|
|
2246
|
+
* Read a single file from a public GitHub repository
|
|
2247
|
+
*
|
|
2248
|
+
* @example
|
|
2249
|
+
* ```typescript
|
|
2250
|
+
* const result = await client.readGitHubFile({
|
|
2251
|
+
* github: 'vercel/next.js',
|
|
2252
|
+
* path: 'src/server/app-render/index.tsx',
|
|
2253
|
+
* startLine: 1,
|
|
2254
|
+
* endLine: 50,
|
|
2255
|
+
* });
|
|
2256
|
+
* if (result.success) console.log(result.content);
|
|
2257
|
+
* ```
|
|
2258
|
+
*/
|
|
2259
|
+
async readGitHubFile(input) {
|
|
2260
|
+
return executeGitHubReadFile(input, { timeout: this.config.timeout });
|
|
2261
|
+
}
|
|
2238
2262
|
async _resolveGitHubRepo(input) {
|
|
2239
2263
|
const { owner, repo } = parseGitHubUrl(input.github);
|
|
2240
2264
|
const baseUrl = this.config.codeSearchUrl || DEFAULT_CODE_SEARCH_URL;
|
|
@@ -2362,6 +2386,65 @@ async function* executeToolCallStreaming(input, config) {
|
|
|
2362
2386
|
}
|
|
2363
2387
|
return processAgentResult(agentResult);
|
|
2364
2388
|
}
|
|
2389
|
+
async function fetchRawGitHubFile(owner, repo, filePath, branch, timeout) {
|
|
2390
|
+
const branches = branch ? [branch] : ["HEAD"];
|
|
2391
|
+
const fallbacks = ["main", "master", "develop"];
|
|
2392
|
+
const fetchWithTimeout = (url) => timeout ? fetch(url, { signal: AbortSignal.timeout(timeout) }) : fetch(url);
|
|
2393
|
+
for (const b of branches) {
|
|
2394
|
+
const url = `https://raw.githubusercontent.com/${owner}/${repo}/${b}/${filePath}`;
|
|
2395
|
+
const res = await fetchWithTimeout(url);
|
|
2396
|
+
if (res.ok) return { content: await res.text(), branch: b };
|
|
2397
|
+
}
|
|
2398
|
+
for (const fb of fallbacks) {
|
|
2399
|
+
if (branch && fb === branch) continue;
|
|
2400
|
+
const url = `https://raw.githubusercontent.com/${owner}/${repo}/${fb}/${filePath}`;
|
|
2401
|
+
const res = await fetchWithTimeout(url);
|
|
2402
|
+
if (res.ok) return { content: await res.text(), branch: fb };
|
|
2403
|
+
}
|
|
2404
|
+
throw new Error(`File not found: ${owner}/${repo}/${filePath}`);
|
|
2405
|
+
}
|
|
2406
|
+
async function executeGitHubReadFile(input, config) {
|
|
2407
|
+
try {
|
|
2408
|
+
const { owner, repo } = parseGitHubUrl(input.github);
|
|
2409
|
+
const { content: raw, branch } = await fetchRawGitHubFile(
|
|
2410
|
+
owner,
|
|
2411
|
+
repo,
|
|
2412
|
+
input.path,
|
|
2413
|
+
input.branch,
|
|
2414
|
+
config?.timeout
|
|
2415
|
+
);
|
|
2416
|
+
const allLines = raw.split("\n");
|
|
2417
|
+
const totalLines = allLines.length;
|
|
2418
|
+
const start = Math.max(1, input.startLine ?? 1);
|
|
2419
|
+
const end = Math.min(totalLines, input.endLine ?? totalLines);
|
|
2420
|
+
const selected = allLines.slice(start - 1, end);
|
|
2421
|
+
const padWidth = String(end).length;
|
|
2422
|
+
const numbered = selected.map((line, i) => `${String(start + i).padStart(padWidth)}|${line}`).join("\n");
|
|
2423
|
+
return {
|
|
2424
|
+
success: true,
|
|
2425
|
+
content: numbered,
|
|
2426
|
+
path: input.path,
|
|
2427
|
+
github: `${owner}/${repo}`,
|
|
2428
|
+
branch,
|
|
2429
|
+
lineRange: [start, end],
|
|
2430
|
+
totalLines
|
|
2431
|
+
};
|
|
2432
|
+
} catch (error) {
|
|
2433
|
+
return {
|
|
2434
|
+
success: false,
|
|
2435
|
+
error: error instanceof Error ? error.message : String(error)
|
|
2436
|
+
};
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
function formatGitHubReadFileResult(result) {
|
|
2440
|
+
if (!result.success) {
|
|
2441
|
+
return `Failed to read file: ${result.error}`;
|
|
2442
|
+
}
|
|
2443
|
+
const rangeStr = result.lineRange ? ` (lines ${result.lineRange[0]}-${result.lineRange[1]} of ${result.totalLines})` : "";
|
|
2444
|
+
return `File: ${result.github}/${result.path}${rangeStr}
|
|
2445
|
+
|
|
2446
|
+
${result.content}`;
|
|
2447
|
+
}
|
|
2365
2448
|
function formatResult(result) {
|
|
2366
2449
|
if (!result.success) {
|
|
2367
2450
|
return `Search failed: ${result.error}`;
|
|
@@ -2389,9 +2472,11 @@ function formatResult(result) {
|
|
|
2389
2472
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2390
2473
|
0 && (module.exports = {
|
|
2391
2474
|
WarpGrepClient,
|
|
2475
|
+
executeGitHubReadFile,
|
|
2392
2476
|
executeToolCall,
|
|
2393
2477
|
executeToolCallStreaming,
|
|
2394
2478
|
executeWarpGrep,
|
|
2479
|
+
formatGitHubReadFileResult,
|
|
2395
2480
|
formatResult
|
|
2396
2481
|
});
|
|
2397
2482
|
//# sourceMappingURL=client.cjs.map
|