Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/specify_cli/extensions/command_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,24 @@ def extension_add(
for warning in manifest.warnings:
console.print(f"\n[yellow]⚠ Compatibility warning:[/yellow] {_escape_markup(str(warning))}")

console.print("\n[bold cyan]Provided commands:[/bold cyan]")
extension_dir = manager.extensions_dir / manifest.id
provided_commands = []
missing_commands = []
for cmd in manifest.commands:
cmd_name = _commands._registered_command_name(project_root, cmd['name'])
console.print(f" • {_escape_markup(str(cmd_name))} - {_escape_markup(str(cmd.get('description', '')))}")
if (extension_dir / cmd["file"]).is_file():
provided_commands.append(cmd)
else:
missing_commands.append(cmd)

if provided_commands:
console.print("\n[bold cyan]Provided commands:[/bold cyan]")
for cmd in provided_commands:
cmd_name = _commands._registered_command_name(project_root, cmd["name"])
console.print(f" • {_escape_markup(str(cmd_name))} - {_escape_markup(str(cmd.get('description', '')))}")
if missing_commands:
console.print("\n[yellow]Warning:[/yellow] Command files missing:")
for cmd in missing_commands:
console.print(f" • {_escape_markup(cmd['name'])} ({_escape_markup(cmd['file'])})")

# Report agent skills registration
reg_meta = manager.registry.get(manifest.id)
Expand Down
46 changes: 46 additions & 0 deletions tests/specify_cli/extensions/test_command_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,52 @@
class TestExtensionAddCLI:
"""CLI tests for ``specify extension add``."""

@pytest.mark.parametrize(
("agent", "skills_dir"),
[("codex", ".agents/skills"), ("claude", ".claude/skills")],
)
@pytest.mark.parametrize("case", ["complete", "missing-one", "missing-all", "ignored"])
def test_add_dev_reports_missing_command_files(
self, extension_dir, project_dir, valid_manifest_data, monkeypatch, agent, skills_dir, case
):
provides = valid_manifest_data["provides"]
provides["commands"].append({
"name": "speckit.test-ext.second",
"file": "commands/second.md",
"description": "Second test command",
})
(extension_dir / "extension.yml").write_text(
yaml.safe_dump(valid_manifest_data), encoding="utf-8"
)
if case in {"complete", "ignored"}:
(extension_dir / "commands/second.md").write_text(
"---\ndescription: Second test command\n---\n\nSecond command\n",
encoding="utf-8",
)
if case == "ignored":
(extension_dir / ".extensionignore").write_text("commands/second.md\n", encoding="utf-8")
if case == "missing-all":
(extension_dir / "commands/hello.md").unlink()

write_listing_project_options(project_dir, {"ai": agent, "ai_skills": True})
with monkeypatch.context() as project_context:
project_context.chdir(project_dir)
result = CliRunner().invoke(app, ["extension", "add", "--dev", str(extension_dir)])
output = strip_ansi(result.output)

assert result.exit_code == 0, output
assert "Extension installed successfully" in output
assert ("Provided commands:" in output) == (case != "missing-all")
assert ("Command files missing:" in output) == (case != "complete")
for command in provides["commands"]:
name = command["name"]
filename = command["file"]
skill_name = name.replace(".", "-")
available = case == "complete" or (case != "missing-all" and name.endswith(".hello"))
assert (project_dir / skills_dir / skill_name / "SKILL.md").is_file() == available
assert (f"• {skill_name} - " in output) == available
assert (f"• {name} ({filename})" in output) == (not available)

@pytest.mark.parametrize(
("config", "warns"),
[
Expand Down
Loading