agentleFS
zuhabulzuhabul/Fetchium/CLAUDE.md

Fetchium

CLAUDE.md4 starsChanged 9 months agoApache-2.0View on GitHub

Xcode on this machine sometimes defaults to the iPhoneOS SDK, which breaks C dependency compilation (zstd-sys, rusqlite, ring). This is fixed in .cargo/config.toml which forces SDKROOT to the macOS SDK. If you see "architecture not supported" errors, run: Fetchium is a Cargo workspace with 4 crates: Data flow: CLI command → FetchiumConfig → fetchium-core pipeline → formatted output The CLI (fetchium-cli/src/main.rs) parses args, loads config, then dispatches to one file per command in crates/fetchium-cli/src/commands/. Each command calls into fetchium-core modules.

  • Pipes a download into a shell
  • Installs packages
  • In this repositoryOne other file it gives its agents.

The file

We split this CLAUDE.md into the rules it gives an agent

7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All shared dependencies go in the workspace Cargo.toml under [workspace.dependencies], then reference them with .workspace = true in each …

    line 118
  2. Distinctive:

    Every commit to main MUST follow the Conventional Commits format.

    line 132
  3. Very specific:

    When adding a new public-facing feature, use feat: — this ensures a minor version bump.

    line 162
  4. Very specific:

    When fixing a bug, use fix: — this ensures a patch version bump.

    line 163
  5. Very specific:

    When making a breaking API change, use feat!: or add BREAKING CHANGE: in the footer.

    line 164
  6. Distinctive:

    All secrets are set in repository Settings → Secrets → Actions:

    line 210
  7. Distinctive:

    Before infra changes: read SSOT, apply changes, then update SSOT + endpoint registry in same task.

    line 231

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Build Commands

# Check all crates compile (fast, no linking)
cargo check

# Build the fetchium binary
cargo build -p fetchium-cli

# Build optimized release binary
cargo build -p fetchium-cli --release

# Run the binary
./target/debug/fetchium --help
./target/debug/fetchium doctor

# Run all tests
cargo test

# Run tests for a specific crate
cargo test -p fetchium-core
cargo test -p fetchium-cli

# Run a single test by name
cargo test -p fetchium-core extract::layer1::tests::extract_simple_page

# Lint (zero warnings policy — treat warnings as errors in CI)
cargo clippy -- -D warnings

# Format
cargo fmt

# Generate docs
cargo doc --open

macOS SDK Note

Xcode on this machine sometimes defaults to the iPhoneOS SDK, which breaks C dependency compilation (zstd-sys, rusqlite, ring). This is fixed in .cargo/config.toml which forces SDKROOT to the macOS SDK. If you see "architecture not supported" errors, run:

export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)

Architecture Overview

Fetchium is a Cargo workspace with 4 crates:

CrateRole
fetchium-coreAll algorithms: search, extract, rank, validate, cache, AI, intelligence
fetchium-cliThe fetchium binary — clap derive CLI, delegates everything to fetchium-core
fetchium-mcpMCP server (Phase 4) — exposes fetchium-core as Model Context Protocol tools
fetchium-apiREST API server via axum (Phase 4)

Data flow: CLI command → FetchiumConfig → fetchium-core pipeline → formatted output

The CLI (fetchium-cli/src/main.rs) parses args, loads config, then dispatches to one file per command in crates/fetchium-cli/src/commands/. Each command calls into fetchium-core modules.

fetchium-core Module Map

The retrieval pipeline is implemented across these modules. Foundational types/config:

  • types.rs — Shared data types: AgentSearchResult, SearchResult, ResultItem, Segment, Finding, Source, EvidenceGraph, CepLayer, PdsTier, ResourceTier, BackendId, etc.
  • error.rs — FetchiumError, StructuredError, ErrorKind, FetchiumResult<T>
  • config.rs — FetchiumConfig loaded from ~/.fetchium/config.toml with env var overrides; includes detect_resource_tier() and data_dir()
  • http/client.rs — HttpClient (reqwest with pooling/retries)
  • resource/mod.rs — detect_tier() delegating to FetchiumConfig::detect_resource_tier()

The core pipeline runs in this order:

search/ → extract/ → rank/ → token/ → validate/ → citation/ → output/
                                                              ↑
                                             research/ ──────┘

Additional modules: ai/, intelligence/, cache/, index/, plugin/, privacy/, collab/, domain/, youtube/, setup/.

Optional Feature Flags (fetchium-core)

Heavy optional dependencies are gated behind features:

FeatureCratePhase
headlesschromiumoxidePhase 2
embeddingsort (ONNX Runtime)Phase 5
vector-searchusearchPhase 5
mcprmcpPhase 4
llamallama-cpp-2Phase 4

Build with a feature: cargo build -p fetchium-core --features headless

Design Reference

  • prd.md — Product Requirements Document describing the algorithms and intended behaviors.

Conventions: run cargo build && cargo test && cargo clippy after changes; keep files focused; put shared dependencies in the workspace Cargo.toml (reference with .workspace = true per crate, never duplicate a version already in the workspace); document public APIs with /// comments.

Key PRD Algorithms

