Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

feat:更改.checkpoint和.logs到agent目录下

ZhouRZd83bd5430f1f
diff --git a/jiuwenclaw/resources/config.yaml b/jiuwenclaw/resources/config.yaml
index 63c5974a94..61132ee3d9 100644
--- a/jiuwenclaw/resources/config.yaml
+++ b/jiuwenclaw/resources/config.yaml
@@ -1,7 +1,7 @@
# 前端显示语言:zh(中文)/ en(英文),与 Web 界面语言切换同步
preferred_language: zh
-# 日志目录:~/.jiuwenclaw/.logs/
+# 日志目录:~/.jiuwenclaw/agent/.logs/
# gateway.log / channel.log / agent_server.log 按源码路径分流;full.log 为汇总。
# level:未单独指定时的默认级别。console_level:控制台;可省略则用 level。
# 环境变量 LOG_LEVEL 仅覆盖控制台级别(不覆盖各日志文件)。
diff --git a/jiuwenclaw/utils.py b/jiuwenclaw/utils.py
index 9f1ba58040..31a4221f4d 100644
--- a/jiuwenclaw/utils.py
+++ b/jiuwenclaw/utils.py
@@ -21,8 +21,8 @@ Runtime layout:
- USER.md
- <root>/agent/sessions
- <root>/agent/jiuwenclaw_workspace/agent-data.json
-- <root>/.checkpoint
-- <root>/.logs(gateway.log / channel.log / agent_server.log / full.log)
+- <root>/agent/.checkpoint
+- <root>/agent/.logs(gateway.log / channel.log / agent_server.log / full.log)
内置模板位于包内 ``jiuwenclaw/resources/``(含 ``agent/`` 下各技能模板以及 ``skills_state.json``)。
"""
@@ -728,8 +728,8 @@ def prepare_workspace(
# ----- copy runtime dirs (new layout) -----
agent_root = workspace_dir / "agent"
agent_sessions = agent_root / "sessions"
- (workspace_dir / ".checkpoint").mkdir(parents=True, exist_ok=True)
- (workspace_dir / ".logs").mkdir(parents=True, exist_ok=True)
+ (agent_root / ".checkpoint").mkdir(parents=True, exist_ok=True)
+ (agent_root / ".logs").mkdir(parents=True, exist_ok=True)
# ----- DeepAgent workspace (standard DeepAgents schema) -----
deepagent_workspace = agent_root / "jiuwenclaw_workspace"
@@ -1067,12 +1067,35 @@ def get_agent_sessions_dir() -> Path:
return get_agent_root_dir() / "sessions"
+_legacy_migration_done: bool = False
+
+
+def _migrate_legacy_checkpoint_and_logs() -> None:
+ """One-time migration: move ~/.jiuwenclaw/.checkpoint and .logs to ~/.jiuwenclaw/agent/."""
+ global _legacy_migration_done
+ if _legacy_migration_done:
+ return
+ _legacy_migration_done = True
+
+ workspace = get_user_workspace_dir()
+ agent_root = workspace / "agent"
+
+ for name in (".checkpoint", ".logs"):
+ legacy = workspace / name
+ new_path = agent_root / name
+ if legacy.exists() and not new_path.exists():
+ agent_root.mkdir(parents=True, exist_ok=True)
+ shutil.move(str(legacy), str(new_path))
+
+
def get_checkpoint_dir() -> Path:
- return get_user_workspace_dir() / ".checkpoint"
+ _migrate_legacy_checkpoint_and_logs()
+ return get_agent_root_dir() / ".checkpoint"
def get_logs_dir() -> Path:
- return get_user_workspace_dir() / ".logs"
+ _migrate_legacy_checkpoint_and_logs()
+ return get_agent_root_dir() / ".logs"
def get_xy_tmp_dir() -> Path:
@@ -1193,7 +1216,7 @@ def setup_logger(log_level: Optional[str] = None) -> logging.Logger:
- ``jiuwenclaw.agentserver.*`` → agent_server.log
- 其余 ``jiuwenclaw.*``(含 ``jiuwenclaw.app``、gateway、evolution、utils 等)→ gateway.log
- 所有分类日志同时写入 ``full.log``。输出目录:``~/.jiuwenclaw/.logs/``。
+ 所有分类日志同时写入 ``full.log``。输出目录:``~/.jiuwenclaw/agent/.logs/``。
级别由 ``config.yaml`` 的 ``logging`` 段控制;环境变量 ``LOG_LEVEL`` 仅覆盖**控制台**级别
(``log_level`` 参数为 ``None`` 时)。若传入 ``log_level``(如单测),则控制台与各文件级别均为该值。
diff --git a/tests/system_tests/conftest.py b/tests/system_tests/conftest.py
index 4f5a8e2860..ffd590e7e4 100644
--- a/tests/system_tests/conftest.py
+++ b/tests/system_tests/conftest.py
@@ -169,8 +169,8 @@ def verify_workspace_structure():
workspace_dir / "agent" / "memory",
workspace_dir / "agent" / "sessions",
workspace_dir / "agent" / "workspace",
- workspace_dir / ".checkpoint",
- workspace_dir / ".logs",
+ workspace_dir / "agent" / ".checkpoint",
+ workspace_dir / "agent" / ".logs",
]
for dir_path in expected_dirs: