"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/
Python
fix: extract_system_package returns wrong command for apt-get matches
sjhddh59f13c7a8314
diff --git a/cli-anything-plugin/skill_generator.py b/cli-anything-plugin/skill_generator.pyindex ecf14c089..e4477d28e 100644--- a/cli-anything-plugin/skill_generator.py+++ b/cli-anything-plugin/skill_generator.py@@ -159,14 +159,16 @@ def extract_system_package(content: str) -> Optional[str]:patterns = [r"`apt install ([\w\-]+)`",r"`brew install ([\w\-]+)`",- r"apt-get install ([\w\-]+)",+ r"`apt-get install ([\w\-]+)`",]for pattern in patterns:match = re.search(pattern, content)if match:package = match.group(1)- if "apt" in pattern:+ if "apt-get" in pattern:+ return f"apt-get install {package}"+ elif "apt" in pattern:return f"apt install {package}"elif "brew" in pattern:return f"brew install {package}"diff --git a/cli-anything-plugin/tests/test_skill_generator.py b/cli-anything-plugin/tests/test_skill_generator.pyindex dec23e868..e43475fd7 100644--- a/cli-anything-plugin/tests/test_skill_generator.py+++ b/cli-anything-plugin/tests/test_skill_generator.py@@ -30,6 +30,7 @@ from skill_generator import (generate_skill_md_simple,generate_skill_file,extract_intro_from_readme,+ extract_system_package,extract_version_from_setup,SkillMetadata,CommandInfo,@@ -206,6 +207,35 @@ class TestExtractIntroFromReadme:assert "Line two" in intro++# ─── extract_system_package Tests ─────────────────────+++class TestExtractSystemPackage:+ def test_apt_install(self):+ content = "Install with `apt install mytool`."+ result = extract_system_package(content)+ assert result == "apt install mytool"++ def test_brew_install(self):+ content = "Install with `brew install mytool`."+ result = extract_system_package(content)+ assert result == "brew install mytool"++ def test_apt_get_install_returns_apt_get_command(self):+ # Regression: apt-get pattern contains "apt" as a substring, so the+ # condition must check "apt-get" before "apt" to avoid returning the+ # wrong command ("apt install" instead of "apt-get install").+ content = "Install with `apt-get install mytool`."+ result = extract_system_package(content)+ assert result == "apt-get install mytool", (+ f"Expected 'apt-get install mytool', got {result!r}"+ )++ def test_returns_none_when_no_match(self):+ content = "No installation instructions here."+ assert extract_system_package(content) is None+# ─── generate_skill_md Tests ───────────────────────────────────────────diff --git a/mubu/agent-harness/skill_generator.py b/mubu/agent-harness/skill_generator.pyindex 3e1a62749..be778ee28 100644--- a/mubu/agent-harness/skill_generator.py+++ b/mubu/agent-harness/skill_generator.py@@ -76,13 +76,15 @@ def extract_system_package(content: str) -> Optional[str]:patterns = [r"`apt install ([\w\-]+)`",r"`brew install ([\w\-]+)`",- r"apt-get install ([\w\-]+)",+ r"`apt-get install ([\w\-]+)`",]for pattern in patterns:match = re.search(pattern, content)if match:package = match.group(1)+ if "apt-get" in pattern:+ return f"apt-get install {package}"if "apt" in pattern:return f"apt install {package}"if "brew" in pattern: