@morphllm/morphsdk 0.2.39 → 0.2.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-OKCGU7UD.js → chunk-4WIBODS7.js} +61 -2
- package/dist/chunk-4WIBODS7.js.map +1 -0
- package/dist/{chunk-LN4CTQZG.js → chunk-7MCSSJJA.js} +2 -2
- package/dist/{chunk-I7WWUHEC.js → chunk-DIWNR3UP.js} +2 -2
- package/dist/{chunk-W5CHJ6OX.js → chunk-JSZQVUSE.js} +2 -2
- package/dist/{chunk-YSBSDU75.js → chunk-LUI7APXX.js} +2 -2
- package/dist/{chunk-EAA7D24N.js → chunk-N5654KQR.js} +13 -13
- package/dist/client.cjs +60 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +2 -2
- package/dist/git/client.cjs +60 -1
- package/dist/git/client.cjs.map +1 -1
- package/dist/git/client.js +1 -1
- package/dist/git/index.cjs +60 -1
- package/dist/git/index.cjs.map +1 -1
- package/dist/git/index.js +1 -1
- package/dist/git/types.cjs.map +1 -1
- package/dist/index.cjs +60 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/tools/warp_grep/agent/runner.js +5 -5
- package/dist/tools/warp_grep/anthropic.js +6 -6
- package/dist/tools/warp_grep/index.js +8 -8
- package/dist/tools/warp_grep/openai.js +6 -6
- package/dist/tools/warp_grep/vercel.js +6 -6
- package/package.json +1 -1
- package/dist/anthropic-DpEAqqZF.d.ts +0 -88
- package/dist/chunk-OKCGU7UD.js.map +0 -1
- package/dist/client.d.ts +0 -114
- package/dist/git/client.d.ts +0 -261
- package/dist/git/config.d.ts +0 -11
- package/dist/git/index.d.ts +0 -5
- package/dist/git/types.d.ts +0 -102
- package/dist/index.d.ts +0 -14
- package/dist/modelrouter/core.d.ts +0 -69
- package/dist/modelrouter/index.d.ts +0 -2
- package/dist/modelrouter/types.d.ts +0 -39
- package/dist/openai-BkKsS30n.d.ts +0 -111
- package/dist/tools/browser/anthropic.d.ts +0 -51
- package/dist/tools/browser/core.d.ts +0 -203
- package/dist/tools/browser/index.d.ts +0 -72
- package/dist/tools/browser/openai.d.ts +0 -73
- package/dist/tools/browser/prompts.d.ts +0 -7
- package/dist/tools/browser/types.d.ts +0 -255
- package/dist/tools/browser/vercel.d.ts +0 -69
- package/dist/tools/codebase_search/anthropic.d.ts +0 -40
- package/dist/tools/codebase_search/core.d.ts +0 -40
- package/dist/tools/codebase_search/index.d.ts +0 -10
- package/dist/tools/codebase_search/openai.d.ts +0 -87
- package/dist/tools/codebase_search/prompts.d.ts +0 -7
- package/dist/tools/codebase_search/types.d.ts +0 -50
- package/dist/tools/codebase_search/vercel.d.ts +0 -65
- package/dist/tools/fastapply/anthropic.d.ts +0 -4
- package/dist/tools/fastapply/core.d.ts +0 -41
- package/dist/tools/fastapply/index.d.ts +0 -10
- package/dist/tools/fastapply/openai.d.ts +0 -4
- package/dist/tools/fastapply/prompts.d.ts +0 -7
- package/dist/tools/fastapply/types.d.ts +0 -77
- package/dist/tools/fastapply/vercel.d.ts +0 -4
- package/dist/tools/index.d.ts +0 -10
- package/dist/tools/utils/resilience.d.ts +0 -58
- package/dist/tools/warp_grep/agent/config.d.ts +0 -8
- package/dist/tools/warp_grep/agent/formatter.d.ts +0 -14
- package/dist/tools/warp_grep/agent/grep_helpers.d.ts +0 -16
- package/dist/tools/warp_grep/agent/parser.d.ts +0 -16
- package/dist/tools/warp_grep/agent/prompt.d.ts +0 -4
- package/dist/tools/warp_grep/agent/runner.d.ts +0 -10
- package/dist/tools/warp_grep/agent/types.d.ts +0 -44
- package/dist/tools/warp_grep/anthropic.d.ts +0 -14
- package/dist/tools/warp_grep/index.d.ts +0 -11
- package/dist/tools/warp_grep/openai.d.ts +0 -33
- package/dist/tools/warp_grep/providers/command.d.ts +0 -48
- package/dist/tools/warp_grep/providers/local.d.ts +0 -30
- package/dist/tools/warp_grep/providers/types.d.ts +0 -49
- package/dist/tools/warp_grep/tools/analyse.d.ts +0 -10
- package/dist/tools/warp_grep/tools/finish.d.ts +0 -10
- package/dist/tools/warp_grep/tools/grep.d.ts +0 -8
- package/dist/tools/warp_grep/tools/read.d.ts +0 -9
- package/dist/tools/warp_grep/utils/files.d.ts +0 -3
- package/dist/tools/warp_grep/utils/format.d.ts +0 -4
- package/dist/tools/warp_grep/utils/paths.d.ts +0 -7
- package/dist/tools/warp_grep/utils/ripgrep.d.ts +0 -11
- package/dist/tools/warp_grep/vercel.d.ts +0 -33
- package/dist/vercel-B1GZ_g9N.d.ts +0 -69
- /package/dist/{chunk-LN4CTQZG.js.map → chunk-7MCSSJJA.js.map} +0 -0
- /package/dist/{chunk-I7WWUHEC.js.map → chunk-DIWNR3UP.js.map} +0 -0
- /package/dist/{chunk-W5CHJ6OX.js.map → chunk-JSZQVUSE.js.map} +0 -0
- /package/dist/{chunk-YSBSDU75.js.map → chunk-LUI7APXX.js.map} +0 -0
- /package/dist/{chunk-EAA7D24N.js.map → chunk-N5654KQR.js.map} +0 -0
|
@@ -106,12 +106,25 @@ var MorphGit = class {
|
|
|
106
106
|
* ```
|
|
107
107
|
*/
|
|
108
108
|
async push(options) {
|
|
109
|
-
const { dir, remote = "origin", branch } = options;
|
|
109
|
+
const { dir, remote = "origin", branch, waitForEmbeddings } = options;
|
|
110
110
|
if (!branch) {
|
|
111
111
|
throw new Error(
|
|
112
112
|
'branch is required for push operations. Specify the branch explicitly: { dir: "./my-project", branch: "main" }'
|
|
113
113
|
);
|
|
114
114
|
}
|
|
115
|
+
let commitHash;
|
|
116
|
+
let repoId;
|
|
117
|
+
if (waitForEmbeddings) {
|
|
118
|
+
commitHash = await git.resolveRef({ fs, dir, ref: "HEAD" });
|
|
119
|
+
const remotes = await git.listRemotes({ fs, dir });
|
|
120
|
+
const originRemote = remotes.find((r) => r.remote === remote);
|
|
121
|
+
if (originRemote) {
|
|
122
|
+
const match = originRemote.url.match(/\/repos\/([^\/]+)$/);
|
|
123
|
+
if (match) {
|
|
124
|
+
repoId = match[1];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
115
128
|
await git.push({
|
|
116
129
|
fs,
|
|
117
130
|
http,
|
|
@@ -120,6 +133,9 @@ var MorphGit = class {
|
|
|
120
133
|
ref: branch,
|
|
121
134
|
onAuth: this.getAuthCallback()
|
|
122
135
|
});
|
|
136
|
+
if (waitForEmbeddings && repoId && commitHash) {
|
|
137
|
+
await this.waitForEmbeddings({ repoId, commitHash });
|
|
138
|
+
}
|
|
123
139
|
}
|
|
124
140
|
/**
|
|
125
141
|
* Pull changes from remote repository
|
|
@@ -152,6 +168,49 @@ var MorphGit = class {
|
|
|
152
168
|
}
|
|
153
169
|
});
|
|
154
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Wait for embeddings to complete after push.
|
|
173
|
+
* Polls status endpoint until embeddings are done.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* await morphGit.push({ dir: './my-project', branch: 'main' });
|
|
178
|
+
* await morphGit.waitForEmbeddings({
|
|
179
|
+
* repoId: 'my-project',
|
|
180
|
+
* onProgress: (p) => console.log(`${p.filesProcessed}/${p.totalFiles}`)
|
|
181
|
+
* });
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
async waitForEmbeddings(options) {
|
|
185
|
+
const { repoId, commitHash, timeout = 12e4, onProgress } = options;
|
|
186
|
+
const startTime = Date.now();
|
|
187
|
+
const pollInterval = 1e3;
|
|
188
|
+
while (Date.now() - startTime < timeout) {
|
|
189
|
+
const statusUrl = `${this.proxyUrl}/v1/repos/${repoId}/embedding-status` + (commitHash ? `?commit_hash=${commitHash}` : "");
|
|
190
|
+
const response = await fetch(statusUrl, {
|
|
191
|
+
headers: { "Authorization": `Bearer ${this.apiKey}` }
|
|
192
|
+
});
|
|
193
|
+
if (response.status === 404) {
|
|
194
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (!response.ok) {
|
|
198
|
+
throw new Error(`Failed to get embedding status: ${response.status}`);
|
|
199
|
+
}
|
|
200
|
+
const status = await response.json();
|
|
201
|
+
if (onProgress && status.progress) {
|
|
202
|
+
onProgress(status.progress);
|
|
203
|
+
}
|
|
204
|
+
if (status.status === "completed") {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (status.status === "failed") {
|
|
208
|
+
throw new Error(`Embeddings failed: ${status.error || "Unknown error"}`);
|
|
209
|
+
}
|
|
210
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
211
|
+
}
|
|
212
|
+
throw new Error(`Embeddings timed out after ${timeout}ms`);
|
|
213
|
+
}
|
|
155
214
|
/**
|
|
156
215
|
* Stage a file for commit
|
|
157
216
|
*
|
|
@@ -455,4 +514,4 @@ var MorphGit = class {
|
|
|
455
514
|
export {
|
|
456
515
|
MorphGit
|
|
457
516
|
};
|
|
458
|
-
//# sourceMappingURL=chunk-
|
|
517
|
+
//# sourceMappingURL=chunk-4WIBODS7.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 CommitMetadata,\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":";AAKA,OAAO,SAAS;AAChB,OAAO,UAAU;AACjB,OAAO,QAAQ;AAkBf,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,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,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAAA;AAAA;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,IAAI,SAAS;AAAA,QAC9B;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":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runWarpGrep
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-N5654KQR.js";
|
|
4
4
|
import {
|
|
5
5
|
LocalRipgrepProvider
|
|
6
6
|
} from "./chunk-UYBIKZPM.js";
|
|
@@ -53,4 +53,4 @@ function createMorphWarpGrepTool(config) {
|
|
|
53
53
|
export {
|
|
54
54
|
createMorphWarpGrepTool
|
|
55
55
|
};
|
|
56
|
-
//# sourceMappingURL=chunk-
|
|
56
|
+
//# sourceMappingURL=chunk-7MCSSJJA.js.map
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-NCVWIW7L.js";
|
|
10
10
|
import {
|
|
11
11
|
MorphGit
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-4WIBODS7.js";
|
|
13
13
|
import {
|
|
14
14
|
AnthropicRouter,
|
|
15
15
|
GeminiRouter,
|
|
@@ -94,4 +94,4 @@ var MorphClient = class {
|
|
|
94
94
|
export {
|
|
95
95
|
MorphClient
|
|
96
96
|
};
|
|
97
|
-
//# sourceMappingURL=chunk-
|
|
97
|
+
//# sourceMappingURL=chunk-DIWNR3UP.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runWarpGrep
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-N5654KQR.js";
|
|
4
4
|
import {
|
|
5
5
|
LocalRipgrepProvider
|
|
6
6
|
} from "./chunk-UYBIKZPM.js";
|
|
@@ -50,4 +50,4 @@ function createMorphWarpGrepTool(config) {
|
|
|
50
50
|
export {
|
|
51
51
|
createMorphWarpGrepTool
|
|
52
52
|
};
|
|
53
|
-
//# sourceMappingURL=chunk-
|
|
53
|
+
//# sourceMappingURL=chunk-JSZQVUSE.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runWarpGrep
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-N5654KQR.js";
|
|
4
4
|
import {
|
|
5
5
|
LocalRipgrepProvider
|
|
6
6
|
} from "./chunk-UYBIKZPM.js";
|
|
@@ -41,4 +41,4 @@ function createMorphWarpGrepTool(config) {
|
|
|
41
41
|
export {
|
|
42
42
|
createMorphWarpGrepTool
|
|
43
43
|
};
|
|
44
|
-
//# sourceMappingURL=chunk-
|
|
44
|
+
//# sourceMappingURL=chunk-LUI7APXX.js.map
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
toolRead
|
|
3
|
-
} from "./chunk-Z2FBMSNE.js";
|
|
4
|
-
import {
|
|
5
|
-
getSystemPrompt
|
|
6
|
-
} from "./chunk-HKZB23U7.js";
|
|
7
|
-
import {
|
|
8
|
-
toolAnalyse
|
|
9
|
-
} from "./chunk-73RQWOQC.js";
|
|
10
|
-
import {
|
|
11
|
-
readFinishFiles
|
|
12
|
-
} from "./chunk-EK7OQPWD.js";
|
|
13
1
|
import {
|
|
14
2
|
AGENT_CONFIG,
|
|
15
3
|
DEFAULT_MODEL
|
|
@@ -25,6 +13,18 @@ import {
|
|
|
25
13
|
import {
|
|
26
14
|
LLMResponseParser
|
|
27
15
|
} from "./chunk-GTOXMAF2.js";
|
|
16
|
+
import {
|
|
17
|
+
getSystemPrompt
|
|
18
|
+
} from "./chunk-HKZB23U7.js";
|
|
19
|
+
import {
|
|
20
|
+
toolAnalyse
|
|
21
|
+
} from "./chunk-73RQWOQC.js";
|
|
22
|
+
import {
|
|
23
|
+
readFinishFiles
|
|
24
|
+
} from "./chunk-EK7OQPWD.js";
|
|
25
|
+
import {
|
|
26
|
+
toolRead
|
|
27
|
+
} from "./chunk-Z2FBMSNE.js";
|
|
28
28
|
import {
|
|
29
29
|
fetchWithRetry,
|
|
30
30
|
withTimeout
|
|
@@ -198,4 +198,4 @@ async function runWarpGrep(config) {
|
|
|
198
198
|
export {
|
|
199
199
|
runWarpGrep
|
|
200
200
|
};
|
|
201
|
-
//# sourceMappingURL=chunk-
|
|
201
|
+
//# sourceMappingURL=chunk-N5654KQR.js.map
|
package/dist/client.cjs
CHANGED
|
@@ -933,12 +933,25 @@ var MorphGit = class {
|
|
|
933
933
|
* ```
|
|
934
934
|
*/
|
|
935
935
|
async push(options) {
|
|
936
|
-
const { dir, remote = "origin", branch } = options;
|
|
936
|
+
const { dir, remote = "origin", branch, waitForEmbeddings } = options;
|
|
937
937
|
if (!branch) {
|
|
938
938
|
throw new Error(
|
|
939
939
|
'branch is required for push operations. Specify the branch explicitly: { dir: "./my-project", branch: "main" }'
|
|
940
940
|
);
|
|
941
941
|
}
|
|
942
|
+
let commitHash;
|
|
943
|
+
let repoId;
|
|
944
|
+
if (waitForEmbeddings) {
|
|
945
|
+
commitHash = await import_isomorphic_git.default.resolveRef({ fs: import_fs.default, dir, ref: "HEAD" });
|
|
946
|
+
const remotes = await import_isomorphic_git.default.listRemotes({ fs: import_fs.default, dir });
|
|
947
|
+
const originRemote = remotes.find((r) => r.remote === remote);
|
|
948
|
+
if (originRemote) {
|
|
949
|
+
const match = originRemote.url.match(/\/repos\/([^\/]+)$/);
|
|
950
|
+
if (match) {
|
|
951
|
+
repoId = match[1];
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
}
|
|
942
955
|
await import_isomorphic_git.default.push({
|
|
943
956
|
fs: import_fs.default,
|
|
944
957
|
http: import_node.default,
|
|
@@ -947,6 +960,9 @@ var MorphGit = class {
|
|
|
947
960
|
ref: branch,
|
|
948
961
|
onAuth: this.getAuthCallback()
|
|
949
962
|
});
|
|
963
|
+
if (waitForEmbeddings && repoId && commitHash) {
|
|
964
|
+
await this.waitForEmbeddings({ repoId, commitHash });
|
|
965
|
+
}
|
|
950
966
|
}
|
|
951
967
|
/**
|
|
952
968
|
* Pull changes from remote repository
|
|
@@ -979,6 +995,49 @@ var MorphGit = class {
|
|
|
979
995
|
}
|
|
980
996
|
});
|
|
981
997
|
}
|
|
998
|
+
/**
|
|
999
|
+
* Wait for embeddings to complete after push.
|
|
1000
|
+
* Polls status endpoint until embeddings are done.
|
|
1001
|
+
*
|
|
1002
|
+
* @example
|
|
1003
|
+
* ```ts
|
|
1004
|
+
* await morphGit.push({ dir: './my-project', branch: 'main' });
|
|
1005
|
+
* await morphGit.waitForEmbeddings({
|
|
1006
|
+
* repoId: 'my-project',
|
|
1007
|
+
* onProgress: (p) => console.log(`${p.filesProcessed}/${p.totalFiles}`)
|
|
1008
|
+
* });
|
|
1009
|
+
* ```
|
|
1010
|
+
*/
|
|
1011
|
+
async waitForEmbeddings(options) {
|
|
1012
|
+
const { repoId, commitHash, timeout = 12e4, onProgress } = options;
|
|
1013
|
+
const startTime = Date.now();
|
|
1014
|
+
const pollInterval = 1e3;
|
|
1015
|
+
while (Date.now() - startTime < timeout) {
|
|
1016
|
+
const statusUrl = `${this.proxyUrl}/v1/repos/${repoId}/embedding-status` + (commitHash ? `?commit_hash=${commitHash}` : "");
|
|
1017
|
+
const response = await fetch(statusUrl, {
|
|
1018
|
+
headers: { "Authorization": `Bearer ${this.apiKey}` }
|
|
1019
|
+
});
|
|
1020
|
+
if (response.status === 404) {
|
|
1021
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
1022
|
+
continue;
|
|
1023
|
+
}
|
|
1024
|
+
if (!response.ok) {
|
|
1025
|
+
throw new Error(`Failed to get embedding status: ${response.status}`);
|
|
1026
|
+
}
|
|
1027
|
+
const status = await response.json();
|
|
1028
|
+
if (onProgress && status.progress) {
|
|
1029
|
+
onProgress(status.progress);
|
|
1030
|
+
}
|
|
1031
|
+
if (status.status === "completed") {
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
if (status.status === "failed") {
|
|
1035
|
+
throw new Error(`Embeddings failed: ${status.error || "Unknown error"}`);
|
|
1036
|
+
}
|
|
1037
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
1038
|
+
}
|
|
1039
|
+
throw new Error(`Embeddings timed out after ${timeout}ms`);
|
|
1040
|
+
}
|
|
982
1041
|
/**
|
|
983
1042
|
* Stage a file for commit
|
|
984
1043
|
*
|