|
1 | 1 | """Tests for OpencodeIntegration.""" |
2 | 2 |
|
| 3 | +import yaml |
| 4 | + |
3 | 5 | from specify_cli.integrations import get_integration |
| 6 | +from specify_cli.integrations.manifest import IntegrationManifest |
4 | 7 |
|
5 | 8 | from .test_integration_base_markdown import MarkdownIntegrationTests |
6 | 9 |
|
@@ -57,3 +60,66 @@ def test_build_exec_args_keeps_plain_prompt_dispatch(self): |
57 | 60 | args = integration.build_exec_args("explain this repository", output_json=False) |
58 | 61 |
|
59 | 62 | assert args == ["opencode", "run", "explain this repository"] |
| 63 | + |
| 64 | + |
| 65 | +class TestOpencodeSkillsMode: |
| 66 | + KEY = "opencode" |
| 67 | + |
| 68 | + def test_skills_option_declared(self): |
| 69 | + integration = get_integration(self.KEY) |
| 70 | + opts = integration.options() |
| 71 | + names = [o.name for o in opts] |
| 72 | + assert "--skills" in names |
| 73 | + skills_opt = next(o for o in opts if o.name == "--skills") |
| 74 | + assert skills_opt.is_flag is True |
| 75 | + assert skills_opt.default is False |
| 76 | + |
| 77 | + def test_skills_mode_creates_skill_md_files(self, tmp_path): |
| 78 | + integration = get_integration(self.KEY) |
| 79 | + manifest = IntegrationManifest(self.KEY, tmp_path) |
| 80 | + created = integration.setup(tmp_path, manifest, parsed_options={"skills": True}, script_type="sh") |
| 81 | + |
| 82 | + skill_files = [p for p in created if p.name == "SKILL.md"] |
| 83 | + assert skill_files |
| 84 | + |
| 85 | + skills_dir = tmp_path / ".opencode" / "skills" |
| 86 | + assert skills_dir.is_dir() |
| 87 | + |
| 88 | + specify_skill = skills_dir / "speckit-specify" / "SKILL.md" |
| 89 | + assert specify_skill.exists() |
| 90 | + |
| 91 | + def test_skills_mode_does_not_create_md_command_files(self, tmp_path): |
| 92 | + integration = get_integration(self.KEY) |
| 93 | + manifest = IntegrationManifest(self.KEY, tmp_path) |
| 94 | + integration.setup(tmp_path, manifest, parsed_options={"skills": True}, script_type="sh") |
| 95 | + |
| 96 | + command_dir = tmp_path / ".opencode" / "command" |
| 97 | + md_files = list(command_dir.glob("*.md")) if command_dir.exists() else [] |
| 98 | + assert md_files == [] |
| 99 | + |
| 100 | + def test_skills_mode_frontmatter(self, tmp_path): |
| 101 | + integration = get_integration(self.KEY) |
| 102 | + manifest = IntegrationManifest(self.KEY, tmp_path) |
| 103 | + integration.setup(tmp_path, manifest, parsed_options={"skills": True}, script_type="sh") |
| 104 | + |
| 105 | + skill_path = tmp_path / ".opencode" / "skills" / "speckit-plan" / "SKILL.md" |
| 106 | + assert skill_path.exists() |
| 107 | + |
| 108 | + content = skill_path.read_text(encoding="utf-8") |
| 109 | + parts = content.split("---", 2) |
| 110 | + parsed = yaml.safe_load(parts[1]) |
| 111 | + |
| 112 | + assert parsed["name"] == "speckit-plan" |
| 113 | + assert "description" in parsed |
| 114 | + assert "compatibility" in parsed |
| 115 | + assert parsed["metadata"]["author"] == "github-spec-kit" |
| 116 | + |
| 117 | + def test_default_mode_unchanged(self, tmp_path): |
| 118 | + integration = get_integration(self.KEY) |
| 119 | + manifest = IntegrationManifest(self.KEY, tmp_path) |
| 120 | + integration.setup(tmp_path, manifest, script_type="sh") |
| 121 | + |
| 122 | + command_dir = tmp_path / ".opencode" / "command" |
| 123 | + assert command_dir.is_dir() |
| 124 | + md_files = list(command_dir.glob("*.md")) |
| 125 | + assert md_files |
0 commit comments