The PRD (§8) defines 17 novel algorithms that don't exist in other tools:

  • CEP (Content Extraction Protocol) — 5-layer cascade: CSS selectors → readability → headless JS → PDF → screenshot OCR
  • QATBE (Query-Aware Token-Budgeted Extraction) — BM25-scored segment ranking + greedy knapsack packing within token budget
  • SCS (Semantic Content Segmentation) — 8 segment types with type-aware token efficiency
  • PDS (Progressive Detail Streaming) — 4 tiers: key_facts (~200 tok), summary (~1000), detailed (~5000), complete
  • HyperFusion — 8-signal ranking: BM25 + semantic + temporal + authority + evidence + diversity + depth + consensus
  • QADD (Query-Aware DOM Distillation) — 5-step DOM pruning for 10-20x token reduction
  • AMRS (Adaptive Multi-Agent Research Swarm) — 4 agent types via tokio channels
  • PIE (Persistent Intelligence Engine) — Cross-session learning via SQLite (source trust, failure patterns, query prediction)
  • RAR (Retry-and-Refine) — 5-checkpoint self-correction loop

Adding New Dependencies

All shared dependencies go in the workspace Cargo.toml under [workspace.dependencies], then reference them with .workspace = true in each crate's Cargo.toml. Never add a version number directly in a crate's Cargo.toml for anything already in the workspace.


Version Control & Release Pipeline

CRITICAL — Read before making any changes

This project uses fully automated semantic versioning via release-please.

All version bumping, tagging, changelog generation, and publishing is automatic.

Conventional Commits — REQUIRED

Every commit to main MUST follow the Conventional Commits format. This is enforced by a PR title lint check in CI and a local git hook.

<type>(<scope>): <description>

[optional body]

[optional footer: BREAKING CHANGE: ...]

Types and their version impact:

TypeVersion bumpExample
featminor (1.0.0 → 1.1.0)feat: add cross-lingual query expansion
fixpatch (1.0.0 → 1.0.1)fix: handle empty query gracefully
feat! or BREAKING CHANGE:MAJOR (1.0.0 → 2.0.0)feat!: redesign config file format
perfpatchperf: cache BM25 term frequencies
docsno releasedocs: update rate limit table
refactorno releaserefactor: extract snippet logic
choreno releasechore: update dependencies
testno releasetest: add fuzzing for URL parser
cino releaseci: fix Windows build step

Rules for AI coding agents

  1. NEVER manually edit the version field in Cargo.toml — release-please does this automatically.
  2. NEVER manually create git tags — release-please creates them when the Release PR is merged.
  3. NEVER run npm publish manually — the release workflow does this automatically.
  4. ALWAYS write commit messages in Conventional Commits format — this is the only way to trigger version bumps.
  5. When adding a new public-facing feature, use feat: — this ensures a minor version bump.
  6. When fixing a bug, use fix: — this ensures a patch version bump.
  7. When making a breaking API change, use feat!: or add BREAKING CHANGE: in the footer.
  8. The chore:, refactor:, docs:, test:, ci: types do NOT trigger a release — use them for non-user-facing changes.

How the pipeline works

You commit feat: or fix: → push to main
        ↓
release-please opens/updates a "Release PR"
(title: "chore(main): release 1.2.0")
        ↓
Team merges the Release PR
        ↓
release-please creates:
  - git tag v1.2.0
  - GitHub Release with changelog
        ↓
release.yml workflow fires:
  ├─ Build: Linux x64/arm64, macOS x64/arm64, Windows x64
  ├─ Attach .tar.gz/.zip + SHA256 to GitHub Release
  ├─ Publish npm package (fetchium @ 1.2.0)
  ├─ Update Homebrew formula (zuhabul/homebrew-fetchium)
  └─ Summary posted to GitHub Actions

Setting up locally (one-time, for humans)

sh scripts/setup-dev.sh   # installs commit-msg and pre-commit git hooks

Distribution channels

ChannelInstall commandStatus
Cargo (git)cargo install --git https://github.com/zuhabul/Fetchium fetchium-cli✅ Works
From sourcecargo build -p fetchium-cli --release✅ Works
GitHub Releasescurl -sSf https://install.fetchium.com | sh✅ All 5 platforms
crates.iocargo install fetchium-cli✅ Published v1.0.0
npm / npxnpm install -g fetchium-cli / npx fetchium-cli --help✅ Published v1.0.0
Homebrewbrew install zuhabul/fetchium/fetchium✅ Tap live
PyPI (LangChain)pip install fetchium-langchain✅ Published v1.0.0
PyPI (CrewAI)pip install fetchium-crewai✅ Published v1.0.0

Required GitHub Secrets

All secrets are set in repository Settings → Secrets → Actions:

SecretPurposeStatus
NPM_TOKENPublish to npmjs.com✅ Set
HOMEBREW_TAP_TOKENPush to zuhabul/homebrew-fetchium✅ Set
CARGO_REGISTRY_TOKENPublish to crates.io✅ Set
PYPI_API_TOKENPublish Python adapters to PyPI✅ Set

One-time setup checklist

  • Create GitHub repository zuhabul/homebrew-fetchium with a Formula/ directory
  • Add NPM_TOKEN secret
  • Add HOMEBREW_TAP_TOKEN secret (GitHub PAT with repo scope on zuhabul/homebrew-fetchium)
  • Add CARGO_REGISTRY_TOKEN secret
  • Add PYPI_API_TOKEN secret
  • First release: v1.0.0 published to all channels

Global Infrastructure SSOT

  • Canonical infrastructure source: /home/echo/INFRASTRUCTURE_SOURCE_OF_TRUTH.md
  • Endpoint registry (machine-friendly): /home/echo/INFRASTRUCTURE_ENDPOINTS.tsv
  • Before infra changes: read SSOT, apply changes, then update SSOT + endpoint registry in same task.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.