Add plugin helper with agent skill for updating plugins
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from .fsutil import sha256_file
|
||||
|
||||
|
||||
SCAN_DIRS = ("Plugins", "Libs", "IPA/Pending")
|
||||
|
||||
|
||||
def scan_instance(instance_path: Path, include_hashes: bool = False) -> dict[str, Any]:
|
||||
files: list[dict[str, Any]] = []
|
||||
for dirname in SCAN_DIRS:
|
||||
root = instance_path / dirname
|
||||
if not root.exists():
|
||||
continue
|
||||
for path in sorted(item for item in root.rglob("*") if item.is_file()):
|
||||
rel = path.relative_to(instance_path).as_posix()
|
||||
entry: dict[str, Any] = {"path": rel, "size": path.stat().st_size}
|
||||
if include_hashes:
|
||||
entry["sha256"] = sha256_file(path)
|
||||
files.append(entry)
|
||||
return {
|
||||
"instancePath": str(instance_path),
|
||||
"files": files,
|
||||
"counts": {
|
||||
"files": len(files),
|
||||
"plugins": sum(1 for item in files if item["path"].startswith("Plugins/")),
|
||||
"libs": sum(1 for item in files if item["path"].startswith("Libs/")),
|
||||
"pending": sum(1 for item in files if item["path"].startswith("IPA/Pending/")),
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user