@morphllm/morphsdk 0.2.96 → 0.2.97

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.
Files changed (2) hide show
  1. package/README.md +84 -147
  2. package/package.json +3 -8
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Morph SDK
2
2
 
3
- Production-ready tools for AI coding agents: Repo Storage with automatic code indexing, semantic search, and Fast Apply (10,500 tokens/s).
3
+ Production-ready tools for AI coding agents: WarpGrep (intelligent code search), Fast Apply (10,500 tokens/s), and Repo Storage.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@morphllm/morphsdk.svg)](https://www.npmjs.com/package/@morphllm/morphsdk)
6
6
 
@@ -18,209 +18,146 @@ export MORPH_API_KEY="sk-your-key-here"
18
18
 
19
19
  ## Features
20
20
 
21
- - **🔍 Semantic Search** - State of the Art Code Search (AST aware chunking, morph-v4-embedding + morph-v4-rerank)
22
- - **📦 Repo Storage** - Agent native git with automatic code indexing, agent metadata, and chat history
21
+ - **🔍 WarpGrep** - Intelligent code search agent that explores your codebase with parallel grep/read operations
23
22
  - **⚡ Fast Apply** - 98% 1st pass accuracy, AI-powered code editing at 10,500 tokens/s
24
- - **🤖 Agent Tools** - Ready-to-use tools for Anthropic, OpenAI, and Vercel AI SDK
23
+ - **📦 Repo Storage** - Agent native git with automatic code indexing and agent metadata
24
+ - **🤖 Agent Tools** - Ready-to-use tools for Anthropic, OpenAI, Gemini, and Vercel AI SDK
25
25
 
26
26
  ## Quick Start
27
27
 
28
- ### Repo Storage + Semantic Search
28
+ ### WarpGrep - Intelligent Code Search
29
29
 
30
- ```typescript
31
- import { MorphClient } from '@morphllm/morphsdk';
30
+ WarpGrep is a search subagent that explores your codebase using parallel grep and file read operations. It understands natural language queries and returns relevant code with line numbers.
32
31
 
33
- const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
32
+ ```typescript
33
+ import { WarpGrepClient } from '@morphllm/morphsdk/tools/warp-grep';
34
34
 
35
- // Initialize repo
36
- await morph.git.init({ repoId: 'my-project', dir: './my-project' });
35
+ const client = new WarpGrepClient({ morphApiKey: process.env.MORPH_API_KEY });
37
36
 
38
- // Commit with agent metadata
39
- await morph.git.add({ dir: './my-project', filepath: '.' });
40
- await morph.git.commit({
41
- dir: './my-project',
42
- message: 'Add authentication'
37
+ const result = await client.execute({
38
+ query: 'Find where authentication requests are handled',
39
+ repoRoot: './my-project'
43
40
  });
44
41
 
45
- // Push (triggers automatic code embedding, 3-8s)
46
- await morph.git.push({ dir: './my-project' });
47
-
48
- // Search your code with natural language
49
- const results = await morph.codebaseSearch.search({
50
- query: "Where is the OAuth login implemented?",
51
- repoId: 'my-project',
52
- targetDirectories: [] // or ['src/auth'] to narrow search
42
+ // Returns relevant files with specific line ranges
43
+ result.files.forEach(file => {
44
+ console.log(`${file.path}: lines ${file.lines}`);
53
45
  });
54
-
55
- console.log(results.results[0].content);
56
46
  ```
57
47
 
58
- ### Fast Apply
48
+ ### As Agent Tool
59
49
 
60
50
  ```typescript
61
- import { MorphClient } from '@morphllm/morphsdk';
51
+ import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';
52
+ import Anthropic from '@anthropic-ai/sdk';
62
53
 
63
- const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
54
+ const client = new Anthropic();
55
+ const tool = createWarpGrepTool({ repoRoot: './my-project' });
64
56
 
65
- // AI-powered file editing
66
- await morph.fastApply.execute({
67
- target_filepath: 'src/app.ts',
68
- instructions: 'Add error handling',
69
- code_edit: 'try { ... } catch (e) { ... }'
57
+ const response = await client.messages.create({
58
+ model: "claude-sonnet-4-5-20250929",
59
+ tools: [tool],
60
+ messages: [{ role: "user", content: "Find the error handling logic" }]
70
61
  });
71
62
  ```
72
63
 
73
- ## Repo Storage
74
-
75
- Git built for AI agents with automatic code indexing and semantic search.
64
+ ### Remote Sandbox Support
76
65
 
77
- ### Git Operations
66
+ WarpGrep works in remote sandboxes (E2B, Modal, Daytona) by providing custom command implementations:
78
67
 
79
68
  ```typescript
80
- // Initialize
81
- await morph.git.init({ repoId: 'my-project', dir: './my-project' });
82
-
83
- // Clone
84
- await morph.git.clone({ repoId: 'my-project', dir: './local-copy' });
85
-
86
- // Stage and commit
87
- await morph.git.add({ dir: './my-project', filepath: '.' });
88
- await morph.git.commit({
89
- dir: './my-project',
90
- message: 'Add feature'
69
+ import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';
70
+
71
+ const tool = createWarpGrepTool({
72
+ repoRoot: '/home/repo',
73
+ remoteCommands: {
74
+ grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,
75
+ read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,
76
+ listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,
77
+ },
91
78
  });
92
-
93
- // Push (triggers code embedding in background)
94
- await morph.git.push({ dir: './my-project' });
95
-
96
- // Status and history
97
- const files = await morph.git.statusMatrix({ dir: './my-project' });
98
- const commits = await morph.git.log({ dir: './my-project', depth: 10 });
99
-
100
- // Branch operations
101
- await morph.git.branch({ dir: './my-project', name: 'feature' });
102
- const branches = await morph.git.listBranches({ dir: './my-project' });
103
- await morph.git.checkout({ dir: './my-project', ref: 'main' });
104
79
  ```
105
80
 
106
- ### Agent Metadata
107
-
108
- Store chat history and browser recordings with commits:
109
-
110
- ```typescript
111
- // Commit with metadata
112
- const sha = await morph.git.commit({
113
- dir: './my-project',
114
- message: 'Implement user auth',
115
- chatHistory: [
116
- { role: 'user', content: 'Add OAuth' },
117
- { role: 'assistant', content: 'Adding Google OAuth' }
118
- ],
119
- recordingId: 'rec_abc123'
120
- });
121
-
122
- // Retrieve metadata later
123
- const metadata = await morph.git.getCommitMetadata({
124
- dir: './my-project',
125
- commitSha: sha
126
- });
127
-
128
- console.log(metadata?.chatHistory);
129
- console.log(metadata?.recordingId);
130
- ```
131
-
132
- ### State of the Art Code Semantic Search
81
+ ## Fast Apply
133
82
 
134
- When you push, Morph automatically embeds your code for semantic search. Each commit is indexed separately:
83
+ AI-powered code editing at 10,500 tokens/s with 98% first-pass accuracy.
135
84
 
136
85
  ```typescript
137
- // Search latest code on 'main'
138
- await morph.codebaseSearch.search({
139
- query: "auth logic",
140
- repoId: 'my-project'
141
- });
86
+ import { MorphClient } from '@morphllm/morphsdk';
142
87
 
143
- // Advanced: Search specific branch
144
- await morph.codebaseSearch.search({
145
- query: "auth logic",
146
- repoId: 'my-project',
147
- branch: 'develop'
148
- });
88
+ const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
149
89
 
150
- // Advanced: Search exact commit
151
- await morph.codebaseSearch.search({
152
- query: "auth logic",
153
- repoId: 'my-project',
154
- commitHash: 'abc123...'
90
+ await morph.fastApply.execute({
91
+ target_filepath: 'src/app.ts',
92
+ instructions: 'Add error handling to the API call',
93
+ code_edit: `
94
+ // ... existing code ...
95
+ try {
96
+ const response = await fetch(url);
97
+ // ... existing code ...
98
+ } catch (e) {
99
+ console.error('API call failed:', e);
100
+ throw e;
101
+ }
102
+ `
155
103
  });
156
104
  ```
157
105
 
158
- ## Semantic Search
106
+ See [tools/fastapply/README.md](./tools/fastapply/README.md) for details.
159
107
 
160
- Two-stage retrieval: embedding similarity (morph-v4-embedding) + reranking (morph-v4-rerank).
108
+ ## Repo Storage
161
109
 
162
- ### As Agent Tool
110
+ Git built for AI agents with automatic code indexing.
163
111
 
164
112
  ```typescript
165
- import { createCodebaseSearchTool } from '@morphllm/morphsdk/tools/anthropic';
166
- import Anthropic from '@anthropic-ai/sdk';
167
-
168
- const client = new Anthropic();
169
- const tool = createCodebaseSearchTool({ repoId: 'my-project' });
170
-
171
- const response = await client.messages.create({
172
- model: "claude-sonnet-4-5-20250929",
173
- tools: [tool],
174
- messages: [{ role: "user", content: "Find authentication code" }]
175
- });
176
- ```
113
+ import { MorphClient } from '@morphllm/morphsdk';
177
114
 
178
- ### Direct Search
115
+ const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
179
116
 
180
- ```typescript
181
- const results = await morph.codebaseSearch.search({
182
- query: "How does authentication work?",
183
- repoId: 'my-project',
184
- targetDirectories: ["src/auth"], // or [] for all
185
- limit: 10
186
- });
117
+ // Initialize repo
118
+ await morph.git.init({ repoId: 'my-project', dir: './my-project' });
187
119
 
188
- results.results.forEach(r => {
189
- console.log(`${r.filepath} (${(r.rerankScore * 100).toFixed(1)}% relevant)`);
190
- console.log(r.content);
120
+ // Stage and commit with agent metadata
121
+ await morph.git.add({ dir: './my-project', filepath: '.' });
122
+ await morph.git.commit({
123
+ dir: './my-project',
124
+ message: 'Add authentication',
125
+ chatHistory: [
126
+ { role: 'user', content: 'Add OAuth login' },
127
+ { role: 'assistant', content: 'Adding Google OAuth...' }
128
+ ]
191
129
  });
192
- ```
193
-
194
- ### How It Works
195
130
 
196
- 1. **Embedding Search**: Query embedded with morph-v4-embedding, vector search retrieves top 50 candidates (~50ms)
197
- 2. **Reranking**: Candidates scored with morph-v4-rerank for precision (~150ms)
198
- 3. **Results**: Top 10 most relevant code chunks (~1230ms total)
199
-
200
- ## Fast Apply
131
+ // Push
132
+ await morph.git.push({ dir: './my-project' });
201
133
 
202
- AI-powered code editing at 10,500 tokens/s. See [tools/fastapply/README.md](./tools/fastapply/README.md) for details.
134
+ // Clone, branch, checkout
135
+ await morph.git.clone({ repoId: 'my-project', dir: './local-copy' });
136
+ await morph.git.branch({ dir: './my-project', name: 'feature' });
137
+ await morph.git.checkout({ dir: './my-project', ref: 'main' });
138
+ ```
203
139
 
204
140
  ## Agent Tools
205
141
 
206
142
  Ready-to-use tools for popular AI frameworks:
207
143
 
208
- - **Anthropic SDK** - `@morphllm/morphsdk/tools/anthropic`
209
- - **OpenAI SDK** - `@morphllm/morphsdk/tools/openai`
210
- - **Vercel AI SDK** - `@morphllm/morphsdk/tools/vercel`
144
+ | Framework | Import Path |
145
+ |-----------|-------------|
146
+ | Anthropic SDK | `@morphllm/morphsdk/tools/warp-grep/anthropic` |
147
+ | OpenAI SDK | `@morphllm/morphsdk/tools/warp-grep/openai` |
148
+ | Gemini SDK | `@morphllm/morphsdk/tools/warp-grep/gemini` |
149
+ | Vercel AI SDK | `@morphllm/morphsdk/tools/warp-grep/vercel` |
211
150
 
212
151
  Available tools:
213
- - `createCodebaseSearchTool` - Semantic code search
152
+ - `createWarpGrepTool` - Intelligent code search
214
153
  - `createFastApplyTool` - AI-powered code editing
215
154
  - `createBrowserTool` - Browser automation
216
- - `createWarpGrepTool` - Fast grep with AI parsing
217
155
 
218
156
  ## Documentation
219
157
 
220
158
  Full docs: [docs.morphllm.com](https://docs.morphllm.com)
221
159
 
222
160
  **Key Pages:**
223
- - [Repo Storage](https://docs.morphllm.com/sdk/components/git) - Git operations and agent metadata
224
- - [Semantic Search](https://docs.morphllm.com/sdk/components/semantic-search) - Code search with natural language
161
+ - [WarpGrep](https://docs.morphllm.com/sdk/components/warp-grep) - Intelligent code search
225
162
  - [Fast Apply](https://docs.morphllm.com/sdk/components/fast-apply) - AI-powered code editing
226
-
163
+ - [Repo Storage](https://docs.morphllm.com/sdk/components/git) - Git operations and agent metadata
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morphllm/morphsdk",
3
- "version": "0.2.96",
3
+ "version": "0.2.97",
4
4
  "description": "TypeScript SDK and CLI for Morph Fast Apply integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -160,6 +160,7 @@
160
160
  "ai": "^5.0.0",
161
161
  "diff": "^7.0.0",
162
162
  "isomorphic-git": "^1.25.10",
163
+ "openai": "^4.52.7",
163
164
  "zod": "^3.23.8"
164
165
  },
165
166
  "devDependencies": {
@@ -173,7 +174,6 @@
173
174
  "@typescript-eslint/parser": "^7.18.0",
174
175
  "dotenv": "^16.4.5",
175
176
  "eslint": "^8.57.0",
176
- "openai": "^4.52.7",
177
177
  "shx": "^0.3.4",
178
178
  "tsup": "^8.5.0",
179
179
  "tsx": "^4.16.2",
@@ -183,7 +183,6 @@
183
183
  "peerDependencies": {
184
184
  "@anthropic-ai/sdk": ">=0.25.0",
185
185
  "@google/generative-ai": ">=0.21.0",
186
- "openai": ">=4.0.0",
187
186
  "ai": ">=5.0.0",
188
187
  "zod": ">=3.23.0"
189
188
  },
@@ -194,9 +193,6 @@
194
193
  "@google/generative-ai": {
195
194
  "optional": true
196
195
  },
197
- "openai": {
198
- "optional": true
199
- },
200
196
  "ai": {
201
197
  "optional": true
202
198
  },
@@ -206,6 +202,5 @@
206
202
  },
207
203
  "publishConfig": {
208
204
  "access": "public"
209
- },
210
- "packageManager": "pnpm@10.15.1+sha512.34e538c329b5553014ca8e8f4535997f96180a1d0f614339357449935350d924e22f8614682191264ec33d1462ac21561aff97f6bb18065351c162c7e8f6de67"
205
+ }
211
206
  }