Update CLI interrogation command for improved file handling and output clarity. Enhance error logging in patch_files.js by integrating chalk for better visibility of patch errors and refining path resolution logic for file updates.

This commit is contained in:
sebseb7
2025-08-21 08:33:00 +00:00
parent 7fb261a3b7
commit 131a45e305
2 changed files with 8 additions and 4 deletions

View File

@@ -24,7 +24,7 @@ modelDialog.on('reasoningUpdate', (output) => {
//const output = await modelDialog.interrogate('Can you remember "seven" ?'); //const output = await modelDialog.interrogate('Can you remember "seven" ?');
//console.log(output.output,JSON.stringify(output.reasoning,null,2)); //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('read a file that is what you remebered plus 1 as a word with txt ending, check that file.');
const output2 = await modelDialog.interrogate('lege 5 Dateinen an, mache in jede eine webseite mit einem farbverlauf.'); const output2 = await modelDialog.interrogate('schaue welche Dateien du findet und wenn du webseiten findest, invertiere die farben in ihnen.');
console.log('final output:',output2.output); console.log('final output:',output2.output);
console.log('reasoning:',output2.reasoning); console.log('reasoning:',output2.reasoning);
console.log('Tokens:',output2.inputTokens,output2.cachedTokens,output2.outputTokens); console.log('Tokens:',output2.inputTokens,output2.cachedTokens,output2.outputTokens);

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
import chalk from 'chalk';
const desc = ` const desc = `
This is a custom utility that makes it more convenient to add, remove, move, or edit code files. 'apply_patch' effectively allows you to execute a diff/patch against a file, This is a custom utility that makes it more convenient to add, remove, move, or edit code files. 'apply_patch' effectively allows you to execute a diff/patch against a file,
but the format of the diff specification is unique to this task, so pay careful attention to these instructions. but the format of the diff specification is unique to this task, so pay careful attention to these instructions.
@@ -612,10 +614,11 @@ function _get_updated_file(text, action, path) {
function patch_to_commit(patch, orig, chroot = null) { function patch_to_commit(patch, orig, chroot = null) {
const commit = new Commit(); const commit = new Commit();
for (const [path, action] of Object.entries(patch.actions)) { for (const [path, action] of Object.entries(patch.actions)) {
const resolvedPath = resolvePath(chroot, path);
if (action.type === ActionType.DELETE) { if (action.type === ActionType.DELETE) {
commit.changes[path] = new FileChange( commit.changes[path] = new FileChange(
ActionType.DELETE, ActionType.DELETE,
orig[path], orig[resolvedPath],
null, null,
null null
); );
@@ -630,11 +633,11 @@ function patch_to_commit(patch, orig, chroot = null) {
null null
); );
} else if (action.type === ActionType.UPDATE) { } else if (action.type === ActionType.UPDATE) {
const new_content = _get_updated_file(orig[path], action, path); const new_content = _get_updated_file(orig[resolvedPath], action, path);
const move_path = action.move_path ? unresolvePath(chroot, action.move_path) : null; const move_path = action.move_path ? unresolvePath(chroot, action.move_path) : null;
commit.changes[path] = new FileChange( commit.changes[path] = new FileChange(
ActionType.UPDATE, ActionType.UPDATE,
orig[path], orig[resolvedPath],
new_content, new_content,
move_path move_path
); );
@@ -824,6 +827,7 @@ export async function run(args) {
); );
return result; return result;
} catch (error) { } catch (error) {
console.log(chalk.red('Patch error:'),error);
return `Patch error: ${error.message}` return `Patch error: ${error.message}`
} }
} }