Skip to content

Dianel555/DSkills / skills/ace-tool

ace-tool

Verified

Semantic codebase search, code indexing, and prompt enhancement via standalone CLI. Use when: (1) Semantic code search with natural language queries, (2) Code indexing for remote codebase retrieval, (3) Prompt enhancement with codebase context, (4) Before grep/find/glob operations for better accuracy, (5) Complex requirements clarification, (6) Large codebase navigation. Triggers: "search context", "enhance prompt", "find code that", "index project", "clarify requirements". IMPORTANT: Always use ace-tool BEFORE grep/find/glob for semantic-level code location.

tests/test_client_endpoints.py

View on GitHub
"""Endpoint routing, third-party detection, hard errors, and config output."""

import os
from unittest.mock import patch

import pytest
from client import AceToolClient


class TestEndpointResolution:
    """Resolution order: PROMPT_ENHANCER_ENDPOINT > ACE_ENHANCER_ENDPOINT > constructor > default."""

    def test_env_overrides_constructor(self):
        with patch.dict(
            os.environ,
            {
                "PROMPT_ENHANCER_ENDPOINT": "claude",
                "ACE_ENHANCER_ENDPOINT": "",
            },
            clear=False,
        ):
            c = AceToolClient(endpoint="openai")
            assert c.endpoint == "claude"

    def test_new_env_wins_over_legacy_and_constructor(self):
        with patch.dict(
            os.environ,
            {
                "PROMPT_ENHANCER_ENDPOINT": "claude",
                "ACE_ENHANCER_ENDPOINT": "openai",
            },
            clear=False,
        ):
            c = AceToolClient(endpoint="gemini")
            assert c.endpoint == "claude"

    def test_legacy_env_used_when_new_absent(self):
        with patch.dict(
            os.environ,
            {
                "PROMPT_ENHANCER_ENDPOINT": "",
                "ACE_ENHANCER_ENDPOINT": "gemini",
            },
            clear=False,
        ):
            c = AceToolClient()
            assert c.endpoint == "gemini"

    def test_constructor_arg_used_when_no_env(self):
        with patch.dict(
            os.environ,
            {
                "PROMPT_ENHANCER_ENDPOINT": "",
                "ACE_ENHANCER_ENDPOINT": "",
            },
            clear=False,
        ):
            c = AceToolClient(endpoint="openai")
            assert c.endpoint == "openai"

    def test_default_when_nothing_set(self):
        with patch.dict(
            os.environ,
            {
                "PROMPT_ENHANCER_ENDPOINT": "",
                "ACE_ENHANCER_ENDPOINT": "",
            },
            clear=False,
        ):
            c = AceToolClient()
            assert c.endpoint == "new"


class TestIsThirdParty:
    def _client(self, endpoint):
        with patch.dict(
            os.environ,
            {
                "PROMPT_ENHANCER_ENDPOINT": "",
                "ACE_ENHANCER_ENDPOINT": "",
            },
            clear=False,
        ):
            return AceToolClient(endpoint=endpoint)

    def test_codex_is_third_party(self):
        assert self._client("codex")._is_third_party() is True

    def test_claude_is_third_party(self):
        assert self._client("claude")._is_third_party() is True

    def test_new_is_not_third_party(self):
        assert self._client("new")._is_third_party() is False


class TestHardError:
    """Unconfigured third-party endpoints raise immediately, no silent fallback."""

    def _assert_raises(self, endpoint):
        with patch.dict(
            os.environ,
            {
                "PROMPT_ENHANCER_ENDPOINT": "",
                "ACE_ENHANCER_ENDPOINT": "",
                "PROMPT_ENHANCER_BASE_URL": "",
                "PROMPT_ENHANCER_TOKEN": "",
            },
            clear=False,
        ):
            c = AceToolClient(endpoint=endpoint)
            with pytest.raises(ValueError, match="PROMPT_ENHANCER_BASE_URL"):
                c.enhance_prompt("test", "")

    def test_unconfigured_claude_raises(self):
        self._assert_raises("claude")

    def test_unconfigured_codex_raises(self):
        self._assert_raises("codex")


class TestGetConfigExtended:
    def test_get_config_has_extended_fields(self):
        with patch.dict(
            os.environ,
            {
                "ACE_API_URL": "http://test",
                "ACE_API_TOKEN": "tok",
                "PROMPT_ENHANCER_ENDPOINT": "claude",
                "ACE_ENHANCER_ENDPOINT": "",
                "PROMPT_ENHANCER_INCLUDE_SEARCH_CONTEXT": "1",
                "PROMPT_ENHANCER_BASE_URL": "http://third",
                "PROMPT_ENHANCER_TOKEN": "tp",
            },
            clear=False,
        ):
            config = AceToolClient().get_config()
            assert "endpoint_effective" in config
            assert "endpoint_env_ready" in config
            assert "search_context_injection" in config
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall