@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,438 +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 glob from "../../../../agents/update/fs-tools/glob.mjs";
|
|
7
|
-
|
|
8
|
-
describe("glob 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(), "glob-test-"));
|
|
18
|
-
|
|
19
|
-
// Change to temp directory
|
|
20
|
-
process.chdir(tempDir);
|
|
21
|
-
|
|
22
|
-
// Create a complex directory structure for testing
|
|
23
|
-
await fs.mkdir("src");
|
|
24
|
-
await fs.mkdir("src/components");
|
|
25
|
-
await fs.mkdir("src/utils");
|
|
26
|
-
await fs.mkdir("tests");
|
|
27
|
-
await fs.mkdir("docs");
|
|
28
|
-
await fs.mkdir("node_modules");
|
|
29
|
-
await fs.mkdir(".git");
|
|
30
|
-
|
|
31
|
-
// Create test files
|
|
32
|
-
await fs.writeFile("index.js", 'console.log("main");');
|
|
33
|
-
await fs.writeFile("README.md", "# Test Project");
|
|
34
|
-
await fs.writeFile("package.json", '{"name": "test"}');
|
|
35
|
-
|
|
36
|
-
await fs.writeFile("src/app.js", "export default app;");
|
|
37
|
-
await fs.writeFile("src/app.ts", "export default app;");
|
|
38
|
-
await fs.writeFile("src/components/Button.jsx", "export const Button = () => {};");
|
|
39
|
-
await fs.writeFile("src/components/Modal.tsx", "export const Modal = () => {};");
|
|
40
|
-
await fs.writeFile("src/utils/helper.js", "export const helper = () => {};");
|
|
41
|
-
|
|
42
|
-
await fs.writeFile("tests/app.test.js", 'test("app", () => {});');
|
|
43
|
-
await fs.writeFile("tests/util.spec.js", 'describe("util", () => {});');
|
|
44
|
-
|
|
45
|
-
await fs.writeFile("docs/api.md", "# API Documentation");
|
|
46
|
-
await fs.writeFile("docs/guide.rst", "Guide");
|
|
47
|
-
|
|
48
|
-
// Files that should be ignored
|
|
49
|
-
await fs.writeFile("node_modules/package.js", "module.exports = {};");
|
|
50
|
-
await fs.writeFile(".git/config", "[core]");
|
|
51
|
-
await fs.writeFile("debug.log", "log entry");
|
|
52
|
-
await fs.writeFile(".DS_Store", "mac metadata");
|
|
53
|
-
|
|
54
|
-
// Wait a bit to ensure different modification times
|
|
55
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
afterEach(async () => {
|
|
59
|
-
// Restore original working directory
|
|
60
|
-
process.chdir(originalCwd);
|
|
61
|
-
|
|
62
|
-
// Clean up temporary directory
|
|
63
|
-
await fs.rm(tempDir, { recursive: true, force: true });
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
describe("basic functionality", () => {
|
|
67
|
-
it("should find all JavaScript files with *.js pattern", async () => {
|
|
68
|
-
const result = await glob({
|
|
69
|
-
pattern: "*.js",
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
assert.strictEqual(result.command, "glob");
|
|
73
|
-
assert.strictEqual(result.error, null);
|
|
74
|
-
assert(result.result.files.includes("index.js"));
|
|
75
|
-
assert(!result.result.files.includes("README.md"));
|
|
76
|
-
assert.strictEqual(result.result.count, 1);
|
|
77
|
-
assert(result.result.message.includes("Found 1 file(s)"));
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("should find files recursively with **/*.js pattern", async () => {
|
|
81
|
-
const result = await glob({
|
|
82
|
-
pattern: "**/*.js",
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
assert.strictEqual(result.error, null);
|
|
86
|
-
assert(result.result.files.includes("index.js"));
|
|
87
|
-
assert(result.result.files.includes("src/app.js"));
|
|
88
|
-
assert(result.result.files.includes("src/utils/helper.js"));
|
|
89
|
-
assert(result.result.files.includes("tests/app.test.js"));
|
|
90
|
-
assert(result.result.count >= 4);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("should find TypeScript files with *.ts pattern", async () => {
|
|
94
|
-
const result = await glob({
|
|
95
|
-
pattern: "**/*.ts*",
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
assert.strictEqual(result.error, null);
|
|
99
|
-
assert(result.result.files.includes("src/app.ts"));
|
|
100
|
-
assert(result.result.files.includes("src/components/Modal.tsx"));
|
|
101
|
-
assert.strictEqual(result.result.count, 2);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("should find markdown files", async () => {
|
|
105
|
-
const result = await glob({
|
|
106
|
-
pattern: "**/*.md",
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
assert.strictEqual(result.error, null);
|
|
110
|
-
assert(result.result.files.includes("README.md"));
|
|
111
|
-
assert(result.result.files.includes("docs/api.md"));
|
|
112
|
-
assert.strictEqual(result.result.count, 2);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it("should find files in specific directory", async () => {
|
|
116
|
-
const result = await glob({
|
|
117
|
-
pattern: "src/*.js",
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
assert.strictEqual(result.error, null);
|
|
121
|
-
assert(result.result.files.includes("src/app.js"));
|
|
122
|
-
assert(!result.result.files.includes("index.js")); // Not in src directory
|
|
123
|
-
assert.strictEqual(result.result.count, 1);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
describe("file filtering and ignoring", () => {
|
|
128
|
-
it("should ignore node_modules directory", async () => {
|
|
129
|
-
const result = await glob({
|
|
130
|
-
pattern: "**/*.js",
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
assert.strictEqual(result.error, null);
|
|
134
|
-
assert(!result.result.files.some((file) => file.includes("node_modules")));
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("should ignore .git directory", async () => {
|
|
138
|
-
const result = await glob({
|
|
139
|
-
pattern: "**/*",
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
assert.strictEqual(result.error, null);
|
|
143
|
-
assert(!result.result.files.some((file) => file.includes(".git")));
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it("should ignore .DS_Store files", async () => {
|
|
147
|
-
const result = await glob({
|
|
148
|
-
pattern: "**/*",
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
assert.strictEqual(result.error, null);
|
|
152
|
-
assert(!result.result.files.includes(".DS_Store"));
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it("should ignore log files", async () => {
|
|
156
|
-
const result = await glob({
|
|
157
|
-
pattern: "**/*",
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
assert.strictEqual(result.error, null);
|
|
161
|
-
assert(!result.result.files.includes("debug.log"));
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
describe("parameter handling", () => {
|
|
166
|
-
it("should work without path parameter (use current directory)", async () => {
|
|
167
|
-
const result = await glob({
|
|
168
|
-
pattern: "*.js",
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
assert.strictEqual(result.error, null);
|
|
172
|
-
assert(result.result.files.includes("index.js"));
|
|
173
|
-
assert.strictEqual(result.arguments.path, undefined);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it("should respect limit parameter", async () => {
|
|
177
|
-
const result = await glob({
|
|
178
|
-
pattern: "**/*",
|
|
179
|
-
|
|
180
|
-
limit: 3,
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
assert.strictEqual(result.error, null);
|
|
184
|
-
assert(result.result.count <= 3);
|
|
185
|
-
assert.strictEqual(result.arguments.limit, 3);
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it("should handle case_sensitive parameter", async () => {
|
|
189
|
-
// Create files with different cases
|
|
190
|
-
await fs.writeFile("Test.js", "test file");
|
|
191
|
-
await fs.writeFile("test.js", "test file");
|
|
192
|
-
|
|
193
|
-
const result = await glob({
|
|
194
|
-
pattern: "*.js",
|
|
195
|
-
|
|
196
|
-
case_sensitive: false,
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
assert.strictEqual(result.error, null);
|
|
200
|
-
assert.strictEqual(result.arguments.case_sensitive, false);
|
|
201
|
-
// Note: Actual case sensitivity depends on filesystem and Node.js glob implementation
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it("should handle respect_git_ignore parameter", async () => {
|
|
205
|
-
const result = await glob({
|
|
206
|
-
pattern: "**/*",
|
|
207
|
-
|
|
208
|
-
respect_git_ignore: false,
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
assert.strictEqual(result.error, null);
|
|
212
|
-
assert.strictEqual(result.arguments.respect_git_ignore, false);
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
describe("sorting and output", () => {
|
|
217
|
-
it("should sort files by modification time", async () => {
|
|
218
|
-
// Create files with different modification times
|
|
219
|
-
await fs.writeFile("old.js", "old file");
|
|
220
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
221
|
-
await fs.writeFile("new.js", "new file");
|
|
222
|
-
|
|
223
|
-
const result = await glob({
|
|
224
|
-
pattern: "*.js",
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
assert.strictEqual(result.error, null);
|
|
228
|
-
// new.js should come before old.js (newer files first)
|
|
229
|
-
const newIndex = result.result.files.indexOf("new.js");
|
|
230
|
-
const oldIndex = result.result.files.indexOf("old.js");
|
|
231
|
-
|
|
232
|
-
if (newIndex >= 0 && oldIndex >= 0) {
|
|
233
|
-
assert(newIndex < oldIndex, "Newer files should come first");
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
it("should include count and message in result", async () => {
|
|
238
|
-
const result = await glob({
|
|
239
|
-
pattern: "**/*.md",
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
assert.strictEqual(result.error, null);
|
|
243
|
-
assert.strictEqual(typeof result.result.count, "number");
|
|
244
|
-
assert.strictEqual(typeof result.result.message, "string");
|
|
245
|
-
assert(result.result.message.includes("Found"));
|
|
246
|
-
assert(result.result.message.includes("modification time"));
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
it("should indicate truncation when limit is reached", async () => {
|
|
250
|
-
const result = await glob({
|
|
251
|
-
pattern: "**/*",
|
|
252
|
-
|
|
253
|
-
limit: 2,
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
assert.strictEqual(result.error, null);
|
|
257
|
-
if (result.result.truncated) {
|
|
258
|
-
assert(result.result.message.includes("2+"));
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
describe("error handling", () => {
|
|
264
|
-
it("should require pattern parameter", async () => {
|
|
265
|
-
const result = await glob({});
|
|
266
|
-
|
|
267
|
-
assert.notStrictEqual(result.error, null);
|
|
268
|
-
assert(result.error.message.includes("Pattern parameter is required"));
|
|
269
|
-
assert.strictEqual(result.result.count, 0);
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
it("should handle empty pattern", async () => {
|
|
273
|
-
const result = await glob({
|
|
274
|
-
pattern: "",
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
assert.notStrictEqual(result.error, null);
|
|
278
|
-
assert(result.error.message.includes("cannot be empty"));
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
it("should handle permission errors gracefully", async () => {
|
|
282
|
-
// This test might not work on all systems, but we include it for completeness
|
|
283
|
-
const result = await glob({
|
|
284
|
-
pattern: "**/*",
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
// Should not throw, even if some files are inaccessible
|
|
288
|
-
assert.strictEqual(typeof result, "object");
|
|
289
|
-
assert.strictEqual(typeof result.result, "object");
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
describe("glob patterns", () => {
|
|
294
|
-
it("should handle wildcard patterns", async () => {
|
|
295
|
-
const result = await glob({
|
|
296
|
-
pattern: "src/**/*.js*",
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
assert.strictEqual(result.error, null);
|
|
300
|
-
assert(result.result.files.includes("src/app.js"));
|
|
301
|
-
assert(result.result.files.includes("src/components/Button.jsx"));
|
|
302
|
-
assert(result.result.count >= 2);
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
it("should handle bracket patterns", async () => {
|
|
306
|
-
const result = await glob({
|
|
307
|
-
pattern: "**/*.{js,ts}",
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
assert.strictEqual(result.error, null);
|
|
311
|
-
assert(result.result.files.some((file) => file.endsWith(".js")));
|
|
312
|
-
assert(result.result.files.some((file) => file.endsWith(".ts")));
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
it("should handle negation patterns (if supported)", async () => {
|
|
316
|
-
// Note: Node.js glob may not support negation directly
|
|
317
|
-
const result = await glob({
|
|
318
|
-
pattern: "**/*.js",
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
assert.strictEqual(result.error, null);
|
|
322
|
-
// Just verify it works without negation
|
|
323
|
-
assert(result.result.files.length > 0);
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
it("should handle single character wildcards", async () => {
|
|
327
|
-
await fs.writeFile("a.js", "test");
|
|
328
|
-
await fs.writeFile("b.js", "test");
|
|
329
|
-
|
|
330
|
-
const result = await glob({
|
|
331
|
-
pattern: "?.js",
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
assert.strictEqual(result.error, null);
|
|
335
|
-
assert(result.result.files.includes("a.js"));
|
|
336
|
-
assert(result.result.files.includes("b.js"));
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
describe("edge cases", () => {
|
|
341
|
-
it("should handle empty directory", async () => {
|
|
342
|
-
await fs.mkdir("empty");
|
|
343
|
-
|
|
344
|
-
const result = await glob({
|
|
345
|
-
pattern: "empty/**/*",
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
assert.strictEqual(result.error, null);
|
|
349
|
-
assert.strictEqual(result.result.count, 0);
|
|
350
|
-
assert(result.result.message.includes("No files found"));
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
it("should handle pattern that matches no files", async () => {
|
|
354
|
-
const result = await glob({
|
|
355
|
-
pattern: "**/*.nonexistent",
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
assert.strictEqual(result.error, null);
|
|
359
|
-
assert.strictEqual(result.result.count, 0);
|
|
360
|
-
assert(result.result.message.includes("No files found"));
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
it("should handle very long file names", async () => {
|
|
364
|
-
const longName = `${"a".repeat(100)}.js`;
|
|
365
|
-
await fs.writeFile(longName, "test");
|
|
366
|
-
|
|
367
|
-
const result = await glob({
|
|
368
|
-
pattern: "**/*.js",
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
assert.strictEqual(result.error, null);
|
|
372
|
-
assert(result.result.files.includes(longName));
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
it("should handle special characters in file names", async () => {
|
|
376
|
-
const specialName = "file with spaces & symbols!.js";
|
|
377
|
-
await fs.writeFile(specialName, "test");
|
|
378
|
-
|
|
379
|
-
const result = await glob({
|
|
380
|
-
pattern: "**/*.js",
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
assert.strictEqual(result.error, null);
|
|
384
|
-
assert(result.result.files.includes(specialName));
|
|
385
|
-
});
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
describe("utility functions", () => {
|
|
390
|
-
let tempDir;
|
|
391
|
-
let originalCwd;
|
|
392
|
-
|
|
393
|
-
beforeEach(async () => {
|
|
394
|
-
originalCwd = process.cwd();
|
|
395
|
-
tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "glob-util-test-"));
|
|
396
|
-
process.chdir(tempDir);
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
afterEach(async () => {
|
|
400
|
-
process.chdir(originalCwd);
|
|
401
|
-
await fs.rm(tempDir, { recursive: true, force: true });
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
it("should validate file sorting by modification time", async () => {
|
|
405
|
-
// Create files with known timestamps
|
|
406
|
-
await fs.writeFile("file1.txt", "content 1");
|
|
407
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
408
|
-
await fs.writeFile("file2.txt", "content 2");
|
|
409
|
-
|
|
410
|
-
const result = await glob({
|
|
411
|
-
pattern: "*.txt",
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
assert.strictEqual(result.error, null);
|
|
415
|
-
const files = result.result.files;
|
|
416
|
-
|
|
417
|
-
if (files.includes("file1.txt") && files.includes("file2.txt")) {
|
|
418
|
-
const file1Index = files.indexOf("file1.txt");
|
|
419
|
-
const file2Index = files.indexOf("file2.txt");
|
|
420
|
-
assert(file2Index < file1Index, "file2.txt should come before file1.txt (newer first)");
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
describe("schema validation", () => {
|
|
426
|
-
it("should have correct input schema", () => {
|
|
427
|
-
assert.strictEqual(typeof glob.input_schema, "object");
|
|
428
|
-
assert.strictEqual(glob.input_schema.type, "object");
|
|
429
|
-
assert(Array.isArray(glob.input_schema.required));
|
|
430
|
-
assert(glob.input_schema.required.includes("pattern"));
|
|
431
|
-
assert.strictEqual(typeof glob.input_schema.properties, "object");
|
|
432
|
-
assert.strictEqual(typeof glob.input_schema.properties.pattern, "object");
|
|
433
|
-
assert.strictEqual(glob.input_schema.properties.pattern.type, "string");
|
|
434
|
-
assert.strictEqual(typeof glob.input_schema.properties.case_sensitive, "object");
|
|
435
|
-
assert.strictEqual(typeof glob.input_schema.properties.respect_git_ignore, "object");
|
|
436
|
-
assert.strictEqual(typeof glob.input_schema.properties.limit, "object");
|
|
437
|
-
});
|
|
438
|
-
});
|