Skip to content

Dianel555/DSkills / skills/exa

High-precision semantic search and content retrieval via Exa API. Use when: (1) Deep research requiring semantic understanding, (2) Code documentation and examples lookup, (3) Company/professional research, (4) AI-powered comprehensive research tasks, (5) URL content extraction with structured output. Triggers: "research", "find papers", "code examples", "company info", "LinkedIn profiles", "deep analysis". Differentiator: Exa excels at semantic/neural search while grok-search is better for real-time news and general web content.

scripts/exa_cli/config.py

View on GitHub
"""Configuration singleton + .env loader for exa_cli."""

from __future__ import annotations

import os
from pathlib import Path

DEFAULT_API_URL = "https://api.exa.ai"


def skill_root() -> Path:
    return Path(__file__).resolve().parents[2]


def load_dotenv(env_path: Path | None = None) -> bool:
    """Load .env using a documented subset:

    - KEY=VALUE on a single line.
    - Outer single/double quotes around VALUE are stripped (no escape decoding).
    - Whole-line comments starting with `#` are ignored.
    - Inline comments, multi-line values, ${VAR} interpolation, and \\n escapes
      are NOT supported (the `#` after a value is preserved literally).
    - Existing process env vars are NOT overwritten.
    """
    root = skill_root()
    search_paths = (
        [env_path]
        if env_path
        else [
            root / ".env",  # canonical default (found from any cwd)
            root / "scripts" / ".env",  # legacy pre-migration location
        ]
    )
    for path in search_paths:
        if path is None or not path.exists():
            continue
        try:
            with open(path, encoding="utf-8") as f:
                for raw in f:
                    line = raw.strip()
                    if not line or line.startswith("#"):
                        continue
                    if "=" not in line:
                        continue
                    key, _, value = line.partition("=")
                    key = key.strip()
                    value = value.strip()
                    if (value.startswith('"') and value.endswith('"')) or (
                        value.startswith("'") and value.endswith("'")
                    ):
                        value = value[1:-1]
                    if key and key not in os.environ:
                        os.environ[key] = value
            return True
        except OSError:
            continue
    return False


class Config:
    _instance: Config | None = None

    def __new__(cls) -> Config:
        if cls._instance is None:
            cls._instance = super().__new__(cls)
            cls._instance._override_url = None
            cls._instance._override_key = None
            cls._instance._override_max_retry_wait = None
            cls._instance._override_auth_scheme = None
        return cls._instance

    @classmethod
    def _reset_for_testing(cls) -> None:
        if cls._instance is not None:
            cls._instance._override_auth_scheme = None
        cls._instance = None

    def set_overrides(
        self,
        api_url: str | None = None,
        api_key: str | None = None,
        max_retry_wait: int | None = None,
        auth_scheme: str | None = None,
    ) -> None:
        if api_url is not None:
            self._override_url = api_url
        if api_key is not None:
            self._override_key = api_key
        if max_retry_wait is not None:
            self._override_max_retry_wait = max_retry_wait
        if auth_scheme is not None:
            self._override_auth_scheme = auth_scheme

    @property
    def debug_enabled(self) -> bool:
        return os.getenv("EXA_DEBUG", "false").lower() in ("true", "1", "yes")

    @property
    def exa_api_url(self) -> str:
        if self._override_url:
            return self._override_url.rstrip("/")
        return os.getenv("EXA_API_URL", DEFAULT_API_URL).rstrip("/")

    @property
    def exa_api_key(self) -> str:
        if self._override_key:
            return self._override_key
        key = os.getenv("EXA_API_KEY")
        if not key:
            raise ValueError("EXA_API_KEY not configured. Set environment variable or use --api-key")
        return key

    @property
    def max_retry_wait(self) -> int:
        if self._override_max_retry_wait is not None:
            return self._override_max_retry_wait
        env_val = os.getenv("EXA_MAX_RETRY_WAIT")
        if env_val:
            try:
                parsed = int(env_val)
                if parsed > 0:
                    return parsed
            except ValueError:
                pass
        return 60

    @property
    def auth_scheme(self) -> str:
        if self._override_auth_scheme is not None:
            return self._override_auth_scheme
        env_val = os.getenv("EXA_AUTH_SCHEME")
        if env_val and env_val in ("x-api-key", "bearer"):
            return env_val
        return "x-api-key"

    @staticmethod
    def mask_api_key(key: str) -> str:
        if not key or len(key) <= 8:
            return "***"
        return f"{key[:4]}{'*' * (len(key) - 8)}{key[-4:]}"

    def get_config_info(self) -> dict:
        try:
            api_url = self.exa_api_url
            api_key_masked = self.mask_api_key(self.exa_api_key)
            config_status = "OK"
        except ValueError as exc:
            api_url = self.exa_api_url
            api_key_masked = "Not configured"
            config_status = f"Error: {exc}"
        return {
            "EXA_API_URL": api_url,
            "EXA_API_KEY": api_key_masked,
            "EXA_DEBUG": self.debug_enabled,
            "auth_scheme": self.auth_scheme,
            "config_status": config_status,
        }
rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file).Stars: 198kUpdated Claude CodeCodexUnverifiedInstall
doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.Stars: 198kUpdated Claude CodeCodexVerifiedInstall