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:
@@ -59,7 +59,9 @@ There are four memory types:
|
||||
```python
|
||||
def write_memory_file(name, mem_type, description, body):
|
||||
path = MEMORY_DIR / f"{memory_slug(name)}.md"
|
||||
path.write_text(memory_document(name, mem_type, description, body))
|
||||
path.write_text(
|
||||
memory_document(name, mem_type, description, body), encoding="utf-8"
|
||||
)
|
||||
rebuild_memory_index()
|
||||
return path
|
||||
```
|
||||
@@ -123,7 +125,7 @@ The code parses and validates the new list before replacing old files. It snapsh
|
||||
|
||||
```python
|
||||
snapshot = {
|
||||
path.name: path.read_text()
|
||||
path.name: path.read_text(encoding="utf-8")
|
||||
for path in MEMORY_DIR.glob("*.md")
|
||||
if path.name != MEMORY_INDEX.name
|
||||
}
|
||||
@@ -137,14 +139,14 @@ try:
|
||||
path.write_text(memory_document(
|
||||
record["name"], record["type"],
|
||||
record["description"], record["body"],
|
||||
))
|
||||
), encoding="utf-8")
|
||||
rebuild_memory_index()
|
||||
except Exception:
|
||||
for path in MEMORY_DIR.glob("*.md"):
|
||||
if path.name != MEMORY_INDEX.name:
|
||||
path.unlink()
|
||||
for filename, content in snapshot.items():
|
||||
(MEMORY_DIR / filename).write_text(content)
|
||||
(MEMORY_DIR / filename).write_text(content, encoding="utf-8")
|
||||
rebuild_memory_index()
|
||||
raise
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user