From 183280ebfcab6a5344dcbd3cda78a2cb5857aa18 Mon Sep 17 00:00:00 2001 From: nonoge <41133441+zhangbububu@users.noreply.github.com> Date: Sun, 26 Jul 2026 08:56:17 +0700 Subject: [PATCH] fix browser extra detection for indentless YAML (#4367) --- backend/tests/test_detect_uv_extras.py | 8 ++++++++ scripts/detect_uv_extras.py | 8 +++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/backend/tests/test_detect_uv_extras.py b/backend/tests/test_detect_uv_extras.py index 3e1ee3c39..0429ea871 100644 --- a/backend/tests/test_detect_uv_extras.py +++ b/backend/tests/test_detect_uv_extras.py @@ -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( diff --git a/scripts/detect_uv_extras.py b/scripts/detect_uv_extras.py index f2bdc230a..deb552008 100755 --- a/scripts/detect_uv_extras.py +++ b/scripts/detect_uv_extras.py @@ -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