@morphllm/morphsdk 0.2.44 → 0.2.46
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/README.md +1 -1
- package/dist/{chunk-TVFGHXPE.js → chunk-3FTAIJBH.js} +4 -4
- package/dist/chunk-5JTJOQUX.js +283 -0
- package/dist/chunk-5JTJOQUX.js.map +1 -0
- package/dist/{chunk-ZRLEAPZV.js → chunk-76DJEQEP.js} +4 -4
- package/dist/{chunk-W3XLPMV3.js → chunk-7HS6YXA3.js} +21 -5
- package/dist/{chunk-W3XLPMV3.js.map → chunk-7HS6YXA3.js.map} +1 -1
- package/dist/chunk-7T7YOPJV.js +82 -0
- package/dist/chunk-7T7YOPJV.js.map +1 -0
- package/dist/chunk-CL45IWIU.js +105 -0
- package/dist/chunk-CL45IWIU.js.map +1 -0
- package/dist/chunk-D6OD3IST.js +70 -0
- package/dist/chunk-D6OD3IST.js.map +1 -0
- package/dist/{chunk-PEGZVGG4.js → chunk-G4AWE5A2.js} +4 -4
- package/dist/{chunk-OUEJ6XEO.js → chunk-GJU7UOFL.js} +4 -4
- package/dist/{chunk-Q7PDN7TS.js → chunk-GZMUGMOZ.js} +1 -1
- package/dist/{chunk-Q7PDN7TS.js.map → chunk-GZMUGMOZ.js.map} +1 -1
- package/dist/chunk-JYBVRF72.js +1 -0
- package/dist/{chunk-EYHXBQQX.js → chunk-LVY5LPEX.js} +70 -10
- package/dist/chunk-LVY5LPEX.js.map +1 -0
- package/dist/{chunk-GDR65N2J.js → chunk-OXHGFHEU.js} +53 -26
- package/dist/chunk-OXHGFHEU.js.map +1 -0
- package/dist/{chunk-VBBJGWHY.js → chunk-P2XKFWFD.js} +2 -2
- package/dist/chunk-PABIV7X6.js +76 -0
- package/dist/chunk-PABIV7X6.js.map +1 -0
- package/dist/{chunk-GTOXMAF2.js → chunk-SWQPIKPY.js} +44 -3
- package/dist/chunk-SWQPIKPY.js.map +1 -0
- package/dist/chunk-TJIUA27P.js +94 -0
- package/dist/chunk-TJIUA27P.js.map +1 -0
- package/dist/{chunk-O5DA5V5S.js → chunk-UBX7QYBD.js} +4 -4
- package/dist/{chunk-X4CQ6D3G.js → chunk-UIZT3KVJ.js} +4 -4
- package/dist/{chunk-UYBIKZPM.js → chunk-UXYK7WZX.js} +2 -2
- package/dist/chunk-WETRQJGU.js +129 -0
- package/dist/chunk-WETRQJGU.js.map +1 -0
- package/dist/client-BGctTHu9.d.ts +318 -0
- package/dist/client.cjs +1954 -53
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +14 -110
- package/dist/client.js +29 -4
- package/dist/core-DxiUwyBe.d.ts +156 -0
- package/dist/git/client.cjs +52 -25
- package/dist/git/client.cjs.map +1 -1
- package/dist/git/client.d.ts +17 -8
- package/dist/git/client.js +1 -1
- package/dist/git/index.cjs +52 -25
- package/dist/git/index.cjs.map +1 -1
- package/dist/git/index.d.ts +1 -1
- package/dist/git/index.js +2 -2
- package/dist/git/types.cjs.map +1 -1
- package/dist/git/types.d.ts +20 -2
- package/dist/index.cjs +2033 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +48 -6
- package/dist/tools/browser/anthropic.cjs +1 -0
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +1 -1
- package/dist/tools/browser/core.cjs +69 -9
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.js +1 -1
- package/dist/tools/browser/index.cjs +69 -9
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.js +1 -1
- package/dist/tools/browser/openai.cjs +1 -0
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.js +1 -1
- package/dist/tools/browser/types.cjs.map +1 -1
- package/dist/tools/browser/types.d.ts +2 -0
- package/dist/tools/browser/vercel.cjs +1 -0
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.js +1 -1
- package/dist/tools/codebase_search/anthropic.js +2 -2
- package/dist/tools/codebase_search/index.js +9 -9
- package/dist/tools/codebase_search/openai.js +2 -2
- package/dist/tools/codebase_search/vercel.js +2 -2
- package/dist/tools/fastapply/anthropic.js +2 -2
- package/dist/tools/fastapply/index.js +7 -7
- package/dist/tools/fastapply/openai.js +2 -2
- package/dist/tools/fastapply/vercel.js +2 -2
- package/dist/tools/index.js +7 -7
- package/dist/tools/warp_grep/agent/config.cjs +80 -1
- package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/config.js +1 -1
- package/dist/tools/warp_grep/agent/parser.cjs +43 -2
- package/dist/tools/warp_grep/agent/parser.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/parser.js +1 -1
- package/dist/tools/warp_grep/agent/prompt.cjs +89 -45
- package/dist/tools/warp_grep/agent/prompt.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/prompt.d.ts +1 -1
- package/dist/tools/warp_grep/agent/prompt.js +1 -1
- package/dist/tools/warp_grep/agent/runner.cjs +229 -49
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +4 -4
- package/dist/tools/warp_grep/agent/types.js +0 -1
- package/dist/tools/warp_grep/anthropic.cjs +311 -83
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +75 -12
- package/dist/tools/warp_grep/anthropic.js +21 -8
- package/dist/tools/warp_grep/index.cjs +415 -126
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +17 -4
- package/dist/tools/warp_grep/index.js +29 -21
- package/dist/tools/warp_grep/openai.cjs +314 -83
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +73 -29
- package/dist/tools/warp_grep/openai.js +21 -8
- package/dist/tools/warp_grep/providers/command.cjs +80 -1
- package/dist/tools/warp_grep/providers/command.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/command.js +2 -2
- package/dist/tools/warp_grep/providers/local.cjs +80 -1
- package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/local.js +2 -2
- package/dist/tools/warp_grep/vercel.cjs +291 -57
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +40 -19
- package/dist/tools/warp_grep/vercel.js +17 -8
- package/package.json +1 -1
- package/dist/chunk-AFEPUNAO.js +0 -15
- package/dist/chunk-AFEPUNAO.js.map +0 -1
- package/dist/chunk-EYHXBQQX.js.map +0 -1
- package/dist/chunk-GDR65N2J.js.map +0 -1
- package/dist/chunk-GTOXMAF2.js.map +0 -1
- package/dist/chunk-HKZB23U7.js +0 -85
- package/dist/chunk-HKZB23U7.js.map +0 -1
- package/dist/chunk-IQHKEIQX.js +0 -54
- package/dist/chunk-IQHKEIQX.js.map +0 -1
- package/dist/chunk-JKFVDM62.js +0 -45
- package/dist/chunk-JKFVDM62.js.map +0 -1
- package/dist/chunk-KL4YVZRF.js +0 -57
- package/dist/chunk-KL4YVZRF.js.map +0 -1
- package/dist/chunk-SMR2T5BT.js +0 -104
- package/dist/chunk-SMR2T5BT.js.map +0 -1
- package/dist/chunk-XYPMN4A3.js +0 -1
- /package/dist/{chunk-TVFGHXPE.js.map → chunk-3FTAIJBH.js.map} +0 -0
- /package/dist/{chunk-ZRLEAPZV.js.map → chunk-76DJEQEP.js.map} +0 -0
- /package/dist/{chunk-PEGZVGG4.js.map → chunk-G4AWE5A2.js.map} +0 -0
- /package/dist/{chunk-OUEJ6XEO.js.map → chunk-GJU7UOFL.js.map} +0 -0
- /package/dist/{chunk-XYPMN4A3.js.map → chunk-JYBVRF72.js.map} +0 -0
- /package/dist/{chunk-VBBJGWHY.js.map → chunk-P2XKFWFD.js.map} +0 -0
- /package/dist/{chunk-O5DA5V5S.js.map → chunk-UBX7QYBD.js.map} +0 -0
- /package/dist/{chunk-X4CQ6D3G.js.map → chunk-UIZT3KVJ.js.map} +0 -0
- /package/dist/{chunk-UYBIKZPM.js.map → chunk-UXYK7WZX.js.map} +0 -0
package/dist/client.d.ts
CHANGED
|
@@ -1,115 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import './
|
|
1
|
+
import './tools/utils/resilience.js';
|
|
2
|
+
import './tools/fastapply/core.js';
|
|
3
|
+
import './tools/codebase_search/core.js';
|
|
4
|
+
import './tools/browser/core.js';
|
|
5
|
+
import './core-DxiUwyBe.js';
|
|
6
|
+
import './git/client.js';
|
|
7
|
+
import './modelrouter/core.js';
|
|
8
|
+
export { M as MorphClient, a as MorphClientConfig } from './client-BGctTHu9.js';
|
|
8
9
|
import './tools/fastapply/types.js';
|
|
9
10
|
import './tools/codebase_search/types.js';
|
|
10
11
|
import './tools/browser/types.js';
|
|
11
|
-
import './
|
|
12
|
+
import './tools/warp_grep/providers/types.js';
|
|
13
|
+
import './git/types.js';
|
|
12
14
|
import 'isomorphic-git';
|
|
13
15
|
import 'isomorphic-git/http/node';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* Provides access to all Morph tools through a single interface
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* import { MorphClient } from '@cuda_oom/morphsdk';
|
|
23
|
-
*
|
|
24
|
-
* const morph = new MorphClient({
|
|
25
|
-
* apiKey: process.env.MORPH_API_KEY,
|
|
26
|
-
* debug: true,
|
|
27
|
-
* timeout: 60000
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* // Use FastApply
|
|
31
|
-
* const editResult = await morph.fastApply.execute({
|
|
32
|
-
* target_filepath: 'src/index.ts',
|
|
33
|
-
* instructions: 'Add error handling',
|
|
34
|
-
* code_edit: 'try { ... } catch (e) { ... }'
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* // Use CodebaseSearch
|
|
38
|
-
* const searchResult = await morph.codebaseSearch.search({
|
|
39
|
-
* query: 'authentication logic',
|
|
40
|
-
* repoId: 'my-project'
|
|
41
|
-
* });
|
|
42
|
-
*
|
|
43
|
-
* // Use Browser automation
|
|
44
|
-
* const browserResult = await morph.browser.execute({
|
|
45
|
-
* task: 'Test the checkout flow',
|
|
46
|
-
* url: 'https://example.com'
|
|
47
|
-
* });
|
|
48
|
-
*
|
|
49
|
-
* // Use Model Router
|
|
50
|
-
* const { model } = await morph.routers.openai.selectModel({
|
|
51
|
-
* input: 'Complex refactoring task',
|
|
52
|
-
* mode: 'balanced'
|
|
53
|
-
* });
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Configuration for the MorphClient
|
|
59
|
-
*/
|
|
60
|
-
interface MorphClientConfig {
|
|
61
|
-
/** Morph API key for authentication (defaults to MORPH_API_KEY env var) */
|
|
62
|
-
apiKey?: string;
|
|
63
|
-
/** Enable debug logging across all tools */
|
|
64
|
-
debug?: boolean;
|
|
65
|
-
/** Default timeout in milliseconds for API requests */
|
|
66
|
-
timeout?: number;
|
|
67
|
-
/** Retry configuration for failed requests */
|
|
68
|
-
retryConfig?: RetryConfig;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Unified Morph SDK Client
|
|
72
|
-
*
|
|
73
|
-
* Provides access to all Morph tools through a single interface:
|
|
74
|
-
* - fastApply: AI-powered file editing with intelligent merging
|
|
75
|
-
* - codebaseSearch: Semantic code search
|
|
76
|
-
* - browser: AI-powered browser automation
|
|
77
|
-
* - git: Version control operations
|
|
78
|
-
* - routers: Intelligent model selection (OpenAI, Anthropic, Gemini)
|
|
79
|
-
*/
|
|
80
|
-
declare class MorphClient {
|
|
81
|
-
/** Client configuration */
|
|
82
|
-
config: MorphClientConfig;
|
|
83
|
-
/** FastApply tool for editing files with AI-powered merge */
|
|
84
|
-
fastApply: FastApplyClient;
|
|
85
|
-
/** CodebaseSearch tool for semantic code search */
|
|
86
|
-
codebaseSearch: CodebaseSearchClient;
|
|
87
|
-
/** Browser tool for AI-powered browser automation */
|
|
88
|
-
browser: BrowserClient;
|
|
89
|
-
/** Git tool for version control operations */
|
|
90
|
-
git: MorphGit;
|
|
91
|
-
/** Model routers for intelligent model selection */
|
|
92
|
-
routers: {
|
|
93
|
-
openai: OpenAIRouter;
|
|
94
|
-
anthropic: AnthropicRouter;
|
|
95
|
-
gemini: GeminiRouter;
|
|
96
|
-
raw: RawRouter;
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Create a new Morph SDK client
|
|
100
|
-
*
|
|
101
|
-
* @param config - Client configuration (apiKey, debug, timeout, retryConfig)
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ```typescript
|
|
105
|
-
* const morph = new MorphClient({
|
|
106
|
-
* apiKey: process.env.MORPH_API_KEY,
|
|
107
|
-
* debug: true,
|
|
108
|
-
* timeout: 60000
|
|
109
|
-
* });
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
constructor(config?: MorphClientConfig);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export { MorphClient, type MorphClientConfig };
|
|
16
|
+
import './modelrouter/types.js';
|
|
17
|
+
import 'openai/resources/index.mjs';
|
|
18
|
+
import '@anthropic-ai/sdk/resources/messages.mjs';
|
|
19
|
+
import 'ai';
|
package/dist/client.js
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MorphClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5JTJOQUX.js";
|
|
4
|
+
import "./chunk-PABIV7X6.js";
|
|
5
|
+
import "./chunk-7T7YOPJV.js";
|
|
6
|
+
import "./chunk-D6OD3IST.js";
|
|
7
|
+
import "./chunk-CL45IWIU.js";
|
|
8
|
+
import "./chunk-7HS6YXA3.js";
|
|
9
|
+
import "./chunk-EK7OQPWD.js";
|
|
10
|
+
import "./chunk-Z2FBMSNE.js";
|
|
11
|
+
import "./chunk-SWQPIKPY.js";
|
|
12
|
+
import "./chunk-WETRQJGU.js";
|
|
13
|
+
import "./chunk-UXYK7WZX.js";
|
|
14
|
+
import "./chunk-G2RSY56Q.js";
|
|
15
|
+
import "./chunk-SMGZ6A64.js";
|
|
16
|
+
import "./chunk-RSLIOCOE.js";
|
|
17
|
+
import "./chunk-73RQWOQC.js";
|
|
18
|
+
import "./chunk-TJIUA27P.js";
|
|
19
|
+
import "./chunk-TICMYDII.js";
|
|
20
|
+
import "./chunk-NDZO5IPV.js";
|
|
21
|
+
import "./chunk-UBX7QYBD.js";
|
|
22
|
+
import "./chunk-GJU7UOFL.js";
|
|
23
|
+
import "./chunk-76DJEQEP.js";
|
|
4
24
|
import "./chunk-WM77HRKO.js";
|
|
25
|
+
import "./chunk-YQMPVJ2L.js";
|
|
26
|
+
import "./chunk-3FTAIJBH.js";
|
|
27
|
+
import "./chunk-G4AWE5A2.js";
|
|
28
|
+
import "./chunk-UIZT3KVJ.js";
|
|
5
29
|
import "./chunk-64PMM72R.js";
|
|
6
|
-
import "./chunk-
|
|
30
|
+
import "./chunk-63WE2C5R.js";
|
|
31
|
+
import "./chunk-LVY5LPEX.js";
|
|
7
32
|
import "./chunk-SQN4DUQS.js";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
33
|
+
import "./chunk-GZMUGMOZ.js";
|
|
34
|
+
import "./chunk-OXHGFHEU.js";
|
|
10
35
|
import "./chunk-CP4NZGRY.js";
|
|
11
36
|
import "./chunk-4VWJFZVS.js";
|
|
12
37
|
import "./chunk-PZ5AY32C.js";
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { WarpGrepProvider } from './tools/warp_grep/providers/types.js';
|
|
2
|
+
import { RetryConfig } from './tools/utils/resilience.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for WarpGrepClient
|
|
6
|
+
*/
|
|
7
|
+
interface WarpGrepClientConfig {
|
|
8
|
+
/** Morph API key (defaults to MORPH_API_KEY env var) */
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
/** Enable debug logging */
|
|
11
|
+
debug?: boolean;
|
|
12
|
+
/** Request timeout in milliseconds */
|
|
13
|
+
timeout?: number;
|
|
14
|
+
/** Retry configuration */
|
|
15
|
+
retryConfig?: RetryConfig;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Input for warp grep execution
|
|
19
|
+
*/
|
|
20
|
+
interface WarpGrepInput {
|
|
21
|
+
/** Free-form repository question */
|
|
22
|
+
query: string;
|
|
23
|
+
/** Root directory of the repository to search */
|
|
24
|
+
repoRoot: string;
|
|
25
|
+
/** Optional custom provider (defaults to LocalRipgrepProvider) */
|
|
26
|
+
provider?: WarpGrepProvider;
|
|
27
|
+
/** Glob patterns to exclude from search */
|
|
28
|
+
excludes?: string[];
|
|
29
|
+
/** Glob patterns to include in search */
|
|
30
|
+
includes?: string[];
|
|
31
|
+
/** Enable debug logging for this request */
|
|
32
|
+
debug?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A single context result with file path and content
|
|
36
|
+
*/
|
|
37
|
+
interface WarpGrepContext {
|
|
38
|
+
/** File path relative to repo root */
|
|
39
|
+
file: string;
|
|
40
|
+
/** Content of the relevant code section */
|
|
41
|
+
content: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Result from warp grep execution
|
|
45
|
+
*/
|
|
46
|
+
interface WarpGrepResult {
|
|
47
|
+
/** Whether the search completed successfully */
|
|
48
|
+
success: boolean;
|
|
49
|
+
/** Relevant code contexts found */
|
|
50
|
+
contexts?: WarpGrepContext[];
|
|
51
|
+
/** Summary of what was found */
|
|
52
|
+
summary?: string;
|
|
53
|
+
/** Error message if search failed */
|
|
54
|
+
error?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Configuration for creating a warp grep tool
|
|
58
|
+
*/
|
|
59
|
+
interface WarpGrepToolConfig {
|
|
60
|
+
/** Root directory of the repository to search */
|
|
61
|
+
repoRoot: string;
|
|
62
|
+
/** Optional custom provider (defaults to LocalRipgrepProvider) */
|
|
63
|
+
provider?: WarpGrepProvider;
|
|
64
|
+
/** Glob patterns to exclude from search */
|
|
65
|
+
excludes?: string[];
|
|
66
|
+
/** Glob patterns to include in search */
|
|
67
|
+
includes?: string[];
|
|
68
|
+
/** Enable debug logging */
|
|
69
|
+
debug?: boolean;
|
|
70
|
+
/** Morph API key (defaults to MORPH_API_KEY env var) */
|
|
71
|
+
apiKey?: string;
|
|
72
|
+
/** Custom tool description */
|
|
73
|
+
description?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Core implementation for morph-warp-grep
|
|
78
|
+
* Provides a client class for programmatic code search
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* WarpGrep client for programmatic code search
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* import { WarpGrepClient } from '@morphllm/morphsdk';
|
|
87
|
+
*
|
|
88
|
+
* const client = new WarpGrepClient({ apiKey: process.env.MORPH_API_KEY });
|
|
89
|
+
*
|
|
90
|
+
* // Simple usage - defaults to LocalRipgrepProvider
|
|
91
|
+
* const result = await client.execute({
|
|
92
|
+
* query: 'Find authentication middleware',
|
|
93
|
+
* repoRoot: '.'
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* // With custom excludes
|
|
97
|
+
* const result = await client.execute({
|
|
98
|
+
* query: 'Find database models',
|
|
99
|
+
* repoRoot: '.',
|
|
100
|
+
* excludes: ['node_modules', '.git', 'dist']
|
|
101
|
+
* });
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
declare class WarpGrepClient {
|
|
105
|
+
private config;
|
|
106
|
+
constructor(config?: WarpGrepClientConfig);
|
|
107
|
+
/**
|
|
108
|
+
* Execute a code search query
|
|
109
|
+
*
|
|
110
|
+
* @param input - Search parameters including query, repoRoot, and optional provider
|
|
111
|
+
* @returns Search results with relevant code contexts
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* const result = await client.execute({
|
|
116
|
+
* query: 'Find authentication middleware',
|
|
117
|
+
* repoRoot: '.'
|
|
118
|
+
* });
|
|
119
|
+
*
|
|
120
|
+
* if (result.success) {
|
|
121
|
+
* for (const ctx of result.contexts) {
|
|
122
|
+
* console.log(`File: ${ctx.file}`);
|
|
123
|
+
* console.log(ctx.content);
|
|
124
|
+
* }
|
|
125
|
+
* }
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
execute(input: WarpGrepInput): Promise<WarpGrepResult>;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Execute a warp grep search directly
|
|
132
|
+
*
|
|
133
|
+
* @param input - Search parameters
|
|
134
|
+
* @param config - Optional client configuration
|
|
135
|
+
* @returns Search results
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* import { executeWarpGrep } from '@morphllm/morphsdk/tools/warp-grep';
|
|
140
|
+
*
|
|
141
|
+
* const result = await executeWarpGrep({
|
|
142
|
+
* query: 'Find authentication middleware',
|
|
143
|
+
* repoRoot: '.'
|
|
144
|
+
* });
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare function executeWarpGrep(input: WarpGrepInput, config?: WarpGrepClientConfig): Promise<WarpGrepResult>;
|
|
148
|
+
/**
|
|
149
|
+
* Format warp grep results for display or tool responses
|
|
150
|
+
*
|
|
151
|
+
* @param result - The search result
|
|
152
|
+
* @returns Formatted string representation
|
|
153
|
+
*/
|
|
154
|
+
declare function formatResult(result: WarpGrepResult): string;
|
|
155
|
+
|
|
156
|
+
export { WarpGrepClient as W, type WarpGrepClientConfig as a, type WarpGrepInput as b, type WarpGrepResult as c, type WarpGrepContext as d, type WarpGrepToolConfig as e, formatResult as f, executeWarpGrep as g };
|
package/dist/git/client.cjs
CHANGED
|
@@ -135,28 +135,26 @@ var MorphGit = class {
|
|
|
135
135
|
* ```ts
|
|
136
136
|
* await morphGit.push({
|
|
137
137
|
* dir: './my-project',
|
|
138
|
-
* branch: 'main' // Required: explicit branch name
|
|
138
|
+
* branch: 'main', // Required: explicit branch name
|
|
139
|
+
* index: true // Optional: generate embeddings (default: true)
|
|
139
140
|
* });
|
|
140
141
|
* ```
|
|
141
142
|
*/
|
|
142
143
|
async push(options) {
|
|
143
|
-
const { dir, remote = "origin", branch, waitForEmbeddings } = options;
|
|
144
|
+
const { dir, remote = "origin", branch, waitForEmbeddings, index = true } = options;
|
|
144
145
|
if (!branch) {
|
|
145
146
|
throw new Error(
|
|
146
147
|
'branch is required for push operations. Specify the branch explicitly: { dir: "./my-project", branch: "main" }'
|
|
147
148
|
);
|
|
148
149
|
}
|
|
149
|
-
|
|
150
|
+
const commitHash = await import_isomorphic_git.default.resolveRef({ fs: import_fs.default, dir, ref: "HEAD" });
|
|
150
151
|
let repoId;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
if (
|
|
156
|
-
|
|
157
|
-
if (match) {
|
|
158
|
-
repoId = match[1];
|
|
159
|
-
}
|
|
152
|
+
const remotes = await import_isomorphic_git.default.listRemotes({ fs: import_fs.default, dir });
|
|
153
|
+
const originRemote = remotes.find((r) => r.remote === remote);
|
|
154
|
+
if (originRemote) {
|
|
155
|
+
const match = originRemote.url.match(/\/repos\/([^\/]+)$/);
|
|
156
|
+
if (match) {
|
|
157
|
+
repoId = match[1];
|
|
160
158
|
}
|
|
161
159
|
}
|
|
162
160
|
await import_isomorphic_git.default.push({
|
|
@@ -167,10 +165,35 @@ var MorphGit = class {
|
|
|
167
165
|
ref: branch,
|
|
168
166
|
onAuth: this.getAuthCallback()
|
|
169
167
|
});
|
|
170
|
-
if (
|
|
168
|
+
if (repoId && commitHash) {
|
|
169
|
+
await this.configureCommit({ repoId, commitHash, branch, index });
|
|
170
|
+
}
|
|
171
|
+
if (waitForEmbeddings && repoId && commitHash && index) {
|
|
171
172
|
await this.waitForEmbeddings({ repoId, commitHash });
|
|
172
173
|
}
|
|
173
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Configure commit settings on the backend after push.
|
|
177
|
+
* Sets the index flag to control embedding generation.
|
|
178
|
+
* @private
|
|
179
|
+
*/
|
|
180
|
+
async configureCommit(options) {
|
|
181
|
+
const { repoId, commitHash, branch, index } = options;
|
|
182
|
+
const response = await fetch(
|
|
183
|
+
`${this.proxyUrl}/v1/repos/${repoId}/commits/${commitHash}/config`,
|
|
184
|
+
{
|
|
185
|
+
method: "POST",
|
|
186
|
+
headers: {
|
|
187
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
188
|
+
"Content-Type": "application/json"
|
|
189
|
+
},
|
|
190
|
+
body: JSON.stringify({ index, branch })
|
|
191
|
+
}
|
|
192
|
+
);
|
|
193
|
+
if (!response.ok) {
|
|
194
|
+
console.warn(`Failed to configure commit: ${response.status}`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
174
197
|
/**
|
|
175
198
|
* Pull changes from remote repository
|
|
176
199
|
*
|
|
@@ -295,6 +318,7 @@ var MorphGit = class {
|
|
|
295
318
|
* name: 'AI Agent',
|
|
296
319
|
* email: 'ai@example.com'
|
|
297
320
|
* },
|
|
321
|
+
* metadata: { issueId: 'PROJ-123', source: 'agent' },
|
|
298
322
|
* chatHistory: [
|
|
299
323
|
* { role: 'user', content: 'Please add a new feature' },
|
|
300
324
|
* { role: 'assistant', content: 'I will add that feature' }
|
|
@@ -304,7 +328,7 @@ var MorphGit = class {
|
|
|
304
328
|
* ```
|
|
305
329
|
*/
|
|
306
330
|
async commit(options) {
|
|
307
|
-
const { dir, message, author, chatHistory, recordingId } = options;
|
|
331
|
+
const { dir, message, author, metadata, chatHistory, recordingId } = options;
|
|
308
332
|
const commitAuthor = author || {
|
|
309
333
|
name: "Morph SDK",
|
|
310
334
|
email: "sdk@morphllm.com"
|
|
@@ -315,17 +339,19 @@ var MorphGit = class {
|
|
|
315
339
|
message,
|
|
316
340
|
author: commitAuthor
|
|
317
341
|
});
|
|
318
|
-
if (chatHistory || recordingId) {
|
|
319
|
-
const
|
|
342
|
+
if (metadata || chatHistory || recordingId) {
|
|
343
|
+
const notes = {
|
|
344
|
+
metadata,
|
|
320
345
|
chatHistory,
|
|
321
|
-
recordingId
|
|
346
|
+
recordingId,
|
|
347
|
+
_version: 1
|
|
322
348
|
};
|
|
323
349
|
await import_isomorphic_git.default.addNote({
|
|
324
350
|
fs: import_fs.default,
|
|
325
351
|
dir,
|
|
326
352
|
ref: "refs/notes/morph-metadata",
|
|
327
353
|
oid: sha,
|
|
328
|
-
note: JSON.stringify(
|
|
354
|
+
note: JSON.stringify(notes, null, 2),
|
|
329
355
|
author: commitAuthor
|
|
330
356
|
});
|
|
331
357
|
}
|
|
@@ -514,18 +540,19 @@ var MorphGit = class {
|
|
|
514
540
|
return oid;
|
|
515
541
|
}
|
|
516
542
|
/**
|
|
517
|
-
* Get metadata
|
|
543
|
+
* Get notes (metadata, chat history, recording ID) attached to a commit
|
|
518
544
|
*
|
|
519
545
|
* @example
|
|
520
546
|
* ```ts
|
|
521
|
-
* const
|
|
547
|
+
* const notes = await morphGit.getCommitMetadata({
|
|
522
548
|
* dir: './my-project',
|
|
523
549
|
* commitSha: 'abc123...'
|
|
524
550
|
* });
|
|
525
551
|
*
|
|
526
|
-
* if (
|
|
527
|
-
* console.log('
|
|
528
|
-
* console.log('
|
|
552
|
+
* if (notes) {
|
|
553
|
+
* console.log('Metadata:', notes.metadata);
|
|
554
|
+
* console.log('Chat history:', notes.chatHistory);
|
|
555
|
+
* console.log('Recording ID:', notes.recordingId);
|
|
529
556
|
* }
|
|
530
557
|
* ```
|
|
531
558
|
*/
|
|
@@ -537,8 +564,8 @@ var MorphGit = class {
|
|
|
537
564
|
ref: "refs/notes/morph-metadata",
|
|
538
565
|
oid: options.commitSha
|
|
539
566
|
});
|
|
540
|
-
const
|
|
541
|
-
return
|
|
567
|
+
const notes = JSON.parse(new TextDecoder().decode(note));
|
|
568
|
+
return notes;
|
|
542
569
|
} catch (err) {
|
|
543
570
|
return null;
|
|
544
571
|
}
|
package/dist/git/client.cjs.map
CHANGED
|
@@ -1 +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 CommitMetadata,\n WaitForEmbeddingsOptions,\n EmbeddingProgress,\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 repository (industry standard: no clone needed)\n await git.init({\n fs,\n dir,\n defaultBranch,\n });\n\n // Add remote pointing to Morph git-proxy\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 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({ \n * dir: './my-project',\n * branch: 'main' // Required: explicit branch name\n * });\n * ```\n */\n async push(options: PushOptions): Promise<void> {\n const { dir, remote = 'origin', branch, waitForEmbeddings } = options;\n\n if (!branch) {\n throw new Error(\n 'branch is required for push operations. ' +\n 'Specify the branch explicitly: { dir: \"./my-project\", branch: \"main\" }'\n );\n }\n\n // Get commit hash and repoId before pushing (for waitForEmbeddings)\n let commitHash: string | undefined;\n let repoId: string | undefined;\n \n if (waitForEmbeddings) {\n commitHash = await git.resolveRef({ fs, dir, ref: 'HEAD' });\n \n // Get repoId from git remote URL\n const remotes = await git.listRemotes({ fs, dir });\n const originRemote = remotes.find(r => r.remote === remote);\n if (originRemote) {\n // Extract repoId from URL: https://repos.morphllm.com/v1/repos/{repoId}\n const match = originRemote.url.match(/\\/repos\\/([^\\/]+)$/);\n if (match) {\n repoId = match[1];\n }\n }\n }\n\n await git.push({\n fs,\n http,\n dir,\n remote,\n ref: branch,\n onAuth: this.getAuthCallback(),\n });\n \n // Wait for embeddings if requested\n if (waitForEmbeddings && repoId && commitHash) {\n await this.waitForEmbeddings({ repoId, commitHash });\n }\n }\n\n /**\n * Pull changes from remote repository\n * \n * @example\n * ```ts\n * await morphGit.pull({ \n * dir: './my-project',\n * branch: 'main' // Required: explicit branch name\n * });\n * ```\n */\n async pull(options: PullOptions): Promise<void> {\n const { dir, remote = 'origin', branch } = options;\n\n if (!branch) {\n throw new Error(\n 'branch is required for pull operations. ' +\n 'Specify the branch explicitly: { dir: \"./my-project\", branch: \"main\" }'\n );\n }\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 * Wait for embeddings to complete after push.\n * Polls status endpoint until embeddings are done.\n * \n * @example\n * ```ts\n * await morphGit.push({ dir: './my-project', branch: 'main' });\n * await morphGit.waitForEmbeddings({\n * repoId: 'my-project',\n * onProgress: (p) => console.log(`${p.filesProcessed}/${p.totalFiles}`)\n * });\n * ```\n */\n async waitForEmbeddings(options: WaitForEmbeddingsOptions): Promise<void> {\n const { repoId, commitHash, timeout = 120000, onProgress } = options;\n const startTime = Date.now();\n const pollInterval = 1000; // Poll every 1s\n \n while (Date.now() - startTime < timeout) {\n const statusUrl = `${this.proxyUrl}/v1/repos/${repoId}/embedding-status` +\n (commitHash ? `?commit_hash=${commitHash}` : '');\n \n const response = await fetch(statusUrl, {\n headers: { 'Authorization': `Bearer ${this.apiKey}` }\n });\n \n if (response.status === 404) {\n // No job found yet - might still be creating\n await new Promise(resolve => setTimeout(resolve, pollInterval));\n continue;\n }\n \n if (!response.ok) {\n throw new Error(`Failed to get embedding status: ${response.status}`);\n }\n \n const status = await response.json();\n \n if (onProgress && status.progress) {\n onProgress(status.progress);\n }\n \n if (status.status === 'completed') {\n return; // Done!\n }\n \n if (status.status === 'failed') {\n throw new Error(`Embeddings failed: ${status.error || 'Unknown error'}`);\n }\n \n // Still processing (queued or processing), wait and poll again\n await new Promise(resolve => setTimeout(resolve, pollInterval));\n }\n \n throw new Error(`Embeddings timed out after ${timeout}ms`);\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 * chatHistory: [\n * { role: 'user', content: 'Please add a new feature' },\n * { role: 'assistant', content: 'I will add that feature' }\n * ],\n * recordingId: 'rec_123'\n * });\n * ```\n */\n async commit(options: CommitOptions): Promise<string> {\n const { dir, message, author, chatHistory, recordingId } = 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 // Store metadata as git note if provided\n if (chatHistory || recordingId) {\n const metadata: CommitMetadata = {\n chatHistory,\n recordingId\n };\n \n await git.addNote({\n fs,\n dir,\n ref: 'refs/notes/morph-metadata',\n oid: sha,\n note: JSON.stringify(metadata, null, 2),\n author: commitAuthor\n });\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 * Get metadata (chat history, recording ID) attached to a commit\n * \n * @example\n * ```ts\n * const metadata = await morphGit.getCommitMetadata({\n * dir: './my-project',\n * commitSha: 'abc123...'\n * });\n * \n * if (metadata) {\n * console.log('Chat history:', metadata.chatHistory);\n * console.log('Recording ID:', metadata.recordingId);\n * }\n * ```\n */\n async getCommitMetadata(options: {\n dir: string;\n commitSha: string;\n }): Promise<CommitMetadata | null> {\n try {\n const note = await git.readNote({\n fs,\n dir: options.dir,\n ref: 'refs/notes/morph-metadata',\n oid: options.commitSha\n });\n \n const metadata = JSON.parse(new TextDecoder().decode(note));\n return metadata;\n } catch (err) {\n // No metadata found for this commit\n return null;\n }\n }\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,4BAAgB;AAChB,kBAAiB;AACjB,gBAAe;AAoBf,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeA,MAAM,KAAK,SAIO;AAChB,UAAM,EAAE,QAAQ,KAAK,gBAAgB,OAAO,IAAI;AAGhD,UAAM,WAAW,MAAM,MAAM,GAAG,KAAK,QA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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA,MAAM,kBAAkB,SAGW;AACjC,QAAI;AACF,YAAM,OAAO,MAAM,sBAAAD,QAAI,SAAS;AAAA,QAC9B,cAAAC;AAAA,QACA,KAAK,QAAQ;AAAA,QACb,KAAK;AAAA,QACL,KAAK,QAAQ;AAAA,MACf,CAAC;AAED,YAAM,WAAW,KAAK,MAAM,IAAI,YAAY,EAAE,OAAO,IAAI,CAAC;AAC1D,aAAO;AAAA,IACT,SAAS,KAAK;AAEZ,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["git","fs","http"]}
|
|
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 MorphNotesSchema,\n WaitForEmbeddingsOptions,\n EmbeddingProgress,\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 repository (industry standard: no clone needed)\n await git.init({\n fs,\n dir,\n defaultBranch,\n });\n\n // Add remote pointing to Morph git-proxy\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 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({ \n * dir: './my-project',\n * branch: 'main', // Required: explicit branch name\n * index: true // Optional: generate embeddings (default: true)\n * });\n * ```\n */\n async push(options: PushOptions): Promise<void> {\n const { dir, remote = 'origin', branch, waitForEmbeddings, index = true } = options;\n\n if (!branch) {\n throw new Error(\n 'branch is required for push operations. ' +\n 'Specify the branch explicitly: { dir: \"./my-project\", branch: \"main\" }'\n );\n }\n\n // Get commit hash and repoId before pushing\n const commitHash = await git.resolveRef({ fs, dir, ref: 'HEAD' });\n \n // Get repoId from git remote URL\n let repoId: string | undefined;\n const remotes = await git.listRemotes({ fs, dir });\n const originRemote = remotes.find(r => r.remote === remote);\n if (originRemote) {\n // Extract repoId from URL: https://repos.morphllm.com/v1/repos/{repoId}\n const match = originRemote.url.match(/\\/repos\\/([^\\/]+)$/);\n if (match) {\n repoId = match[1];\n }\n }\n\n await git.push({\n fs,\n http,\n dir,\n remote,\n ref: branch,\n onAuth: this.getAuthCallback(),\n });\n \n // Configure commit after successful push (set index flag)\n if (repoId && commitHash) {\n await this.configureCommit({ repoId, commitHash, branch, index });\n }\n \n // Wait for embeddings if requested (and indexing is enabled)\n if (waitForEmbeddings && repoId && commitHash && index) {\n await this.waitForEmbeddings({ repoId, commitHash });\n }\n }\n\n /**\n * Configure commit settings on the backend after push.\n * Sets the index flag to control embedding generation.\n * @private\n */\n private async configureCommit(options: {\n repoId: string;\n commitHash: string;\n branch: string;\n index: boolean;\n }): Promise<void> {\n const { repoId, commitHash, branch, index } = options;\n \n const response = await fetch(\n `${this.proxyUrl}/v1/repos/${repoId}/commits/${commitHash}/config`,\n {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${this.apiKey}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ index, branch }),\n }\n );\n\n if (!response.ok) {\n // Non-fatal: log warning but don't throw\n console.warn(`Failed to configure commit: ${response.status}`);\n }\n }\n\n /**\n * Pull changes from remote repository\n * \n * @example\n * ```ts\n * await morphGit.pull({ \n * dir: './my-project',\n * branch: 'main' // Required: explicit branch name\n * });\n * ```\n */\n async pull(options: PullOptions): Promise<void> {\n const { dir, remote = 'origin', branch } = options;\n\n if (!branch) {\n throw new Error(\n 'branch is required for pull operations. ' +\n 'Specify the branch explicitly: { dir: \"./my-project\", branch: \"main\" }'\n );\n }\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 * Wait for embeddings to complete after push.\n * Polls status endpoint until embeddings are done.\n * \n * @example\n * ```ts\n * await morphGit.push({ dir: './my-project', branch: 'main' });\n * await morphGit.waitForEmbeddings({\n * repoId: 'my-project',\n * onProgress: (p) => console.log(`${p.filesProcessed}/${p.totalFiles}`)\n * });\n * ```\n */\n async waitForEmbeddings(options: WaitForEmbeddingsOptions): Promise<void> {\n const { repoId, commitHash, timeout = 120000, onProgress } = options;\n const startTime = Date.now();\n const pollInterval = 1000; // Poll every 1s\n \n while (Date.now() - startTime < timeout) {\n const statusUrl = `${this.proxyUrl}/v1/repos/${repoId}/embedding-status` +\n (commitHash ? `?commit_hash=${commitHash}` : '');\n \n const response = await fetch(statusUrl, {\n headers: { 'Authorization': `Bearer ${this.apiKey}` }\n });\n \n if (response.status === 404) {\n // No job found yet - might still be creating\n await new Promise(resolve => setTimeout(resolve, pollInterval));\n continue;\n }\n \n if (!response.ok) {\n throw new Error(`Failed to get embedding status: ${response.status}`);\n }\n \n const status = await response.json();\n \n if (onProgress && status.progress) {\n onProgress(status.progress);\n }\n \n if (status.status === 'completed') {\n return; // Done!\n }\n \n if (status.status === 'failed') {\n throw new Error(`Embeddings failed: ${status.error || 'Unknown error'}`);\n }\n \n // Still processing (queued or processing), wait and poll again\n await new Promise(resolve => setTimeout(resolve, pollInterval));\n }\n \n throw new Error(`Embeddings timed out after ${timeout}ms`);\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 * metadata: { issueId: 'PROJ-123', source: 'agent' },\n * chatHistory: [\n * { role: 'user', content: 'Please add a new feature' },\n * { role: 'assistant', content: 'I will add that feature' }\n * ],\n * recordingId: 'rec_123'\n * });\n * ```\n */\n async commit(options: CommitOptions): Promise<string> {\n const { dir, message, author, metadata, chatHistory, recordingId } = 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 // Store notes if any note fields are provided\n if (metadata || chatHistory || recordingId) {\n const notes: MorphNotesSchema = {\n metadata,\n chatHistory,\n recordingId,\n _version: 1\n };\n \n await git.addNote({\n fs,\n dir,\n ref: 'refs/notes/morph-metadata',\n oid: sha,\n note: JSON.stringify(notes, null, 2),\n author: commitAuthor\n });\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 * Get notes (metadata, chat history, recording ID) attached to a commit\n * \n * @example\n * ```ts\n * const notes = await morphGit.getCommitMetadata({\n * dir: './my-project',\n * commitSha: 'abc123...'\n * });\n * \n * if (notes) {\n * console.log('Metadata:', notes.metadata);\n * console.log('Chat history:', notes.chatHistory);\n * console.log('Recording ID:', notes.recordingId);\n * }\n * ```\n */\n async getCommitMetadata(options: {\n dir: string;\n commitSha: string;\n }): Promise<MorphNotesSchema | null> {\n try {\n const note = await git.readNote({\n fs,\n dir: options.dir,\n ref: 'refs/notes/morph-metadata',\n oid: options.commitSha\n });\n \n const notes: MorphNotesSchema = JSON.parse(new TextDecoder().decode(note));\n return notes;\n } catch (err) {\n // No notes found for this commit\n return null;\n }\n }\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAA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AK,IAAI,IAAI;AAErB,UAAM,MAAM,MAAM,sBAAAD,QAAI,WAAW;AAAA,MAC/B,cAAAC;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBA,MAAM,kBAAkB,SAGa;AACnC,QAAI;AACF,YAAM,OAAO,MAAM,sBAAAD,QAAI,SAAS;AAAA,QAC9B,cAAAC;AAAA,QACA,KAAK,QAAQ;AAAA,QACb,KAAK;AAAA,QACL,KAAK,QAAQ;AAAA,MACf,CAAC;AAED,YAAM,QAA0B,KAAK,MAAM,IAAI,YAAY,EAAE,OAAO,IAAI,CAAC;AACzE,aAAO;AAAA,IACT,SAAS,KAAK;AAEZ,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["git","fs","http"]}
|
package/dist/git/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MorphGitConfig, CloneOptions, PushOptions, PullOptions, WaitForEmbeddingsOptions, AddOptions, CommitOptions, StatusOptions, LogOptions, CommitObject, CheckoutOptions, BranchOptions, StatusResult,
|
|
1
|
+
import { MorphGitConfig, CloneOptions, PushOptions, PullOptions, WaitForEmbeddingsOptions, AddOptions, CommitOptions, StatusOptions, LogOptions, CommitObject, CheckoutOptions, BranchOptions, StatusResult, MorphNotesSchema } from './types.js';
|
|
2
2
|
import 'isomorphic-git';
|
|
3
3
|
import 'isomorphic-git/http/node';
|
|
4
4
|
import '../tools/utils/resilience.js';
|
|
@@ -70,11 +70,18 @@ declare class MorphGit {
|
|
|
70
70
|
* ```ts
|
|
71
71
|
* await morphGit.push({
|
|
72
72
|
* dir: './my-project',
|
|
73
|
-
* branch: 'main' // Required: explicit branch name
|
|
73
|
+
* branch: 'main', // Required: explicit branch name
|
|
74
|
+
* index: true // Optional: generate embeddings (default: true)
|
|
74
75
|
* });
|
|
75
76
|
* ```
|
|
76
77
|
*/
|
|
77
78
|
push(options: PushOptions): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Configure commit settings on the backend after push.
|
|
81
|
+
* Sets the index flag to control embedding generation.
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
private configureCommit;
|
|
78
85
|
/**
|
|
79
86
|
* Pull changes from remote repository
|
|
80
87
|
*
|
|
@@ -137,6 +144,7 @@ declare class MorphGit {
|
|
|
137
144
|
* name: 'AI Agent',
|
|
138
145
|
* email: 'ai@example.com'
|
|
139
146
|
* },
|
|
147
|
+
* metadata: { issueId: 'PROJ-123', source: 'agent' },
|
|
140
148
|
* chatHistory: [
|
|
141
149
|
* { role: 'user', content: 'Please add a new feature' },
|
|
142
150
|
* { role: 'assistant', content: 'I will add that feature' }
|
|
@@ -251,25 +259,26 @@ declare class MorphGit {
|
|
|
251
259
|
ref: string;
|
|
252
260
|
}): Promise<string>;
|
|
253
261
|
/**
|
|
254
|
-
* Get metadata
|
|
262
|
+
* Get notes (metadata, chat history, recording ID) attached to a commit
|
|
255
263
|
*
|
|
256
264
|
* @example
|
|
257
265
|
* ```ts
|
|
258
|
-
* const
|
|
266
|
+
* const notes = await morphGit.getCommitMetadata({
|
|
259
267
|
* dir: './my-project',
|
|
260
268
|
* commitSha: 'abc123...'
|
|
261
269
|
* });
|
|
262
270
|
*
|
|
263
|
-
* if (
|
|
264
|
-
* console.log('
|
|
265
|
-
* console.log('
|
|
271
|
+
* if (notes) {
|
|
272
|
+
* console.log('Metadata:', notes.metadata);
|
|
273
|
+
* console.log('Chat history:', notes.chatHistory);
|
|
274
|
+
* console.log('Recording ID:', notes.recordingId);
|
|
266
275
|
* }
|
|
267
276
|
* ```
|
|
268
277
|
*/
|
|
269
278
|
getCommitMetadata(options: {
|
|
270
279
|
dir: string;
|
|
271
280
|
commitSha: string;
|
|
272
|
-
}): Promise<
|
|
281
|
+
}): Promise<MorphNotesSchema | null>;
|
|
273
282
|
}
|
|
274
283
|
|
|
275
284
|
export { MorphGit };
|