Skip to content

Commit 9860b6f

Browse files
refactor(goal): code analysis engine
changes: - file: disk_analyzer.py area: analyzer modified: [__init__, suggest_cleanup_actions, _identify_cache_type, DiskAnalyzer] - file: cleanup_planner.py area: core modified: [__init__, CleanupType, CleanupPlanner, _get_category_for_action, _dict_to_action] stats: lines: "+64/-734 (net -670)" files: 10 complexity: "Large structural change (normalized)"
1 parent 1f1cc8d commit 9860b6f

14 files changed

Lines changed: 90 additions & 737 deletions

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
## [2.1.18] - 2026-02-26
2+
3+
### Summary
4+
5+
refactor(goal): code analysis engine
6+
7+
### Test
8+
9+
- update test_click.py
10+
- update test_click2.py
11+
12+
### Other
13+
14+
- update fixos/diagnostics/disk_analyzer.py
15+
- update fixos/interactive/cleanup_planner.py
16+
- update patch_cli.py
17+
- update patch_cli2.py
18+
- update patch_cli3.py
19+
- update patch_cli4.py
20+
- update patch_docs.py
21+
- update patch_parser.py
22+
23+
124
## [2.1.17] - 2026-02-26
225

326
### Summary

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.17
1+
2.1.18

fixos/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""fixos – AI-powered Linux/Windows diagnostics and repair."""
2-
__version__ = "2.1.17"
2+
__version__ = "2.1.18"

fixos/diagnostics/disk_analyzer.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def __init__(self, base_path: str = "/"):
1919
self.base_path = Path(base_path)
2020
self.cache_patterns = [
2121
".cache", "__pycache__", "node_modules", ".npm",
22-
".pip", "cache", "Cache", ".gradle", ".maven", ".cargo"
22+
".pip", "cache", "Cache", ".gradle", ".maven", ".cargo",
23+
"apt", "dnf", "yum", "pacman", "pkg", "docker/overlay2", "docker/image", "Containers"
2324
]
2425
self.log_patterns = [
2526
".log", "logs", "Logs", "*.log", "*.out", "*.err"
@@ -232,11 +233,35 @@ def suggest_cleanup_actions(self, path: Path) -> List[Dict]:
232233
"path": log_dir["path"],
233234
"size_gb": log_dir["size_gb"],
234235
"description": f"Clean old log files",
235-
"command": f"find {log_dir['path']} -name '*.log' -mtime +30 -delete",
236+
"command": f"find {log_dir['path']} -name '*.log' -mtime +30 -delete || rm -rf {log_dir['path']}/*.log",
236237
"safe": True,
237238
"impact": "medium"
238239
})
239240

241+
# Docker and Package Manager specific suggestions
242+
# These are generated regardless if we found them in cache dirs to guarantee they are surfaced
243+
suggestions.append({
244+
"type": "docker_cleanup",
245+
"priority": "high",
246+
"path": "/var/lib/docker",
247+
"size_gb": 0.0, # Will be recalculated by planner
248+
"description": "Clean unused Docker images, containers, and volumes",
249+
"command": "docker system prune -af --volumes",
250+
"safe": False,
251+
"impact": "high"
252+
})
253+
254+
suggestions.append({
255+
"type": "package_cleanup",
256+
"priority": "medium",
257+
"path": "/var/cache",
258+
"size_gb": 0.0, # Will be recalculated
259+
"description": "Clean system package manager cache (apt/dnf/pacman)",
260+
"command": "apt-get clean || dnf clean all || pacman -Scc --noconfirm",
261+
"safe": True,
262+
"impact": "medium"
263+
})
264+
240265
# Temp directory cleanup
241266
for temp_dir in temp_dirs[:3]:
242267
if temp_dir["size_mb"] > 20:
@@ -329,6 +354,10 @@ def _identify_cache_type(self, dir_path: Path) -> str:
329354
return "maven"
330355
elif "cargo" in name:
331356
return "cargo"
357+
elif "docker" in path_str or "containers" in path_str:
358+
return "docker"
359+
elif "apt" in path_str or "dnf" in path_str or "yum" in path_str or "pacman" in path_str:
360+
return "package_manager"
332361
elif "browser" in path_str or "chrome" in path_str or "firefox" in path_str:
333362
return "browser"
334363
else:

fixos/interactive/cleanup_planner.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class CleanupType(Enum):
2424
LARGE_FILE = "large_file"
2525
SYSTEM = "system_cleanup"
2626
USER = "user_cleanup"
27+
DOCKER = "docker_cleanup"
28+
PACKAGE_MGR = "package_cleanup"
2729

2830

2931
@dataclass
@@ -86,6 +88,18 @@ def __init__(self):
8688
"description": "User-specific cleanup actions",
8789
"color": "green",
8890
"icon": "👤"
91+
},
92+
"docker": {
93+
"name": "Docker & Containers",
94+
"description": "Unused images, containers, and volumes",
95+
"color": "cyan",
96+
"icon": "🐳"
97+
},
98+
"package_manager": {
99+
"name": "Package Cache",
100+
"description": "Cached system packages (apt/dnf/pacman)",
101+
"color": "magenta",
102+
"icon": "📦"
89103
}
90104
}
91105

@@ -217,9 +231,22 @@ def interactive_selection(self, plan: Dict[str, Any]) -> Dict[str, Any]:
217231
def _dict_to_action(self, suggestion: Dict) -> CleanupAction:
218232
"""Convert dictionary suggestion to CleanupAction"""
219233
try:
234+
# Need to handle strings if suggestion payload comes in as string not Enum
235+
ctype_val = suggestion.get("type", "large_file")
236+
try:
237+
ctype = CleanupType(ctype_val)
238+
except ValueError:
239+
ctype = CleanupType.LARGE_FILE
240+
241+
prio_val = suggestion.get("priority", "low")
242+
try:
243+
prio = Priority(prio_val)
244+
except ValueError:
245+
prio = Priority.LOW
246+
220247
return CleanupAction(
221-
type=CleanupType(suggestion.get("type", "large_file")),
222-
priority=Priority(suggestion.get("priority", "low")),
248+
type=ctype,
249+
priority=prio,
223250
path=suggestion.get("path", ""),
224251
size_gb=float(suggestion.get("size_gb", 0)),
225252
description=suggestion.get("description", ""),
@@ -269,6 +296,10 @@ def _get_category_for_action(self, action: CleanupAction) -> str:
269296
return "temp"
270297
elif action.type == CleanupType.LARGE_FILE:
271298
return "large_files"
299+
elif action.type.value == "docker_cleanup" or "docker" in action.path.lower():
300+
return "docker"
301+
elif action.type.value == "package_cleanup" or action.path == "/var/cache":
302+
return "package_manager"
272303
elif "system" in action.path.lower() or action.path.startswith("/"):
273304
return "system"
274305
else:

patch_cli.py

Whitespace-only changes.

patch_cli2.py

Lines changed: 0 additions & 84 deletions
This file was deleted.

patch_cli3.py

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)