Compare commits
112 Commits
56bea3d587
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 88c89ab9c1 | |||
| 095f02fc59 | |||
| 12e7133e34 | |||
| 90bba40c75 | |||
| f13e73b733 | |||
| 4ca7c2da6c | |||
| d7cbf7833f | |||
| 00c1f5c2b1 | |||
| 5d2c5e3a58 | |||
| 229f8fd222 | |||
| 262cceab4a | |||
| b76fc91cbf | |||
| 476513c334 | |||
| 14f4153d71 | |||
| 67e1905fc6 | |||
| c305721d62 | |||
| 8575dad70d | |||
| 72cc0c4c06 | |||
| 9ecb422ba1 | |||
| 11af66f34c | |||
| 7e83e83e33 | |||
| 5fbf8c1be2 | |||
| 33285c4f6f | |||
| a084858863 | |||
| 2a196dd576 | |||
| 2a98835f2f | |||
| d06c265003 | |||
| 5fd8081646 | |||
| 5adbf31d09 | |||
| 56bc2a53f7 | |||
| c58befd27a | |||
| c4865d3e62 | |||
| 394d149954 | |||
| ddbfe5a321 | |||
| 67e1c19dee | |||
| 7d368e52c2 | |||
| 76fa3117ca | |||
| e1399098f0 | |||
| e93a8c3bef | |||
| a842f38cc2 | |||
| a5c9c8d687 | |||
| 16aaa54d4f | |||
| 3211c9b953 | |||
| 87955f80e0 | |||
| d6759f9fd7 | |||
| 2e3d83cbab | |||
| fe76773cb5 | |||
| 9298ebf965 | |||
| 50000c0dc0 | |||
| e03ac06f03 | |||
| d95b580e5f | |||
| 3615ca15bc | |||
| 0f173943ee | |||
| 5428ccc4c2 | |||
| d2f91e941c | |||
| e0345a68fc | |||
| 6fa45102ca | |||
| 1dddeb3318 | |||
| b994fb85b8 | |||
| 148bec815b | |||
| 64b344b64c | |||
| 59c6dd974b | |||
| 58841a133b | |||
| 55156989c8 | |||
| 73a14eacb4 | |||
| 27050cd06c | |||
| d5a8d954a1 | |||
| b521283903 | |||
| 3caff4fa9f | |||
| 5420ee1cb7 | |||
| 3a291d78af | |||
| 9842015eaf | |||
| 5e0603c079 | |||
| efb2a4a1aa | |||
| 374ea026e8 | |||
| 09286f5abd | |||
| a8390dc49c | |||
| 5ef6acf77e | |||
| 7660209de8 | |||
| 3df2174a4a | |||
| d079e0eb5f | |||
| 70ebc57990 | |||
| 60e9188e53 | |||
| 649985db97 | |||
| 65fdd51495 | |||
| 5d0d72cbc4 | |||
| 7805305100 | |||
| 2a4cfcaee3 | |||
| 35e534e126 | |||
| b64bbad44a | |||
| 6c11196996 | |||
| fcfb6af1eb | |||
| c8ea5a5aa5 | |||
| 0d46d4a900 | |||
| 1a34b59f42 | |||
| 5d6d6f32d7 | |||
| 5cec3fd321 | |||
| 47c609c886 | |||
| 781526de56 | |||
| 1c36b771ff | |||
| 3dd382198d | |||
| b46bc8ef6a | |||
| f888bae907 | |||
| da764ab901 | |||
| 0a8e6b5ac9 | |||
| e89a6618d4 | |||
| ad9b6b7d98 | |||
| 5ab10d466d | |||
| dc2e9fcbb6 | |||
| 251f7480c3 | |||
| 738bd5b762 | |||
| 2dce9223e0 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@ __pycache__/
|
|||||||
*.db-shm
|
*.db-shm
|
||||||
*.db-journal
|
*.db-journal
|
||||||
!state_*.db
|
!state_*.db
|
||||||
|
state_merged.db
|
||||||
|
|||||||
@@ -27,3 +27,32 @@ RackNerd VPS (New Year Special):
|
|||||||
- Root Password: Zg58Mb73C4ueHFYhq3
|
- Root Password: Zg58Mb73C4ueHFYhq3
|
||||||
- 已安装 hermes agent
|
- 已安装 hermes agent
|
||||||
- 问题: Telegram 对话失联无响应
|
- 问题: Telegram 对话失联无响应
|
||||||
|
§
|
||||||
|
## Hermes Sync 架构 (2026-04-14 建成)
|
||||||
|
|
||||||
|
Gitea: https://d.momix.cc/Mixer/hermes-sync
|
||||||
|
|
||||||
|
三台机器:
|
||||||
|
- 本地 Linux (10-40-29-186): ~/.hermes-sync (symlink to ~/hermes-sync-tmp), ~/.hermes
|
||||||
|
- VPS RackNerd (soe219028): ~/.hermes-sync, ~/.hermes
|
||||||
|
- MacOS (MixdeMac-mini.local): /Users/moore/.hermes-sync, /Users/moore/.hermes
|
||||||
|
|
||||||
|
同步内容:memories/MEMORY.md, skills/, state.db(每机器一个 state_<hostname>.db)
|
||||||
|
不同步:config.yaml, .env, auth.json 等配置
|
||||||
|
|
||||||
|
sync.sh 已稳定:217行,无checkpoint,直接copy到temp dir再处理,避免SQLite WAL锁冲突
|
||||||
|
cron: 每2小时,VPS和MacOS用绝对路径 /Users/moore/.hermes-sync/sync.sh
|
||||||
|
本地: 软链 ~/hermes-sync-tmp -> ~/hermes-sync
|
||||||
|
|
||||||
|
MacOS hostname: MixdeMac-mini.local
|
||||||
|
|
||||||
|
## macOS Hermes 路径
|
||||||
|
- 数据目录: /Users/moore/.hermes/state.db
|
||||||
|
- Hermes CLI: /Users/moore/.local/bin/hermes
|
||||||
|
- 无systemd,用cron管理后台进程
|
||||||
|
|
||||||
|
## SQLite 多机同步关键经验
|
||||||
|
- WAL模式的db不能直接copy,会损坏。用temp dir中转。
|
||||||
|
- 不能对WAL模式的db做checkpoint(会造成malformed image),直接shutil.copy2即可,WAL会在下次连接时自动attach。
|
||||||
|
- merge时sessions用INSERT OR REPLACE(去重),messages用INSERT OR IGNORE(避免重复插入)
|
||||||
|
- 列数用PRAGMA table_info动态获取,不硬编码
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
167
sync.sh
167
sync.sh
@@ -1,4 +1,17 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# ── Step 0.5: Clean stale temp directories from previous runs ────────────
|
||||||
|
python3 << 'CLEANUP'
|
||||||
|
import shutil, glob, os
|
||||||
|
for prefix in ['hs_merge_', 'hs_exp_', 'hs_rest_']:
|
||||||
|
for d in glob.glob(os.path.join('/tmp', prefix + '*')):
|
||||||
|
try:
|
||||||
|
shutil.rmtree(d)
|
||||||
|
print(f'Cleaned: {d}')
|
||||||
|
except Exception as e:
|
||||||
|
print(f'Failed to clean {d}: {e}')
|
||||||
|
CLEANUP
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
SYNC_DIR="${SYNC_DIR:-$HOME/.hermes-sync}"
|
SYNC_DIR="${SYNC_DIR:-$HOME/.hermes-sync}"
|
||||||
@@ -8,25 +21,51 @@ cd "$SYNC_DIR"
|
|||||||
|
|
||||||
echo "[$(date '+%H:%M:%S')] Sync from $HOSTNAME..."
|
echo "[$(date '+%H:%M:%S')] Sync from $HOSTNAME..."
|
||||||
|
|
||||||
# ── Step 1: Export local state.db (via temp dir to avoid lock) ────────────
|
# ── Step 0: Clean local state_merged.db to avoid git pull conflicts ──────
|
||||||
python3 << PYEOF
|
# The merged db is produced by this script, not tracked, and can conflict
|
||||||
|
# with remote when pulling. Remove it before fetch+merge.
|
||||||
|
rm -f "$SYNC_DIR/state_merged.db"
|
||||||
|
|
||||||
|
# ── Step 1: Export local state.db (via temp dir to avoid lock & WAL issues) ─
|
||||||
|
python3 << 'PYEOF'
|
||||||
import sqlite3, os, shutil, tempfile
|
import sqlite3, os, shutil, tempfile
|
||||||
|
|
||||||
local_db = os.path.join(os.path.expanduser('~/.hermes'), 'state.db')
|
local_db = os.path.join(os.path.expanduser('~/.hermes'), 'state.db')
|
||||||
export_db = os.path.join(os.path.expanduser('~/.hermes-sync'), f"state_{os.environ.get('HOSTNAME') or __import__('socket').gethostname()}.db")
|
export_db = os.path.join(os.path.expanduser('~/.hermes-sync'), f"state_{os.environ.get('HOSTNAME') or __import__('socket').gethostname()}.db")
|
||||||
|
hostname = os.environ.get('HOSTNAME') or __import__('socket').gethostname()
|
||||||
tmpdir = tempfile.mkdtemp(prefix='hs_exp_')
|
tmpdir = tempfile.mkdtemp(prefix='hs_exp_')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tmp_db = os.path.join(tmpdir, 'db')
|
# Step 1a: Open with WAL mode and checkpoint (forces WAL -> main db)
|
||||||
shutil.copy2(local_db, tmp_db)
|
conn = sqlite3.connect(f'file:{local_db}?mode=ro', uri=True)
|
||||||
|
jm = conn.execute('PRAGMA journal_mode').fetchone()[0]
|
||||||
|
|
||||||
test = sqlite3.connect(tmp_db)
|
if jm == 'wal':
|
||||||
|
# WAL mode: checkpoint first to flush WAL into main db
|
||||||
|
conn.execute('PRAGMA wal_checkpoint(TRUNCATE)')
|
||||||
|
print(f'WAL checkpointed ({jm})')
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
# Step 1b: Copy all three files (db + -wal + -shm) if they exist
|
||||||
|
tmp_db = os.path.join(tmpdir, 'db')
|
||||||
|
for suffix in ['', '-wal', '-shm']:
|
||||||
|
src = local_db + suffix
|
||||||
|
if os.path.exists(src):
|
||||||
|
shutil.copy2(src, tmp_db + suffix)
|
||||||
|
|
||||||
|
# Step 1c: Verify (open read-only to confirm it's not corrupted)
|
||||||
|
test = sqlite3.connect(f'file:{tmp_db}?mode=ro', uri=True)
|
||||||
r = test.execute('SELECT COUNT(*) FROM sessions').fetchone()[0]
|
r = test.execute('SELECT COUNT(*) FROM sessions').fetchone()[0]
|
||||||
m = test.execute('SELECT COUNT(*) FROM messages').fetchone()[0]
|
m = test.execute('SELECT COUNT(*) FROM messages').fetchone()[0]
|
||||||
test.close()
|
test.close()
|
||||||
|
|
||||||
shutil.copy2(tmp_db, export_db)
|
shutil.copy2(tmp_db, export_db)
|
||||||
print(f'Exported: {r}s/{m}m')
|
if os.path.exists(tmp_db + '-wal'):
|
||||||
|
shutil.copy2(tmp_db + '-wal', export_db + '-wal')
|
||||||
|
if os.path.exists(tmp_db + '-shm'):
|
||||||
|
shutil.copy2(tmp_db + '-shm', export_db + '-shm')
|
||||||
|
|
||||||
|
print(f'Exported: {r}s/{m}m (journal={jm})')
|
||||||
finally:
|
finally:
|
||||||
shutil.rmtree(tmpdir, ignore_errors=True)
|
shutil.rmtree(tmpdir, ignore_errors=True)
|
||||||
PYEOF
|
PYEOF
|
||||||
@@ -80,53 +119,54 @@ tmpdir = tempfile.mkdtemp(prefix='hs_merge_')
|
|||||||
tmp_merged = os.path.join(tmpdir, 'merged.db')
|
tmp_merged = os.path.join(tmpdir, 'merged.db')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Create merged DB with proper schema
|
# Create merged DB (DELETE journal avoids WAL complications during merge)
|
||||||
conn = sqlite3.connect(tmp_merged)
|
conn = sqlite3.connect(tmp_merged)
|
||||||
conn.execute('PRAGMA journal_mode=DELETE')
|
conn.execute('PRAGMA journal_mode=DELETE')
|
||||||
conn.execute('PRAGMA locking_mode=NORMAL')
|
conn.execute('PRAGMA locking_mode=NORMAL')
|
||||||
conn.execute('PRAGMA synchronous=FULL')
|
conn.execute('PRAGMA synchronous=FULL')
|
||||||
|
|
||||||
conn.execute('''
|
# Use one reference DB to get exact schema (handles FTS, etc.)
|
||||||
CREATE TABLE sessions (
|
ref_db = db_files[0]
|
||||||
id TEXT PRIMARY KEY, source TEXT NOT NULL, user_id TEXT,
|
ref_copy = os.path.join(tmpdir, 'ref.db')
|
||||||
model TEXT, model_config TEXT, system_prompt TEXT,
|
shutil.copy2(ref_db, ref_copy)
|
||||||
parent_session_id TEXT, started_at REAL, ended_at REAL,
|
if os.path.exists(ref_db + '-wal'):
|
||||||
end_reason TEXT, message_count INTEGER DEFAULT 0,
|
shutil.copy2(ref_db + '-wal', ref_copy + '-wal')
|
||||||
tool_call_count INTEGER DEFAULT 0, input_tokens INTEGER DEFAULT 0,
|
if os.path.exists(ref_db + '-shm'):
|
||||||
output_tokens INTEGER DEFAULT 0, cache_read_tokens INTEGER DEFAULT 0,
|
shutil.copy2(ref_db + '-shm', ref_copy + '-shm')
|
||||||
cache_write_tokens INTEGER DEFAULT 0, reasoning_tokens INTEGER DEFAULT 0,
|
|
||||||
billing_provider TEXT, billing_base_url TEXT, billing_mode TEXT,
|
|
||||||
estimated_cost_usd REAL, actual_cost_usd REAL,
|
|
||||||
cost_status TEXT, cost_source TEXT, pricing_version TEXT, title TEXT
|
|
||||||
)''')
|
|
||||||
|
|
||||||
conn.execute('''
|
ref = sqlite3.connect(f'file:{ref_copy}?mode=ro', uri=True)
|
||||||
CREATE TABLE messages (
|
for line in ref.iterdump():
|
||||||
id INTEGER PRIMARY KEY,
|
# Skip FTS virtual table data rows (they are derived, not real data)
|
||||||
session_id TEXT NOT NULL, role TEXT NOT NULL, content TEXT,
|
if line.startswith('INSERT INTO messages_fts') or \
|
||||||
tool_call_id TEXT, tool_calls TEXT, tool_name TEXT,
|
line.startswith('DELETE FROM messages_fts'):
|
||||||
timestamp REAL NOT NULL, token_count INTEGER,
|
continue
|
||||||
finish_reason TEXT, reasoning TEXT, reasoning_details TEXT,
|
try:
|
||||||
codex_reasoning_items TEXT
|
conn.execute(line)
|
||||||
)''')
|
except Exception as e:
|
||||||
|
pass # Ignore schema errors from partial DDL
|
||||||
conn.execute('CREATE INDEX idx_msg_session ON messages(session_id)')
|
ref.close()
|
||||||
conn.execute('CREATE INDEX idx_msg_ts ON messages(timestamp)')
|
os.remove(ref_copy)
|
||||||
|
if os.path.exists(ref_copy + '-wal'):
|
||||||
|
os.remove(ref_copy + '-wal')
|
||||||
|
|
||||||
|
# Copy sessions (INSERT OR REPLACE to dedupe by PK)
|
||||||
for db_file in db_files:
|
for db_file in db_files:
|
||||||
name = os.path.basename(db_file)
|
name = os.path.basename(db_file)
|
||||||
# Copy to temp file first (avoids WAL lock issues with open connections)
|
|
||||||
|
# Copy to temp with WAL files
|
||||||
tmp_copy = os.path.join(tmpdir, name)
|
tmp_copy = os.path.join(tmpdir, name)
|
||||||
shutil.copy2(db_file, tmp_copy)
|
shutil.copy2(db_file, tmp_copy)
|
||||||
# Also copy WAL if exists
|
|
||||||
if os.path.exists(db_file + '-wal'):
|
if os.path.exists(db_file + '-wal'):
|
||||||
shutil.copy2(db_file + '-wal', tmp_copy + '-wal')
|
shutil.copy2(db_file + '-wal', tmp_copy + '-wal')
|
||||||
|
if os.path.exists(db_file + '-shm'):
|
||||||
|
shutil.copy2(db_file + '-shm', tmp_copy + '-shm')
|
||||||
|
|
||||||
src = sqlite3.connect(tmp_copy)
|
src = sqlite3.connect(f'file:{tmp_copy}?mode=ro', uri=True)
|
||||||
|
|
||||||
s_cnt = src.execute('SELECT COUNT(*) FROM sessions').fetchone()[0]
|
s_cnt = src.execute('SELECT COUNT(*) FROM sessions').fetchone()[0]
|
||||||
m_cnt = src.execute('SELECT COUNT(*) FROM messages').fetchone()[0]
|
m_cnt = src.execute('SELECT COUNT(*) FROM messages').fetchone()[0]
|
||||||
print(f' {name}: {s_cnt}s/{m_cnt}m')
|
jm = src.execute('PRAGMA journal_mode').fetchone()[0]
|
||||||
|
print(f' {name}: {s_cnt}s/{m_cnt}m journal={jm}')
|
||||||
|
|
||||||
sess_rows = src.execute('SELECT * FROM sessions').fetchall()
|
sess_rows = src.execute('SELECT * FROM sessions').fetchall()
|
||||||
sess_cols = len(src.execute('PRAGMA table_info(sessions)').fetchall())
|
sess_cols = len(src.execute('PRAGMA table_info(sessions)').fetchall())
|
||||||
@@ -140,8 +180,9 @@ try:
|
|||||||
|
|
||||||
src.close()
|
src.close()
|
||||||
os.remove(tmp_copy)
|
os.remove(tmp_copy)
|
||||||
if os.path.exists(tmp_copy + '-wal'):
|
for suf in ['-wal', '-shm']:
|
||||||
os.remove(tmp_copy + '-wal')
|
if os.path.exists(tmp_copy + suf):
|
||||||
|
os.remove(tmp_copy + suf)
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
@@ -149,13 +190,20 @@ try:
|
|||||||
if os.path.exists(merged_path):
|
if os.path.exists(merged_path):
|
||||||
os.remove(merged_path)
|
os.remove(merged_path)
|
||||||
shutil.copy2(tmp_merged, merged_path)
|
shutil.copy2(tmp_merged, merged_path)
|
||||||
|
# Ensure no WAL on merged (merge output should be clean DELETE)
|
||||||
|
for suf in ['-wal', '-shm']:
|
||||||
|
if os.path.exists(merged_path + suf):
|
||||||
|
os.remove(merged_path + suf)
|
||||||
print(f'Merged: {os.path.getsize(merged_path)/1024:.0f} KB')
|
print(f'Merged: {os.path.getsize(merged_path)/1024:.0f} KB')
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
shutil.rmtree(tmpdir, ignore_errors=True)
|
shutil.rmtree(tmpdir, ignore_errors=True)
|
||||||
PYEOF
|
PYEOF
|
||||||
|
|
||||||
# ── Step 5: Push ─────────────────────────────────────────────────────────
|
# ── Step 5: Stage merged DB (it was just created in Step 4) ─────────────
|
||||||
|
git add state_merged.db 2>/dev/null || true
|
||||||
|
|
||||||
|
# ── Step 6: Push ─────────────────────────────────────────────────────────
|
||||||
if [ "$HAS_LOCAL" = true ]; then
|
if [ "$HAS_LOCAL" = true ]; then
|
||||||
git commit -m "Sync $(date '+%Y-%m-%d %H:%M')" 2>/dev/null || true
|
git commit -m "Sync $(date '+%Y-%m-%d %H:%M')" 2>/dev/null || true
|
||||||
if ! git push origin main 2>&1; then
|
if ! git push origin main 2>&1; then
|
||||||
@@ -167,7 +215,7 @@ else
|
|||||||
echo "No local changes"
|
echo "No local changes"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ── Step 6: Restore merged state to local hermes ─────────────────────────
|
# ── Step 7: Restore merged state to local hermes ─────────────────────────
|
||||||
python3 << 'PYEOF'
|
python3 << 'PYEOF'
|
||||||
import sqlite3, os, shutil, tempfile
|
import sqlite3, os, shutil, tempfile
|
||||||
|
|
||||||
@@ -180,23 +228,43 @@ if not os.path.exists(merged_path):
|
|||||||
else:
|
else:
|
||||||
tmpdir = tempfile.mkdtemp(prefix='hs_rest_')
|
tmpdir = tempfile.mkdtemp(prefix='hs_rest_')
|
||||||
try:
|
try:
|
||||||
|
# Step 7a: Ensure merged db is fully checkpointed (DELETE journal mode)
|
||||||
|
merge_conn = sqlite3.connect(f'file:{merged_path}?mode=ro', uri=True)
|
||||||
|
merge_jm = merge_conn.execute('PRAGMA journal_mode').fetchone()[0]
|
||||||
|
if merge_jm == 'wal':
|
||||||
|
merge_conn.execute('PRAGMA wal_checkpoint(TRUNCATE)')
|
||||||
|
print(f'Restored merged DB had WAL, checkpointed ({merge_jm})')
|
||||||
|
merge_conn.close()
|
||||||
|
|
||||||
tmp_db = os.path.join(tmpdir, 'db')
|
tmp_db = os.path.join(tmpdir, 'db')
|
||||||
shutil.copy2(merged_path, tmp_db)
|
shutil.copy2(merged_path, tmp_db)
|
||||||
|
# Also copy -wal/-shm if present
|
||||||
|
for suf in ['-wal', '-shm']:
|
||||||
|
if os.path.exists(merged_path + suf):
|
||||||
|
shutil.copy2(merged_path + suf, tmp_db + suf)
|
||||||
|
|
||||||
test = sqlite3.connect(tmp_db)
|
# Step 7b: Verify before overwriting
|
||||||
|
test = sqlite3.connect(f'file:{tmp_db}?mode=ro', uri=True)
|
||||||
r = test.execute('SELECT COUNT(*) FROM sessions').fetchone()[0]
|
r = test.execute('SELECT COUNT(*) FROM sessions').fetchone()[0]
|
||||||
m = test.execute('SELECT COUNT(*) FROM messages').fetchone()[0]
|
m = test.execute('SELECT COUNT(*) FROM messages').fetchone()[0]
|
||||||
|
test.execute('PRAGMA integrity_check') # verify
|
||||||
test.close()
|
test.close()
|
||||||
|
|
||||||
shutil.copy2(local_db, local_db + '.bak')
|
shutil.copy2(local_db, local_db + '.bak')
|
||||||
shutil.copy2(tmp_db, local_db)
|
shutil.copy2(tmp_db, local_db)
|
||||||
|
# Also copy WAL files to local
|
||||||
|
for suf in ['-wal', '-shm']:
|
||||||
|
if os.path.exists(tmp_db + suf):
|
||||||
|
shutil.copy2(tmp_db + suf, local_db + suf)
|
||||||
|
elif os.path.exists(local_db + suf):
|
||||||
|
os.remove(local_db + suf)
|
||||||
os.remove(local_db + '.bak')
|
os.remove(local_db + '.bak')
|
||||||
print(f'Restored: {r}s/{m}m')
|
print(f'Restored: {r}s/{m}m')
|
||||||
finally:
|
finally:
|
||||||
shutil.rmtree(tmpdir, ignore_errors=True)
|
shutil.rmtree(tmpdir, ignore_errors=True)
|
||||||
PYEOF
|
PYEOF
|
||||||
|
|
||||||
# ── Step 7: Sync memories + skills (additive) ────────────────────────────
|
# ── Step 8: Sync memories + skills (additive) ────────────────────────────
|
||||||
cp "$SYNC_DIR/memories/MEMORY.md" "$HERMES_HOME/memories/MEMORY.md" 2>/dev/null || true
|
cp "$SYNC_DIR/memories/MEMORY.md" "$HERMES_HOME/memories/MEMORY.md" 2>/dev/null || true
|
||||||
if [ -d "$SYNC_DIR/skills" ]; then
|
if [ -d "$SYNC_DIR/skills" ]; then
|
||||||
mkdir -p "$HERMES_HOME/skills"
|
mkdir -p "$HERMES_HOME/skills"
|
||||||
@@ -204,4 +272,19 @@ if [ -d "$SYNC_DIR/skills" ]; then
|
|||||||
cp -rn "$SYNC_DIR/skills/"* "$HERMES_HOME/skills/" 2>/dev/null || true
|
cp -rn "$SYNC_DIR/skills/"* "$HERMES_HOME/skills/" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ── Cleanup: Remove stale hermes-sync temp dirs from system tmp ─────────────
|
||||||
|
# (in case previous runs were interrupted and finally block didn't fire)
|
||||||
|
python3 -c "
|
||||||
|
import shutil, glob, os
|
||||||
|
tmp = os.environ.get('TMPDIR', '/tmp')
|
||||||
|
for p in glob.glob(os.path.join(tmp, 'hs_exp_*')) + \
|
||||||
|
glob.glob(os.path.join(tmp, 'hs_merge_*')) + \
|
||||||
|
glob.glob(os.path.join(tmp, 'hs_rest_*')):
|
||||||
|
try:
|
||||||
|
shutil.rmtree(p)
|
||||||
|
print(f'Cleaned: {p}')
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
" 2>/dev/null || true
|
||||||
|
|
||||||
echo "[$(date '+%H:%M:%S')] Done"
|
echo "[$(date '+%H:%M:%S')] Done"
|
||||||
|
|||||||
Reference in New Issue
Block a user