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

View on GitHub
"""Codex endpoint: Responses API output parsing and model resolution."""

import os
from unittest.mock import patch

import pytest
from client import AceToolClient


class TestExtractCodexOutputText:
    def _extract(self, api_response):
        return AceToolClient._extract_codex_output_text(api_response)

    def test_final_answer_priority(self):
        resp = {
            "output": [
                {"type": "message", "phase": "thinking", "content": [{"type": "output_text", "text": "thinking text"}]},
                {
                    "type": "message",
                    "phase": "final_answer",
                    "content": [{"type": "output_text", "text": "final text"}],
                },
            ]
        }
        assert self._extract(resp) == "final text"

    def test_multi_part_concat(self):
        resp = {
            "output": [
                {
                    "type": "message",
                    "phase": "final_answer",
                    "content": [
                        {"type": "output_text", "text": "part1"},
                        {"type": "output_text", "text": "part2"},
                    ],
                },
            ]
        }
        assert self._extract(resp) == "part1\npart2"

    def test_refusal_raises(self):
        resp = {
            "output": [
                {"type": "message", "content": [{"type": "refusal", "refusal": "I cannot do that"}]},
            ]
        }
        with pytest.raises(RuntimeError, match="Codex API refusal"):
            self._extract(resp)

    def test_refusal_plus_text_returns_text(self):
        resp = {
            "output": [
                {
                    "type": "message",
                    "content": [
                        {"type": "refusal", "refusal": "refused"},
                        {"type": "output_text", "text": "actual output"},
                    ],
                },
            ]
        }
        assert self._extract(resp) == "actual output"

    def test_no_output_raises(self):
        with pytest.raises(RuntimeError, match="no output_text"):
            self._extract({"output": []})

    def test_empty_text_ignored(self):
        resp = {
            "output": [
                {
                    "type": "message",
                    "content": [
                        {"type": "output_text", "text": "  "},
                        {"type": "output_text", "text": "real"},
                    ],
                },
            ]
        }
        assert self._extract(resp) == "real"

    def test_null_content_raises(self):
        resp = {"output": [{"type": "message", "content": None}]}
        with pytest.raises(RuntimeError, match="no output_text"):
            self._extract(resp)


class TestCodexModelResolution:
    def test_codex_default_model(self):
        with patch.dict(
            os.environ,
            {
                "PROMPT_ENHANCER_ENDPOINT": "",
                "ACE_ENHANCER_ENDPOINT": "",
                "PROMPT_ENHANCER_MODEL": "",
            },
            clear=False,
        ):
            c = AceToolClient(endpoint="codex")
            from templates import DEFAULT_CODEX_MODEL

            assert c._get_third_party_model() == DEFAULT_CODEX_MODEL
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