@morphllm/morphsdk 0.2.21 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-DF2ZOO7R.js → chunk-5VQEQSJQ.js} +3 -52
- package/dist/chunk-5VQEQSJQ.js.map +1 -0
- package/dist/chunk-73RQWOQC.js +16 -0
- package/dist/chunk-73RQWOQC.js.map +1 -0
- package/dist/{chunk-2DXRTGRH.js → chunk-74ZHKB54.js} +1 -1
- package/dist/{chunk-2DXRTGRH.js.map → chunk-74ZHKB54.js.map} +1 -1
- package/dist/chunk-AFEPUNAO.js +15 -0
- package/dist/chunk-AFEPUNAO.js.map +1 -0
- package/dist/chunk-EAA7D24N.js +201 -0
- package/dist/chunk-EAA7D24N.js.map +1 -0
- package/dist/chunk-EK7OQPWD.js +44 -0
- package/dist/chunk-EK7OQPWD.js.map +1 -0
- package/dist/chunk-FSVBNZMU.js +44 -0
- package/dist/chunk-FSVBNZMU.js.map +1 -0
- package/dist/chunk-G2RSY56Q.js +11 -0
- package/dist/chunk-G2RSY56Q.js.map +1 -0
- package/dist/chunk-GTOXMAF2.js +140 -0
- package/dist/chunk-GTOXMAF2.js.map +1 -0
- package/dist/chunk-HKZB23U7.js +85 -0
- package/dist/chunk-HKZB23U7.js.map +1 -0
- package/dist/chunk-JZGU5UC6.js +53 -0
- package/dist/chunk-JZGU5UC6.js.map +1 -0
- package/dist/chunk-NDZO5IPV.js +121 -0
- package/dist/chunk-NDZO5IPV.js.map +1 -0
- package/dist/{chunk-34F3D6JD.js → chunk-NSQGPBMU.js} +9 -9
- package/dist/chunk-RSLIOCOE.js +26 -0
- package/dist/chunk-RSLIOCOE.js.map +1 -0
- package/dist/chunk-SMGZ6A64.js +53 -0
- package/dist/chunk-SMGZ6A64.js.map +1 -0
- package/dist/chunk-TICMYDII.js +81 -0
- package/dist/chunk-TICMYDII.js.map +1 -0
- package/dist/chunk-UYBIKZPM.js +135 -0
- package/dist/chunk-UYBIKZPM.js.map +1 -0
- package/dist/chunk-VBBJGWHY.js +73 -0
- package/dist/chunk-VBBJGWHY.js.map +1 -0
- package/dist/chunk-XQLKK2ZH.js +56 -0
- package/dist/chunk-XQLKK2ZH.js.map +1 -0
- package/dist/chunk-XYPMN4A3.js +1 -0
- package/dist/chunk-XYPMN4A3.js.map +1 -0
- package/dist/chunk-Z2FBMSNE.js +10 -0
- package/dist/chunk-Z2FBMSNE.js.map +1 -0
- package/dist/client.cjs +2 -51
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +4 -4
- package/dist/git/client.cjs +2 -51
- package/dist/git/client.cjs.map +1 -1
- package/dist/git/client.js +1 -1
- package/dist/git/index.cjs +2 -51
- package/dist/git/index.cjs.map +1 -1
- package/dist/git/index.js +2 -2
- package/dist/git/types.cjs.map +1 -1
- package/dist/index.cjs +2 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -10
- package/dist/tools/warp_grep/agent/config.cjs +41 -0
- package/dist/tools/warp_grep/agent/config.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/config.js +12 -0
- package/dist/tools/warp_grep/agent/config.js.map +1 -0
- package/dist/tools/warp_grep/agent/formatter.cjs +106 -0
- package/dist/tools/warp_grep/agent/formatter.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/formatter.js +10 -0
- package/dist/tools/warp_grep/agent/formatter.js.map +1 -0
- package/dist/tools/warp_grep/agent/grep_helpers.cjs +148 -0
- package/dist/tools/warp_grep/agent/grep_helpers.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/grep_helpers.js +14 -0
- package/dist/tools/warp_grep/agent/grep_helpers.js.map +1 -0
- package/dist/tools/warp_grep/agent/parser.cjs +165 -0
- package/dist/tools/warp_grep/agent/parser.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/parser.js +10 -0
- package/dist/tools/warp_grep/agent/parser.js.map +1 -0
- package/dist/tools/warp_grep/agent/prompt.cjs +110 -0
- package/dist/tools/warp_grep/agent/prompt.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/prompt.js +10 -0
- package/dist/tools/warp_grep/agent/prompt.js.map +1 -0
- package/dist/tools/warp_grep/agent/runner.cjs +744 -0
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/runner.js +17 -0
- package/dist/tools/warp_grep/agent/runner.js.map +1 -0
- package/dist/tools/warp_grep/agent/types.cjs +19 -0
- package/dist/tools/warp_grep/agent/types.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/types.js +2 -0
- package/dist/tools/warp_grep/agent/types.js.map +1 -0
- package/dist/tools/warp_grep/anthropic.cjs +977 -0
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -0
- package/dist/tools/warp_grep/anthropic.js +22 -0
- package/dist/tools/warp_grep/anthropic.js.map +1 -0
- package/dist/tools/warp_grep/index.cjs +1136 -0
- package/dist/tools/warp_grep/index.cjs.map +1 -0
- package/dist/tools/warp_grep/index.js +48 -0
- package/dist/tools/warp_grep/index.js.map +1 -0
- package/dist/tools/warp_grep/openai.cjs +980 -0
- package/dist/tools/warp_grep/openai.cjs.map +1 -0
- package/dist/tools/warp_grep/openai.js +22 -0
- package/dist/tools/warp_grep/openai.js.map +1 -0
- package/dist/tools/warp_grep/providers/command.cjs +98 -0
- package/dist/tools/warp_grep/providers/command.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/command.js +9 -0
- package/dist/tools/warp_grep/providers/command.js.map +1 -0
- package/dist/tools/warp_grep/providers/local.cjs +232 -0
- package/dist/tools/warp_grep/providers/local.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/local.js +12 -0
- package/dist/tools/warp_grep/providers/local.js.map +1 -0
- package/dist/tools/warp_grep/providers/types.cjs +19 -0
- package/dist/tools/warp_grep/providers/types.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/types.js +1 -0
- package/dist/tools/warp_grep/providers/types.js.map +1 -0
- package/dist/tools/warp_grep/tools/analyse.cjs +40 -0
- package/dist/tools/warp_grep/tools/analyse.cjs.map +1 -0
- package/dist/tools/warp_grep/tools/analyse.js +8 -0
- package/dist/tools/warp_grep/tools/analyse.js.map +1 -0
- package/dist/tools/warp_grep/tools/finish.cjs +69 -0
- package/dist/tools/warp_grep/tools/finish.cjs.map +1 -0
- package/dist/tools/warp_grep/tools/finish.js +10 -0
- package/dist/tools/warp_grep/tools/finish.js.map +1 -0
- package/dist/tools/warp_grep/tools/grep.cjs +35 -0
- package/dist/tools/warp_grep/tools/grep.cjs.map +1 -0
- package/dist/tools/warp_grep/tools/grep.js +12 -0
- package/dist/tools/warp_grep/tools/grep.js.map +1 -0
- package/dist/tools/warp_grep/tools/read.cjs +34 -0
- package/dist/tools/warp_grep/tools/read.cjs.map +1 -0
- package/dist/tools/warp_grep/tools/read.js +8 -0
- package/dist/tools/warp_grep/tools/read.js.map +1 -0
- package/dist/tools/warp_grep/utils/files.cjs +45 -0
- package/dist/tools/warp_grep/utils/files.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/files.js +8 -0
- package/dist/tools/warp_grep/utils/files.js.map +1 -0
- package/dist/tools/warp_grep/utils/format.cjs +42 -0
- package/dist/tools/warp_grep/utils/format.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/format.js +18 -0
- package/dist/tools/warp_grep/utils/format.js.map +1 -0
- package/dist/tools/warp_grep/utils/paths.cjs +91 -0
- package/dist/tools/warp_grep/utils/paths.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/paths.js +16 -0
- package/dist/tools/warp_grep/utils/paths.js.map +1 -0
- package/dist/tools/warp_grep/utils/ripgrep.cjs +50 -0
- package/dist/tools/warp_grep/utils/ripgrep.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/ripgrep.js +8 -0
- package/dist/tools/warp_grep/utils/ripgrep.js.map +1 -0
- package/dist/tools/warp_grep/vercel.cjs +968 -0
- package/dist/tools/warp_grep/vercel.cjs.map +1 -0
- package/dist/tools/warp_grep/vercel.js +22 -0
- package/dist/tools/warp_grep/vercel.js.map +1 -0
- package/package.json +23 -3
- package/dist/anthropic-CknfcMoO.d.ts +0 -64
- package/dist/chunk-DF2ZOO7R.js.map +0 -1
- package/dist/client.d.ts +0 -114
- package/dist/git/client.d.ts +0 -255
- package/dist/git/config.d.ts +0 -11
- package/dist/git/index.d.ts +0 -5
- package/dist/git/types.d.ts +0 -102
- package/dist/index.d.ts +0 -14
- package/dist/modelrouter/core.d.ts +0 -56
- package/dist/modelrouter/index.d.ts +0 -2
- package/dist/modelrouter/types.d.ts +0 -35
- package/dist/openai-BkKsS30n.d.ts +0 -111
- package/dist/tools/browser/anthropic.d.ts +0 -51
- package/dist/tools/browser/core.d.ts +0 -196
- package/dist/tools/browser/index.d.ts +0 -72
- package/dist/tools/browser/openai.d.ts +0 -69
- package/dist/tools/browser/prompts.d.ts +0 -7
- package/dist/tools/browser/types.d.ts +0 -227
- package/dist/tools/browser/vercel.d.ts +0 -69
- package/dist/tools/codebase_search/anthropic.d.ts +0 -40
- package/dist/tools/codebase_search/core.d.ts +0 -40
- package/dist/tools/codebase_search/index.d.ts +0 -10
- package/dist/tools/codebase_search/openai.d.ts +0 -87
- package/dist/tools/codebase_search/prompts.d.ts +0 -7
- package/dist/tools/codebase_search/types.d.ts +0 -46
- package/dist/tools/codebase_search/vercel.d.ts +0 -65
- package/dist/tools/fastapply/anthropic.d.ts +0 -4
- package/dist/tools/fastapply/core.d.ts +0 -41
- package/dist/tools/fastapply/index.d.ts +0 -10
- package/dist/tools/fastapply/openai.d.ts +0 -4
- package/dist/tools/fastapply/prompts.d.ts +0 -7
- package/dist/tools/fastapply/types.d.ts +0 -77
- package/dist/tools/fastapply/vercel.d.ts +0 -4
- package/dist/tools/index.d.ts +0 -10
- package/dist/tools/utils/resilience.d.ts +0 -58
- package/dist/vercel-B1GZ_g9N.d.ts +0 -69
- /package/dist/{chunk-34F3D6JD.js.map → chunk-NSQGPBMU.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/agent/formatter.ts"],"sourcesContent":["export class ToolOutputFormatter {\n\tformat(\n\t\ttoolName: string,\n\t\targs: Record<string, unknown> | null | undefined,\n\t\toutput: string,\n\t\toptions: { isError?: boolean } = {}\n\t): string {\n\t\tconst name = (toolName ?? \"\").trim();\n\t\tif (!name) {\n\t\t\treturn \"\";\n\t\t}\n\t\tconst payload = (output as any)?.toString?.()?.trim?.() ?? \"\";\n\t\tconst isError = Boolean(options.isError);\n\t\tconst safeArgs = args ?? {};\n\n\t\tif (!payload && !isError) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\tswitch (name) {\n\t\t\tcase \"read\":\n\t\t\t\treturn this.formatRead(safeArgs, payload, isError);\n\t\t\tcase \"analyse\":\n\t\t\t\treturn this.formatAnalyse(safeArgs, payload, isError);\n\t\t\tcase \"grep\":\n\t\t\t\treturn this.formatGrep(safeArgs, payload, isError);\n\t\t\tdefault:\n\t\t\t\treturn payload ? `<tool_output>\\n${payload}\\n</tool_output>` : \"\";\n\t\t}\n\t}\n\n\tprivate formatRead(args: Record<string, unknown>, payload: string, isError: boolean): string {\n\t\tif (isError) {\n\t\t\treturn payload;\n\t\t}\n\t\tconst path = this.asString(args.path) || \"...\";\n\t\treturn `<file path=\"${path}\">\\n${payload}\\n</file>`;\n\t}\n\n\tprivate formatAnalyse(args: Record<string, unknown>, payload: string, isError: boolean): string {\n\t\tconst path = this.asString(args.path) || \".\";\n\t\tif (isError) {\n\t\t\treturn `<analyse_results path=\"${path}\" status=\"error\">\\n${payload}\\n</analyse_results>`;\n\t\t}\n\t\treturn `<analyse_results path=\"${path}\">\\n${payload}\\n</analyse_results>`;\n\t}\n\n\tprivate formatGrep(args: Record<string, unknown>, payload: string, isError: boolean): string {\n\t\tconst pattern = this.asString(args.pattern);\n\t\tconst path = this.asString(args.path);\n\t\tconst attributes: string[] = [];\n\t\tif (pattern !== undefined) {\n\t\t\tattributes.push(`pattern=\"${pattern}\"`);\n\t\t}\n\t\tif (path !== undefined) {\n\t\t\tattributes.push(`path=\"${path}\"`);\n\t\t}\n\t\tif (isError) {\n\t\t\tattributes.push('status=\"error\"');\n\t\t}\n\t\tconst attrText = attributes.length ? ` ${attributes.join(\" \")}` : \"\";\n\t\treturn `<grep_output${attrText}>\\n${payload}\\n</grep_output>`;\n\t}\n\n\tprivate asString(value: unknown): string | undefined {\n\t\tif (value === null || value === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn String(value);\n\t}\n}\n\nconst sharedFormatter = new ToolOutputFormatter();\n\nexport function formatAgentToolOutput(\n\ttoolName: string,\n\targs: Record<string, unknown> | null | undefined,\n\toutput: string,\n\toptions: { isError?: boolean } = {}\n): string {\n\treturn sharedFormatter.format(toolName, args, output, options);\n}\n\n"],"mappings":";AAAO,IAAM,sBAAN,MAA0B;AAAA,EAChC,OACC,UACA,MACA,QACA,UAAiC,CAAC,GACzB;AACT,UAAM,QAAQ,YAAY,IAAI,KAAK;AACnC,QAAI,CAAC,MAAM;AACV,aAAO;AAAA,IACR;AACA,UAAM,UAAW,QAAgB,WAAW,GAAG,OAAO,KAAK;AAC3D,UAAM,UAAU,QAAQ,QAAQ,OAAO;AACvC,UAAM,WAAW,QAAQ,CAAC;AAE1B,QAAI,CAAC,WAAW,CAAC,SAAS;AACzB,aAAO;AAAA,IACR;AAEA,YAAQ,MAAM;AAAA,MACb,KAAK;AACJ,eAAO,KAAK,WAAW,UAAU,SAAS,OAAO;AAAA,MAClD,KAAK;AACJ,eAAO,KAAK,cAAc,UAAU,SAAS,OAAO;AAAA,MACrD,KAAK;AACJ,eAAO,KAAK,WAAW,UAAU,SAAS,OAAO;AAAA,MAClD;AACC,eAAO,UAAU;AAAA,EAAkB,OAAO;AAAA,kBAAqB;AAAA,IACjE;AAAA,EACD;AAAA,EAEQ,WAAW,MAA+B,SAAiB,SAA0B;AAC5F,QAAI,SAAS;AACZ,aAAO;AAAA,IACR;AACA,UAAM,OAAO,KAAK,SAAS,KAAK,IAAI,KAAK;AACzC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o,
|
|
8
|
+
toRepoRelative
|
|
9
|
+
} from "./chunk-SMGZ6A64.js";
|
|
10
|
+
import {
|
|
11
|
+
runRipgrep
|
|
12
|
+
} from "./chunk-RSLIOCOE.js";
|
|
13
|
+
import {
|
|
14
|
+
DEFAULT_EXCLUDES
|
|
15
|
+
} from "./chunk-AFEPUNAO.js";
|
|
16
|
+
|
|
17
|
+
// tools/warp_grep/providers/local.ts
|
|
18
|
+
import fs from "fs/promises";
|
|
19
|
+
import path from "path";
|
|
20
|
+
var LocalRipgrepProvider = class {
|
|
21
|
+
constructor(repoRoot, excludes = DEFAULT_EXCLUDES) {
|
|
22
|
+
this.repoRoot = repoRoot;
|
|
23
|
+
this.excludes = excludes;
|
|
24
|
+
}
|
|
25
|
+
async grep(params) {
|
|
26
|
+
const abs = resolveUnderRepo(this.repoRoot, params.path);
|
|
27
|
+
const stat = await fs.stat(abs).catch(() => null);
|
|
28
|
+
if (!stat) return { lines: [] };
|
|
29
|
+
const targetArg = abs === path.resolve(this.repoRoot) ? "." : toRepoRelative(this.repoRoot, abs);
|
|
30
|
+
const args = [
|
|
31
|
+
"--no-config",
|
|
32
|
+
"--no-heading",
|
|
33
|
+
"--with-filename",
|
|
34
|
+
"--line-number",
|
|
35
|
+
"--color=never",
|
|
36
|
+
"--trim",
|
|
37
|
+
"--max-columns=400",
|
|
38
|
+
...this.excludes.flatMap((e) => ["-g", `!${e}`]),
|
|
39
|
+
params.pattern,
|
|
40
|
+
targetArg || "."
|
|
41
|
+
];
|
|
42
|
+
const res = await runRipgrep(args, { cwd: this.repoRoot });
|
|
43
|
+
if (res.exitCode === -1) {
|
|
44
|
+
throw new Error(res.stderr || "ripgrep (rg) execution failed.");
|
|
45
|
+
}
|
|
46
|
+
if (res.exitCode !== 0 && res.exitCode !== 1) {
|
|
47
|
+
throw new Error(res.stderr || `ripgrep failed with code ${res.exitCode}`);
|
|
48
|
+
}
|
|
49
|
+
const lines = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
50
|
+
return { lines };
|
|
51
|
+
}
|
|
52
|
+
async glob(params) {
|
|
53
|
+
const abs = resolveUnderRepo(this.repoRoot, params.path);
|
|
54
|
+
const targetArg = abs === path.resolve(this.repoRoot) ? "." : toRepoRelative(this.repoRoot, abs);
|
|
55
|
+
const args = [
|
|
56
|
+
"--no-config",
|
|
57
|
+
"--files",
|
|
58
|
+
"-g",
|
|
59
|
+
params.pattern,
|
|
60
|
+
...this.excludes.flatMap((e) => ["-g", `!${e}`]),
|
|
61
|
+
targetArg || "."
|
|
62
|
+
];
|
|
63
|
+
const res = await runRipgrep(args, { cwd: this.repoRoot });
|
|
64
|
+
if (res.exitCode === -1) {
|
|
65
|
+
throw new Error(res.stderr || "ripgrep (rg) execution failed.");
|
|
66
|
+
}
|
|
67
|
+
const files = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
68
|
+
return { files };
|
|
69
|
+
}
|
|
70
|
+
async read(params) {
|
|
71
|
+
const abs = resolveUnderRepo(this.repoRoot, params.path);
|
|
72
|
+
const stat = await fs.stat(abs).catch(() => null);
|
|
73
|
+
if (!stat || !stat.isFile()) {
|
|
74
|
+
throw new Error(`Path is not a file: ${params.path}`);
|
|
75
|
+
}
|
|
76
|
+
if (isSymlink(abs)) {
|
|
77
|
+
throw new Error(`Refusing to read symlink: ${params.path}`);
|
|
78
|
+
}
|
|
79
|
+
if (!isTextualFile(abs)) {
|
|
80
|
+
throw new Error(`Non-text or too-large file: ${params.path}`);
|
|
81
|
+
}
|
|
82
|
+
const lines = await readAllLines(abs);
|
|
83
|
+
const total = lines.length;
|
|
84
|
+
const s = params.start ?? 1;
|
|
85
|
+
const e = Math.min(params.end ?? total, total);
|
|
86
|
+
if (s > total && total > 0) {
|
|
87
|
+
throw new Error(`start ${s} exceeds file length (${total})`);
|
|
88
|
+
}
|
|
89
|
+
const out = [];
|
|
90
|
+
for (let i = s; i <= e; i += 1) {
|
|
91
|
+
const content = lines[i - 1] ?? "";
|
|
92
|
+
out.push(`${i}|${content}`);
|
|
93
|
+
}
|
|
94
|
+
return { lines: out };
|
|
95
|
+
}
|
|
96
|
+
async analyse(params) {
|
|
97
|
+
const abs = resolveUnderRepo(this.repoRoot, params.path);
|
|
98
|
+
const stat = await fs.stat(abs).catch(() => null);
|
|
99
|
+
if (!stat || !stat.isDirectory()) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
const maxResults = params.maxResults ?? 100;
|
|
103
|
+
const maxDepth = params.maxDepth ?? 2;
|
|
104
|
+
const regex = params.pattern ? new RegExp(params.pattern) : null;
|
|
105
|
+
const results = [];
|
|
106
|
+
async function walk(dir, depth) {
|
|
107
|
+
if (depth > maxDepth || results.length >= maxResults) return;
|
|
108
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
109
|
+
for (const entry of entries) {
|
|
110
|
+
const full = path.join(dir, entry.name);
|
|
111
|
+
const rel = toRepoRelative(abs, full).replace(/^[.][/\\]?/, "");
|
|
112
|
+
if (DEFAULT_EXCLUDES.some((ex) => rel.split(path.sep).includes(ex))) continue;
|
|
113
|
+
if (regex && !regex.test(entry.name)) continue;
|
|
114
|
+
if (results.length >= maxResults) break;
|
|
115
|
+
results.push({
|
|
116
|
+
name: entry.name,
|
|
117
|
+
path: toRepoRelative(path.resolve(""), full),
|
|
118
|
+
// relative display
|
|
119
|
+
type: entry.isDirectory() ? "dir" : "file",
|
|
120
|
+
depth
|
|
121
|
+
});
|
|
122
|
+
if (entry.isDirectory()) {
|
|
123
|
+
await walk(full, depth + 1);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
await walk(abs, 0);
|
|
128
|
+
return results;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export {
|
|
133
|
+
LocalRipgrepProvider
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=chunk-UYBIKZPM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/providers/local.ts"],"sourcesContent":["import fs from 'fs/promises';\nimport fssync from 'fs';\nimport path from 'path';\nimport { runRipgrep } from '../utils/ripgrep.js';\nimport { ensureWithinRepo, resolveUnderRepo, toRepoRelative, isSymlink, isTextualFile } from '../utils/paths.js';\nimport type { WarpGrepProvider, GrepResult, ReadResult, AnalyseEntry } from './types.js';\nimport { readAllLines } from '../utils/files.js';\nimport { DEFAULT_EXCLUDES } from '../agent/config.js';\n\nexport class LocalRipgrepProvider implements WarpGrepProvider {\n constructor(private readonly repoRoot: string, private readonly excludes: string[] = DEFAULT_EXCLUDES) {}\n\n async grep(params: { pattern: string; path: string }): Promise<GrepResult> {\n const abs = resolveUnderRepo(this.repoRoot, params.path);\n const stat = await fs.stat(abs).catch(() => null);\n if (!stat) return { lines: [] };\n const targetArg = abs === path.resolve(this.repoRoot) ? '.' : toRepoRelative(this.repoRoot, abs);\n const args = [\n '--no-config',\n '--no-heading',\n '--with-filename',\n '--line-number',\n '--color=never',\n '--trim',\n '--max-columns=400',\n ...this.excludes.flatMap((e) => ['-g', `!${e}`]),\n params.pattern,\n targetArg || '.',\n ];\n const res = await runRipgrep(args, { cwd: this.repoRoot });\n if (res.exitCode === -1) {\n throw new Error(res.stderr || 'ripgrep (rg) execution failed.');\n }\n if (res.exitCode !== 0 && res.exitCode !== 1) {\n throw new Error(res.stderr || `ripgrep failed with code ${res.exitCode}`);\n }\n const lines = (res.stdout || '')\n .trim()\n .split(/\\r?\\n/)\n .filter((l) => l.length > 0);\n return { lines };\n }\n\n async glob(params: { pattern: string; path: string }): Promise<{ files: string[] }> {\n const abs = resolveUnderRepo(this.repoRoot, params.path);\n const targetArg = abs === path.resolve(this.repoRoot) ? '.' : toRepoRelative(this.repoRoot, abs);\n const args = [\n '--no-config',\n '--files',\n '-g',\n params.pattern,\n ...this.excludes.flatMap((e) => ['-g', `!${e}`]),\n targetArg || '.',\n ];\n const res = await runRipgrep(args, { cwd: this.repoRoot });\n if (res.exitCode === -1) {\n throw new Error(res.stderr || 'ripgrep (rg) execution failed.');\n }\n const files = (res.stdout || '')\n .trim()\n .split(/\\r?\\n/)\n .filter((l) => l.length > 0);\n return { files };\n }\n\n async read(params: { path: string; start?: number; end?: number }): Promise<ReadResult> {\n const abs = resolveUnderRepo(this.repoRoot, params.path);\n const stat = await fs.stat(abs).catch(() => null);\n if (!stat || !stat.isFile()) {\n throw new Error(`Path is not a file: ${params.path}`);\n }\n if (isSymlink(abs)) {\n throw new Error(`Refusing to read symlink: ${params.path}`);\n }\n if (!isTextualFile(abs)) {\n throw new Error(`Non-text or too-large file: ${params.path}`);\n }\n const lines = await readAllLines(abs);\n const total = lines.length;\n const s = params.start ?? 1;\n const e = Math.min(params.end ?? total, total);\n if (s > total && total > 0) {\n throw new Error(`start ${s} exceeds file length (${total})`);\n }\n const out: string[] = [];\n for (let i = s; i <= e; i += 1) {\n const content = lines[i - 1] ?? '';\n out.push(`${i}|${content}`);\n }\n return { lines: out };\n }\n\n async analyse(params: { path: string; pattern?: string | null; maxResults?: number; maxDepth?: number }): Promise<AnalyseEntry[]> {\n const abs = resolveUnderRepo(this.repoRoot, params.path);\n const stat = await fs.stat(abs).catch(() => null);\n if (!stat || !stat.isDirectory()) {\n return [];\n }\n const maxResults = params.maxResults ?? 100;\n const maxDepth = params.maxDepth ?? 2;\n const regex = params.pattern ? new RegExp(params.pattern) : null;\n\n const results: AnalyseEntry[] = [];\n async function walk(dir: string, depth: number) {\n if (depth > maxDepth || results.length >= maxResults) return;\n const entries = await fs.readdir(dir, { withFileTypes: true });\n for (const entry of entries) {\n const full = path.join(dir, entry.name);\n const rel = toRepoRelative(abs, full).replace(/^[.][/\\\\]?/, '');\n if (DEFAULT_EXCLUDES.some((ex) => rel.split(path.sep).includes(ex))) continue;\n if (regex && !regex.test(entry.name)) continue;\n if (results.length >= maxResults) break;\n results.push({\n name: entry.name,\n path: toRepoRelative(path.resolve(''), full), // relative display\n type: entry.isDirectory() ? 'dir' : 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AAAA,UAC3C,MAAM,MAAM,YAAY,IAAI,QAAQ;AAAA,UACpC;AAAA,QACF,CAAC;AACD,YAAI,MAAM,YAAY,GAAG;AACvB,gBAAM,KAAK,MAAM,QAAQ,CAAC;AAAA,QAC5B;AAAA,MACF;AAAA,IACF;AACA,UAAM,KAAK,KAAK,CAAC;AACjB,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_EXCLUDES
|
|
3
|
+
} from "./chunk-AFEPUNAO.js";
|
|
4
|
+
|
|
5
|
+
// tools/warp_grep/providers/command.ts
|
|
6
|
+
var CommandExecProvider = class {
|
|
7
|
+
constructor(opts) {
|
|
8
|
+
this.opts = opts;
|
|
9
|
+
}
|
|
10
|
+
map(path) {
|
|
11
|
+
return this.opts.pathMap ? this.opts.pathMap(path) : path;
|
|
12
|
+
}
|
|
13
|
+
async grep(params) {
|
|
14
|
+
const remotePath = this.map(params.path);
|
|
15
|
+
const args = [
|
|
16
|
+
"--no-config",
|
|
17
|
+
"--no-heading",
|
|
18
|
+
"--with-filename",
|
|
19
|
+
"--line-number",
|
|
20
|
+
"--color=never",
|
|
21
|
+
"--trim",
|
|
22
|
+
"--max-columns=400",
|
|
23
|
+
...(this.opts.excludes ?? DEFAULT_EXCLUDES).flatMap((e) => ["-g", `!${e}`]),
|
|
24
|
+
params.pattern,
|
|
25
|
+
remotePath || "."
|
|
26
|
+
];
|
|
27
|
+
const res = await this.opts.run("rg", args, { cwd: this.opts.cwd, env: this.opts.env });
|
|
28
|
+
if (res.exitCode === -1) throw new Error(res.stderr || "ripgrep execution failed");
|
|
29
|
+
if (res.exitCode !== 0 && res.exitCode !== 1) throw new Error(res.stderr || `ripgrep failed (${res.exitCode})`);
|
|
30
|
+
const lines = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
31
|
+
return { lines };
|
|
32
|
+
}
|
|
33
|
+
async glob(params) {
|
|
34
|
+
const remotePath = this.map(params.path);
|
|
35
|
+
const args = [
|
|
36
|
+
"--no-config",
|
|
37
|
+
"--files",
|
|
38
|
+
"-g",
|
|
39
|
+
params.pattern,
|
|
40
|
+
...(this.opts.excludes ?? DEFAULT_EXCLUDES).flatMap((e) => ["-g", `!${e}`]),
|
|
41
|
+
remotePath || "."
|
|
42
|
+
];
|
|
43
|
+
const res = await this.opts.run("rg", args, { cwd: this.opts.cwd, env: this.opts.env });
|
|
44
|
+
if (res.exitCode === -1) throw new Error(res.stderr || "ripgrep execution failed");
|
|
45
|
+
const files = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
46
|
+
return { files };
|
|
47
|
+
}
|
|
48
|
+
async read(params) {
|
|
49
|
+
const remotePath = this.map(params.path);
|
|
50
|
+
const rc = this.opts.readCommand ? this.opts.readCommand(remotePath, params.start, params.end) : { cmd: "sed", args: ["-n", `${params.start ?? 1},${params.end ?? 1e6}p`, remotePath] };
|
|
51
|
+
const res = await this.opts.run(rc.cmd, rc.args, { cwd: this.opts.cwd, env: this.opts.env });
|
|
52
|
+
if (res.exitCode !== 0) throw new Error(res.stderr || `read failed (${res.exitCode})`);
|
|
53
|
+
const text = res.stdout || "";
|
|
54
|
+
const lines = text.split(/\r?\n/).map((line, idx) => `${(params.start ?? 1) + idx}|${line}`);
|
|
55
|
+
return { lines: lines.filter((l) => l !== `${(params.start ?? 1) + (lines.length - 1)}|`) };
|
|
56
|
+
}
|
|
57
|
+
async analyse(params) {
|
|
58
|
+
const target = this.map(params.path);
|
|
59
|
+
const pattern = params.pattern ?? "*";
|
|
60
|
+
const files = await this.glob({ pattern, path: target }).catch(() => ({ files: [] }));
|
|
61
|
+
return files.files.slice(0, params.maxResults ?? 100).map((f) => ({
|
|
62
|
+
name: f.split("/").pop() || f,
|
|
63
|
+
path: f,
|
|
64
|
+
type: f.endsWith("/") ? "dir" : "file",
|
|
65
|
+
depth: 0
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
CommandExecProvider
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=chunk-VBBJGWHY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/providers/command.ts"],"sourcesContent":["import type { WarpGrepProvider, GrepResult, ReadResult, AnalyseEntry } from './types.js';\nimport { DEFAULT_EXCLUDES } from '../agent/config.js';\n\ntype ExecResult = { stdout: string; stderr: string; exitCode: number };\n\nexport class CommandExecProvider implements WarpGrepProvider {\n constructor(\n private readonly opts: {\n run: (cmd: string, args: string[], options?: { cwd?: string; env?: Record<string, string> }) => Promise<ExecResult>;\n pathMap?: (localPath: string) => string;\n cwd?: string;\n env?: Record<string, string>;\n readCommand?: (remotePath: string, start?: number, end?: number) => { cmd: string; args: string[] };\n excludes?: string[];\n }\n ) {}\n\n private map(path: string): string {\n return this.opts.pathMap ? this.opts.pathMap(path) : path;\n }\n\n async grep(params: { pattern: string; path: string }): Promise<GrepResult> {\n const remotePath = this.map(params.path);\n const args = [\n '--no-config',\n '--no-heading',\n '--with-filename',\n '--line-number',\n '--color=never',\n '--trim',\n '--max-columns=400',\n ...((this.opts.excludes ?? DEFAULT_EXCLUDES).flatMap((e) => ['-g', `!${e}`])),\n params.pattern,\n remotePath || '.',\n ];\n const res = await this.opts.run('rg', args, { cwd: this.opts.cwd, env: this.opts.env });\n if (res.exitCode === -1) throw new Error(res.stderr || 'ripgrep execution failed');\n if (res.exitCode !== 0 && res.exitCode !== 1) throw new Error(res.stderr || `ripgrep failed (${res.exitCode})`);\n const lines = (res.stdout || '')\n .trim()\n .split(/\\r?\\n/)\n .filter((l) => l.length > 0);\n return { lines };\n }\n\n async glob(params: { pattern: string; path: string }): Promise<{ files: string[] }> {\n const remotePath = this.map(params.path);\n const args = [\n '--no-config',\n '--files',\n '-g',\n params.pattern,\n ...((this.opts.excludes ?? DEFAULT_EXCLUDES).flatMap((e) => ['-g', `!${e}`])),\n remotePath || '.',\n ];\n const res = await this.opts.run('rg', args, { cwd: this.opts.cwd, env: this.opts.env });\n if (res.exitCode === -1) throw new Error(res.stderr || 'ripgrep execution failed');\n const files = (res.stdout || '')\n .trim()\n .split(/\\r?\\n/)\n .filter((l) => l.length > 0);\n return { files };\n }\n\n async read(params: { path: string; start?: number; end?: number }): Promise<ReadResult> {\n const remotePath = this.map(params.path);\n const rc = this.opts.readCommand\n ? this.opts.readCommand(remotePath, params.start, params.end)\n : { cmd: 'sed', args: ['-n', `${params.start ?? 1},${params.end ?? 1_000_000}p`, remotePath] };\n const res = await this.opts.run(rc.cmd, rc.args, { cwd: this.opts.cwd, env: this.opts.env });\n if (res.exitCode !== 0) throw new Error(res.stderr || `read failed (${res.exitCode})`);\n const text = res.stdout || '';\n const lines = text.split(/\\r?\\n/).map((line, idx) => `${(params.start ?? 1) + idx}|${line}`);\n return { lines: lines.filter(l => l !== `${(params.start ?? 1) + (lines.length - 1)}|`) };\n }\n\n async analyse(params: { path: string; pattern?: string | null; maxResults?: number; maxDepth?: number }): Promise<AnalyseEntry[]> {\n // Minimal remote analyse: glob all files and trim\n const target = this.map(params.path);\n const pattern = params.pattern ?? '*';\n const files = await this.glob({ pattern, path: target }).catch(() => ({ files: [] }));\n return files.files.slice(0, params.maxResults ?? 100).map((f) => ({\n name: f.split('/').pop() || f,\n path: f,\n type: f.endsWith('/') ? 'dir' : 'file',\n depth: 0,\n }));\n }\n}\n\n\n"],"mappings":";;;;;AAKO,IAAM,sBAAN,MAAsD;AAAA,EAC3D,YACmB,MAQjB;AARiB;AAAA,EAQhB;AAAA,EAEK,IAAI,MAAsB;AAChC,WAAO,KAAK,KAAK,UAAU,KAAK,KAAK,QAAQ,IAAI,IAAI;AAAA,EACvD;AAAA,EAEA,MAAM,KAAK,QAAgE;AACzE,UAAM,aAAa,KAAK,IAAI,OAAO,IAAI;AACvC,UAAM,OAAO;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAA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
|
|
2
|
+
runWarpGrep
|
|
3
|
+
} from "./chunk-EAA7D24N.js";
|
|
4
|
+
import {
|
|
5
|
+
LocalRipgrepProvider
|
|
6
|
+
} from "./chunk-UYBIKZPM.js";
|
|
7
|
+
|
|
8
|
+
// tools/warp_grep/openai.ts
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
var INPUT_SCHEMA = z.object({
|
|
11
|
+
query: z.string().describe("Free-form repository question")
|
|
12
|
+
});
|
|
13
|
+
function createMorphWarpGrepTool(config) {
|
|
14
|
+
const tool = {
|
|
15
|
+
type: "function",
|
|
16
|
+
function: {
|
|
17
|
+
name: "morph-warp-grep",
|
|
18
|
+
description: "A fast and accurate tool that can search for all relevant context in a codebase. You must use this tool to save time and avoid context pollution.",
|
|
19
|
+
parameters: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
query: { type: "string", description: "Free-form repository question" }
|
|
23
|
+
},
|
|
24
|
+
required: ["query"]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return Object.assign(tool, {
|
|
29
|
+
execute: async (input) => {
|
|
30
|
+
const parsed = INPUT_SCHEMA.parse(typeof input === "string" ? JSON.parse(input) : input);
|
|
31
|
+
const provider = config.provider ?? new LocalRipgrepProvider(config.repoRoot, config.excludes);
|
|
32
|
+
const result = await runWarpGrep({
|
|
33
|
+
query: parsed.query,
|
|
34
|
+
repoRoot: config.repoRoot,
|
|
35
|
+
provider,
|
|
36
|
+
excludes: config.excludes,
|
|
37
|
+
includes: config.includes,
|
|
38
|
+
debug: config.debug ?? false,
|
|
39
|
+
apiKey: config.apiKey
|
|
40
|
+
});
|
|
41
|
+
if (result.terminationReason !== "completed" || !result.finish?.metadata) {
|
|
42
|
+
return { success: false, error: "Search did not complete", messages: result.messages };
|
|
43
|
+
}
|
|
44
|
+
const contexts = (result.finish.resolved || []).map((r) => ({
|
|
45
|
+
file: r.path,
|
|
46
|
+
content: r.content
|
|
47
|
+
}));
|
|
48
|
+
return { success: true, contexts, summary: result.finish.payload };
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
createMorphWarpGrepTool
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=chunk-XQLKK2ZH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/openai.ts"],"sourcesContent":["import type { ChatCompletionTool } from 'openai/resources/chat/completions';\nimport { z } from 'zod';\nimport { runWarpGrep } from './agent/runner.js';\nimport type { WarpGrepProvider } from './providers/types.js';\nimport { LocalRipgrepProvider } from './providers/local.js';\nimport { AGENT_CONFIG } from './agent/config.js';\n\nexport type WarpGrepConfig = {\n repoRoot: string;\n provider?: WarpGrepProvider;\n excludes?: string[];\n includes?: string[];\n debug?: boolean;\n apiKey?: string; // Morph API key (defaults to env)\n};\n\nconst INPUT_SCHEMA = z.object({\n query: z.string().describe('Free-form repository question'),\n});\n\nexport function createMorphWarpGrepTool(config: WarpGrepConfig) {\n const tool: ChatCompletionTool = {\n type: 'function',\n function: {\n name: 'morph-warp-grep',\n description: 'A fast and accurate tool that can search for all relevant context in a codebase. You must use this tool to save time and avoid context pollution.',\n parameters: {\n type: 'object',\n properties: {\n query: { type: 'string', description: 'Free-form repository question' },\n },\n required: ['query'],\n },\n },\n };\n\n return Object.assign(tool, {\n execute: async (input: unknown) => {\n const parsed = INPUT_SCHEMA.parse(typeof input === 'string' ? JSON.parse(input) : input);\n const provider = config.provider ?? new LocalRipgrepProvider(config.repoRoot, config.excludes);\n const result = await runWarpGrep({\n query: parsed.query,\n repoRoot: config.repoRoot,\n provider,\n excludes: config.excludes,\n includes: config.includes,\n debug: config.debug ?? false,\n apiKey: config.apiKey,\n });\n if (result.terminationReason !== 'completed' || !result.finish?.metadata) {\n return { success: false, error: 'Search did not complete', messages: result.messages };\n }\n const contexts = (result.finish.resolved || []).map((r: any) => ({\n file: r.path,\n content: r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AAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-XYPMN4A3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// tools/warp_grep/tools/read.ts
|
|
2
|
+
async function toolRead(provider, args) {
|
|
3
|
+
const res = await provider.read({ path: args.path, start: args.start, end: args.end });
|
|
4
|
+
return res.lines.join("\n");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
toolRead
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=chunk-Z2FBMSNE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/tools/read.ts"],"sourcesContent":["import type { WarpGrepProvider } from '../providers/types.js';\n\nexport async function toolRead(\n provider: WarpGrepProvider,\n args: { path: string; start?: number; end?: number }\n): Promise<string> {\n const res = await provider.read({ path: args.path, start: args.start, end: args.end });\n return res.lines.join('\\n');\n}\n\n\n"],"mappings":";AAEA,eAAsB,SACpB,UACA,MACiB;AACjB,QAAM,MAAM,MAAM,SAAS,KAAK,EAAE,MAAM,KAAK,MAAM,OAAO,KAAK,OAAO,KAAK,KAAK,IAAI,CAAC;AACrF,SAAO,IAAI,MAAM,KAAK,IAAI;AAC5B;","names":[]}
|
package/dist/client.cjs
CHANGED
|
@@ -1016,17 +1016,12 @@ var MorphGit = class {
|
|
|
1016
1016
|
* author: {
|
|
1017
1017
|
* name: 'AI Agent',
|
|
1018
1018
|
* email: 'ai@example.com'
|
|
1019
|
-
* }
|
|
1020
|
-
* chatHistory: [
|
|
1021
|
-
* { role: 'user', content: 'Please add a new feature' },
|
|
1022
|
-
* { role: 'assistant', content: 'I will add that feature' }
|
|
1023
|
-
* ],
|
|
1024
|
-
* recordingId: 'rec_123'
|
|
1019
|
+
* }
|
|
1025
1020
|
* });
|
|
1026
1021
|
* ```
|
|
1027
1022
|
*/
|
|
1028
1023
|
async commit(options) {
|
|
1029
|
-
const { dir, message, author
|
|
1024
|
+
const { dir, message, author } = options;
|
|
1030
1025
|
const commitAuthor = author || {
|
|
1031
1026
|
name: "Morph SDK",
|
|
1032
1027
|
email: "sdk@morphllm.com"
|
|
@@ -1037,20 +1032,6 @@ var MorphGit = class {
|
|
|
1037
1032
|
message,
|
|
1038
1033
|
author: commitAuthor
|
|
1039
1034
|
});
|
|
1040
|
-
if (chatHistory || recordingId) {
|
|
1041
|
-
const metadata = {
|
|
1042
|
-
chatHistory,
|
|
1043
|
-
recordingId
|
|
1044
|
-
};
|
|
1045
|
-
await import_isomorphic_git.default.addNote({
|
|
1046
|
-
fs: import_fs.default,
|
|
1047
|
-
dir,
|
|
1048
|
-
ref: "refs/notes/morph-metadata",
|
|
1049
|
-
oid: sha,
|
|
1050
|
-
note: JSON.stringify(metadata, null, 2),
|
|
1051
|
-
author: commitAuthor
|
|
1052
|
-
});
|
|
1053
|
-
}
|
|
1054
1035
|
return sha;
|
|
1055
1036
|
}
|
|
1056
1037
|
/**
|
|
@@ -1235,36 +1216,6 @@ var MorphGit = class {
|
|
|
1235
1216
|
});
|
|
1236
1217
|
return oid;
|
|
1237
1218
|
}
|
|
1238
|
-
/**
|
|
1239
|
-
* Get metadata (chat history, recording ID) attached to a commit
|
|
1240
|
-
*
|
|
1241
|
-
* @example
|
|
1242
|
-
* ```ts
|
|
1243
|
-
* const metadata = await morphGit.getCommitMetadata({
|
|
1244
|
-
* dir: './my-project',
|
|
1245
|
-
* commitSha: 'abc123...'
|
|
1246
|
-
* });
|
|
1247
|
-
*
|
|
1248
|
-
* if (metadata) {
|
|
1249
|
-
* console.log('Chat history:', metadata.chatHistory);
|
|
1250
|
-
* console.log('Recording ID:', metadata.recordingId);
|
|
1251
|
-
* }
|
|
1252
|
-
* ```
|
|
1253
|
-
*/
|
|
1254
|
-
async getCommitMetadata(options) {
|
|
1255
|
-
try {
|
|
1256
|
-
const note = await import_isomorphic_git.default.readNote({
|
|
1257
|
-
fs: import_fs.default,
|
|
1258
|
-
dir: options.dir,
|
|
1259
|
-
ref: "refs/notes/morph-metadata",
|
|
1260
|
-
oid: options.commitSha
|
|
1261
|
-
});
|
|
1262
|
-
const metadata = JSON.parse(new TextDecoder().decode(note));
|
|
1263
|
-
return metadata;
|
|
1264
|
-
} catch (err) {
|
|
1265
|
-
return null;
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
1219
|
};
|
|
1269
1220
|
|
|
1270
1221
|
// git/index.ts
|