fix browser extra detection for indentless YAML (#4367)

This commit is contained in:
nonoge 2026-07-26 08:56:17 +07:00 committed by GitHub
parent b5cc3a81c3
commit 183280ebfc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 3 deletions

View File

@ -157,6 +157,14 @@ def test_detect_from_config_browser_via_browser_navigate_tool(tmp_path):
assert detect.detect_from_config(cfg) == ["browser"]
def test_detect_from_config_browser_via_indentless_tools_list(tmp_path):
cfg = tmp_path / "config.yaml"
cfg.write_text(
"tools:\n- name: web_fetch\n group: web\n- name: browser_navigate\n group: browser\n",
)
assert detect.detect_from_config(cfg) == ["browser"]
def test_detect_from_config_ignores_commented_browser_tool(tmp_path):
cfg = tmp_path / "config.yaml"
cfg.write_text(

View File

@ -237,14 +237,16 @@ def tools_include_name(lines: list[str], tool_name: str) -> bool:
continue
if not inside:
continue
name_match = _LIST_ITEM_NAME_RE.match(line)
if name_match:
if _unquote(name_match.group(1).strip()) == tool_name:
return True
continue
stripped = line.lstrip()
indent = len(line) - len(stripped)
if indent == 0:
inside = False
continue
name_match = _LIST_ITEM_NAME_RE.match(line)
if name_match and _unquote(name_match.group(1).strip()) == tool_name:
return True
return False