@morphllm/morphsdk 0.2.6

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 (168) hide show
  1. package/README.md +39 -0
  2. package/dist/chunk-4UVEBIDK.js +358 -0
  3. package/dist/chunk-4UVEBIDK.js.map +1 -0
  4. package/dist/chunk-4V46N27D.js +169 -0
  5. package/dist/chunk-4V46N27D.js.map +1 -0
  6. package/dist/chunk-4VWJFZVS.js +89 -0
  7. package/dist/chunk-4VWJFZVS.js.map +1 -0
  8. package/dist/chunk-5COKN3XD.js +91 -0
  9. package/dist/chunk-5COKN3XD.js.map +1 -0
  10. package/dist/chunk-5VQEQSJQ.js +394 -0
  11. package/dist/chunk-5VQEQSJQ.js.map +1 -0
  12. package/dist/chunk-63WE2C5R.js +43 -0
  13. package/dist/chunk-63WE2C5R.js.map +1 -0
  14. package/dist/chunk-74ZHKB54.js +9 -0
  15. package/dist/chunk-74ZHKB54.js.map +1 -0
  16. package/dist/chunk-7PZJQFCY.js +39 -0
  17. package/dist/chunk-7PZJQFCY.js.map +1 -0
  18. package/dist/chunk-BILUTNBC.js +83 -0
  19. package/dist/chunk-BILUTNBC.js.map +1 -0
  20. package/dist/chunk-G4DJ6VSM.js +78 -0
  21. package/dist/chunk-G4DJ6VSM.js.map +1 -0
  22. package/dist/chunk-HGIFACNP.js +59 -0
  23. package/dist/chunk-HGIFACNP.js.map +1 -0
  24. package/dist/chunk-OI5YYE36.js +189 -0
  25. package/dist/chunk-OI5YYE36.js.map +1 -0
  26. package/dist/chunk-PZ5AY32C.js +10 -0
  27. package/dist/chunk-PZ5AY32C.js.map +1 -0
  28. package/dist/chunk-VJK4PH5V.js +105 -0
  29. package/dist/chunk-VJK4PH5V.js.map +1 -0
  30. package/dist/chunk-WXBUVKYL.js +128 -0
  31. package/dist/chunk-WXBUVKYL.js.map +1 -0
  32. package/dist/chunk-X2K57BH6.js +1 -0
  33. package/dist/chunk-X2K57BH6.js.map +1 -0
  34. package/dist/chunk-YQMPVJ2L.js +32 -0
  35. package/dist/chunk-YQMPVJ2L.js.map +1 -0
  36. package/dist/chunk-YWS2GRQC.js +97 -0
  37. package/dist/chunk-YWS2GRQC.js.map +1 -0
  38. package/dist/chunk-ZQEWQ7LJ.js +97 -0
  39. package/dist/chunk-ZQEWQ7LJ.js.map +1 -0
  40. package/dist/client.cjs +1358 -0
  41. package/dist/client.cjs.map +1 -0
  42. package/dist/client.js +15 -0
  43. package/dist/client.js.map +1 -0
  44. package/dist/git/client.cjs +428 -0
  45. package/dist/git/client.cjs.map +1 -0
  46. package/dist/git/client.js +8 -0
  47. package/dist/git/client.js.map +1 -0
  48. package/dist/git/config.cjs +41 -0
  49. package/dist/git/config.cjs.map +1 -0
  50. package/dist/git/config.js +17 -0
  51. package/dist/git/config.js.map +1 -0
  52. package/dist/git/index.cjs +438 -0
  53. package/dist/git/index.cjs.map +1 -0
  54. package/dist/git/index.js +14 -0
  55. package/dist/git/index.js.map +1 -0
  56. package/dist/git/types.cjs +19 -0
  57. package/dist/git/types.cjs.map +1 -0
  58. package/dist/git/types.js +1 -0
  59. package/dist/git/types.js.map +1 -0
  60. package/dist/index.cjs +1372 -0
  61. package/dist/index.cjs.map +1 -0
  62. package/dist/index.js +34 -0
  63. package/dist/index.js.map +1 -0
  64. package/dist/tools/browser/anthropic.cjs +281 -0
  65. package/dist/tools/browser/anthropic.cjs.map +1 -0
  66. package/dist/tools/browser/anthropic.js +72 -0
  67. package/dist/tools/browser/anthropic.js.map +1 -0
  68. package/dist/tools/browser/core.cjs +459 -0
  69. package/dist/tools/browser/core.cjs.map +1 -0
  70. package/dist/tools/browser/core.js +21 -0
  71. package/dist/tools/browser/core.js.map +1 -0
  72. package/dist/tools/browser/index.cjs +497 -0
  73. package/dist/tools/browser/index.cjs.map +1 -0
  74. package/dist/tools/browser/index.js +27 -0
  75. package/dist/tools/browser/index.js.map +1 -0
  76. package/dist/tools/browser/openai.cjs +297 -0
  77. package/dist/tools/browser/openai.cjs.map +1 -0
  78. package/dist/tools/browser/openai.js +85 -0
  79. package/dist/tools/browser/openai.js.map +1 -0
  80. package/dist/tools/browser/prompts.cjs +64 -0
  81. package/dist/tools/browser/prompts.cjs.map +1 -0
  82. package/dist/tools/browser/prompts.js +10 -0
  83. package/dist/tools/browser/prompts.js.map +1 -0
  84. package/dist/tools/browser/types.cjs +19 -0
  85. package/dist/tools/browser/types.cjs.map +1 -0
  86. package/dist/tools/browser/types.js +1 -0
  87. package/dist/tools/browser/types.js.map +1 -0
  88. package/dist/tools/browser/vercel.cjs +242 -0
  89. package/dist/tools/browser/vercel.cjs.map +1 -0
  90. package/dist/tools/browser/vercel.js +49 -0
  91. package/dist/tools/browser/vercel.js.map +1 -0
  92. package/dist/tools/codebase_search/anthropic.cjs +267 -0
  93. package/dist/tools/codebase_search/anthropic.cjs.map +1 -0
  94. package/dist/tools/codebase_search/anthropic.js +11 -0
  95. package/dist/tools/codebase_search/anthropic.js.map +1 -0
  96. package/dist/tools/codebase_search/core.cjs +201 -0
  97. package/dist/tools/codebase_search/core.cjs.map +1 -0
  98. package/dist/tools/codebase_search/core.js +11 -0
  99. package/dist/tools/codebase_search/core.js.map +1 -0
  100. package/dist/tools/codebase_search/index.cjs +393 -0
  101. package/dist/tools/codebase_search/index.cjs.map +1 -0
  102. package/dist/tools/codebase_search/index.js +27 -0
  103. package/dist/tools/codebase_search/index.js.map +1 -0
  104. package/dist/tools/codebase_search/openai.cjs +316 -0
  105. package/dist/tools/codebase_search/openai.cjs.map +1 -0
  106. package/dist/tools/codebase_search/openai.js +21 -0
  107. package/dist/tools/codebase_search/openai.js.map +1 -0
  108. package/dist/tools/codebase_search/prompts.cjs +57 -0
  109. package/dist/tools/codebase_search/prompts.cjs.map +1 -0
  110. package/dist/tools/codebase_search/prompts.js +10 -0
  111. package/dist/tools/codebase_search/prompts.js.map +1 -0
  112. package/dist/tools/codebase_search/types.cjs +19 -0
  113. package/dist/tools/codebase_search/types.cjs.map +1 -0
  114. package/dist/tools/codebase_search/types.js +1 -0
  115. package/dist/tools/codebase_search/types.js.map +1 -0
  116. package/dist/tools/codebase_search/vercel.cjs +230 -0
  117. package/dist/tools/codebase_search/vercel.cjs.map +1 -0
  118. package/dist/tools/codebase_search/vercel.js +15 -0
  119. package/dist/tools/codebase_search/vercel.js.map +1 -0
  120. package/dist/tools/fastapply/anthropic.cjs +335 -0
  121. package/dist/tools/fastapply/anthropic.cjs.map +1 -0
  122. package/dist/tools/fastapply/anthropic.js +13 -0
  123. package/dist/tools/fastapply/anthropic.js.map +1 -0
  124. package/dist/tools/fastapply/core.cjs +267 -0
  125. package/dist/tools/fastapply/core.cjs.map +1 -0
  126. package/dist/tools/fastapply/core.js +15 -0
  127. package/dist/tools/fastapply/core.js.map +1 -0
  128. package/dist/tools/fastapply/index.cjs +500 -0
  129. package/dist/tools/fastapply/index.cjs.map +1 -0
  130. package/dist/tools/fastapply/index.js +32 -0
  131. package/dist/tools/fastapply/index.js.map +1 -0
  132. package/dist/tools/fastapply/openai.cjs +353 -0
  133. package/dist/tools/fastapply/openai.cjs.map +1 -0
  134. package/dist/tools/fastapply/openai.js +21 -0
  135. package/dist/tools/fastapply/openai.js.map +1 -0
  136. package/dist/tools/fastapply/prompts.cjs +68 -0
  137. package/dist/tools/fastapply/prompts.cjs.map +1 -0
  138. package/dist/tools/fastapply/prompts.js +10 -0
  139. package/dist/tools/fastapply/prompts.js.map +1 -0
  140. package/dist/tools/fastapply/types.cjs +19 -0
  141. package/dist/tools/fastapply/types.cjs.map +1 -0
  142. package/dist/tools/fastapply/types.js +1 -0
  143. package/dist/tools/fastapply/types.js.map +1 -0
  144. package/dist/tools/fastapply/vercel.cjs +347 -0
  145. package/dist/tools/fastapply/vercel.cjs.map +1 -0
  146. package/dist/tools/fastapply/vercel.js +17 -0
  147. package/dist/tools/fastapply/vercel.js.map +1 -0
  148. package/dist/tools/index.cjs +500 -0
  149. package/dist/tools/index.cjs.map +1 -0
  150. package/dist/tools/index.js +32 -0
  151. package/dist/tools/index.js.map +1 -0
  152. package/dist/tools/modelrouter/core.cjs +286 -0
  153. package/dist/tools/modelrouter/core.cjs.map +1 -0
  154. package/dist/tools/modelrouter/core.js +13 -0
  155. package/dist/tools/modelrouter/core.js.map +1 -0
  156. package/dist/tools/modelrouter/index.cjs +286 -0
  157. package/dist/tools/modelrouter/index.cjs.map +1 -0
  158. package/dist/tools/modelrouter/index.js +13 -0
  159. package/dist/tools/modelrouter/index.js.map +1 -0
  160. package/dist/tools/modelrouter/types.cjs +19 -0
  161. package/dist/tools/modelrouter/types.cjs.map +1 -0
  162. package/dist/tools/modelrouter/types.js +1 -0
  163. package/dist/tools/modelrouter/types.js.map +1 -0
  164. package/dist/tools/utils/resilience.cjs +115 -0
  165. package/dist/tools/utils/resilience.cjs.map +1 -0
  166. package/dist/tools/utils/resilience.js +12 -0
  167. package/dist/tools/utils/resilience.js.map +1 -0
  168. package/package.json +159 -0
