fix(agent): preserve agent-owned state in project workspaces (#4945)

This commit is contained in:
chengyongru
2026-07-22 17:25:22 +08:00
committed by GitHub
parent 4cd6eb6c38
commit b189a37648
23 changed files with 560 additions and 89 deletions
+39
View File
@@ -297,6 +297,45 @@ def test_disabled_skills_excluded_from_build_skills_summary(tmp_path: Path) -> N
assert "beta" in summary
def test_build_skills_summary_groups_paths_by_root(tmp_path: Path) -> None:
workspace = tmp_path / "ws"
workspace_skills = workspace / "skills"
workspace_skills.mkdir(parents=True)
workspace_path = _write_skill(workspace_skills, "alpha", body="# Alpha")
builtin = tmp_path / "builtin"
builtin_path = _write_skill(builtin, "beta", body="# Beta")
summary = SkillsLoader(workspace, builtin_skills_dir=builtin).build_skills_summary()
assert summary.count(str(workspace_skills)) == 1
assert summary.count(str(builtin)) == 1
assert str(workspace_path) not in summary
assert str(builtin_path) not in summary
assert "`alpha/SKILL.md`" in summary
assert "`beta/SKILL.md`" in summary
def test_bundled_update_setup_description_is_valid_yaml(tmp_path: Path) -> None:
metadata = SkillsLoader(tmp_path).get_skill_metadata("update-setup")
assert metadata is not None
assert metadata["description"].startswith("One-time setup wizard")
assert "Triggers:" in metadata["description"]
def test_bundled_skills_use_agent_owned_paths(tmp_path: Path) -> None:
loader = SkillsLoader(tmp_path)
memory = loader.load_skill("memory")
update_setup = loader.load_skill("update-setup")
assert memory is not None
assert "<history-log-path>" in memory
assert 'path="memory/history.jsonl"' not in memory
assert update_setup is not None
assert "<agent-workspace>/skills/update/SKILL.md" in update_setup
assert "Never substitute a project-relative" in update_setup
def test_disabled_skills_excluded_from_get_always_skills(tmp_path: Path) -> None:
workspace = tmp_path / "ws"
ws_skills = workspace / "skills"