@aigne/doc-smith 0.8.12-beta.6 → 0.8.12-beta.8
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/.aigne/doc-smith/config.yaml +1 -1
- package/.aigne/doc-smith/history.yaml +37 -0
- package/.aigne/doc-smith/media-description.yaml +91 -0
- package/.aigne/doc-smith/preferences.yml +12 -0
- package/.aigne/doc-smith/upload-cache.yaml +36 -69
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +24 -0
- package/agents/clear/choose-contents.mjs +14 -1
- package/agents/clear/clear-media-description.mjs +129 -0
- package/agents/clear/index.yaml +3 -1
- package/agents/evaluate/code-snippet.mjs +28 -24
- package/agents/evaluate/document-structure.yaml +0 -4
- package/agents/evaluate/document.yaml +1 -5
- package/agents/generate/index.yaml +1 -0
- package/agents/generate/update-document-structure.yaml +9 -3
- package/agents/history/view.mjs +5 -2
- package/agents/init/index.mjs +10 -0
- package/agents/media/batch-generate-media-description.yaml +44 -0
- package/agents/media/generate-media-description.yaml +47 -0
- package/agents/media/load-media-description.mjs +238 -0
- package/agents/update/generate-document.yaml +10 -4
- package/agents/update/index.yaml +1 -0
- package/agents/update/update-document-detail.yaml +9 -3
- package/agents/update/user-review-document.mjs +2 -1
- package/agents/utils/load-sources.mjs +103 -53
- package/aigne.yaml +6 -0
- package/assets/report-template/report.html +34 -34
- package/docs/configuration-initial-setup.md +74 -55
- package/docs/configuration.ja.md +59 -86
- package/docs/configuration.md +59 -86
- package/docs/configuration.zh-TW.md +59 -86
- package/docs/configuration.zh.md +59 -86
- package/docs/getting-started.ja.md +43 -24
- package/docs/getting-started.md +29 -10
- package/docs/getting-started.zh-TW.md +42 -23
- package/docs/getting-started.zh.md +39 -20
- package/docs/guides-cleaning-up.ja.md +16 -15
- package/docs/guides-cleaning-up.md +19 -17
- package/docs/guides-cleaning-up.zh-TW.md +16 -15
- package/docs/guides-cleaning-up.zh.md +12 -11
- package/docs/guides-evaluating-documents.md +70 -29
- package/docs/guides-generating-documentation.ja.md +34 -32
- package/docs/guides-generating-documentation.md +59 -119
- package/docs/guides-generating-documentation.zh-TW.md +34 -32
- package/docs/guides-generating-documentation.zh.md +30 -28
- package/docs/guides-interactive-chat.md +34 -26
- package/docs/guides-managing-history.ja.md +17 -20
- package/docs/guides-managing-history.md +19 -17
- package/docs/guides-managing-history.zh-TW.md +18 -21
- package/docs/guides-managing-history.zh.md +13 -16
- package/docs/guides-publishing-your-docs.md +40 -35
- package/docs/guides-translating-documentation.ja.md +17 -17
- package/docs/guides-translating-documentation.md +39 -34
- package/docs/guides-translating-documentation.zh-TW.md +21 -21
- package/docs/guides-translating-documentation.zh.md +18 -18
- package/docs/guides-updating-documentation.ja.md +35 -35
- package/docs/guides-updating-documentation.md +11 -9
- package/docs/guides-updating-documentation.zh-TW.md +27 -27
- package/docs/guides-updating-documentation.zh.md +26 -26
- package/docs/overview.ja.md +13 -13
- package/docs/overview.md +2 -2
- package/docs/overview.zh-TW.md +19 -19
- package/docs/overview.zh.md +16 -16
- package/docs/release-notes.md +60 -27
- package/package.json +2 -1
- package/prompts/common/afs/afs-tools-usage.md +5 -0
- package/prompts/common/afs/use-afs-instruction.md +1 -0
- package/prompts/detail/generate/system-prompt.md +0 -13
- package/prompts/detail/generate/user-prompt.md +7 -0
- package/prompts/detail/update/system-prompt.md +1 -2
- package/prompts/detail/update/user-prompt.md +7 -0
- package/prompts/evaluate/document-structure.md +6 -7
- package/prompts/evaluate/document.md +16 -25
- package/prompts/media/media-description/system-prompt.md +35 -0
- package/prompts/media/media-description/user-prompt.md +8 -0
- package/prompts/structure/generate/system-prompt.md +0 -19
- package/prompts/structure/generate/user-prompt.md +22 -1
- package/prompts/structure/update/system-prompt.md +0 -17
- package/prompts/structure/update/user-prompt.md +24 -0
- package/tests/agents/history/view.test.mjs +97 -0
- package/tests/utils/history-utils.test.mjs +125 -97
- package/utils/constants/index.mjs +0 -107
- package/utils/file-utils.mjs +42 -1
- package/utils/history-utils.mjs +3 -3
- package/agents/update/fs-tools/glob.mjs +0 -184
- package/agents/update/fs-tools/grep.mjs +0 -317
- package/agents/update/fs-tools/read-file.mjs +0 -309
- package/media.md +0 -19
- package/tests/agents/update/fs-tools/glob.test.mjs +0 -438
- package/tests/agents/update/fs-tools/grep.test.mjs +0 -279
- package/tests/agents/update/fs-tools/read-file.test.mjs +0 -549
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
import os from "node:os";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { afterEach, beforeEach, describe, it } from "bun:test";
|
|
6
|
-
import grep from "../../../../agents/update/fs-tools/grep.mjs";
|
|
7
|
-
|
|
8
|
-
describe("grep tool", () => {
|
|
9
|
-
let tempDir;
|
|
10
|
-
let originalCwd;
|
|
11
|
-
|
|
12
|
-
beforeEach(async () => {
|
|
13
|
-
// Save original working directory
|
|
14
|
-
originalCwd = process.cwd();
|
|
15
|
-
|
|
16
|
-
// Create temporary directory for test files
|
|
17
|
-
tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "grep-test-"));
|
|
18
|
-
|
|
19
|
-
// Change to temp directory
|
|
20
|
-
process.chdir(tempDir);
|
|
21
|
-
|
|
22
|
-
// Create test files
|
|
23
|
-
await fs.writeFile("test1.txt", "hello world\nthis is a test\nworld of testing");
|
|
24
|
-
|
|
25
|
-
await fs.writeFile(
|
|
26
|
-
"test2.js",
|
|
27
|
-
'function hello() {\n return "world";\n}\nconst test = "hello";',
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
await fs.mkdir("subdir");
|
|
31
|
-
await fs.writeFile("subdir/nested.txt", "nested hello file\nwith world content");
|
|
32
|
-
|
|
33
|
-
await fs.writeFile("test3.md", "# Hello\nMarkdown with world content\n## World Section");
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
afterEach(async () => {
|
|
37
|
-
// Restore original working directory
|
|
38
|
-
process.chdir(originalCwd);
|
|
39
|
-
|
|
40
|
-
// Clean up temporary directory
|
|
41
|
-
await fs.rm(tempDir, { recursive: true, force: true });
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
describe("basic functionality", () => {
|
|
45
|
-
it("should find matches using JavaScript fallback", async () => {
|
|
46
|
-
const result = await grep({
|
|
47
|
-
pattern: "hello",
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
assert.strictEqual(result.command, "grep");
|
|
51
|
-
assert.deepStrictEqual(result.arguments, { pattern: "hello", include: undefined });
|
|
52
|
-
assert.strictEqual(result.error, null);
|
|
53
|
-
assert(result.result.includes("Found"));
|
|
54
|
-
assert(result.result.includes("hello"));
|
|
55
|
-
assert(result.result.includes("test1.txt"));
|
|
56
|
-
assert(result.result.includes("test2.js"));
|
|
57
|
-
assert(result.result.includes("nested.txt"));
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("should find matches with include filter", async () => {
|
|
61
|
-
const result = await grep({
|
|
62
|
-
pattern: "hello",
|
|
63
|
-
|
|
64
|
-
include: "*.js",
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
assert(result.result.includes("test2.js"));
|
|
68
|
-
assert(!result.result.includes("test1.txt"));
|
|
69
|
-
assert(result.result.includes('filter: "*.js"'));
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("should return no matches when pattern not found", async () => {
|
|
73
|
-
const result = await grep({
|
|
74
|
-
pattern: "nonexistent",
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
assert(result.result.includes("No matches found"));
|
|
78
|
-
assert(result.result.includes("nonexistent"));
|
|
79
|
-
assert.strictEqual(result.error, null);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("should be case insensitive", async () => {
|
|
83
|
-
const result = await grep({
|
|
84
|
-
pattern: "HELLO",
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
assert(result.result.includes("Found"));
|
|
88
|
-
assert(result.result.includes("hello"));
|
|
89
|
-
assert.strictEqual(result.error, null);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe("error handling", () => {
|
|
94
|
-
it("should handle invalid regex pattern", async () => {
|
|
95
|
-
const result = await grep({
|
|
96
|
-
pattern: "[[[",
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
assert.notStrictEqual(result.error, null);
|
|
100
|
-
assert(result.error.message.includes("Invalid regular expression"));
|
|
101
|
-
assert(result.result.includes("Error during grep search"));
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("should handle file read errors gracefully", async () => {
|
|
105
|
-
// Create a binary file that might cause read issues
|
|
106
|
-
await fs.writeFile("binary.bin", Buffer.from([0x00, 0x01, 0x02]));
|
|
107
|
-
|
|
108
|
-
const result = await grep({
|
|
109
|
-
pattern: "hello",
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
// Should still work, just ignore unreadable files
|
|
113
|
-
assert.strictEqual(result.error, null);
|
|
114
|
-
assert.strictEqual(typeof result.result, "string");
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
describe("output formatting", () => {
|
|
119
|
-
it("should format single match correctly", async () => {
|
|
120
|
-
// Create a file with single match
|
|
121
|
-
await fs.writeFile("single.txt", "one hello here");
|
|
122
|
-
|
|
123
|
-
const result = await grep({
|
|
124
|
-
pattern: "hello",
|
|
125
|
-
|
|
126
|
-
include: "single.txt",
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
assert(result.result.includes("Found 1 match"));
|
|
130
|
-
assert(result.result.includes("File: single.txt"));
|
|
131
|
-
assert(result.result.includes("L1: one hello here"));
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("should format multiple matches correctly", async () => {
|
|
135
|
-
const result = await grep({
|
|
136
|
-
pattern: "world",
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
assert(/Found \d+ matches/.test(result.result));
|
|
140
|
-
assert(result.result.includes("File:"));
|
|
141
|
-
assert(result.result.includes("L1:"));
|
|
142
|
-
assert(result.result.includes("---"));
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it("should group matches by file and sort by line number", async () => {
|
|
146
|
-
// Create file with multiple matches
|
|
147
|
-
await fs.writeFile(
|
|
148
|
-
"multi.txt",
|
|
149
|
-
"line 1 with test\nline 2 normal\nline 3 with test\nline 4 with test",
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
const result = await grep({
|
|
153
|
-
pattern: "test",
|
|
154
|
-
|
|
155
|
-
include: "multi.txt",
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
const lines = result.result.split("\n");
|
|
159
|
-
const lineNumbers = lines
|
|
160
|
-
.filter((line) => line.startsWith("L"))
|
|
161
|
-
.map((line) => parseInt(line.match(/L(\d+):/)[1], 10));
|
|
162
|
-
|
|
163
|
-
// Should be in ascending order
|
|
164
|
-
assert.deepStrictEqual(lineNumbers, [1, 3, 4]);
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
describe("directory and file filtering", () => {
|
|
169
|
-
it("should exclude node_modules and .git directories", async () => {
|
|
170
|
-
// Create node_modules and .git directories with files
|
|
171
|
-
await fs.mkdir("node_modules");
|
|
172
|
-
await fs.writeFile("node_modules/package.js", "hello from node_modules");
|
|
173
|
-
|
|
174
|
-
await fs.mkdir(".git");
|
|
175
|
-
await fs.writeFile(".git/config", "hello from git");
|
|
176
|
-
|
|
177
|
-
const result = await grep({
|
|
178
|
-
pattern: "hello",
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
// Should not include matches from node_modules or .git
|
|
182
|
-
assert(!result.result.includes("node_modules"));
|
|
183
|
-
assert(!result.result.includes(".git"));
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it("should respect include glob pattern in JS fallback", async () => {
|
|
187
|
-
const result = await grep({
|
|
188
|
-
pattern: "hello",
|
|
189
|
-
|
|
190
|
-
include: "*.md",
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
assert(result.result.includes("test3.md"));
|
|
194
|
-
assert(!result.result.includes("test1.txt"));
|
|
195
|
-
assert(!result.result.includes("test2.js"));
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
describe("path handling", () => {
|
|
200
|
-
it("should default to current directory when no path specified", async () => {
|
|
201
|
-
const result = await grep({
|
|
202
|
-
pattern: "hello",
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
assert.strictEqual(result.arguments.path, undefined);
|
|
206
|
-
assert(result.result.includes("Found"));
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it("should search in nested directories", async () => {
|
|
210
|
-
const result = await grep({
|
|
211
|
-
pattern: "nested",
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
assert(result.result.includes("nested.txt"));
|
|
215
|
-
assert(result.result.includes("nested hello file"));
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
describe("regex patterns", () => {
|
|
220
|
-
it("should handle regex special characters correctly", async () => {
|
|
221
|
-
// Create file with content that matches regex pattern
|
|
222
|
-
await fs.writeFile("regex.txt", 'const foo = "bar";');
|
|
223
|
-
|
|
224
|
-
const result = await grep({
|
|
225
|
-
pattern: "foo.*bar",
|
|
226
|
-
|
|
227
|
-
include: "regex.txt",
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
assert(result.result.includes("Found"));
|
|
231
|
-
assert(result.result.includes('const foo = "bar";'));
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it("should handle word boundaries", async () => {
|
|
235
|
-
await fs.writeFile("boundary.txt", "hello\nhelloing\nworld hello test");
|
|
236
|
-
|
|
237
|
-
const result = await grep({
|
|
238
|
-
pattern: "\\bhello\\b",
|
|
239
|
-
|
|
240
|
-
include: "boundary.txt",
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
// Should match 'hello' but not 'helloing'
|
|
244
|
-
assert(result.result.includes("L1: hello"));
|
|
245
|
-
assert(result.result.includes("L3: world hello test"));
|
|
246
|
-
assert(!result.result.includes("helloing"));
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
describe("input validation", () => {
|
|
251
|
-
it("should require pattern parameter", async () => {
|
|
252
|
-
const result = await grep({});
|
|
253
|
-
|
|
254
|
-
assert.notStrictEqual(result.error, null);
|
|
255
|
-
assert(result.result.includes("Error"));
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it("should handle empty pattern", async () => {
|
|
259
|
-
const result = await grep({
|
|
260
|
-
pattern: "",
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
// Empty pattern should match all lines
|
|
264
|
-
assert(result.result.includes("Found"));
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
describe("schema validation", () => {
|
|
270
|
-
it("should have correct input schema", () => {
|
|
271
|
-
assert.strictEqual(typeof grep.input_schema, "object");
|
|
272
|
-
assert.strictEqual(grep.input_schema.type, "object");
|
|
273
|
-
assert(Array.isArray(grep.input_schema.required));
|
|
274
|
-
assert(grep.input_schema.required.includes("pattern"));
|
|
275
|
-
assert.strictEqual(typeof grep.input_schema.properties, "object");
|
|
276
|
-
assert.strictEqual(typeof grep.input_schema.properties.pattern, "object");
|
|
277
|
-
assert.strictEqual(grep.input_schema.properties.pattern.type, "string");
|
|
278
|
-
});
|
|
279
|
-
});
|