From 15cb154a19cabb5c3c66491a61f215ef104d5280 Mon Sep 17 00:00:00 2001
From: TevinClaw <510129976@qq.com>
Date: Sat, 14 Mar 2026 13:03:06 +0800
Subject: [PATCH] feat(早报): 增加昨日总结模块

---
 workspace/skills/memory-management/scripts/write_l0.py |   63 +++++++++++++++++++++++++++++++
 1 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/workspace/skills/memory-management/scripts/write_l0.py b/workspace/skills/memory-management/scripts/write_l0.py
new file mode 100755
index 0000000..7d29caf
--- /dev/null
+++ b/workspace/skills/memory-management/scripts/write_l0.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python3
+"""
+快速写入L0层 (MEMORY.md)
+"""
+
+import sys
+import argparse
+from datetime import datetime
+from pathlib import Path
+
+
+def main():
+    parser = argparse.ArgumentParser(description="写入L0层记忆")
+    parser.add_argument("content", help="记录内容")
+    parser.add_argument("--link", help="关联的L2文件路径")
+    parser.add_argument("--type", default="活动", help="记录类型")
+    args = parser.parse_args()
+    
+    workspace = Path.home() / ".openclaw" / "workspace"
+    memory_file = workspace / "MEMORY.md"
+    
+    # 确保文件存在
+    if not memory_file.exists():
+        print(f"❌ {memory_file} 不存在")
+        return 1
+    
+    today = datetime.now().strftime("%Y-%m-%d")
+    
+    # 构建记录行
+    line = f"- **[{args.type}]** {args.content}"
+    if args.link:
+        line += f" → 详见 [{args.link}](./{args.link})"
+    
+    # 读取现有内容
+    with open(memory_file, 'r', encoding='utf-8') as f:
+        content = f.read()
+    
+    # 在"最近活动"部分添加
+    if "### 最近活动" in content:
+        parts = content.split("### 最近活动")
+        if len(parts) == 2:
+            # 在第一行后插入
+            lines = parts[1].split('\n')
+            insert_idx = 0
+            for i, l in enumerate(lines):
+                if l.strip() and not l.startswith('#'):
+                    insert_idx = i
+                    break
+            lines.insert(insert_idx, f"- {today}: {args.content}")
+            new_content = parts[0] + "### 最近活动" + '\n'.join(lines)
+            
+            with open(memory_file, 'w', encoding='utf-8') as f:
+                f.write(new_content)
+            
+            print(f"✅ 已写入L0: {args.content}")
+            return 0
+    
+    print("⚠️  未找到'最近活动'区块,请手动添加")
+    return 1
+
+
+if __name__ == "__main__":
+    sys.exit(main())

--
Gitblit v1.9.1