@morphllm/morphsdk 0.2.20 → 0.2.22
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-73RQWOQC.js +16 -0
- package/dist/chunk-73RQWOQC.js.map +1 -0
- package/dist/chunk-AFEPUNAO.js +15 -0
- package/dist/chunk-AFEPUNAO.js.map +1 -0
- package/dist/chunk-EAA7D24N.js +201 -0
- package/dist/chunk-EAA7D24N.js.map +1 -0
- package/dist/chunk-EK7OQPWD.js +44 -0
- package/dist/chunk-EK7OQPWD.js.map +1 -0
- package/dist/chunk-FSVBNZMU.js +44 -0
- package/dist/chunk-FSVBNZMU.js.map +1 -0
- package/dist/chunk-G2RSY56Q.js +11 -0
- package/dist/chunk-G2RSY56Q.js.map +1 -0
- package/dist/chunk-GTOXMAF2.js +140 -0
- package/dist/chunk-GTOXMAF2.js.map +1 -0
- package/dist/chunk-HKZB23U7.js +85 -0
- package/dist/chunk-HKZB23U7.js.map +1 -0
- package/dist/chunk-JZGU5UC6.js +53 -0
- package/dist/chunk-JZGU5UC6.js.map +1 -0
- package/dist/chunk-NDZO5IPV.js +121 -0
- package/dist/chunk-NDZO5IPV.js.map +1 -0
- package/dist/{chunk-XUL4CHWU.js → chunk-NSQGPBMU.js} +4 -4
- package/dist/chunk-RSLIOCOE.js +26 -0
- package/dist/chunk-RSLIOCOE.js.map +1 -0
- package/dist/chunk-SMGZ6A64.js +53 -0
- package/dist/chunk-SMGZ6A64.js.map +1 -0
- package/dist/chunk-TICMYDII.js +81 -0
- package/dist/chunk-TICMYDII.js.map +1 -0
- package/dist/chunk-UYBIKZPM.js +135 -0
- package/dist/chunk-UYBIKZPM.js.map +1 -0
- package/dist/chunk-VBBJGWHY.js +73 -0
- package/dist/chunk-VBBJGWHY.js.map +1 -0
- package/dist/chunk-XQLKK2ZH.js +56 -0
- package/dist/chunk-XQLKK2ZH.js.map +1 -0
- package/dist/chunk-XYPMN4A3.js +1 -0
- package/dist/chunk-XYPMN4A3.js.map +1 -0
- package/dist/chunk-Z2FBMSNE.js +10 -0
- package/dist/chunk-Z2FBMSNE.js.map +1 -0
- package/dist/client.js +3 -3
- package/dist/index.js +5 -5
- package/dist/tools/warp_grep/agent/config.cjs +41 -0
- package/dist/tools/warp_grep/agent/config.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/config.js +12 -0
- package/dist/tools/warp_grep/agent/config.js.map +1 -0
- package/dist/tools/warp_grep/agent/formatter.cjs +106 -0
- package/dist/tools/warp_grep/agent/formatter.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/formatter.js +10 -0
- package/dist/tools/warp_grep/agent/formatter.js.map +1 -0
- package/dist/tools/warp_grep/agent/grep_helpers.cjs +148 -0
- package/dist/tools/warp_grep/agent/grep_helpers.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/grep_helpers.js +14 -0
- package/dist/tools/warp_grep/agent/grep_helpers.js.map +1 -0
- package/dist/tools/warp_grep/agent/parser.cjs +165 -0
- package/dist/tools/warp_grep/agent/parser.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/parser.js +10 -0
- package/dist/tools/warp_grep/agent/parser.js.map +1 -0
- package/dist/tools/warp_grep/agent/prompt.cjs +110 -0
- package/dist/tools/warp_grep/agent/prompt.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/prompt.js +10 -0
- package/dist/tools/warp_grep/agent/prompt.js.map +1 -0
- package/dist/tools/warp_grep/agent/runner.cjs +744 -0
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/runner.js +17 -0
- package/dist/tools/warp_grep/agent/runner.js.map +1 -0
- package/dist/tools/warp_grep/agent/types.cjs +19 -0
- package/dist/tools/warp_grep/agent/types.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/types.js +2 -0
- package/dist/tools/warp_grep/agent/types.js.map +1 -0
- package/dist/tools/warp_grep/anthropic.cjs +977 -0
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -0
- package/dist/tools/warp_grep/anthropic.js +22 -0
- package/dist/tools/warp_grep/anthropic.js.map +1 -0
- package/dist/tools/warp_grep/index.cjs +1136 -0
- package/dist/tools/warp_grep/index.cjs.map +1 -0
- package/dist/tools/warp_grep/index.js +48 -0
- package/dist/tools/warp_grep/index.js.map +1 -0
- package/dist/tools/warp_grep/openai.cjs +980 -0
- package/dist/tools/warp_grep/openai.cjs.map +1 -0
- package/dist/tools/warp_grep/openai.js +22 -0
- package/dist/tools/warp_grep/openai.js.map +1 -0
- package/dist/tools/warp_grep/providers/command.cjs +98 -0
- package/dist/tools/warp_grep/providers/command.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/command.js +9 -0
- package/dist/tools/warp_grep/providers/command.js.map +1 -0
- package/dist/tools/warp_grep/providers/local.cjs +232 -0
- package/dist/tools/warp_grep/providers/local.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/local.js +12 -0
- package/dist/tools/warp_grep/providers/local.js.map +1 -0
- package/dist/tools/warp_grep/providers/types.cjs +19 -0
- package/dist/tools/warp_grep/providers/types.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/types.js +1 -0
- package/dist/tools/warp_grep/providers/types.js.map +1 -0
- package/dist/tools/warp_grep/tools/analyse.cjs +40 -0
- package/dist/tools/warp_grep/tools/analyse.cjs.map +1 -0
- package/dist/tools/warp_grep/tools/analyse.js +8 -0
- package/dist/tools/warp_grep/tools/analyse.js.map +1 -0
- package/dist/tools/warp_grep/tools/finish.cjs +69 -0
- package/dist/tools/warp_grep/tools/finish.cjs.map +1 -0
- package/dist/tools/warp_grep/tools/finish.js +10 -0
- package/dist/tools/warp_grep/tools/finish.js.map +1 -0
- package/dist/tools/warp_grep/tools/grep.cjs +35 -0
- package/dist/tools/warp_grep/tools/grep.cjs.map +1 -0
- package/dist/tools/warp_grep/tools/grep.js +12 -0
- package/dist/tools/warp_grep/tools/grep.js.map +1 -0
- package/dist/tools/warp_grep/tools/read.cjs +34 -0
- package/dist/tools/warp_grep/tools/read.cjs.map +1 -0
- package/dist/tools/warp_grep/tools/read.js +8 -0
- package/dist/tools/warp_grep/tools/read.js.map +1 -0
- package/dist/tools/warp_grep/utils/files.cjs +45 -0
- package/dist/tools/warp_grep/utils/files.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/files.js +8 -0
- package/dist/tools/warp_grep/utils/files.js.map +1 -0
- package/dist/tools/warp_grep/utils/format.cjs +42 -0
- package/dist/tools/warp_grep/utils/format.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/format.js +18 -0
- package/dist/tools/warp_grep/utils/format.js.map +1 -0
- package/dist/tools/warp_grep/utils/paths.cjs +91 -0
- package/dist/tools/warp_grep/utils/paths.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/paths.js +16 -0
- package/dist/tools/warp_grep/utils/paths.js.map +1 -0
- package/dist/tools/warp_grep/utils/ripgrep.cjs +50 -0
- package/dist/tools/warp_grep/utils/ripgrep.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/ripgrep.js +8 -0
- package/dist/tools/warp_grep/utils/ripgrep.js.map +1 -0
- package/dist/tools/warp_grep/vercel.cjs +968 -0
- package/dist/tools/warp_grep/vercel.cjs.map +1 -0
- package/dist/tools/warp_grep/vercel.js +22 -0
- package/dist/tools/warp_grep/vercel.js.map +1 -0
- package/package.json +23 -3
- package/dist/anthropic-CknfcMoO.d.ts +0 -64
- package/dist/client.d.ts +0 -114
- package/dist/git/client.d.ts +0 -230
- package/dist/git/config.d.ts +0 -11
- package/dist/git/index.d.ts +0 -5
- package/dist/git/types.d.ts +0 -91
- package/dist/index.d.ts +0 -14
- package/dist/modelrouter/core.d.ts +0 -56
- package/dist/modelrouter/index.d.ts +0 -2
- package/dist/modelrouter/types.d.ts +0 -35
- package/dist/openai-BkKsS30n.d.ts +0 -111
- package/dist/tools/browser/anthropic.d.ts +0 -51
- package/dist/tools/browser/core.d.ts +0 -196
- package/dist/tools/browser/index.d.ts +0 -72
- package/dist/tools/browser/openai.d.ts +0 -69
- package/dist/tools/browser/prompts.d.ts +0 -7
- package/dist/tools/browser/types.d.ts +0 -227
- package/dist/tools/browser/vercel.d.ts +0 -69
- package/dist/tools/codebase_search/anthropic.d.ts +0 -40
- package/dist/tools/codebase_search/core.d.ts +0 -40
- package/dist/tools/codebase_search/index.d.ts +0 -10
- package/dist/tools/codebase_search/openai.d.ts +0 -87
- package/dist/tools/codebase_search/prompts.d.ts +0 -7
- package/dist/tools/codebase_search/types.d.ts +0 -46
- package/dist/tools/codebase_search/vercel.d.ts +0 -65
- package/dist/tools/fastapply/anthropic.d.ts +0 -4
- package/dist/tools/fastapply/core.d.ts +0 -41
- package/dist/tools/fastapply/index.d.ts +0 -10
- package/dist/tools/fastapply/openai.d.ts +0 -4
- package/dist/tools/fastapply/prompts.d.ts +0 -7
- package/dist/tools/fastapply/types.d.ts +0 -77
- package/dist/tools/fastapply/vercel.d.ts +0 -4
- package/dist/tools/index.d.ts +0 -10
- package/dist/tools/utils/resilience.d.ts +0 -58
- package/dist/vercel-B1GZ_g9N.d.ts +0 -69
- /package/dist/{chunk-XUL4CHWU.js.map → chunk-NSQGPBMU.js.map} +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
runWarpGrep
|
|
3
|
+
} from "./chunk-EAA7D24N.js";
|
|
4
|
+
import {
|
|
5
|
+
LocalRipgrepProvider
|
|
6
|
+
} from "./chunk-UYBIKZPM.js";
|
|
7
|
+
|
|
8
|
+
// tools/warp_grep/openai.ts
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
var INPUT_SCHEMA = z.object({
|
|
11
|
+
query: z.string().describe("Free-form repository question")
|
|
12
|
+
});
|
|
13
|
+
function createMorphWarpGrepTool(config) {
|
|
14
|
+
const tool = {
|
|
15
|
+
type: "function",
|
|
16
|
+
function: {
|
|
17
|
+
name: "morph-warp-grep",
|
|
18
|
+
description: "A fast and accurate tool that can search for all relevant context in a codebase. You must use this tool to save time and avoid context pollution.",
|
|
19
|
+
parameters: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
query: { type: "string", description: "Free-form repository question" }
|
|
23
|
+
},
|
|
24
|
+
required: ["query"]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return Object.assign(tool, {
|
|
29
|
+
execute: async (input) => {
|
|
30
|
+
const parsed = INPUT_SCHEMA.parse(typeof input === "string" ? JSON.parse(input) : input);
|
|
31
|
+
const provider = config.provider ?? new LocalRipgrepProvider(config.repoRoot, config.excludes);
|
|
32
|
+
const result = await runWarpGrep({
|
|
33
|
+
query: parsed.query,
|
|
34
|
+
repoRoot: config.repoRoot,
|
|
35
|
+
provider,
|
|
36
|
+
excludes: config.excludes,
|
|
37
|
+
includes: config.includes,
|
|
38
|
+
debug: config.debug ?? false,
|
|
39
|
+
apiKey: config.apiKey
|
|
40
|
+
});
|
|
41
|
+
if (result.terminationReason !== "completed" || !result.finish?.metadata) {
|
|
42
|
+
return { success: false, error: "Search did not complete", messages: result.messages };
|
|
43
|
+
}
|
|
44
|
+
const contexts = (result.finish.resolved || []).map((r) => ({
|
|
45
|
+
file: r.path,
|
|
46
|
+
content: r.content
|
|
47
|
+
}));
|
|
48
|
+
return { success: true, contexts, summary: result.finish.payload };
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
createMorphWarpGrepTool
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=chunk-XQLKK2ZH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/openai.ts"],"sourcesContent":["import type { ChatCompletionTool } from 'openai/resources/chat/completions';\nimport { z } from 'zod';\nimport { runWarpGrep } from './agent/runner.js';\nimport type { WarpGrepProvider } from './providers/types.js';\nimport { LocalRipgrepProvider } from './providers/local.js';\nimport { AGENT_CONFIG } from './agent/config.js';\n\nexport type WarpGrepConfig = {\n repoRoot: string;\n provider?: WarpGrepProvider;\n excludes?: string[];\n includes?: string[];\n debug?: boolean;\n apiKey?: string; // Morph API key (defaults to env)\n};\n\nconst INPUT_SCHEMA = z.object({\n query: z.string().describe('Free-form repository question'),\n});\n\nexport function createMorphWarpGrepTool(config: WarpGrepConfig) {\n const tool: ChatCompletionTool = {\n type: 'function',\n function: {\n name: 'morph-warp-grep',\n description: 'A fast and accurate tool that can search for all relevant context in a codebase. You must use this tool to save time and avoid context pollution.',\n parameters: {\n type: 'object',\n properties: {\n query: { type: 'string', description: 'Free-form repository question' },\n },\n required: ['query'],\n },\n },\n };\n\n return Object.assign(tool, {\n execute: async (input: unknown) => {\n const parsed = INPUT_SCHEMA.parse(typeof input === 'string' ? JSON.parse(input) : input);\n const provider = config.provider ?? new LocalRipgrepProvider(config.repoRoot, config.excludes);\n const result = await runWarpGrep({\n query: parsed.query,\n repoRoot: config.repoRoot,\n provider,\n excludes: config.excludes,\n includes: config.includes,\n debug: config.debug ?? false,\n apiKey: config.apiKey,\n });\n if (result.terminationReason !== 'completed' || !result.finish?.metadata) {\n return { success: false, error: 'Search did not complete', messages: result.messages };\n }\n const contexts = (result.finish.resolved || []).map((r: any) => ({\n file: r.path,\n content: r.content,\n }));\n return { success: true, contexts, summary: result.finish.payload };\n },\n });\n}\n\n\n"],"mappings":";;;;;;;;AACA,SAAS,SAAS;AAelB,IAAM,eAAe,EAAE,OAAO;AAAA,EAC5B,OAAO,EAAE,OAAO,EAAE,SAAS,+BAA+B;AAC5D,CAAC;AAEM,SAAS,wBAAwB,QAAwB;AAC9D,QAAM,OAA2B;AAAA,IAC/B,MAAM;AAAA,IACN,UAAU;AAAA,MACR,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY;AAAA,UACV,OAAO,EAAE,MAAM,UAAU,aAAa,gCAAgC;AAAA,QACxE;AAAA,QACA,UAAU,CAAC,OAAO;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AAEA,SAAO,OAAO,OAAO,MAAM;AAAA,IACzB,SAAS,OAAO,UAAmB;AACjC,YAAM,SAAS,aAAa,MAAM,OAAO,UAAU,WAAW,KAAK,MAAM,KAAK,IAAI,KAAK;AACvF,YAAM,WAAW,OAAO,YAAY,IAAI,qBAAqB,OAAO,UAAU,OAAO,QAAQ;AAC7F,YAAM,SAAS,MAAM,YAAY;AAAA,QAC/B,OAAO,OAAO;AAAA,QACd,UAAU,OAAO;AAAA,QACjB;AAAA,QACA,UAAU,OAAO;AAAA,QACjB,UAAU,OAAO;AAAA,QACjB,OAAO,OAAO,SAAS;AAAA,QACvB,QAAQ,OAAO;AAAA,MACjB,CAAC;AACD,UAAI,OAAO,sBAAsB,eAAe,CAAC,OAAO,QAAQ,UAAU;AACxE,eAAO,EAAE,SAAS,OAAO,OAAO,2BAA2B,UAAU,OAAO,SAAS;AAAA,MACvF;AACA,YAAM,YAAY,OAAO,OAAO,YAAY,CAAC,GAAG,IAAI,CAAC,OAAY;AAAA,QAC/D,MAAM,EAAE;AAAA,QACR,SAAS,EAAE;AAAA,MACb,EAAE;AACF,aAAO,EAAE,SAAS,MAAM,UAAU,SAAS,OAAO,OAAO,QAAQ;AAAA,IACnE;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-XYPMN4A3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// tools/warp_grep/tools/read.ts
|
|
2
|
+
async function toolRead(provider, args) {
|
|
3
|
+
const res = await provider.read({ path: args.path, start: args.start, end: args.end });
|
|
4
|
+
return res.lines.join("\n");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
toolRead
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=chunk-Z2FBMSNE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/tools/read.ts"],"sourcesContent":["import type { WarpGrepProvider } from '../providers/types.js';\n\nexport async function toolRead(\n provider: WarpGrepProvider,\n args: { path: string; start?: number; end?: number }\n): Promise<string> {\n const res = await provider.read({ path: args.path, start: args.start, end: args.end });\n return res.lines.join('\\n');\n}\n\n\n"],"mappings":";AAEA,eAAsB,SACpB,UACA,MACiB;AACjB,QAAM,MAAM,MAAM,SAAS,KAAK,EAAE,MAAM,KAAK,MAAM,OAAO,KAAK,OAAO,KAAK,KAAK,IAAI,CAAC;AACrF,SAAO,IAAI,MAAM,KAAK,IAAI;AAC5B;","names":[]}
|
package/dist/client.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MorphClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NSQGPBMU.js";
|
|
4
4
|
import "./chunk-VJK4PH5V.js";
|
|
5
5
|
import "./chunk-Q7USYY6R.js";
|
|
6
6
|
import "./chunk-GPFHYUKV.js";
|
|
7
|
-
import "./chunk-AKVAAKRB.js";
|
|
8
|
-
import "./chunk-4VWJFZVS.js";
|
|
9
7
|
import "./chunk-74ZHKB54.js";
|
|
10
8
|
import "./chunk-5VQEQSJQ.js";
|
|
9
|
+
import "./chunk-AKVAAKRB.js";
|
|
10
|
+
import "./chunk-4VWJFZVS.js";
|
|
11
11
|
import "./chunk-PZ5AY32C.js";
|
|
12
12
|
export {
|
|
13
13
|
MorphClient
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MorphClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NSQGPBMU.js";
|
|
4
4
|
import {
|
|
5
5
|
CodebaseSearchClient
|
|
6
6
|
} from "./chunk-VJK4PH5V.js";
|
|
@@ -10,16 +10,16 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
BrowserClient
|
|
12
12
|
} from "./chunk-GPFHYUKV.js";
|
|
13
|
+
import "./chunk-74ZHKB54.js";
|
|
14
|
+
import {
|
|
15
|
+
MorphGit
|
|
16
|
+
} from "./chunk-5VQEQSJQ.js";
|
|
13
17
|
import {
|
|
14
18
|
AnthropicRouter,
|
|
15
19
|
GeminiRouter,
|
|
16
20
|
OpenAIRouter
|
|
17
21
|
} from "./chunk-AKVAAKRB.js";
|
|
18
22
|
import "./chunk-4VWJFZVS.js";
|
|
19
|
-
import "./chunk-74ZHKB54.js";
|
|
20
|
-
import {
|
|
21
|
-
MorphGit
|
|
22
|
-
} from "./chunk-5VQEQSJQ.js";
|
|
23
23
|
import "./chunk-PZ5AY32C.js";
|
|
24
24
|
export {
|
|
25
25
|
AnthropicRouter,
|
|
@@ -0,0 +1,41 @@
|
|
|
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/agent/config.ts
|
|
21
|
+
var config_exports = {};
|
|
22
|
+
__export(config_exports, {
|
|
23
|
+
AGENT_CONFIG: () => AGENT_CONFIG,
|
|
24
|
+
DEFAULT_EXCLUDES: () => DEFAULT_EXCLUDES,
|
|
25
|
+
DEFAULT_MODEL: () => DEFAULT_MODEL
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(config_exports);
|
|
28
|
+
var AGENT_CONFIG = {
|
|
29
|
+
// Give the model freedom; failsafe cap to prevent infinite loops
|
|
30
|
+
MAX_ROUNDS: 10,
|
|
31
|
+
TIMEOUT_MS: 3e4
|
|
32
|
+
};
|
|
33
|
+
var DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || "").split(",").map((s) => s.trim()).filter(Boolean).concat(["node_modules", ".git", "dist", "build", ".cache", "venv", "target"]);
|
|
34
|
+
var DEFAULT_MODEL = "morph-warp-grep";
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
AGENT_CONFIG,
|
|
38
|
+
DEFAULT_EXCLUDES,
|
|
39
|
+
DEFAULT_MODEL
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=config.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../tools/warp_grep/agent/config.ts"],"sourcesContent":["// 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\nexport const DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || '')\n .split(',')\n .map(s => s.trim())\n .filter(Boolean)\n .concat(['node_modules', '.git', 'dist', 'build', '.cache', 'venv', 'target']);\n\nexport const DEFAULT_MODEL = 'morph-warp-grep';\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,eAAe;AAAA;AAAA,EAE1B,YAAY;AAAA,EACZ,YAAY;AACd;AAEO,IAAM,oBAAoB,QAAQ,IAAI,2BAA2B,IACrE,MAAM,GAAG,EACT,IAAI,OAAK,EAAE,KAAK,CAAC,EACjB,OAAO,OAAO,EACd,OAAO,CAAC,gBAAgB,QAAQ,QAAQ,SAAS,UAAU,QAAQ,QAAQ,CAAC;AAExE,IAAM,gBAAgB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,106 @@
|
|
|
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/agent/formatter.ts
|
|
21
|
+
var formatter_exports = {};
|
|
22
|
+
__export(formatter_exports, {
|
|
23
|
+
ToolOutputFormatter: () => ToolOutputFormatter,
|
|
24
|
+
formatAgentToolOutput: () => formatAgentToolOutput
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(formatter_exports);
|
|
27
|
+
var ToolOutputFormatter = class {
|
|
28
|
+
format(toolName, args, output, options = {}) {
|
|
29
|
+
const name = (toolName ?? "").trim();
|
|
30
|
+
if (!name) {
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
33
|
+
const payload = output?.toString?.()?.trim?.() ?? "";
|
|
34
|
+
const isError = Boolean(options.isError);
|
|
35
|
+
const safeArgs = args ?? {};
|
|
36
|
+
if (!payload && !isError) {
|
|
37
|
+
return "";
|
|
38
|
+
}
|
|
39
|
+
switch (name) {
|
|
40
|
+
case "read":
|
|
41
|
+
return this.formatRead(safeArgs, payload, isError);
|
|
42
|
+
case "analyse":
|
|
43
|
+
return this.formatAnalyse(safeArgs, payload, isError);
|
|
44
|
+
case "grep":
|
|
45
|
+
return this.formatGrep(safeArgs, payload, isError);
|
|
46
|
+
default:
|
|
47
|
+
return payload ? `<tool_output>
|
|
48
|
+
${payload}
|
|
49
|
+
</tool_output>` : "";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
formatRead(args, payload, isError) {
|
|
53
|
+
if (isError) {
|
|
54
|
+
return payload;
|
|
55
|
+
}
|
|
56
|
+
const path = this.asString(args.path) || "...";
|
|
57
|
+
return `<file path="${path}">
|
|
58
|
+
${payload}
|
|
59
|
+
</file>`;
|
|
60
|
+
}
|
|
61
|
+
formatAnalyse(args, payload, isError) {
|
|
62
|
+
const path = this.asString(args.path) || ".";
|
|
63
|
+
if (isError) {
|
|
64
|
+
return `<analyse_results path="${path}" status="error">
|
|
65
|
+
${payload}
|
|
66
|
+
</analyse_results>`;
|
|
67
|
+
}
|
|
68
|
+
return `<analyse_results path="${path}">
|
|
69
|
+
${payload}
|
|
70
|
+
</analyse_results>`;
|
|
71
|
+
}
|
|
72
|
+
formatGrep(args, payload, isError) {
|
|
73
|
+
const pattern = this.asString(args.pattern);
|
|
74
|
+
const path = this.asString(args.path);
|
|
75
|
+
const attributes = [];
|
|
76
|
+
if (pattern !== void 0) {
|
|
77
|
+
attributes.push(`pattern="${pattern}"`);
|
|
78
|
+
}
|
|
79
|
+
if (path !== void 0) {
|
|
80
|
+
attributes.push(`path="${path}"`);
|
|
81
|
+
}
|
|
82
|
+
if (isError) {
|
|
83
|
+
attributes.push('status="error"');
|
|
84
|
+
}
|
|
85
|
+
const attrText = attributes.length ? ` ${attributes.join(" ")}` : "";
|
|
86
|
+
return `<grep_output${attrText}>
|
|
87
|
+
${payload}
|
|
88
|
+
</grep_output>`;
|
|
89
|
+
}
|
|
90
|
+
asString(value) {
|
|
91
|
+
if (value === null || value === void 0) {
|
|
92
|
+
return void 0;
|
|
93
|
+
}
|
|
94
|
+
return String(value);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
var sharedFormatter = new ToolOutputFormatter();
|
|
98
|
+
function formatAgentToolOutput(toolName, args, output, options = {}) {
|
|
99
|
+
return sharedFormatter.format(toolName, args, output, options);
|
|
100
|
+
}
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
ToolOutputFormatter,
|
|
104
|
+
formatAgentToolOutput
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=formatter.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../tools/warp_grep/agent/formatter.ts"],"sourcesContent":["export class ToolOutputFormatter {\n\tformat(\n\t\ttoolName: string,\n\t\targs: Record<string, unknown> | null | undefined,\n\t\toutput: string,\n\t\toptions: { isError?: boolean } = {}\n\t): string {\n\t\tconst name = (toolName ?? \"\").trim();\n\t\tif (!name) {\n\t\t\treturn \"\";\n\t\t}\n\t\tconst payload = (output as any)?.toString?.()?.trim?.() ?? \"\";\n\t\tconst isError = Boolean(options.isError);\n\t\tconst safeArgs = args ?? {};\n\n\t\tif (!payload && !isError) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\tswitch (name) {\n\t\t\tcase \"read\":\n\t\t\t\treturn this.formatRead(safeArgs, payload, isError);\n\t\t\tcase \"analyse\":\n\t\t\t\treturn this.formatAnalyse(safeArgs, payload, isError);\n\t\t\tcase \"grep\":\n\t\t\t\treturn this.formatGrep(safeArgs, payload, isError);\n\t\t\tdefault:\n\t\t\t\treturn payload ? `<tool_output>\\n${payload}\\n</tool_output>` : \"\";\n\t\t}\n\t}\n\n\tprivate formatRead(args: Record<string, unknown>, payload: string, isError: boolean): string {\n\t\tif (isError) {\n\t\t\treturn payload;\n\t\t}\n\t\tconst path = this.asString(args.path) || \"...\";\n\t\treturn `<file path=\"${path}\">\\n${payload}\\n</file>`;\n\t}\n\n\tprivate formatAnalyse(args: Record<string, unknown>, payload: string, isError: boolean): string {\n\t\tconst path = this.asString(args.path) || \".\";\n\t\tif (isError) {\n\t\t\treturn `<analyse_results path=\"${path}\" status=\"error\">\\n${payload}\\n</analyse_results>`;\n\t\t}\n\t\treturn `<analyse_results path=\"${path}\">\\n${payload}\\n</analyse_results>`;\n\t}\n\n\tprivate formatGrep(args: Record<string, unknown>, payload: string, isError: boolean): string {\n\t\tconst pattern = this.asString(args.pattern);\n\t\tconst path = this.asString(args.path);\n\t\tconst attributes: string[] = [];\n\t\tif (pattern !== undefined) {\n\t\t\tattributes.push(`pattern=\"${pattern}\"`);\n\t\t}\n\t\tif (path !== undefined) {\n\t\t\tattributes.push(`path=\"${path}\"`);\n\t\t}\n\t\tif (isError) {\n\t\t\tattributes.push('status=\"error\"');\n\t\t}\n\t\tconst attrText = attributes.length ? ` ${attributes.join(\" \")}` : \"\";\n\t\treturn `<grep_output${attrText}>\\n${payload}\\n</grep_output>`;\n\t}\n\n\tprivate asString(value: unknown): string | undefined {\n\t\tif (value === null || value === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn String(value);\n\t}\n}\n\nconst sharedFormatter = new ToolOutputFormatter();\n\nexport function formatAgentToolOutput(\n\ttoolName: string,\n\targs: Record<string, unknown> | null | undefined,\n\toutput: string,\n\toptions: { isError?: boolean } = {}\n): string {\n\treturn sharedFormatter.format(toolName, args, output, options);\n}\n\n"],"mappings":";;;;;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,UAAM,aAAuB,CAAC;AAC9B,QAAI,YAAY,QAAW;AAC1B,iBAAW,KAAK,YAAY,OAAO,GAAG;AAAA,IACvC;AACA,QAAI,SAAS,QAAW;AACvB,iBAAW,KAAK,SAAS,IAAI,GAAG;AAAA,IACjC;AACA,QAAI,SAAS;AACZ,iBAAW,KAAK,gBAAgB;AAAA,IACjC;AACA,UAAM,WAAW,WAAW,SAAS,IAAI,WAAW,KAAK,GAAG,CAAC,KAAK;AAClE,WAAO,eAAe,QAAQ;AAAA,EAAM,OAAO;AAAA;AAAA,EAC5C;AAAA,EAEQ,SAAS,OAAoC;AACpD,QAAI,UAAU,QAAQ,UAAU,QAAW;AAC1C,aAAO;AAAA,IACR;AACA,WAAO,OAAO,KAAK;AAAA,EACpB;AACD;AAEA,IAAM,kBAAkB,IAAI,oBAAoB;AAEzC,SAAS,sBACf,UACA,MACA,QACA,UAAiC,CAAC,GACzB;AACT,SAAO,gBAAgB,OAAO,UAAU,MAAM,QAAQ,OAAO;AAC9D;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,148 @@
|
|
|
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/agent/grep_helpers.ts
|
|
21
|
+
var grep_helpers_exports = {};
|
|
22
|
+
__export(grep_helpers_exports, {
|
|
23
|
+
GrepState: () => GrepState,
|
|
24
|
+
MAX_GREP_OUTPUT_CHARS_PER_TURN: () => MAX_GREP_OUTPUT_CHARS_PER_TURN,
|
|
25
|
+
formatTurnGrepOutput: () => formatTurnGrepOutput,
|
|
26
|
+
parseAndFilterGrepOutput: () => parseAndFilterGrepOutput
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(grep_helpers_exports);
|
|
29
|
+
var GrepState = class {
|
|
30
|
+
seenLines = /* @__PURE__ */ new Set();
|
|
31
|
+
isNew(path, lineNumber) {
|
|
32
|
+
const key = this.makeKey(path, lineNumber);
|
|
33
|
+
return !this.seenLines.has(key);
|
|
34
|
+
}
|
|
35
|
+
add(path, lineNumber) {
|
|
36
|
+
this.seenLines.add(this.makeKey(path, lineNumber));
|
|
37
|
+
}
|
|
38
|
+
makeKey(path, lineNumber) {
|
|
39
|
+
return `${path}:${lineNumber}`;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var MAX_GREP_OUTPUT_CHARS_PER_TURN = 6e4;
|
|
43
|
+
function extractMatchFields(payload) {
|
|
44
|
+
const text = payload.replace(/\r?\n$/, "");
|
|
45
|
+
if (!text || text.startsWith("[error]")) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const firstSep = text.indexOf(":");
|
|
49
|
+
if (firstSep === -1) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
let filePath = text.slice(0, firstSep).trim();
|
|
53
|
+
if (!filePath) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
if (filePath.startsWith("./") || filePath.startsWith(".\\")) {
|
|
57
|
+
filePath = filePath.slice(2);
|
|
58
|
+
}
|
|
59
|
+
const remainder = text.slice(firstSep + 1);
|
|
60
|
+
const secondSep = remainder.indexOf(":");
|
|
61
|
+
if (secondSep === -1) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
const linePart = remainder.slice(0, secondSep);
|
|
65
|
+
const lineNumber = Number.parseInt(linePart, 10);
|
|
66
|
+
if (!Number.isInteger(lineNumber) || lineNumber <= 0) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
let contentSegment = remainder.slice(secondSep + 1);
|
|
70
|
+
const columnSep = contentSegment.indexOf(":");
|
|
71
|
+
if (columnSep !== -1 && /^\d+$/.test(contentSegment.slice(0, columnSep))) {
|
|
72
|
+
contentSegment = contentSegment.slice(columnSep + 1);
|
|
73
|
+
}
|
|
74
|
+
const content = contentSegment.trim();
|
|
75
|
+
if (!content) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return { path: filePath, lineNumber, content };
|
|
79
|
+
}
|
|
80
|
+
function parseAndFilterGrepOutput(rawOutput, state) {
|
|
81
|
+
const matches = [];
|
|
82
|
+
if (typeof rawOutput !== "string" || !rawOutput.trim()) {
|
|
83
|
+
return matches;
|
|
84
|
+
}
|
|
85
|
+
for (const line of rawOutput.split(/\r?\n/)) {
|
|
86
|
+
const fields = extractMatchFields(line);
|
|
87
|
+
if (!fields) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (state.isNew(fields.path, fields.lineNumber)) {
|
|
91
|
+
matches.push(fields);
|
|
92
|
+
state.add(fields.path, fields.lineNumber);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return matches;
|
|
96
|
+
}
|
|
97
|
+
function truncateOutput(payload, maxChars) {
|
|
98
|
+
if (payload.length <= maxChars) {
|
|
99
|
+
return payload;
|
|
100
|
+
}
|
|
101
|
+
const note = "... (output truncated)";
|
|
102
|
+
const available = maxChars - note.length - 1;
|
|
103
|
+
if (available <= 0) {
|
|
104
|
+
return note;
|
|
105
|
+
}
|
|
106
|
+
if (payload.length <= available) {
|
|
107
|
+
return `${payload.slice(0, available).replace(/\n$/, "")}
|
|
108
|
+
${note}`;
|
|
109
|
+
}
|
|
110
|
+
const core = payload.slice(0, Math.max(0, available - 1));
|
|
111
|
+
const trimmed = core.replace(/\n$/, "").replace(/\s+$/, "");
|
|
112
|
+
const snippet = trimmed ? `${trimmed}\u2026` : "\u2026";
|
|
113
|
+
return `${snippet}
|
|
114
|
+
${note}`;
|
|
115
|
+
}
|
|
116
|
+
function formatTurnGrepOutput(matches, maxChars = MAX_GREP_OUTPUT_CHARS_PER_TURN) {
|
|
117
|
+
if (!matches || matches.length === 0) {
|
|
118
|
+
return "No new matches found.";
|
|
119
|
+
}
|
|
120
|
+
const matchesByFile = /* @__PURE__ */ new Map();
|
|
121
|
+
for (const match of matches) {
|
|
122
|
+
if (!matchesByFile.has(match.path)) {
|
|
123
|
+
matchesByFile.set(match.path, []);
|
|
124
|
+
}
|
|
125
|
+
matchesByFile.get(match.path).push(match);
|
|
126
|
+
}
|
|
127
|
+
const lines = [];
|
|
128
|
+
const sortedPaths = Array.from(matchesByFile.keys()).sort();
|
|
129
|
+
sortedPaths.forEach((filePath, index) => {
|
|
130
|
+
if (index > 0) {
|
|
131
|
+
lines.push("");
|
|
132
|
+
}
|
|
133
|
+
lines.push(filePath);
|
|
134
|
+
const sortedMatches = matchesByFile.get(filePath).slice().sort((a, b) => a.lineNumber - b.lineNumber);
|
|
135
|
+
for (const match of sortedMatches) {
|
|
136
|
+
lines.push(`${match.lineNumber}:${match.content}`);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return truncateOutput(lines.join("\n"), maxChars);
|
|
140
|
+
}
|
|
141
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
142
|
+
0 && (module.exports = {
|
|
143
|
+
GrepState,
|
|
144
|
+
MAX_GREP_OUTPUT_CHARS_PER_TURN,
|
|
145
|
+
formatTurnGrepOutput,
|
|
146
|
+
parseAndFilterGrepOutput
|
|
147
|
+
});
|
|
148
|
+
//# sourceMappingURL=grep_helpers.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../tools/warp_grep/agent/grep_helpers.ts"],"sourcesContent":["export interface GrepMatch {\n\tpath: string;\n\tlineNumber: number;\n\tcontent: string;\n}\n\nexport class GrepState {\n\tprivate readonly seenLines = new Set<string>();\n\n\tisNew(path: string, lineNumber: number): boolean {\n\t\tconst key = this.makeKey(path, lineNumber);\n\t\treturn !this.seenLines.has(key);\n\t}\n\n\tadd(path: string, lineNumber: number): void {\n\t\tthis.seenLines.add(this.makeKey(path, lineNumber));\n\t}\n\n\tprivate makeKey(path: string, lineNumber: number): string {\n\t\treturn `${path}:${lineNumber}`;\n\t}\n}\n\nexport const MAX_GREP_OUTPUT_CHARS_PER_TURN = 60_000;\n\nfunction extractMatchFields(payload: string): GrepMatch | null {\n\tconst text = payload.replace(/\\r?\\n$/, \"\");\n\tif (!text || text.startsWith(\"[error]\")) {\n\t\treturn null;\n\t}\n\n\tconst firstSep = text.indexOf(\":\");\n\tif (firstSep === -1) {\n\t\treturn null;\n\t}\n\tlet filePath = text.slice(0, firstSep).trim();\n\tif (!filePath) {\n\t\treturn null;\n\t}\n\tif (filePath.startsWith(\"./\") || filePath.startsWith(\".\\\\\")) {\n\t\tfilePath = filePath.slice(2);\n\t}\n\n\tconst remainder = text.slice(firstSep + 1);\n\tconst secondSep = remainder.indexOf(\":\");\n\tif (secondSep === -1) {\n\t\treturn null;\n\t}\n\n\tconst linePart = remainder.slice(0, secondSep);\n\tconst lineNumber = Number.parseInt(linePart, 10);\n\tif (!Number.isInteger(lineNumber) || lineNumber <= 0) {\n\t\treturn null;\n\t}\n\n\tlet contentSegment = remainder.slice(secondSep + 1);\n\tconst columnSep = contentSegment.indexOf(\":\");\n\tif (columnSep !== -1 && /^\\d+$/.test(contentSegment.slice(0, columnSep))) {\n\t\tcontentSegment = contentSegment.slice(columnSep + 1);\n\t}\n\n\tconst content = contentSegment.trim();\n\tif (!content) {\n\t\treturn null;\n\t}\n\n\treturn { path: filePath, lineNumber, content };\n}\n\nexport function parseAndFilterGrepOutput(rawOutput: string, state: GrepState): GrepMatch[] {\n\tconst matches: GrepMatch[] = [];\n\tif (typeof rawOutput !== \"string\" || !rawOutput.trim()) {\n\t\treturn matches;\n\t}\n\n\tfor (const line of rawOutput.split(/\\r?\\n/)) {\n\t\tconst fields = extractMatchFields(line);\n\t\tif (!fields) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (state.isNew(fields.path, fields.lineNumber)) {\n\t\t\tmatches.push(fields);\n\t\t\tstate.add(fields.path, fields.lineNumber);\n\t\t}\n\t}\n\n\treturn matches;\n}\n\nfunction truncateOutput(payload: string, maxChars: number): string {\n\tif (payload.length <= maxChars) {\n\t\treturn payload;\n\t}\n\n\tconst note = \"... (output truncated)\";\n\tconst available = maxChars - note.length - 1;\n\tif (available <= 0) {\n\t\treturn note;\n\t}\n\n\tif (payload.length <= available) {\n\t\treturn `${payload.slice(0, available).replace(/\\n$/, \"\")}\\n${note}`;\n\t}\n\n\tconst core = payload.slice(0, Math.max(0, available - 1));\n\tconst trimmed = core.replace(/\\n$/, \"\").replace(/\\s+$/, \"\");\n\tconst snippet = trimmed ? `${trimmed}…` : \"…\";\n\treturn `${snippet}\\n${note}`;\n}\n\nexport function formatTurnGrepOutput(\n\tmatches: GrepMatch[],\n\tmaxChars: number = MAX_GREP_OUTPUT_CHARS_PER_TURN\n): string {\n\tif (!matches || matches.length === 0) {\n\t\treturn \"No new matches found.\";\n\t}\n\n\tconst matchesByFile = new Map<string, GrepMatch[]>();\n\tfor (const match of matches) {\n\t\tif (!matchesByFile.has(match.path)) {\n\t\t\tmatchesByFile.set(match.path, []);\n\t\t}\n\t\tmatchesByFile.get(match.path)!.push(match);\n\t}\n\n\tconst lines: string[] = [];\n\tconst sortedPaths = Array.from(matchesByFile.keys()).sort();\n\tsortedPaths.forEach((filePath, index) => {\n\t\tif (index > 0) {\n\t\t\tlines.push(\"\");\n\t\t}\n\t\tlines.push(filePath);\n\t\tconst sortedMatches = matchesByFile\n\t\t\t.get(filePath)!\n\t\t\t.slice()\n\t\t\t.sort((a, b) => a.lineNumber - b.lineNumber);\n\t\tfor (const match of sortedMatches) {\n\t\t\tlines.push(`${match.lineNumber}:${match.content}`);\n\t\t}\n\t});\n\n\treturn truncateOutput(lines.join(\"\\n\"), maxChars);\n}\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,IAAM,YAAN,MAAgB;AAAA,EACL,YAAY,oBAAI,IAAY;AAAA,EAE7C,MAAM,MAAc,YAA6B;AAChD,UAAM,MAAM,KAAK,QAAQ,MAAM,UAAU;AACzC,WAAO,CAAC,KAAK,UAAU,IAAI,GAAG;AAAA,EAC/B;AAAA,EAEA,IAAI,MAAc,YAA0B;AAC3C,SAAK,UAAU,IAAI,KAAK,QAAQ,MAAM,UAAU,CAAC;AAAA,EAClD;AAAA,EAEQ,QAAQ,MAAc,YAA4B;AACzD,WAAO,GAAG,IAAI,IAAI,UAAU;AAAA,EAC7B;AACD;AAEO,IAAM,iCAAiC;AAE9C,SAAS,mBAAmB,SAAmC;AAC9D,QAAM,OAAO,QAAQ,QAAQ,UAAU,EAAE;AACzC,MAAI,CAAC,QAAQ,KAAK,WAAW,SAAS,GAAG;AACxC,WAAO;AAAA,EACR;AAEA,QAAM,WAAW,KAAK,QAAQ,GAAG;AACjC,MAAI,aAAa,IAAI;AACpB,WAAO;AAAA,EACR;AACA,MAAI,WAAW,KAAK,MAAM,GAAG,QAAQ,EAAE,KAAK;AAC5C,MAAI,CAAC,UAAU;AACd,WAAO;AAAA,EACR;AACA,MAAI,SAAS,WAAW,IAAI,KAAK,SAAS,WAAW,KAAK,GAAG;AAC5D,eAAW,SAAS,MAAM,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|
|
1
|
+
import {
|
|
2
|
+
GrepState,
|
|
3
|
+
MAX_GREP_OUTPUT_CHARS_PER_TURN,
|
|
4
|
+
formatTurnGrepOutput,
|
|
5
|
+
parseAndFilterGrepOutput
|
|
6
|
+
} from "../../../chunk-NDZO5IPV.js";
|
|
7
|
+
import "../../../chunk-PZ5AY32C.js";
|
|
8
|
+
export {
|
|
9
|
+
GrepState,
|
|
10
|
+
MAX_GREP_OUTPUT_CHARS_PER_TURN,
|
|
11
|
+
formatTurnGrepOutput,
|
|
12
|
+
parseAndFilterGrepOutput
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=grep_helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|