@epoch-agent/plugin-file 0.1.0 → 0.3.1
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/index.js +3 -17
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -179,7 +179,6 @@ ${c.unifiedDiff}` : `${c.type}: ${c.path}`
|
|
|
179
179
|
duration: 0
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
|
-
|
|
183
182
|
// src/tools/file-diff-preview.ts
|
|
184
183
|
async function execDiffPreview(args, ctx) {
|
|
185
184
|
const patch = String(args["patch"] || "");
|
|
@@ -248,11 +247,9 @@ function buildDiffSummary(hunks, workDir) {
|
|
|
248
247
|
lines.push("\u786E\u8BA4\u65E0\u8BEF\u540E\uFF0C\u4F7F\u7528 file_multi_patch \u5DE5\u5177\u5E94\u7528\u4EE5\u4E0A\u53D8\u66F4\u3002");
|
|
249
248
|
return lines.join("\n");
|
|
250
249
|
}
|
|
251
|
-
|
|
252
250
|
// src/tools/file-list.ts
|
|
253
251
|
import { readdirSync, statSync } from "fs";
|
|
254
252
|
import { join as join2 } from "path";
|
|
255
|
-
|
|
256
253
|
// src/utils.ts
|
|
257
254
|
import { homedir } from "os";
|
|
258
255
|
import { resolve as resolve2 } from "path";
|
|
@@ -376,7 +373,6 @@ function truncateOutput(text) {
|
|
|
376
373
|
function formatWithLineNumbers(content, startLine) {
|
|
377
374
|
return content.split("\n").map((line, i) => String(startLine + i).padStart(4, " ") + "|" + line).join("\n");
|
|
378
375
|
}
|
|
379
|
-
|
|
380
376
|
// src/tools/file-list.ts
|
|
381
377
|
function formatEntry(entry) {
|
|
382
378
|
const size = entry.type === "directory" ? "-" : entry.size.toLocaleString("en-US");
|
|
@@ -440,7 +436,6 @@ ${body}
|
|
|
440
436
|
});
|
|
441
437
|
}
|
|
442
438
|
}
|
|
443
|
-
|
|
444
439
|
// src/tools/file-multi-read.ts
|
|
445
440
|
import { readFile } from "fs/promises";
|
|
446
441
|
async function execMultiRead(args, ctx) {
|
|
@@ -475,7 +470,6 @@ ${truncateOutput(output)}`);
|
|
|
475
470
|
}
|
|
476
471
|
return { success: true, output: results.join("\n\n"), duration: 0 };
|
|
477
472
|
}
|
|
478
|
-
|
|
479
473
|
// src/tools/file-patch.ts
|
|
480
474
|
import { readFile as readFile2, writeFile } from "fs/promises";
|
|
481
475
|
import { basename } from "path";
|
|
@@ -597,7 +591,6 @@ function lineTrimMatch(content, old) {
|
|
|
597
591
|
}
|
|
598
592
|
return null;
|
|
599
593
|
}
|
|
600
|
-
|
|
601
594
|
// src/tools/file-read.ts
|
|
602
595
|
import { readFile as readFile3 } from "fs/promises";
|
|
603
596
|
async function execRead(args, ctx) {
|
|
@@ -643,10 +636,9 @@ ${output}`;
|
|
|
643
636
|
return { success: false, output: "", error: { code: 2001, message }, duration: 0 };
|
|
644
637
|
}
|
|
645
638
|
}
|
|
646
|
-
|
|
647
639
|
// src/tools/file-search.ts
|
|
648
640
|
import { spawn } from "child_process";
|
|
649
|
-
import { resolveRipgrep,
|
|
641
|
+
import { resolveRipgrep, ripgrepInstallHint, WINDOWS_HIDE_FLAGS } from "@epoch-agent/infra";
|
|
650
642
|
function execSearch(args, ctx) {
|
|
651
643
|
return new Promise((resolve4) => {
|
|
652
644
|
const pattern = String(args["pattern"] ?? "");
|
|
@@ -721,20 +713,20 @@ function execSearch(args, ctx) {
|
|
|
721
713
|
});
|
|
722
714
|
child.on("error", (err) => {
|
|
723
715
|
const notFound = err.code === "ENOENT";
|
|
716
|
+
const suggestion = resolveRipgrep().hint ?? ripgrepInstallHint();
|
|
724
717
|
resolve4({
|
|
725
718
|
success: false,
|
|
726
719
|
output: "",
|
|
727
720
|
error: {
|
|
728
721
|
code: 2005,
|
|
729
722
|
message: `ripgrep \u672A\u5B89\u88C5\u6216\u4E0D\u53EF\u7528: ${err.message}`,
|
|
730
|
-
...notFound ? { suggestion
|
|
723
|
+
...notFound ? { suggestion } : {}
|
|
731
724
|
},
|
|
732
725
|
duration: 0
|
|
733
726
|
});
|
|
734
727
|
});
|
|
735
728
|
});
|
|
736
729
|
}
|
|
737
|
-
|
|
738
730
|
// src/tools/file-write.ts
|
|
739
731
|
import { mkdir, readFile as readFile4, rename, stat, unlink, writeFile as writeFile2 } from "fs/promises";
|
|
740
732
|
import { basename as basename2, resolve as resolve3 } from "path";
|
|
@@ -785,7 +777,6 @@ async function execWrite(args, ctx) {
|
|
|
785
777
|
};
|
|
786
778
|
}
|
|
787
779
|
}
|
|
788
|
-
|
|
789
780
|
// src/index.ts
|
|
790
781
|
var READ_ONLY = { readOnlyHint: true, idempotentHint: true, openWorldHint: false };
|
|
791
782
|
var DESTRUCTIVE = {
|
|
@@ -870,7 +861,6 @@ var filePlugin = {
|
|
|
870
861
|
supportsParallel: true,
|
|
871
862
|
annotations: READ_ONLY,
|
|
872
863
|
operation: "file_read",
|
|
873
|
-
// 搜索的对象是目录,不是 pattern
|
|
874
864
|
describeTarget: dirTarget,
|
|
875
865
|
execute: execSearch
|
|
876
866
|
},
|
|
@@ -931,10 +921,6 @@ var filePlugin = {
|
|
|
931
921
|
properties: { patch: { type: "string", description: "V4A \u683C\u5F0F\u7684\u591A\u6587\u4EF6\u8865\u4E01\u5185\u5BB9" } },
|
|
932
922
|
required: ["patch"]
|
|
933
923
|
},
|
|
934
|
-
// 真实语义是只读(只算 diff 不落盘),annotations 照实写。
|
|
935
|
-
// 但 operation 仍填 file_write:老白名单把它归在 FILE_WRITE_TOOLS 里,
|
|
936
|
-
// 只改一边会让 recordApproval 那条路径与这里分叉。往严的方向偏,
|
|
937
|
-
// 代价只是多一次确认;纠正白名单本身是方案 06 的地盘。
|
|
938
924
|
annotations: READ_ONLY,
|
|
939
925
|
operation: "file_write",
|
|
940
926
|
describeTarget: patchTarget,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epoch-agent/plugin-file",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "epoch-agent 文件系统操作插件",
|
|
6
6
|
"repository": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"diff": "^9.0.0",
|
|
25
|
-
"@epoch-agent/infra": "0.1
|
|
26
|
-
"@epoch-agent/protocol": "0.1
|
|
25
|
+
"@epoch-agent/infra": "0.3.1",
|
|
26
|
+
"@epoch-agent/protocol": "0.3.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^26.1.2",
|