# anysearch-ai/anysearch-skill architecture

> Architecture diagram of the GitHub repository anysearch-ai/anysearch-skill, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anysearch-ai/anysearch-skill
- Repository: https://github.com/anysearch-ai/anysearch-skill

## Overview

1. **What this repo is**
   - This is a **packaged AI-agent skill**, not a server or application backend.
   - Its purpose is to give agents a unified interface for **AnySearch API** capabilities: general search, vertical/domain search, batch search, and page content extraction.

2. **Main architectural shape**
   - The repo is organized as a **thin client layer** around an external search service.
   - The core behavior lives in **runtime-specific CLI entrypoints** under `scripts/`, with a small amount of shared spec/config data.

3. **Runtime adapters**
   - There are four equivalent command-line frontends:
     - `scripts/anysearch_cli.py` for Python
     - `scripts/anysearch_cli.js` for Node.js
     - `scripts/anysearch_cli.ps1` for PowerShell
     - `scripts/anysearch_cli.sh` for Bash
   - These are not separate products; they are **alternate adapters for different execution environments**.
   - The repo expects one of them to be chosen as the active runtime for the host agent environment.

4. **Active runtime selection**
   - `runtime.conf.example` shows that the skill records a preferred runtime in `runtime.conf`.
   - The README defines a **priority order** for choosing a runtime: Python, then Node.js, then Shell, with PowerShell as the Windows shell path.
   - This is a deployment-time concern: the skill is designed to run wherever the agent platform supports one of these interpreters.

5. **Command surface**
   - The CLIs expose a small, consistent set of actions:
     - `doc` for capability/verification output
     - `search` for single-query search
     - `batch_search` for parallel query execution
     - `extract` for fetching and returning full-page content
   - The `extract` path is special in that it returns **Markdown directly**, rather than requiring a separate formatting step.

6. **External service boundary**
   - The key runtime boundary is the **AnySearch API service** at `anysearch.com`.
   - The repository itself holds no search index, crawl store, or document database; it is a **request/response client** to that external service.
   - API access is optional but recommended, and anonymous access is supported with lower limits.

7. **Authentication and configuration**
   - API credentials are configured through:
     - CLI flag `--api_key`
     - `.env` file from `.env.example`
     - environment variable `ANYSEARCH_API_KEY`
     - anonymous fallback if none is provided
   - This creates a clear config precedence chain and separates secrets from code.

8. **Shared metadata and generation assets**
   - `scripts/shared/constants.json` and `scripts/shared/doc_spec.md` suggest shared, runtime-agnostic content used by the CLIs.
   - `scripts/generate.py` likely produces or synchronizes repeated command/help/documentation material across the different runtime implementations.
   - That indicates a **single source of truth** for shared behavior, even though multiple language frontends exist.

9. **Packaging and installation boundary**
   - The repo is meant to be installed into an **agent skill directory** and loaded by agent tooling.
   - `SKILL.md`, `README.md`, `.env.example`, and runtime config files define the skill’s operational contract rather than an application UI.
   - `.gitignore` keeps environment secrets and runtime detection output out of source control.

10. **End-to-end data flow**
   - An agent invokes the chosen CLI runtime.
   - The CLI reads runtime/config state and resolves the API key from the configured precedence chain.
   - The CLI sends a search or extraction request to the AnySearch service.
   - The service returns results or page content.
   - The CLI emits machine-readable output to the agent, with extraction already normalized to Markdown.

11. **Important architectural conclusion**
   - The repo is best diagrammed as a **multi-runtime client wrapper** around one external API, with shared documentation/spec assets and minimal local state.
   - There are no internal subsystems such as databases, queues, background jobs, or web endpoints; the main boundaries are **runtime selection**, **configuration/auth**, and **external API communication**.

