@epoch-agent/plugin-file 0.1.0 → 0.2.0
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 +2 -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"] ?? "");
|
|
@@ -727,14 +719,13 @@ function execSearch(args, ctx) {
|
|
|
727
719
|
error: {
|
|
728
720
|
code: 2005,
|
|
729
721
|
message: `ripgrep \u672A\u5B89\u88C5\u6216\u4E0D\u53EF\u7528: ${err.message}`,
|
|
730
|
-
...notFound ? { suggestion: `\u5B89\u88C5 ripgrep \u540E\u91CD\u8BD5\uFF1A${
|
|
722
|
+
...notFound ? { suggestion: `\u5B89\u88C5 ripgrep \u540E\u91CD\u8BD5\uFF1A${ripgrepInstallHint()}` } : {}
|
|
731
723
|
},
|
|
732
724
|
duration: 0
|
|
733
725
|
});
|
|
734
726
|
});
|
|
735
727
|
});
|
|
736
728
|
}
|
|
737
|
-
|
|
738
729
|
// src/tools/file-write.ts
|
|
739
730
|
import { mkdir, readFile as readFile4, rename, stat, unlink, writeFile as writeFile2 } from "fs/promises";
|
|
740
731
|
import { basename as basename2, resolve as resolve3 } from "path";
|
|
@@ -785,7 +776,6 @@ async function execWrite(args, ctx) {
|
|
|
785
776
|
};
|
|
786
777
|
}
|
|
787
778
|
}
|
|
788
|
-
|
|
789
779
|
// src/index.ts
|
|
790
780
|
var READ_ONLY = { readOnlyHint: true, idempotentHint: true, openWorldHint: false };
|
|
791
781
|
var DESTRUCTIVE = {
|
|
@@ -870,7 +860,6 @@ var filePlugin = {
|
|
|
870
860
|
supportsParallel: true,
|
|
871
861
|
annotations: READ_ONLY,
|
|
872
862
|
operation: "file_read",
|
|
873
|
-
// 搜索的对象是目录,不是 pattern
|
|
874
863
|
describeTarget: dirTarget,
|
|
875
864
|
execute: execSearch
|
|
876
865
|
},
|
|
@@ -931,10 +920,6 @@ var filePlugin = {
|
|
|
931
920
|
properties: { patch: { type: "string", description: "V4A \u683C\u5F0F\u7684\u591A\u6587\u4EF6\u8865\u4E01\u5185\u5BB9" } },
|
|
932
921
|
required: ["patch"]
|
|
933
922
|
},
|
|
934
|
-
// 真实语义是只读(只算 diff 不落盘),annotations 照实写。
|
|
935
|
-
// 但 operation 仍填 file_write:老白名单把它归在 FILE_WRITE_TOOLS 里,
|
|
936
|
-
// 只改一边会让 recordApproval 那条路径与这里分叉。往严的方向偏,
|
|
937
|
-
// 代价只是多一次确认;纠正白名单本身是方案 06 的地盘。
|
|
938
923
|
annotations: READ_ONLY,
|
|
939
924
|
operation: "file_write",
|
|
940
925
|
describeTarget: patchTarget,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epoch-agent/plugin-file",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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.
|
|
26
|
-
"@epoch-agent/protocol": "0.
|
|
25
|
+
"@epoch-agent/infra": "0.2.0",
|
|
26
|
+
"@epoch-agent/protocol": "0.2.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^26.1.2",
|