Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agent/auxiliary_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ def _read_nous_auth() -> Optional[dict]:
try:
if not _AUTH_JSON_PATH.is_file():
return None
data = json.loads(_AUTH_JSON_PATH.read_text())
data = json.loads(_AUTH_JSON_PATH.read_text(encoding="utf-8"))
if data.get("active_provider") != "nous":
return None
provider = data.get("providers", {}).get("nous", {})
Expand Down
4 changes: 2 additions & 2 deletions agent/copilot_acp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ def _handle_server_message(
if block_error:
raise PermissionError(block_error)
try:
content = path.read_text()
content = path.read_text(encoding="utf-8")
except FileNotFoundError:
content = ""
line = params.get("line")
Expand Down Expand Up @@ -659,7 +659,7 @@ def _handle_server_message(
f"Write denied: '{path}' is a protected system/credential file."
)
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(str(params.get("content") or ""))
path.write_text(str(params.get("content") or ""), encoding="utf-8")
response = {
"jsonrpc": "2.0",
"id": message_id,
Expand Down
2 changes: 1 addition & 1 deletion agent/shell_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def allowlist_path() -> Path:
def load_allowlist() -> Dict[str, Any]:
"""Return the parsed allowlist, or an empty skeleton if absent."""
try:
raw = json.loads(allowlist_path().read_text())
raw = json.loads(allowlist_path().read_text(encoding="utf-8"))
except (FileNotFoundError, json.JSONDecodeError, OSError):
return {"approvals": []}
if not isinstance(raw, dict):
Expand Down
2 changes: 1 addition & 1 deletion tools/managed_tool_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _read_nous_provider_state() -> Optional[dict]:
path = auth_json_path()
if not path.is_file():
return None
data = json.loads(path.read_text())
data = json.loads(path.read_text(encoding="utf-8"))
providers = data.get("providers", {})
if not isinstance(providers, dict):
return None
Expand Down
28 changes: 14 additions & 14 deletions tools/skills_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ def _read_cache(self, key: str) -> Optional[list]:
stat = cache_file.stat()
if time.time() - stat.st_mtime > INDEX_CACHE_TTL:
return None
return json.loads(cache_file.read_text())
return json.loads(cache_file.read_text(encoding="utf-8"))
except (OSError, json.JSONDecodeError):
return None

Expand All @@ -930,7 +930,7 @@ def _write_cache(self, key: str, data: list) -> None:
INDEX_CACHE_DIR.mkdir(parents=True, exist_ok=True)
cache_file = INDEX_CACHE_DIR / f"{key}.json"
try:
cache_file.write_text(json.dumps(data, ensure_ascii=False))
cache_file.write_text(json.dumps(data, ensure_ascii=False), encoding="utf-8")
except OSError as e:
logger.debug("Could not write cache: %s", e)

Expand Down Expand Up @@ -3104,7 +3104,7 @@ def _read_index_cache(key: str) -> Optional[Any]:
stat = cache_file.stat()
if time.time() - stat.st_mtime > INDEX_CACHE_TTL:
return None
return json.loads(cache_file.read_text())
return json.loads(cache_file.read_text(encoding="utf-8"))
except (OSError, json.JSONDecodeError):
return None

Expand All @@ -3118,12 +3118,12 @@ def _write_index_cache(key: str, data: Any) -> None:
ignore_file = HUB_DIR / ".ignore"
if not ignore_file.exists():
try:
ignore_file.write_text("# Exclude hub internals from search tools\n*\n")
ignore_file.write_text("# Exclude hub internals from search tools\n*\n", encoding="utf-8")
except OSError:
pass
cache_file = INDEX_CACHE_DIR / f"{key}.json"
try:
cache_file.write_text(json.dumps(data, ensure_ascii=False, default=str))
cache_file.write_text(json.dumps(data, ensure_ascii=False, default=str), encoding="utf-8")
except OSError as e:
logger.debug("Could not write cache: %s", e)

Expand Down Expand Up @@ -3157,13 +3157,13 @@ def load(self) -> dict:
if not self.path.exists():
return {"version": 1, "installed": {}}
try:
return json.loads(self.path.read_text())
return json.loads(self.path.read_text(encoding="utf-8"))
except (json.JSONDecodeError, OSError):
return {"version": 1, "installed": {}}

def save(self, data: dict) -> None:
self.path.parent.mkdir(parents=True, exist_ok=True)
self.path.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n")
self.path.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")

def record_install(
self,
Expand Down Expand Up @@ -3229,14 +3229,14 @@ def load(self) -> List[dict]:
if not self.path.exists():
return []
try:
data = json.loads(self.path.read_text())
data = json.loads(self.path.read_text(encoding="utf-8"))
return data.get("taps", [])
except (json.JSONDecodeError, OSError):
return []

def save(self, taps: List[dict]) -> None:
self.path.parent.mkdir(parents=True, exist_ok=True)
self.path.write_text(json.dumps({"taps": taps}, indent=2) + "\n")
self.path.write_text(json.dumps({"taps": taps}, indent=2) + "\n", encoding="utf-8")

def add(self, repo: str, path: str = "skills/") -> bool:
"""Add a tap. Returns False if already exists."""
Expand Down Expand Up @@ -3290,11 +3290,11 @@ def ensure_hub_dirs() -> None:
QUARANTINE_DIR.mkdir(exist_ok=True)
INDEX_CACHE_DIR.mkdir(exist_ok=True)
if not LOCK_FILE.exists():
LOCK_FILE.write_text('{"version": 1, "installed": {}}\n')
LOCK_FILE.write_text('{"version": 1, "installed": {}}\n', encoding="utf-8")
if not AUDIT_LOG.exists():
AUDIT_LOG.touch()
if not TAPS_FILE.exists():
TAPS_FILE.write_text('{"taps": []}\n')
TAPS_FILE.write_text('{"taps": []}\n', encoding="utf-8")


def quarantine_bundle(bundle: SkillBundle) -> Path:
Expand Down Expand Up @@ -3538,7 +3538,7 @@ def _load_hermes_index() -> Optional[dict]:
try:
age = time.time() - HERMES_INDEX_CACHE_FILE.stat().st_mtime
if age < HERMES_INDEX_TTL:
return json.loads(HERMES_INDEX_CACHE_FILE.read_text())
return json.loads(HERMES_INDEX_CACHE_FILE.read_text(encoding="utf-8"))
except (OSError, json.JSONDecodeError):
pass

Expand All @@ -3560,7 +3560,7 @@ def _load_hermes_index() -> Optional[dict]:
# Cache locally
try:
HERMES_INDEX_CACHE_FILE.parent.mkdir(parents=True, exist_ok=True)
HERMES_INDEX_CACHE_FILE.write_text(json.dumps(data))
HERMES_INDEX_CACHE_FILE.write_text(json.dumps(data), encoding="utf-8")
except OSError:
pass

Expand All @@ -3571,7 +3571,7 @@ def _load_stale_index_cache() -> Optional[dict]:
"""Fall back to stale cache when the network fetch fails."""
if HERMES_INDEX_CACHE_FILE.exists():
try:
return json.loads(HERMES_INDEX_CACHE_FILE.read_text())
return json.loads(HERMES_INDEX_CACHE_FILE.read_text(encoding="utf-8"))
except (OSError, json.JSONDecodeError):
pass
return None
Expand Down
2 changes: 1 addition & 1 deletion tools/skills_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def _backfill_optional_provenance(quiet: bool = False) -> List[str]:

lock_path = SKILLS_DIR / ".hub" / "lock.json"
try:
data = json.loads(lock_path.read_text()) if lock_path.exists() else {"version": 1, "installed": {}}
data = json.loads(lock_path.read_text(encoding="utf-8")) if lock_path.exists() else {"version": 1, "installed": {}}
except (json.JSONDecodeError, OSError):
data = {"version": 1, "installed": {}}
installed = data.setdefault("installed", {})
Expand Down
2 changes: 1 addition & 1 deletion tools/xai_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def has_xai_credentials() -> bool:
auth_path = get_hermes_home() / "auth.json"
if not auth_path.exists():
return False
store = json.loads(auth_path.read_text())
store = json.loads(auth_path.read_text(encoding="utf-8"))
providers = store.get("providers") if isinstance(store, dict) else None
xai_state = providers.get("xai-oauth") if isinstance(providers, dict) else None
tokens = xai_state.get("tokens") if isinstance(xai_state, dict) else None
Expand Down