@ducci/jarvis 1.0.43 → 1.0.44
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/package.json +1 -1
- package/src/server/tools.js +20 -15
package/package.json
CHANGED
package/src/server/tools.js
CHANGED
|
@@ -11,35 +11,40 @@ const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;
|
|
|
11
11
|
const TOOL_TIMEOUT_MS = 60_000;
|
|
12
12
|
|
|
13
13
|
const SEED_TOOLS = {
|
|
14
|
-
|
|
14
|
+
read_file: {
|
|
15
15
|
definition: {
|
|
16
16
|
type: 'function',
|
|
17
17
|
function: {
|
|
18
|
-
name: '
|
|
19
|
-
description: '
|
|
18
|
+
name: 'read_file',
|
|
19
|
+
description: 'Read a file from disk. Returns the file content as a string. Use offset and limit to read large files in chunks instead of loading everything at once.',
|
|
20
20
|
parameters: {
|
|
21
21
|
type: 'object',
|
|
22
22
|
properties: {
|
|
23
23
|
path: {
|
|
24
24
|
type: 'string',
|
|
25
|
-
description: '
|
|
25
|
+
description: 'Absolute or relative path to the file to read.',
|
|
26
|
+
},
|
|
27
|
+
offset: {
|
|
28
|
+
type: 'number',
|
|
29
|
+
description: 'Line number to start reading from (1-based). Omit to start from the beginning.',
|
|
30
|
+
},
|
|
31
|
+
limit: {
|
|
32
|
+
type: 'number',
|
|
33
|
+
description: 'Maximum number of lines to return. Omit to read the entire file (or remainder from offset).',
|
|
26
34
|
},
|
|
27
35
|
},
|
|
28
|
-
required: [],
|
|
36
|
+
required: ['path'],
|
|
29
37
|
},
|
|
30
38
|
},
|
|
31
39
|
},
|
|
32
40
|
code: `
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
timeout: 10000,
|
|
41
|
-
});
|
|
42
|
-
return { status: "ok", path: resolved, output };
|
|
41
|
+
const targetPath = path.resolve(args.path);
|
|
42
|
+
const raw = await fs.promises.readFile(targetPath, 'utf8');
|
|
43
|
+
const lines = raw.split('\\n');
|
|
44
|
+
const offset = args.offset ? args.offset - 1 : 0;
|
|
45
|
+
const slice = args.limit ? lines.slice(offset, offset + args.limit) : lines.slice(offset);
|
|
46
|
+
const totalLines = lines.length;
|
|
47
|
+
return { status: 'ok', path: targetPath, content: slice.join('\\n'), totalLines, returnedLines: slice.length, offset: offset + 1 };
|
|
43
48
|
`,
|
|
44
49
|
},
|
|
45
50
|
exec: {
|