Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
refactor(tools): remove unused global file state compatibility
chengyongrua4a733d965c6
diff --git a/nanobot/agent/tools/file_state.py b/nanobot/agent/tools/file_state.pyindex bb60a5faa..686ee8b99 100644--- a/nanobot/agent/tools/file_state.py+++ b/nanobot/agent/tools/file_state.py@@ -100,10 +100,6 @@ class FileStates:"""Return the raw ReadState entry for a path, or None."""return self._state.get(str(Path(path).resolve()))- def raw_state(self) -> dict[str, ReadState]:- """Return the mutable backing map for legacy compatibility."""- return self._state-def clear(self) -> None:"""Clear all tracked state (useful for testing)."""self._state.clear()@@ -156,34 +152,3 @@ def bind_file_states(file_states: FileStates) -> Token[FileStates | None]:def reset_file_states(token: Token[FileStates | None]) -> None:_current_file_states.reset(token)---# Module-level default instance, retained for backward compatibility with-# tests and callers that reach in directly. Per-session callers should hold-# their own FileStates instance instead of touching this one.-_default = FileStates()---def record_read(path: str | Path, offset: int = 1, limit: int | None = None) -> None:- _default.record_read(path, offset=offset, limit=limit)---def record_write(path: str | Path) -> None:- _default.record_write(path)---def is_unchanged(path: str | Path, offset: int = 1, limit: int | None = None) -> bool:- return _default.is_unchanged(path, offset=offset, limit=limit)---def clear() -> None:- _default.clear()---# Legacy attribute for callers that reached into the module-level dict-# directly (filesystem.py used to do this). Kept as a property-like accessor-# so existing imports keep working.-def __getattr__(name: str):- if name == "_state":- return _default.raw_state()- raise AttributeError(name)diff --git a/tests/tools/test_edit_advanced.py b/tests/tools/test_edit_advanced.pyindex 08675aa22..26323a3d1 100644--- a/tests/tools/test_edit_advanced.py+++ b/tests/tools/test_edit_advanced.py@@ -12,17 +12,8 @@ import osimport pytest-from nanobot.agent.tools import file_statefrom nanobot.agent.tools.filesystem import EditFileTool, ReadFileTool-[email protected](autouse=True)-def _clear_file_state():- file_state.clear()- yield- file_state.clear()--# ---------------------------------------------------------------------------# Delete-line newline cleanup# ---------------------------------------------------------------------------diff --git a/tests/tools/test_edit_enhancements.py b/tests/tools/test_edit_enhancements.pyindex fbf08b43c..4b2ebcf29 100644--- a/tests/tools/test_edit_enhancements.py+++ b/tests/tools/test_edit_enhancements.py@@ -13,14 +13,6 @@ from nanobot.agent.tools.filesystem import EditFileTool, ReadFileTool# Helpers# ---------------------------------------------------------------------------[email protected](autouse=True)-def _clear_file_state():- """Reset global read-state between tests."""- file_state.clear()- yield- file_state.clear()--# ---------------------------------------------------------------------------# Read-independent editing# ---------------------------------------------------------------------------diff --git a/tests/tools/test_read_enhancements.py b/tests/tools/test_read_enhancements.pyindex 5e3c91bbc..756618c61 100644--- a/tests/tools/test_read_enhancements.py+++ b/tests/tools/test_read_enhancements.py@@ -23,13 +23,6 @@ def _document_source(text: str) -> DocumentLineSource:return DocumentLineSource(lines)[email protected](autouse=True)-def _clear_file_state():- file_state.clear()- yield- file_state.clear()--# ---------------------------------------------------------------------------# Description fix# ---------------------------------------------------------------------------