From eb3f58b2e63c714df3aa4d78c04fe8c797031e80 Mon Sep 17 00:00:00 2001 From: sebseb7 Date: Thu, 21 Aug 2025 12:58:14 +0000 Subject: [PATCH] Refactor CLI and file handling tools for improved functionality. Update CLI interrogation command for better clarity and adjust logging format. Modify list_files.js to enhance path display logic and update read_file.js schema to allow null values for optional parameters, improving flexibility in file reading operations. --- cli2.js | 4 ++-- tools/list_files.js | 5 ++++- tools/read_file.js | 8 ++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cli2.js b/cli2.js index 5a29f5e..cf86f9a 100644 --- a/cli2.js +++ b/cli2.js @@ -24,8 +24,8 @@ modelDialog.on('reasoningUpdate', (output) => { //const output = await modelDialog.interrogate('Can you remember "seven" ?'); //console.log(output.output,JSON.stringify(output.reasoning,null,2)); //const output2 = await modelDialog.interrogate('read a file that is what you remebered plus 1 as a word with txt ending, check that file.'); - const output2 = await modelDialog.interrogate('schaue welche Dateien du findet und wenn du webseiten findest, invertiere die farben in ihnen.'); + const output2 = await modelDialog.interrogate('Hi, use the list files tools and the read files tool on /readme.txt in same variations to test it. use the tools in parallel.'); console.log('final output:',output2.output); console.log('reasoning:',output2.reasoning); - console.log('Tokens:',output2.inputTokens,output2.cachedTokens,output2.outputTokens); + console.log('Ti:',output2.inputTokens,'Tc:',output2.cachedTokens,'To:',output2.outputTokens); })() diff --git a/tools/list_files.js b/tools/list_files.js index 08e00a0..33f992d 100644 --- a/tools/list_files.js +++ b/tools/list_files.js @@ -159,7 +159,10 @@ export async function run(args) { return { err: `Path does not exist${inputPath ? `: ${inputPath}` : ""}` }; } - const cwd = path.relative(chrootResolved, stat.isFile() ? path.dirname(resolvedBase) : resolvedBase) || "."; + const cwd = toDisplayPath( + stat.isFile() ? path.dirname(resolvedBase) : resolvedBase, + chrootResolved + ); // Handle single file case if (stat.isFile()) { diff --git a/tools/read_file.js b/tools/read_file.js index 407dcc7..a81d628 100644 --- a/tools/read_file.js +++ b/tools/read_file.js @@ -8,12 +8,12 @@ const virtual_chroot = '/workspaces/aiTools/root'; // Ensures reads are confined to `virtual_chroot`. export default { - type: "function", name: "read_file", description: "read a file", strict: true, + type: "function", name: "read_file", description: "read a file", strict: false, parameters: { - type: "object", required: ["path","linesToSkip","linesToRead"], additionalProperties: false, properties: { + type: "object", required: ["path"], additionalProperties: false, properties: { path: { type: "string", description: "The path to the file to read.", }, - linesToSkip: { type: "integer", description: "The number of lines to skip. Use 0 to read from the beginning.", minimum: 0 }, - linesToRead: { type: "integer", description: "1-400 The number of lines to read.", minimum: 1, maximum: 400 } + linesToSkip: { type: ["integer", "null"], description: "The number of lines to skip. Use 0 to read from the beginning, which is the default.", minimum: 0 }, + linesToRead: { type: ["integer", "null"], description: "1-400 The number of lines to read. 400 is the default.", minimum: 1, maximum: 400 } } } };