File Operation Protocols
1. Core Safety Protocols
1.1 Path Handling Standards
- Quoting: Always use double quotes for file paths (e.g.,
cd "C:/My Docs"). - Separators: Prefer forward slashes
/. If backslashes are needed, ensure they are escaped or quoted properly. - Forbidden: Do not use Windows-native
dir,del,copy,move. Use POSIXls,rm,cp,mv.
1.2 Plan-Verify-Execute (PVE) Workflow
Mandatory for all filesystem interactions:
- Plan: Propose a clear action plan with specific file paths.
- Verify: Use read-only tools (
Glob,Read) to verify preconditions (file existence, current content) before any side-effect operation. - Execute: Execute the operation only after verification.
1.3 Recursive Context Retrieval Protocol (Auggie-Inspired)
Trigger: When analyzing code dependencies or fixing bugs.
-
Semantic Query Construction:
- Do NOT just grep for exact matches.
- Use NL to formulate 3-point queries: Where (location), What (definition), How (usage).
-
Definition-Chain Verification:
- Found
funcA()call? -> FindfuncAdefinition. funcAusesInterfaceB? -> FindInterfaceBdefinition.InterfaceBextendsBaseC? -> FindBaseCdefinition.- Stop Condition: When you hold the Full Type Signature of all interacting components.
- Found
-
Completeness Check:
- If context is partial, explicitly list missing parts using
TodoWrite(inCHINESE/简体中文only). - If ambiguous, use
AskUserQuestion(inCHINESE/简体中文only) to align boundaries.
- If context is partial, explicitly list missing parts using
1.4 Execution Protocol (Type 1)
- Silence: Execute tools silently. Do not chat between tool calls unless necessary.
- Concurrency: Default to serial. Parallel permitted for independent, non-conflicting read operations.
- Parameter Integrity: STRICTLY check
file_pathandold_string/new_stringbefore calling.
2. Advanced Reading Protocols
2.1 Streaming Bulk Read Protocol
Trigger: When reading 2 or more files.
- Manifest: List target files using
Globorls. - Instruction: Generate a series of
Readcalls serially. - Execution: Execute one by one without intermediate dialogue.
- Fallback: If
file_patherrors occur, switch to interactive one-by-one mode.
3. Robust File Editing Protocol
3.1 Read-Modify-Read Cycle (Mandatory)
- Pre-Read: Read the file to confirm context (silently).
- Modify: Execute
EditorMultiEdit. - Post-Read: Read the file again to verify the change (silently).
3.2 Escalation Path for Edit Failures
If Edit fails with "String to replace not found":
- Silent Grep:
Grepfor thenew_stringto see if it's already there.- Found: Abort, report success.
- Scrutiny: Re-examine
old_stringfor whitespace/indentation mismatches. Retry once. - MultiEdit Degradation: Degrade
MultiEditto singleEditcalls. - RMWR (Last Resort): Request permission to use Read-Modify-Write-Read (overwrite entire file).
