rename: myclaude -> myagents

This commit is contained in:
Zhengshou Lai
2026-07-01 23:27:14 +08:00
parent 1db0187b70
commit 7f1aa9f27e
23 changed files with 859 additions and 937 deletions
+24 -24
View File
@@ -1,65 +1,65 @@
"""Tests for myclaude.project_root."""
"""Tests for myagents.project_root."""
import os
from pathlib import Path
from unittest.mock import patch
from myclaude.project_root import get_myclaude_project_root, get_workspace_root
from myagents.project_root import get_project_root, get_workspace_root
class TestGetMyclaudeProjectRoot:
"""Tests for get_myclaude_project_root."""
class TestGetProjectRoot:
"""Tests for get_project_root."""
def test_env_var_takes_priority(self, tmp_path: Path) -> None:
"""MYCLAUDE_PROJECT_ROOT env var should be used when set."""
"""MYAGENTS_PROJECT_ROOT env var should be used when set."""
fake_root = tmp_path / "fake_repo"
fake_root.mkdir()
(fake_root / "pyproject.toml").write_text('name = "myclaude"\n')
(fake_root / "pyproject.toml").write_text('name = "myagents"\n')
with patch.dict(os.environ, {"MYCLAUDE_PROJECT_ROOT": str(fake_root)}):
result = get_myclaude_project_root()
with patch.dict(os.environ, {"MYAGENTS_PROJECT_ROOT": str(fake_root)}):
result = get_project_root()
assert result == fake_root.resolve()
def test_env_var_expands_tilde(self, tmp_path: Path) -> None:
"""MYCLAUDE_PROJECT_ROOT should expand ~ to home directory."""
"""MYAGENTS_PROJECT_ROOT should expand ~ to home directory."""
home = tmp_path / "home"
home.mkdir()
fake_root = home / "fake_repo"
fake_root.mkdir()
(fake_root / "pyproject.toml").write_text('name = "myclaude"\n')
(fake_root / "pyproject.toml").write_text('name = "myagents"\n')
with patch.dict(
os.environ,
{
"MYCLAUDE_PROJECT_ROOT": "~/fake_repo",
"MYAGENTS_PROJECT_ROOT": "~/fake_repo",
"HOME": str(home),
},
):
result = get_myclaude_project_root()
result = get_project_root()
assert result == fake_root.resolve()
def test_fallback_when_not_in_repo(self) -> None:
"""When not in a repo, fallback to ~/.myclaude."""
"""When not in a repo, fallback to ~/.myagents."""
with (
patch.dict(os.environ, {}, clear=True),
patch("pathlib.Path.cwd", side_effect=OSError),
patch(
"myclaude.project_root._pyproject_names_myclaude",
"myagents.project_root._pyproject_names_myagents",
return_value=False,
),
):
result = get_myclaude_project_root()
assert result == Path.home() / ".myclaude"
result = get_project_root()
assert result == Path.home() / ".myagents"
class TestGetWorkspaceRoot:
"""Tests for get_workspace_root."""
def test_env_var_takes_priority(self, tmp_path: Path) -> None:
"""MYCLAUDE_WORKSPACE_ROOT env var should be used when set."""
"""MYAGENTS_WORKSPACE_ROOT env var should be used when set."""
custom = tmp_path / "custom_workspace"
with patch.dict(os.environ, {"MYCLAUDE_WORKSPACE_ROOT": str(custom)}):
with patch.dict(os.environ, {"MYAGENTS_WORKSPACE_ROOT": str(custom)}):
result = get_workspace_root()
assert result == custom.resolve()
assert result.is_dir()
@@ -69,21 +69,21 @@ class TestGetWorkspaceRoot:
new_ws = tmp_path / "new_workspace"
assert not new_ws.exists()
with patch.dict(os.environ, {"MYCLAUDE_WORKSPACE_ROOT": str(new_ws)}):
with patch.dict(os.environ, {"MYAGENTS_WORKSPACE_ROOT": str(new_ws)}):
result = get_workspace_root()
assert result == new_ws.resolve()
assert result.is_dir()
def test_defaults_to_project_workspace(self, tmp_path: Path) -> None:
"""When project_root/workspace exists, use it."""
project_root = tmp_path / "myclaude"
project_root = tmp_path / "myagents"
project_root.mkdir()
workspace = project_root / "workspace"
workspace.mkdir()
(project_root / "pyproject.toml").write_text('name = "myclaude"\n')
(project_root / "pyproject.toml").write_text('name = "myagents"\n')
with patch.dict(
os.environ, {"MYCLAUDE_PROJECT_ROOT": str(project_root)}, clear=True
os.environ, {"MYAGENTS_PROJECT_ROOT": str(project_root)}, clear=True
):
result = get_workspace_root()
assert result == workspace.resolve()
@@ -95,8 +95,8 @@ class TestGetWorkspaceRoot:
with (
patch.dict(os.environ, {}, clear=True),
patch(
"myclaude.project_root.get_myclaude_project_root",
return_value=tmp_path / ".myclaude",
"myagents.project_root.get_project_root",
return_value=tmp_path / ".myagents",
),
patch("pathlib.Path.home", return_value=home),
):