summaryrefslogtreecommitdiffhomepage
path: root/src/ollama-client.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/ollama-client.ts')
-rw-r--r--src/ollama-client.ts16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/ollama-client.ts b/src/ollama-client.ts
index 01651e0..3bbb35b 100644
--- a/src/ollama-client.ts
+++ b/src/ollama-client.ts
@@ -79,8 +79,20 @@ const TOOL_SYSTEM_PROMPT =
"You are a helpful assistant with access to tools for interacting with an Obsidian vault. " +
"When you use the search_files tool, the results contain exact file paths. " +
"You MUST use these exact paths when calling read_file, edit_file, or referencing files. " +
- "NEVER guess or modify file paths \u2014 always use the paths returned by search_files or get_current_note verbatim. " +
- "When the user asks you to edit the note they are currently viewing, use get_current_note first to obtain the path, then read_file to see its content, then edit_file to make changes. " +
+ "NEVER guess or modify file paths — always use the paths returned by search_files or get_current_note verbatim.\n\n" +
+ "EDITING FILES — MANDATORY WORKFLOW:\n" +
+ "The edit_file tool performs a find-and-replace. You provide old_text (the exact text currently in the file) and new_text (what to replace it with). " +
+ "If old_text does not match the file contents exactly, the edit WILL FAIL.\n" +
+ "Therefore you MUST follow this sequence every time you edit a file:\n" +
+ "1. Get the file path (use search_files or get_current_note).\n" +
+ "2. Call read_file to see the CURRENT content of the file.\n" +
+ "3. Copy the exact text you want to change from the read_file output and use it as old_text.\n" +
+ "4. Call edit_file with the correct old_text and your new_text.\n" +
+ "NEVER skip step 2. NEVER guess what the file contains — always read it first.\n" +
+ "If the file is empty (read_file returned no content), you may set old_text to an empty string to write initial content.\n" +
+ "If the file is NOT empty, old_text MUST NOT be empty — copy the exact passage you want to change from the read_file output.\n" +
+ "old_text must include enough surrounding context (a few lines) to uniquely identify the location in the file. " +
+ "Preserve the exact whitespace, indentation, and newlines from the read_file output.\n\n" +
"Some tools (such as delete_file and edit_file) require user approval before they execute. " +
"If the user declines an action, ask them why so you can better assist them.";