mirror of
https://github.com/shareAI-lab/analysis_claude_code.git
synced 2026-09-20 12:13:38 +08:00
fix: use UTF-8 for text file operations
This commit is contained in:
@@ -41,7 +41,7 @@ def safe_path(p: str) -> Path:
|
||||
return path
|
||||
|
||||
def run_read(path: str, limit: int = None) -> str:
|
||||
text = safe_path(path).read_text()
|
||||
text = safe_path(path).read_text(encoding="utf-8")
|
||||
lines = text.splitlines()
|
||||
if limit and limit < len(lines):
|
||||
lines = lines[:limit]
|
||||
|
||||
@@ -52,7 +52,7 @@ class SkillLoader:
|
||||
def __init__(self, skills_dir: Path):
|
||||
self.skills = {}
|
||||
for f in sorted(skills_dir.rglob("SKILL.md")):
|
||||
text = f.read_text()
|
||||
text = f.read_text(encoding="utf-8")
|
||||
meta, body = self._parse_frontmatter(text)
|
||||
name = meta.get("name", f.parent.name)
|
||||
self.skills[name] = {"meta": meta, "body": body}
|
||||
|
||||
@@ -71,7 +71,7 @@ class TaskManager:
|
||||
```python
|
||||
def _clear_dependency(self, completed_id):
|
||||
for f in self.dir.glob("task_*.json"):
|
||||
task = json.loads(f.read_text())
|
||||
task = json.loads(f.read_text(encoding="utf-8"))
|
||||
if completed_id in task.get("blockedBy", []):
|
||||
task["blockedBy"].remove(completed_id)
|
||||
self._save(task)
|
||||
|
||||
@@ -78,8 +78,8 @@ class MessageBus:
|
||||
def read_inbox(self, name):
|
||||
path = self.dir / f"{name}.jsonl"
|
||||
if not path.exists(): return "[]"
|
||||
msgs = [json.loads(l) for l in path.read_text().strip().splitlines() if l]
|
||||
path.write_text("") # drain
|
||||
msgs = [json.loads(l) for l in path.read_text(encoding="utf-8").strip().splitlines() if l]
|
||||
path.write_text("", encoding="utf-8") # drain
|
||||
return json.dumps(msgs, indent=2)
|
||||
```
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ def _idle_poll(self, name, messages):
|
||||
def scan_unclaimed_tasks() -> list:
|
||||
unclaimed = []
|
||||
for f in sorted(TASKS_DIR.glob("task_*.json")):
|
||||
task = json.loads(f.read_text())
|
||||
task = json.loads(f.read_text(encoding="utf-8"))
|
||||
if (task.get("status") == "pending"
|
||||
and not task.get("owner")
|
||||
and not task.get("blockedBy")):
|
||||
|
||||
Reference in New Issue
Block a user