haansi
v0.1.45
Published
Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex
Readme
Haansi CLI
Session collector and MCP server for Claude Code and OpenAI Codex. Uploads your coding-agent session data to the Haansi platform for mining, search, and knowledge retrieval, and registers the Haansi MCP server with either or both agents.
Published to npm as haansi.
Supported agents
| Agent | Sessions read from | MCP config file |
| ------------ | ----------------------------------------- | ---------------------- |
| Claude Code | ~/.claude/projects/**/*.jsonl | ~/.claude.json |
| OpenAI Codex | $CODEX_HOME/sessions/**/rollout-*.jsonl | ~/.codex/config.toml |
By default, commands act on every installed agent. Target a specific one with --agent claude, --agent codex, or --agent both. The choice is remembered in ~/.haansi/config.json. Run haansi agents to see what's detected and selected.
Installation
npm install -g haansiRequires Node.js >= 18.0.0.
Authentication
The CLI uses hsk_ tokens for authentication. Generate a token at https://app.haansi.co/settings/developer/tokens.
haansi initThis prompts for your token, validates it against the API, and saves it to ~/.haansi/credentials.json (mode 0600). Alternatively, set the HAANSI_TOKEN environment variable.
Commands
| Command | Description |
| --------------------------------- | ------------------------------------------------------ |
| haansi init | Authenticate and save your API token |
| haansi collect [--agent <sel>] | Upload new/changed sessions (once) |
| haansi agents | List supported / installed / selected agents |
| haansi daemon | Run the collector on a schedule (every 30 min) |
| haansi setup-daemon | Install macOS launchd service for auto-start on login |
| haansi setup-mcp [t] [--agent] | Register MCP servers with Claude Code and/or Codex |
| haansi mcp-server | Start the Haansi MCP server (stdio, used by the agent) |
| haansi config get [key] | Show preferences (e.g. session_mode) |
| haansi config set <key> <val> | Update a preference |
| haansi search-solutions <query> | Semantic search over mined solutions |
| haansi list-solutions | List recent mined solutions |
| haansi search-knowledge <query> | Search knowledge artifacts |
| haansi save-knowledge | Save a problem/solution for future retrieval |
Collect options
--agent <sel>--claude,codex, orboth(default: installed agents)--force-all-- Re-upload all sessions, not just new ones--dry-run-- Scan without uploading--limit <n>-- Upload at most n sessions
Configuration
| Environment Variable | Description | Default |
| ------------------------- | ----------------------------------------- | ----------------------- |
| HAANSI_TOKEN | API token (alternative to haansi init) | -- |
| HAANSI_API_URL | API base URL | https://api.haansi.co |
| CODEX_HOME | Codex home directory | ~/.codex |
| HAANSI_AGENTS | Daemon: comma-separated agents to collect | (all installed) |
| HAANSI_COLLECT_SCHEDULE | Cron expression for daemon | */30 * * * * |
User preferences
Set via haansi config set <key> <value>:
session_mode--privateororg(default:org)
Daemon (macOS)
haansi setup-daemon # install and start
haansi setup-daemon --uninstall # stop and removeInstalls a launchd plist at ~/Library/LaunchAgents/co.haansi.daemon.plist. Logs are written to ~/.haansi/daemon.log.
MCP Server
haansi setup-mcp # all installed agents
haansi setup-mcp --agent codex # Codex only
haansi setup-mcp --agent both # Claude Code + CodexRegisters haansi-solutions (stdio) and haansi-exchange (http) with the selected agent(s): Claude Code via ~/.claude.json, Codex via the [mcp_servers.*] tables in ~/.codex/config.toml. Existing config is preserved — only the managed entries are added/updated. Restart the agent to pick up the change.
Package: haansi
Location: apps/cli/
