From f9bc52daea212e503d47dbd552db2faf0894bed0 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 9 Aug 2024 16:22:33 -0300 Subject: [PATCH] feat: add read-only files to the tokens report --- aider/commands.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/aider/commands.py b/aider/commands.py index e01b88b5b..de1ca23df 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -329,6 +329,16 @@ class Commands: tokens = self.coder.main_model.token_count(content) res.append((tokens, f"{relative_fname}", "use /drop to drop from chat")) + # read-only files + for fname in self.coder.abs_read_only_fnames: + relative_fname = self.coder.get_rel_fname(fname) + content = self.io.read_text(fname) + if content is not None and not is_image_file(relative_fname): + # approximate + content = f"{relative_fname}\n```\n" + content + "```\n" + tokens = self.coder.main_model.token_count(content) + res.append((tokens, f"{relative_fname} (read-only)", "")) + self.io.tool_output( f"Approximate context window usage for {self.coder.main_model.name}, in tokens:" )