spark: add hermes environment validator script
This commit is contained in:
1 parent
039246958f
commit
5b33e436f7
2 files changed
+132
No files matched your search
@@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Hermes Environment Validator - validates key paths and directory structure."""
|
||||
|
||||
import os
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
def validate_hermes_environment():
|
||||
"""Validate Hermes Agent environment structure."""
|
||||
|
||||
hermes_root = Path("/root/.hermes")
|
||||
results = {
|
||||
"hermes_root": {
|
||||
"path": str(hermes_root),
|
||||
"exists": hermes_root.exists(),
|
||||
"is_dir": hermes_root.is_dir() if hermes_root.exists() else False
|
||||
},
|
||||
"required_paths": [],
|
||||
"scratch_dir": None,
|
||||
"profile_paths": {}
|
||||
}
|
||||
|
||||
# Define required paths
|
||||
required_paths = [
|
||||
"profiles/spark", # spark profile
|
||||
"skills", # skills directory
|
||||
"plugins", # plugins directory
|
||||
"cron", # cron directory
|
||||
"memories", # memories directory
|
||||
"cache/scratch" # scratch (TMPDIR)
|
||||
]
|
||||
|
||||
for rel_path in required_paths:
|
||||
full_path = hermes_root / rel_path
|
||||
results["required_paths"].append({
|
||||
"path": rel_path,
|
||||
"full_path": str(full_path),
|
||||
"exists": full_path.exists(),
|
||||
"is_dir": full_path.is_dir() if full_path.exists() else False,
|
||||
"item_count": len(list(full_path.iterdir())) if full_path.exists() and full_path.is_dir() else 0
|
||||
})
|
||||
|
||||
# Check scratch directory
|
||||
scratch = hermes_root / "profiles/spark/cache/scratch"
|
||||
results["scratch_dir"] = {
|
||||
"path": str(scratch),
|
||||
"exists": scratch.exists(),
|
||||
"is_dir": scratch.is_dir() if scratch.exists() else False
|
||||
}
|
||||
|
||||
# Check TMPDIR
|
||||
tmpdir = Path(os.environ.get("TMPDIR", "/tmp"))
|
||||
results["tmpdir"] = {
|
||||
"path": str(tmpdir),
|
||||
"exists": tmpdir.exists(),
|
||||
"is_dir": tmpdir.is_dir() if tmpdir.exists() else False
|
||||
}
|
||||
|
||||
# Profile paths
|
||||
profile_root = hermes_root / "profiles"
|
||||
if profile_root.exists():
|
||||
for profile in profile_root.iterdir():
|
||||
if profile.is_dir():
|
||||
results["profile_paths"][profile.name] = {
|
||||
"exists": True,
|
||||
"is_dir": True,
|
||||
"item_count": len(list(profile.iterdir()))
|
||||
}
|
||||
|
||||
# Overall status
|
||||
all_required_exist = all(p["exists"] and p["is_dir"] for p in results["required_paths"])
|
||||
results["valid"] = results["hermes_root"]["is_dir"] and all_required_exist
|
||||
|
||||
return results
|
||||
|
||||
def main():
|
||||
results = validate_hermes_environment()
|
||||
|
||||
# Print JSON output
|
||||
print(json.dumps(results, indent=2))
|
||||
|
||||
# Print summary
|
||||
print("\n--- SUMMARY ---")
|
||||
print(f"Hermes root valid: {results['hermes_root']['is_dir']}")
|
||||
print(f"All required paths exist: {results['valid']}")
|
||||
|
||||
missing = [p for p in results["required_paths"] if not p["exists"]]
|
||||
if missing:
|
||||
print(f"Missing paths: {[p['path'] for p in missing]}")
|
||||
else:
|
||||
print("All required paths present")
|
||||
|
||||
return 0 if results["valid"] else 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit(main())
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Quick verification of Hermes environment paths."""
|
||||
|
||||
import os
|
||||
import json
|
||||
|
||||
# Key paths to verify
|
||||
paths = [
|
||||
"/root/.hermes",
|
||||
"/root/.hermes/profiles/spark",
|
||||
"/root/.hermes/skills",
|
||||
"/root/.hermes/plugins",
|
||||
"/root/.hermes/cron",
|
||||
"/root/.hermes/memories",
|
||||
"/root/.hermes/cache/scratch"
|
||||
]
|
||||
|
||||
results = []
|
||||
all_valid = True
|
||||
|
||||
for path in paths:
|
||||
exists = os.path.isdir(path)
|
||||
results.append({"path": path, "valid": exists})
|
||||
if not exists:
|
||||
all_valid = False
|
||||
|
||||
# Output result
|
||||
output = {
|
||||
"valid": all_valid,
|
||||
"checked_paths": len(paths),
|
||||
"all_present": all_valid,
|
||||
"results": results
|
||||
}
|
||||
|
||||
print(json.dumps(output, indent=2))
|
||||
exit(0 if all_valid else 1)
|
||||
Reference in new issue
Block a user