@morphllm/morphsdk 0.2.21 → 0.2.23

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 (193) hide show
  1. package/dist/{chunk-BILUTNBC.js → chunk-4A7UBGLS.js} +2 -2
  2. package/dist/chunk-73RQWOQC.js +16 -0
  3. package/dist/chunk-73RQWOQC.js.map +1 -0
  4. package/dist/chunk-AFEPUNAO.js +15 -0
  5. package/dist/chunk-AFEPUNAO.js.map +1 -0
  6. package/dist/{chunk-VJK4PH5V.js → chunk-AG3ICTC5.js} +5 -2
  7. package/dist/chunk-AG3ICTC5.js.map +1 -0
  8. package/dist/chunk-EAA7D24N.js +201 -0
  9. package/dist/chunk-EAA7D24N.js.map +1 -0
  10. package/dist/chunk-EK7OQPWD.js +44 -0
  11. package/dist/chunk-EK7OQPWD.js.map +1 -0
  12. package/dist/chunk-G2RSY56Q.js +11 -0
  13. package/dist/chunk-G2RSY56Q.js.map +1 -0
  14. package/dist/chunk-GTOXMAF2.js +140 -0
  15. package/dist/chunk-GTOXMAF2.js.map +1 -0
  16. package/dist/chunk-HKZB23U7.js +85 -0
  17. package/dist/chunk-HKZB23U7.js.map +1 -0
  18. package/dist/{chunk-34F3D6JD.js → chunk-HWJN5AMA.js} +8 -8
  19. package/dist/chunk-LN4CTQZG.js +56 -0
  20. package/dist/chunk-LN4CTQZG.js.map +1 -0
  21. package/dist/chunk-NDZO5IPV.js +121 -0
  22. package/dist/chunk-NDZO5IPV.js.map +1 -0
  23. package/dist/chunk-RSLIOCOE.js +26 -0
  24. package/dist/chunk-RSLIOCOE.js.map +1 -0
  25. package/dist/chunk-S3GI7HNR.js +44 -0
  26. package/dist/chunk-S3GI7HNR.js.map +1 -0
  27. package/dist/chunk-SMGZ6A64.js +53 -0
  28. package/dist/chunk-SMGZ6A64.js.map +1 -0
  29. package/dist/chunk-TICMYDII.js +81 -0
  30. package/dist/chunk-TICMYDII.js.map +1 -0
  31. package/dist/chunk-UYBIKZPM.js +135 -0
  32. package/dist/chunk-UYBIKZPM.js.map +1 -0
  33. package/dist/chunk-VBBJGWHY.js +73 -0
  34. package/dist/chunk-VBBJGWHY.js.map +1 -0
  35. package/dist/chunk-W5CHJ6OX.js +53 -0
  36. package/dist/chunk-W5CHJ6OX.js.map +1 -0
  37. package/dist/{chunk-WXBUVKYL.js → chunk-WHZQDTM6.js} +2 -2
  38. package/dist/chunk-XYPMN4A3.js +1 -0
  39. package/dist/chunk-XYPMN4A3.js.map +1 -0
  40. package/dist/{chunk-YVGRWE7D.js → chunk-Y2IY7NYY.js} +2 -2
  41. package/dist/chunk-Z2FBMSNE.js +10 -0
  42. package/dist/chunk-Z2FBMSNE.js.map +1 -0
  43. package/dist/client.cjs +4 -1
  44. package/dist/client.cjs.map +1 -1
  45. package/dist/client.js +5 -5
  46. package/dist/index.cjs +4 -1
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.js +9 -9
  49. package/dist/tools/codebase_search/anthropic.cjs +4 -1
  50. package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
  51. package/dist/tools/codebase_search/anthropic.js +2 -2
  52. package/dist/tools/codebase_search/core.cjs +4 -1
  53. package/dist/tools/codebase_search/core.cjs.map +1 -1
  54. package/dist/tools/codebase_search/core.js +1 -1
  55. package/dist/tools/codebase_search/index.cjs +4 -1
  56. package/dist/tools/codebase_search/index.cjs.map +1 -1
  57. package/dist/tools/codebase_search/index.js +6 -6
  58. package/dist/tools/codebase_search/openai.cjs +4 -1
  59. package/dist/tools/codebase_search/openai.cjs.map +1 -1
  60. package/dist/tools/codebase_search/openai.js +2 -2
  61. package/dist/tools/codebase_search/types.cjs.map +1 -1
  62. package/dist/tools/codebase_search/vercel.cjs +4 -1
  63. package/dist/tools/codebase_search/vercel.cjs.map +1 -1
  64. package/dist/tools/codebase_search/vercel.js +2 -2
  65. package/dist/tools/warp_grep/agent/config.cjs +41 -0
  66. package/dist/tools/warp_grep/agent/config.cjs.map +1 -0
  67. package/dist/tools/warp_grep/agent/config.js +12 -0
  68. package/dist/tools/warp_grep/agent/config.js.map +1 -0
  69. package/dist/tools/warp_grep/agent/formatter.cjs +106 -0
  70. package/dist/tools/warp_grep/agent/formatter.cjs.map +1 -0
  71. package/dist/tools/warp_grep/agent/formatter.js +10 -0
  72. package/dist/tools/warp_grep/agent/formatter.js.map +1 -0
  73. package/dist/tools/warp_grep/agent/grep_helpers.cjs +148 -0
  74. package/dist/tools/warp_grep/agent/grep_helpers.cjs.map +1 -0
  75. package/dist/tools/warp_grep/agent/grep_helpers.js +14 -0
  76. package/dist/tools/warp_grep/agent/grep_helpers.js.map +1 -0
  77. package/dist/tools/warp_grep/agent/parser.cjs +165 -0
  78. package/dist/tools/warp_grep/agent/parser.cjs.map +1 -0
  79. package/dist/tools/warp_grep/agent/parser.js +10 -0
  80. package/dist/tools/warp_grep/agent/parser.js.map +1 -0
  81. package/dist/tools/warp_grep/agent/prompt.cjs +110 -0
  82. package/dist/tools/warp_grep/agent/prompt.cjs.map +1 -0
  83. package/dist/tools/warp_grep/agent/prompt.js +10 -0
  84. package/dist/tools/warp_grep/agent/prompt.js.map +1 -0
  85. package/dist/tools/warp_grep/agent/runner.cjs +744 -0
  86. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -0
  87. package/dist/tools/warp_grep/agent/runner.js +17 -0
  88. package/dist/tools/warp_grep/agent/runner.js.map +1 -0
  89. package/dist/tools/warp_grep/agent/types.cjs +19 -0
  90. package/dist/tools/warp_grep/agent/types.cjs.map +1 -0
  91. package/dist/tools/warp_grep/agent/types.js +2 -0
  92. package/dist/tools/warp_grep/agent/types.js.map +1 -0
  93. package/dist/tools/warp_grep/anthropic.cjs +977 -0
  94. package/dist/tools/warp_grep/anthropic.cjs.map +1 -0
  95. package/dist/tools/warp_grep/anthropic.js +22 -0
  96. package/dist/tools/warp_grep/anthropic.js.map +1 -0
  97. package/dist/tools/warp_grep/index.cjs +1136 -0
  98. package/dist/tools/warp_grep/index.cjs.map +1 -0
  99. package/dist/tools/warp_grep/index.js +48 -0
  100. package/dist/tools/warp_grep/index.js.map +1 -0
  101. package/dist/tools/warp_grep/openai.cjs +980 -0
  102. package/dist/tools/warp_grep/openai.cjs.map +1 -0
  103. package/dist/tools/warp_grep/openai.js +22 -0
  104. package/dist/tools/warp_grep/openai.js.map +1 -0
  105. package/dist/tools/warp_grep/providers/command.cjs +98 -0
  106. package/dist/tools/warp_grep/providers/command.cjs.map +1 -0
  107. package/dist/tools/warp_grep/providers/command.js +9 -0
  108. package/dist/tools/warp_grep/providers/command.js.map +1 -0
  109. package/dist/tools/warp_grep/providers/local.cjs +232 -0
  110. package/dist/tools/warp_grep/providers/local.cjs.map +1 -0
  111. package/dist/tools/warp_grep/providers/local.js +12 -0
  112. package/dist/tools/warp_grep/providers/local.js.map +1 -0
  113. package/dist/tools/warp_grep/providers/types.cjs +19 -0
  114. package/dist/tools/warp_grep/providers/types.cjs.map +1 -0
  115. package/dist/tools/warp_grep/providers/types.js +1 -0
  116. package/dist/tools/warp_grep/providers/types.js.map +1 -0
  117. package/dist/tools/warp_grep/tools/analyse.cjs +40 -0
  118. package/dist/tools/warp_grep/tools/analyse.cjs.map +1 -0
  119. package/dist/tools/warp_grep/tools/analyse.js +8 -0
  120. package/dist/tools/warp_grep/tools/analyse.js.map +1 -0
  121. package/dist/tools/warp_grep/tools/finish.cjs +69 -0
  122. package/dist/tools/warp_grep/tools/finish.cjs.map +1 -0
  123. package/dist/tools/warp_grep/tools/finish.js +10 -0
  124. package/dist/tools/warp_grep/tools/finish.js.map +1 -0
  125. package/dist/tools/warp_grep/tools/grep.cjs +35 -0
  126. package/dist/tools/warp_grep/tools/grep.cjs.map +1 -0
  127. package/dist/tools/warp_grep/tools/grep.js +12 -0
  128. package/dist/tools/warp_grep/tools/grep.js.map +1 -0
  129. package/dist/tools/warp_grep/tools/read.cjs +34 -0
  130. package/dist/tools/warp_grep/tools/read.cjs.map +1 -0
  131. package/dist/tools/warp_grep/tools/read.js +8 -0
  132. package/dist/tools/warp_grep/tools/read.js.map +1 -0
  133. package/dist/tools/warp_grep/utils/files.cjs +45 -0
  134. package/dist/tools/warp_grep/utils/files.cjs.map +1 -0
  135. package/dist/tools/warp_grep/utils/files.js +8 -0
  136. package/dist/tools/warp_grep/utils/files.js.map +1 -0
  137. package/dist/tools/warp_grep/utils/format.cjs +42 -0
  138. package/dist/tools/warp_grep/utils/format.cjs.map +1 -0
  139. package/dist/tools/warp_grep/utils/format.js +18 -0
  140. package/dist/tools/warp_grep/utils/format.js.map +1 -0
  141. package/dist/tools/warp_grep/utils/paths.cjs +91 -0
  142. package/dist/tools/warp_grep/utils/paths.cjs.map +1 -0
  143. package/dist/tools/warp_grep/utils/paths.js +16 -0
  144. package/dist/tools/warp_grep/utils/paths.js.map +1 -0
  145. package/dist/tools/warp_grep/utils/ripgrep.cjs +50 -0
  146. package/dist/tools/warp_grep/utils/ripgrep.cjs.map +1 -0
  147. package/dist/tools/warp_grep/utils/ripgrep.js +8 -0
  148. package/dist/tools/warp_grep/utils/ripgrep.js.map +1 -0
  149. package/dist/tools/warp_grep/vercel.cjs +968 -0
  150. package/dist/tools/warp_grep/vercel.cjs.map +1 -0
  151. package/dist/tools/warp_grep/vercel.js +22 -0
  152. package/dist/tools/warp_grep/vercel.js.map +1 -0
  153. package/package.json +23 -3
  154. package/dist/anthropic-CknfcMoO.d.ts +0 -64
  155. package/dist/chunk-VJK4PH5V.js.map +0 -1
  156. package/dist/client.d.ts +0 -114
  157. package/dist/git/client.d.ts +0 -255
  158. package/dist/git/config.d.ts +0 -11
  159. package/dist/git/index.d.ts +0 -5
  160. package/dist/git/types.d.ts +0 -102
  161. package/dist/index.d.ts +0 -14
  162. package/dist/modelrouter/core.d.ts +0 -56
  163. package/dist/modelrouter/index.d.ts +0 -2
  164. package/dist/modelrouter/types.d.ts +0 -35
  165. package/dist/openai-BkKsS30n.d.ts +0 -111
  166. package/dist/tools/browser/anthropic.d.ts +0 -51
  167. package/dist/tools/browser/core.d.ts +0 -196
  168. package/dist/tools/browser/index.d.ts +0 -72
  169. package/dist/tools/browser/openai.d.ts +0 -69
  170. package/dist/tools/browser/prompts.d.ts +0 -7
  171. package/dist/tools/browser/types.d.ts +0 -227
  172. package/dist/tools/browser/vercel.d.ts +0 -69
  173. package/dist/tools/codebase_search/anthropic.d.ts +0 -40
  174. package/dist/tools/codebase_search/core.d.ts +0 -40
  175. package/dist/tools/codebase_search/index.d.ts +0 -10
  176. package/dist/tools/codebase_search/openai.d.ts +0 -87
  177. package/dist/tools/codebase_search/prompts.d.ts +0 -7
  178. package/dist/tools/codebase_search/types.d.ts +0 -46
  179. package/dist/tools/codebase_search/vercel.d.ts +0 -65
  180. package/dist/tools/fastapply/anthropic.d.ts +0 -4
  181. package/dist/tools/fastapply/core.d.ts +0 -41
  182. package/dist/tools/fastapply/index.d.ts +0 -10
  183. package/dist/tools/fastapply/openai.d.ts +0 -4
  184. package/dist/tools/fastapply/prompts.d.ts +0 -7
  185. package/dist/tools/fastapply/types.d.ts +0 -77
  186. package/dist/tools/fastapply/vercel.d.ts +0 -4
  187. package/dist/tools/index.d.ts +0 -10
  188. package/dist/tools/utils/resilience.d.ts +0 -58
  189. package/dist/vercel-B1GZ_g9N.d.ts +0 -69
  190. /package/dist/{chunk-BILUTNBC.js.map → chunk-4A7UBGLS.js.map} +0 -0
  191. /package/dist/{chunk-34F3D6JD.js.map → chunk-HWJN5AMA.js.map} +0 -0
  192. /package/dist/{chunk-WXBUVKYL.js.map → chunk-WHZQDTM6.js.map} +0 -0
  193. /package/dist/{chunk-YVGRWE7D.js.map → chunk-Y2IY7NYY.js.map} +0 -0
