{"id":47942951,"url":"https://github.com/nihen/ah","last_synced_at":"2026-04-04T08:13:55.167Z","repository":{"id":346633932,"uuid":"1190784221","full_name":"nihen/ah","owner":"nihen","description":"Agent History — search and browse AI coding agent sessions (Claude, Codex, Gemini, Copilot, Cursor) from a single CLI","archived":false,"fork":false,"pushed_at":"2026-03-25T16:14:42.000Z","size":136,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-25T23:22:59.631Z","etag":null,"topics":["ai-agent","claude-code-cli","codex-cli","developer-tool","rust-cli"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nihen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-03-24T16:04:29.000Z","updated_at":"2026-03-25T15:24:55.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/nihen/ah","commit_stats":null,"previous_names":["nihen/ah"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/nihen/ah","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihen%2Fah","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihen%2Fah/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihen%2Fah/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihen%2Fah/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nihen","download_url":"https://codeload.github.com/nihen/ah/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihen%2Fah/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31392422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T04:26:24.776Z","status":"ssl_error","status_checked_at":"2026-04-04T04:23:34.147Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agent","claude-code-cli","codex-cli","developer-tool","rust-cli"],"created_at":"2026-04-04T08:13:52.188Z","updated_at":"2026-04-04T08:13:55.158Z","avatar_url":"https://github.com/nihen.png","language":"Rust","readme":"# Agent History (ah)\n\n**A**gent **H**istory — search, inspect, and resume coding-agent sessions from a single CLI.\n\n`ah` discovers session files from [Claude Code](https://claude.ai/), [Codex](https://github.com/openai/codex), [Gemini CLI](https://github.com/google-gemini/gemini-cli), [Cursor](https://cursor.com/), and [GitHub Copilot CLI](https://docs.github.com/en/copilot/github-copilot-in-the-cli). It works with zero config, defaults to the current directory, and gives you one place to search, inspect, and resume past work.\n\nRead-only by default. `ah` works directly on agent session files, lets you search and inspect them, and only executes when you explicitly run `resume`.\n\n## Demo\n\n![Demo](demo/demo.svg)\n\n## Quick Look\n\nOn a TTY, `ah log` outputs in `git log` style with auto-pager. Defaults to current directory:\n\n```console\n$ ah log\nsession a1b2c3d4-5e6f-7a8b-9c0d-e1f2a3b4c5d6\nAgent:    claude\nProject:  my-webapp\nCwd:      /home/user/src/my-webapp\nDate:     2026-03-23 14:00 - 2026-03-23 18:00\n\n    implement OAuth2 authentication flow\n\nsession e5f6a7b8-9c0d-1e2f-3a4b-5c6d7e8f9a0b\nAgent:    cursor\nProject:  my-webapp\nCwd:      /home/user/src/my-webapp\nDate:     2026-03-23 12:15 - 2026-03-23 14:22\n\n    fix memory leak in worker pool\n```\n\nPick a session ID from the log and resume it — `ah` launches the original agent's resume command (e.g. `claude --resume`):\n\n```console\n$ ah resume a1b2c3d4-5e6f-7a8b-9c0d-e1f2a3b4c5d6\n```\n\nWant the exact command first without executing anything?\n\n```console\n$ ah resume --print a1b2c3d4-5e6f-7a8b-9c0d-e1f2a3b4c5d6\ncd '/home/user/src/my-webapp' \u0026\u0026 'claude' '--resume' 'a1b2c3d4-5e6f-7a8b-9c0d-e1f2a3b4c5d6'\n```\n\nOr browse and filter sessions with `-i` (via [fzf](https://github.com/junegunn/fzf) or compatible finder, with transcript preview):\n\n```console\n$ ah resume -i\n```\n\nFull-text search across all directories (piped output is plain TSV):\n\n```console\n$ ah log -a -q \"OAuth\" | head -3\nclaude  my-webapp    2026-03-23 18:00  implement OAuth2 authentication flow  ...implement OAuth2 auth...          a1b2c3d4-5e6f-7a8b-9c0d-e1f2a3b4c5d6\ncursor  my-webapp    2026-03-23 14:22  fix memory leak in worker pool        ...reviewing the OAuth token...      e5f6a7b8-9c0d-1e2f-3a4b-5c6d7e8f9a0b\ncodex   api-server   2026-03-22 11:30  add Redis caching layer              ...cache OAuth tokens with 1h TTL... sess_7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b\n```\n\nShow a session transcript:\n\n```console\n$ ah show a1b2c3d4\n\u003e\u003e\u003e implement OAuth2 authentication flow\n\nI'll implement the OAuth2 flow. Let me start by reading the existing auth module...\n```\n\nSessions grouped by project:\n\n```console\n$ ah project -a\nPROJECT      SESSION_COUNT  LAST_MODIFIED_AT  AGENTS\nmy-webapp    18             2026-03-23 18:00  claude, codex, cursor, gemini\napi-server   14             2026-03-23 09:15  claude, codex, copilot, cursor\nml-pipeline  11             2026-03-22 08:50  claude, copilot, gemini\ninfra         5             2026-03-20 17:40  codex, cursor\ndocs          3             2026-03-19 11:25  claude, gemini\n```\n\nList agent memory and instruction files across all agents:\n\n```console\n$ ah memory -a\nAGENT   PROJECT    TYPE         NAME              MODIFIED_AT       DESCRIPTION\nclaude  my-webapp  feedback     always-run-tests  2026-03-23 18:00  Run test suite before committing\nclaude  my-webapp  instruction  CLAUDE.md         2026-03-22 10:00\ncodex   my-webapp  instruction  AGENTS.md         2026-03-21 15:30\n```\n\nShow session summary per agent:\n\n```console\n$ ah agent\nAGENT     SESSIONS  LATEST\nclaude          50  2026-03-24 17:55\ncodex           42  2026-03-24 16:32\ncopilot         18  2026-03-23 19:00\ncursor          12  2026-03-22 13:40\ngemini           5  2026-03-21 10:50\n```\n\n## Support Matrix\n\n| Agent | List | Search | Show | Resume | Running | Memory |\n|-------|------|--------|------|--------|---------|--------|\n| Claude | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |\n| Codex | ✓ | ✓ | ✓ | ✓ | | |\n| Gemini | ✓ | ✓ | ✓ | ✓ | | |\n| Copilot | ✓ | ✓ | ✓ | ✓ | | |\n| Cursor | ✓ | ✓ | ✓ | ✓ | | |\n\n## Features\n\n- **Cross-agent** — one tool for 5 agents (see `ah list-agents`)\n- **Zero-config** — scans the standard session locations for each supported CLI\n- **Fast** — parallel file collection with [rayon](https://github.com/rayon-rs/rayon), regex search via [memmap2](https://github.com/RazrFalcon/memmap2-rs), no subprocesses for search/parsing\n- **Resume-friendly** — `ah resume` and `ah show` can target the latest matching session without pasting IDs\n- **Structured output** — `git log`-style multi-line format with auto-pager on TTY, plain TSV when piped, plus `--table`, `--json`, `--ltsv`\n- **Interactive** — `-i` adds fuzzy selection with transcript preview (via [fzf](https://github.com/junegunn/fzf) or compatible finder)\n\n## Installation\n\n### Homebrew\n\n```bash\nbrew install nihen/tap/ah\n```\n\nSupported in the tap today:\n- Apple Silicon macOS\n- Linux x86_64\n\nIntel Mac users should use Cargo or a source build.\n\n### Cargo\n\n```bash\ncargo install ah-cli\n```\n\n### From binary\n\nDownload a prebuilt binary from [GitHub Releases](https://github.com/nihen/ah/releases).\n\nAvailable today:\n- macOS arm64\n- Linux x86_64\n\n### From source\n\n```bash\ncargo install --git https://github.com/nihen/ah\n```\n\n### Shell completion\n\n```bash\n# zsh\nmkdir -p ~/.zfunc \u0026\u0026 ah completion zsh \u003e ~/.zfunc/_ah\n# Add to .zshrc: fpath=(~/.zfunc $fpath); autoload -Uz compinit \u0026\u0026 compinit\n\n# bash\nah completion bash \u003e ~/.local/share/bash-completion/completions/ah\n\n# fish\nah completion fish \u003e ~/.config/fish/completions/ah.fish\n```\n\n## Tips\n\n### Interactive mode (-i)\n\nMost commands support `-i` for fuzzy selection with transcript preview. Requires [`fzf`](https://github.com/junegunn/fzf) or a compatible finder (e.g. [`sk`](https://github.com/lotabout/skim)) in `PATH`. Override with `$AH_SELECTOR`.\n\nUseful as a shell function — pick a project, browse its sessions, resume:\n\n```bash\nahr() { local d; d=\"$(ah project -i)\" \u0026\u0026 ah resume -i -d \"$d\"; }\n```\n\n## Command-line options\n\n### `ah -h`\n\n```\nSearch, inspect, and resume coding-agent sessions from one CLI\n(read-only except resume)\n\nDefaults to the current directory. Use -a to search across all known sessions.\n\nUsage:\n  ah \u003cCOMMAND\u003e [OPTIONS]\n\nCommands:\n  log                 List sessions\n  project             List known projects\n  show                Show session transcript\n  resume              Resume an agent session\n  memory              List agent memory and instruction files\n  agent               Show session summary per agent\n\nHelp / setup:\n  list-agents         List supported agents\n  completion          Generate shell completion script\n  man                 Generate man page\n\nGlobal options:\n  -a, --all               Show all sessions (disable default cwd filtering)\n  --agent \u003cNAME\u003e          Filter by agent name (e.g. claude, codex, gemini)\n  --project \u003cNAME\u003e        Filter by project name\n  -d, --dir \u003cPATH\u003e        Filter by working directory (default: current directory)\n  -q, --query \u003cREGEX\u003e     Full-text search query (regex, case-insensitive)\n  -p, --prompt-only       Search only user prompts (use with -q)\n  -n, --limit N           Max session files to scan (default: 0, no limit)\n  -i, --interactive       Interactive mode via fuzzy finder (fzf/sk)\n  -s \u003cCMD\u003e                Override fuzzy selector (default: $AH_SELECTOR or fzf)\n  --no-preview            Disable preview in interactive mode\n  --running               Show only currently running sessions (Claude only for now)\n  --since \u003cSPEC\u003e          Show sessions newer than (e.g. \"2026-03-20\", \"3d\", \"1w\", \"2m\" = ~60 days)\n  --until \u003cSPEC\u003e          Show sessions older than (e.g. \"2026-03-20\", \"3d\", \"1w\", \"2m\" = ~60 days)\n  --color                 Force colored output (even through pipes)\n  --no-color              Disable colored output\n  --no-pager              Disable automatic pager\n  -h, --help              Show this help\n  -V, --version           Show version\n\nExamples:\n  ah log                      # latest sessions for the current directory\n  ah log -a -q \"auth\"         # search across all known sessions\n  ah resume                   # resume the latest matching session\n  ah show -q \"OAuth\"          # show the latest matching session\n  ah resume -i                # browse sessions with fzf/sk and resume\n\nRun `ah \u003cCOMMAND\u003e --help` for subcommand-specific options.\n```\n\n### `ah log --help`\n\n```\nList sessions\n\nUsage:\n  ah log [OPTIONS]\n\nOptions:\n  -o, --fields \u003cFIELDS\u003e   Select output fields (replaces defaults, see --list-fields)\n                          Default: agent, project, modified_at, title, id\n                          With -q: agent, project, modified_at, title, matched, id\n  -O, --extra-fields \u003cFIELDS\u003e  Add fields to defaults (comma-separated)\n  --table                 Aligned table with header row\n  --tsv                   Tab-separated values (no header, no color)\n  --ltsv                  Labeled Tab-Separated Values (in -i mode: selector display format)\n  --json                  JSON Lines output\n  -S, --sort \u003cFIELD\u003e      Sort by field (default: modified_at)\n  --asc                   Sort ascending\n  --desc                  Sort descending (default)\n  --transcript-limit N    Max characters for transcript field (default: 500)\n  --title-limit N         Max characters for auto-generated title (default: 50, 0 = no limit)\n  -L, --list-fields       List available output fields and exit (use with --json for machine-readable output)\n\nDefault output (when no format flag is given):\n  git-log style multi-line with auto-pager on TTY, plain TSV when piped\n\nInteractive mode:\n  -i, --interactive       Browse sessions via fuzzy finder; prints selected path\n  -s \u003cCMD\u003e                Selector command (default: $AH_SELECTOR or fzf)\n  --no-preview            Disable transcript preview (enabled by default for fzf, sk)\n\nGlobal options are also available (see ah -h).\n```\n\n### `ah show --help`\n\n```\nShow session transcript\n\nUsage:\n  ah show [OPTIONS] [SESSION]\n\nIf SESSION is omitted, ah shows the latest session matching stdin, -q, and other filters.\n\nOptions:\n  --head N                Show first N messages only\n  --pretty                Pretty-print with colors (default)\n  --raw                   Output raw session file content\n  --json                  Output normalized JSON Lines ({\"role\":\"user\",\"text\":\"...\"})\n  --md                    Output as Markdown (## User / ## Assistant headers)\n  -f, --follow            Follow session output in real-time (like tail -f)\n\nInteractive mode:\n  -i, --interactive       Select session via fuzzy finder then show it\n  -o, --fields \u003cFIELDS\u003e   Display fields in interactive mode (default: agent,project,modified_at,title)\n  -s \u003cCMD\u003e                Selector command (default: $AH_SELECTOR or fzf)\n  --no-preview            Disable transcript preview\n\nGlobal options are also available (see ah -h).\n```\n\n### `ah resume --help`\n\n```\nResume an agent session\n\nUsage:\n  ah resume [OPTIONS] [SESSION] [-- EXTRA_ARGS...]\n\nIf SESSION is omitted, ah resumes the latest session matching stdin, -q, and other filters.\n\nArguments after -- are passed directly to the agent command.\n\nThe only command that launches an agent process; other commands are read-only.\n\nOptions:\n  --print                 Print the resolved resume command and exit (read-only; does not execute)\n\nInteractive mode:\n  -i, --interactive       Select session via fuzzy finder then resume it\n  -o, --fields \u003cFIELDS\u003e   Display fields in interactive mode (default: agent,project,modified_at,title)\n  -s \u003cCMD\u003e                Selector command (default: $AH_SELECTOR or fzf)\n  --ltsv                  Use LTSV format for interactive selector display\n  --no-preview            Disable transcript preview\n\nExamples:\n  ah resume                   # resume latest matching session\n  ah resume --print           # print the resolved resume command\n  ah resume a1b2c3d4          # resume by ID\n  ah resume -i                # interactive selection\n  ah resume -- --dry-run      # pass extra args to agent\n\nGlobal options are also available (see ah -h).\n```\n\n### `ah project --help`\n\n```\nList known projects\n\nUsage:\n  ah project [OPTIONS]\n\nOptions:\n  -o, --fields \u003cFIELDS\u003e   Select output fields (replaces defaults, see --list-fields)\n                          Default: project, session_count, last_modified_at, agents\n                          In -i mode default: cwd, project, session_count, last_modified_at\n  -O, --extra-fields \u003cFIELDS\u003e  Add fields to defaults (comma-separated)\n  --table                 Aligned table with header row\n  --tsv                   Tab-separated values (no header, no color)\n  --ltsv                  Labeled Tab-Separated Values (in -i mode: selector display format)\n  --json                  JSON Lines output\n  -S, --sort \u003cFIELD\u003e      Sort by field (default: last_modified_at)\n  --asc                   Sort ascending\n  --desc                  Sort descending (default)\n  -L, --list-fields       List available output fields and exit (use with --json for machine-readable output)\n\nDefault output (when no format flag is given):\n  Aligned table with auto-pager on TTY, plain TSV when piped\n\nInteractive mode:\n  -i, --interactive       Browse projects via fuzzy finder; prints selected cwd\n  -s \u003cCMD\u003e                Selector command (default: $AH_SELECTOR or fzf)\n  --no-preview            Disable preview\n\nGlobal options are also available (see ah -h).\n```\n\n### `ah memory --help`\n\n```\nList agent memory files\n\nUsage:\n  ah memory [OPTIONS]\n\nOptions:\n  -o, --fields \u003cFIELDS\u003e   Select output fields (replaces defaults, see --list-fields)\n                          Default: agent, project, type, name, modified_at, description\n  -O, --extra-fields \u003cFIELDS\u003e  Add fields to defaults (comma-separated)\n  -t, --type \u003cTYPE\u003e       Filter by memory type (user/feedback/project/reference/instruction)\n  --table                 Aligned table with header row\n  --tsv                   Tab-separated values (no header, no color)\n  --ltsv                  Labeled Tab-Separated Values\n  --json                  JSON Lines output\n  -S, --sort \u003cFIELD\u003e      Sort by field (default: modified_at)\n  --asc                   Sort ascending\n  --desc                  Sort descending (default)\n  -L, --list-fields       List available output fields and exit (use with --json for machine-readable output)\n\nDefault output (when no format flag is given):\n  Aligned table with auto-pager on TTY, plain TSV when piped\n\nInteractive mode:\n  -i, --interactive       Browse memory files via fuzzy finder\n  -s \u003cCMD\u003e                Selector command (default: $AH_SELECTOR or fzf)\n  --no-preview            Disable preview\n\nGlobal options are also available (see ah -h).\n```\n\n### `ah agent --help`\n\n```\nShow session summary per agent\n\nUsage:\n  ah agent [OPTIONS]\n\nShows how many sessions were found for each agent and the latest modified time.\n\nOptions:\n  --table                 Output as aligned table\n  --tsv                   Output as TSV (tab-separated values)\n  --ltsv                  Output as LTSV (Labeled TSV)\n  --json                  Output as JSON Lines\n\nDefault output (when no format flag is given):\n  Aligned table with auto-pager on TTY, plain TSV when piped\n\nGlobal options are also available (see ah -h).\n```\n\n## Configuration (~/.ahrc)\n\n`ah` works out of the box with no configuration. Optionally, create `~/.ahrc` (TOML) to customize agent settings.\n\n### Disable an agent\n\n```toml\n[agents.codex]\ndisabled = true\n```\n\n### Add extra file patterns to a built-in agent\n\n```toml\n[agents.claude]\nextra_patterns = [\"~/claude-archive/projects/*/*.jsonl\"]\n```\n\n### Add a custom agent (using an existing plugin's parser)\n\n```toml\n[agents.aider]\nplugin = \"claude\"\nfile_patterns = [\"~/.aider/history/*.jsonl\"]\n```\n\nAvailable plugins: `claude`, `codex`, `gemini`, `copilot`, `cursor`. The `plugin` field tells `ah` how to parse the session files.\n\n### Environment variables\n\nEach built-in agent respects its CLI's config directory environment variable:\n\n| Agent   | Session Files | Env Var            | Default     |\n|---------|---------------|--------------------|-------------|\n| Claude  | `projects/*/*.jsonl` | `CLAUDE_CONFIG_DIR`| `~/.claude` |\n| Codex   | `sessions/**/*.jsonl` | `CODEX_HOME`       | `~/.codex`  |\n| Gemini  | `tmp/*/chats/session-*.json` | `GEMINI_CLI_HOME`  | `~/.gemini` |\n| Copilot | `session-state/*/workspace.yaml` | `COPILOT_HOME`     | `~/.copilot`|\n| Cursor  | `projects/*/agent-transcripts/**/*.jsonl` | `CURSOR_CONFIG_DIR`| `~/.cursor` |\n\nRun `ah list-agents` to see the full configuration including glob patterns and capabilities.\n\nAdditional environment variables:\n\n| Env Var    | Description |\n|------------|-------------|\n| `AH_PAGER` | Override pager command (default: `less`). Set to empty string to disable |\n| `PAGER`    | Fallback pager command (used if `AH_PAGER` is not set) |\n| `AH_COLOR` | Set to `1` to force colored output (like `--color`) |\n| `NO_COLOR` | Set to disable colored output ([no-color.org](https://no-color.org/)) |\n\n## Examples\n\n### SQL with [trdsql](https://github.com/noborus/trdsql)\n\n```bash\nah log -a --ltsv | trdsql -iltsv \"SELECT * FROM - WHERE agent='claude'\"\nah log -a --ltsv | trdsql -iltsv \"SELECT agent, COUNT(*) as cnt FROM - GROUP BY agent\"\n```\n\n### JSON with [jq](https://github.com/jqlang/jq)\n\n```bash\nah log -a --json | jq '.project'\nah log -a --json -n 1 | jq '.'\nah project --json | jq '.project'       # list project names\n```\n\n### Piping\n\n```bash\nah log -q \"auth\" -o path | head -1 | ah show    # show latest match\nah log -q \"auth\" -o path | head -1 | ah resume  # resume latest match\nah log -a -o project | sort | uniq -c | sort -rn # project ranking\n```\n\n## For AI Agents (CLAUDE.md / AGENTS.md)\n\nAdd this line to your project or global instructions so your coding agent knows about `ah`:\n\n```\n`ah` — cross-agent session history CLI. Run `ah -h` for usage; key commands: `ah log` (list sessions), `ah show` (view transcript), `ah log -a -q \"keyword\"` (search all).\n```\n\n## Roadmap\n\n- **Remote session aggregation** — `ssh` to a remote host running `ah`, aggregate results locally. Like rsync's remote process model: computation happens near the data, only metadata travels over the wire.\n\n## License\n\n[MIT](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnihen%2Fah","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnihen%2Fah","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnihen%2Fah/lists"}