refactor: move get_config from file_ops.py to text_editor.py to keep file_ops pure

linuztx committed Feb 27, 2026 at 10:36 UTC 2827b57b8692eab8a108bf709dc093ae0c46ffb2
2 files changed +16 -21
plugins/text_editor/helpers/file_ops.py
+1 -18
@@ -8,29 +8,12 @@ import os
8 import shutil
9 import tempfile
10 from dataclasses import dataclass
11 -from typing import TYPE_CHECKING
11
13 -from python.helpers import plugins, tokens
14 -
15 -if TYPE_CHECKING:
16 - from agent import Agent
12 +from python.helpers import tokens
13
14 _BINARY_PEEK = 8192
15
16
21 -# ------------------------------------------------------------------
22 -# Config
23 -# ------------------------------------------------------------------
24 -
25 -def get_config(agent: "Agent") -> dict:
26 - config = plugins.get_plugin_config("text_editor", agent=agent) or {}
27 - return {
28 - "max_line_tokens": int(config.get("max_line_tokens", 500)),
29 - "default_line_count": int(config.get("default_line_count", 100)),
30 - "max_total_read_tokens": int(config.get("max_total_read_tokens", 4000)),
31 - }
32 -
33 -
17 # ------------------------------------------------------------------
18 # Binary detection
19 # ------------------------------------------------------------------
plugins/text_editor/tools/text_editor.py
+15 -3
@@ -2,8 +2,8 @@ import os
2
3 from python.helpers.tool import Tool, Response
4 from python.helpers.extension import call_extensions
5 +from python.helpers import plugins
6 from plugins.text_editor.helpers.file_ops import (
6 - get_config,
7 read_file,
8 write_file,
9 validate_edits,
@@ -32,7 +32,7 @@ class TextEditor(Tool):
32 if not path:
33 return self._error("read", path, "path is required")
34
35 - cfg = get_config(self.agent)
35 + cfg = _get_config(self.agent)
36 line_from = int(kwargs.get("line_from", 1))
37 raw_to = kwargs.get("line_to")
38 line_to = int(raw_to) if raw_to is not None else None
@@ -143,4 +143,16 @@ class TextEditor(Tool):
143 f"fw.text_editor.{action}_error.md", path=path, error=error
144 )
145 return Response(message=msg, break_loop=False)
146 -
\ No newline at end of file
146 +
147 +# ------------------------------------------------------------------
148 +# Config
149 +# ------------------------------------------------------------------
150 +
151 +def _get_config(agent) -> dict:
152 + config = plugins.get_plugin_config("text_editor", agent=agent) or {}
153 + return {
154 + "max_line_tokens": int(config.get("max_line_tokens", 500)),
155 + "default_line_count": int(config.get("default_line_count", 100)),
156 + "max_total_read_tokens": int(config.get("max_total_read_tokens", 4000)),
157 + }
158 +
\ No newline at end of file