@@ -0,0 +1,89 @@
1
+ // tools/utils/resilience.ts
2
+ var DEFAULT_RETRY_CONFIG = {
3
+ maxRetries: 3,
4
+ initialDelay: 1e3,
5
+ maxDelay: 3e4,
6
+ backoffMultiplier: 2,
7
+ retryableErrors: ["ECONNREFUSED", "ETIMEDOUT", "ENOTFOUND"]
8
+ };
9
+ async function fetchWithRetry(url, options, retryConfig = {}) {
10
+ const {
11
+ maxRetries = DEFAULT_RETRY_CONFIG.maxRetries,
12
+ initialDelay = DEFAULT_RETRY_CONFIG.initialDelay,
13
+ maxDelay = DEFAULT_RETRY_CONFIG.maxDelay,
14
+ backoffMultiplier = DEFAULT_RETRY_CONFIG.backoffMultiplier,
15
+ retryableErrors = DEFAULT_RETRY_CONFIG.retryableErrors,
16
+ onRetry
17
+ } = retryConfig;
18
+ let lastError = null;
19
+ let delay = initialDelay;
20
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
21
+ try {
22
+ const response = await fetch(url, options);
23
+ if (response.status === 429 || response.status === 503) {
24
+ if (attempt < maxRetries) {
25
+ const retryAfter = response.headers.get("Retry-After");
26
+ const waitTime = retryAfter ? parseInt(retryAfter) * 1e3 : Math.min(delay, maxDelay);
27
+ const error = new Error(`HTTP ${response.status}: Retrying after ${waitTime}ms`);
28
+ if (onRetry) {
29
+ onRetry(attempt + 1, error);
30
+ }
31
+ await sleep(waitTime);
32
+ delay *= backoffMultiplier;
33
+ continue;
34
+ }
35
+ }
36
+ return response;
37
+ } catch (error) {
38
+ lastError = error;
39
+ const isRetryable = retryableErrors.some(
40
+ (errType) => lastError?.message?.includes(errType)
41
+ );
42
+ if (!isRetryable || attempt === maxRetries) {
43
+ throw lastError;
44
+ }
45
+ const waitTime = Math.min(delay, maxDelay);
46
+ if (onRetry) {
47
+ onRetry(attempt + 1, lastError);
48
+ }
49
+ await sleep(waitTime);
50
+ delay *= backoffMultiplier;
51
+ }
52
+ }
53
+ throw lastError || new Error("Max retries exceeded");
54
+ }
55
+ async function withTimeout(promise, timeoutMs, errorMessage) {
56
+ let timeoutId;
57
+ const timeoutPromise = new Promise((_, reject) => {
58
+ timeoutId = setTimeout(() => {
59
+ reject(new Error(errorMessage || `Operation timed out after ${timeoutMs}ms`));
60
+ }, timeoutMs);
61
+ });
62
+ try {
63
+ const result = await Promise.race([promise, timeoutPromise]);
64
+ clearTimeout(timeoutId);
65
+ return result;
66
+ } catch (error) {
67
+ clearTimeout(timeoutId);
68
+ throw error;
69
+ }
70
+ }
71
+ function sleep(ms) {
72
+ return new Promise((resolve) => setTimeout(resolve, ms));
73
+ }
74
+ var MorphError = class extends Error {
75
+ constructor(message, code, statusCode, retryable = false) {
76
+ super(message);
77
+ this.code = code;
78
+ this.statusCode = statusCode;
79
+ this.retryable = retryable;
80
+ this.name = "MorphError";
81
+ }
82
+ };
83
+
84
+ export {
85
+ fetchWithRetry,
86
+ withTimeout,
87
+ MorphError
88
+ };
89
+ //# sourceMappingURL=chunk-4VWJFZVS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../tools/utils/resilience.ts"],"sourcesContent":["/**\n * Resilience utilities for retry logic and timeout handling\n */\n\nexport interface RetryConfig {\n maxRetries?: number; // Default: 3\n initialDelay?: number; // Default: 1000ms\n maxDelay?: number; // Default: 30000ms\n backoffMultiplier?: number; // Default: 2\n retryableErrors?: string[]; // Default: ['ECONNREFUSED', 'ETIMEDOUT', 'ENOTFOUND']\n onRetry?: (attempt: number, error: Error) => void;\n}\n\nconst DEFAULT_RETRY_CONFIG: Required<Omit<RetryConfig, 'onRetry'>> = {\n maxRetries: 3,\n initialDelay: 1000,\n maxDelay: 30000,\n backoffMultiplier: 2,\n retryableErrors: ['ECONNREFUSED', 'ETIMEDOUT', 'ENOTFOUND'],\n};\n\n/**\n * Retry a fetch request with exponential backoff\n * \n * @param url - Request URL\n * @param options - Fetch options\n * @param retryConfig - Retry configuration\n * @returns Response from fetch\n * \n * @example\n * ```typescript\n * const response = await fetchWithRetry(\n * 'https://api.example.com/data',\n * { method: 'POST', body: JSON.stringify(data) },\n * { maxRetries: 5, initialDelay: 500 }\n * );\n * ```\n */\nexport async function fetchWithRetry(\n url: string,\n options: RequestInit,\n retryConfig: RetryConfig = {}\n): Promise<Response> {\n const {\n maxRetries = DEFAULT_RETRY_CONFIG.maxRetries,\n initialDelay = DEFAULT_RETRY_CONFIG.initialDelay,\n maxDelay = DEFAULT_RETRY_CONFIG.maxDelay,\n backoffMultiplier = DEFAULT_RETRY_CONFIG.backoffMultiplier,\n retryableErrors = DEFAULT_RETRY_CONFIG.retryableErrors,\n onRetry,\n } = retryConfig;\n\n let lastError: Error | null = null;\n let delay = initialDelay;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n const response = await fetch(url, options);\n \n // Retry on 429 (rate limit) or 503 (service unavailable)\n if (response.status === 429 || response.status === 503) {\n if (attempt < maxRetries) {\n // Check for Retry-After header\n const retryAfter = response.headers.get('Retry-After');\n const waitTime = retryAfter \n ? parseInt(retryAfter) * 1000 \n : Math.min(delay, maxDelay);\n \n const error = new Error(`HTTP ${response.status}: Retrying after ${waitTime}ms`);\n if (onRetry) {\n onRetry(attempt + 1, error);\n }\n \n await sleep(waitTime);\n delay *= backoffMultiplier;\n continue;\n }\n }\n\n return response;\n } catch (error) {\n lastError = error as Error;\n \n // Check if error is retryable\n const isRetryable = retryableErrors.some(errType => \n lastError?.message?.includes(errType)\n );\n\n if (!isRetryable || attempt === maxRetries) {\n throw lastError;\n }\n\n // Exponential backoff\n const waitTime = Math.min(delay, maxDelay);\n if (onRetry) {\n onRetry(attempt + 1, lastError);\n }\n \n await sleep(waitTime);\n delay *= backoffMultiplier;\n }\n }\n\n throw lastError || new Error('Max retries exceeded');\n}\n\n/**\n * Add timeout to any promise\n * \n * @param promise - Promise to wrap with timeout\n * @param timeoutMs - Timeout in milliseconds\n * @param errorMessage - Optional custom error message\n * @returns Promise that rejects if timeout is reached\n * \n * @example\n * ```typescript\n * const result = await withTimeout(\n * fetchData(),\n * 5000,\n * 'Data fetch timed out'\n * );\n * ```\n */\nexport async function withTimeout<T>(\n promise: Promise<T>,\n timeoutMs: number,\n errorMessage?: string\n): Promise<T> {\n let timeoutId: NodeJS.Timeout | number;\n \n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = setTimeout(() => {\n reject(new Error(errorMessage || `Operation timed out after ${timeoutMs}ms`));\n }, timeoutMs);\n });\n\n try {\n const result = await Promise.race([promise, timeoutPromise]);\n clearTimeout(timeoutId!);\n return result;\n } catch (error) {\n clearTimeout(timeoutId!);\n throw error;\n }\n}\n\n/**\n * Sleep for specified milliseconds\n */\nfunction sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n\n/**\n * Unified error type for all tools\n */\nexport class MorphError extends Error {\n constructor(\n message: string,\n public code: string,\n public statusCode?: number,\n public retryable: boolean = false\n ) {\n super(message);\n this.name = 'MorphError';\n }\n}\n\n\n"],"mappings":";AAaA,IAAM,uBAA+D;AAAA,EACnE,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,UAAU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AmBA,eAAsB,YACpB,SACA,WACA,cACY;AACZ,MAAI;AAEJ,QAAM,iBAAiB,IAAI,QAAe,CAAC,GAAG,WAAW;AACvD,gBAAY,WAAW,MAAM;AAC3B,aAAO,IAAI,MAAM,gBAAgB,6BAA6B,SAAS,IAAI,CAAC;AAAA,IAC9E,GAAG,SAAS;AAAA,EACd,CAAC;AAED,MAAI;AACF,UAAM,SAAS,MAAM,QAAQ,KAAK,CAAC,SAAS,cAAc,CAAC;AAC3D,iBAAa,SAAU;AACvB,WAAO;AAAA,EACT,SAAS,OAAO;AACd,iBAAa,SAAU;AACvB,UAAM;AAAA,EACR;AACF;AAKA,SAAS,MAAM,IAA2B;AACxC,SAAO,IAAI,QAAQ,aAAW,WAAW,SAAS,EAAE,CAAC;AACvD;AAKO,IAAM,aAAN,cAAyB,MAAM;AAAA,EACpC,YACE,SACO,MACA,YACA,YAAqB,OAC5B;AACA,UAAM,OAAO;AAJN;AACA;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
@@ -0,0 +1,91 @@
1
+ import {
2
+ EDIT_FILE_SYSTEM_PROMPT,
3
+ EDIT_FILE_TOOL_DESCRIPTION
4
+ } from "./chunk-63WE2C5R.js";
5
+ import {
6
+ executeEditFile
7
+ } from "./chunk-4V46N27D.js";
8
+ import {
9
+ __export
10
+ } from "./chunk-PZ5AY32C.js";
11
+
12
+ // tools/fastapply/vercel.ts
13
+ var vercel_exports = {};
14
+ __export(vercel_exports, {
15
+ createEditFileTool: () => createEditFileTool,
16
+ default: () => vercel_default,
17
+ editFileTool: () => editFileTool,
18
+ getSystemPrompt: () => getSystemPrompt
19
+ });
20
+ import { tool } from "ai";
21
+ import { z } from "zod";
22
+ var editFileSchema = z.object({
23
+ target_filepath: z.string().describe("The path of the target file to modify"),
24
+ instructions: z.string().describe("A single sentence describing what you are changing (first person)"),
25
+ code_edit: z.string().describe("The lazy edit with // ... existing code ... markers")
26
+ });
27
+ var editFileTool = tool({
28
+ description: EDIT_FILE_TOOL_DESCRIPTION,
29
+ parameters: editFileSchema,
30
+ // @ts-ignore
31
+ execute: async (params) => {
32
+ const result = await executeEditFile({
33
+ target_filepath: params.target_filepath,
34
+ instructions: params.instructions,
35
+ code_edit: params.code_edit
36
+ });
37
+ if (!result.success) {
38
+ throw new Error(`Failed to edit file: ${result.error}`);
39
+ }
40
+ return {
41
+ success: true,
42
+ filepath: result.filepath,
43
+ changes: result.changes,
44
+ udiff: result.udiff
45
+ };
46
+ }
47
+ });
48
+ function getSystemPrompt() {
49
+ return EDIT_FILE_SYSTEM_PROMPT;
50
+ }
51
+ function createEditFileTool(config = {}) {
52
+ const schema = z.object({
53
+ target_filepath: z.string().describe("The path of the target file to modify"),
54
+ instructions: z.string().describe("A single sentence describing what you are changing (first person)"),
55
+ code_edit: z.string().describe("The lazy edit with // ... existing code ... markers")
56
+ });
57
+ return tool({
58
+ description: EDIT_FILE_TOOL_DESCRIPTION,
59
+ parameters: schema,
60
+ // @ts-ignore
61
+ execute: async (params) => {
62
+ const result = await executeEditFile(
63
+ {
64
+ target_filepath: params.target_filepath,
65
+ instructions: params.instructions,
66
+ code_edit: params.code_edit
67
+ },
68
+ config
69
+ );
70
+ if (!result.success) {
71
+ throw new Error(`Failed to edit file: ${result.error}`);
72
+ }
73
+ return {
74
+ success: true,
75
+ filepath: result.filepath,
76
+ changes: result.changes,
77
+ udiff: result.udiff
78
+ };
79
+ }
80
+ });
81
+ }
82
+ var vercel_default = editFileTool;
83
+
84
+ export {
85
+ editFileTool,
86
+ getSystemPrompt,
87
+ createEditFileTool,
88
+ vercel_default,
89
+ vercel_exports
90
+ };
91
+ //# sourceMappingURL=chunk-5COKN3XD.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 instructions: 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// @ts-ignore - Vercel AI SDK tool() has execute runtime support but types are incomplete\nexport const editFileTool = tool({\n description: EDIT_FILE_TOOL_DESCRIPTION,\n parameters: editFileSchema,\n // @ts-ignore\n execute: async (params) => {\n const result = await executeEditFile({\n target_filepath: params.target_filepath,\n instructions: params.instructions,\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 * });\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 instructions: 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 // @ts-ignore - Vercel AI SDK tool() has execute runtime support but types are incomplete\n return tool({\n description: EDIT_FILE_TOOL_DESCRIPTION,\n parameters: schema,\n // @ts-ignore\n execute: async (params) => {\n const result = await executeEditFile(\n {\n target_filepath: params.target_filepath,\n instructions: params.instructions,\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,cAAc,EACX,OAAO,EACP,SAAS,mEAAmE;AAAA,EAC/E,WAAW,EACR,OAAO,EACP,SAAS,qDAAqD;AACnE,CAAC;AAGM,IAAM,eAAe,KAAK;AAAA,EAC/B,aAAa;AAAA,EACb,YAAY;AAAA;AAAA,EAEZ,SAAS,OAAO,WAAW;AACzB,UAAM,SAAS,MAAM,gBAAgB;AAAA,MACnC,iBAAiB,OAAO;AAAA,MACxB,cAAc,OAAO;AAAA,MACrB,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;AAsBO,SAAS,mBAAmB,SAAyB,CAAC,GAAG;AAC9D,QAAM,SAAS,EAAE,OAAO;AAAA,IACtB,iBAAiB,EAAE,OAAO,EAAE,SAAS,uCAAuC;AAAA,IAC5E,cAAc,EACX,OAAO,EACP,SAAS,mEAAmE;AAAA,IAC/E,WAAW,EACR,OAAO,EACP,SAAS,qDAAqD;AAAA,EACnE,CAAC;AAGD,SAAO,KAAK;AAAA,IACV,aAAa;AAAA,IACb,YAAY;AAAA;AAAA,IAEZ,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM;AAAA,QACnB;AAAA,UACE,iBAAiB,OAAO;AAAA,UACxB,cAAc,OAAO;AAAA,UACrB,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":[]}
@@ -0,0 +1,394 @@
1
+ // git/client.ts
2
+ import git from "isomorphic-git";
3
+ import http from "isomorphic-git/http/node";
4
+ import fs from "fs";
5
+ var DEFAULT_PROXY_URL = "https://repos.morphllm.com";
6
+ var MorphGit = class {
7
+ apiKey;
8
+ proxyUrl;
9
+ constructor(config) {
10
+ if (!config.apiKey) {
11
+ throw new Error("API key is required. Get one at https://morphllm.com/dashboard");
12
+ }
13
+ if (!config.apiKey.startsWith("sk-") && !config.apiKey.startsWith("morph-")) {
14
+ throw new Error("Invalid API key format. Expected: sk-... or morph-...");
15
+ }
16
+ this.apiKey = config.apiKey;
17
+ this.proxyUrl = config.proxyUrl || DEFAULT_PROXY_URL;
18
+ }
19
+ /**
20
+ * Get auth callback for isomorphic-git operations
21
+ * @private
22
+ */
23
+ getAuthCallback() {
24
+ return () => ({
25
+ username: "morph",
26
+ password: this.apiKey
27
+ });
28
+ }
29
+ /**
30
+ * Initialize a new repository
31
+ * Creates the repo in the database and in the git provider
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * await morphGit.init({
36
+ * repoId: 'my-project',
37
+ * dir: './my-project',
38
+ * defaultBranch: 'main'
39
+ * });
40
+ * ```
41
+ */
42
+ async init(options) {
43
+ const { repoId, dir, defaultBranch = "main" } = options;
44
+ const response = await fetch(`${this.proxyUrl}/v1/repos`, {
45
+ method: "POST",
46
+ headers: {
47
+ "Authorization": `Bearer ${this.apiKey}`,
48
+ "Content-Type": "application/json"
49
+ },
50
+ body: JSON.stringify({
51
+ repoId,
52
+ name: repoId,
53
+ defaultBranch
54
+ })
55
+ });
56
+ if (!response.ok) {
57
+ const error = await response.text();
58
+ throw new Error(`Failed to create repository: ${error}`);
59
+ }
60
+ await git.init({
61
+ fs,
62
+ dir,
63
+ defaultBranch
64
+ });
65
+ await git.addRemote({
66
+ fs,
67
+ dir,
68
+ remote: "origin",
69
+ url: `${this.proxyUrl}/v1/repos/${repoId}`
70
+ });
71
+ console.log(`\u2713 Repository '${repoId}' initialized`);
72
+ }
73
+ /**
74
+ * Clone a repository from Morph repos
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * await morphGit.clone({
79
+ * repoId: 'my-project',
80
+ * dir: './my-project'
81
+ * });
82
+ * ```
83
+ */
84
+ async clone(options) {
85
+ const { repoId, dir, branch = "main", depth, singleBranch = true } = options;
86
+ await git.clone({
87
+ fs,
88
+ http,
89
+ dir,
90
+ corsProxy: this.proxyUrl,
91
+ url: `${this.proxyUrl}/v1/repos/${repoId}`,
92
+ ref: branch,
93
+ singleBranch,
94
+ depth,
95
+ onAuth: this.getAuthCallback()
96
+ });
97
+ }
98
+ /**
99
+ * Push changes to remote repository
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * await morphGit.push({ dir: './my-project' });
104
+ * ```
105
+ */
106
+ async push(options) {
107
+ const { dir, remote = "origin", branch } = options;
108
+ await git.push({
109
+ fs,
110
+ http,
111
+ dir,
112
+ remote,
113
+ ref: branch,
114
+ onAuth: this.getAuthCallback()
115
+ });
116
+ }
117
+ /**
118
+ * Pull changes from remote repository
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * await morphGit.pull({ dir: './my-project' });
123
+ * ```
124
+ */
125
+ async pull(options) {
126
+ const { dir, remote = "origin", branch } = options;
127
+ await git.pull({
128
+ fs,
129
+ http,
130
+ dir,
131
+ remote,
132
+ ref: branch,
133
+ onAuth: this.getAuthCallback(),
134
+ author: {
135
+ name: "Morph Agent",
136
+ email: "agent@morph.com"
137
+ }
138
+ });
139
+ }
140
+ /**
141
+ * Stage a file for commit
142
+ *
143
+ * @example
144
+ * ```ts
145
+ * await morphGit.add({
146
+ * dir: './my-project',
147
+ * filepath: 'src/app.ts'
148
+ * });
149
+ * ```
150
+ */
151
+ async add(options) {
152
+ const { dir, filepath } = options;
153
+ await git.add({
154
+ fs,
155
+ dir,
156
+ filepath
157
+ });
158
+ }
159
+ /**
160
+ * Remove a file from staging
161
+ *
162
+ * @example
163
+ * ```ts
164
+ * await morphGit.remove({
165
+ * dir: './my-project',
166
+ * filepath: 'src/old-file.ts'
167
+ * });
168
+ * ```
169
+ */
170
+ async remove(options) {
171
+ const { dir, filepath } = options;
172
+ await git.remove({
173
+ fs,
174
+ dir,
175
+ filepath
176
+ });
177
+ }
178
+ /**
179
+ * Commit staged changes
180
+ *
181
+ * @example
182
+ * ```ts
183
+ * await morphGit.commit({
184
+ * dir: './my-project',
185
+ * message: 'Add new feature',
186
+ * author: {
187
+ * name: 'AI Agent',
188
+ * email: 'ai@example.com'
189
+ * }
190
+ * });
191
+ * ```
192
+ */
193
+ async commit(options) {
194
+ const { dir, message, author } = options;
195
+ const commitAuthor = author || {
196
+ name: "Morph SDK",
197
+ email: "sdk@morphllm.com"
198
+ };
199
+ const sha = await git.commit({
200
+ fs,
201
+ dir,
202
+ message,
203
+ author: commitAuthor
204
+ });
205
+ return sha;
206
+ }
207
+ /**
208
+ * Get status of a file
209
+ *
210
+ * @example
211
+ * ```ts
212
+ * const status = await morphGit.status({
213
+ * dir: './my-project',
214
+ * filepath: 'src/app.ts'
215
+ * });
216
+ * console.log(status); // 'modified', '*added', etc.
217
+ * ```
218
+ */
219
+ async status(options) {
220
+ const { dir, filepath } = options;
221
+ if (!filepath) {
222
+ throw new Error("filepath is required for status check");
223
+ }
224
+ const status = await git.status({
225
+ fs,
226
+ dir,
227
+ filepath
228
+ });
229
+ return status;
230
+ }
231
+ /**
232
+ * Get commit history
233
+ *
234
+ * @example
235
+ * ```ts
236
+ * const commits = await morphGit.log({
237
+ * dir: './my-project',
238
+ * depth: 10
239
+ * });
240
+ * ```
241
+ */
242
+ async log(options) {
243
+ const { dir, depth, ref } = options;
244
+ const commits = await git.log({
245
+ fs,
246
+ dir,
247
+ depth,
248
+ ref
249
+ });
250
+ return commits;
251
+ }
252
+ /**
253
+ * Checkout a branch or commit
254
+ *
255
+ * @example
256
+ * ```ts
257
+ * await morphGit.checkout({
258
+ * dir: './my-project',
259
+ * ref: 'feature-branch'
260
+ * });
261
+ * ```
262
+ */
263
+ async checkout(options) {
264
+ const { dir, ref } = options;
265
+ await git.checkout({
266
+ fs,
267
+ dir,
268
+ ref
269
+ });
270
+ }
271
+ /**
272
+ * Create a new branch
273
+ *
274
+ * @example
275
+ * ```ts
276
+ * await morphGit.branch({
277
+ * dir: './my-project',
278
+ * name: 'feature-branch',
279
+ * checkout: true
280
+ * });
281
+ * ```
282
+ */
283
+ async branch(options) {
284
+ const { dir, name, checkout = false } = options;
285
+ await git.branch({
286
+ fs,
287
+ dir,
288
+ ref: name,
289
+ checkout
290
+ });
291
+ }
292
+ /**
293
+ * List all branches
294
+ *
295
+ * @example
296
+ * ```ts
297
+ * const branches = await morphGit.listBranches({
298
+ * dir: './my-project'
299
+ * });
300
+ * ```
301
+ */
302
+ async listBranches(options) {
303
+ const { dir } = options;
304
+ const branches = await git.listBranches({
305
+ fs,
306
+ dir
307
+ });
308
+ return branches;
309
+ }
310
+ /**
311
+ * Get the current branch name
312
+ *
313
+ * @example
314
+ * ```ts
315
+ * const branch = await morphGit.currentBranch({
316
+ * dir: './my-project'
317
+ * });
318
+ * ```
319
+ */
320
+ async currentBranch(options) {
321
+ const { dir } = options;
322
+ const branch = await git.currentBranch({
323
+ fs,
324
+ dir
325
+ });
326
+ return branch || void 0;
327
+ }
328
+ /**
329
+ * Get list of changed files (similar to git diff --name-only)
330
+ *
331
+ * @example
332
+ * ```ts
333
+ * const changes = await morphGit.statusMatrix({
334
+ * dir: './my-project'
335
+ * });
336
+ * ```
337
+ */
338
+ async statusMatrix(options) {
339
+ const { dir } = options;
340
+ const matrix = await git.statusMatrix({
341
+ fs,
342
+ dir
343
+ });
344
+ return matrix.map(([filepath, HEADStatus, workdirStatus, stageStatus]) => {
345
+ let status = "unmodified";
346
+ if (HEADStatus === 1 && workdirStatus === 2 && stageStatus === 2) {
347
+ status = "modified";
348
+ } else if (HEADStatus === 1 && workdirStatus === 2 && stageStatus === 1) {
349
+ status = "*modified";
350
+ } else if (HEADStatus === 0 && workdirStatus === 2 && stageStatus === 2) {
351
+ status = "added";
352
+ } else if (HEADStatus === 0 && workdirStatus === 2 && stageStatus === 0) {
353
+ status = "*added";
354
+ } else if (HEADStatus === 1 && workdirStatus === 0 && stageStatus === 0) {
355
+ status = "deleted";
356
+ } else if (HEADStatus === 1 && workdirStatus === 0 && stageStatus === 1) {
357
+ status = "*deleted";
358
+ } else if (HEADStatus === 1 && workdirStatus === 1 && stageStatus === 1) {
359
+ status = "unmodified";
360
+ } else if (HEADStatus === 0 && workdirStatus === 0 && stageStatus === 0) {
361
+ status = "absent";
362
+ }
363
+ return {
364
+ filepath,
365
+ status
366
+ };
367
+ });
368
+ }
369
+ /**
370
+ * Get the current commit hash
371
+ *
372
+ * @example
373
+ * ```ts
374
+ * const hash = await morphGit.resolveRef({
375
+ * dir: './my-project',
376
+ * ref: 'HEAD'
377
+ * });
378
+ * ```
379
+ */
380
+ async resolveRef(options) {
381
+ const { dir, ref } = options;
382
+ const oid = await git.resolveRef({
383
+ fs,
384
+ dir,
385
+ ref
386
+ });
387
+ return oid;
388
+ }
389
+ };
390
+
391
+ export {
392
+ MorphGit
393
+ };
394
+ //# sourceMappingURL=chunk-5VQEQSJQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../git/client.ts"],"sourcesContent":["/**\n * Morph Git Client - Simple, high-level Git operations\n * Built on isomorphic-git with explicit configuration\n */\n\nimport git from 'isomorphic-git';\nimport http from 'isomorphic-git/http/node';\nimport fs from 'fs';\nimport type {\n CloneOptions,\n PushOptions,\n PullOptions,\n AddOptions,\n CommitOptions,\n StatusOptions,\n LogOptions,\n CheckoutOptions,\n BranchOptions,\n DiffOptions,\n CommitObject,\n StatusResult,\n MorphGitConfig,\n} from './types.js';\n\nconst DEFAULT_PROXY_URL = 'https://repos.morphllm.com';\n\n/**\n * MorphGit - Git operations for AI agents with Morph backend\n * \n * @example\n * ```typescript\n * import { MorphGit } from 'morphsdk/git';\n * \n * const morphGit = new MorphGit({\n * apiKey: process.env.MORPH_API_KEY!,\n * proxyUrl: 'https://repos.morphllm.com' // Optional\n * });\n * \n * await morphGit.init({ repoId: 'my-project', dir: './my-project' });\n * await morphGit.push({ dir: './my-project' });\n * ```\n */\nexport class MorphGit {\n private readonly apiKey: string;\n private readonly proxyUrl: string;\n\n constructor(config: MorphGitConfig) {\n // Validate API key\n if (!config.apiKey) {\n throw new Error('API key is required. Get one at https://morphllm.com/dashboard');\n }\n \n if (!config.apiKey.startsWith('sk-') && !config.apiKey.startsWith('morph-')) {\n throw new Error('Invalid API key format. Expected: sk-... or morph-...');\n }\n \n this.apiKey = config.apiKey;\n this.proxyUrl = config.proxyUrl || DEFAULT_PROXY_URL;\n }\n \n /**\n * Get auth callback for isomorphic-git operations\n * @private\n */\n private getAuthCallback() {\n return () => ({\n username: 'morph',\n password: this.apiKey,\n });\n }\n\n /**\n * Initialize a new repository\n * Creates the repo in the database and in the git provider\n * \n * @example\n * ```ts\n * await morphGit.init({\n * repoId: 'my-project',\n * dir: './my-project',\n * defaultBranch: 'main'\n * });\n * ```\n */\n async init(options: {\n repoId: string;\n dir: string;\n defaultBranch?: string;\n }): Promise<void> {\n const { repoId, dir, defaultBranch = 'main' } = options;\n\n // Call backend API to create repository\n const response = await fetch(`${this.proxyUrl}/v1/repos`, {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${this.apiKey}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n repoId,\n name: repoId,\n defaultBranch,\n }),\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`Failed to create repository: ${error}`);\n }\n\n // Initialize local git repo\n await git.init({\n fs,\n dir,\n defaultBranch,\n });\n\n // Add remote\n await git.addRemote({\n fs,\n dir,\n remote: 'origin',\n url: `${this.proxyUrl}/v1/repos/${repoId}`,\n });\n\n console.log(`✓ Repository '${repoId}' initialized`);\n }\n\n /**\n * Clone a repository from Morph repos\n * \n * @example\n * ```ts\n * await morphGit.clone({\n * repoId: 'my-project',\n * dir: './my-project'\n * });\n * ```\n */\n async clone(options: CloneOptions): Promise<void> {\n const { repoId, dir, branch = 'main', depth, singleBranch = true } = options;\n\n await git.clone({\n fs,\n http,\n dir,\n corsProxy: this.proxyUrl,\n url: `${this.proxyUrl}/v1/repos/${repoId}`,\n ref: branch,\n singleBranch,\n depth,\n onAuth: this.getAuthCallback(),\n });\n }\n\n /**\n * Push changes to remote repository\n * \n * @example\n * ```ts\n * await morphGit.push({ dir: './my-project' });\n * ```\n */\n async push(options: PushOptions): Promise<void> {\n const { dir, remote = 'origin', branch } = options;\n\n await git.push({\n fs,\n http,\n dir,\n remote,\n ref: branch,\n onAuth: this.getAuthCallback(),\n });\n }\n\n /**\n * Pull changes from remote repository\n * \n * @example\n * ```ts\n * await morphGit.pull({ dir: './my-project' });\n * ```\n */\n async pull(options: PullOptions): Promise<void> {\n const { dir, remote = 'origin', branch } = options;\n\n await git.pull({\n fs,\n http,\n dir,\n remote,\n ref: branch,\n onAuth: this.getAuthCallback(),\n author: {\n name: 'Morph Agent',\n email: 'agent@morph.com',\n },\n });\n }\n\n /**\n * Stage a file for commit\n * \n * @example\n * ```ts\n * await morphGit.add({\n * dir: './my-project',\n * filepath: 'src/app.ts'\n * });\n * ```\n */\n async add(options: AddOptions): Promise<void> {\n const { dir, filepath } = options;\n\n await git.add({\n fs,\n dir,\n filepath,\n });\n }\n\n /**\n * Remove a file from staging\n * \n * @example\n * ```ts\n * await morphGit.remove({\n * dir: './my-project',\n * filepath: 'src/old-file.ts'\n * });\n * ```\n */\n async remove(options: AddOptions): Promise<void> {\n const { dir, filepath } = options;\n\n await git.remove({\n fs,\n dir,\n filepath,\n });\n }\n\n /**\n * Commit staged changes\n * \n * @example\n * ```ts\n * await morphGit.commit({\n * dir: './my-project',\n * message: 'Add new feature',\n * author: {\n * name: 'AI Agent',\n * email: 'ai@example.com'\n * }\n * });\n * ```\n */\n async commit(options: CommitOptions): Promise<string> {\n const { dir, message, author } = options;\n\n // Provide default author if not specified\n const commitAuthor = author || {\n name: 'Morph SDK',\n email: 'sdk@morphllm.com'\n };\n\n const sha = await git.commit({\n fs,\n dir,\n message,\n author: commitAuthor,\n });\n\n return sha;\n }\n\n /**\n * Get status of a file\n * \n * @example\n * ```ts\n * const status = await morphGit.status({\n * dir: './my-project',\n * filepath: 'src/app.ts'\n * });\n * console.log(status); // 'modified', '*added', etc.\n * ```\n */\n async status(options: StatusOptions): Promise<string> {\n const { dir, filepath } = options;\n\n if (!filepath) {\n throw new Error('filepath is required for status check');\n }\n\n const status = await git.status({\n fs,\n dir,\n filepath,\n });\n\n return status;\n }\n\n /**\n * Get commit history\n * \n * @example\n * ```ts\n * const commits = await morphGit.log({\n * dir: './my-project',\n * depth: 10\n * });\n * ```\n */\n async log(options: LogOptions): Promise<CommitObject[]> {\n const { dir, depth, ref } = options;\n\n const commits = await git.log({\n fs,\n dir,\n depth,\n ref,\n });\n\n return commits as CommitObject[];\n }\n\n /**\n * Checkout a branch or commit\n * \n * @example\n * ```ts\n * await morphGit.checkout({\n * dir: './my-project',\n * ref: 'feature-branch'\n * });\n * ```\n */\n async checkout(options: CheckoutOptions): Promise<void> {\n const { dir, ref } = options;\n\n await git.checkout({\n fs,\n dir,\n ref,\n });\n }\n\n /**\n * Create a new branch\n * \n * @example\n * ```ts\n * await morphGit.branch({\n * dir: './my-project',\n * name: 'feature-branch',\n * checkout: true\n * });\n * ```\n */\n async branch(options: BranchOptions): Promise<void> {\n const { dir, name, checkout = false } = options;\n\n await git.branch({\n fs,\n dir,\n ref: name,\n checkout,\n });\n }\n\n /**\n * List all branches\n * \n * @example\n * ```ts\n * const branches = await morphGit.listBranches({\n * dir: './my-project'\n * });\n * ```\n */\n async listBranches(options: { dir: string }): Promise<string[]> {\n const { dir } = options;\n\n const branches = await git.listBranches({\n fs,\n dir,\n });\n\n return branches;\n }\n\n /**\n * Get the current branch name\n * \n * @example\n * ```ts\n * const branch = await morphGit.currentBranch({\n * dir: './my-project'\n * });\n * ```\n */\n async currentBranch(options: { dir: string }): Promise<string | undefined> {\n const { dir } = options;\n\n const branch = await git.currentBranch({\n fs,\n dir,\n });\n\n return branch || undefined;\n }\n\n /**\n * Get list of changed files (similar to git diff --name-only)\n * \n * @example\n * ```ts\n * const changes = await morphGit.statusMatrix({\n * dir: './my-project'\n * });\n * ```\n */\n async statusMatrix(options: { dir: string }): Promise<StatusResult[]> {\n const { dir } = options;\n\n const matrix = await git.statusMatrix({\n fs,\n dir,\n });\n\n return matrix.map(([filepath, HEADStatus, workdirStatus, stageStatus]) => {\n let status: StatusResult['status'] = 'unmodified';\n\n // Determine status based on statusMatrix values\n if (HEADStatus === 1 && workdirStatus === 2 && stageStatus === 2) {\n status = 'modified';\n } else if (HEADStatus === 1 && workdirStatus === 2 && stageStatus === 1) {\n status = '*modified';\n } else if (HEADStatus === 0 && workdirStatus === 2 && stageStatus === 2) {\n status = 'added';\n } else if (HEADStatus === 0 && workdirStatus === 2 && stageStatus === 0) {\n status = '*added';\n } else if (HEADStatus === 1 && workdirStatus === 0 && stageStatus === 0) {\n status = 'deleted';\n } else if (HEADStatus === 1 && workdirStatus === 0 && stageStatus === 1) {\n status = '*deleted';\n } else if (HEADStatus === 1 && workdirStatus === 1 && stageStatus === 1) {\n status = 'unmodified';\n } else if (HEADStatus === 0 && workdirStatus === 0 && stageStatus === 0) {\n status = 'absent';\n }\n\n return {\n filepath,\n status,\n };\n });\n }\n\n /**\n * Get the current commit hash\n * \n * @example\n * ```ts\n * const hash = await morphGit.resolveRef({\n * dir: './my-project',\n * ref: 'HEAD'\n * });\n * ```\n */\n async resolveRef(options: { dir: string; ref: string }): Promise<string> {\n const { dir, ref } = options;\n\n const oid = await git.resolveRef({\n fs,\n dir,\n ref,\n });\n\n return oid;\n }\n}\n\n"],"mappings":";AAKA,OAAO,SAAS;AAChB,OAAO,UAAU;AACjB,OAAO,QAAQ;AAiBf,IAAM,oBAAoB;AAkBnB,IAAM,WAAN,MAAe;AAAA,EACH;AAAA,EACA;AAAA,EAEjB,YAAY,QAAwB;AAElC,QAAI,CAAC,OAAO,QAAQ;AAClB,YAAM,IAAI,MAAM,gEAAgE;AAAA,IAClF;AAEA,QAAI,CAAC,OAAO,OAAO,WAAW,KAAK,KAAK,CAAC,OAAO,OAAO,WAAW,QAAQ,GAAG;AAC3E,YAAM,IAAI,MAAM,uDAAuD;AAAA,IACzE;AAEA,SAAK,SAAS,OAAO;AACrB,SAAK,WAAW,OAAO,YAAY;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,kBAAkB;AACxB,WAAO,OAAO;AAAA,MACZ,UAAU;AAAA,MACV,UAAU,KAAK;AAAA,IACjB;AAAA,EACF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kBAAkB,KAAK,gBAAgB,GAAG;AACvE,iBAAS;AAAA,MACX;AAEA,aAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,MAAM,WAAW,SAAwD;AACvE,UAAM,EAAE,KAAK,IAAI,IAAI;AAErB,UAAM,MAAM,MAAM,IAAI,WAAW;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,43 @@
1
+ // tools/fastapply/prompts.ts
2
+ var EDIT_FILE_TOOL_DESCRIPTION = `Use this tool to make an edit to an existing file.
3
+
4
+ This 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.
5
+
6
+ When writing the edit, you should specify each edit in sequence, with the special comment // ... existing code ... to represent unchanged code in between edited lines.
7
+
8
+ For example:
9
+
10
+ // ... existing code ...
11
+ FIRST_EDIT
12
+ // ... existing code ...
13
+ SECOND_EDIT
14
+ // ... existing code ...
15
+ THIRD_EDIT
16
+ // ... existing code ...
17
+
18
+ You should still bias towards repeating as few lines of the original file as possible to convey the change.
19
+ But, each edit should contain minimally sufficient context of unchanged lines around the code you're editing to resolve ambiguity.
20
+
21
+ DO 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.
22
+
23
+ If you plan on deleting a section, you must provide context before and after to delete it.
24
+
25
+ Make sure it is clear what the edit should be, and where it should be applied.
26
+ Make 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.`;
27
+ var 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:
28
+
29
+ // ... existing code ...
30
+ {{ edit_1 }}
31
+ // ... existing code ...
32
+ {{ edit_2 }}
33
+ // ... existing code ...
34
+
35
+ Often 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.
36
+
37
+ These 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.`;
38
+
39
+ export {
40
+ EDIT_FILE_TOOL_DESCRIPTION,
41
+ EDIT_FILE_SYSTEM_PROMPT
42
+ };
43
+ //# sourceMappingURL=chunk-63WE2C5R.js.map