@morphllm/morphsdk 0.2.55 → 0.2.57
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-37SRI4GW.js → chunk-6X5UOY7B.js} +34 -39
- package/dist/chunk-6X5UOY7B.js.map +1 -0
- package/dist/chunk-7OQOOB3R.js +1 -0
- package/dist/{chunk-X5HNQ7SB.js → chunk-CFF636UC.js} +3 -3
- package/dist/{chunk-KO6JQFRE.js → chunk-GJ5TYNRD.js} +2 -2
- package/dist/{chunk-ZWY434TS.js → chunk-IMYQOKFO.js} +3 -3
- package/dist/{chunk-BSHJGJ25.js → chunk-KBQWGT5L.js} +3 -3
- package/dist/{chunk-C6QQL6FX.js → chunk-QFIHUCTF.js} +5 -5
- package/dist/client.cjs +28 -142
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +8 -9
- package/dist/index.cjs +28 -209
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +9 -14
- package/dist/tools/warp_grep/agent/runner.cjs +28 -142
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +3 -4
- package/dist/tools/warp_grep/anthropic.cjs +28 -142
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.js +5 -6
- package/dist/tools/warp_grep/harness.cjs +859 -0
- package/dist/tools/warp_grep/harness.cjs.map +1 -0
- package/dist/tools/warp_grep/harness.d.ts +176 -0
- package/dist/tools/warp_grep/harness.js +76 -0
- package/dist/tools/warp_grep/harness.js.map +1 -0
- package/dist/tools/warp_grep/index.cjs +28 -209
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +0 -1
- package/dist/tools/warp_grep/index.js +8 -13
- package/dist/tools/warp_grep/openai.cjs +28 -142
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.js +5 -6
- package/dist/tools/warp_grep/vercel.cjs +28 -142
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.js +5 -6
- package/package.json +7 -2
- package/dist/chunk-37SRI4GW.js.map +0 -1
- package/dist/chunk-JYBVRF72.js +0 -1
- package/dist/chunk-NDZO5IPV.js +0 -121
- package/dist/chunk-NDZO5IPV.js.map +0 -1
- package/dist/chunk-P2XKFWFD.js +0 -73
- package/dist/chunk-P2XKFWFD.js.map +0 -1
- package/dist/tools/warp_grep/agent/grep_helpers.cjs +0 -148
- package/dist/tools/warp_grep/agent/grep_helpers.cjs.map +0 -1
- package/dist/tools/warp_grep/agent/grep_helpers.d.ts +0 -16
- package/dist/tools/warp_grep/agent/grep_helpers.js +0 -14
- package/dist/tools/warp_grep/agent/grep_helpers.js.map +0 -1
- package/dist/tools/warp_grep/providers/command.cjs +0 -177
- package/dist/tools/warp_grep/providers/command.cjs.map +0 -1
- package/dist/tools/warp_grep/providers/command.d.ts +0 -48
- package/dist/tools/warp_grep/providers/command.js +0 -9
- package/dist/tools/warp_grep/providers/command.js.map +0 -1
- /package/dist/{chunk-JYBVRF72.js.map → chunk-7OQOOB3R.js.map} +0 -0
- /package/dist/{chunk-X5HNQ7SB.js.map → chunk-CFF636UC.js.map} +0 -0
- /package/dist/{chunk-KO6JQFRE.js.map → chunk-GJ5TYNRD.js.map} +0 -0
- /package/dist/{chunk-ZWY434TS.js.map → chunk-IMYQOKFO.js.map} +0 -0
- /package/dist/{chunk-BSHJGJ25.js.map → chunk-KBQWGT5L.js.map} +0 -0
- /package/dist/{chunk-C6QQL6FX.js.map → chunk-QFIHUCTF.js.map} +0 -0
|
@@ -30,7 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// tools/warp_grep/index.ts
|
|
31
31
|
var warp_grep_exports = {};
|
|
32
32
|
__export(warp_grep_exports, {
|
|
33
|
-
CommandExecProvider: () => CommandExecProvider,
|
|
34
33
|
LocalRipgrepProvider: () => LocalRipgrepProvider,
|
|
35
34
|
WARP_GREP_DESCRIPTION: () => WARP_GREP_DESCRIPTION,
|
|
36
35
|
WARP_GREP_SYSTEM_PROMPT: () => SYSTEM_PROMPT,
|
|
@@ -621,120 +620,6 @@ function formatAgentToolOutput(toolName, args, output, options = {}) {
|
|
|
621
620
|
return sharedFormatter.format(toolName, args, output, options);
|
|
622
621
|
}
|
|
623
622
|
|
|
624
|
-
// tools/warp_grep/agent/grep_helpers.ts
|
|
625
|
-
var GrepState = class {
|
|
626
|
-
seenLines = /* @__PURE__ */ new Set();
|
|
627
|
-
isNew(path4, lineNumber) {
|
|
628
|
-
const key = this.makeKey(path4, lineNumber);
|
|
629
|
-
return !this.seenLines.has(key);
|
|
630
|
-
}
|
|
631
|
-
add(path4, lineNumber) {
|
|
632
|
-
this.seenLines.add(this.makeKey(path4, lineNumber));
|
|
633
|
-
}
|
|
634
|
-
makeKey(path4, lineNumber) {
|
|
635
|
-
return `${path4}:${lineNumber}`;
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
var MAX_GREP_OUTPUT_CHARS_PER_TURN = 6e4;
|
|
639
|
-
function extractMatchFields(payload) {
|
|
640
|
-
const text = payload.replace(/\r?\n$/, "");
|
|
641
|
-
if (!text || text.startsWith("[error]")) {
|
|
642
|
-
return null;
|
|
643
|
-
}
|
|
644
|
-
const firstSep = text.indexOf(":");
|
|
645
|
-
if (firstSep === -1) {
|
|
646
|
-
return null;
|
|
647
|
-
}
|
|
648
|
-
let filePath = text.slice(0, firstSep).trim();
|
|
649
|
-
if (!filePath) {
|
|
650
|
-
return null;
|
|
651
|
-
}
|
|
652
|
-
if (filePath.startsWith("./") || filePath.startsWith(".\\")) {
|
|
653
|
-
filePath = filePath.slice(2);
|
|
654
|
-
}
|
|
655
|
-
const remainder = text.slice(firstSep + 1);
|
|
656
|
-
const secondSep = remainder.indexOf(":");
|
|
657
|
-
if (secondSep === -1) {
|
|
658
|
-
return null;
|
|
659
|
-
}
|
|
660
|
-
const linePart = remainder.slice(0, secondSep);
|
|
661
|
-
const lineNumber = Number.parseInt(linePart, 10);
|
|
662
|
-
if (!Number.isInteger(lineNumber) || lineNumber <= 0) {
|
|
663
|
-
return null;
|
|
664
|
-
}
|
|
665
|
-
let contentSegment = remainder.slice(secondSep + 1);
|
|
666
|
-
const columnSep = contentSegment.indexOf(":");
|
|
667
|
-
if (columnSep !== -1 && /^\d+$/.test(contentSegment.slice(0, columnSep))) {
|
|
668
|
-
contentSegment = contentSegment.slice(columnSep + 1);
|
|
669
|
-
}
|
|
670
|
-
const content = contentSegment.trim();
|
|
671
|
-
if (!content) {
|
|
672
|
-
return null;
|
|
673
|
-
}
|
|
674
|
-
return { path: filePath, lineNumber, content };
|
|
675
|
-
}
|
|
676
|
-
function parseAndFilterGrepOutput(rawOutput, state) {
|
|
677
|
-
const matches = [];
|
|
678
|
-
if (typeof rawOutput !== "string" || !rawOutput.trim()) {
|
|
679
|
-
return matches;
|
|
680
|
-
}
|
|
681
|
-
for (const line of rawOutput.split(/\r?\n/)) {
|
|
682
|
-
const fields = extractMatchFields(line);
|
|
683
|
-
if (!fields) {
|
|
684
|
-
continue;
|
|
685
|
-
}
|
|
686
|
-
if (state.isNew(fields.path, fields.lineNumber)) {
|
|
687
|
-
matches.push(fields);
|
|
688
|
-
state.add(fields.path, fields.lineNumber);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
return matches;
|
|
692
|
-
}
|
|
693
|
-
function truncateOutput(payload, maxChars) {
|
|
694
|
-
if (payload.length <= maxChars) {
|
|
695
|
-
return payload;
|
|
696
|
-
}
|
|
697
|
-
const note = "... (output truncated)";
|
|
698
|
-
const available = maxChars - note.length - 1;
|
|
699
|
-
if (available <= 0) {
|
|
700
|
-
return note;
|
|
701
|
-
}
|
|
702
|
-
if (payload.length <= available) {
|
|
703
|
-
return `${payload.slice(0, available).replace(/\n$/, "")}
|
|
704
|
-
${note}`;
|
|
705
|
-
}
|
|
706
|
-
const core = payload.slice(0, Math.max(0, available - 1));
|
|
707
|
-
const trimmed = core.replace(/\n$/, "").replace(/\s+$/, "");
|
|
708
|
-
const snippet = trimmed ? `${trimmed}\u2026` : "\u2026";
|
|
709
|
-
return `${snippet}
|
|
710
|
-
${note}`;
|
|
711
|
-
}
|
|
712
|
-
function formatTurnGrepOutput(matches, maxChars = MAX_GREP_OUTPUT_CHARS_PER_TURN) {
|
|
713
|
-
if (!matches || matches.length === 0) {
|
|
714
|
-
return "No new matches found.";
|
|
715
|
-
}
|
|
716
|
-
const matchesByFile = /* @__PURE__ */ new Map();
|
|
717
|
-
for (const match of matches) {
|
|
718
|
-
if (!matchesByFile.has(match.path)) {
|
|
719
|
-
matchesByFile.set(match.path, []);
|
|
720
|
-
}
|
|
721
|
-
matchesByFile.get(match.path).push(match);
|
|
722
|
-
}
|
|
723
|
-
const lines = [];
|
|
724
|
-
const sortedPaths = Array.from(matchesByFile.keys()).sort();
|
|
725
|
-
sortedPaths.forEach((filePath, index) => {
|
|
726
|
-
if (index > 0) {
|
|
727
|
-
lines.push("");
|
|
728
|
-
}
|
|
729
|
-
lines.push(filePath);
|
|
730
|
-
const sortedMatches = matchesByFile.get(filePath).slice().sort((a, b) => a.lineNumber - b.lineNumber);
|
|
731
|
-
for (const match of sortedMatches) {
|
|
732
|
-
lines.push(`${match.lineNumber}:${match.content}`);
|
|
733
|
-
}
|
|
734
|
-
});
|
|
735
|
-
return truncateOutput(lines.join("\n"), maxChars);
|
|
736
|
-
}
|
|
737
|
-
|
|
738
623
|
// tools/warp_grep/tools/finish.ts
|
|
739
624
|
async function readFinishFiles(repoRoot, files, reader) {
|
|
740
625
|
const out = [];
|
|
@@ -830,7 +715,6 @@ async function runWarpGrep(config) {
|
|
|
830
715
|
const model = config.model || DEFAULT_MODEL;
|
|
831
716
|
const provider = config.provider;
|
|
832
717
|
const errors = [];
|
|
833
|
-
const grepState = new GrepState();
|
|
834
718
|
let finishMeta;
|
|
835
719
|
let terminationReason = "terminated";
|
|
836
720
|
for (let round = 1; round <= maxRounds; round += 1) {
|
|
@@ -856,10 +740,25 @@ async function runWarpGrep(config) {
|
|
|
856
740
|
const msg = c.arguments?.message || "Command skipped due to parsing error";
|
|
857
741
|
formatted.push(msg);
|
|
858
742
|
}
|
|
859
|
-
const
|
|
743
|
+
const allPromises = [];
|
|
744
|
+
for (const c of grepCalls) {
|
|
745
|
+
const args = c.arguments ?? {};
|
|
746
|
+
allPromises.push(
|
|
747
|
+
provider.grep({ pattern: args.pattern, path: args.path }).then(
|
|
748
|
+
(grepRes) => {
|
|
749
|
+
if (grepRes.error) {
|
|
750
|
+
return { terminate: true, error: grepRes.error };
|
|
751
|
+
}
|
|
752
|
+
const output = grepRes.lines.join("\n") || "no matches";
|
|
753
|
+
return formatAgentToolOutput("grep", args, output, { isError: false });
|
|
754
|
+
},
|
|
755
|
+
(err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
|
|
756
|
+
)
|
|
757
|
+
);
|
|
758
|
+
}
|
|
860
759
|
for (const c of analyseCalls) {
|
|
861
760
|
const args = c.arguments ?? {};
|
|
862
|
-
|
|
761
|
+
allPromises.push(
|
|
863
762
|
toolAnalyse(provider, args).then(
|
|
864
763
|
(p) => formatAgentToolOutput("analyse", args, p, { isError: false }),
|
|
865
764
|
(err) => formatAgentToolOutput("analyse", args, String(err), { isError: true })
|
|
@@ -868,38 +767,24 @@ async function runWarpGrep(config) {
|
|
|
868
767
|
}
|
|
869
768
|
for (const c of readCalls) {
|
|
870
769
|
const args = c.arguments ?? {};
|
|
871
|
-
|
|
770
|
+
allPromises.push(
|
|
872
771
|
toolRead(provider, args).then(
|
|
873
772
|
(p) => formatAgentToolOutput("read", args, p, { isError: false }),
|
|
874
773
|
(err) => formatAgentToolOutput("read", args, String(err), { isError: true })
|
|
875
774
|
)
|
|
876
775
|
);
|
|
877
776
|
}
|
|
878
|
-
const
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
errors
|
|
886
|
-
|
|
887
|
-
return {
|
|
888
|
-
terminationReason: "terminated",
|
|
889
|
-
messages,
|
|
890
|
-
errors
|
|
891
|
-
};
|
|
892
|
-
}
|
|
893
|
-
const rawOutput = Array.isArray(grepRes.lines) ? grepRes.lines.join("\n") : "";
|
|
894
|
-
const newMatches = parseAndFilterGrepOutput(rawOutput, grepState);
|
|
895
|
-
let formattedPayload = formatTurnGrepOutput(newMatches);
|
|
896
|
-
if (formattedPayload === "No new matches found.") {
|
|
897
|
-
formattedPayload = "no new matches";
|
|
898
|
-
}
|
|
899
|
-
formatted.push(formatAgentToolOutput("grep", args, formattedPayload, { isError: false }));
|
|
900
|
-
} catch (err) {
|
|
901
|
-
formatted.push(formatAgentToolOutput("grep", args, String(err), { isError: true }));
|
|
777
|
+
const allResults = await Promise.all(allPromises);
|
|
778
|
+
for (const result of allResults) {
|
|
779
|
+
if (typeof result === "object" && "terminate" in result) {
|
|
780
|
+
errors.push({ message: result.error });
|
|
781
|
+
return {
|
|
782
|
+
terminationReason: "terminated",
|
|
783
|
+
messages,
|
|
784
|
+
errors
|
|
785
|
+
};
|
|
902
786
|
}
|
|
787
|
+
formatted.push(result);
|
|
903
788
|
}
|
|
904
789
|
if (formatted.length > 0) {
|
|
905
790
|
const turnsUsed = round;
|
|
@@ -1311,71 +1196,6 @@ function formatResult(result) {
|
|
|
1311
1196
|
var WARP_GREP_TOOL_NAME = "warpgrep_codebase_search";
|
|
1312
1197
|
var WARP_GREP_DESCRIPTION = 'IMPORTANT: If you need to explore the codebase to gather context, and the task does not involve a single file or function which is provided by name, you should ALWAYS use the warpgrep codebase search tool first instead of running search commands. When the task requires exploration beyond a single known file, invoke warpgrep first with a natural-language query describing the target functionality, bug, or architectural concern. Warp Grep is a fast and accurate tool that can search for all relevant context in a codebase. Keep queries action-oriented (e.g., "Find where billing invoices are generated and emailed"), and after reviewing the summarized results, you may verify important findings with other search tools or direct file reads to ensure completeness. Warp Grep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. When a task requires exploration beyond a single known file, ALWAYS default to warpgrep codebase search before other search mechanisms.';
|
|
1313
1198
|
|
|
1314
|
-
// tools/warp_grep/providers/command.ts
|
|
1315
|
-
var CommandExecProvider = class {
|
|
1316
|
-
constructor(opts) {
|
|
1317
|
-
this.opts = opts;
|
|
1318
|
-
}
|
|
1319
|
-
map(path4) {
|
|
1320
|
-
return this.opts.pathMap ? this.opts.pathMap(path4) : path4;
|
|
1321
|
-
}
|
|
1322
|
-
async grep(params) {
|
|
1323
|
-
const remotePath = this.map(params.path);
|
|
1324
|
-
const args = [
|
|
1325
|
-
"--no-config",
|
|
1326
|
-
"--no-heading",
|
|
1327
|
-
"--with-filename",
|
|
1328
|
-
"--line-number",
|
|
1329
|
-
"--color=never",
|
|
1330
|
-
"--trim",
|
|
1331
|
-
"--max-columns=400",
|
|
1332
|
-
...(this.opts.excludes ?? DEFAULT_EXCLUDES).flatMap((e) => ["-g", `!${e}`]),
|
|
1333
|
-
params.pattern,
|
|
1334
|
-
remotePath || "."
|
|
1335
|
-
];
|
|
1336
|
-
const res = await this.opts.run("rg", args, { cwd: this.opts.cwd, env: this.opts.env });
|
|
1337
|
-
if (res.exitCode === -1) throw new Error(res.stderr || "ripgrep execution failed");
|
|
1338
|
-
if (res.exitCode !== 0 && res.exitCode !== 1) throw new Error(res.stderr || `ripgrep failed (${res.exitCode})`);
|
|
1339
|
-
const lines = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
1340
|
-
return { lines };
|
|
1341
|
-
}
|
|
1342
|
-
async glob(params) {
|
|
1343
|
-
const remotePath = this.map(params.path);
|
|
1344
|
-
const args = [
|
|
1345
|
-
"--no-config",
|
|
1346
|
-
"--files",
|
|
1347
|
-
"-g",
|
|
1348
|
-
params.pattern,
|
|
1349
|
-
...(this.opts.excludes ?? DEFAULT_EXCLUDES).flatMap((e) => ["-g", `!${e}`]),
|
|
1350
|
-
remotePath || "."
|
|
1351
|
-
];
|
|
1352
|
-
const res = await this.opts.run("rg", args, { cwd: this.opts.cwd, env: this.opts.env });
|
|
1353
|
-
if (res.exitCode === -1) throw new Error(res.stderr || "ripgrep execution failed");
|
|
1354
|
-
const files = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
1355
|
-
return { files };
|
|
1356
|
-
}
|
|
1357
|
-
async read(params) {
|
|
1358
|
-
const remotePath = this.map(params.path);
|
|
1359
|
-
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] };
|
|
1360
|
-
const res = await this.opts.run(rc.cmd, rc.args, { cwd: this.opts.cwd, env: this.opts.env });
|
|
1361
|
-
if (res.exitCode !== 0) throw new Error(res.stderr || `read failed (${res.exitCode})`);
|
|
1362
|
-
const text = res.stdout || "";
|
|
1363
|
-
const lines = text.split(/\r?\n/).map((line, idx) => `${(params.start ?? 1) + idx}|${line}`);
|
|
1364
|
-
return { lines: lines.filter((l) => l !== `${(params.start ?? 1) + (lines.length - 1)}|`) };
|
|
1365
|
-
}
|
|
1366
|
-
async analyse(params) {
|
|
1367
|
-
const target = this.map(params.path);
|
|
1368
|
-
const pattern = params.pattern ?? "*";
|
|
1369
|
-
const files = await this.glob({ pattern, path: target }).catch(() => ({ files: [] }));
|
|
1370
|
-
return files.files.slice(0, params.maxResults ?? 100).map((f) => ({
|
|
1371
|
-
name: f.split("/").pop() || f,
|
|
1372
|
-
path: f,
|
|
1373
|
-
type: f.endsWith("/") ? "dir" : "file",
|
|
1374
|
-
depth: 0
|
|
1375
|
-
}));
|
|
1376
|
-
}
|
|
1377
|
-
};
|
|
1378
|
-
|
|
1379
1199
|
// tools/warp_grep/openai.ts
|
|
1380
1200
|
var TOOL_PARAMETERS = {
|
|
1381
1201
|
type: "object",
|
|
@@ -1512,7 +1332,6 @@ function createMorphWarpGrepTool3(config) {
|
|
|
1512
1332
|
}
|
|
1513
1333
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1514
1334
|
0 && (module.exports = {
|
|
1515
|
-
CommandExecProvider,
|
|
1516
1335
|
LocalRipgrepProvider,
|
|
1517
1336
|
WARP_GREP_DESCRIPTION,
|
|
1518
1337
|
WARP_GREP_SYSTEM_PROMPT,
|