Skip to content

The agent that grows with you

refactor(tools): discovery scan sees loop-registered tools; fix lint module import

Teknium3f5564d7279e
diff --git a/tools/file_operations_lint.py b/tools/file_operations_lint.py
index feb58b45126..c8da5a4bd56 100644
--- a/tools/file_operations_lint.py
+++ b/tools/file_operations_lint.py
@@ -11,7 +11,7 @@ import os
import tomllib
from typing import Callable, Dict, Optional
-from tools.file_operations_types import LintResult
+from tools.file_operations_common import LintResult
# Shell linters by extension, run via _exec() for languages whose check needs an
# external toolchain. ``.tsx`` is deliberately absent: it has never had a shell
diff --git a/tools/registry.py b/tools/registry.py
index 921f1886671..7c20959fb89 100644
--- a/tools/registry.py
+++ b/tools/registry.py
@@ -105,7 +105,14 @@ def _module_registers_tools(module_path: Path) -> bool:
except SyntaxError:
return False
- return any(_is_registry_register_call(stmt) for stmt in tree.body)
+ # Module-level ``for`` loops count too: table-driven modules register
+ # several tools from one loop, which still runs at import time.
+ for stmt in tree.body:
+ if _is_registry_register_call(stmt):
+ return True
+ if isinstance(stmt, ast.For) and any(_is_registry_register_call(s) for s in stmt.body):
+ return True
+ return False
def discover_builtin_tools(tools_dir: Optional[Path] = None) -> List[str]: