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:
2
cli2.js
2
cli2.js
@@ -24,7 +24,7 @@ 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('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('reasoning:',output2.reasoning);
|
||||
console.log('Tokens:',output2.inputTokens,output2.cachedTokens,output2.outputTokens);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import chalk from 'chalk';
|
||||
|
||||
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,
|
||||
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) {
|
||||
const commit = new Commit();
|
||||
for (const [path, action] of Object.entries(patch.actions)) {
|
||||
const resolvedPath = resolvePath(chroot, path);
|
||||
if (action.type === ActionType.DELETE) {
|
||||
commit.changes[path] = new FileChange(
|
||||
ActionType.DELETE,
|
||||
orig[path],
|
||||
orig[resolvedPath],
|
||||
null,
|
||||
null
|
||||
);
|
||||
@@ -630,11 +633,11 @@ function patch_to_commit(patch, orig, chroot = null) {
|
||||
null
|
||||
);
|
||||
} 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;
|
||||
commit.changes[path] = new FileChange(
|
||||
ActionType.UPDATE,
|
||||
orig[path],
|
||||
orig[resolvedPath],
|
||||
new_content,
|
||||
move_path
|
||||
);
|
||||
@@ -824,6 +827,7 @@ export async function run(args) {
|
||||
);
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.log(chalk.red('Patch error:'),error);
|
||||
return `Patch error: ${error.message}`
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user