@morphllm/morphsdk 0.2.54 → 0.2.56
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-4HOUN5TW.js → chunk-4ZHDBKBY.js} +3 -3
- package/dist/chunk-7OQOOB3R.js +1 -0
- package/dist/{chunk-FB3E5BRY.js → chunk-GJURLQ3L.js} +3 -3
- package/dist/{chunk-D5ZSGQT4.js → chunk-QVRXBAMM.js} +2 -2
- package/dist/{chunk-IFVROB4L.js → chunk-SALJ2K6S.js} +9 -10
- package/dist/chunk-SALJ2K6S.js.map +1 -0
- package/dist/{chunk-PYTBBWL6.js → chunk-UIRJE422.js} +3 -3
- package/dist/{chunk-KVMZPOUT.js → chunk-WSSSSBWU.js} +5 -5
- package/dist/client.cjs +12 -13
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +7 -7
- package/dist/index.cjs +12 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +8 -12
- package/dist/tools/warp_grep/agent/runner.cjs +5 -6
- 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 +12 -13
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.js +4 -4
- package/dist/tools/warp_grep/index.cjs +12 -80
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +0 -1
- package/dist/tools/warp_grep/index.js +7 -11
- package/dist/tools/warp_grep/openai.cjs +12 -13
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.js +4 -4
- package/dist/tools/warp_grep/vercel.cjs +12 -13
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.js +4 -4
- package/package.json +2 -2
- package/dist/chunk-IFVROB4L.js.map +0 -1
- package/dist/chunk-JYBVRF72.js +0 -1
- package/dist/chunk-P2XKFWFD.js +0 -73
- package/dist/chunk-P2XKFWFD.js.map +0 -1
- package/dist/tools/warp_grep/providers/command.cjs +0 -177
- package/dist/tools/warp_grep/providers/command.cjs.map +0 -1
- package/dist/tools/warp_grep/providers/command.d.ts +0 -48
- package/dist/tools/warp_grep/providers/command.js +0 -9
- package/dist/tools/warp_grep/providers/command.js.map +0 -1
- /package/dist/{chunk-4HOUN5TW.js.map → chunk-4ZHDBKBY.js.map} +0 -0
- /package/dist/{chunk-JYBVRF72.js.map → chunk-7OQOOB3R.js.map} +0 -0
- /package/dist/{chunk-FB3E5BRY.js.map → chunk-GJURLQ3L.js.map} +0 -0
- /package/dist/{chunk-D5ZSGQT4.js.map → chunk-QVRXBAMM.js.map} +0 -0
- /package/dist/{chunk-PYTBBWL6.js.map → chunk-UIRJE422.js.map} +0 -0
- /package/dist/{chunk-KVMZPOUT.js.map → chunk-WSSSSBWU.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/warp_grep/agent/runner.ts"],"sourcesContent":["import { AGENT_CONFIG, DEFAULT_MODEL } from './config.js';\nimport { getSystemPrompt } from './prompt.js';\nimport type { AgentRunResult, ChatMessage, SessionConfig, ToolCall, AgentFinish } from './types.js';\nimport { LLMResponseParser } from './parser.js';\nimport type { WarpGrepProvider } from '../providers/types.js';\nimport { toolRead } from '../tools/read.js';\nimport { toolAnalyse } from '../tools/analyse.js';\nimport { fetchWithRetry, withTimeout } from '../../utils/resilience.js';\nimport { formatAgentToolOutput } from './formatter.js';\nimport { GrepState, parseAndFilterGrepOutput, formatTurnGrepOutput } from './grep_helpers.js';\nimport { readFinishFiles } from '../tools/finish.js';\nimport path from 'path';\nimport fs from 'fs/promises';\n\ntype EventName =\n | 'initial_state'\n | 'round_start'\n | 'round_end'\n | 'finish'\n | 'error';\n\nexport type EventCallback = (name: EventName, payload: Record<string, unknown>) => void;\n\nconst parser = new LLMResponseParser();\n\nasync function buildInitialState(repoRoot: string, query: string): Promise<string> {\n // Summarize top-level directories and file counts\n try {\n const entries = await fs.readdir(repoRoot, { withFileTypes: true });\n const dirs = entries.filter(e => e.isDirectory()).map(d => d.name).slice(0, 50);\n const files = entries.filter(e => e.isFile()).map(f => f.name).slice(0, 50);\n const parts = [\n `<repo_root>${repoRoot}</repo_root>`,\n `<top_dirs>${dirs.join(', ')}</top_dirs>`,\n `<top_files>${files.join(', ')}</top_files>`,\n ];\n return parts.join('\\n');\n } catch {\n return `<repo_root>${repoRoot}</repo_root>`;\n }\n}\n\nfunction formatAssistantToolBlock(name: string, args: Record<string, unknown>, payload: string, isError = false): string {\n const argStr = Object.entries(args)\n .map(([k, v]) => `${k}=${JSON.stringify(v)}`)\n .join(' ');\n const prefix = isError ? 'error' : 'result';\n return `<${prefix} name=\"${name}\" ${argStr}>\\n${payload}\\n</${prefix}>`;\n}\n\nasync function callModel(messages: ChatMessage[], model: string, apiKey?: string): Promise<string> {\n const api = 'https://api.morphllm.com/v1/chat/completions';\n const fetchPromise = fetchWithRetry(\n api,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${apiKey || process.env.MORPH_API_KEY || ''}`,\n },\n body: JSON.stringify({\n model,\n temperature: 0.0,\n max_tokens: 1024,\n messages,\n }),\n },\n {}\n );\n const resp = await withTimeout(fetchPromise, AGENT_CONFIG.TIMEOUT_MS, 'morph-warp-grep request timed out');\n if (!resp.ok) {\n // keeping these cases are real throws, if this happens retry will likely not help, so best we just throw here, notice the error and fix\n const t = await resp.text();\n throw new Error(`morph-warp-grep error ${resp.status}: ${t}`);\n }\n const data = await resp.json();\n const content = data?.choices?.[0]?.message?.content;\n if (!content || typeof content !== 'string') {\n throw new Error('Invalid response from model');\n }\n return content;\n}\n\nexport async function runWarpGrep(config: SessionConfig & { provider: WarpGrepProvider }): Promise<AgentRunResult> {\n const repoRoot = path.resolve(config.repoRoot || process.cwd());\n const messages: ChatMessage[] = [];\n\n // system\n const systemMessage = { role: 'system' as const, content: getSystemPrompt() };\n messages.push(systemMessage);\n // user query\n const queryContent = `<query>${config.query}</query>`;\n messages.push({ role: 'user', content: queryContent });\n // initial state\n const initialState = await buildInitialState(repoRoot, config.query);\n messages.push({ role: 'user', content: initialState });\n\n const maxRounds = AGENT_CONFIG.MAX_ROUNDS;\n const model = config.model || DEFAULT_MODEL;\n const provider = config.provider;\n const errors: Array<{ message: string }> = [];\n const grepState = new GrepState();\n\n let finishMeta: AgentFinish | undefined;\n let terminationReason: AgentRunResult['terminationReason'] = 'terminated';\n\n for (let round = 1; round <= maxRounds; round += 1) {\n // call model\n const assistantContent = await callModel(messages, model, config.apiKey).catch((e: unknown) => {\n errors.push({ message: e instanceof Error ? e.message : String(e) });\n return '';\n });\n if (!assistantContent) break;\n messages.push({ role: 'assistant', content: assistantContent });\n\n // parse tool calls (no longer throws - returns _skip calls for malformed commands)\n const toolCalls = parser.parse(assistantContent);\n if (toolCalls.length === 0) {\n errors.push({ message: 'No tool calls produced by the model.' });\n terminationReason = 'terminated';\n break;\n }\n\n const finishCalls = toolCalls.filter(c => c.name === 'finish');\n const grepCalls = toolCalls.filter(c => c.name === 'grep');\n const analyseCalls = toolCalls.filter(c => c.name === 'analyse');\n const readCalls = toolCalls.filter(c => c.name === 'read');\n const skipCalls = toolCalls.filter(c => c.name === '_skip');\n\n const formatted: string[] = [];\n\n // Surface any skipped commands as feedback to the LLM\n for (const c of skipCalls) {\n const msg = (c.arguments as { message?: string })?.message || 'Command skipped due to parsing error';\n formatted.push(msg);\n }\n\n // Execute non-grep tools in parallel\n const otherPromises: Array<Promise<string>> = [];\n for (const c of analyseCalls) {\n const args = (c.arguments ?? {}) as { path: string; pattern?: string | null };\n otherPromises.push(\n toolAnalyse(provider, args).then(\n p => formatAgentToolOutput('analyse', args, p, { isError: false }),\n err => formatAgentToolOutput('analyse', args, String(err), { isError: true })\n )\n );\n }\n for (const c of readCalls) {\n const args = (c.arguments ?? {}) as { path: string; start?: number; end?: number };\n otherPromises.push(\n toolRead(provider, args).then(\n p => formatAgentToolOutput('read', args, p, { isError: false }),\n err => formatAgentToolOutput('read', args, String(err), { isError: true })\n )\n );\n }\n const otherResults = await Promise.all(otherPromises);\n formatted.push(...otherResults);\n\n // Execute grep calls sequentially like MCP runner to keep outputs compact\n for (const c of grepCalls) {\n const args = (c.arguments ?? {}) as { pattern: string; path: string };\n try {\n const grepRes = await provider.grep({ pattern: args.pattern, path: args.path });\n \n // Check for ripgrep availability error - terminate early with clear message\n if (grepRes.error) {\n errors.push({ message: grepRes.error });\n terminationReason = 'terminated';\n // Return immediately with the error so user knows to install ripgrep\n return {\n terminationReason: 'terminated',\n messages,\n errors,\n };\n }\n \n const rawOutput = Array.isArray(grepRes.lines) ? grepRes.lines.join('\\n') : '';\n const newMatches = parseAndFilterGrepOutput(rawOutput, grepState);\n let formattedPayload = formatTurnGrepOutput(newMatches);\n if (formattedPayload === \"No new matches found.\") {\n formattedPayload = \"no new matches\";\n }\n formatted.push(formatAgentToolOutput('grep', args, formattedPayload, { isError: false }));\n } catch (err) {\n formatted.push(formatAgentToolOutput('grep', args, String(err), { isError: true }));\n }\n }\n\n if (formatted.length > 0) {\n // Add turn counter message\n const turnsUsed = round;\n const turnsRemaining = 4 - turnsUsed;\n let turnMessage: string;\n if (turnsRemaining === 0) {\n turnMessage = `\\n\\n[Turn ${turnsUsed}/4] This is your LAST turn. You MUST call the finish tool now.`;\n } else if (turnsRemaining === 1) {\n turnMessage = `\\n\\n[Turn ${turnsUsed}/4] You have 1 turn remaining. Next turn you MUST call the finish tool.`;\n } else {\n turnMessage = `\\n\\n[Turn ${turnsUsed}/4] You have ${turnsRemaining} turns remaining.`;\n }\n messages.push({ role: 'user', content: formatted.join('\\n') + turnMessage });\n }\n\n if (finishCalls.length) {\n const fc = finishCalls[0];\n const files = ((fc.arguments as any)?.files ?? []) as AgentFinish['files'];\n finishMeta = { files };\n terminationReason = 'completed';\n break;\n }\n }\n\n if (terminationReason !== 'completed' || !finishMeta) {\n return { terminationReason, messages, errors };\n }\n\n // Build finish payload\n const parts: string[] = ['Relevant context found:'];\n for (const f of finishMeta.files) {\n const ranges = f.lines.map(([s, e]) => `${s}-${e}`).join(', ');\n parts.push(`- ${f.path}: ${ranges}`);\n }\n const payload = parts.join('\\n');\n\n // Resolve file contents for returned ranges\n // Wrap reader in try-catch to handle non-existent or unreadable files gracefully\n // Track files that couldn't be read for error reporting\n const fileReadErrors: Array<{ path: string; error: string }> = [];\n const resolved = await readFinishFiles(\n repoRoot,\n finishMeta.files,\n async (p: string, s: number, e: number) => {\n try {\n const rr = await provider.read({ path: p, start: s, end: e });\n // rr.lines are \"line|content\" → strip the \"line|\" prefix\n return rr.lines.map(l => {\n const idx = l.indexOf('|');\n return idx >= 0 ? l.slice(idx + 1) : l;\n });\n } catch (err) {\n // File doesn't exist or can't be read - log error but don't throw\n // This handles cases where the agent hallucinated a path or the file was deleted\n const errorMsg = err instanceof Error ? err.message : String(err);\n fileReadErrors.push({ path: p, error: errorMsg });\n console.error(`[warp_grep] Failed to read file: ${p} - ${errorMsg}`);\n return [`[couldn't find: ${p}]`];\n }\n }\n );\n\n // Add file read errors to the result so MCP can report them\n if (fileReadErrors.length > 0) {\n errors.push(...fileReadErrors.map(e => ({ message: `File read error: ${e.path} - ${e.error}` })));\n }\n\n return {\n terminationReason: 'completed',\n messages,\n finish: { payload, metadata: finishMeta, resolved },\n };\n}\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,OAAO,UAAU;AACjB,OAAO,QAAQ;AAWf,IAAM,SAAS,IAAI,kBAAkB;AAErC,eAAe,kBAAkB,UAAkB,OAAgC;AAEjF,MAAI;AACF,UAAM,UAAU,MAAM,GAAG,QAAQ,UAAU,EAAE,eAAe,KAAK,CAAC;AAClE,UAAM,OAAO,QAAQ,OAAO,OAAK,EAAE,YAAY,CAAC,EAAE,IAAI,OAAK,EAAE,IAAI,EAAE,MAAM,GAAG,EA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AAI;AAK/B,QAAM,iBAAyD,CAAC;AAChE,QAAM,WAAW,MAAM;AAAA,IACrB;AAAA,IACA,WAAW;AAAA,IACX,OAAO,GAAW,GAAW,MAAc;AACzC,UAAI;AACF,cAAM,KAAK,MAAM,SAAS,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,EAAE,CAAC;AAE5D,eAAO,GAAG,MAAM,IAAI,OAAK;AACvB,gBAAM,MAAM,EAAE,QAAQ,GAAG;AACzB,iBAAO,OAAO,IAAI,EAAE,MAAM,MAAM,CAAC,IAAI;AAAA,QACvC,CAAC;AAAA,MACH,SAAS,KAAK;AAGZ,cAAM,WAAW,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAChE,uBAAe,KAAK,EAAE,MAAM,GAAG,OAAO,SAAS,CAAC;AAChD,gBAAQ,MAAM,oCAAoC,CAAC,MAAM,QAAQ,EAAE;AACnE,eAAO,CAAC,mBAAmB,CAAC,GAAG;AAAA,MACjC;AAAA,IACF;AAAA,EACF;AAGA,MAAI,eAAe,SAAS,GAAG;AAC7B,WAAO,KAAK,GAAG,eAAe,IAAI,QAAM,EAAE,SAAS,oBAAoB,EAAE,IAAI,MAAM,EAAE,KAAK,GAAG,EAAE,CAAC;AAAA,EAClG;AAEA,SAAO;AAAA,IACL,mBAAmB;AAAA,IACnB;AAAA,IACA,QAAQ,EAAE,SAAS,UAAU,YAAY,SAAS;AAAA,EACpD;AACF;","names":[]}
|
package/dist/chunk-JYBVRF72.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-JYBVRF72.js.map
|
package/dist/chunk-P2XKFWFD.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_EXCLUDES
|
|
3
|
-
} from "./chunk-TJIUA27P.js";
|
|
4
|
-
|
|
5
|
-
// tools/warp_grep/providers/command.ts
|
|
6
|
-
var CommandExecProvider = class {
|
|
7
|
-
constructor(opts) {
|
|
8
|
-
this.opts = opts;
|
|
9
|
-
}
|
|
10
|
-
map(path) {
|
|
11
|
-
return this.opts.pathMap ? this.opts.pathMap(path) : path;
|
|
12
|
-
}
|
|
13
|
-
async grep(params) {
|
|
14
|
-
const remotePath = this.map(params.path);
|
|
15
|
-
const args = [
|
|
16
|
-
"--no-config",
|
|
17
|
-
"--no-heading",
|
|
18
|
-
"--with-filename",
|
|
19
|
-
"--line-number",
|
|
20
|
-
"--color=never",
|
|
21
|
-
"--trim",
|
|
22
|
-
"--max-columns=400",
|
|
23
|
-
...(this.opts.excludes ?? DEFAULT_EXCLUDES).flatMap((e) => ["-g", `!${e}`]),
|
|
24
|
-
params.pattern,
|
|
25
|
-
remotePath || "."
|
|
26
|
-
];
|
|
27
|
-
const res = await this.opts.run("rg", args, { cwd: this.opts.cwd, env: this.opts.env });
|
|
28
|
-
if (res.exitCode === -1) throw new Error(res.stderr || "ripgrep execution failed");
|
|
29
|
-
if (res.exitCode !== 0 && res.exitCode !== 1) throw new Error(res.stderr || `ripgrep failed (${res.exitCode})`);
|
|
30
|
-
const lines = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
31
|
-
return { lines };
|
|
32
|
-
}
|
|
33
|
-
async glob(params) {
|
|
34
|
-
const remotePath = this.map(params.path);
|
|
35
|
-
const args = [
|
|
36
|
-
"--no-config",
|
|
37
|
-
"--files",
|
|
38
|
-
"-g",
|
|
39
|
-
params.pattern,
|
|
40
|
-
...(this.opts.excludes ?? DEFAULT_EXCLUDES).flatMap((e) => ["-g", `!${e}`]),
|
|
41
|
-
remotePath || "."
|
|
42
|
-
];
|
|
43
|
-
const res = await this.opts.run("rg", args, { cwd: this.opts.cwd, env: this.opts.env });
|
|
44
|
-
if (res.exitCode === -1) throw new Error(res.stderr || "ripgrep execution failed");
|
|
45
|
-
const files = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
46
|
-
return { files };
|
|
47
|
-
}
|
|
48
|
-
async read(params) {
|
|
49
|
-
const remotePath = this.map(params.path);
|
|
50
|
-
const rc = this.opts.readCommand ? this.opts.readCommand(remotePath, params.start, params.end) : { cmd: "sed", args: ["-n", `${params.start ?? 1},${params.end ?? 1e6}p`, remotePath] };
|
|
51
|
-
const res = await this.opts.run(rc.cmd, rc.args, { cwd: this.opts.cwd, env: this.opts.env });
|
|
52
|
-
if (res.exitCode !== 0) throw new Error(res.stderr || `read failed (${res.exitCode})`);
|
|
53
|
-
const text = res.stdout || "";
|
|
54
|
-
const lines = text.split(/\r?\n/).map((line, idx) => `${(params.start ?? 1) + idx}|${line}`);
|
|
55
|
-
return { lines: lines.filter((l) => l !== `${(params.start ?? 1) + (lines.length - 1)}|`) };
|
|
56
|
-
}
|
|
57
|
-
async analyse(params) {
|
|
58
|
-
const target = this.map(params.path);
|
|
59
|
-
const pattern = params.pattern ?? "*";
|
|
60
|
-
const files = await this.glob({ pattern, path: target }).catch(() => ({ files: [] }));
|
|
61
|
-
return files.files.slice(0, params.maxResults ?? 100).map((f) => ({
|
|
62
|
-
name: f.split("/").pop() || f,
|
|
63
|
-
path: f,
|
|
64
|
-
type: f.endsWith("/") ? "dir" : "file",
|
|
65
|
-
depth: 0
|
|
66
|
-
}));
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export {
|
|
71
|
-
CommandExecProvider
|
|
72
|
-
};
|
|
73
|
-
//# sourceMappingURL=chunk-P2XKFWFD.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/warp_grep/providers/command.ts"],"sourcesContent":["import type { WarpGrepProvider, GrepResult, ReadResult, AnalyseEntry } from './types.js';\nimport { DEFAULT_EXCLUDES } from '../agent/config.js';\n\ntype ExecResult = { stdout: string; stderr: string; exitCode: number };\n\nexport class CommandExecProvider implements WarpGrepProvider {\n constructor(\n private readonly opts: {\n run: (cmd: string, args: string[], options?: { cwd?: string; env?: Record<string, string> }) => Promise<ExecResult>;\n pathMap?: (localPath: string) => string;\n cwd?: string;\n env?: Record<string, string>;\n readCommand?: (remotePath: string, start?: number, end?: number) => { cmd: string; args: string[] };\n excludes?: string[];\n }\n ) {}\n\n private map(path: string): string {\n return this.opts.pathMap ? this.opts.pathMap(path) : path;\n }\n\n async grep(params: { pattern: string; path: string }): Promise<GrepResult> {\n const remotePath = this.map(params.path);\n const args = [\n '--no-config',\n '--no-heading',\n '--with-filename',\n '--line-number',\n '--color=never',\n '--trim',\n '--max-columns=400',\n ...((this.opts.excludes ?? DEFAULT_EXCLUDES).flatMap((e) => ['-g', `!${e}`])),\n params.pattern,\n remotePath || '.',\n ];\n const res = await this.opts.run('rg', args, { cwd: this.opts.cwd, env: this.opts.env });\n if (res.exitCode === -1) throw new Error(res.stderr || 'ripgrep execution failed');\n if (res.exitCode !== 0 && res.exitCode !== 1) throw new Error(res.stderr || `ripgrep failed (${res.exitCode})`);\n const lines = (res.stdout || '')\n .trim()\n .split(/\\r?\\n/)\n .filter((l) => l.length > 0);\n return { lines };\n }\n\n async glob(params: { pattern: string; path: string }): Promise<{ files: string[] }> {\n const remotePath = this.map(params.path);\n const args = [\n '--no-config',\n '--files',\n '-g',\n params.pattern,\n ...((this.opts.excludes ?? DEFAULT_EXCLUDES).flatMap((e) => ['-g', `!${e}`])),\n remotePath || '.',\n ];\n const res = await this.opts.run('rg', args, { cwd: this.opts.cwd, env: this.opts.env });\n if (res.exitCode === -1) throw new Error(res.stderr || 'ripgrep execution failed');\n const files = (res.stdout || '')\n .trim()\n .split(/\\r?\\n/)\n .filter((l) => l.length > 0);\n return { files };\n }\n\n async read(params: { path: string; start?: number; end?: number }): Promise<ReadResult> {\n const remotePath = this.map(params.path);\n const rc = this.opts.readCommand\n ? this.opts.readCommand(remotePath, params.start, params.end)\n : { cmd: 'sed', args: ['-n', `${params.start ?? 1},${params.end ?? 1_000_000}p`, remotePath] };\n const res = await this.opts.run(rc.cmd, rc.args, { cwd: this.opts.cwd, env: this.opts.env });\n if (res.exitCode !== 0) throw new Error(res.stderr || `read failed (${res.exitCode})`);\n const text = res.stdout || '';\n const lines = text.split(/\\r?\\n/).map((line, idx) => `${(params.start ?? 1) + idx}|${line}`);\n return { lines: lines.filter(l => l !== `${(params.start ?? 1) + (lines.length - 1)}|`) };\n }\n\n async analyse(params: { path: string; pattern?: string | null; maxResults?: number; maxDepth?: number }): Promise<AnalyseEntry[]> {\n // Minimal remote analyse: glob all files and trim\n const target = this.map(params.path);\n const pattern = params.pattern ?? '*';\n const files = await this.glob({ pattern, path: target }).catch(() => ({ files: [] }));\n return files.files.slice(0, params.maxResults ?? 100).map((f) => ({\n name: f.split('/').pop() || f,\n path: f,\n type: f.endsWith('/') ? 'dir' : 'file',\n depth: 0,\n }));\n }\n}\n\n\n"],"mappings":";;;;;AAKO,IAAM,sBAAN,MAAsD;AAAA,EAC3D,YACmB,MAQjB;AARiB;AAAA,EAQhB;AAAA,EAEK,IAAI,MAAsB;AAChC,WAAO,KAAK,KAAK,UAAU,KAAK,KAAK,QAAQ,IAAI,IAAI;AAAA,EACvD;AAAA,EAEA,MAAM,KAAK,QAAgE;AACzE,UAAM,aAAa,KAAK,IAAI,OAAO,IAAI;AACvC,UAAM,OAAO;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,IAAK,KAAK,KAAK,YAAY,kBAAkB,QAAQ,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;AAAA,MAC3E,OAAO;AAAA,MACP,cAAc;AAAA,IAChB;AACA,UAAM,MAAM,MAAM,KAAK,KAAK,IAAI,MAAM,MAAM,EAAE,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,IAAI,CAAC;AACtF,QAAI,IAAI,aAAa,GAAI,OAAM,IAAI,MAAM,IAAI,UAAU,0BAA0B;AACjF,QAAI,IAAI,aAAa,KAAK,IAAI,aAAa,EAAG,OAAM,IAAI,MAAM,IAAI,UAAU,mBAAmB,IAAI,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,UAAM,OAAO,IAAI,UAAU;AAC3B,UAAM,QAAQ,KAAK,MAAM,OAAO,EAAE,IAAI,CAAC,MAAM,QAAQ,IAAI,OAAO,SAAS,KAAK,GAAG,IAAI,IAAI,EAAE;AAC3F,WAAO,EAAE,OAAO,MAAM,OAAO,OAAK,MAAM,IAAI,OAAO,SAAS,MAAM,MAAM,SAAS,EAAE,GAAG,EAAE;AAAA,EAC1F;AAAA,EAEA,MAAM,QAAQ,QAAoH;AAEhI,UAAM,SAAS,KAAK,IAAI,OAAO,IAAI;AACnC,UAAM,UAAU,OAAO,WAAW;AAClC,UAAM,QAAQ,MAAM,KAAK,KAAK,EAAE,SAAS,MAAM,OAAO,CAAC,EAAE,MAAM,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE;AACpF,WAAO,MAAM,MAAM,MAAM,GAAG,OAAO,cAAc,GAAG,EAAE,IAAI,CAAC,OAAO;AAAA,MAChE,MAAM,EAAE,MAAM,GAAG,EAAE,IAAI,KAAK;AAAA,MAC5B,MAAM;AAAA,MACN,MAAM,EAAE,SAAS,GAAG,IAAI,QAAQ;AAAA,MAChC,OAAO;AAAA,IACT,EAAE;AAAA,EACJ;AACF;","names":[]}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// tools/warp_grep/providers/command.ts
|
|
21
|
-
var command_exports = {};
|
|
22
|
-
__export(command_exports, {
|
|
23
|
-
CommandExecProvider: () => CommandExecProvider
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(command_exports);
|
|
26
|
-
|
|
27
|
-
// tools/warp_grep/agent/config.ts
|
|
28
|
-
var BUILTIN_EXCLUDES = [
|
|
29
|
-
// Version control
|
|
30
|
-
".git",
|
|
31
|
-
".svn",
|
|
32
|
-
".hg",
|
|
33
|
-
".bzr",
|
|
34
|
-
// Dependencies
|
|
35
|
-
"node_modules",
|
|
36
|
-
"bower_components",
|
|
37
|
-
".pnpm",
|
|
38
|
-
".yarn",
|
|
39
|
-
"vendor",
|
|
40
|
-
"packages",
|
|
41
|
-
"Pods",
|
|
42
|
-
".bundle",
|
|
43
|
-
// Python
|
|
44
|
-
"__pycache__",
|
|
45
|
-
".pytest_cache",
|
|
46
|
-
".mypy_cache",
|
|
47
|
-
".ruff_cache",
|
|
48
|
-
".venv",
|
|
49
|
-
"venv",
|
|
50
|
-
".tox",
|
|
51
|
-
".nox",
|
|
52
|
-
".eggs",
|
|
53
|
-
"*.egg-info",
|
|
54
|
-
// Build outputs
|
|
55
|
-
"dist",
|
|
56
|
-
"build",
|
|
57
|
-
"out",
|
|
58
|
-
"output",
|
|
59
|
-
"target",
|
|
60
|
-
"_build",
|
|
61
|
-
".next",
|
|
62
|
-
".nuxt",
|
|
63
|
-
".output",
|
|
64
|
-
".vercel",
|
|
65
|
-
".netlify",
|
|
66
|
-
// Cache directories
|
|
67
|
-
".cache",
|
|
68
|
-
".parcel-cache",
|
|
69
|
-
".turbo",
|
|
70
|
-
".nx",
|
|
71
|
-
".gradle",
|
|
72
|
-
// IDE/Editor
|
|
73
|
-
".idea",
|
|
74
|
-
".vscode",
|
|
75
|
-
".vs",
|
|
76
|
-
// Coverage
|
|
77
|
-
"coverage",
|
|
78
|
-
".coverage",
|
|
79
|
-
"htmlcov",
|
|
80
|
-
".nyc_output",
|
|
81
|
-
// Temporary
|
|
82
|
-
"tmp",
|
|
83
|
-
"temp",
|
|
84
|
-
".tmp",
|
|
85
|
-
".temp",
|
|
86
|
-
// Lock files
|
|
87
|
-
"package-lock.json",
|
|
88
|
-
"yarn.lock",
|
|
89
|
-
"pnpm-lock.yaml",
|
|
90
|
-
"bun.lockb",
|
|
91
|
-
"Cargo.lock",
|
|
92
|
-
"Gemfile.lock",
|
|
93
|
-
"poetry.lock",
|
|
94
|
-
// Binary/minified
|
|
95
|
-
"*.min.js",
|
|
96
|
-
"*.min.css",
|
|
97
|
-
"*.bundle.js",
|
|
98
|
-
"*.wasm",
|
|
99
|
-
"*.so",
|
|
100
|
-
"*.dll",
|
|
101
|
-
"*.pyc",
|
|
102
|
-
"*.map",
|
|
103
|
-
"*.js.map",
|
|
104
|
-
// Hidden directories catch-all
|
|
105
|
-
".*"
|
|
106
|
-
];
|
|
107
|
-
var DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || "").split(",").map((s) => s.trim()).filter(Boolean).concat(BUILTIN_EXCLUDES);
|
|
108
|
-
|
|
109
|
-
// tools/warp_grep/providers/command.ts
|
|
110
|
-
var CommandExecProvider = class {
|
|
111
|
-
constructor(opts) {
|
|
112
|
-
this.opts = opts;
|
|
113
|
-
}
|
|
114
|
-
map(path) {
|
|
115
|
-
return this.opts.pathMap ? this.opts.pathMap(path) : path;
|
|
116
|
-
}
|
|
117
|
-
async grep(params) {
|
|
118
|
-
const remotePath = this.map(params.path);
|
|
119
|
-
const args = [
|
|
120
|
-
"--no-config",
|
|
121
|
-
"--no-heading",
|
|
122
|
-
"--with-filename",
|
|
123
|
-
"--line-number",
|
|
124
|
-
"--color=never",
|
|
125
|
-
"--trim",
|
|
126
|
-
"--max-columns=400",
|
|
127
|
-
...(this.opts.excludes ?? DEFAULT_EXCLUDES).flatMap((e) => ["-g", `!${e}`]),
|
|
128
|
-
params.pattern,
|
|
129
|
-
remotePath || "."
|
|
130
|
-
];
|
|
131
|
-
const res = await this.opts.run("rg", args, { cwd: this.opts.cwd, env: this.opts.env });
|
|
132
|
-
if (res.exitCode === -1) throw new Error(res.stderr || "ripgrep execution failed");
|
|
133
|
-
if (res.exitCode !== 0 && res.exitCode !== 1) throw new Error(res.stderr || `ripgrep failed (${res.exitCode})`);
|
|
134
|
-
const lines = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
135
|
-
return { lines };
|
|
136
|
-
}
|
|
137
|
-
async glob(params) {
|
|
138
|
-
const remotePath = this.map(params.path);
|
|
139
|
-
const args = [
|
|
140
|
-
"--no-config",
|
|
141
|
-
"--files",
|
|
142
|
-
"-g",
|
|
143
|
-
params.pattern,
|
|
144
|
-
...(this.opts.excludes ?? DEFAULT_EXCLUDES).flatMap((e) => ["-g", `!${e}`]),
|
|
145
|
-
remotePath || "."
|
|
146
|
-
];
|
|
147
|
-
const res = await this.opts.run("rg", args, { cwd: this.opts.cwd, env: this.opts.env });
|
|
148
|
-
if (res.exitCode === -1) throw new Error(res.stderr || "ripgrep execution failed");
|
|
149
|
-
const files = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
150
|
-
return { files };
|
|
151
|
-
}
|
|
152
|
-
async read(params) {
|
|
153
|
-
const remotePath = this.map(params.path);
|
|
154
|
-
const rc = this.opts.readCommand ? this.opts.readCommand(remotePath, params.start, params.end) : { cmd: "sed", args: ["-n", `${params.start ?? 1},${params.end ?? 1e6}p`, remotePath] };
|
|
155
|
-
const res = await this.opts.run(rc.cmd, rc.args, { cwd: this.opts.cwd, env: this.opts.env });
|
|
156
|
-
if (res.exitCode !== 0) throw new Error(res.stderr || `read failed (${res.exitCode})`);
|
|
157
|
-
const text = res.stdout || "";
|
|
158
|
-
const lines = text.split(/\r?\n/).map((line, idx) => `${(params.start ?? 1) + idx}|${line}`);
|
|
159
|
-
return { lines: lines.filter((l) => l !== `${(params.start ?? 1) + (lines.length - 1)}|`) };
|
|
160
|
-
}
|
|
161
|
-
async analyse(params) {
|
|
162
|
-
const target = this.map(params.path);
|
|
163
|
-
const pattern = params.pattern ?? "*";
|
|
164
|
-
const files = await this.glob({ pattern, path: target }).catch(() => ({ files: [] }));
|
|
165
|
-
return files.files.slice(0, params.maxResults ?? 100).map((f) => ({
|
|
166
|
-
name: f.split("/").pop() || f,
|
|
167
|
-
path: f,
|
|
168
|
-
type: f.endsWith("/") ? "dir" : "file",
|
|
169
|
-
depth: 0
|
|
170
|
-
}));
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
174
|
-
0 && (module.exports = {
|
|
175
|
-
CommandExecProvider
|
|
176
|
-
});
|
|
177
|
-
//# sourceMappingURL=command.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../tools/warp_grep/providers/command.ts","../../../../tools/warp_grep/agent/config.ts"],"sourcesContent":["import type { WarpGrepProvider, GrepResult, ReadResult, AnalyseEntry } from './types.js';\nimport { DEFAULT_EXCLUDES } from '../agent/config.js';\n\ntype ExecResult = { stdout: string; stderr: string; exitCode: number };\n\nexport class CommandExecProvider implements WarpGrepProvider {\n constructor(\n private readonly opts: {\n run: (cmd: string, args: string[], options?: { cwd?: string; env?: Record<string, string> }) => Promise<ExecResult>;\n pathMap?: (localPath: string) => string;\n cwd?: string;\n env?: Record<string, string>;\n readCommand?: (remotePath: string, start?: number, end?: number) => { cmd: string; args: string[] };\n excludes?: string[];\n }\n ) {}\n\n private map(path: string): string {\n return this.opts.pathMap ? this.opts.pathMap(path) : path;\n }\n\n async grep(params: { pattern: string; path: string }): Promise<GrepResult> {\n const remotePath = this.map(params.path);\n const args = [\n '--no-config',\n '--no-heading',\n '--with-filename',\n '--line-number',\n '--color=never',\n '--trim',\n '--max-columns=400',\n ...((this.opts.excludes ?? DEFAULT_EXCLUDES).flatMap((e) => ['-g', `!${e}`])),\n params.pattern,\n remotePath || '.',\n ];\n const res = await this.opts.run('rg', args, { cwd: this.opts.cwd, env: this.opts.env });\n if (res.exitCode === -1) throw new Error(res.stderr || 'ripgrep execution failed');\n if (res.exitCode !== 0 && res.exitCode !== 1) throw new Error(res.stderr || `ripgrep failed (${res.exitCode})`);\n const lines = (res.stdout || '')\n .trim()\n .split(/\\r?\\n/)\n .filter((l) => l.length > 0);\n return { lines };\n }\n\n async glob(params: { pattern: string; path: string }): Promise<{ files: string[] }> {\n const remotePath = this.map(params.path);\n const args = [\n '--no-config',\n '--files',\n '-g',\n params.pattern,\n ...((this.opts.excludes ?? DEFAULT_EXCLUDES).flatMap((e) => ['-g', `!${e}`])),\n remotePath || '.',\n ];\n const res = await this.opts.run('rg', args, { cwd: this.opts.cwd, env: this.opts.env });\n if (res.exitCode === -1) throw new Error(res.stderr || 'ripgrep execution failed');\n const files = (res.stdout || '')\n .trim()\n .split(/\\r?\\n/)\n .filter((l) => l.length > 0);\n return { files };\n }\n\n async read(params: { path: string; start?: number; end?: number }): Promise<ReadResult> {\n const remotePath = this.map(params.path);\n const rc = this.opts.readCommand\n ? this.opts.readCommand(remotePath, params.start, params.end)\n : { cmd: 'sed', args: ['-n', `${params.start ?? 1},${params.end ?? 1_000_000}p`, remotePath] };\n const res = await this.opts.run(rc.cmd, rc.args, { cwd: this.opts.cwd, env: this.opts.env });\n if (res.exitCode !== 0) throw new Error(res.stderr || `read failed (${res.exitCode})`);\n const text = res.stdout || '';\n const lines = text.split(/\\r?\\n/).map((line, idx) => `${(params.start ?? 1) + idx}|${line}`);\n return { lines: lines.filter(l => l !== `${(params.start ?? 1) + (lines.length - 1)}|`) };\n }\n\n async analyse(params: { path: string; pattern?: string | null; maxResults?: number; maxDepth?: number }): Promise<AnalyseEntry[]> {\n // Minimal remote analyse: glob all files and trim\n const target = this.map(params.path);\n const pattern = params.pattern ?? '*';\n const files = await this.glob({ pattern, path: target }).catch(() => ({ files: [] }));\n return files.files.slice(0, params.maxResults ?? 100).map((f) => ({\n name: f.split('/').pop() || f,\n path: f,\n type: f.endsWith('/') ? 'dir' : 'file',\n depth: 0,\n }));\n }\n}\n\n\n","// Agent configuration defaults for morph-warp-grep\n// Hard-coded: SDK does not expose control over rounds or timeout.\nexport const AGENT_CONFIG = {\n // Give the model freedom; failsafe cap to prevent infinite loops\n MAX_ROUNDS: 10,\n TIMEOUT_MS: 30000,\n};\n\n/**\n * Comprehensive exclusion list for directories and files\n * These patterns are used with ripgrep's -g flag\n */\nconst BUILTIN_EXCLUDES = [\n // Version control\n '.git', '.svn', '.hg', '.bzr',\n \n // Dependencies\n 'node_modules', 'bower_components', '.pnpm', '.yarn',\n 'vendor', 'packages', 'Pods', '.bundle',\n \n // Python\n '__pycache__', '.pytest_cache', '.mypy_cache', '.ruff_cache',\n '.venv', 'venv', '.tox', '.nox', '.eggs', '*.egg-info',\n \n // Build outputs\n 'dist', 'build', 'out', 'output', 'target', '_build',\n '.next', '.nuxt', '.output', '.vercel', '.netlify',\n \n // Cache directories\n '.cache', '.parcel-cache', '.turbo', '.nx', '.gradle',\n \n // IDE/Editor\n '.idea', '.vscode', '.vs',\n \n // Coverage\n 'coverage', '.coverage', 'htmlcov', '.nyc_output',\n \n // Temporary\n 'tmp', 'temp', '.tmp', '.temp',\n \n // Lock files\n 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb',\n 'Cargo.lock', 'Gemfile.lock', 'poetry.lock',\n \n // Binary/minified\n '*.min.js', '*.min.css', '*.bundle.js',\n '*.wasm', '*.so', '*.dll', '*.pyc',\n '*.map', '*.js.map',\n \n // Hidden directories catch-all\n '.*',\n];\n\nexport const DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || '')\n .split(',')\n .map(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AO,MAAM,MAAM,MAAM,GAAG,OAAO,cAAc,GAAG,EAAE,IAAI,CAAC,OAAO;AAAA,MAChE,MAAM,EAAE,MAAM,GAAG,EAAE,IAAI,KAAK;AAAA,MAC5B,MAAM;AAAA,MACN,MAAM,EAAE,SAAS,GAAG,IAAI,QAAQ;AAAA,MAChC,OAAO;AAAA,IACT,EAAE;AAAA,EACJ;AACF;","names":[]}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { WarpGrepProvider, GrepResult, ReadResult, AnalyseEntry } from './types.js';
|
|
2
|
-
|
|
3
|
-
type ExecResult = {
|
|
4
|
-
stdout: string;
|
|
5
|
-
stderr: string;
|
|
6
|
-
exitCode: number;
|
|
7
|
-
};
|
|
8
|
-
declare class CommandExecProvider implements WarpGrepProvider {
|
|
9
|
-
private readonly opts;
|
|
10
|
-
constructor(opts: {
|
|
11
|
-
run: (cmd: string, args: string[], options?: {
|
|
12
|
-
cwd?: string;
|
|
13
|
-
env?: Record<string, string>;
|
|
14
|
-
}) => Promise<ExecResult>;
|
|
15
|
-
pathMap?: (localPath: string) => string;
|
|
16
|
-
cwd?: string;
|
|
17
|
-
env?: Record<string, string>;
|
|
18
|
-
readCommand?: (remotePath: string, start?: number, end?: number) => {
|
|
19
|
-
cmd: string;
|
|
20
|
-
args: string[];
|
|
21
|
-
};
|
|
22
|
-
excludes?: string[];
|
|
23
|
-
});
|
|
24
|
-
private map;
|
|
25
|
-
grep(params: {
|
|
26
|
-
pattern: string;
|
|
27
|
-
path: string;
|
|
28
|
-
}): Promise<GrepResult>;
|
|
29
|
-
glob(params: {
|
|
30
|
-
pattern: string;
|
|
31
|
-
path: string;
|
|
32
|
-
}): Promise<{
|
|
33
|
-
files: string[];
|
|
34
|
-
}>;
|
|
35
|
-
read(params: {
|
|
36
|
-
path: string;
|
|
37
|
-
start?: number;
|
|
38
|
-
end?: number;
|
|
39
|
-
}): Promise<ReadResult>;
|
|
40
|
-
analyse(params: {
|
|
41
|
-
path: string;
|
|
42
|
-
pattern?: string | null;
|
|
43
|
-
maxResults?: number;
|
|
44
|
-
maxDepth?: number;
|
|
45
|
-
}): Promise<AnalyseEntry[]>;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export { CommandExecProvider };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|