Refactor path handling in patch_files.js to use user-specified paths for action keys, improving consistency and error messaging. Update CLI to replace commented-out test cases with a new interrogation command in German for business website creation, enhancing functionality.
This commit is contained in:
7
cli2.js
7
cli2.js
@@ -21,9 +21,10 @@ modelDialog.on('reasoningUpdate', (output) => {
|
|||||||
|
|
||||||
|
|
||||||
(async ()=>{
|
(async ()=>{
|
||||||
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('Ersttelle eine beispiel business webseite für acme mit react und webpack. Lege die Dateien in /demo an');
|
||||||
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);
|
||||||
|
|||||||
@@ -238,9 +238,9 @@ class Parser {
|
|||||||
if (path) {
|
if (path) {
|
||||||
// Resolve path with chroot
|
// Resolve path with chroot
|
||||||
const resolvedPath = resolvePath(this.chroot, path);
|
const resolvedPath = resolvePath(this.chroot, path);
|
||||||
|
// Use user-specified path as the key to avoid double-resolving later
|
||||||
if (resolvedPath in this.patch.actions) {
|
if (path in this.patch.actions) {
|
||||||
throw new DiffError(`Duplicate update for file: ${resolvedPath}`);
|
throw new DiffError(`Duplicate update for file: ${path}`);
|
||||||
}
|
}
|
||||||
const move_to = this.read_str("*** Move to: ");
|
const move_to = this.read_str("*** Move to: ");
|
||||||
if (!(resolvedPath in this.current_files)) {
|
if (!(resolvedPath in this.current_files)) {
|
||||||
@@ -248,8 +248,8 @@ class Parser {
|
|||||||
}
|
}
|
||||||
const text = this.current_files[resolvedPath];
|
const text = this.current_files[resolvedPath];
|
||||||
const action = this._parse_update_file(text);
|
const action = this._parse_update_file(text);
|
||||||
action.move_path = move_to ? resolvePath(this.chroot, move_to) : null;
|
action.move_path = move_to ? move_to : null;
|
||||||
this.patch.actions[resolvedPath] = action;
|
this.patch.actions[path] = action;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,14 +258,13 @@ class Parser {
|
|||||||
if (path) {
|
if (path) {
|
||||||
// Resolve path with chroot
|
// Resolve path with chroot
|
||||||
const resolvedPath = resolvePath(this.chroot, path);
|
const resolvedPath = resolvePath(this.chroot, path);
|
||||||
|
if (path in this.patch.actions) {
|
||||||
if (resolvedPath in this.patch.actions) {
|
throw new DiffError(`Duplicate delete for file: ${path}`);
|
||||||
throw new DiffError(`Duplicate delete for file: ${resolvedPath}`);
|
|
||||||
}
|
}
|
||||||
if (!(resolvedPath in this.current_files)) {
|
if (!(resolvedPath in this.current_files)) {
|
||||||
throw new DiffError(`Delete File Error - missing file: ${resolvedPath}`);
|
throw new DiffError(`Delete File Error - missing file: ${path}`);
|
||||||
}
|
}
|
||||||
this.patch.actions[resolvedPath] = new PatchAction(ActionType.DELETE);
|
this.patch.actions[path] = new PatchAction(ActionType.DELETE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,14 +273,13 @@ class Parser {
|
|||||||
if (path) {
|
if (path) {
|
||||||
// Resolve path with chroot
|
// Resolve path with chroot
|
||||||
const resolvedPath = resolvePath(this.chroot, path);
|
const resolvedPath = resolvePath(this.chroot, path);
|
||||||
|
if (path in this.patch.actions) {
|
||||||
if (resolvedPath in this.patch.actions) {
|
throw new DiffError(`Duplicate add for file: ${path}`);
|
||||||
throw new DiffError(`Duplicate add for file: ${resolvedPath}`);
|
|
||||||
}
|
}
|
||||||
if (resolvedPath in this.current_files) {
|
if (resolvedPath in this.current_files) {
|
||||||
throw new DiffError(`Add File Error - file already exists: ${resolvedPath}`);
|
throw new DiffError(`Add File Error - file already exists: ${path}`);
|
||||||
}
|
}
|
||||||
this.patch.actions[resolvedPath] = this._parse_add_file();
|
this.patch.actions[path] = this._parse_add_file();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,7 +368,9 @@ class Parser {
|
|||||||
if (!s.startsWith("+")) {
|
if (!s.startsWith("+")) {
|
||||||
throw new DiffError(`Invalid Add File line (missing '+'): ${s}`);
|
throw new DiffError(`Invalid Add File line (missing '+'): ${s}`);
|
||||||
}
|
}
|
||||||
lines.push(s.substring(1)); // strip leading '+'
|
// Strip leading '+' and ignore a single optional space immediately after '+'
|
||||||
|
const content = s.substring(1).replace(/^ /, "");
|
||||||
|
lines.push(content);
|
||||||
}
|
}
|
||||||
return new PatchAction(ActionType.ADD, lines.join("\n"));
|
return new PatchAction(ActionType.ADD, lines.join("\n"));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user