项目文件夹

文件
kazuki 5463aff45a feat(confidence): implement skill checks in TS + enrich Python, add CLI/install tests
Complete the confidence-check skill's TypeScript implementation (4 of its 5
checks were placeholder stubs that only read context flags) and enrich the
Python ConfidenceChecker with real tech-stack detection, architecture
anti-pattern warnings, and multi-language duplicate search.

Logic is ported from the kazukinakai fork. The dead airis-agent import layer
from the fork is intentionally dropped: the checks work with zero optional
dependencies, and each check still honors its explicit *_complete / *_verified
context-flag override for testing and pre-checked scenarios.

- confidence.ts: implement noDuplicates / architectureCompliant /
  hasOssReference / rootCauseIdentified with project scanning, CLAUDE.md
  tech-stack parsing, and regex-based uncertainty detection. Synced across all
  four tracked skill copies (src CLI source, plugin source, repo-root, .claude).
- confidence.py: add _read_tech_stack and _check_architecture_anti_patterns;
  multi-language (py/ts/js) + content-grep _search_codebase; richer root-cause
  validation. Flat single-class structure preserved; accepts both upstream
  (target_name/root_cause) and fork (feature_name/proposed_technology) keys.
- tests: add test_cli_main, test_doctor, test_execution_init, test_install_mcp,
  test_install_skill, e2e/test_cli_e2e; expand test_confidence to a superset.

All ported tests pass against the existing upstream modules. fork-only
init/check CLI tests and circular full-suite meta-tests were excluded.

NOTE: the confidence-check skill is duplicated across four tracked locations;
a follow-up should collapse these to a single source.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-08 20:40:13 +09:00

125 行
3.8 KiB
Python

"""
Tests for SuperClaude Doctor Command
Tests health check functionality.
"""
from pathlib import Path
from unittest.mock import patch
class TestDoctor:
"""Tests for doctor module"""
def test_run_doctor_returns_dict(self):
"""Test run_doctor returns expected dict structure"""
from superclaude.cli.doctor import run_doctor
result = run_doctor()
assert isinstance(result, dict)
assert "checks" in result
assert "passed" in result
assert isinstance(result["checks"], list)
def test_run_doctor_with_verbose(self):
"""Test run_doctor with verbose flag"""
from superclaude.cli.doctor import run_doctor
result = run_doctor(verbose=True)
assert isinstance(result, dict)
assert "checks" in result
def test_check_pytest_plugin_structure(self):
"""Test pytest plugin check returns proper structure"""
from superclaude.cli.doctor import _check_pytest_plugin
result = _check_pytest_plugin()
assert isinstance(result, dict)
assert "name" in result
assert "passed" in result
assert isinstance(result["passed"], bool)
def test_check_skills_installed_structure(self):
"""Test skills check returns proper structure"""
from superclaude.cli.doctor import _check_skills_installed
result = _check_skills_installed()
assert isinstance(result, dict)
assert "name" in result
assert "passed" in result
assert "details" in result
def test_check_skills_installed_no_skills_dir(self):
"""Test skills check when no skills directory exists"""
from superclaude.cli.doctor import _check_skills_installed
with patch.object(Path, "exists", return_value=False):
result = _check_skills_installed()
# Should pass even without skills (optional)
assert result["passed"] is True
def test_check_configuration_structure(self):
"""Test configuration check returns proper structure"""
from superclaude.cli.doctor import _check_configuration
result = _check_configuration()
assert isinstance(result, dict)
assert "name" in result
assert "passed" in result
def test_check_configuration_success(self):
"""Test configuration check passes with installed package"""
from superclaude.cli.doctor import _check_configuration
result = _check_configuration()
# Should pass since superclaude is installed
assert result["passed"] is True
assert "details" in result
assert any("SuperClaude" in d for d in result["details"])
def test_all_checks_have_required_keys(self):
"""Test all checks return required keys"""
from superclaude.cli.doctor import run_doctor
result = run_doctor()
for check in result["checks"]:
assert "name" in check
assert "passed" in check
class TestDoctorEdgeCases:
"""Edge case tests for doctor"""
def test_run_doctor_passed_reflects_all_checks(self):
"""Test that passed reflects all check statuses"""
from superclaude.cli.doctor import run_doctor
result = run_doctor()
expected_passed = all(check["passed"] for check in result["checks"])
assert result["passed"] == expected_passed
@patch("superclaude.cli.doctor._check_pytest_plugin")
def test_run_doctor_aggregates_failures(self, mock_plugin_check):
"""Test run_doctor properly aggregates check failures"""
mock_plugin_check.return_value = {
"name": "pytest plugin",
"passed": False,
"details": ["Test failure"],
}
from superclaude.cli.doctor import run_doctor
result = run_doctor()
# At least one check should report the mocked failure
assert isinstance(result, dict)