@aigne/doc-smith 0.8.11 → 0.8.12-beta
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.12-beta](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.11...v0.8.12-beta) (2025-10-07)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* read file tool should support relative path ([#162](https://github.com/AIGNE-io/aigne-doc-smith/issues/162)) ([cf1291b](https://github.com/AIGNE-io/aigne-doc-smith/commit/cf1291b0be5b51db15d052310c30b0552a4092e1))
|
|
9
|
+
|
|
3
10
|
## [0.8.11](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.11-beta.7...v0.8.11) (2025-10-05)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import fsPromises from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
3
|
+
import path, { isAbsolute } from "node:path";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Detects if a file is likely binary by checking for null bytes
|
|
@@ -199,6 +199,8 @@ export default async function readFile({ path: filePath, offset, limit, encoding
|
|
|
199
199
|
let result = {};
|
|
200
200
|
let error = null;
|
|
201
201
|
|
|
202
|
+
if (filePath && !isAbsolute(filePath)) filePath = path.join(process.cwd(), filePath);
|
|
203
|
+
|
|
202
204
|
try {
|
|
203
205
|
// Validate file path first (this checks if it's absolute)
|
|
204
206
|
const pathError = validateFilePath(filePath);
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, it } from "bun:test";
|
|
1
2
|
import assert from "node:assert";
|
|
2
3
|
import fs from "node:fs/promises";
|
|
3
4
|
import os from "node:os";
|
|
4
5
|
import path from "node:path";
|
|
5
|
-
import { afterEach, beforeEach, describe, it } from "bun:test";
|
|
6
6
|
import readFile from "../../../../agents/update/fs-tools/read-file.mjs";
|
|
7
7
|
|
|
8
8
|
describe("read-file tool", () => {
|
|
@@ -11,11 +11,13 @@ describe("read-file tool", () => {
|
|
|
11
11
|
beforeEach(async () => {
|
|
12
12
|
// Create temporary directory for test files
|
|
13
13
|
tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "read-file-test-"));
|
|
14
|
+
process.chdir(tempDir);
|
|
14
15
|
});
|
|
15
16
|
|
|
16
17
|
afterEach(async () => {
|
|
17
18
|
// Clean up temporary directory
|
|
18
19
|
await fs.rm(tempDir, { recursive: true, force: true });
|
|
20
|
+
process.chdir(__dirname);
|
|
19
21
|
});
|
|
20
22
|
|
|
21
23
|
describe("basic functionality", () => {
|
|
@@ -25,13 +27,16 @@ describe("read-file tool", () => {
|
|
|
25
27
|
await fs.writeFile(filePath, content, "utf8");
|
|
26
28
|
|
|
27
29
|
const result = await readFile({
|
|
28
|
-
path:
|
|
30
|
+
path: "test.txt",
|
|
29
31
|
});
|
|
30
32
|
|
|
31
33
|
assert.strictEqual(result.command, "read_file");
|
|
32
34
|
assert.strictEqual(result.error, null);
|
|
33
35
|
assert.strictEqual(result.result.content, content);
|
|
34
|
-
assert.strictEqual(
|
|
36
|
+
assert.strictEqual(
|
|
37
|
+
await fs.realpath(result.result.metadata.path),
|
|
38
|
+
await fs.realpath(filePath),
|
|
39
|
+
);
|
|
35
40
|
assert.strictEqual(result.result.metadata.mimeType, "text/plain");
|
|
36
41
|
assert.strictEqual(result.result.metadata.isBinary, false);
|
|
37
42
|
assert.strictEqual(result.result.metadata.encoding, "utf8");
|
|
@@ -348,15 +353,6 @@ describe("read-file tool", () => {
|
|
|
348
353
|
assert(result.error.message.includes("required"));
|
|
349
354
|
});
|
|
350
355
|
|
|
351
|
-
it("should require absolute path", async () => {
|
|
352
|
-
const result = await readFile({
|
|
353
|
-
path: "relative/path.txt",
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
assert.notStrictEqual(result.error, null);
|
|
357
|
-
assert(result.error.message.includes("absolute"));
|
|
358
|
-
});
|
|
359
|
-
|
|
360
356
|
it("should handle non-existent files", async () => {
|
|
361
357
|
const result = await readFile({
|
|
362
358
|
path: path.join(tempDir, "nonexistent.txt"),
|