一键导入
about-fin
// Learn about fin itself — what it is, how it works, its architecture. Use when asked about fin.
// Learn about fin itself — what it is, how it works, its architecture. Use when asked about fin.
| name | about_fin |
| description | Learn about fin itself — what it is, how it works, its architecture. Use when asked about fin. |
fin is a minimal, opinionated CLI agent harness written in Go by meain. Source code: https://github.com/meain/fin
fin takes a prompt, runs an agent loop (stream LLM response → execute tool calls → repeat), and exits. It supports session persistence, multiple LLM providers, an extensible skill system, and multiple output modes.
fin "explain this code" # basic prompt
fin -c "follow up" # continue last session
fin -s <uuid> "follow up" # continue specific session (prefix match or 1-based index)
fin -n <name> "prompt" # named session (resumes if it exists, else creates)
fin -match "prompt" # search recent sessions, offer to resume a match
git diff | fin "review this" # piped input
fin -export json|html|message # export session
fin -export message | glow # pipe last response to glow
fin -ui debug "what is in go.mod" # default + turn timings + token usage
fin -ui quiet "summarize" > out.txt # just the response on stdout
fin -sessions # list last 10 sessions (JSON if piped, ANSI table on TTY)
fin -all -sessions # list all sessions
fin -since 1h -sessions # filter sessions by age (1h, 2d, 1w, 30m)
fin -approve all|safe|none "prompt" # tool approval mode
fin -yolo "prompt" # alias for -approve all
fin --max-turns 5 "prompt" # cap agent loop iterations
fin -model provider/model "prompt" # override model for this run (alias names also work)
fin -color auto|always|never # color output (NO_COLOR honored)
fin -config <path> # override config file location
fin -f script.fin # read prompt from file (strips shebang line)
fin -f script.fin "extra args" # file prompt + positional args appended
fin -tools read,shell "prompt" # restrict tool set (also: all, none)
Prompt files can be made executable so they run like a normal CLI tool. See the README for full examples.
#!/usr/bin/env -S fin -f
Summarize the files in the current directory
#!/usr/bin/env -S fin -yolo --max-turns 3 -f
Read all TODO comments in this project and create a summary
The leading #! line is stripped before the prompt is sent. Positional args after the script path are appended to the prompt; piped stdin is prepended.
TOML at ~/.config/fin/config.toml:
[models] — primary (main conversation model), secondary (title generation and any secondary tasks)[settings] — project_file (default: AGENTS.md), max_turns, approve, ui[settings.matching] — tuning for -match: title_weight (default 3), content_cap (default 5), recency_decay_d (default 7), recency_bonus (default 0.5)[model_aliases] — short names mapping to provider/model (e.g. sonnet = "anthropic/claude-sonnet-4-6"). Alias chains resolved up to 10 hops.[providers.*] — base_url, api_key_env, headers[tools.*] — approval (auto/confirm/deny), allow/deny glob patterns for shellAnthropic Claude, OpenAI, and any OpenAI-compatible API (Groq, OpenRouter, Ollama, local models). All via raw HTTP — no provider SDKs. Configurable per-provider base URLs, API keys, and custom headers.
sh -c, returns stdout and stderr separatelyProgressive disclosure: only skill names and descriptions are loaded at startup. Full instructions load on activation. Skills are discovered from .agents/skills/ in the project (walks up to root) and ~/.agents/skills/ globally. Follows symlinks. Builtin skills are embedded in the binary.
~/.local/share/fin/sessions/. First line is a session header (id, title, model, cwd, started_at); each subsequent line is one message.tmp + rename full rewrite.fin process modified the file since load, to avoid clobbering concurrent runs.fin -s abc12 works). Named sessions via -n. Match recent sessions to the current prompt with -match.pbcopy, glow, etc.)git diff | fin "review this" — stdin pipe detected automatically, content prepended to prompt.
Per-tool configurable: auto, confirm, or deny. Shell tool supports allow/deny glob patterns. -approve all|safe|none overrides at runtime; -yolo is shorthand for -approve all.
-tools filters the active tool set. all (default) enables everything; none disables every tool; a comma list (-tools read,shell) enables only the named tools. Filter applies to subagents too. Valid names: read, write, edit, shell, compact, use_skill, subagent.
Rate limits (429) and server errors (5xx) retried up to 3 times with exponential backoff + jitter.
Assembled from: embedded base prompt → runtime context (date, OS, cwd) → skill list → ~/.agents/AGENTS.md → project AGENTS.md (walks up to root). Base prompt sections are gated by -tools so a disabled tool's section never reaches the model.
The agent talks to the UI through agent.UIWriter. Payloads crossing the boundary are structured data (no ANSI escapes, no pre-formatted strings). The terminal ui package is the current implementation; a TUI, web, or audio frontend can drop in by implementing the same interface — no agent change needed.
Shows streaming line count during tool call argument generation (e.g. write (47 lines) updates in real-time). Esc / Ctrl+C cancels a turn.
Raw-mode TTY multiplexer captures keystrokes during execution so the next prompt can be typed while a turn is still running.
Clone into a temporary directory and read through the files:
git clone https://github.com/meain/fin.git /tmp/fin-source
Then use the read tool on /tmp/fin-source to explore. Layout:
main.go — 10-LOC entry point, calls cli.Run()internal/cli/ — flag parsing, session glue, the driverinternal/agent/ — Agent type, turn loop, UIWriter interface, Debug* payloads, subagent runnerinternal/ui/ — terminal UIWriter implementation (ANSI, cursor moves, parallel-tool display)internal/session/ — JSONL persistence, loaders, -match scoringinternal/export/ — JSON / HTML / message exportersinternal/provider/ — Anthropic (SSE) and OpenAI-compatible (NDJSON) implementationsinternal/tool/ — Tool interface and the seven builtin tools, plus Labeler for displayinternal/skill/ — Skill discovery (project + global)internal/prompt/ — System prompt assembly + section gatinginternal/config/, internal/approval/, internal/render/, internal/input/, internal/fsutil/, internal/embed/, internal/types/ — supporting leaves