@morphllm/morphsdk 0.2.21 → 0.2.22
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-DF2ZOO7R.js → chunk-5VQEQSJQ.js} +3 -52
- package/dist/chunk-5VQEQSJQ.js.map +1 -0
- package/dist/chunk-73RQWOQC.js +16 -0
- package/dist/chunk-73RQWOQC.js.map +1 -0
- package/dist/{chunk-2DXRTGRH.js → chunk-74ZHKB54.js} +1 -1
- package/dist/{chunk-2DXRTGRH.js.map → chunk-74ZHKB54.js.map} +1 -1
- package/dist/chunk-AFEPUNAO.js +15 -0
- package/dist/chunk-AFEPUNAO.js.map +1 -0
- package/dist/chunk-EAA7D24N.js +201 -0
- package/dist/chunk-EAA7D24N.js.map +1 -0
- package/dist/chunk-EK7OQPWD.js +44 -0
- package/dist/chunk-EK7OQPWD.js.map +1 -0
- package/dist/chunk-FSVBNZMU.js +44 -0
- package/dist/chunk-FSVBNZMU.js.map +1 -0
- package/dist/chunk-G2RSY56Q.js +11 -0
- package/dist/chunk-G2RSY56Q.js.map +1 -0
- package/dist/chunk-GTOXMAF2.js +140 -0
- package/dist/chunk-GTOXMAF2.js.map +1 -0
- package/dist/chunk-HKZB23U7.js +85 -0
- package/dist/chunk-HKZB23U7.js.map +1 -0
- package/dist/chunk-JZGU5UC6.js +53 -0
- package/dist/chunk-JZGU5UC6.js.map +1 -0
- package/dist/chunk-NDZO5IPV.js +121 -0
- package/dist/chunk-NDZO5IPV.js.map +1 -0
- package/dist/{chunk-34F3D6JD.js → chunk-NSQGPBMU.js} +9 -9
- package/dist/chunk-RSLIOCOE.js +26 -0
- package/dist/chunk-RSLIOCOE.js.map +1 -0
- package/dist/chunk-SMGZ6A64.js +53 -0
- package/dist/chunk-SMGZ6A64.js.map +1 -0
- package/dist/chunk-TICMYDII.js +81 -0
- package/dist/chunk-TICMYDII.js.map +1 -0
- package/dist/chunk-UYBIKZPM.js +135 -0
- package/dist/chunk-UYBIKZPM.js.map +1 -0
- package/dist/chunk-VBBJGWHY.js +73 -0
- package/dist/chunk-VBBJGWHY.js.map +1 -0
- package/dist/chunk-XQLKK2ZH.js +56 -0
- package/dist/chunk-XQLKK2ZH.js.map +1 -0
- package/dist/chunk-XYPMN4A3.js +1 -0
- package/dist/chunk-XYPMN4A3.js.map +1 -0
- package/dist/chunk-Z2FBMSNE.js +10 -0
- package/dist/chunk-Z2FBMSNE.js.map +1 -0
- package/dist/client.cjs +2 -51
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +4 -4
- package/dist/git/client.cjs +2 -51
- package/dist/git/client.cjs.map +1 -1
- package/dist/git/client.js +1 -1
- package/dist/git/index.cjs +2 -51
- package/dist/git/index.cjs.map +1 -1
- package/dist/git/index.js +2 -2
- package/dist/git/types.cjs.map +1 -1
- package/dist/index.cjs +2 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -10
- package/dist/tools/warp_grep/agent/config.cjs +41 -0
- package/dist/tools/warp_grep/agent/config.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/config.js +12 -0
- package/dist/tools/warp_grep/agent/config.js.map +1 -0
- package/dist/tools/warp_grep/agent/formatter.cjs +106 -0
- package/dist/tools/warp_grep/agent/formatter.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/formatter.js +10 -0
- package/dist/tools/warp_grep/agent/formatter.js.map +1 -0
- package/dist/tools/warp_grep/agent/grep_helpers.cjs +148 -0
- package/dist/tools/warp_grep/agent/grep_helpers.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/grep_helpers.js +14 -0
- package/dist/tools/warp_grep/agent/grep_helpers.js.map +1 -0
- package/dist/tools/warp_grep/agent/parser.cjs +165 -0
- package/dist/tools/warp_grep/agent/parser.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/parser.js +10 -0
- package/dist/tools/warp_grep/agent/parser.js.map +1 -0
- package/dist/tools/warp_grep/agent/prompt.cjs +110 -0
- package/dist/tools/warp_grep/agent/prompt.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/prompt.js +10 -0
- package/dist/tools/warp_grep/agent/prompt.js.map +1 -0
- package/dist/tools/warp_grep/agent/runner.cjs +744 -0
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/runner.js +17 -0
- package/dist/tools/warp_grep/agent/runner.js.map +1 -0
- package/dist/tools/warp_grep/agent/types.cjs +19 -0
- package/dist/tools/warp_grep/agent/types.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/types.js +2 -0
- package/dist/tools/warp_grep/agent/types.js.map +1 -0
- package/dist/tools/warp_grep/anthropic.cjs +977 -0
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -0
- package/dist/tools/warp_grep/anthropic.js +22 -0
- package/dist/tools/warp_grep/anthropic.js.map +1 -0
- package/dist/tools/warp_grep/index.cjs +1136 -0
- package/dist/tools/warp_grep/index.cjs.map +1 -0
- package/dist/tools/warp_grep/index.js +48 -0
- package/dist/tools/warp_grep/index.js.map +1 -0
- package/dist/tools/warp_grep/openai.cjs +980 -0
- package/dist/tools/warp_grep/openai.cjs.map +1 -0
- package/dist/tools/warp_grep/openai.js +22 -0
- package/dist/tools/warp_grep/openai.js.map +1 -0
- package/dist/tools/warp_grep/providers/command.cjs +98 -0
- package/dist/tools/warp_grep/providers/command.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/command.js +9 -0
- package/dist/tools/warp_grep/providers/command.js.map +1 -0
- package/dist/tools/warp_grep/providers/local.cjs +232 -0
- package/dist/tools/warp_grep/providers/local.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/local.js +12 -0
- package/dist/tools/warp_grep/providers/local.js.map +1 -0
- package/dist/tools/warp_grep/providers/types.cjs +19 -0
- package/dist/tools/warp_grep/providers/types.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/types.js +1 -0
- package/dist/tools/warp_grep/providers/types.js.map +1 -0
- package/dist/tools/warp_grep/tools/analyse.cjs +40 -0
- package/dist/tools/warp_grep/tools/analyse.cjs.map +1 -0
- package/dist/tools/warp_grep/tools/analyse.js +8 -0
- package/dist/tools/warp_grep/tools/analyse.js.map +1 -0
- package/dist/tools/warp_grep/tools/finish.cjs +69 -0
- package/dist/tools/warp_grep/tools/finish.cjs.map +1 -0
- package/dist/tools/warp_grep/tools/finish.js +10 -0
- package/dist/tools/warp_grep/tools/finish.js.map +1 -0
- package/dist/tools/warp_grep/tools/grep.cjs +35 -0
- package/dist/tools/warp_grep/tools/grep.cjs.map +1 -0
- package/dist/tools/warp_grep/tools/grep.js +12 -0
- package/dist/tools/warp_grep/tools/grep.js.map +1 -0
- package/dist/tools/warp_grep/tools/read.cjs +34 -0
- package/dist/tools/warp_grep/tools/read.cjs.map +1 -0
- package/dist/tools/warp_grep/tools/read.js +8 -0
- package/dist/tools/warp_grep/tools/read.js.map +1 -0
- package/dist/tools/warp_grep/utils/files.cjs +45 -0
- package/dist/tools/warp_grep/utils/files.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/files.js +8 -0
- package/dist/tools/warp_grep/utils/files.js.map +1 -0
- package/dist/tools/warp_grep/utils/format.cjs +42 -0
- package/dist/tools/warp_grep/utils/format.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/format.js +18 -0
- package/dist/tools/warp_grep/utils/format.js.map +1 -0
- package/dist/tools/warp_grep/utils/paths.cjs +91 -0
- package/dist/tools/warp_grep/utils/paths.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/paths.js +16 -0
- package/dist/tools/warp_grep/utils/paths.js.map +1 -0
- package/dist/tools/warp_grep/utils/ripgrep.cjs +50 -0
- package/dist/tools/warp_grep/utils/ripgrep.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/ripgrep.js +8 -0
- package/dist/tools/warp_grep/utils/ripgrep.js.map +1 -0
- package/dist/tools/warp_grep/vercel.cjs +968 -0
- package/dist/tools/warp_grep/vercel.cjs.map +1 -0
- package/dist/tools/warp_grep/vercel.js +22 -0
- package/dist/tools/warp_grep/vercel.js.map +1 -0
- package/package.json +23 -3
- package/dist/anthropic-CknfcMoO.d.ts +0 -64
- package/dist/chunk-DF2ZOO7R.js.map +0 -1
- package/dist/client.d.ts +0 -114
- package/dist/git/client.d.ts +0 -255
- package/dist/git/config.d.ts +0 -11
- package/dist/git/index.d.ts +0 -5
- package/dist/git/types.d.ts +0 -102
- package/dist/index.d.ts +0 -14
- package/dist/modelrouter/core.d.ts +0 -56
- package/dist/modelrouter/index.d.ts +0 -2
- package/dist/modelrouter/types.d.ts +0 -35
- package/dist/openai-BkKsS30n.d.ts +0 -111
- package/dist/tools/browser/anthropic.d.ts +0 -51
- package/dist/tools/browser/core.d.ts +0 -196
- package/dist/tools/browser/index.d.ts +0 -72
- package/dist/tools/browser/openai.d.ts +0 -69
- package/dist/tools/browser/prompts.d.ts +0 -7
- package/dist/tools/browser/types.d.ts +0 -227
- package/dist/tools/browser/vercel.d.ts +0 -69
- package/dist/tools/codebase_search/anthropic.d.ts +0 -40
- package/dist/tools/codebase_search/core.d.ts +0 -40
- package/dist/tools/codebase_search/index.d.ts +0 -10
- package/dist/tools/codebase_search/openai.d.ts +0 -87
- package/dist/tools/codebase_search/prompts.d.ts +0 -7
- package/dist/tools/codebase_search/types.d.ts +0 -46
- package/dist/tools/codebase_search/vercel.d.ts +0 -65
- package/dist/tools/fastapply/anthropic.d.ts +0 -4
- package/dist/tools/fastapply/core.d.ts +0 -41
- package/dist/tools/fastapply/index.d.ts +0 -10
- package/dist/tools/fastapply/openai.d.ts +0 -4
- package/dist/tools/fastapply/prompts.d.ts +0 -7
- package/dist/tools/fastapply/types.d.ts +0 -77
- package/dist/tools/fastapply/vercel.d.ts +0 -4
- package/dist/tools/index.d.ts +0 -10
- package/dist/tools/utils/resilience.d.ts +0 -58
- package/dist/vercel-B1GZ_g9N.d.ts +0 -69
- /package/dist/{chunk-34F3D6JD.js.map → chunk-NSQGPBMU.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,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,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 };
|
package/dist/tools/index.d.ts
DELETED
|
@@ -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 };
|
|
File without changes
|