@@ -1,40 +0,0 @@
1
- import { CodebaseSearchResult, CodebaseSearchInput, CodebaseSearchConfig } from './types.js';
2
- import '../utils/resilience.js';
3
-
4
- /**
5
- * Core implementation for codebase search
6
- * Calls Morph rerank service for two-stage semantic search
7
- */
8
-
9
- /**
10
- * CodebaseSearch client for programmatic semantic search
11
- */
12
- declare class CodebaseSearchClient {
13
- private config;
14
- constructor(config?: {
15
- apiKey?: string;
16
- debug?: boolean;
17
- timeout?: number;
18
- retryConfig?: any;
19
- });
20
- /**
21
- * Execute a semantic code search
22
- *
23
- * @param input - Search parameters including query, repoId, and target directories
24
- * @param overrides - Optional config overrides for this operation
25
- * @returns Search results with ranked code matches
26
- */
27
- search(input: {
28
- query: string;
29
- repoId: string;
30
- target_directories?: string[];
31
- explanation?: string;
32
- limit?: number;
33
- }, overrides?: any): Promise<CodebaseSearchResult>;
34
- }
35
- /**
36
- * Execute semantic code search
37
- */
38
- declare function executeCodebaseSearch(input: CodebaseSearchInput, config: CodebaseSearchConfig): Promise<CodebaseSearchResult>;
39
-
40
- export { CodebaseSearchClient, executeCodebaseSearch };
@@ -1,10 +0,0 @@
1
- export { executeCodebaseSearch } from './core.js';
2
- export { CODEBASE_SEARCH_DESCRIPTION, CODEBASE_SEARCH_SYSTEM_PROMPT } from './prompts.js';
3
- export { CodeSearchResult, CodebaseSearchConfig, CodebaseSearchInput, CodebaseSearchResult, SearchStats } from './types.js';
4
- export { createCodebaseSearchTool as anthropicCodebaseSearchTool } from './anthropic.js';
5
- export { createCodebaseSearchTool as openaiCodebaseSearchTool } from './openai.js';
6
- export { createCodebaseSearchTool as vercelCodebaseSearchTool } from './vercel.js';
7
- import '../utils/resilience.js';
8
- import '@anthropic-ai/sdk/resources/messages';
9
- import 'openai/resources/chat/completions';
10
- import 'ai';
@@ -1,87 +0,0 @@
1
- import { ChatCompletionTool } from 'openai/resources/chat/completions';
2
- import { CodebaseSearchConfig, CodebaseSearchInput, CodebaseSearchResult } from './types.js';
3
- import '../utils/resilience.js';
4
-
5
- /**
6
- * OpenAI SDK adapter for codebase_search tool
7
- */
8
-
9
- /**
10
- * Direct codebase_search tool definition
11
- * Use this when you want to pass config at execute time
12
- */
13
- declare const codebaseSearchTool: ChatCompletionTool;
14
- /**
15
- * Create OpenAI-native codebase_search tool with execute and formatResult methods
16
- *
17
- * @param config - Configuration with repoId
18
- * @returns OpenAI ChatCompletionTool definition with methods
19
- *
20
- * @example
21
- * ```ts
22
- * import OpenAI from 'openai';
23
- * import { createCodebaseSearchTool } from 'morphsdk/tools/openai';
24
- *
25
- * const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
26
- * const tool = createCodebaseSearchTool({ repoId: 'my-project' });
27
- *
28
- * const response = await client.chat.completions.create({
29
- * model: "gpt-4o",
30
- * tools: [tool], // tool itself is the ChatCompletionTool
31
- * messages: [{ role: "user", content: "Find authentication code" }]
32
- * });
33
- *
34
- * // Execute and format
35
- * const result = await tool.execute(toolCallArgs);
36
- * const formatted = tool.formatResult(result);
37
- * ```
38
- */
39
- declare function createCodebaseSearchTool(config: CodebaseSearchConfig): ChatCompletionTool & {
40
- execute: (input: CodebaseSearchInput | string) => Promise<CodebaseSearchResult>;
41
- formatResult: (result: CodebaseSearchResult) => string;
42
- getSystemPrompt: () => string;
43
- };
44
- /**
45
- * Execute codebase_search tool call
46
- *
47
- * @param input - Tool input from GPT (parsed from tool_calls)
48
- * @param config - Configuration with repoId (REQUIRED)
49
- * @returns Search results
50
- *
51
- * @example
52
- * ```ts
53
- * // Handle tool calls from GPT:
54
- * if (response.choices[0].message.tool_calls) {
55
- * for (const toolCall of response.choices[0].message.tool_calls) {
56
- * const args = JSON.parse(toolCall.function.arguments);
57
- * const result = await execute(args, { repoId: 'my-project' });
58
- * console.log(`Found ${result.results.length} matches`);
59
- * }
60
- * }
61
- * ```
62
- */
63
- declare function execute(input: CodebaseSearchInput, config: CodebaseSearchConfig): Promise<CodebaseSearchResult>;
64
- /**
65
- * Format search results for GPT
66
- *
67
- * @param result - Search result from endpoint
68
- * @returns Formatted string for tool message
69
- */
70
- declare function formatResult(result: CodebaseSearchResult): string;
71
- /**
72
- * Get the system prompt for codebase_search usage
73
- *
74
- * @returns System prompt to guide GPT
75
- */
76
- declare function getSystemPrompt(): string;
77
- /**
78
- * Default export for convenience
79
- */
80
- declare const _default: {
81
- createCodebaseSearchTool: typeof createCodebaseSearchTool;
82
- execute: typeof execute;
83
- formatResult: typeof formatResult;
84
- getSystemPrompt: typeof getSystemPrompt;
85
- };
86
-
87
- export { codebaseSearchTool, createCodebaseSearchTool, _default as default, execute, formatResult, getSystemPrompt };
@@ -1,7 +0,0 @@
1
- /**
2
- * Tool descriptions and system prompts for codebase search
3
- */
4
- declare const CODEBASE_SEARCH_DESCRIPTION = "Semantic search that finds code by meaning, not exact text.\n\nUse this to explore unfamiliar codebases or ask \"how/where/what\" questions:\n- \"How does X work?\" - Find implementation details\n- \"Where is Y handled?\" - Locate specific functionality\n- \"What happens when Z?\" - Understand flow\n\nThe tool uses two-stage retrieval (embedding similarity + reranking) to find the most semantically relevant code chunks.\n\nReturns code chunks with file paths, line ranges, and full content ranked by relevance.";
5
- declare const CODEBASE_SEARCH_SYSTEM_PROMPT = "You have access to the codebase_search tool that performs semantic code search.\n\nWhen searching:\n- Use natural language queries describing what you're looking for\n- Be specific about functionality, not variable names\n- Use target_directories to narrow search if you know the area\n- Results are ranked by relevance (rerank score is most important)\n\nThe tool returns:\n- File paths with symbol names (e.g. \"src/auth.ts::AuthService@L1-L17\")\n- Line ranges for precise navigation\n- Full code content for each match\n- Dual relevance scores: embedding similarity + rerank score\n\nUse results to understand code or answer questions. The content is provided in full - avoid re-reading unless you need more context.";
6
-
7
- export { CODEBASE_SEARCH_DESCRIPTION, CODEBASE_SEARCH_SYSTEM_PROMPT };
@@ -1,46 +0,0 @@
1
- import { RetryConfig } from '../utils/resilience.js';
2
-
3
- /**
4
- * Type definitions for codebase search tool
5
- */
6
-
7
- interface CodebaseSearchConfig {
8
- repoId: string;
9
- searchUrl?: string;
10
- apiKey?: string;
11
- /** Timeout for search requests in ms (default: 30000) */
12
- timeout?: number;
13
- /** Retry configuration for API calls */
14
- retryConfig?: RetryConfig;
15
- /** Enable debug logging (default: false) */
16
- debug?: boolean;
17
- }
18
- interface CodebaseSearchInput {
19
- query: string;
20
- target_directories?: string[];
21
- explanation?: string;
22
- limit?: number;
23
- }
24
- interface CodeSearchResult {
25
- filepath: string;
26
- symbolPath: string;
27
- content: string;
28
- language: string;
29
- startLine: number;
30
- endLine: number;
31
- embeddingSimilarity: number;
32
- rerankScore: number;
33
- }
34
- interface SearchStats {
35
- totalResults: number;
36
- candidatesRetrieved: number;
37
- searchTimeMs: number;
38
- }
39
- interface CodebaseSearchResult {
40
- success: boolean;
41
- results: CodeSearchResult[];
42
- stats: SearchStats;
43
- error?: string;
44
- }
45
-
46
- export type { CodeSearchResult, CodebaseSearchConfig, CodebaseSearchInput, CodebaseSearchResult, SearchStats };
@@ -1,65 +0,0 @@
1
- import * as ai from 'ai';
2
- import { CodebaseSearchConfig } from './types.js';
3
- import '../utils/resilience.js';
4
-
5
- /**
6
- * Create Vercel AI SDK codebase_search tool
7
- *
8
- * @param config - Configuration with repoId
9
- * @returns Vercel AI SDK tool definition (execution built-in)
10
- *
11
- * @example
12
- * ```ts
13
- * import { generateText } from 'ai';
14
- * import { anthropic } from '@ai-sdk/anthropic';
15
- * import { createCodebaseSearchTool } from 'morphsdk/tools/codebase-search/vercel';
16
- *
17
- * const tool = createCodebaseSearchTool({ repoId: 'my-project' });
18
- *
19
- * const result = await generateText({
20
- * model: anthropic('claude-3-5-sonnet-20241022'),
21
- * tools: { codebaseSearch: tool },
22
- * prompt: "Find authentication code",
23
- * maxSteps: 5
24
- * });
25
- *
26
- * // Vercel AI SDK automatically executes and handles results
27
- * console.log(result.text);
28
- * ```
29
- */
30
- declare function createCodebaseSearchTool(config: CodebaseSearchConfig): ai.Tool<{
31
- query: string;
32
- target_directories: string[];
33
- explanation: string;
34
- limit?: number | undefined;
35
- }, {
36
- error: string | undefined;
37
- results: never[];
38
- found?: undefined;
39
- searchTime?: undefined;
40
- } | {
41
- found: number;
42
- searchTime: string;
43
- results: {
44
- file: string;
45
- symbol: string;
46
- lines: string;
47
- language: string;
48
- relevance: string;
49
- code: string;
50
- }[];
51
- error?: undefined;
52
- }>;
53
- /**
54
- * Get system prompt for Vercel AI SDK
55
- */
56
- declare function getSystemPrompt(): string;
57
- /**
58
- * Default export
59
- */
60
- declare const _default: {
61
- createCodebaseSearchTool: typeof createCodebaseSearchTool;
62
- getSystemPrompt: typeof getSystemPrompt;
63
- };
64
-
65
- export { createCodebaseSearchTool, _default as default, getSystemPrompt };
@@ -1,4 +0,0 @@
1
- import '@anthropic-ai/sdk/resources/messages';
2
- import './types.js';
3
- export { c as createEditFileTool, e as editFileTool } from '../../anthropic-CknfcMoO.js';
4
- import '../utils/resilience.js';
@@ -1,41 +0,0 @@
1
- import { EditFileInput, EditFileConfig, EditFileResult, EditChanges } from './types.js';
2
- import '../utils/resilience.js';
3
-
4
- /**
5
- * Core implementation of Morph Fast Apply
6
- */
7
-
8
- /**
9
- * FastApply client for programmatic file editing
10
- */
11
- declare class FastApplyClient {
12
- private config;
13
- constructor(config?: {
14
- apiKey?: string;
15
- debug?: boolean;
16
- timeout?: number;
17
- retryConfig?: any;
18
- });
19
- /**
20
- * Execute a file edit operation
21
- *
22
- * @param input - Edit parameters including filepath, instructions, and code_edit
23
- * @param overrides - Optional config overrides for this operation
24
- * @returns Edit result with success status and changes
25
- */
26
- execute(input: EditFileInput, overrides?: Partial<EditFileConfig>): Promise<EditFileResult>;
27
- }
28
- /**
29
- * Generate a unified diff between two strings
30
- */
31
- declare function generateUdiff(original: string, modified: string, filepath: string): string;
32
- /**
33
- * Count changes from a unified diff
34
- */
35
- declare function countChanges(original: string, modified: string): EditChanges;
36
- /**
37
- * Execute a file edit using Morph Fast Apply
38
- */
39
- declare function executeEditFile(input: EditFileInput, config?: EditFileConfig): Promise<EditFileResult>;
40
-
41
- export { FastApplyClient, countChanges, executeEditFile, generateUdiff };
@@ -1,10 +0,0 @@
1
- export { countChanges, executeEditFile, generateUdiff } from './core.js';
2
- export { EditChanges, EditFileConfig, EditFileInput, EditFileResult } from './types.js';
3
- export { EDIT_FILE_SYSTEM_PROMPT, EDIT_FILE_TOOL_DESCRIPTION } from './prompts.js';
4
- export { a as anthropic } from '../../anthropic-CknfcMoO.js';
5
- export { o as openai } from '../../openai-BkKsS30n.js';
6
- export { v as vercel } from '../../vercel-B1GZ_g9N.js';
7
- import '../utils/resilience.js';
8
- import '@anthropic-ai/sdk/resources/messages';
9
- import 'openai/resources/chat/completions';
10
- import 'ai';
@@ -1,4 +0,0 @@
1
- import 'openai/resources/chat/completions';
2
- import './types.js';
3
- export { c as createEditFileTool, e as default, e as editFileTool, a as execute, f as formatResult, g as getSystemPrompt } from '../../openai-BkKsS30n.js';
4
- import '../utils/resilience.js';
@@ -1,7 +0,0 @@
1
- /**
2
- * System prompts for edit_file tool
3
- */
4
- declare const EDIT_FILE_TOOL_DESCRIPTION = "Use this tool to make an edit to an existing file.\n\nThis will be read by a less intelligent model, which will quickly apply the edit. You should make it clear what the edit is, while also minimizing the unchanged code you write.\n\nWhen writing the edit, you should specify each edit in sequence, with the special comment // ... existing code ... to represent unchanged code in between edited lines.\n\nFor example:\n\n// ... existing code ...\nFIRST_EDIT\n// ... existing code ...\nSECOND_EDIT\n// ... existing code ...\nTHIRD_EDIT\n// ... existing code ...\n\nYou should still bias towards repeating as few lines of the original file as possible to convey the change.\nBut, each edit should contain minimally sufficient context of unchanged lines around the code you're editing to resolve ambiguity.\n\nDO NOT omit spans of pre-existing code (or comments) without using the // ... existing code ... comment to indicate its absence. If you omit the existing code comment, the model may inadvertently delete these lines.\n\nIf you plan on deleting a section, you must provide context before and after to delete it.\n\nMake sure it is clear what the edit should be, and where it should be applied.\nMake edits to a file in a single edit_file call instead of multiple edit_file calls to the same file. The apply model can handle many distinct edits at once.";
5
- declare const EDIT_FILE_SYSTEM_PROMPT = "When the user is asking for edits to their code, use the edit_file tool to highlight the changes necessary and add comments to indicate where unchanged code has been skipped. For example:\n\n// ... existing code ...\n{{ edit_1 }}\n// ... existing code ...\n{{ edit_2 }}\n// ... existing code ...\n\nOften this will mean that the start/end of the file will be skipped, but that's okay! Rewrite the entire file ONLY if specifically requested. Always provide a brief explanation of the updates, unless the user specifically requests only the code.\n\nThese edit codeblocks are also read by a less intelligent language model, colloquially called the apply model, to update the file. To help specify the edit to the apply model, you will be very careful when generating the codeblock to not introduce ambiguity. You will specify all unchanged regions (code and comments) of the file with \"// ... existing code ...\" comment markers. This will ensure the apply model will not delete existing unchanged code or comments when editing the file.";
6
-
7
- export { EDIT_FILE_SYSTEM_PROMPT, EDIT_FILE_TOOL_DESCRIPTION };
@@ -1,77 +0,0 @@
1
- import { RetryConfig } from '../utils/resilience.js';
2
-
3
- /**
4
- * Core types for Morph Fast Apply SDK
5
- */
6
-
7
- /**
8
- * Input parameters for the edit_file tool
9
- */
10
- interface EditFileInput {
11
- /** Path to the file to edit (relative to baseDir) */
12
- target_filepath: string;
13
- /** First-person description of what you're changing */
14
- instructions: string;
15
- /** Lazy edit with // ... existing code ... markers */
16
- code_edit: string;
17
- }
18
- /**
19
- * Statistics about the changes made
20
- */
21
- interface EditChanges {
22
- linesAdded: number;
23
- linesRemoved: number;
24
- linesModified: number;
25
- }
26
- /**
27
- * Result returned after executing an edit
28
- */
29
- interface EditFileResult {
30
- /** Whether the edit was successful */
31
- success: boolean;
32
- /** Path to the edited file */
33
- filepath: string;
34
- /** Universal diff format showing changes */
35
- udiff?: string;
36
- /** Statistics about the changes */
37
- changes: EditChanges;
38
- /** Error message if unsuccessful */
39
- error?: string;
40
- }
41
- /**
42
- * Configuration options for the edit_file tool
43
- */
44
- interface EditFileConfig {
45
- /** Morph API key (defaults to MORPH_API_KEY env var) */
46
- morphApiKey?: string;
47
- /** Morph API base URL */
48
- morphApiUrl?: string;
49
- /** Base directory for file operations (defaults to cwd) */
50
- baseDir?: string;
51
- /** Whether to generate udiff (default: true) */
52
- generateUdiff?: boolean;
53
- /** Whether to automatically write to file (default: true) */
54
- autoWrite?: boolean;
55
- /** Custom system prompt (null to disable) */
56
- systemPrompt?: string | null;
57
- /** Custom tool description (defaults to EDIT_FILE_TOOL_DESCRIPTION) */
58
- description?: string;
59
- /** Timeout for API calls in ms (default: 30000) */
60
- timeout?: number;
61
- /** Retry configuration for API calls */
62
- retryConfig?: RetryConfig;
63
- /** Enable debug logging (default: false) */
64
- debug?: boolean;
65
- }
66
- /**
67
- * Response from Morph Apply API
68
- */
69
- interface MorphApplyResponse {
70
- choices: Array<{
71
- message: {
72
- content: string;
73
- };
74
- }>;
75
- }
76
-
77
- export type { EditChanges, EditFileConfig, EditFileInput, EditFileResult, MorphApplyResponse };
@@ -1,4 +0,0 @@
1
- import 'ai';
2
- import './types.js';
3
- export { c as createEditFileTool, e as default, e as editFileTool, g as getSystemPrompt } from '../../vercel-B1GZ_g9N.js';
4
- import '../utils/resilience.js';
@@ -1,10 +0,0 @@
1
- export { countChanges, executeEditFile, generateUdiff } from './fastapply/core.js';
2
- export { EditChanges, EditFileConfig, EditFileInput, EditFileResult } from './fastapply/types.js';
3
- export { EDIT_FILE_SYSTEM_PROMPT, EDIT_FILE_TOOL_DESCRIPTION } from './fastapply/prompts.js';
4
- export { a as anthropic } from '../anthropic-CknfcMoO.js';
5
- export { o as openai } from '../openai-BkKsS30n.js';
6
- export { v as vercel } from '../vercel-B1GZ_g9N.js';
7
- import './utils/resilience.js';
8
- import '@anthropic-ai/sdk/resources/messages';
9
- import 'openai/resources/chat/completions';
10
- import 'ai';
@@ -1,58 +0,0 @@
1
- /**
2
- * Resilience utilities for retry logic and timeout handling
3
- */
4
- interface RetryConfig {
5
- maxRetries?: number;
6
- initialDelay?: number;
7
- maxDelay?: number;
8
- backoffMultiplier?: number;
9
- retryableErrors?: string[];
10
- onRetry?: (attempt: number, error: Error) => void;
11
- }
12
- /**
13
- * Retry a fetch request with exponential backoff
14
- *
15
- * @param url - Request URL
16
- * @param options - Fetch options
17
- * @param retryConfig - Retry configuration
18
- * @returns Response from fetch
19
- *
20
- * @example
21
- * ```typescript
22
- * const response = await fetchWithRetry(
23
- * 'https://api.example.com/data',
24
- * { method: 'POST', body: JSON.stringify(data) },
25
- * { maxRetries: 5, initialDelay: 500 }
26
- * );
27
- * ```
28
- */
29
- declare function fetchWithRetry(url: string, options: RequestInit, retryConfig?: RetryConfig): Promise<Response>;
30
- /**
31
- * Add timeout to any promise
32
- *
33
- * @param promise - Promise to wrap with timeout
34
- * @param timeoutMs - Timeout in milliseconds
35
- * @param errorMessage - Optional custom error message
36
- * @returns Promise that rejects if timeout is reached
37
- *
38
- * @example
39
- * ```typescript
40
- * const result = await withTimeout(
41
- * fetchData(),
42
- * 5000,
43
- * 'Data fetch timed out'
44
- * );
45
- * ```
46
- */
47
- declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, errorMessage?: string): Promise<T>;
48
- /**
49
- * Unified error type for all tools
50
- */
51
- declare class MorphError extends Error {
52
- code: string;
53
- statusCode?: number | undefined;
54
- retryable: boolean;
55
- constructor(message: string, code: string, statusCode?: number | undefined, retryable?: boolean);
56
- }
57
-
58
- export { MorphError, type RetryConfig, fetchWithRetry, withTimeout };
@@ -1,69 +0,0 @@
1
- import * as ai from 'ai';
2
- import { EditChanges, EditFileConfig } from './tools/fastapply/types.js';
3
-
4
- declare const editFileTool: ai.Tool<{
5
- target_filepath: string;
6
- instructions: string;
7
- code_edit: string;
8
- }, {
9
- success: boolean;
10
- filepath: string;
11
- changes: EditChanges;
12
- udiff: string | undefined;
13
- }>;
14
- /**
15
- * Get the system prompt for edit_file usage
16
- *
17
- * Add this to your system message to guide the model on using edit_file properly.
18
- *
19
- * @example
20
- * ```ts
21
- * const result = await generateText({
22
- * model: anthropic('claude-sonnet-4-5-20250929'),
23
- * system: getSystemPrompt(),
24
- * tools: { editFile: editFileTool },
25
- * prompt: "Fix bugs"
26
- * });
27
- * ```
28
- */
29
- declare function getSystemPrompt(): string;
30
- /**
31
- * Create a custom edit_file tool with configuration
32
- *
33
- * @param config - Configuration options
34
- * @returns Vercel AI SDK tool with custom config
35
- *
36
- * @example
37
- * ```ts
38
- * const customEditTool = createEditFileTool({
39
- * baseDir: './src',
40
- * generateUdiff: true,
41
- * description: 'Custom tool description for your use case'
42
- * });
43
- *
44
- * const result = await generateText({
45
- * model: anthropic('claude-sonnet-4-5-20250929'),
46
- * tools: { editFile: customEditTool },
47
- * prompt: "Fix bugs"
48
- * });
49
- * ```
50
- */
51
- declare function createEditFileTool(config?: EditFileConfig): ai.Tool<{
52
- target_filepath: string;
53
- instructions: string;
54
- code_edit: string;
55
- }, {
56
- success: boolean;
57
- filepath: string;
58
- changes: EditChanges;
59
- udiff: string | undefined;
60
- }>;
61
-
62
- declare const vercel_createEditFileTool: typeof createEditFileTool;
63
- declare const vercel_editFileTool: typeof editFileTool;
64
- declare const vercel_getSystemPrompt: typeof getSystemPrompt;
65
- declare namespace vercel {
66
- export { vercel_createEditFileTool as createEditFileTool, editFileTool as default, vercel_editFileTool as editFileTool, vercel_getSystemPrompt as getSystemPrompt };
67
- }
68
-
69
- export { createEditFileTool as c, editFileTool as e, getSystemPrompt as g, vercel as v };