@morphllm/morphsdk 0.2.45 → 0.2.46
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/README.md +1 -1
- package/dist/{chunk-TVFGHXPE.js → chunk-3FTAIJBH.js} +4 -4
- package/dist/chunk-5JTJOQUX.js +283 -0
- package/dist/chunk-5JTJOQUX.js.map +1 -0
- package/dist/{chunk-ZRLEAPZV.js → chunk-76DJEQEP.js} +4 -4
- package/dist/{chunk-W3XLPMV3.js → chunk-7HS6YXA3.js} +21 -5
- package/dist/{chunk-W3XLPMV3.js.map → chunk-7HS6YXA3.js.map} +1 -1
- package/dist/chunk-7T7YOPJV.js +82 -0
- package/dist/chunk-7T7YOPJV.js.map +1 -0
- package/dist/chunk-CL45IWIU.js +105 -0
- package/dist/chunk-CL45IWIU.js.map +1 -0
- package/dist/chunk-D6OD3IST.js +70 -0
- package/dist/chunk-D6OD3IST.js.map +1 -0
- package/dist/{chunk-PEGZVGG4.js → chunk-G4AWE5A2.js} +4 -4
- package/dist/{chunk-OUEJ6XEO.js → chunk-GJU7UOFL.js} +4 -4
- package/dist/{chunk-Q7PDN7TS.js → chunk-GZMUGMOZ.js} +1 -1
- package/dist/{chunk-Q7PDN7TS.js.map → chunk-GZMUGMOZ.js.map} +1 -1
- package/dist/chunk-JYBVRF72.js +1 -0
- package/dist/{chunk-GDR65N2J.js → chunk-OXHGFHEU.js} +53 -26
- package/dist/chunk-OXHGFHEU.js.map +1 -0
- package/dist/{chunk-VBBJGWHY.js → chunk-P2XKFWFD.js} +2 -2
- package/dist/chunk-PABIV7X6.js +76 -0
- package/dist/chunk-PABIV7X6.js.map +1 -0
- package/dist/{chunk-GTOXMAF2.js → chunk-SWQPIKPY.js} +44 -3
- package/dist/chunk-SWQPIKPY.js.map +1 -0
- package/dist/chunk-TJIUA27P.js +94 -0
- package/dist/chunk-TJIUA27P.js.map +1 -0
- package/dist/{chunk-O5DA5V5S.js → chunk-UBX7QYBD.js} +4 -4
- package/dist/{chunk-X4CQ6D3G.js → chunk-UIZT3KVJ.js} +4 -4
- package/dist/{chunk-UYBIKZPM.js → chunk-UXYK7WZX.js} +2 -2
- package/dist/chunk-WETRQJGU.js +129 -0
- package/dist/chunk-WETRQJGU.js.map +1 -0
- package/dist/client-BGctTHu9.d.ts +318 -0
- package/dist/client.cjs +1885 -44
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +14 -110
- package/dist/client.js +28 -3
- package/dist/core-DxiUwyBe.d.ts +156 -0
- package/dist/git/client.cjs +52 -25
- package/dist/git/client.cjs.map +1 -1
- package/dist/git/client.d.ts +17 -8
- package/dist/git/client.js +1 -1
- package/dist/git/index.cjs +52 -25
- package/dist/git/index.cjs.map +1 -1
- package/dist/git/index.d.ts +1 -1
- package/dist/git/index.js +2 -2
- package/dist/git/types.cjs.map +1 -1
- package/dist/git/types.d.ts +20 -2
- package/dist/index.cjs +1964 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +47 -5
- package/dist/tools/codebase_search/anthropic.js +2 -2
- package/dist/tools/codebase_search/index.js +9 -9
- package/dist/tools/codebase_search/openai.js +2 -2
- package/dist/tools/codebase_search/vercel.js +2 -2
- package/dist/tools/fastapply/anthropic.js +2 -2
- package/dist/tools/fastapply/index.js +7 -7
- package/dist/tools/fastapply/openai.js +2 -2
- package/dist/tools/fastapply/vercel.js +2 -2
- package/dist/tools/index.js +7 -7
- package/dist/tools/warp_grep/agent/config.cjs +80 -1
- package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/config.js +1 -1
- package/dist/tools/warp_grep/agent/parser.cjs +43 -2
- package/dist/tools/warp_grep/agent/parser.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/parser.js +1 -1
- package/dist/tools/warp_grep/agent/prompt.cjs +89 -45
- package/dist/tools/warp_grep/agent/prompt.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/prompt.d.ts +1 -1
- package/dist/tools/warp_grep/agent/prompt.js +1 -1
- package/dist/tools/warp_grep/agent/runner.cjs +229 -49
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +4 -4
- package/dist/tools/warp_grep/agent/types.js +0 -1
- package/dist/tools/warp_grep/anthropic.cjs +311 -83
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +75 -12
- package/dist/tools/warp_grep/anthropic.js +21 -8
- package/dist/tools/warp_grep/index.cjs +415 -126
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +17 -4
- package/dist/tools/warp_grep/index.js +29 -21
- package/dist/tools/warp_grep/openai.cjs +314 -83
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +73 -29
- package/dist/tools/warp_grep/openai.js +21 -8
- package/dist/tools/warp_grep/providers/command.cjs +80 -1
- package/dist/tools/warp_grep/providers/command.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/command.js +2 -2
- package/dist/tools/warp_grep/providers/local.cjs +80 -1
- package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/local.js +2 -2
- package/dist/tools/warp_grep/vercel.cjs +291 -57
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +40 -19
- package/dist/tools/warp_grep/vercel.js +17 -8
- package/package.json +1 -1
- package/dist/chunk-AFEPUNAO.js +0 -15
- package/dist/chunk-AFEPUNAO.js.map +0 -1
- package/dist/chunk-GDR65N2J.js.map +0 -1
- package/dist/chunk-GTOXMAF2.js.map +0 -1
- package/dist/chunk-HKZB23U7.js +0 -85
- package/dist/chunk-HKZB23U7.js.map +0 -1
- package/dist/chunk-IQHKEIQX.js +0 -54
- package/dist/chunk-IQHKEIQX.js.map +0 -1
- package/dist/chunk-JKFVDM62.js +0 -45
- package/dist/chunk-JKFVDM62.js.map +0 -1
- package/dist/chunk-K6FQZZ2E.js +0 -104
- package/dist/chunk-K6FQZZ2E.js.map +0 -1
- package/dist/chunk-KL4YVZRF.js +0 -57
- package/dist/chunk-KL4YVZRF.js.map +0 -1
- package/dist/chunk-XYPMN4A3.js +0 -1
- /package/dist/{chunk-TVFGHXPE.js.map → chunk-3FTAIJBH.js.map} +0 -0
- /package/dist/{chunk-ZRLEAPZV.js.map → chunk-76DJEQEP.js.map} +0 -0
- /package/dist/{chunk-PEGZVGG4.js.map → chunk-G4AWE5A2.js.map} +0 -0
- /package/dist/{chunk-OUEJ6XEO.js.map → chunk-GJU7UOFL.js.map} +0 -0
- /package/dist/{chunk-XYPMN4A3.js.map → chunk-JYBVRF72.js.map} +0 -0
- /package/dist/{chunk-VBBJGWHY.js.map → chunk-P2XKFWFD.js.map} +0 -0
- /package/dist/{chunk-O5DA5V5S.js.map → chunk-UBX7QYBD.js.map} +0 -0
- /package/dist/{chunk-X4CQ6D3G.js.map → chunk-UIZT3KVJ.js.map} +0 -0
- /package/dist/{chunk-UYBIKZPM.js.map → chunk-UXYK7WZX.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
export { MorphClient, MorphClientConfig } from './client.js';
|
|
1
|
+
export { A as AnthropicToolFactory, M as MorphClient, a as MorphClientConfig, O as OpenAIToolFactory, V as VercelToolFactory } from './client-BGctTHu9.js';
|
|
2
2
|
export { FastApplyClient } from './tools/fastapply/core.js';
|
|
3
3
|
export { CodebaseSearchClient } from './tools/codebase_search/core.js';
|
|
4
|
+
export { W as WarpGrepClient, a as WarpGrepClientConfig, d as WarpGrepContext, b as WarpGrepInput, c as WarpGrepResult, e as WarpGrepToolConfig } from './core-DxiUwyBe.js';
|
|
4
5
|
export { BrowserClient } from './tools/browser/core.js';
|
|
5
6
|
export { MorphGit } from './git/client.js';
|
|
6
7
|
export { MorphGitConfig } from './git/types.js';
|
|
8
|
+
export { LocalRipgrepProvider } from './tools/warp_grep/providers/local.js';
|
|
9
|
+
export { CommandExecProvider } from './tools/warp_grep/providers/command.js';
|
|
10
|
+
export { WarpGrepProvider } from './tools/warp_grep/providers/types.js';
|
|
7
11
|
export { AnthropicRouter, GeminiRouter, OpenAIRouter, RawRouter } from './modelrouter/core.js';
|
|
8
12
|
export { EditFileConfig, EditFileInput, EditFileResult } from './tools/fastapply/types.js';
|
|
9
13
|
export { CodebaseSearchConfig, CodebaseSearchInput, CodebaseSearchResult } from './tools/codebase_search/types.js';
|
|
10
14
|
export { BrowserConfig, BrowserError, BrowserTaskInput, BrowserTaskInputWithSchema, BrowserTaskResult, BrowserTaskWithPromise, BrowserTaskWithPromiseAndSchema, ErrorsResponse, RecordingStatus } from './tools/browser/types.js';
|
|
11
15
|
export { ComplexityLevel, Provider, RawRouterResult, RouterConfig, RouterInput, RouterMode, RouterResult } from './modelrouter/types.js';
|
|
12
16
|
export { RetryConfig } from './tools/utils/resilience.js';
|
|
17
|
+
import 'openai/resources/index.mjs';
|
|
18
|
+
import '@anthropic-ai/sdk/resources/messages.mjs';
|
|
19
|
+
import 'ai';
|
|
13
20
|
import 'isomorphic-git';
|
|
14
21
|
import 'isomorphic-git/http/node';
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,56 @@
|
|
|
1
|
+
import "./chunk-JYBVRF72.js";
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
CommandExecProvider
|
|
4
|
+
} from "./chunk-P2XKFWFD.js";
|
|
5
|
+
import {
|
|
6
|
+
AnthropicToolFactory,
|
|
7
|
+
MorphClient,
|
|
8
|
+
OpenAIToolFactory,
|
|
9
|
+
VercelToolFactory
|
|
10
|
+
} from "./chunk-5JTJOQUX.js";
|
|
11
|
+
import "./chunk-PABIV7X6.js";
|
|
12
|
+
import "./chunk-7T7YOPJV.js";
|
|
13
|
+
import "./chunk-D6OD3IST.js";
|
|
14
|
+
import {
|
|
15
|
+
WarpGrepClient
|
|
16
|
+
} from "./chunk-CL45IWIU.js";
|
|
17
|
+
import "./chunk-7HS6YXA3.js";
|
|
18
|
+
import "./chunk-EK7OQPWD.js";
|
|
19
|
+
import "./chunk-Z2FBMSNE.js";
|
|
20
|
+
import "./chunk-SWQPIKPY.js";
|
|
21
|
+
import "./chunk-WETRQJGU.js";
|
|
22
|
+
import {
|
|
23
|
+
LocalRipgrepProvider
|
|
24
|
+
} from "./chunk-UXYK7WZX.js";
|
|
25
|
+
import "./chunk-G2RSY56Q.js";
|
|
26
|
+
import "./chunk-SMGZ6A64.js";
|
|
27
|
+
import "./chunk-RSLIOCOE.js";
|
|
28
|
+
import "./chunk-73RQWOQC.js";
|
|
29
|
+
import "./chunk-TJIUA27P.js";
|
|
30
|
+
import "./chunk-TICMYDII.js";
|
|
31
|
+
import "./chunk-NDZO5IPV.js";
|
|
32
|
+
import "./chunk-UBX7QYBD.js";
|
|
33
|
+
import "./chunk-GJU7UOFL.js";
|
|
34
|
+
import "./chunk-76DJEQEP.js";
|
|
4
35
|
import {
|
|
5
36
|
CodebaseSearchClient
|
|
6
37
|
} from "./chunk-WM77HRKO.js";
|
|
38
|
+
import "./chunk-YQMPVJ2L.js";
|
|
39
|
+
import "./chunk-3FTAIJBH.js";
|
|
40
|
+
import "./chunk-G4AWE5A2.js";
|
|
41
|
+
import "./chunk-UIZT3KVJ.js";
|
|
7
42
|
import {
|
|
8
43
|
FastApplyClient
|
|
9
44
|
} from "./chunk-64PMM72R.js";
|
|
45
|
+
import "./chunk-63WE2C5R.js";
|
|
10
46
|
import {
|
|
11
47
|
BrowserClient
|
|
12
48
|
} from "./chunk-LVY5LPEX.js";
|
|
13
49
|
import "./chunk-SQN4DUQS.js";
|
|
14
|
-
import "./chunk-
|
|
50
|
+
import "./chunk-GZMUGMOZ.js";
|
|
15
51
|
import {
|
|
16
52
|
MorphGit
|
|
17
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-OXHGFHEU.js";
|
|
18
54
|
import {
|
|
19
55
|
AnthropicRouter,
|
|
20
56
|
GeminiRouter,
|
|
@@ -25,13 +61,19 @@ import "./chunk-4VWJFZVS.js";
|
|
|
25
61
|
import "./chunk-PZ5AY32C.js";
|
|
26
62
|
export {
|
|
27
63
|
AnthropicRouter,
|
|
64
|
+
AnthropicToolFactory,
|
|
28
65
|
BrowserClient,
|
|
29
66
|
CodebaseSearchClient,
|
|
67
|
+
CommandExecProvider,
|
|
30
68
|
FastApplyClient,
|
|
31
69
|
GeminiRouter,
|
|
70
|
+
LocalRipgrepProvider,
|
|
32
71
|
MorphClient,
|
|
33
72
|
MorphGit,
|
|
34
73
|
OpenAIRouter,
|
|
35
|
-
|
|
74
|
+
OpenAIToolFactory,
|
|
75
|
+
RawRouter,
|
|
76
|
+
VercelToolFactory,
|
|
77
|
+
WarpGrepClient
|
|
36
78
|
};
|
|
37
79
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCodebaseSearchTool
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-YQMPVJ2L.js";
|
|
3
|
+
} from "../../chunk-GJU7UOFL.js";
|
|
5
4
|
import "../../chunk-WM77HRKO.js";
|
|
5
|
+
import "../../chunk-YQMPVJ2L.js";
|
|
6
6
|
import "../../chunk-4VWJFZVS.js";
|
|
7
7
|
import "../../chunk-PZ5AY32C.js";
|
|
8
8
|
export {
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCodebaseSearchTool as createCodebaseSearchTool3
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-UBX7QYBD.js";
|
|
4
|
+
import {
|
|
5
|
+
createCodebaseSearchTool as createCodebaseSearchTool2
|
|
6
|
+
} from "../../chunk-GJU7UOFL.js";
|
|
4
7
|
import {
|
|
5
8
|
createCodebaseSearchTool
|
|
6
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-76DJEQEP.js";
|
|
7
10
|
import {
|
|
8
|
-
|
|
9
|
-
} from "../../chunk-
|
|
11
|
+
executeCodebaseSearch
|
|
12
|
+
} from "../../chunk-WM77HRKO.js";
|
|
10
13
|
import {
|
|
11
14
|
CODEBASE_SEARCH_DESCRIPTION,
|
|
12
15
|
CODEBASE_SEARCH_SYSTEM_PROMPT
|
|
13
16
|
} from "../../chunk-YQMPVJ2L.js";
|
|
14
|
-
import {
|
|
15
|
-
executeCodebaseSearch
|
|
16
|
-
} from "../../chunk-WM77HRKO.js";
|
|
17
17
|
import "../../chunk-4VWJFZVS.js";
|
|
18
18
|
import "../../chunk-PZ5AY32C.js";
|
|
19
19
|
export {
|
|
20
20
|
CODEBASE_SEARCH_DESCRIPTION,
|
|
21
21
|
CODEBASE_SEARCH_SYSTEM_PROMPT,
|
|
22
|
-
|
|
22
|
+
createCodebaseSearchTool2 as anthropicCodebaseSearchTool,
|
|
23
23
|
executeCodebaseSearch,
|
|
24
|
-
|
|
24
|
+
createCodebaseSearchTool as openaiCodebaseSearchTool,
|
|
25
25
|
createCodebaseSearchTool3 as vercelCodebaseSearchTool
|
|
26
26
|
};
|
|
27
27
|
//# sourceMappingURL=index.js.map
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
formatResult,
|
|
6
6
|
getSystemPrompt,
|
|
7
7
|
openai_default
|
|
8
|
-
} from "../../chunk-
|
|
9
|
-
import "../../chunk-YQMPVJ2L.js";
|
|
8
|
+
} from "../../chunk-76DJEQEP.js";
|
|
10
9
|
import "../../chunk-WM77HRKO.js";
|
|
10
|
+
import "../../chunk-YQMPVJ2L.js";
|
|
11
11
|
import "../../chunk-4VWJFZVS.js";
|
|
12
12
|
import "../../chunk-PZ5AY32C.js";
|
|
13
13
|
export {
|
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
createCodebaseSearchTool,
|
|
3
3
|
getSystemPrompt,
|
|
4
4
|
vercel_default
|
|
5
|
-
} from "../../chunk-
|
|
6
|
-
import "../../chunk-YQMPVJ2L.js";
|
|
5
|
+
} from "../../chunk-UBX7QYBD.js";
|
|
7
6
|
import "../../chunk-WM77HRKO.js";
|
|
7
|
+
import "../../chunk-YQMPVJ2L.js";
|
|
8
8
|
import "../../chunk-4VWJFZVS.js";
|
|
9
9
|
import "../../chunk-PZ5AY32C.js";
|
|
10
10
|
export {
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
execute,
|
|
5
5
|
formatResult,
|
|
6
6
|
getSystemPrompt
|
|
7
|
-
} from "../../chunk-
|
|
8
|
-
import "../../chunk-63WE2C5R.js";
|
|
7
|
+
} from "../../chunk-3FTAIJBH.js";
|
|
9
8
|
import "../../chunk-64PMM72R.js";
|
|
9
|
+
import "../../chunk-63WE2C5R.js";
|
|
10
10
|
import "../../chunk-4VWJFZVS.js";
|
|
11
11
|
import "../../chunk-PZ5AY32C.js";
|
|
12
12
|
export {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import "../../chunk-X2K57BH6.js";
|
|
2
2
|
import {
|
|
3
3
|
anthropic_exports
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-3FTAIJBH.js";
|
|
5
5
|
import {
|
|
6
6
|
openai_exports
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-G4AWE5A2.js";
|
|
8
8
|
import {
|
|
9
9
|
vercel_exports
|
|
10
|
-
} from "../../chunk-
|
|
11
|
-
import {
|
|
12
|
-
EDIT_FILE_SYSTEM_PROMPT,
|
|
13
|
-
EDIT_FILE_TOOL_DESCRIPTION
|
|
14
|
-
} from "../../chunk-63WE2C5R.js";
|
|
10
|
+
} from "../../chunk-UIZT3KVJ.js";
|
|
15
11
|
import {
|
|
16
12
|
countChanges,
|
|
17
13
|
executeEditFile,
|
|
18
14
|
generateUdiff
|
|
19
15
|
} from "../../chunk-64PMM72R.js";
|
|
16
|
+
import {
|
|
17
|
+
EDIT_FILE_SYSTEM_PROMPT,
|
|
18
|
+
EDIT_FILE_TOOL_DESCRIPTION
|
|
19
|
+
} from "../../chunk-63WE2C5R.js";
|
|
20
20
|
import "../../chunk-4VWJFZVS.js";
|
|
21
21
|
import "../../chunk-PZ5AY32C.js";
|
|
22
22
|
export {
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
formatResult,
|
|
6
6
|
getSystemPrompt,
|
|
7
7
|
openai_default
|
|
8
|
-
} from "../../chunk-
|
|
9
|
-
import "../../chunk-63WE2C5R.js";
|
|
8
|
+
} from "../../chunk-G4AWE5A2.js";
|
|
10
9
|
import "../../chunk-64PMM72R.js";
|
|
10
|
+
import "../../chunk-63WE2C5R.js";
|
|
11
11
|
import "../../chunk-4VWJFZVS.js";
|
|
12
12
|
import "../../chunk-PZ5AY32C.js";
|
|
13
13
|
export {
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
editFileTool,
|
|
4
4
|
getSystemPrompt,
|
|
5
5
|
vercel_default
|
|
6
|
-
} from "../../chunk-
|
|
7
|
-
import "../../chunk-63WE2C5R.js";
|
|
6
|
+
} from "../../chunk-UIZT3KVJ.js";
|
|
8
7
|
import "../../chunk-64PMM72R.js";
|
|
8
|
+
import "../../chunk-63WE2C5R.js";
|
|
9
9
|
import "../../chunk-4VWJFZVS.js";
|
|
10
10
|
import "../../chunk-PZ5AY32C.js";
|
|
11
11
|
export {
|
package/dist/tools/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import "../chunk-X2K57BH6.js";
|
|
2
2
|
import {
|
|
3
3
|
anthropic_exports
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-3FTAIJBH.js";
|
|
5
5
|
import {
|
|
6
6
|
openai_exports
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-G4AWE5A2.js";
|
|
8
8
|
import {
|
|
9
9
|
vercel_exports
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import {
|
|
12
|
-
EDIT_FILE_SYSTEM_PROMPT,
|
|
13
|
-
EDIT_FILE_TOOL_DESCRIPTION
|
|
14
|
-
} from "../chunk-63WE2C5R.js";
|
|
10
|
+
} from "../chunk-UIZT3KVJ.js";
|
|
15
11
|
import {
|
|
16
12
|
countChanges,
|
|
17
13
|
executeEditFile,
|
|
18
14
|
generateUdiff
|
|
19
15
|
} from "../chunk-64PMM72R.js";
|
|
16
|
+
import {
|
|
17
|
+
EDIT_FILE_SYSTEM_PROMPT,
|
|
18
|
+
EDIT_FILE_TOOL_DESCRIPTION
|
|
19
|
+
} from "../chunk-63WE2C5R.js";
|
|
20
20
|
import "../chunk-4VWJFZVS.js";
|
|
21
21
|
import "../chunk-PZ5AY32C.js";
|
|
22
22
|
export {
|
|
@@ -30,7 +30,86 @@ var AGENT_CONFIG = {
|
|
|
30
30
|
MAX_ROUNDS: 10,
|
|
31
31
|
TIMEOUT_MS: 3e4
|
|
32
32
|
};
|
|
33
|
-
var
|
|
33
|
+
var BUILTIN_EXCLUDES = [
|
|
34
|
+
// Version control
|
|
35
|
+
".git",
|
|
36
|
+
".svn",
|
|
37
|
+
".hg",
|
|
38
|
+
".bzr",
|
|
39
|
+
// Dependencies
|
|
40
|
+
"node_modules",
|
|
41
|
+
"bower_components",
|
|
42
|
+
".pnpm",
|
|
43
|
+
".yarn",
|
|
44
|
+
"vendor",
|
|
45
|
+
"packages",
|
|
46
|
+
"Pods",
|
|
47
|
+
".bundle",
|
|
48
|
+
// Python
|
|
49
|
+
"__pycache__",
|
|
50
|
+
".pytest_cache",
|
|
51
|
+
".mypy_cache",
|
|
52
|
+
".ruff_cache",
|
|
53
|
+
".venv",
|
|
54
|
+
"venv",
|
|
55
|
+
".tox",
|
|
56
|
+
".nox",
|
|
57
|
+
".eggs",
|
|
58
|
+
"*.egg-info",
|
|
59
|
+
// Build outputs
|
|
60
|
+
"dist",
|
|
61
|
+
"build",
|
|
62
|
+
"out",
|
|
63
|
+
"output",
|
|
64
|
+
"target",
|
|
65
|
+
"_build",
|
|
66
|
+
".next",
|
|
67
|
+
".nuxt",
|
|
68
|
+
".output",
|
|
69
|
+
".vercel",
|
|
70
|
+
".netlify",
|
|
71
|
+
// Cache directories
|
|
72
|
+
".cache",
|
|
73
|
+
".parcel-cache",
|
|
74
|
+
".turbo",
|
|
75
|
+
".nx",
|
|
76
|
+
".gradle",
|
|
77
|
+
// IDE/Editor
|
|
78
|
+
".idea",
|
|
79
|
+
".vscode",
|
|
80
|
+
".vs",
|
|
81
|
+
// Coverage
|
|
82
|
+
"coverage",
|
|
83
|
+
".coverage",
|
|
84
|
+
"htmlcov",
|
|
85
|
+
".nyc_output",
|
|
86
|
+
// Temporary
|
|
87
|
+
"tmp",
|
|
88
|
+
"temp",
|
|
89
|
+
".tmp",
|
|
90
|
+
".temp",
|
|
91
|
+
// Lock files
|
|
92
|
+
"package-lock.json",
|
|
93
|
+
"yarn.lock",
|
|
94
|
+
"pnpm-lock.yaml",
|
|
95
|
+
"bun.lockb",
|
|
96
|
+
"Cargo.lock",
|
|
97
|
+
"Gemfile.lock",
|
|
98
|
+
"poetry.lock",
|
|
99
|
+
// Binary/minified
|
|
100
|
+
"*.min.js",
|
|
101
|
+
"*.min.css",
|
|
102
|
+
"*.bundle.js",
|
|
103
|
+
"*.wasm",
|
|
104
|
+
"*.so",
|
|
105
|
+
"*.dll",
|
|
106
|
+
"*.pyc",
|
|
107
|
+
"*.map",
|
|
108
|
+
"*.js.map",
|
|
109
|
+
// Hidden directories catch-all
|
|
110
|
+
".*"
|
|
111
|
+
];
|
|
112
|
+
var DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || "").split(",").map((s) => s.trim()).filter(Boolean).concat(BUILTIN_EXCLUDES);
|
|
34
113
|
var DEFAULT_MODEL = "morph-warp-grep";
|
|
35
114
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
115
|
0 && (module.exports = {
|
|
@@ -1 +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\
|
|
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\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(s => s.trim())\n .filter(Boolean)\n .concat(BUILTIN_EX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OAAO,gBAAgB;AAEnB,IAAM,gBAAgB;","names":[]}
|
|
@@ -30,13 +30,54 @@ var LLMResponseParseError = class extends Error {
|
|
|
30
30
|
this.name = "LLMResponseParseError";
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
+
var VALID_COMMANDS = ["analyse", "grep", "read", "finish"];
|
|
34
|
+
function preprocessText(text) {
|
|
35
|
+
let processed = text.replace(/<think>[\s\S]*?<\/think>/gi, "");
|
|
36
|
+
const openingTagRegex = /<tool_call>|<tool>/gi;
|
|
37
|
+
const closingTagRegex = /<\/tool_call>|<\/tool>/gi;
|
|
38
|
+
const openingMatches = processed.match(openingTagRegex) || [];
|
|
39
|
+
const closingMatches = processed.match(closingTagRegex) || [];
|
|
40
|
+
if (openingMatches.length > closingMatches.length) {
|
|
41
|
+
const lastClosingMatch = /<\/tool_call>|<\/tool>/gi;
|
|
42
|
+
let lastClosingIndex = -1;
|
|
43
|
+
let match;
|
|
44
|
+
while ((match = lastClosingMatch.exec(processed)) !== null) {
|
|
45
|
+
lastClosingIndex = match.index + match[0].length;
|
|
46
|
+
}
|
|
47
|
+
if (lastClosingIndex > 0) {
|
|
48
|
+
processed = processed.slice(0, lastClosingIndex);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const toolCallLines = [];
|
|
52
|
+
const toolTagRegex = /<tool_call>([\s\S]*?)<\/tool_call>|<tool>([\s\S]*?)<\/tool>/gi;
|
|
53
|
+
let tagMatch;
|
|
54
|
+
while ((tagMatch = toolTagRegex.exec(processed)) !== null) {
|
|
55
|
+
const content = (tagMatch[1] || tagMatch[2] || "").trim();
|
|
56
|
+
if (content) {
|
|
57
|
+
const lines = content.split(/\r?\n/).map((l) => l.trim()).filter((l) => l);
|
|
58
|
+
toolCallLines.push(...lines);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const allLines = processed.split(/\r?\n/).map((l) => l.trim());
|
|
62
|
+
for (const line of allLines) {
|
|
63
|
+
if (!line) continue;
|
|
64
|
+
if (line.startsWith("<")) continue;
|
|
65
|
+
const firstWord = line.split(/\s/)[0];
|
|
66
|
+
if (VALID_COMMANDS.includes(firstWord)) {
|
|
67
|
+
if (!toolCallLines.includes(line)) {
|
|
68
|
+
toolCallLines.push(line);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return toolCallLines;
|
|
73
|
+
}
|
|
33
74
|
var LLMResponseParser = class {
|
|
34
75
|
finishSpecSplitRe = /,(?=[^,\s]+:)/;
|
|
35
76
|
parse(text) {
|
|
36
77
|
if (typeof text !== "string") {
|
|
37
78
|
throw new TypeError("Command text must be a string.");
|
|
38
79
|
}
|
|
39
|
-
const lines = text
|
|
80
|
+
const lines = preprocessText(text);
|
|
40
81
|
const commands = [];
|
|
41
82
|
let finishAccumulator = null;
|
|
42
83
|
lines.forEach((line, idx) => {
|
|
@@ -59,7 +100,7 @@ var LLMResponseParser = class {
|
|
|
59
100
|
finishAccumulator = this.handleFinish(parts, ctx, finishAccumulator);
|
|
60
101
|
break;
|
|
61
102
|
default:
|
|
62
|
-
|
|
103
|
+
break;
|
|
63
104
|
}
|
|
64
105
|
});
|
|
65
106
|
if (finishAccumulator) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../tools/warp_grep/agent/parser.ts"],"sourcesContent":["// Parses assistant lines into structured tool calls\nimport type { ToolCall } from './types.js';\n\nexport class LLMResponseParseError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'LLMResponseParseError';\n }\n}\n\ntype LineContext = { lineNumber: number; raw: string };\n\nexport class LLMResponseParser {\n private readonly finishSpecSplitRe = /,(?=[^,\\s]+:)/;\n\n parse(text: string): ToolCall[] {\n if (typeof text !== 'string') {\n throw new TypeError('Command text must be a string.');\n }\n const lines = text.split(/\\r?\\n/).map(l => l.trim());\n const commands: ToolCall[] = [];\n let finishAccumulator: Map<string, number[][]> | null = null;\n\n lines.forEach((line, idx) => {\n if (!line || line.startsWith('#')) return;\n const ctx: LineContext = { lineNumber: idx + 1, raw: line };\n const parts = this.splitLine(line, ctx);\n if (parts.length === 0) return;\n const cmd = parts[0];\n switch (cmd) {\n case 'analyse':\n this.handleAnalyse(parts, ctx, commands);\n break;\n case 'grep':\n this.handleGrep(parts, ctx, commands);\n break;\n case 'read':\n this.handleRead(parts, ctx, commands);\n break;\n case 'finish':\n finishAccumulator = this.handleFinish(parts, ctx, finishAccumulator);\n break;\n default:\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: Unsupported command '${cmd}'`);\n }\n });\n\n if (finishAccumulator) {\n const map = finishAccumulator as Map<string, number[][]>;\n const entries = [...map.entries()];\n const filesPayload = entries.map(([path, ranges]) => ({\n path,\n lines: [...ranges].sort((a, b) => a[0] - b[0]) as Array<[number, number]>,\n }));\n commands.push({ name: 'finish', arguments: { files: filesPayload } });\n }\n return commands;\n }\n\n private splitLine(line: string, ctx: LineContext): string[] {\n try {\n // Split by whitespace but keep quoted blocks as one\n const parts: string[] = [];\n let current = '';\n let inSingle = false;\n for (let i = 0; i < line.length; i++) {\n const ch = line[i];\n if (ch === \"'\" && line[i - 1] !== '\\\\') {\n inSingle = !inSingle;\n current += ch;\n } else if (!inSingle && /\\s/.test(ch)) {\n if (current) {\n parts.push(current);\n current = '';\n }\n } else {\n current += ch;\n }\n }\n if (current) parts.push(current);\n return parts;\n } catch {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: Unable to parse line.`);\n }\n }\n\n private handleAnalyse(parts: string[], ctx: LineContext, commands: ToolCall[]) {\n // analyse <path> [pattern]\n if (parts.length < 2) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: analyse requires <path>`);\n }\n const path = parts[1];\n const pattern = parts[2]?.replace(/^\"|\"$/g, '') ?? null;\n commands.push({ name: 'analyse', arguments: { path, pattern } });\n }\n\n // no glob tool in MCP\n\n private handleGrep(parts: string[], ctx: LineContext, commands: ToolCall[]) {\n // grep '<pattern>' <path>\n if (parts.length < 3) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: grep requires '<pattern>' and <path>`);\n }\n const pat = parts[1];\n if (!pat.startsWith(\"'\") || !pat.endsWith(\"'\")) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: grep pattern must be single-quoted`);\n }\n commands.push({ name: 'grep', arguments: { pattern: pat.slice(1, -1), path: parts[2] } });\n }\n\n private handleRead(parts: string[], ctx: LineContext, commands: ToolCall[]) {\n // read <path>[:start-end]\n if (parts.length < 2) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: read requires <path> or <path>:<start-end>`);\n }\n const spec = parts[1];\n const rangeIdx = spec.indexOf(':');\n if (rangeIdx === -1) {\n commands.push({ name: 'read', arguments: { path: spec } });\n return;\n }\n const path = spec.slice(0, rangeIdx);\n const range = spec.slice(rangeIdx + 1);\n const [s, e] = range.split('-').map(v => parseInt(v, 10));\n if (!Number.isFinite(s) || !Number.isFinite(e)) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: invalid read range '${range}'`);\n }\n commands.push({ name: 'read', arguments: { path, start: s, end: e } });\n }\n\n private handleFinish(parts: string[], ctx: LineContext, acc: Map<string, number[][]> | null) {\n // finish file1:1-10,20-30 file2:5-7\n const map = acc ?? new Map<string, number[][]>();\n const args = parts.slice(1);\n for (const token of args) {\n const [path, rangesText] = token.split(':', 2);\n if (!path || !rangesText) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: invalid finish token '${token}'`);\n }\n const rangeSpecs = rangesText.split(',').filter(Boolean);\n for (const spec of rangeSpecs) {\n const [s, e] = spec.split('-').map(v => parseInt(v, 10));\n if (!Number.isFinite(s) || !Number.isFinite(e) || e < s) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: invalid range '${spec}'`);\n }\n const arr = map.get(path) ?? [];\n arr.push([s, e]);\n map.set(path, arr);\n }\n }\n return map;\n }\n}\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAG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,CAAC,QAAQ,CAAC,YAAY;AACxB,cAAM,IAAI,sBAAsB,QAAQ,IAAI,UAAU,2BAA2B,KAAK,GAAG;AAAA,MAC3F;AACA,YAAM,aAAa,WAAW,MAAM,GAAG,EAAE,OAAO,OAAO;AACvD,iBAAW,QAAQ,YAAY;AAC7B,cAAM,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI,OAAK,SAAS,GAAG,EAAE,CAAC;AACvD,YAAI,CAAC,OAAO,SAAS,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,KAAK,IAAI,GAAG;AACvD,gBAAM,IAAI,sBAAsB,QAAQ,IAAI,UAAU,oBAAoB,IAAI,GAAG;AAAA,QACnF;AACA,cAAM,MAAM,IAAI,IAAI,IAAI,KAAK,CAAC;AAC9B,YAAI,KAAK,CAAC,GAAG,CAAC,CAAC;AACf,YAAI,IAAI,MAAM,GAAG;AAAA,MACnB;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../tools/warp_grep/agent/parser.ts"],"sourcesContent":["// Parses assistant lines into structured tool calls\nimport type { ToolCall } from './types.js';\n\nexport class LLMResponseParseError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'LLMResponseParseError';\n }\n}\n\ntype LineContext = { lineNumber: number; raw: string };\n\n// Valid tool command names\nconst VALID_COMMANDS = ['analyse', 'grep', 'read', 'finish'];\n\n/**\n * Preprocesses text to handle XML tags:\n * 1. Removes <think>...</think> blocks entirely\n * 2. Extracts content from <tool>...</tool> or <tool_call>...</tool_call> tags\n * 3. Passes through raw tool calls (lines starting with valid commands)\n * 4. Discards unclosed <tool...> tags\n */\nfunction preprocessText(text: string): string[] {\n // Step 1: Remove <think>...</think> blocks (including multiline)\n let processed = text.replace(/<think>[\\s\\S]*?<\\/think>/gi, '');\n \n // Step 2: Check for unclosed <tool or <tool_call tags and discard them\n // Find all opening tags and their positions\n const openingTagRegex = /<tool_call>|<tool>/gi;\n const closingTagRegex = /<\\/tool_call>|<\\/tool>/gi;\n \n // Count opening and closing tags\n const openingMatches = processed.match(openingTagRegex) || [];\n const closingMatches = processed.match(closingTagRegex) || [];\n \n // If there are more opening than closing tags, we have unclosed tags\n // In that case, only process complete tag pairs\n if (openingMatches.length > closingMatches.length) {\n // Remove any content after the last complete closing tag\n const lastClosingMatch = /<\\/tool_call>|<\\/tool>/gi;\n let lastClosingIndex = -1;\n let match;\n while ((match = lastClosingMatch.exec(processed)) !== null) {\n lastClosingIndex = match.index + match[0].length;\n }\n if (lastClosingIndex > 0) {\n processed = processed.slice(0, lastClosingIndex);\n }\n }\n \n // Step 3: Extract content from <tool_call>...</tool_call> and <tool>...</tool> tags\n const toolCallLines: string[] = [];\n const toolTagRegex = /<tool_call>([\\s\\S]*?)<\\/tool_call>|<tool>([\\s\\S]*?)<\\/tool>/gi;\n let tagMatch;\n \n while ((tagMatch = toolTagRegex.exec(processed)) !== null) {\n const content = (tagMatch[1] || tagMatch[2] || '').trim();\n if (content) {\n // Split content by newlines in case there are multiple tool calls in one tag\n const lines = content.split(/\\r?\\n/).map(l => l.trim()).filter(l => l);\n toolCallLines.push(...lines);\n }\n }\n \n // Step 4: Also extract raw tool calls (lines starting with valid commands)\n // This provides backwards compatibility\n const allLines = processed.split(/\\r?\\n/).map(l => l.trim());\n for (const line of allLines) {\n if (!line) continue;\n \n // Skip lines that are inside XML tags (already processed above)\n if (line.startsWith('<')) continue;\n \n // Check if line starts with a valid command\n const firstWord = line.split(/\\s/)[0];\n if (VALID_COMMANDS.includes(firstWord)) {\n // Avoid duplicates\n if (!toolCallLines.includes(line)) {\n toolCallLines.push(line);\n }\n }\n }\n \n return toolCallLines;\n}\n\nexport class LLMResponseParser {\n private readonly finishSpecSplitRe = /,(?=[^,\\s]+:)/;\n\n parse(text: string): ToolCall[] {\n if (typeof text !== 'string') {\n throw new TypeError('Command text must be a string.');\n }\n \n // Preprocess to handle XML tags\n const lines = preprocessText(text);\n \n const commands: ToolCall[] = [];\n let finishAccumulator: Map<string, number[][]> | null = null;\n\n lines.forEach((line, idx) => {\n if (!line || line.startsWith('#')) return;\n const ctx: LineContext = { lineNumber: idx + 1, raw: line };\n const parts = this.splitLine(line, ctx);\n if (parts.length === 0) return;\n const cmd = parts[0];\n switch (cmd) {\n case 'analyse':\n this.handleAnalyse(parts, ctx, commands);\n break;\n case 'grep':\n this.handleGrep(parts, ctx, commands);\n break;\n case 'read':\n this.handleRead(parts, ctx, commands);\n break;\n case 'finish':\n finishAccumulator = this.handleFinish(parts, ctx, finishAccumulator);\n break;\n default:\n // Silently ignore unknown commands after preprocessing\n // (they might be remnants of XML or other content)\n break;\n }\n });\n\n if (finishAccumulator) {\n const map = finishAccumulator as Map<string, number[][]>;\n const entries = [...map.entries()];\n const filesPayload = entries.map(([path, ranges]) => ({\n path,\n lines: [...ranges].sort((a, b) => a[0] - b[0]) as Array<[number, number]>,\n }));\n commands.push({ name: 'finish', arguments: { files: filesPayload } });\n }\n return commands;\n }\n\n private splitLine(line: string, ctx: LineContext): string[] {\n try {\n // Split by whitespace but keep quoted blocks as one\n const parts: string[] = [];\n let current = '';\n let inSingle = false;\n for (let i = 0; i < line.length; i++) {\n const ch = line[i];\n if (ch === \"'\" && line[i - 1] !== '\\\\') {\n inSingle = !inSingle;\n current += ch;\n } else if (!inSingle && /\\s/.test(ch)) {\n if (current) {\n parts.push(current);\n current = '';\n }\n } else {\n current += ch;\n }\n }\n if (current) parts.push(current);\n return parts;\n } catch {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: Unable to parse line.`);\n }\n }\n\n private handleAnalyse(parts: string[], ctx: LineContext, commands: ToolCall[]) {\n // analyse <path> [pattern]\n if (parts.length < 2) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: analyse requires <path>`);\n }\n const path = parts[1];\n const pattern = parts[2]?.replace(/^\"|\"$/g, '') ?? null;\n commands.push({ name: 'analyse', arguments: { path, pattern } });\n }\n\n // no glob tool in MCP\n\n private handleGrep(parts: string[], ctx: LineContext, commands: ToolCall[]) {\n // grep '<pattern>' <path>\n if (parts.length < 3) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: grep requires '<pattern>' and <path>`);\n }\n const pat = parts[1];\n if (!pat.startsWith(\"'\") || !pat.endsWith(\"'\")) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: grep pattern must be single-quoted`);\n }\n commands.push({ name: 'grep', arguments: { pattern: pat.slice(1, -1), path: parts[2] } });\n }\n\n private handleRead(parts: string[], ctx: LineContext, commands: ToolCall[]) {\n // read <path>[:start-end]\n if (parts.length < 2) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: read requires <path> or <path>:<start-end>`);\n }\n const spec = parts[1];\n const rangeIdx = spec.indexOf(':');\n if (rangeIdx === -1) {\n commands.push({ name: 'read', arguments: { path: spec } });\n return;\n }\n const path = spec.slice(0, rangeIdx);\n const range = spec.slice(rangeIdx + 1);\n const [s, e] = range.split('-').map(v => parseInt(v, 10));\n if (!Number.isFinite(s) || !Number.isFinite(e)) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: invalid read range '${range}'`);\n }\n commands.push({ name: 'read', arguments: { path, start: s, end: e } });\n }\n\n private handleFinish(parts: string[], ctx: LineContext, acc: Map<string, number[][]> | null) {\n // finish file1:1-10,20-30 file2:5-7\n const map = acc ?? new Map<string, number[][]>();\n const args = parts.slice(1);\n for (const token of args) {\n const [path, rangesText] = token.split(':', 2);\n if (!path || !rangesText) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: invalid finish token '${token}'`);\n }\n const rangeSpecs = rangesText.split(',').filter(Boolean);\n for (const spec of rangeSpecs) {\n const [s, e] = spec.split('-').map(v => parseInt(v, 10));\n if (!Number.isFinite(s) || !Number.isFinite(e) || e < s) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: invalid range '${spec}'`);\n }\n const arr = map.get(path) ?? [];\n arr.push([s, e]);\n map.set(path, arr);\n }\n }\n return map;\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