Skip to content

Commit 984528e

Browse files
committed
fix: address PR review round 3
- Clarify parsed_options forwarding is intentional (all options passed, integrations decide what to use) - Extract _strip_ansi() helper in test_extensions.py and test_presets.py - Remove unused pytest import (test_cli.py), unused locals (test_integration_base_skills.py) - Reword --ai-commands-dir deprecation to be actionable without referencing the not-yet-implemented --integration-options
1 parent 13f53ec commit 984528e

5 files changed

Lines changed: 22 additions & 17 deletions

File tree

src/specify_cli/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,9 @@ def init(
22482248
resolved_integration.key, project_path, version=get_speckit_version()
22492249
)
22502250

2251-
# Build parsed_options from legacy CLI flags for Stage 5 integrations
2251+
# Forward all legacy CLI flags to the integration as parsed_options.
2252+
# Integrations receive every option and decide what to use;
2253+
# irrelevant keys are simply ignored by the integration's setup().
22522254
integration_parsed_options: dict[str, Any] = {}
22532255
if ai_commands_dir:
22542256
integration_parsed_options["commands_dir"] = ai_commands_dir

tests/integrations/test_cli.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import json
44
import os
55

6-
import pytest
7-
86

97
class TestInitIntegrationFlag:
108
def test_integration_and_ai_mutually_exclusive(self, tmp_path):

tests/integrations/test_integration_base_skills.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ def test_skill_directory_structure(self, tmp_path):
9797
i = get_integration(self.KEY)
9898
m = IntegrationManifest(self.KEY, tmp_path)
9999
created = i.setup(tmp_path, m)
100-
skills_dir = i.skills_dest(tmp_path)
101100
skill_files = [f for f in created if "scripts" not in f.parts]
102101

103102
expected_commands = {
@@ -223,7 +222,7 @@ def test_pre_existing_skills_not_removed(self, tmp_path):
223222
def test_setup_installs_update_context_scripts(self, tmp_path):
224223
i = get_integration(self.KEY)
225224
m = IntegrationManifest(self.KEY, tmp_path)
226-
created = i.setup(tmp_path, m)
225+
i.setup(tmp_path, m)
227226
scripts_dir = tmp_path / ".specify" / "integrations" / self.KEY / "scripts"
228227
assert scripts_dir.is_dir(), f"Scripts directory not created for {self.KEY}"
229228
assert (scripts_dir / "update-context.sh").exists()

tests/test_extensions.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Catalog stack (multi-catalog support)
1010
"""
1111

12+
import re
1213
import pytest
1314
import json
1415
import tempfile
@@ -33,6 +34,11 @@
3334
)
3435

3536

37+
def _strip_ansi(text: str) -> str:
38+
"""Remove ANSI escape codes from Rich-formatted CLI output."""
39+
return re.sub(r'\x1b\[[0-9;]*m', '', text)
40+
41+
3642
# ===== Fixtures =====
3743

3844
@pytest.fixture
@@ -3126,8 +3132,7 @@ def test_list_shows_extension_id(self, extension_dir, project_dir):
31263132
result = runner.invoke(app, ["extension", "list"])
31273133

31283134
assert result.exit_code == 0, result.output
3129-
import re as _re
3130-
plain = _re.sub(r'\x1b\[[0-9;]*m', '', result.output)
3135+
plain = _strip_ansi(result.output)
31313136
# Verify the extension ID is shown in the output
31323137
assert "test-ext" in plain
31333138
# Verify name and version are also shown
@@ -3362,8 +3367,7 @@ def test_list_shows_priority(self, extension_dir, project_dir):
33623367
result = runner.invoke(app, ["extension", "list"])
33633368

33643369
assert result.exit_code == 0, result.output
3365-
import re as _re
3366-
plain = _re.sub(r'\x1b\[[0-9;]*m', '', result.output)
3370+
plain = _strip_ansi(result.output)
33673371
assert "Priority: 7" in plain
33683372

33693373
def test_set_priority_changes_priority(self, extension_dir, project_dir):
@@ -3385,8 +3389,7 @@ def test_set_priority_changes_priority(self, extension_dir, project_dir):
33853389
result = runner.invoke(app, ["extension", "set-priority", "test-ext", "5"])
33863390

33873391
assert result.exit_code == 0, result.output
3388-
import re as _re
3389-
plain = _re.sub(r'\x1b\[[0-9;]*m', '', result.output)
3392+
plain = _strip_ansi(result.output)
33903393
assert "priority changed: 10 → 5" in plain
33913394

33923395
# Reload registry to see updated value
@@ -3409,8 +3412,7 @@ def test_set_priority_same_value_no_change(self, extension_dir, project_dir):
34093412
result = runner.invoke(app, ["extension", "set-priority", "test-ext", "5"])
34103413

34113414
assert result.exit_code == 0, result.output
3412-
import re as _re
3413-
plain = _re.sub(r'\x1b\[[0-9;]*m', '', result.output)
3415+
plain = _strip_ansi(result.output)
34143416
assert "already has priority 5" in plain
34153417

34163418
def test_set_priority_invalid_value(self, extension_dir, project_dir):

tests/test_presets.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212

1313
import pytest
14+
import re
1415
import json
1516
import tempfile
1617
import shutil
@@ -35,6 +36,11 @@
3536
from specify_cli.extensions import ExtensionRegistry
3637

3738

39+
def _strip_ansi(text: str) -> str:
40+
"""Remove ANSI escape codes from Rich-formatted CLI output."""
41+
return re.sub(r'\x1b\[[0-9;]*m', '', text)
42+
43+
3844
# ===== Fixtures =====
3945

4046

@@ -2441,8 +2447,7 @@ def test_set_priority_changes_priority(self, project_dir, pack_dir):
24412447
result = runner.invoke(app, ["preset", "set-priority", "test-pack", "5"])
24422448

24432449
assert result.exit_code == 0, result.output
2444-
import re as _re
2445-
plain = _re.sub(r'\x1b\[[0-9;]*m', '', result.output)
2450+
plain = _strip_ansi(result.output)
24462451
assert "priority changed: 10 → 5" in plain
24472452

24482453
# Reload registry to see updated value
@@ -2465,8 +2470,7 @@ def test_set_priority_same_value_no_change(self, project_dir, pack_dir):
24652470
result = runner.invoke(app, ["preset", "set-priority", "test-pack", "5"])
24662471

24672472
assert result.exit_code == 0, result.output
2468-
import re as _re
2469-
plain = _re.sub(r'\x1b\[[0-9;]*m', '', result.output)
2473+
plain = _strip_ansi(result.output)
24702474
assert "already has priority 5" in plain
24712475

24722476
def test_set_priority_invalid_value(self, project_dir, pack_dir):

0 commit comments

Comments
 (0)