@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
|
@@ -572,6 +572,8 @@ Details: ${res.stderr}` : ""}`
|
|
|
572
572
|
// tools/warp_grep/anthropic.ts
|
|
573
573
|
var anthropic_exports = {};
|
|
574
574
|
__export(anthropic_exports, {
|
|
575
|
+
createGitHubReadFileTool: () => createGitHubReadFileTool,
|
|
576
|
+
createGitHubSearchTool: () => createGitHubSearchTool,
|
|
575
577
|
createWarpGrepTool: () => createWarpGrepTool,
|
|
576
578
|
execute: () => execute,
|
|
577
579
|
formatResult: () => formatResult,
|
|
@@ -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.123",
|
|
1381
1383
|
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
1382
1384
|
type: "module",
|
|
1383
1385
|
main: "./dist/index.cjs",
|
|
@@ -1519,7 +1521,7 @@ var package_default = {
|
|
|
1519
1521
|
"!dist/**/*.test.*"
|
|
1520
1522
|
],
|
|
1521
1523
|
scripts: {
|
|
1522
|
-
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",
|
|
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/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",
|
|
1523
1525
|
prepare: "npm run build",
|
|
1524
1526
|
typecheck: "tsc --noEmit",
|
|
1525
1527
|
lint: "eslint .",
|
|
@@ -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
|
}
|
|
@@ -1810,6 +1812,171 @@ async function runWarpGrep(config) {
|
|
|
1810
1812
|
timings
|
|
1811
1813
|
};
|
|
1812
1814
|
}
|
|
1815
|
+
async function* runWarpGrepStreaming(config) {
|
|
1816
|
+
const totalStart = Date.now();
|
|
1817
|
+
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1818
|
+
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
1819
|
+
const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
|
|
1820
|
+
const messages = [];
|
|
1821
|
+
messages.push({ role: "system", content: getSystemPrompt() });
|
|
1822
|
+
const initialStateStart = Date.now();
|
|
1823
|
+
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
1824
|
+
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1825
|
+
messages.push({ role: "user", content: initialState });
|
|
1826
|
+
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1827
|
+
const model = config.model || DEFAULT_MODEL;
|
|
1828
|
+
const provider = config.provider;
|
|
1829
|
+
const errors = [];
|
|
1830
|
+
let finishMeta;
|
|
1831
|
+
let terminationReason = "terminated";
|
|
1832
|
+
for (let turn = 1; turn <= maxTurns; turn += 1) {
|
|
1833
|
+
const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
|
|
1834
|
+
enforceContextLimit(messages);
|
|
1835
|
+
const modelCallStart = Date.now();
|
|
1836
|
+
const assistantContent = await callModel(messages, model, {
|
|
1837
|
+
morphApiKey: config.morphApiKey,
|
|
1838
|
+
morphApiUrl: config.morphApiUrl,
|
|
1839
|
+
retryConfig: config.retryConfig,
|
|
1840
|
+
timeout: timeoutMs
|
|
1841
|
+
}).catch((e) => {
|
|
1842
|
+
const errMsg = e instanceof Error ? e.message : String(e);
|
|
1843
|
+
console.error(`[warp_grep:stream] Morph API call failed on turn ${turn}:`, errMsg);
|
|
1844
|
+
errors.push({ message: errMsg });
|
|
1845
|
+
return "";
|
|
1846
|
+
});
|
|
1847
|
+
turnMetrics.morph_api_ms = Date.now() - modelCallStart;
|
|
1848
|
+
if (!assistantContent) {
|
|
1849
|
+
console.error(`[warp_grep:stream] Empty response from Morph API on turn ${turn}. Errors so far:`, errors);
|
|
1850
|
+
timings.turns.push(turnMetrics);
|
|
1851
|
+
break;
|
|
1852
|
+
}
|
|
1853
|
+
messages.push({ role: "assistant", content: assistantContent });
|
|
1854
|
+
const toolCalls = parser.parse(assistantContent);
|
|
1855
|
+
if (toolCalls.length === 0) {
|
|
1856
|
+
console.error(`[warp_grep:stream] No tool calls parsed on turn ${turn}. Assistant content (first 500 chars):`, assistantContent.slice(0, 500));
|
|
1857
|
+
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" });
|
|
1858
|
+
terminationReason = "terminated";
|
|
1859
|
+
timings.turns.push(turnMetrics);
|
|
1860
|
+
break;
|
|
1861
|
+
}
|
|
1862
|
+
yield {
|
|
1863
|
+
turn,
|
|
1864
|
+
toolCalls: toolCalls.map((c) => ({
|
|
1865
|
+
name: c.name,
|
|
1866
|
+
arguments: c.arguments ?? {}
|
|
1867
|
+
}))
|
|
1868
|
+
};
|
|
1869
|
+
const finishCalls = toolCalls.filter((c) => c.name === "finish");
|
|
1870
|
+
const grepCalls = toolCalls.filter((c) => c.name === "grep");
|
|
1871
|
+
const listDirCalls = toolCalls.filter((c) => c.name === "list_directory");
|
|
1872
|
+
const readCalls = toolCalls.filter((c) => c.name === "read");
|
|
1873
|
+
const skipCalls = toolCalls.filter((c) => c.name === "_skip");
|
|
1874
|
+
const formatted = [];
|
|
1875
|
+
for (const c of skipCalls) {
|
|
1876
|
+
const msg = c.arguments?.message || "Command skipped due to parsing error";
|
|
1877
|
+
formatted.push(msg);
|
|
1878
|
+
}
|
|
1879
|
+
const allPromises = [];
|
|
1880
|
+
for (const c of grepCalls) {
|
|
1881
|
+
const args = c.arguments ?? {};
|
|
1882
|
+
allPromises.push(
|
|
1883
|
+
toolGrep(provider, args).then(
|
|
1884
|
+
({ output }) => formatAgentToolOutput("grep", args, output, { isError: false }),
|
|
1885
|
+
(err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
|
|
1886
|
+
)
|
|
1887
|
+
);
|
|
1888
|
+
}
|
|
1889
|
+
for (const c of listDirCalls) {
|
|
1890
|
+
const args = c.arguments ?? {};
|
|
1891
|
+
allPromises.push(
|
|
1892
|
+
toolListDirectory(provider, args).then(
|
|
1893
|
+
(p) => formatAgentToolOutput("list_directory", args, p, { isError: false }),
|
|
1894
|
+
(err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
|
|
1895
|
+
)
|
|
1896
|
+
);
|
|
1897
|
+
}
|
|
1898
|
+
for (const c of readCalls) {
|
|
1899
|
+
const args = c.arguments ?? {};
|
|
1900
|
+
allPromises.push(
|
|
1901
|
+
toolRead(provider, args).then(
|
|
1902
|
+
(p) => formatAgentToolOutput("read", args, p, { isError: false }),
|
|
1903
|
+
(err) => formatAgentToolOutput("read", args, String(err), { isError: true })
|
|
1904
|
+
)
|
|
1905
|
+
);
|
|
1906
|
+
}
|
|
1907
|
+
const toolExecStart = Date.now();
|
|
1908
|
+
const allResults = await Promise.all(allPromises);
|
|
1909
|
+
turnMetrics.local_tools_ms = Date.now() - toolExecStart;
|
|
1910
|
+
for (const result of allResults) {
|
|
1911
|
+
formatted.push(result);
|
|
1912
|
+
}
|
|
1913
|
+
if (formatted.length > 0) {
|
|
1914
|
+
const turnMessage = formatTurnMessage(turn, maxTurns);
|
|
1915
|
+
const contextBudget = calculateContextBudget(messages);
|
|
1916
|
+
messages.push({ role: "user", content: formatted.join("\n") + turnMessage + "\n" + contextBudget });
|
|
1917
|
+
}
|
|
1918
|
+
timings.turns.push(turnMetrics);
|
|
1919
|
+
if (finishCalls.length) {
|
|
1920
|
+
const fc = finishCalls[0];
|
|
1921
|
+
const files = fc.arguments?.files ?? [];
|
|
1922
|
+
const textResult = fc.arguments?.textResult;
|
|
1923
|
+
finishMeta = { files };
|
|
1924
|
+
terminationReason = "completed";
|
|
1925
|
+
if (files.length === 0) {
|
|
1926
|
+
const payload2 = textResult || "No relevant code found.";
|
|
1927
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1928
|
+
return {
|
|
1929
|
+
terminationReason: "completed",
|
|
1930
|
+
messages,
|
|
1931
|
+
finish: { payload: payload2, metadata: finishMeta },
|
|
1932
|
+
timings
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
break;
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
if (terminationReason !== "completed" || !finishMeta) {
|
|
1939
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1940
|
+
return { terminationReason, messages, errors, timings };
|
|
1941
|
+
}
|
|
1942
|
+
const parts = ["Relevant context found:"];
|
|
1943
|
+
for (const f of finishMeta.files) {
|
|
1944
|
+
const ranges = f.lines === "*" ? "*" : Array.isArray(f.lines) ? f.lines.map(([s, e]) => `${s}-${e}`).join(", ") : "*";
|
|
1945
|
+
parts.push(`- ${f.path}: ${ranges}`);
|
|
1946
|
+
}
|
|
1947
|
+
const payload = parts.join("\n");
|
|
1948
|
+
const finishResolutionStart = Date.now();
|
|
1949
|
+
const fileReadErrors = [];
|
|
1950
|
+
const resolved = await readFinishFiles(
|
|
1951
|
+
repoRoot,
|
|
1952
|
+
finishMeta.files,
|
|
1953
|
+
async (p, s, e) => {
|
|
1954
|
+
try {
|
|
1955
|
+
const rr = await provider.read({ path: p, start: s, end: e });
|
|
1956
|
+
return rr.lines.map((l) => {
|
|
1957
|
+
const idx = l.indexOf("|");
|
|
1958
|
+
return idx >= 0 ? l.slice(idx + 1) : l;
|
|
1959
|
+
});
|
|
1960
|
+
} catch (err) {
|
|
1961
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
1962
|
+
fileReadErrors.push({ path: p, error: errorMsg });
|
|
1963
|
+
console.error(`[warp_grep] Failed to read file: ${p} - ${errorMsg}`);
|
|
1964
|
+
return [`[couldn't find: ${p}]`];
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
);
|
|
1968
|
+
timings.finish_resolution_ms = Date.now() - finishResolutionStart;
|
|
1969
|
+
if (fileReadErrors.length > 0) {
|
|
1970
|
+
errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
|
|
1971
|
+
}
|
|
1972
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1973
|
+
return {
|
|
1974
|
+
terminationReason: "completed",
|
|
1975
|
+
messages,
|
|
1976
|
+
finish: { payload, metadata: finishMeta, resolved },
|
|
1977
|
+
timings
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1813
1980
|
|
|
1814
1981
|
// tools/warp_grep/providers/remote.ts
|
|
1815
1982
|
init_config();
|
|
@@ -1992,11 +2159,153 @@ var RemoteCommandsProvider = class {
|
|
|
1992
2159
|
}
|
|
1993
2160
|
};
|
|
1994
2161
|
|
|
2162
|
+
// tools/warp_grep/providers/code_storage_http.ts
|
|
2163
|
+
async function post(url, body, op) {
|
|
2164
|
+
const res = await fetch(url, {
|
|
2165
|
+
method: "POST",
|
|
2166
|
+
headers: { "Content-Type": "application/json" },
|
|
2167
|
+
body: JSON.stringify(body)
|
|
2168
|
+
});
|
|
2169
|
+
if (!res.ok) {
|
|
2170
|
+
const text = await res.text().catch(() => res.statusText);
|
|
2171
|
+
throw new Error(`${op} failed (${res.status}): ${text}`);
|
|
2172
|
+
}
|
|
2173
|
+
const data = await res.json();
|
|
2174
|
+
if (data.error) throw new Error(data.error);
|
|
2175
|
+
return data.stdout;
|
|
2176
|
+
}
|
|
2177
|
+
function createCodeStorageHttpCommands(config) {
|
|
2178
|
+
const { baseUrl, repoId, branch } = config;
|
|
2179
|
+
const encodedRepoId = encodeURIComponent(repoId);
|
|
2180
|
+
return {
|
|
2181
|
+
grep: (pattern, path5, glob) => post(`${baseUrl}/api/code-search/${encodedRepoId}/grep`, { pattern, path: path5, glob, branch }, "grep"),
|
|
2182
|
+
read: (path5, start, end) => post(`${baseUrl}/api/code-search/${encodedRepoId}/read`, { path: path5, start, end, branch }, "read"),
|
|
2183
|
+
listDir: (path5, maxDepth) => post(`${baseUrl}/api/code-search/${encodedRepoId}/list`, { path: path5, maxDepth, branch }, "list")
|
|
2184
|
+
};
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
// tools/warp_grep/utils/github.ts
|
|
2188
|
+
function parseGitHubUrl(input) {
|
|
2189
|
+
input = input.trim();
|
|
2190
|
+
const urlPattern = /^(?:https?:\/\/)?github\.com\/([^\/]+)\/([^\/\?\#]+)/;
|
|
2191
|
+
const match = input.match(urlPattern);
|
|
2192
|
+
if (match) {
|
|
2193
|
+
return { owner: match[1], repo: match[2].replace(/\.git$/, "") };
|
|
2194
|
+
}
|
|
2195
|
+
const shortPattern = /^([^\/]+)\/([^\/]+)$/;
|
|
2196
|
+
const shortMatch = input.match(shortPattern);
|
|
2197
|
+
if (shortMatch && !shortMatch[1].includes(".")) {
|
|
2198
|
+
return { owner: shortMatch[1], repo: shortMatch[2].replace(/\.git$/, "") };
|
|
2199
|
+
}
|
|
2200
|
+
throw new Error(
|
|
2201
|
+
`Invalid GitHub URL or shorthand: "${input}". Expected "owner/repo" or "https://github.com/owner/repo"`
|
|
2202
|
+
);
|
|
2203
|
+
}
|
|
2204
|
+
|
|
1995
2205
|
// tools/warp_grep/client.ts
|
|
2206
|
+
var DEFAULT_CODE_SEARCH_URL = "https://morphllm.com";
|
|
1996
2207
|
async function getLocalProvider(repoRoot, excludes) {
|
|
1997
2208
|
const { LocalRipgrepProvider: LocalRipgrepProvider2 } = await Promise.resolve().then(() => (init_local(), local_exports));
|
|
1998
2209
|
return new LocalRipgrepProvider2(repoRoot, excludes);
|
|
1999
2210
|
}
|
|
2211
|
+
var WarpGrepClient = class {
|
|
2212
|
+
config;
|
|
2213
|
+
constructor(config = {}) {
|
|
2214
|
+
this.config = { ...config };
|
|
2215
|
+
}
|
|
2216
|
+
execute(input) {
|
|
2217
|
+
const toolConfig = {
|
|
2218
|
+
repoRoot: input.repoRoot,
|
|
2219
|
+
remoteCommands: input.remoteCommands,
|
|
2220
|
+
provider: input.provider,
|
|
2221
|
+
excludes: input.excludes,
|
|
2222
|
+
includes: input.includes,
|
|
2223
|
+
debug: input.debug ?? this.config.debug,
|
|
2224
|
+
morphApiKey: this.config.morphApiKey,
|
|
2225
|
+
morphApiUrl: this.config.morphApiUrl,
|
|
2226
|
+
retryConfig: this.config.retryConfig,
|
|
2227
|
+
timeout: this.config.timeout
|
|
2228
|
+
};
|
|
2229
|
+
if (input.streamSteps) {
|
|
2230
|
+
return executeToolCallStreaming({ query: input.query }, toolConfig);
|
|
2231
|
+
}
|
|
2232
|
+
return executeToolCall({ query: input.query }, toolConfig);
|
|
2233
|
+
}
|
|
2234
|
+
searchGitHub(input) {
|
|
2235
|
+
if (input.streamSteps) {
|
|
2236
|
+
return this._searchGitHubStreaming(input);
|
|
2237
|
+
}
|
|
2238
|
+
return this._searchGitHubAsync(input);
|
|
2239
|
+
}
|
|
2240
|
+
/**
|
|
2241
|
+
* Read a single file from a public GitHub repository
|
|
2242
|
+
*
|
|
2243
|
+
* @example
|
|
2244
|
+
* ```typescript
|
|
2245
|
+
* const result = await client.readGitHubFile({
|
|
2246
|
+
* github: 'vercel/next.js',
|
|
2247
|
+
* path: 'src/server/app-render/index.tsx',
|
|
2248
|
+
* startLine: 1,
|
|
2249
|
+
* endLine: 50,
|
|
2250
|
+
* });
|
|
2251
|
+
* if (result.success) console.log(result.content);
|
|
2252
|
+
* ```
|
|
2253
|
+
*/
|
|
2254
|
+
async readGitHubFile(input) {
|
|
2255
|
+
return executeGitHubReadFile(input, { timeout: this.config.timeout });
|
|
2256
|
+
}
|
|
2257
|
+
async _resolveGitHubRepo(input) {
|
|
2258
|
+
const { owner, repo } = parseGitHubUrl(input.github);
|
|
2259
|
+
const baseUrl = this.config.codeSearchUrl || DEFAULT_CODE_SEARCH_URL;
|
|
2260
|
+
const importRes = await fetch(`${baseUrl}/api/code-search/get-or-create?url=${encodeURIComponent(`${owner}/${repo}`)}`);
|
|
2261
|
+
if (!importRes.ok) {
|
|
2262
|
+
const text = await importRes.text().catch(() => importRes.statusText);
|
|
2263
|
+
throw new Error(`Failed to import repo ${owner}/${repo}: ${text}`);
|
|
2264
|
+
}
|
|
2265
|
+
const { repoId, defaultBranch } = await importRes.json();
|
|
2266
|
+
return {
|
|
2267
|
+
repo,
|
|
2268
|
+
remoteCommands: createCodeStorageHttpCommands({ baseUrl, repoId, branch: input.branch || defaultBranch })
|
|
2269
|
+
};
|
|
2270
|
+
}
|
|
2271
|
+
async _searchGitHubAsync(input) {
|
|
2272
|
+
try {
|
|
2273
|
+
const { repo, remoteCommands } = await this._resolveGitHubRepo(input);
|
|
2274
|
+
return this.execute({
|
|
2275
|
+
query: input.query,
|
|
2276
|
+
repoRoot: repo,
|
|
2277
|
+
remoteCommands
|
|
2278
|
+
});
|
|
2279
|
+
} catch (error) {
|
|
2280
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
async *_searchGitHubStreaming(input) {
|
|
2284
|
+
let repo;
|
|
2285
|
+
let remoteCommands;
|
|
2286
|
+
try {
|
|
2287
|
+
({ repo, remoteCommands } = await this._resolveGitHubRepo(input));
|
|
2288
|
+
} catch (error) {
|
|
2289
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
2290
|
+
}
|
|
2291
|
+
const generator = this.execute({
|
|
2292
|
+
query: input.query,
|
|
2293
|
+
repoRoot: repo,
|
|
2294
|
+
remoteCommands,
|
|
2295
|
+
streamSteps: true
|
|
2296
|
+
});
|
|
2297
|
+
let result;
|
|
2298
|
+
for (; ; ) {
|
|
2299
|
+
const { value, done } = await generator.next();
|
|
2300
|
+
if (done) {
|
|
2301
|
+
result = value;
|
|
2302
|
+
break;
|
|
2303
|
+
}
|
|
2304
|
+
yield value;
|
|
2305
|
+
}
|
|
2306
|
+
return result;
|
|
2307
|
+
}
|
|
2308
|
+
};
|
|
2000
2309
|
async function executeToolCall(input, config) {
|
|
2001
2310
|
const parsed = typeof input === "string" ? JSON.parse(input) : input;
|
|
2002
2311
|
const provider = config.remoteCommands ? new RemoteCommandsProvider(config.repoRoot, config.remoteCommands) : config.provider ?? await getLocalProvider(config.repoRoot, config.excludes);
|
|
@@ -2025,6 +2334,105 @@ async function executeToolCall(input, config) {
|
|
|
2025
2334
|
}));
|
|
2026
2335
|
return { success: true, contexts, summary: finish.payload };
|
|
2027
2336
|
}
|
|
2337
|
+
function processAgentResult(result) {
|
|
2338
|
+
const finish = result.finish;
|
|
2339
|
+
if (result.terminationReason !== "completed" || !finish?.metadata) {
|
|
2340
|
+
const errorDetails = result.errors?.map((e) => e.message).join("; ") || "unknown reason";
|
|
2341
|
+
console.error(`[warp_grep] processAgentResult failed. Reason: ${result.terminationReason}. Errors: ${errorDetails}. Turns: ${result.timings?.turns?.length ?? 0}`);
|
|
2342
|
+
return { success: false, error: `Search did not complete: ${errorDetails}` };
|
|
2343
|
+
}
|
|
2344
|
+
const contexts = (finish.resolved ?? []).map((r) => ({
|
|
2345
|
+
file: r.path,
|
|
2346
|
+
content: r.content,
|
|
2347
|
+
lines: r.ranges
|
|
2348
|
+
}));
|
|
2349
|
+
return { success: true, contexts, summary: finish.payload };
|
|
2350
|
+
}
|
|
2351
|
+
async function* executeToolCallStreaming(input, config) {
|
|
2352
|
+
const parsed = typeof input === "string" ? JSON.parse(input) : input;
|
|
2353
|
+
const provider = config.remoteCommands ? new RemoteCommandsProvider(config.repoRoot, config.remoteCommands) : config.provider ?? await getLocalProvider(config.repoRoot, config.excludes);
|
|
2354
|
+
const generator = runWarpGrepStreaming({
|
|
2355
|
+
query: parsed.query,
|
|
2356
|
+
repoRoot: config.repoRoot,
|
|
2357
|
+
provider,
|
|
2358
|
+
excludes: config.excludes,
|
|
2359
|
+
includes: config.includes,
|
|
2360
|
+
debug: config.debug ?? false,
|
|
2361
|
+
morphApiKey: config.morphApiKey,
|
|
2362
|
+
morphApiUrl: config.morphApiUrl,
|
|
2363
|
+
retryConfig: config.retryConfig,
|
|
2364
|
+
timeout: config.timeout
|
|
2365
|
+
});
|
|
2366
|
+
let agentResult;
|
|
2367
|
+
for (; ; ) {
|
|
2368
|
+
const { value, done } = await generator.next();
|
|
2369
|
+
if (done) {
|
|
2370
|
+
agentResult = value;
|
|
2371
|
+
break;
|
|
2372
|
+
}
|
|
2373
|
+
yield value;
|
|
2374
|
+
}
|
|
2375
|
+
return processAgentResult(agentResult);
|
|
2376
|
+
}
|
|
2377
|
+
async function fetchRawGitHubFile(owner, repo, filePath, branch, timeout) {
|
|
2378
|
+
const branches = branch ? [branch] : ["HEAD"];
|
|
2379
|
+
const fallbacks = ["main", "master", "develop"];
|
|
2380
|
+
const fetchWithTimeout = (url) => timeout ? fetch(url, { signal: AbortSignal.timeout(timeout) }) : fetch(url);
|
|
2381
|
+
for (const b of branches) {
|
|
2382
|
+
const url = `https://raw.githubusercontent.com/${owner}/${repo}/${b}/${filePath}`;
|
|
2383
|
+
const res = await fetchWithTimeout(url);
|
|
2384
|
+
if (res.ok) return { content: await res.text(), branch: b };
|
|
2385
|
+
}
|
|
2386
|
+
for (const fb of fallbacks) {
|
|
2387
|
+
if (branch && fb === branch) continue;
|
|
2388
|
+
const url = `https://raw.githubusercontent.com/${owner}/${repo}/${fb}/${filePath}`;
|
|
2389
|
+
const res = await fetchWithTimeout(url);
|
|
2390
|
+
if (res.ok) return { content: await res.text(), branch: fb };
|
|
2391
|
+
}
|
|
2392
|
+
throw new Error(`File not found: ${owner}/${repo}/${filePath}`);
|
|
2393
|
+
}
|
|
2394
|
+
async function executeGitHubReadFile(input, config) {
|
|
2395
|
+
try {
|
|
2396
|
+
const { owner, repo } = parseGitHubUrl(input.github);
|
|
2397
|
+
const { content: raw, branch } = await fetchRawGitHubFile(
|
|
2398
|
+
owner,
|
|
2399
|
+
repo,
|
|
2400
|
+
input.path,
|
|
2401
|
+
input.branch,
|
|
2402
|
+
config?.timeout
|
|
2403
|
+
);
|
|
2404
|
+
const allLines = raw.split("\n");
|
|
2405
|
+
const totalLines = allLines.length;
|
|
2406
|
+
const start = Math.max(1, input.startLine ?? 1);
|
|
2407
|
+
const end = Math.min(totalLines, input.endLine ?? totalLines);
|
|
2408
|
+
const selected = allLines.slice(start - 1, end);
|
|
2409
|
+
const padWidth = String(end).length;
|
|
2410
|
+
const numbered = selected.map((line, i) => `${String(start + i).padStart(padWidth)}|${line}`).join("\n");
|
|
2411
|
+
return {
|
|
2412
|
+
success: true,
|
|
2413
|
+
content: numbered,
|
|
2414
|
+
path: input.path,
|
|
2415
|
+
github: `${owner}/${repo}`,
|
|
2416
|
+
branch,
|
|
2417
|
+
lineRange: [start, end],
|
|
2418
|
+
totalLines
|
|
2419
|
+
};
|
|
2420
|
+
} catch (error) {
|
|
2421
|
+
return {
|
|
2422
|
+
success: false,
|
|
2423
|
+
error: error instanceof Error ? error.message : String(error)
|
|
2424
|
+
};
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
function formatGitHubReadFileResult(result) {
|
|
2428
|
+
if (!result.success) {
|
|
2429
|
+
return `Failed to read file: ${result.error}`;
|
|
2430
|
+
}
|
|
2431
|
+
const rangeStr = result.lineRange ? ` (lines ${result.lineRange[0]}-${result.lineRange[1]} of ${result.totalLines})` : "";
|
|
2432
|
+
return `File: ${result.github}/${result.path}${rangeStr}
|
|
2433
|
+
|
|
2434
|
+
${result.content}`;
|
|
2435
|
+
}
|
|
2028
2436
|
function formatResult(result) {
|
|
2029
2437
|
if (!result.success) {
|
|
2030
2438
|
return `Search failed: ${result.error}`;
|
|
@@ -2053,6 +2461,33 @@ function formatResult(result) {
|
|
|
2053
2461
|
// tools/warp_grep/prompts.ts
|
|
2054
2462
|
var WARP_GREP_TOOL_NAME = "warpgrep_codebase_search";
|
|
2055
2463
|
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.';
|
|
2464
|
+
var GITHUB_WARP_GREP_SEARCH_TOOL_NAME = "warpgrep_github_search";
|
|
2465
|
+
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.';
|
|
2466
|
+
var GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA = {
|
|
2467
|
+
type: "object",
|
|
2468
|
+
properties: {
|
|
2469
|
+
query: { type: "string", description: "Natural language search query describing what to find in the repository" },
|
|
2470
|
+
github: { type: "string", description: 'owner/repo shorthand (ex: "vercel/next.js" for "https://github.com/vercel/next.js")' },
|
|
2471
|
+
branch: { type: "string", description: "Branch to search (defaults to the repository default branch)" }
|
|
2472
|
+
},
|
|
2473
|
+
required: ["query", "github"]
|
|
2474
|
+
};
|
|
2475
|
+
var GITHUB_SEARCH_TOOL_NAME = GITHUB_WARP_GREP_SEARCH_TOOL_NAME;
|
|
2476
|
+
var GITHUB_SEARCH_DESCRIPTION = GITHUB_WARP_GREP_SEARCH_DESCRIPTION;
|
|
2477
|
+
var GITHUB_SEARCH_INPUT_SCHEMA = GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA;
|
|
2478
|
+
var GITHUB_READ_FILE_TOOL_NAME = "readfile_github_search";
|
|
2479
|
+
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.";
|
|
2480
|
+
var GITHUB_READ_FILE_INPUT_SCHEMA = {
|
|
2481
|
+
type: "object",
|
|
2482
|
+
properties: {
|
|
2483
|
+
github: { type: "string", description: 'owner/repo shorthand (e.g., "vercel/next.js")' },
|
|
2484
|
+
path: { type: "string", description: 'File path within the repository (e.g., "src/server/index.ts")' },
|
|
2485
|
+
startLine: { type: "number", description: "Start line number (1-based). Omit to start from beginning." },
|
|
2486
|
+
endLine: { type: "number", description: "End line number (1-based, inclusive). Omit to read to the end." },
|
|
2487
|
+
branch: { type: "string", description: "Branch to read from (defaults to the repository default branch)" }
|
|
2488
|
+
},
|
|
2489
|
+
required: ["github", "path"]
|
|
2490
|
+
};
|
|
2056
2491
|
|
|
2057
2492
|
// tools/warp_grep/anthropic.ts
|
|
2058
2493
|
var INPUT_SCHEMA = {
|
|
@@ -2088,8 +2523,44 @@ function createWarpGrepTool(config) {
|
|
|
2088
2523
|
}
|
|
2089
2524
|
});
|
|
2090
2525
|
}
|
|
2526
|
+
function createGitHubSearchTool(config) {
|
|
2527
|
+
const client = new WarpGrepClient(config);
|
|
2528
|
+
const tool = {
|
|
2529
|
+
name: GITHUB_SEARCH_TOOL_NAME,
|
|
2530
|
+
description: GITHUB_SEARCH_DESCRIPTION,
|
|
2531
|
+
input_schema: GITHUB_SEARCH_INPUT_SCHEMA
|
|
2532
|
+
};
|
|
2533
|
+
return Object.assign(tool, {
|
|
2534
|
+
execute: async (input) => {
|
|
2535
|
+
return client.searchGitHub(input);
|
|
2536
|
+
},
|
|
2537
|
+
formatResult: (result) => {
|
|
2538
|
+
return formatResult(result);
|
|
2539
|
+
},
|
|
2540
|
+
getSystemPrompt: () => {
|
|
2541
|
+
return getSystemPrompt();
|
|
2542
|
+
}
|
|
2543
|
+
});
|
|
2544
|
+
}
|
|
2545
|
+
function createGitHubReadFileTool(config) {
|
|
2546
|
+
const tool = {
|
|
2547
|
+
name: GITHUB_READ_FILE_TOOL_NAME,
|
|
2548
|
+
description: GITHUB_READ_FILE_DESCRIPTION,
|
|
2549
|
+
input_schema: GITHUB_READ_FILE_INPUT_SCHEMA
|
|
2550
|
+
};
|
|
2551
|
+
return Object.assign(tool, {
|
|
2552
|
+
execute: async (input) => {
|
|
2553
|
+
return executeGitHubReadFile(input, config);
|
|
2554
|
+
},
|
|
2555
|
+
formatResult: (result) => {
|
|
2556
|
+
return formatGitHubReadFileResult(result);
|
|
2557
|
+
}
|
|
2558
|
+
});
|
|
2559
|
+
}
|
|
2091
2560
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2092
2561
|
0 && (module.exports = {
|
|
2562
|
+
createGitHubReadFileTool,
|
|
2563
|
+
createGitHubSearchTool,
|
|
2093
2564
|
createWarpGrepTool,
|
|
2094
2565
|
execute,
|
|
2095
2566
|
formatResult,
|