diff --git a/cli2.js b/cli2.js index d135e89..434bd2a 100644 --- a/cli2.js +++ b/cli2.js @@ -21,9 +21,10 @@ modelDialog.on('reasoningUpdate', (output) => { (async ()=>{ - 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 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('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('reasoning:',output2.reasoning); console.log('Tokens:',output2.inputTokens,output2.cachedTokens,output2.outputTokens); diff --git a/tools/patch_files.js b/tools/patch_files.js index e125d65..e572b45 100644 --- a/tools/patch_files.js +++ b/tools/patch_files.js @@ -238,9 +238,9 @@ class Parser { if (path) { // Resolve path with chroot const resolvedPath = resolvePath(this.chroot, path); - - if (resolvedPath in this.patch.actions) { - throw new DiffError(`Duplicate update for file: ${resolvedPath}`); + // Use user-specified path as the key to avoid double-resolving later + if (path in this.patch.actions) { + throw new DiffError(`Duplicate update for file: ${path}`); } const move_to = this.read_str("*** Move to: "); if (!(resolvedPath in this.current_files)) { @@ -248,8 +248,8 @@ class Parser { } const text = this.current_files[resolvedPath]; const action = this._parse_update_file(text); - action.move_path = move_to ? resolvePath(this.chroot, move_to) : null; - this.patch.actions[resolvedPath] = action; + action.move_path = move_to ? move_to : null; + this.patch.actions[path] = action; continue; } @@ -258,14 +258,13 @@ class Parser { if (path) { // Resolve path with chroot const resolvedPath = resolvePath(this.chroot, path); - - if (resolvedPath in this.patch.actions) { - throw new DiffError(`Duplicate delete for file: ${resolvedPath}`); + if (path in this.patch.actions) { + throw new DiffError(`Duplicate delete for file: ${path}`); } 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; } @@ -274,14 +273,13 @@ class Parser { if (path) { // Resolve path with chroot const resolvedPath = resolvePath(this.chroot, path); - - if (resolvedPath in this.patch.actions) { - throw new DiffError(`Duplicate add for file: ${resolvedPath}`); + if (path in this.patch.actions) { + throw new DiffError(`Duplicate add for file: ${path}`); } 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; } @@ -370,7 +368,9 @@ class Parser { if (!s.startsWith("+")) { 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")); }