discovery

A description of how the Ion engine finds agent definition files. It searches project and user folders, with project files taking priority when filenames match.

In plain words
What is it for?
Use it when configuring or debugging agent loading. Agent files are Markdown files found in .ion/agents, the user's Ion agents folder, and configured extra directories.
Why use it?
It explains which agent definition is loaded when several files have the same name and how extra search folders or recursion affect discovery.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/dsswift/ion/discovery
Clone the repo
git clone --depth 1 https://github.com/dsswift/ion
Per session 10 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 599 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00010 $0.00599
Opus 5 $0.00005 $0.00300
Sonnet 5 $0.00002 $0.00120
Haiku 4.5 $0.00001 $0.00060

Measured 2d ago against content hash 7a8120633b65, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

discovery scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/agents/discovery.md · 85 lines

How it starts

The opening of the file, as written. The whole thing — 85 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Agent Discovery

The engine discovers agents by walking directories in a defined order. Project-level agents override user-level agents with the same name.

Discovery order

Directories are scanned in this order. The first directory wins for any given agent name.

Priority Directory Description
1 .ion/agents/ Project-specific agents, relative to working directory
2 ~/.ion/agents/ User-level agents, shared across all projects
3 Extra directories Additional paths specified via config

Walk options

Discovery behavior is controlled by WalkOptions:

type WalkOptions struct {
    IncludeUserDir    bool     // scan ~/.ion/agents/
    IncludeProjectDir bool     // scan .ion/agents/ relative to cwd
    ExtraDirs         []string // additional directories
    Recursive         bool     // walk subdirectories
}

When Recursive is true (default for zero value), the walker descends into subdirectories. Only .md files are collected.

Deduplication

Agents are deduplicated by filename stem. If both .ion/agents/reviewer.md and ~/.ion/agents/reviewer.md exist, only the project-level file is loaded because project directories are scanned first.

This means project agents shadow user agents of the same name. Rename the project file if you need both.

Discovery process

  1. Walk -- Collect .md file paths from all configured directories.
  2. Parse -- Load each file and parse the frontmatter into an AgentDef.
  3. Build graph -- Assemble agent definitions into a parent-child graph with cycle detection.

Files that fail to parse (missing frontmatter fences, read errors) are logged and skipped. They do not block discovery of other agents.

graph, err := agentdiscovery.Discover(WalkOptions{
    IncludeProjectDir: true,
    IncludeUserDir:    true,
})

Directory structure examples

Simple flat layout:

~/.ion/agents/
  code-reviewer.md
  summarizer.md
  translator.md

Read the full file on GitHub · 85 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 85 lines · 10 tokens per session scan A 7a8120633b65

Subscribe to this mod's changes

discovery is an agent published in the GitHub repository dsswift/ion (4 stars, last pushed 2d ago), licensed MIT. It adds 10 tokens to every session and 599 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.