-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_bundle_framework_augmentation.py
More file actions
142 lines (126 loc) · 4.13 KB
/
Copy pathtest_bundle_framework_augmentation.py
File metadata and controls
142 lines (126 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
"""Regression coverage for adding a framework to an installed bundle."""
from pathlib import Path
def _write_bundle(root: Path) -> Path:
bundle_dir = root / "toolkit"
skills_dir = bundle_dir / "skills"
for name in ("toolkit-plan", "toolkit-review"):
skill_dir = skills_dir / name
skill_dir.mkdir(parents=True)
(skill_dir / "capability.yaml").write_text(
f"""\
kind: skill
name: {name}
version: 1.0.0
description: {name} test skill
frameworks:
- opencode
"""
)
(skill_dir / "SKILL.md").write_text(f"# {name}\n")
(bundle_dir / "capability.yaml").write_text(
"""\
kind: bundle
name: toolkit
version: 1.0.0
description: Toolkit test bundle
frameworks:
- opencode
- qwen
- cursor
capabilities:
- name: toolkit-plan
source: ./skills/toolkit-plan
version: 1.0.0
- name: toolkit-review
source: ./skills/toolkit-review
version: 1.0.0
"""
)
return bundle_dir
def test_installed_bundle_adds_new_project_framework_to_every_member(
tmp_home: Path,
tmp_path: Path,
monkeypatch,
) -> None:
from capacium.commands.install import install_capability
from capacium.registry import Registry
monkeypatch.delenv("CAPACIUM_PROJECT_ROOT", raising=False)
bundle_dir = _write_bundle(tmp_path)
assert install_capability(
"test/toolkit@1.0.0",
source_dir=bundle_dir,
no_lock=True,
framework="opencode",
)
opencode_skills = tmp_home / ".opencode" / "skills"
assert (opencode_skills / "toolkit-plan").is_symlink()
assert (opencode_skills / "toolkit-review").is_symlink()
registry = Registry()
for name in ("toolkit-plan", "toolkit-review"):
member = registry.get_capability(f"test/{name}", "1.0.0")
assert member is not None
assert member.frameworks == ["opencode"]
assert "cursor" not in registry.get_adapter_statuses(
f"test/{name}", "1.0.0"
)
assert install_capability(
"test/toolkit",
no_lock=True,
offline=True,
framework="qwen",
)
qwen_skills = tmp_home / ".qwen" / "skills"
assert (qwen_skills / "toolkit-plan").is_symlink()
assert (qwen_skills / "toolkit-review").is_symlink()
assert not (qwen_skills / "toolkit").exists()
for name in ("toolkit-plan", "toolkit-review"):
member = registry.get_capability(f"test/{name}", "1.0.0")
assert member is not None
assert "qwen" in member.frameworks
assert registry.get_adapter_statuses(f"test/{name}", "1.0.0")[
"qwen"
].status == "installed"
project_root = tmp_path / "cursor-project"
assert install_capability(
"test/toolkit",
no_lock=True,
offline=True,
framework="cursor",
project=str(project_root),
)
cursor_skills = project_root / ".cursor" / "skills"
member_links = {
path.name: path.resolve()
for path in cursor_skills.iterdir()
if path.is_symlink()
}
assert set(member_links) == {"toolkit-plan", "toolkit-review"}
assert not (cursor_skills / "toolkit").exists()
for name, target in member_links.items():
member = registry.get_capability(f"test/{name}", "1.0.0")
assert member is not None
assert target == member.install_path.resolve()
assert "cursor" in member.frameworks
assert registry.get_adapter_statuses(f"test/{name}", "1.0.0")[
"cursor"
].status == "installed"
bundle = registry.get_capability("test/toolkit", "1.0.0")
assert bundle is not None
assert "cursor" in bundle.frameworks
assert install_capability(
"test/toolkit",
no_lock=True,
offline=True,
framework="cursor",
project=str(project_root),
)
repeated_links = {
path.name: path.resolve()
for path in cursor_skills.iterdir()
if path.is_symlink()
}
assert repeated_links == member_links
assert (opencode_skills / "toolkit-plan").is_symlink()
assert (opencode_skills / "toolkit-review").is_symlink()
assert (qwen_skills / "toolkit-plan").is_symlink()
assert (qwen_skills / "toolkit-review").is_symlink()