Skip to content
Open
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
8 changes: 7 additions & 1 deletion src/specify_cli/extensions/_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,16 +623,22 @@ def extension_add(
for warning in manifest.warnings:
console.print(f"\n[yellow]⚠ Compatibility warning:[/yellow] {_escape_markup(str(warning))}")

is_cline = load_init_options(project_root).get("ai") == "cline"
selected_ai = load_init_options(project_root).get("ai")
is_cline = selected_ai == "cline"
is_forge = selected_ai == "forge"

if is_cline:
from specify_cli.integrations.cline import format_cline_command_name
if is_forge:
from specify_cli.integrations.forge import format_forge_command_name

console.print("\n[bold cyan]Provided commands:[/bold cyan]")
for cmd in manifest.commands:
cmd_name = cmd['name']
if is_cline:
cmd_name = format_cline_command_name(cmd_name)
elif is_forge:
cmd_name = format_forge_command_name(cmd_name)
console.print(f" • {_escape_markup(str(cmd_name))} - {_escape_markup(str(cmd.get('description', '')))}")

# Report agent skills registration
Expand Down
31 changes: 31 additions & 0 deletions tests/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9010,3 +9010,34 @@ def test_non_utf8_registry_does_not_crash(self, tmp_path, monkeypatch):
# Must not raise; must fall back to the "no siblings" path.
cfg = ConfigManager(tmp_path, "testext")._get_env_config()
assert cfg == {"url": "v"}


def test_forge_extension_install_listing_hyphenates_command_names(
extension_dir, project_dir
):
"""The post-install 'Provided commands' listing must show hyphenated
/speckit-<name> command names for a Forge project (Forge registers
hyphenated names), mirroring the existing Cline handling."""
import json
import os

from typer.testing import CliRunner

from specify_cli import app

init_options = project_dir / ".specify" / "init-options.json"
init_options.write_text(json.dumps({"ai": "forge", "script": "sh"}))

old_cwd = os.getcwd()
try:
os.chdir(project_dir)
result = CliRunner().invoke(
app, ["extension", "add", str(extension_dir), "--dev"]
)
finally:
os.chdir(old_cwd)

assert result.exit_code == 0, result.output
# Forge registers hyphenated command names, so the summary must match.
assert "speckit-test-ext-hello" in result.output
assert "speckit.test-ext.hello" not in result.output