INNER CODE UNIT · Python
_classify_path
AgentSkillOS/SkillAnything · scripts/analyze_target.py:83
def _classify_path(path: str, verbose: bool = False) -> str:
"""Read a local file/dir and guess its category."""
p = Path(path)
if p.is_dir():
return "library"
try:
text = p.read_text(errors="replace")[:32_000]
except OSError:
return "unknown"
if any(kw in text.lower() for kw in ["openapi", "swagger", "operationid"]):
return "api"
if any(kw in text.lower() for kw in ["import ", "def ", "class ", "function "]):
return "library"
if any(kw in text.lower() for kw in ["step ", "workflow", "pipeline", "stage"]):
return "workflow"
return "file"