Main entry points: [`scripts/anysearch_cli.py`](https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/anysearch_cli.py) (Python CLI), [`scripts/anysearch_cli.js`](https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/anysearch_cli.js) (Node CLI), [`README.md`](https://github.com/anysearch-ai/anysearch-skill/blob/main/README.md) (README), [`scripts/anysearch_cli.ps1`](https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/anysearch_cli.ps1) (PowerShell CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_runtime["Runtime adapters"]
  node_node_py_cli["Python CLI<br/>runtime adapter<br/>[anysearch_cli.py]"]
  node_node_js_cli["Node CLI<br/>runtime adapter<br/>[anysearch_cli.js]"]
  node_node_ps_cli["PowerShell CLI<br/>runtime adapter<br/>[anysearch_cli.ps1]"]
  node_node_sh_cli["Shell CLI<br/>runtime adapter<br/>[anysearch_cli.sh]"]
  node_node_doc_action{{"Doc command<br/>cli action"}}
  node_node_search_action{{"Search command<br/>cli action"}}
  node_node_batch_action{{"Batch search<br/>cli action"}}
  node_node_extract_action{{"Extract command<br/>cli action"}}
end

subgraph group_group_shared["Shared assets"]
  node_node_generate["Generator<br/>sync tool<br/>[generate.py]"]
  node_node_constants["Constants<br/>shared config<br/>[constants.json]"]
  node_node_doc_spec["Doc spec<br/>shared spec<br/>[doc_spec.md]"]
end

subgraph group_group_config["Packaging & config"]
  node_node_readme["README<br/>operator guide<br/>[README.md]"]
  node_node_skill["Skill doc<br/>packaging manifest<br/>[SKILL.md]"]
  node_node_runtime_example["Runtime example<br/>runtime config"]
  node_node_env_example["Env example<br/>secret config<br/>[.env.example]"]
  node_node_gitignore["Git ignore<br/>repo hygiene<br/>[.gitignore]"]
end

subgraph group_group_external["External service"]
  node_node_anysearch_api[("AnySearch API<br/>external search api")]
end

node_node_readme -->|"runtime priority"| node_node_runtime_example
node_node_readme -->|"prefer"| node_node_py_cli
node_node_readme -->|"fallback"| node_node_js_cli
node_node_readme -->|"fallback"| node_node_sh_cli
node_node_readme -->|"windows path"| node_node_ps_cli
node_node_skill -->|"operates with"| node_node_readme
node_node_env_example -->|"api key"| node_node_anysearch_api
node_node_runtime_example -->|"selects"| node_node_py_cli
node_node_runtime_example -->|"selects"| node_node_js_cli
node_node_runtime_example -->|"selects"| node_node_sh_cli
node_node_runtime_example -->|"selects"| node_node_ps_cli
node_node_py_cli -->|"reads"| node_node_constants
node_node_py_cli -->|"reads"| node_node_doc_spec
node_node_js_cli -->|"reads"| node_node_constants
node_node_js_cli -->|"reads"| node_node_doc_spec
node_node_ps_cli -->|"reads"| node_node_constants
node_node_sh_cli -->|"reads"| node_node_doc_spec
node_node_generate -->|"syncs"| node_node_constants
node_node_generate -->|"syncs"| node_node_doc_spec
node_node_py_cli -->|"exposes"| node_node_doc_action
node_node_py_cli -->|"exposes"| node_node_search_action
node_node_py_cli -->|"exposes"| node_node_batch_action
node_node_py_cli -->|"exposes"| node_node_extract_action
node_node_js_cli -->|"exposes"| node_node_doc_action
node_node_js_cli -->|"exposes"| node_node_search_action
node_node_js_cli -->|"exposes"| node_node_batch_action
node_node_js_cli -->|"exposes"| node_node_extract_action
node_node_ps_cli -->|"exposes"| node_node_doc_action
node_node_ps_cli -->|"exposes"| node_node_search_action
node_node_ps_cli -->|"exposes"| node_node_extract_action
node_node_sh_cli -->|"exposes"| node_node_search_action
node_node_sh_cli -->|"exposes"| node_node_batch_action
node_node_sh_cli -->|"exposes"| node_node_extract_action
node_node_search_action -->|"request"| node_node_anysearch_api
node_node_batch_action -->|"request"| node_node_anysearch_api
node_node_extract_action -->|"fetch page"| node_node_anysearch_api
node_node_doc_action -.->|"verify"| node_node_anysearch_api
node_node_gitignore -->|"protects"| node_node_env_example

click node_node_py_cli "https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/anysearch_cli.py"
click node_node_js_cli "https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/anysearch_cli.js"
click node_node_ps_cli "https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/anysearch_cli.ps1"
click node_node_sh_cli "https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/anysearch_cli.sh"
click node_node_generate "https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/generate.py"
click node_node_constants "https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/shared/constants.json"
click node_node_doc_spec "https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/shared/doc_spec.md"
click node_node_readme "https://github.com/anysearch-ai/anysearch-skill/blob/main/README.md"
click node_node_skill "https://github.com/anysearch-ai/anysearch-skill/blob/main/SKILL.md"
click node_node_runtime_example "https://github.com/anysearch-ai/anysearch-skill/blob/main/runtime.conf.example"
click node_node_env_example "https://github.com/anysearch-ai/anysearch-skill/blob/main/.env.example"
click node_node_gitignore "https://github.com/anysearch-ai/anysearch-skill/blob/main/.gitignore"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_py_cli,node_node_js_cli,node_node_ps_cli,node_node_sh_cli,node_node_doc_action,node_node_search_action,node_node_batch_action,node_node_extract_action toneBlue
class node_node_generate,node_node_constants,node_node_doc_spec toneAmber
class node_node_readme,node_node_skill,node_node_runtime_example,node_node_env_example,node_node_gitignore toneMint
class node_node_anysearch_api toneRose
```

## Components

### Runtime adapters

Equivalent CLI frontends for different execution environments.

- [Python CLI](https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/anysearch_cli.py): runtime adapter · Primary CLI entrypoint for Python environments. · `scripts/anysearch_cli.py`
- [Node CLI](https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/anysearch_cli.js): runtime adapter · CLI entrypoint for Node.js environments. · `scripts/anysearch_cli.js`
- [PowerShell CLI](https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/anysearch_cli.ps1): runtime adapter · CLI entrypoint for Windows PowerShell environments. · `scripts/anysearch_cli.ps1`
- [Shell CLI](https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/anysearch_cli.sh): runtime adapter · CLI entrypoint for Bash-compatible environments. · `scripts/anysearch_cli.sh`
- **Doc command**: cli action · Capability and verification output path exposed by each runtime.
- **Search command**: cli action · Single-query search path exposed by each runtime.
- **Batch search**: cli action · Parallel multi-query search path exposed by each runtime.
- **Extract command**: cli action · Fetches page content and returns Markdown directly.

### Shared assets

Common spec and generated material reused by all runtimes.

- [Generator](https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/generate.py): sync tool · Builds or synchronizes repeated command/help/documentation material. · `scripts/generate.py`
- [Constants](https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/shared/constants.json): shared config · Runtime-agnostic constants used by the CLIs. · `scripts/shared/constants.json`
- [Doc spec](https://github.com/anysearch-ai/anysearch-skill/blob/main/scripts/shared/doc_spec.md): shared spec · Shared command and documentation specification. · `scripts/shared/doc_spec.md`

### Packaging & config

Repository-level files that define installation, runtime selection, and secret handling.

- [README](https://github.com/anysearch-ai/anysearch-skill/blob/main/README.md): operator guide · Human-facing overview and runtime selection guidance. · `README.md`
- [Skill doc](https://github.com/anysearch-ai/anysearch-skill/blob/main/SKILL.md): packaging manifest · Skill-level operational contract for agent tooling. · `SKILL.md`
- [Runtime example](https://github.com/anysearch-ai/anysearch-skill/blob/main/runtime.conf.example): runtime config · Example preferred-runtime configuration. · `runtime.conf.example`
- [Env example](https://github.com/anysearch-ai/anysearch-skill/blob/main/.env.example): secret config · Example API-key and environment configuration. · `.env.example`
- [Git ignore](https://github.com/anysearch-ai/anysearch-skill/blob/main/.gitignore): repo hygiene · Excludes secrets and generated runtime state from source control. · `.gitignore`

### External service

The AnySearch API boundary outside this repository.

- **AnySearch API**: external search api · External request/response service for search and content extraction.

## Connections

- README → Runtime example: runtime priority · Documents how the preferred runtime is selected.
- README → Python CLI: prefer · Python is the first runtime choice when available.
- README → Node CLI: fallback · Node.js is the second runtime choice.
- README → Shell CLI: fallback · Shell is the next fallback runtime.
- README → PowerShell CLI: windows path · PowerShell is the Windows shell option.
- Skill doc → README: operates with · Defines the skill contract alongside the README.
- Env example → AnySearch API: api key · Provides one source of API credential configuration.
- Runtime example → Python CLI: selects · Preferred runtime resolves to a concrete CLI adapter.
- Runtime example → Node CLI: selects · Preferred runtime resolves to a concrete CLI adapter.
- Runtime example → Shell CLI: selects · Preferred runtime resolves to a concrete CLI adapter.
- Runtime example → PowerShell CLI: selects · Preferred runtime resolves to a concrete CLI adapter.
- Python CLI → Constants: reads · Consumes shared constants for behavior and output.
- Python CLI → Doc spec: reads · Uses the shared documentation/spec definition.
- Node CLI → Constants: reads · Consumes shared constants for behavior and output.
- Node CLI → Doc spec: reads · Uses the shared documentation/spec definition.
- PowerShell CLI → Constants: reads · Consumes shared constants for behavior and output.
- Shell CLI → Doc spec: reads · Uses the shared documentation/spec definition.
- Generator → Constants: syncs · Keeps generated behavior aligned with shared constants.
- Generator → Doc spec: syncs · Keeps generated help/spec material aligned.
- Python CLI → Doc command: exposes · Provides the doc capability through the runtime CLI.
- Python CLI → Search command: exposes · Provides single-query search through the runtime CLI.
- Python CLI → Batch search: exposes · Provides batch search through the runtime CLI.
- Python CLI → Extract command: exposes · Provides Markdown extraction through the runtime CLI.
- Node CLI → Doc command: exposes · Provides the doc capability through the runtime CLI.
- Node CLI → Search command: exposes · Provides single-query search through the runtime CLI.
- Node CLI → Batch search: exposes · Provides batch search through the runtime CLI.
- Node CLI → Extract command: exposes · Provides Markdown extraction through the runtime CLI.
- PowerShell CLI → Doc command: exposes · Provides the doc capability through the runtime CLI.
- PowerShell CLI → Search command: exposes · Provides single-query search through the runtime CLI.
- PowerShell CLI → Extract command: exposes · Provides Markdown extraction through the runtime CLI.
- Shell CLI → Search command: exposes · Provides single-query search through the runtime CLI.
- Shell CLI → Batch search: exposes · Provides batch search through the runtime CLI.
- Shell CLI → Extract command: exposes · Provides Markdown extraction through the runtime CLI.
- Search command → AnySearch API: request · Search commands send queries to the external API.
- Batch search → AnySearch API: request · Batch search sends multiple queries to the external API.
- Extract command → AnySearch API: fetch page · Extraction retrieves page content from the external service.
- Doc command → AnySearch API: verify · Capability output may confirm service availability and behavior.
- Git ignore → Env example: protects · Keeps local secret and environment artifacts out of source control.
