Skip to content

refactor: 集中管理 ~/.nimo 路径,统一通过 NIMO_HOME 环境变量覆盖#31

Merged
robscc merged 1 commit intomainfrom
refactor/centralize-nimo-home-paths
Mar 21, 2026
Merged

refactor: 集中管理 ~/.nimo 路径,统一通过 NIMO_HOME 环境变量覆盖#31
robscc merged 1 commit intomainfrom
refactor/centralize-nimo-home-paths

Conversation

@robscc
Copy link
Owner

@robscc robscc commented Mar 21, 2026

Summary

  • 将所有硬编码的 Path.home() / ".nimo" 统一收敛到 agentpal/paths.pyget_nimo_home(),全局仅保留一处默认值
  • config.pyconfig_file.pyproviders/manager.pycontext_builder.pymanager.py、CLI 模块等全部改为通过 agentpal.paths 获取路径
  • 支持 NIMO_HOME 环境变量覆盖默认的 ~/.nimo 基础目录

改动文件

文件 改动
paths.py 新增 get_nimo_dir 别名(向后兼容 get_nimo_home
config.py workspace_dir / skills_dir 默认值改用 paths 函数
config_file.py ConfigFileManager 使用 get_nimo_dir()
providers/manager.py ProviderManager 使用 get_nimo_dir()
workspace/context_builder.py system prompt 动态获取 workspace 路径
workspace/manager.py DEFAULT_DIR 改用 get_workspace_dir()
cli/process.py PidManager 使用 get_run_dir()
cli/utils.py 委托给 agentpal.paths.get_workspace_dir
cli/commands/init_cmd.py 使用 agentpal.paths.get_workspace_dir

Test plan

  • 验证默认启动行为不变(不设环境变量时仍使用 ~/.nimo
  • 设置 NIMO_HOME=/tmp/test-nimo 验证所有路径正确指向新目录
  • 运行 pytest tests/unit/ tests/integration/ 确认无回归

🤖 Generated with Claude Code

将所有硬编码的 Path.home() / ".nimo" 统一指向 agentpal/paths.py 的
get_nimo_home(),支持 NIMO_HOME 环境变量覆盖默认路径。

- config.py: workspace_dir/skills_dir 默认值改用 get_workspace_dir()/get_skills_dir()
- config_file.py: 使用 get_nimo_dir (get_nimo_home 的别名)
- providers/manager.py: 使用 get_nimo_dir 代替硬编码路径
- workspace/context_builder.py: system prompt 中动态获取 workspace 路径
- workspace/manager.py: DEFAULT_DIR 改用 get_workspace_dir()
- cli/process.py: PidManager 使用 get_run_dir()
- cli/utils.py: 委托给 agentpal.paths.get_workspace_dir
- cli/commands/init_cmd.py: 使用 agentpal.paths.get_workspace_dir

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@robscc robscc merged commit 905c720 into main Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant