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_cli.py

View on GitHub
"""CLI command behavior: index auth resolution, enhance error exit codes."""

import json
import os
from types import SimpleNamespace
from unittest.mock import MagicMock, patch

import pytest

try:
    from scripts import ace_cli
except ImportError:
    import ace_cli


def _index_args(project_root):
    return SimpleNamespace(api_url=None, token=None, endpoint=None, project_root=str(project_root))


class TestIndexAuth:
    """Test cmd_index resolves auth via the full session chain, not legacy vars only."""

    def test_index_accepts_augment_session_auth(self, tmp_path):
        """Regression: index must work with AUGMENT_SESSION_AUTH (new session format)."""
        env_data = {"accessToken": "session_token", "tenantURL": "https://session.example.com/"}
        env_vars = {"AUGMENT_SESSION_AUTH": json.dumps(env_data), "ACE_API_URL": "", "ACE_API_TOKEN": ""}

        captured = {}

        class FakeIndexer:
            def __init__(self, project_root, base_url, token):
                captured["base_url"] = base_url
                captured["token"] = token
                self.root = project_root
                self._index = SimpleNamespace(last_indexed=0.0)

            def __enter__(self):
                return self

            def __exit__(self, *exc_info):
                captured["closed"] = True

            def get_blob_names(self):
                return ["blob1", "blob2"]

        with (
            patch("pathlib.Path.home", return_value=tmp_path),
            patch.dict(os.environ, env_vars, clear=False),
            patch.object(ace_cli, "Indexer", FakeIndexer),
            patch.object(
                ace_cli.AceToolClient, "_wait_for_index", lambda self, indexer, names: (names, False), create=True
            ),
        ):
            ace_cli.cmd_index(_index_args(tmp_path))

        assert captured["base_url"] == "https://session.example.com"
        assert captured["token"] == "session_token"
        assert captured["closed"] is True

    def test_index_errors_when_no_auth(self, tmp_path, capsys):
        """Index exits with a clear error when no auth source is configured."""
        env_vars = {"AUGMENT_SESSION_AUTH": "", "ACE_API_URL": "", "ACE_API_TOKEN": ""}

        with (
            patch("pathlib.Path.home", return_value=tmp_path),
            patch.dict(os.environ, env_vars, clear=False),
            pytest.raises(SystemExit) as exc,
        ):
            ace_cli.cmd_index(_index_args(tmp_path))

        assert exc.value.code == 1
        err = json.loads(capsys.readouterr().err)
        assert "authentication" in err["error"].lower()


class TestCmdEnhancePromptError:
    """cmd_enhance_prompt exits 1 when enhancement returns an error dict."""

    def test_error_exits_with_code_1(self):
        args = MagicMock()
        args.no_interactive = True
        args.prompt = "test"
        args.history = ""
        args.history_file = None
        args.project_root = None
        args.api_url = None
        args.token = None
        args.endpoint = "new"

        with (
            patch.dict(os.environ, {"ACE_API_URL": "", "ACE_API_TOKEN": ""}, clear=False),
            patch.object(ace_cli, "AceToolClient") as mock_client,
        ):
            mock_client.return_value.enhance_prompt.return_value = {"error": "test error"}
            with pytest.raises(SystemExit) as exc_info:
                ace_cli.cmd_enhance_prompt(args)
            assert exc_info.value.code == 1
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