mihoro
AGENTS.md313 starsChanged 10 months agoMITView on GitHub
Notes for agents working in this repo. Mihoro is a Rust CLI for managing Mihomo on Linux. It handles: - Initializing and updating the Mihomo binary - Managing remote configuration subscriptions (YAML configs) - Bootstrapping config interactively via mihoro init - Applying config overrides via TOML (local settings override remote YAML) - Managing the per-user systemd service - Managing optional web dashboard assets - Exporting proxy environment variables for shells - Self-upgrading to the latest GitHub release From .github/workflows/ci.yml:
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,843 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
We split this AGENTS.md into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 79
Only mihomo_config fields are overridden.
- Very specific: line 93
All methods return anyhow::Result<T> for consistent error handling
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.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.
Files
AGENTS.md
Notes for agents working in this repo.
Project overview
Mihoro is a Rust CLI for managing Mihomo on Linux. It handles:
- Initializing and updating the Mihomo binary
- Managing remote configuration subscriptions (YAML configs)
- Bootstrapping config interactively via
mihoro init - Applying config overrides via TOML (local settings override remote YAML)
- Managing the per-user systemd service
- Managing optional web dashboard assets
- Exporting proxy environment variables for shells
- Self-upgrading to the latest GitHub release
Build and development commands
# Build
cargo build
cargo build --release
# Run
cargo run -- [args]
# Check code
cargo check --all-targets
# Format
cargo fmt --all
cargo fmt --all -- --check # Verify formatting
# Lint
cargo clippy
# Run tests
cargo test
# Local installation
cargo install --path .CI commands
From .github/workflows/ci.yml:
cargo fmt --all -- --check
cargo clippy
cargo check --all-targetsArchitecture
Module structure
src/
├── main.rs # CLI entry point, Clap parsing, command dispatch
├── init.rs # `mihoro init` flow: bootstrap config, prompt for subscription URL, stage reporting
├── mihoro.rs # Core Mihoro struct with init/update/apply/uninstall helpers
├── config.rs # Config (TOML) and MihomoConfig parsing with serde defaults
├── ui.rs # Dashboard source selection and UI asset installation
├── resolve_mihomo_bin.rs # Resolve/download mihomo release artifacts for supported architectures
├── utils.rs # File I/O, download, gzip extraction, base64 decoding
├── systemctl.rs # Fluent wrapper around systemctl commands
├── cmd.rs # Clap derive enums for CLI structure
├── proxy.rs # Shell-specific proxy env var generation
├── upgrade.rs # Self-upgrade functionality using self_update crate
└── cron.rs # Auto-update cron job managementKey pieces
- Config override system: merges local TOML overrides with remote YAML configs
Config: Main TOML config at~/.config/mihoro.tomlMihomoConfig: Mihomo-specific settings using#[serde(default)]extensivelyMihomoYamlConfig: Parses remote YAML with#[serde(flatten)]to preserve unrecognized fields- Only mihomo_config fields are overridden; remote YAML fields pass through unchanged
- Systemctl builder: method chaining for systemd commands
Systemctl::new().start("mihomo.service").execute()? - Init flow:
mihoro initis the main onboarding pathbootstrap_config()creates the default TOML config if missing- Interactive runs prompt for
remote_config_urland continue in the same command --yesis for non-interactive use and expects required fields to already be present- Stage reports make repeat runs safe and easier to follow
- Mihoro: main struct holding config and derived paths
- All methods return
anyhow::Result<T>for consistent error handling - Uses Tokio async for downloads
- All methods return
- Self-upgrade: updates from GitHub releases
upgrade::run_upgrade(): Downloads and replaces the current binaryupgrade::check_for_update(): Checks for new versions without installing- Uses
self_updatecrate with GitHub backend - Runs in
tokio::task::spawn_blockingto avoid async runtime conflicts - Release artifacts must be named
mihoro-<version>-<target>.tar.gz
Configuration flow
mihoro initcreates~/.config/mihoro.tomlif it does not exist- Interactive init prompts for the remote subscription URL when
remote_config_urlis empty - Remote YAML config is downloaded from the subscription URL
- Local TOML overrides are merged into the final
config.yaml - The user systemd service is written, enabled, and started
Runtime paths
- Config:
~/.config/mihoro.toml - Mihomo binary:
~/.local/bin/mihomo - Mihomo config:
~/.config/mihomo/config.yaml - Systemd service:
~/.config/systemd/user/mihomo.service
Dependencies
clap4.5: CLI argument parsing with derive macrostokio1.44: Async runtime (full features)serde+serde_yaml: Serialization/deserializationreqwest0.12: HTTP client with streaming supportanyhow: Error handlingcolored: Terminal colorsindicatif: Progress bars for downloadsself_update0.42: Self-upgrade functionality with GitHub releases backend
Code style
- Edition: Rust 2021
- Formatting:
rustfmt.toml(max line width 100, hard tabs) - Linting:
clippy.tomlsets thresholds for complexity/argument count - Unit tests live alongside the modules under
src/ cargo testcurrently discovers 32 unit tests
Shell integration
Proxy commands detect shell type (bash/zsh/fish) and generate appropriate export/unset commands for eval $(mihoro proxy export) usage.
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
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.

