@morphllm/morphsdk 0.2.154 → 0.2.155
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-2WAHX6I2.js → chunk-372QEHFA.js} +2 -2
- package/dist/{chunk-MTRH7FMN.js → chunk-3ULQXPPO.js} +2 -2
- package/dist/{chunk-KRRO7FF2.js → chunk-AEYK5XL5.js} +2 -2
- package/dist/{chunk-VK76R3IN.js → chunk-CNKSTKRM.js} +2 -2
- package/dist/{chunk-QSATHLZJ.js → chunk-CZ2LZ4GV.js} +4 -3
- package/dist/{chunk-QSATHLZJ.js.map → chunk-CZ2LZ4GV.js.map} +1 -1
- package/dist/{chunk-UDI5U6QV.js → chunk-D34NUQGV.js} +2 -2
- package/dist/{chunk-3XO33KPS.js → chunk-DQJBEM4O.js} +2 -2
- package/dist/{chunk-3XO33KPS.js.map → chunk-DQJBEM4O.js.map} +1 -1
- package/dist/{chunk-P57SFOLD.js → chunk-GOKSI67V.js} +2 -2
- package/dist/{chunk-5IKDEESU.js → chunk-GPK433QG.js} +3 -3
- package/dist/{chunk-LK4C3NYX.js → chunk-GZXWWB4Z.js} +2 -2
- package/dist/{chunk-Y5O3A7SU.js → chunk-KQR3VCGR.js} +2 -2
- package/dist/{chunk-TAGDMT3K.js → chunk-L4GXXQEO.js} +2 -2
- package/dist/{chunk-ZSA3NL5T.js → chunk-MBVOMNXG.js} +2 -2
- package/dist/{chunk-J43SJUCO.js → chunk-NMBM37CB.js} +3 -2
- package/dist/{chunk-J43SJUCO.js.map → chunk-NMBM37CB.js.map} +1 -1
- package/dist/{chunk-A6T6E636.js → chunk-Q3HZGVQ2.js} +2 -2
- package/dist/{chunk-YKBVE3CE.js → chunk-TZCNMJHF.js} +2 -2
- package/dist/{chunk-4R6F66B7.js → chunk-V2BUYOKP.js} +2 -2
- package/dist/{chunk-PRHEWGWC.js → chunk-Y23PQQRM.js} +17 -17
- package/dist/{chunk-D5UUKDKL.js → chunk-Y3LQWQHU.js} +4 -4
- package/dist/chunk-Y3LQWQHU.js.map +1 -0
- package/dist/{chunk-WQU6QXSU.js → chunk-YCUX3ZNQ.js} +2 -2
- package/dist/{chunk-Q77CT3RI.js → chunk-YIUOPGWE.js} +2 -2
- package/dist/{chunk-ZHKANLAQ.js → chunk-YJEXFOLJ.js} +4 -4
- package/dist/chunk-YJEXFOLJ.js.map +1 -0
- package/dist/{chunk-FOKMTUWC.js → chunk-YRHDWJDA.js} +2 -2
- package/dist/{chunk-N4KLUOXK.js → chunk-YYOPTKC3.js} +2 -2
- package/dist/{chunk-3BTUUH23.js → chunk-ZMGKZNII.js} +6 -6
- package/dist/chunk-ZMGKZNII.js.map +1 -0
- package/dist/{client-BcO_qte8.d.ts → client-PkB7g9SA.d.ts} +1 -1
- package/dist/client.cjs +13 -11
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +22 -22
- package/dist/edge.cjs +3 -2
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.js +4 -4
- package/dist/index.cjs +13 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +22 -22
- package/dist/modelrouter/core.cjs +1 -1
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.js +3 -3
- package/dist/modelrouter/index.cjs +1 -1
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.js +3 -3
- package/dist/subagents/anthropic.cjs +1 -1
- package/dist/subagents/anthropic.cjs.map +1 -1
- package/dist/subagents/anthropic.js +4 -4
- package/dist/subagents/vercel.cjs +1 -1
- package/dist/subagents/vercel.cjs.map +1 -1
- package/dist/subagents/vercel.js +4 -4
- package/dist/tools/browser/anthropic.cjs +1 -1
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +5 -5
- package/dist/tools/browser/core.cjs +1 -1
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.js +4 -4
- package/dist/tools/browser/index.cjs +1 -1
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.js +7 -7
- package/dist/tools/browser/openai.cjs +1 -1
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.js +5 -5
- package/dist/tools/browser/profiles/core.cjs +1 -1
- package/dist/tools/browser/profiles/core.cjs.map +1 -1
- package/dist/tools/browser/profiles/core.js +3 -3
- package/dist/tools/browser/profiles/index.cjs +1 -1
- package/dist/tools/browser/profiles/index.cjs.map +1 -1
- package/dist/tools/browser/profiles/index.js +3 -3
- package/dist/tools/browser/vercel.cjs +1 -1
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.js +5 -5
- package/dist/tools/codebase_search/anthropic.cjs +1 -1
- package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
- package/dist/tools/codebase_search/anthropic.js +4 -4
- package/dist/tools/codebase_search/core.cjs +1 -1
- package/dist/tools/codebase_search/core.cjs.map +1 -1
- package/dist/tools/codebase_search/core.js +3 -3
- package/dist/tools/codebase_search/index.cjs +1 -1
- package/dist/tools/codebase_search/index.cjs.map +1 -1
- package/dist/tools/codebase_search/index.js +6 -6
- package/dist/tools/codebase_search/openai.cjs +1 -1
- package/dist/tools/codebase_search/openai.cjs.map +1 -1
- package/dist/tools/codebase_search/openai.js +4 -4
- package/dist/tools/codebase_search/vercel.cjs +1 -1
- package/dist/tools/codebase_search/vercel.cjs.map +1 -1
- package/dist/tools/codebase_search/vercel.js +4 -4
- package/dist/tools/fastapply/anthropic.cjs +7 -5
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +4 -4
- package/dist/tools/fastapply/apply.cjs +3 -2
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +2 -2
- package/dist/tools/fastapply/core.cjs +5 -3
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.js +3 -3
- package/dist/tools/fastapply/index.cjs +13 -11
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.d.ts +1 -1
- package/dist/tools/fastapply/index.js +6 -6
- package/dist/tools/fastapply/openai.cjs +7 -5
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +4 -4
- package/dist/tools/fastapply/types.cjs.map +1 -1
- package/dist/tools/fastapply/types.d.ts +6 -2
- package/dist/tools/fastapply/vercel.cjs +9 -7
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.d.ts +1 -1
- package/dist/tools/fastapply/vercel.js +4 -4
- package/dist/tools/index.cjs +13 -11
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +6 -6
- package/dist/tools/utils/resilience.cjs +1 -1
- package/dist/tools/utils/resilience.cjs.map +1 -1
- package/dist/tools/utils/resilience.js +2 -2
- package/dist/tools/warp_grep/agent/runner.cjs +1 -1
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +2 -2
- package/dist/tools/warp_grep/anthropic.cjs +1 -1
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.js +4 -4
- package/dist/tools/warp_grep/client.cjs +1 -1
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.js +3 -3
- package/dist/tools/warp_grep/gemini.cjs +1 -1
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.js +3 -3
- package/dist/tools/warp_grep/index.cjs +1 -1
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.js +3 -3
- package/dist/tools/warp_grep/openai.cjs +1 -1
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.js +4 -4
- package/dist/tools/warp_grep/vercel.cjs +1 -1
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.js +4 -4
- package/dist/{vercel-B1GZ_g9N.d.ts → vercel-Cg38kNm4.d.ts} +2 -2
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3BTUUH23.js.map +0 -1
- package/dist/chunk-D5UUKDKL.js.map +0 -1
- package/dist/chunk-ZHKANLAQ.js.map +0 -1
- /package/dist/{chunk-2WAHX6I2.js.map → chunk-372QEHFA.js.map} +0 -0
- /package/dist/{chunk-MTRH7FMN.js.map → chunk-3ULQXPPO.js.map} +0 -0
- /package/dist/{chunk-KRRO7FF2.js.map → chunk-AEYK5XL5.js.map} +0 -0
- /package/dist/{chunk-VK76R3IN.js.map → chunk-CNKSTKRM.js.map} +0 -0
- /package/dist/{chunk-UDI5U6QV.js.map → chunk-D34NUQGV.js.map} +0 -0
- /package/dist/{chunk-P57SFOLD.js.map → chunk-GOKSI67V.js.map} +0 -0
- /package/dist/{chunk-5IKDEESU.js.map → chunk-GPK433QG.js.map} +0 -0
- /package/dist/{chunk-LK4C3NYX.js.map → chunk-GZXWWB4Z.js.map} +0 -0
- /package/dist/{chunk-Y5O3A7SU.js.map → chunk-KQR3VCGR.js.map} +0 -0
- /package/dist/{chunk-TAGDMT3K.js.map → chunk-L4GXXQEO.js.map} +0 -0
- /package/dist/{chunk-ZSA3NL5T.js.map → chunk-MBVOMNXG.js.map} +0 -0
- /package/dist/{chunk-A6T6E636.js.map → chunk-Q3HZGVQ2.js.map} +0 -0
- /package/dist/{chunk-YKBVE3CE.js.map → chunk-TZCNMJHF.js.map} +0 -0
- /package/dist/{chunk-4R6F66B7.js.map → chunk-V2BUYOKP.js.map} +0 -0
- /package/dist/{chunk-PRHEWGWC.js.map → chunk-Y23PQQRM.js.map} +0 -0
- /package/dist/{chunk-WQU6QXSU.js.map → chunk-YCUX3ZNQ.js.map} +0 -0
- /package/dist/{chunk-Q77CT3RI.js.map → chunk-YIUOPGWE.js.map} +0 -0
- /package/dist/{chunk-FOKMTUWC.js.map → chunk-YRHDWJDA.js.map} +0 -0
- /package/dist/{chunk-N4KLUOXK.js.map → chunk-YYOPTKC3.js.map} +0 -0
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-63WE2C5R.js";
|
|
5
5
|
import {
|
|
6
6
|
executeEditFile
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NMBM37CB.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
10
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -31,7 +31,7 @@ var editFileTool = {
|
|
|
31
31
|
type: "string",
|
|
32
32
|
description: "The path of the target file to modify"
|
|
33
33
|
},
|
|
34
|
-
|
|
34
|
+
instruction: {
|
|
35
35
|
type: "string",
|
|
36
36
|
description: "A single sentence describing what you are changing (first person)"
|
|
37
37
|
},
|
|
@@ -40,7 +40,7 @@ var editFileTool = {
|
|
|
40
40
|
description: "The lazy edit with // ... existing code ... markers"
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
-
required: ["target_filepath", "
|
|
43
|
+
required: ["target_filepath", "instruction", "code_edit"]
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
};
|
|
@@ -91,4 +91,4 @@ export {
|
|
|
91
91
|
openai_default,
|
|
92
92
|
openai_exports
|
|
93
93
|
};
|
|
94
|
-
//# sourceMappingURL=chunk-
|
|
94
|
+
//# sourceMappingURL=chunk-YJEXFOLJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/fastapply/openai.ts"],"sourcesContent":["/**\n * OpenAI SDK adapter for edit_file tool\n */\n\nimport type { ChatCompletionTool } from 'openai/resources/chat/completions';\nimport { executeEditFile } from './core.js';\nimport { EDIT_FILE_TOOL_DESCRIPTION, EDIT_FILE_SYSTEM_PROMPT } from './prompts.js';\nimport type { EditFileInput, EditFileResult, EditFileConfig } from './types.js';\n\n/**\n * OpenAI-native tool definition for edit_file\n * \n * @example\n * ```ts\n * import OpenAI from 'openai';\n * import { editFileTool } from 'morphsdk/tools/openai';\n * \n * const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });\n * \n * const response = await client.chat.completions.create({\n * model: \"gpt-4o\",\n * tools: [editFileTool],\n * messages: [{ role: \"user\", content: \"Fix the bug in app.ts\" }]\n * });\n * ```\n */\nexport const editFileTool: ChatCompletionTool = {\n type: 'function',\n function: {\n name: 'edit_file',\n description: EDIT_FILE_TOOL_DESCRIPTION,\n parameters: {\n type: 'object',\n properties: {\n target_filepath: {\n type: 'string',\n description: 'The path of the target file to modify',\n },\n instruction: {\n type: 'string',\n description: 'A single sentence describing what you are changing (first person)',\n },\n code_edit: {\n type: 'string',\n description: 'The lazy edit with // ... existing code ... markers',\n },\n },\n required: ['target_filepath', 'instruction', 'code_edit'],\n },\n },\n};\n\n/**\n * Execute an edit_file tool call\n * \n * @param input - The tool input from GPT (parsed from tool_calls)\n * @param config - Optional configuration\n * @returns The result of the edit operation\n * \n * @example\n * ```ts\n * const args = JSON.parse(toolCall.function.arguments);\n * const result = await execute(args);\n * console.log('Changes applied:', result.udiff);\n * ```\n */\nexport async function execute(\n input: EditFileInput,\n config?: EditFileConfig\n): Promise<EditFileResult> {\n return executeEditFile(input, config);\n}\n\n/**\n * Get the system prompt for edit_file usage\n * \n * Add this to your system message to guide GPT on using edit_file properly.\n * \n * @example\n * ```ts\n * const response = await client.chat.completions.create({\n * model: \"gpt-4o\",\n * messages: [\n * { role: \"system\", content: getSystemPrompt() },\n * { role: \"user\", content: \"Fix bugs\" }\n * ],\n * tools: [editFileTool]\n * });\n * ```\n */\nexport function getSystemPrompt(): string {\n return EDIT_FILE_SYSTEM_PROMPT;\n}\n\n/**\n * Format the result for passing back to GPT\n * \n * @param result - The edit result\n * @returns Formatted string for tool message\n */\nexport function formatResult(result: EditFileResult): string {\n if (!result.success) {\n return `Error editing file: ${result.error}`;\n }\n \n const { changes } = result;\n return `Successfully applied changes to ${result.filepath}. Added ${changes.linesAdded}, removed ${changes.linesRemoved}, modified ${changes.linesModified}.`;\n}\n\n/**\n * Create a custom edit_file tool with configuration and methods\n * \n * @param config - Configuration options\n * @returns Tool definition with execute and formatResult methods\n * \n * @example\n * ```ts\n * import OpenAI from 'openai';\n * import { createEditFileTool } from 'morphsdk/tools/fastapply/openai';\n * \n * const tool = createEditFileTool({\n * baseDir: './src',\n * generateUdiff: true,\n * description: 'Custom tool description for your use case'\n * });\n * \n * const client = new OpenAI();\n * \n * const response = await client.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [tool], // tool itself is the ChatCompletionTool\n * messages: [{ role: 'user', content: 'Fix bug in app.ts' }]\n * });\n * \n * // Execute and format\n * const result = await tool.execute(toolCallArgs);\n * const formatted = tool.formatResult(result);\n * ```\n */\nexport function createEditFileTool(config: EditFileConfig = {}) {\n const toolDef: ChatCompletionTool = {\n ...editFileTool,\n ...(config.description && {\n function: {\n ...editFileTool.function,\n description: config.description,\n },\n }),\n };\n \n return Object.assign({}, toolDef, {\n execute: async (input: EditFileInput | string): Promise<EditFileResult> => {\n const parsedInput = typeof input === 'string' ? JSON.parse(input) : input;\n return execute(parsedInput, config);\n },\n formatResult: (result: EditFileResult): string => {\n return formatResult(result);\n },\n getSystemPrompt: (): string => {\n return getSystemPrompt();\n },\n });\n}\n\n// Default export for convenience\nexport default editFileTool;\n\n"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BO,IAAM,eAAmC;AAAA,EAC9C,MAAM;AAAA,EACN,UAAU;AAAA,IACR,MAAM;AAAA,IACN,aAAa;AAAA,IACb,YAAY;AAAA,MACV,MAAM;AAAA,MACN,YAAY;AAAA,QACV,iBAAiB;AAAA,UACf,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,aAAa;AAAA,UACX,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,WAAW;AAAA,UACT,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,MACF;AAAA,MACA,UAAU,CAAC,mBAAmB,eAAe,WAAW;AAAA,IAC1D;AAAA,EACF;AACF;AAgBA,eAAsB,QACpB,OACA,QACyB;AACzB,SAAO,gBAAgB,OAAO,MAAM;AACtC;AAmBO,SAAS,kBAA0B;AACxC,SAAO;AACT;AAQO,SAAS,aAAa,QAAgC;AAC3D,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,uBAAuB,OAAO,KAAK;AAAA,EAC5C;AAEA,QAAM,EAAE,QAAQ,IAAI;AACpB,SAAO,mCAAmC,OAAO,QAAQ,WAAW,QAAQ,UAAU,aAAa,QAAQ,YAAY,cAAc,QAAQ,aAAa;AAC5J;AAgCO,SAAS,mBAAmB,SAAyB,CAAC,GAAG;AAC9D,QAAM,UAA8B;AAAA,IAClC,GAAG;AAAA,IACH,GAAI,OAAO,eAAe;AAAA,MACxB,UAAU;AAAA,QACR,GAAG,aAAa;AAAA,QAChB,aAAa,OAAO;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AAEA,SAAO,OAAO,OAAO,CAAC,GAAG,SAAS;AAAA,IAChC,SAAS,OAAO,UAA2D;AACzE,YAAM,cAAc,OAAO,UAAU,WAAW,KAAK,MAAM,KAAK,IAAI;AACpE,aAAO,QAAQ,aAAa,MAAM;AAAA,IACpC;AAAA,IACA,cAAc,CAAC,WAAmC;AAChD,aAAO,aAAa,MAAM;AAAA,IAC5B;AAAA,IACA,iBAAiB,MAAc;AAC7B,aAAO,gBAAgB;AAAA,IACzB;AAAA,EACF,CAAC;AACH;AAGA,IAAO,iBAAQ;","names":[]}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./chunk-2VERUKO2.js";
|
|
13
13
|
import {
|
|
14
14
|
fetchWithRetry
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-MBVOMNXG.js";
|
|
16
16
|
|
|
17
17
|
// tools/browser/profiles/core.ts
|
|
18
18
|
var DEFAULT_API_URL = process.env.MORPH_ENVIRONMENT === "DEV" ? "http://localhost:8000" : "https://browser.morphllm.com";
|
|
@@ -386,4 +386,4 @@ export {
|
|
|
386
386
|
listRepos,
|
|
387
387
|
getProfileState
|
|
388
388
|
};
|
|
389
|
-
//# sourceMappingURL=chunk-
|
|
389
|
+
//# sourceMappingURL=chunk-YRHDWJDA.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
executeCodebaseSearch
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-V2BUYOKP.js";
|
|
4
4
|
import {
|
|
5
5
|
CODEBASE_SEARCH_DESCRIPTION,
|
|
6
6
|
CODEBASE_SEARCH_SYSTEM_PROMPT
|
|
@@ -125,4 +125,4 @@ export {
|
|
|
125
125
|
getSystemPrompt,
|
|
126
126
|
openai_default
|
|
127
127
|
};
|
|
128
|
-
//# sourceMappingURL=chunk-
|
|
128
|
+
//# sourceMappingURL=chunk-YYOPTKC3.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-63WE2C5R.js";
|
|
5
5
|
import {
|
|
6
6
|
executeEditFile
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NMBM37CB.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
10
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -21,7 +21,7 @@ import { tool } from "ai";
|
|
|
21
21
|
import { z } from "zod";
|
|
22
22
|
var editFileSchema = z.object({
|
|
23
23
|
target_filepath: z.string().describe("The path of the target file to modify"),
|
|
24
|
-
|
|
24
|
+
instruction: z.string().describe("A single sentence describing what you are changing (first person)"),
|
|
25
25
|
code_edit: z.string().describe("The lazy edit with // ... existing code ... markers")
|
|
26
26
|
});
|
|
27
27
|
var editFileTool = tool({
|
|
@@ -30,7 +30,7 @@ var editFileTool = tool({
|
|
|
30
30
|
execute: async (params) => {
|
|
31
31
|
const result = await executeEditFile({
|
|
32
32
|
target_filepath: params.target_filepath,
|
|
33
|
-
|
|
33
|
+
instruction: params.instruction,
|
|
34
34
|
code_edit: params.code_edit
|
|
35
35
|
});
|
|
36
36
|
if (!result.success) {
|
|
@@ -50,7 +50,7 @@ function getSystemPrompt() {
|
|
|
50
50
|
function createEditFileTool(config = {}) {
|
|
51
51
|
const schema = z.object({
|
|
52
52
|
target_filepath: z.string().describe("The path of the target file to modify"),
|
|
53
|
-
|
|
53
|
+
instruction: z.string().describe("A single sentence describing what you are changing (first person)"),
|
|
54
54
|
code_edit: z.string().describe("The lazy edit with // ... existing code ... markers")
|
|
55
55
|
});
|
|
56
56
|
return tool({
|
|
@@ -60,7 +60,7 @@ function createEditFileTool(config = {}) {
|
|
|
60
60
|
const result = await executeEditFile(
|
|
61
61
|
{
|
|
62
62
|
target_filepath: params.target_filepath,
|
|
63
|
-
|
|
63
|
+
instruction: params.instruction,
|
|
64
64
|
code_edit: params.code_edit
|
|
65
65
|
},
|
|
66
66
|
config
|
|
@@ -86,4 +86,4 @@ export {
|
|
|
86
86
|
vercel_default,
|
|
87
87
|
vercel_exports
|
|
88
88
|
};
|
|
89
|
-
//# sourceMappingURL=chunk-
|
|
89
|
+
//# sourceMappingURL=chunk-ZMGKZNII.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/fastapply/vercel.ts"],"sourcesContent":["/**\n * Vercel AI SDK adapter for edit_file tool\n */\n\nimport { tool } from 'ai';\nimport { z } from 'zod';\nimport { executeEditFile } from './core.js';\nimport { EDIT_FILE_TOOL_DESCRIPTION, EDIT_FILE_SYSTEM_PROMPT } from './prompts.js';\nimport type { EditFileConfig } from './types.js';\n\n/**\n * Vercel AI SDK tool for edit_file\n * \n * @example\n * ```ts\n * import { generateText } from 'ai';\n * import { anthropic } from '@ai-sdk/anthropic';\n * import { editFileTool } from 'morphsdk/tools/vercel';\n * \n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { editFile: editFileTool },\n * prompt: \"Fix the bug in app.ts\"\n * });\n * ```\n */\nconst editFileSchema = z.object({\n target_filepath: z.string().describe('The path of the target file to modify'),\n instruction: z\n .string()\n .describe('A single sentence describing what you are changing (first person)'),\n code_edit: z\n .string()\n .describe('The lazy edit with // ... existing code ... markers'),\n});\n\nexport const editFileTool = tool({\n description: EDIT_FILE_TOOL_DESCRIPTION,\n inputSchema: editFileSchema,\n execute: async (params) => {\n const result = await executeEditFile({\n target_filepath: params.target_filepath,\n instruction: params.instruction,\n code_edit: params.code_edit,\n });\n \n if (!result.success) {\n throw new Error(`Failed to edit file: ${result.error}`);\n }\n \n return {\n success: true,\n filepath: result.filepath,\n changes: result.changes,\n udiff: result.udiff,\n };\n },\n});\n\n/**\n * Get the system prompt for edit_file usage\n * \n * Add this to your system message to guide the model on using edit_file properly.\n * \n * @example\n * ```ts\n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * system: getSystemPrompt(),\n * tools: { editFile: editFileTool },\n * prompt: \"Fix bugs\"\n * });\n * ```\n */\nexport function getSystemPrompt(): string {\n return EDIT_FILE_SYSTEM_PROMPT;\n}\n\n/**\n * Create a custom edit_file tool with configuration\n * \n * @param config - Configuration options\n * @returns Vercel AI SDK tool with custom config\n * \n * @example\n * ```ts\n * const customEditTool = createEditFileTool({\n * baseDir: './src',\n * generateUdiff: true,\n * description: 'Custom tool description for your use case'\n * });\n * \n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { editFile: customEditTool },\n * prompt: \"Fix bugs\"\n * });\n * ```\n */\nexport function createEditFileTool(config: EditFileConfig = {}) {\n const schema = z.object({\n target_filepath: z.string().describe('The path of the target file to modify'),\n instruction: z\n .string()\n .describe('A single sentence describing what you are changing (first person)'),\n code_edit: z\n .string()\n .describe('The lazy edit with // ... existing code ... markers'),\n });\n\n return tool({\n description: config.description || EDIT_FILE_TOOL_DESCRIPTION,\n inputSchema: schema,\n execute: async (params) => {\n const result = await executeEditFile(\n {\n target_filepath: params.target_filepath,\n instruction: params.instruction,\n code_edit: params.code_edit,\n },\n config\n );\n \n if (!result.success) {\n throw new Error(`Failed to edit file: ${result.error}`);\n }\n \n return {\n success: true,\n filepath: result.filepath,\n changes: result.changes,\n udiff: result.udiff,\n };\n },\n });\n}\n\n// Default export for convenience\nexport default editFileTool;\n\n"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,SAAS,YAAY;AACrB,SAAS,SAAS;AAqBlB,IAAM,iBAAiB,EAAE,OAAO;AAAA,EAC9B,iBAAiB,EAAE,OAAO,EAAE,SAAS,uCAAuC;AAAA,EAC5E,aAAa,EACV,OAAO,EACP,SAAS,mEAAmE;AAAA,EAC/E,WAAW,EACR,OAAO,EACP,SAAS,qDAAqD;AACnE,CAAC;AAEM,IAAM,eAAe,KAAK;AAAA,EAC/B,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS,OAAO,WAAW;AACzB,UAAM,SAAS,MAAM,gBAAgB;AAAA,MACnC,iBAAiB,OAAO;AAAA,MACxB,aAAa,OAAO;AAAA,MACpB,WAAW,OAAO;AAAA,IACpB,CAAC;AAED,QAAI,CAAC,OAAO,SAAS;AACnB,YAAM,IAAI,MAAM,wBAAwB,OAAO,KAAK,EAAE;AAAA,IACxD;AAEA,WAAO;AAAA,MACL,SAAS;AAAA,MACT,UAAU,OAAO;AAAA,MACjB,SAAS,OAAO;AAAA,MAChB,OAAO,OAAO;AAAA,IAChB;AAAA,EACF;AACF,CAAC;AAiBM,SAAS,kBAA0B;AACxC,SAAO;AACT;AAuBO,SAAS,mBAAmB,SAAyB,CAAC,GAAG;AAC9D,QAAM,SAAS,EAAE,OAAO;AAAA,IACtB,iBAAiB,EAAE,OAAO,EAAE,SAAS,uCAAuC;AAAA,IAC5E,aAAa,EACV,OAAO,EACP,SAAS,mEAAmE;AAAA,IAC/E,WAAW,EACR,OAAO,EACP,SAAS,qDAAqD;AAAA,EACnE,CAAC;AAED,SAAO,KAAK;AAAA,IACV,aAAa,OAAO,eAAe;AAAA,IACnC,aAAa;AAAA,IACb,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM;AAAA,QACnB;AAAA,UACE,iBAAiB,OAAO;AAAA,UACxB,aAAa,OAAO;AAAA,UACpB,WAAW,OAAO;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAEA,UAAI,CAAC,OAAO,SAAS;AACnB,cAAM,IAAI,MAAM,wBAAwB,OAAO,KAAK,EAAE;AAAA,MACxD;AAEA,aAAO;AAAA,QACL,SAAS;AAAA,QACT,UAAU,OAAO;AAAA,QACjB,SAAS,OAAO;AAAA,QAChB,OAAO,OAAO;AAAA,MAChB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAGA,IAAO,iBAAQ;","names":[]}
|
|
@@ -851,7 +851,7 @@ declare class VercelToolFactory {
|
|
|
851
851
|
*/
|
|
852
852
|
createEditFileTool(toolConfig?: Omit<EditFileConfig, 'morphApiKey'>): ai.Tool<{
|
|
853
853
|
target_filepath: string;
|
|
854
|
-
|
|
854
|
+
instruction: string;
|
|
855
855
|
code_edit: string;
|
|
856
856
|
}, {
|
|
857
857
|
success: boolean;
|
package/dist/client.cjs
CHANGED
|
@@ -36,7 +36,7 @@ var init_package = __esm({
|
|
|
36
36
|
"package.json"() {
|
|
37
37
|
package_default = {
|
|
38
38
|
name: "@morphllm/morphsdk",
|
|
39
|
-
version: "0.2.
|
|
39
|
+
version: "0.2.155",
|
|
40
40
|
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
41
41
|
type: "module",
|
|
42
42
|
main: "./dist/index.cjs",
|
|
@@ -367,10 +367,11 @@ async function applyEdit(input, config = {}) {
|
|
|
367
367
|
if (debug) {
|
|
368
368
|
console.log(`[FastApply] Applying edit to code (${input.originalCode.length} chars)`);
|
|
369
369
|
}
|
|
370
|
+
const instruction = input.instruction ?? input.instructions ?? "";
|
|
370
371
|
const { content: mergedCode, completionId } = await callMorphAPI(
|
|
371
372
|
input.originalCode,
|
|
372
373
|
input.codeEdit,
|
|
373
|
-
|
|
374
|
+
instruction,
|
|
374
375
|
filepath,
|
|
375
376
|
config
|
|
376
377
|
);
|
|
@@ -1084,7 +1085,8 @@ async function executeEditFile(input, config = {}) {
|
|
|
1084
1085
|
}
|
|
1085
1086
|
if (debug) console.log(`[FastApply] File doesn't exist, will create new file`);
|
|
1086
1087
|
}
|
|
1087
|
-
const
|
|
1088
|
+
const instruction = input.instruction ?? input.instructions ?? "";
|
|
1089
|
+
const { content: mergedCode, completionId } = await callMorphAPI2(originalCode, input.code_edit, instruction, input.target_filepath, config);
|
|
1088
1090
|
const udiff = config.generateUdiff !== false ? generateUdiff2(originalCode, mergedCode, input.target_filepath) : void 0;
|
|
1089
1091
|
if (config.autoWrite !== false) {
|
|
1090
1092
|
await writeFile(fullPath, mergedCode, "utf-8");
|
|
@@ -5153,7 +5155,7 @@ var editFileTool = {
|
|
|
5153
5155
|
type: "string",
|
|
5154
5156
|
description: "The path of the target file to modify"
|
|
5155
5157
|
},
|
|
5156
|
-
|
|
5158
|
+
instruction: {
|
|
5157
5159
|
type: "string",
|
|
5158
5160
|
description: "A single sentence describing what you are changing (first person)"
|
|
5159
5161
|
},
|
|
@@ -5162,7 +5164,7 @@ var editFileTool = {
|
|
|
5162
5164
|
description: "The lazy edit with // ... existing code ... markers"
|
|
5163
5165
|
}
|
|
5164
5166
|
},
|
|
5165
|
-
required: ["target_filepath", "
|
|
5167
|
+
required: ["target_filepath", "instruction", "code_edit"]
|
|
5166
5168
|
}
|
|
5167
5169
|
}
|
|
5168
5170
|
};
|
|
@@ -5384,7 +5386,7 @@ var editFileTool2 = {
|
|
|
5384
5386
|
type: "string",
|
|
5385
5387
|
description: "The path of the target file to modify"
|
|
5386
5388
|
},
|
|
5387
|
-
|
|
5389
|
+
instruction: {
|
|
5388
5390
|
type: "string",
|
|
5389
5391
|
description: "A single sentence describing what you are changing (first person)"
|
|
5390
5392
|
},
|
|
@@ -5393,7 +5395,7 @@ var editFileTool2 = {
|
|
|
5393
5395
|
description: "The lazy edit with // ... existing code ... markers"
|
|
5394
5396
|
}
|
|
5395
5397
|
},
|
|
5396
|
-
required: ["target_filepath", "
|
|
5398
|
+
required: ["target_filepath", "instruction", "code_edit"]
|
|
5397
5399
|
}
|
|
5398
5400
|
};
|
|
5399
5401
|
function formatResult5(result) {
|
|
@@ -5938,7 +5940,7 @@ var import_ai3 = require("ai");
|
|
|
5938
5940
|
var import_zod3 = require("zod");
|
|
5939
5941
|
var editFileSchema = import_zod3.z.object({
|
|
5940
5942
|
target_filepath: import_zod3.z.string().describe("The path of the target file to modify"),
|
|
5941
|
-
|
|
5943
|
+
instruction: import_zod3.z.string().describe("A single sentence describing what you are changing (first person)"),
|
|
5942
5944
|
code_edit: import_zod3.z.string().describe("The lazy edit with // ... existing code ... markers")
|
|
5943
5945
|
});
|
|
5944
5946
|
var editFileTool3 = (0, import_ai3.tool)({
|
|
@@ -5947,7 +5949,7 @@ var editFileTool3 = (0, import_ai3.tool)({
|
|
|
5947
5949
|
execute: async (params) => {
|
|
5948
5950
|
const result = await executeEditFile({
|
|
5949
5951
|
target_filepath: params.target_filepath,
|
|
5950
|
-
|
|
5952
|
+
instruction: params.instruction,
|
|
5951
5953
|
code_edit: params.code_edit
|
|
5952
5954
|
});
|
|
5953
5955
|
if (!result.success) {
|
|
@@ -5964,7 +5966,7 @@ var editFileTool3 = (0, import_ai3.tool)({
|
|
|
5964
5966
|
function createEditFileTool3(config = {}) {
|
|
5965
5967
|
const schema = import_zod3.z.object({
|
|
5966
5968
|
target_filepath: import_zod3.z.string().describe("The path of the target file to modify"),
|
|
5967
|
-
|
|
5969
|
+
instruction: import_zod3.z.string().describe("A single sentence describing what you are changing (first person)"),
|
|
5968
5970
|
code_edit: import_zod3.z.string().describe("The lazy edit with // ... existing code ... markers")
|
|
5969
5971
|
});
|
|
5970
5972
|
return (0, import_ai3.tool)({
|
|
@@ -5974,7 +5976,7 @@ function createEditFileTool3(config = {}) {
|
|
|
5974
5976
|
const result = await executeEditFile(
|
|
5975
5977
|
{
|
|
5976
5978
|
target_filepath: params.target_filepath,
|
|
5977
|
-
|
|
5979
|
+
instruction: params.instruction,
|
|
5978
5980
|
code_edit: params.code_edit
|
|
5979
5981
|
},
|
|
5980
5982
|
config
|