@morphllm/morphsdk 0.2.52 → 0.2.54
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-UU6XCZG3.js → chunk-4HOUN5TW.js} +6 -5
- package/dist/chunk-4HOUN5TW.js.map +1 -0
- package/dist/{chunk-G4AWE5A2.js → chunk-5QIWYEHJ.js} +2 -2
- package/dist/{chunk-64PMM72R.js → chunk-CKTA4AXM.js} +58 -2
- package/dist/chunk-CKTA4AXM.js.map +1 -0
- package/dist/{chunk-MZT6HVGD.js → chunk-D5ZSGQT4.js} +5 -3
- package/dist/{chunk-MZT6HVGD.js.map → chunk-D5ZSGQT4.js.map} +1 -1
- package/dist/{chunk-YR53PPVM.js → chunk-FB3E5BRY.js} +6 -5
- package/dist/chunk-FB3E5BRY.js.map +1 -0
- package/dist/{chunk-L5BMGLLQ.js → chunk-IFVROB4L.js} +21 -14
- package/dist/{chunk-L5BMGLLQ.js.map → chunk-IFVROB4L.js.map} +1 -1
- package/dist/{chunk-3FTAIJBH.js → chunk-IUG2FHNN.js} +2 -2
- package/dist/{chunk-PZDR5ZZ2.js → chunk-KVMZPOUT.js} +9 -9
- package/dist/{chunk-FYQUSDOE.js → chunk-PYTBBWL6.js} +3 -3
- package/dist/{chunk-UIZT3KVJ.js → chunk-QZNGKOCZ.js} +2 -2
- package/dist/{client-BGctTHu9.d.ts → client-CFoR--IU.d.ts} +1 -1
- package/dist/client.cjs +67 -4
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +15 -15
- package/dist/{core-DxiUwyBe.d.ts → core-CpkYEi_T.d.ts} +2 -0
- package/dist/index.cjs +71 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.js +19 -17
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +2 -2
- package/dist/tools/fastapply/core.cjs +57 -0
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.d.ts +50 -2
- package/dist/tools/fastapply/core.js +3 -1
- package/dist/tools/fastapply/index.cjs +34 -0
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.d.ts +2 -2
- package/dist/tools/fastapply/index.js +6 -4
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +2 -2
- package/dist/tools/fastapply/types.cjs.map +1 -1
- package/dist/tools/fastapply/types.d.ts +47 -1
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +2 -2
- package/dist/tools/index.cjs +34 -0
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.js +6 -4
- package/dist/tools/warp_grep/agent/runner.cjs +8 -1
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +6 -6
- package/dist/tools/warp_grep/anthropic.cjs +12 -4
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +2 -2
- package/dist/tools/warp_grep/anthropic.js +8 -8
- package/dist/tools/warp_grep/index.cjs +14 -4
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +7 -3
- package/dist/tools/warp_grep/index.js +12 -10
- package/dist/tools/warp_grep/openai.cjs +12 -4
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +2 -2
- package/dist/tools/warp_grep/openai.js +8 -8
- package/dist/tools/warp_grep/vercel.cjs +9 -2
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +2 -2
- package/dist/tools/warp_grep/vercel.js +8 -8
- package/package.json +1 -1
- package/dist/chunk-64PMM72R.js.map +0 -1
- package/dist/chunk-UU6XCZG3.js.map +0 -1
- package/dist/chunk-YR53PPVM.js.map +0 -1
- /package/dist/{chunk-G4AWE5A2.js.map → chunk-5QIWYEHJ.js.map} +0 -0
- /package/dist/{chunk-3FTAIJBH.js.map → chunk-IUG2FHNN.js.map} +0 -0
- /package/dist/{chunk-PZDR5ZZ2.js.map → chunk-KVMZPOUT.js.map} +0 -0
- /package/dist/{chunk-FYQUSDOE.js.map → chunk-PYTBBWL6.js.map} +0 -0
- /package/dist/{chunk-UIZT3KVJ.js.map → chunk-QZNGKOCZ.js.map} +0 -0
package/dist/client.cjs
CHANGED
|
@@ -145,6 +145,29 @@ var FastApplyClient = class {
|
|
|
145
145
|
async execute(input, overrides) {
|
|
146
146
|
return executeEditFile(input, { ...this.config, ...overrides });
|
|
147
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Apply an edit to code directly without file I/O
|
|
150
|
+
*
|
|
151
|
+
* Useful for sandbox environments or when you manage your own file system.
|
|
152
|
+
* Compatible with the earlier OpenAI client API contract.
|
|
153
|
+
*
|
|
154
|
+
* @param input - Code and edit parameters
|
|
155
|
+
* @param overrides - Optional config overrides for this operation
|
|
156
|
+
* @returns Result with merged code
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const result = await client.applyEdit({
|
|
161
|
+
* originalCode: 'function hello() { return "world"; }',
|
|
162
|
+
* codeEdit: 'function hello() { return "universe"; }',
|
|
163
|
+
* instructions: 'Change return value'
|
|
164
|
+
* });
|
|
165
|
+
* console.log(result.mergedCode);
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
async applyEdit(input, overrides) {
|
|
169
|
+
return applyEdit(input, { ...this.config, ...overrides });
|
|
170
|
+
}
|
|
148
171
|
};
|
|
149
172
|
function generateUdiff(original, modified, filepath) {
|
|
150
173
|
return (0, import_diff.createTwoFilesPatch)(
|
|
@@ -274,6 +297,38 @@ async function executeEditFile(input, config = {}) {
|
|
|
274
297
|
};
|
|
275
298
|
}
|
|
276
299
|
}
|
|
300
|
+
async function applyEdit(input, config = {}) {
|
|
301
|
+
const debug = config.debug || false;
|
|
302
|
+
const filepath = input.filepath || "file";
|
|
303
|
+
try {
|
|
304
|
+
if (debug) {
|
|
305
|
+
console.log(`[FastApply] Applying edit to code (${input.originalCode.length} chars)`);
|
|
306
|
+
}
|
|
307
|
+
const mergedCode = await callMorphAPI(
|
|
308
|
+
input.originalCode,
|
|
309
|
+
input.codeEdit,
|
|
310
|
+
input.instructions,
|
|
311
|
+
filepath,
|
|
312
|
+
config
|
|
313
|
+
);
|
|
314
|
+
const udiff = config.generateUdiff !== false ? generateUdiff(input.originalCode, mergedCode, filepath) : void 0;
|
|
315
|
+
const changes = countChanges(input.originalCode, mergedCode);
|
|
316
|
+
return {
|
|
317
|
+
success: true,
|
|
318
|
+
mergedCode,
|
|
319
|
+
udiff,
|
|
320
|
+
changes
|
|
321
|
+
};
|
|
322
|
+
} catch (error) {
|
|
323
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
324
|
+
if (debug) console.error(`[FastApply] Error: ${errorMessage}`);
|
|
325
|
+
return {
|
|
326
|
+
success: false,
|
|
327
|
+
changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },
|
|
328
|
+
error: errorMessage
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
}
|
|
277
332
|
|
|
278
333
|
// tools/codebase_search/core.ts
|
|
279
334
|
var CodebaseSearchClient = class {
|
|
@@ -1708,6 +1763,7 @@ async function runWarpGrep(config) {
|
|
|
1708
1763
|
parts.push(`- ${f.path}: ${ranges}`);
|
|
1709
1764
|
}
|
|
1710
1765
|
const payload = parts.join("\n");
|
|
1766
|
+
const fileReadErrors = [];
|
|
1711
1767
|
const resolved = await readFinishFiles(
|
|
1712
1768
|
repoRoot,
|
|
1713
1769
|
finishMeta.files,
|
|
@@ -1718,11 +1774,17 @@ async function runWarpGrep(config) {
|
|
|
1718
1774
|
const idx = l.indexOf("|");
|
|
1719
1775
|
return idx >= 0 ? l.slice(idx + 1) : l;
|
|
1720
1776
|
});
|
|
1721
|
-
} catch {
|
|
1777
|
+
} catch (err) {
|
|
1778
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
1779
|
+
fileReadErrors.push({ path: p, error: errorMsg });
|
|
1780
|
+
console.error(`[warp_grep] Failed to read file: ${p} - ${errorMsg}`);
|
|
1722
1781
|
return [`[couldn't find: ${p}]`];
|
|
1723
1782
|
}
|
|
1724
1783
|
}
|
|
1725
1784
|
);
|
|
1785
|
+
if (fileReadErrors.length > 0) {
|
|
1786
|
+
errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
|
|
1787
|
+
}
|
|
1726
1788
|
return {
|
|
1727
1789
|
terminationReason: "completed",
|
|
1728
1790
|
messages,
|
|
@@ -2812,7 +2874,8 @@ var RawRouter = class extends BaseRouter {
|
|
|
2812
2874
|
};
|
|
2813
2875
|
|
|
2814
2876
|
// tools/warp_grep/prompts.ts
|
|
2815
|
-
var
|
|
2877
|
+
var WARP_GREP_TOOL_NAME = "warpgrep_codebase_search";
|
|
2878
|
+
var WARP_GREP_DESCRIPTION = 'IMPORTANT: If you need to explore the codebase to gather context, and the task does not involve a single file or function which is provided by name, you should ALWAYS use the warpgrep codebase search tool first instead of running search commands. When the task requires exploration beyond a single known file, invoke warpgrep first with a natural-language query describing the target functionality, bug, or architectural concern. Warp Grep is a fast and accurate tool that can search for all relevant context in a codebase. Keep queries action-oriented (e.g., "Find where billing invoices are generated and emailed"), and after reviewing the summarized results, you may verify important findings with other search tools or direct file reads to ensure completeness. Warp Grep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. When a task requires exploration beyond a single known file, ALWAYS default to warpgrep codebase search before other search mechanisms.';
|
|
2816
2879
|
|
|
2817
2880
|
// tools/warp_grep/openai.ts
|
|
2818
2881
|
var TOOL_PARAMETERS = {
|
|
@@ -2848,7 +2911,7 @@ function createMorphWarpGrepTool(config) {
|
|
|
2848
2911
|
const tool4 = {
|
|
2849
2912
|
type: "function",
|
|
2850
2913
|
function: {
|
|
2851
|
-
name:
|
|
2914
|
+
name: config.name ?? WARP_GREP_TOOL_NAME,
|
|
2852
2915
|
description: config.description ?? WARP_GREP_DESCRIPTION,
|
|
2853
2916
|
parameters: TOOL_PARAMETERS
|
|
2854
2917
|
}
|
|
@@ -3155,7 +3218,7 @@ async function execute3(input, config) {
|
|
|
3155
3218
|
}
|
|
3156
3219
|
function createMorphWarpGrepTool2(config) {
|
|
3157
3220
|
const tool4 = {
|
|
3158
|
-
name:
|
|
3221
|
+
name: config.name ?? WARP_GREP_TOOL_NAME,
|
|
3159
3222
|
description: config.description ?? WARP_GREP_DESCRIPTION,
|
|
3160
3223
|
input_schema: INPUT_SCHEMA
|
|
3161
3224
|
};
|