1
0

feat: Introduce a /reset command to clear the chat session and token tracking, and update documentation.

This commit is contained in:
2026-03-04 22:24:05 +01:00
parent d7a94436d1
commit ed897aeb01
9 changed files with 777 additions and 387 deletions

View File

@@ -14,7 +14,13 @@ internal static class FileTools
{
public static Action<string> Log { get; set; } = Console.WriteLine;
[Description("Read a file. Max 200 lines per call. Returns lines with line:hash| anchors.")]
/// <summary>
/// Optional callback invoked after each successful ReadFile call, with the resolved path.
/// Set by ReplLoop to trigger deduplication compaction while the tool loop is still active.
/// </summary>
public static Action<string>? OnFileRead { get; set; }
[Description("Read a file. Max 200 lines per call. Returns lines with line:hash| anchors. IMPORTANT: Call GrepFile first (pattern: 'public|class|func|interface|enum|def') to get a structural outline and target startLine/endLine before calling this.")]
public static string ReadFile(
[Description("Path to the file.")] string path,
[Description("First line to return (inclusive). Defaults to 1.")] int startLine = 1,
@@ -40,7 +46,9 @@ internal static class FileTools
return $"ERROR: File too large to read at once ({lines.Length} lines). Provide startLine and endLine to read a chunk of max 200 lines. Use GrepFile to get an outline (grep 'public') and find the line numbers.";
}
return HashlineEncoder.Encode(lines, startLine, endLine);
string result = HashlineEncoder.Encode(lines, startLine, endLine);
OnFileRead?.Invoke(path);
return result;
}
catch (Exception ex)
{