@morphllm/morphsdk 0.2.103 → 0.2.105

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Morph SDK
2
2
 
3
- Production-ready tools for AI coding agents: WarpGrep (intelligent code search), Fast Apply (10,500 tokens/s), and Repo Storage.
3
+ Production-ready tools for AI coding agents: WarpGrep (intelligent code search), Fast Apply (10,500 tokens/s), GitHub integration, and Browser automation.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@morphllm/morphsdk.svg)](https://www.npmjs.com/package/@morphllm/morphsdk)
6
6
 
@@ -20,6 +20,8 @@ export MORPH_API_KEY="sk-your-key-here"
20
20
 
21
21
  - **šŸ” WarpGrep** - Intelligent code search agent that explores your codebase with parallel grep/read operations
22
22
  - **⚔ Fast Apply** - 98% 1st pass accuracy, AI-powered code editing at 10,500 tokens/s
23
+ - **šŸ™ GitHub** - Access PR context, post comments, manage check runs through your connected GitHub account
24
+ - **🌐 Browser** - AI-powered browser automation for testing and interaction
23
25
  - **šŸ“¦ Repo Storage** - Agent native git with automatic code indexing and agent metadata
24
26
  - **šŸ¤– Agent Tools** - Ready-to-use tools for Anthropic, OpenAI, Gemini, and Vercel AI SDK
25
27
 
@@ -78,6 +80,147 @@ const tool = createWarpGrepTool({
78
80
  });
79
81
  ```
80
82
 
83
+ ## GitHub Integration
84
+
85
+ Access your GitHub repositories, pull requests, and deployments through your connected Morph account.
86
+
87
+ ### Setup
88
+
89
+ Connect your GitHub account in the [Morph Dashboard](https://morphllm.com/dashboard/integrations/github), then use the SDK:
90
+
91
+ ```typescript
92
+ import { MorphClient } from '@morphllm/morphsdk';
93
+
94
+ const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
95
+
96
+ // List your GitHub installations
97
+ const installations = await morph.github.installations.list();
98
+ console.log(installations);
99
+ // [{ id: "12345", accountLogin: "acme", accountType: "Organization" }]
100
+ ```
101
+
102
+ ### List Repositories
103
+
104
+ ```typescript
105
+ // List repos for an installation
106
+ const repos = await morph.github.repos.list({
107
+ installationId: "12345"
108
+ });
109
+ // [{ id: 123, name: "app", fullName: "acme/app", private: true }]
110
+ ```
111
+
112
+ ### Get Pull Request Context
113
+
114
+ ```typescript
115
+ // Get PR with full context (title, body, diff, files)
116
+ const pr = await morph.github.pullRequests.get({
117
+ owner: "acme",
118
+ repo: "app",
119
+ number: 42
120
+ });
121
+
122
+ console.log(pr.title); // "Add user authentication"
123
+ console.log(pr.diff); // Full unified diff
124
+ console.log(pr.files); // [{ filename, status, additions, deletions, patch }]
125
+ ```
126
+
127
+ ### Find Preview Deployments
128
+
129
+ ```typescript
130
+ // Get deployments for a PR's head SHA
131
+ const deployments = await morph.github.deployments.list({
132
+ owner: "acme",
133
+ repo: "app",
134
+ sha: pr.headSha
135
+ });
136
+
137
+ const preview = deployments.find(d => d.environment === "preview");
138
+ console.log(preview?.url); // "https://app-pr-42.vercel.app"
139
+ ```
140
+
141
+ ### Post PR Comments
142
+
143
+ ```typescript
144
+ // Post a comment to a PR
145
+ const comment = await morph.github.comments.create({
146
+ owner: "acme",
147
+ repo: "app",
148
+ pr: 42,
149
+ body: "## Test Results\n\nāœ… All tests passed!"
150
+ });
151
+
152
+ // Update the comment
153
+ await morph.github.comments.update({
154
+ owner: "acme",
155
+ repo: "app",
156
+ commentId: comment.id,
157
+ body: "## Test Results\n\nāœ… All tests passed!\n\nUpdated at: " + new Date()
158
+ });
159
+ ```
160
+
161
+ ### Manage Check Runs (CI Status)
162
+
163
+ ```typescript
164
+ // Create a check run
165
+ const checkRun = await morph.github.checkRuns.create({
166
+ owner: "acme",
167
+ repo: "app",
168
+ sha: pr.headSha,
169
+ name: "Preview Test",
170
+ status: "in_progress",
171
+ title: "Testing preview deployment...",
172
+ summary: "Running automated browser tests"
173
+ });
174
+
175
+ // Update with results
176
+ await morph.github.checkRuns.update({
177
+ owner: "acme",
178
+ repo: "app",
179
+ checkRunId: checkRun.id,
180
+ conclusion: "success",
181
+ title: "āœ… Preview test passed",
182
+ summary: "All tests completed successfully"
183
+ });
184
+ ```
185
+
186
+ ### Full Example: PR Preview Testing
187
+
188
+ ```typescript
189
+ import { MorphClient } from '@morphllm/morphsdk';
190
+
191
+ const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
192
+
193
+ async function testPRPreview(owner: string, repo: string, prNumber: number) {
194
+ // 1. Get PR context
195
+ const pr = await morph.github.pullRequests.get({ owner, repo, number: prNumber });
196
+
197
+ // 2. Find preview deployment
198
+ const deployments = await morph.github.deployments.list({ owner, repo, sha: pr.headSha });
199
+ const preview = deployments.find(d => d.state === "success" && d.url);
200
+
201
+ if (!preview) {
202
+ console.log("No preview deployment found");
203
+ return;
204
+ }
205
+
206
+ // 3. Run browser test with PR context
207
+ const task = await morph.browser.createTask({
208
+ url: preview.url,
209
+ diff: pr.diff,
210
+ task: "Test the changes in this PR"
211
+ });
212
+
213
+ // 4. Wait for results
214
+ const recording = await morph.browser.waitForRecording(task.recordingId);
215
+
216
+ // 5. Post results to PR
217
+ await morph.github.comments.create({
218
+ owner, repo, pr: prNumber,
219
+ body: `## šŸ¤– Preview Test Results\n\n${recording.result || "Test completed"}`
220
+ });
221
+ }
222
+ ```
223
+
81
224
  ## Fast Apply
82
225
 
83
226
  AI-powered code editing at 10,500 tokens/s with 98% first-pass accuracy.
@@ -160,4 +303,6 @@ Full docs: [docs.morphllm.com](https://docs.morphllm.com)
160
303
  **Key Pages:**
161
304
  - [WarpGrep](https://docs.morphllm.com/sdk/components/warp-grep) - Intelligent code search
162
305
  - [Fast Apply](https://docs.morphllm.com/sdk/components/fast-apply) - AI-powered code editing
306
+ - [GitHub](https://docs.morphllm.com/sdk/components/github) - GitHub integration for PR context and automation
307
+ - [Browser](https://docs.morphllm.com/sdk/components/browser) - AI-powered browser automation
163
308
  - [Repo Storage](https://docs.morphllm.com/sdk/components/git) - Git operations and agent metadata