Skip to content
vhxnifPublic

About

Chat with AI via CLI.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

ifcli

Chat with AI via Command Line Interface.

Features:

  • Agent / session two-level conversation management (agent = chat, session = topic)
  • Automatic session name generation
  • Per-agent system prompts, models, tools and skills
  • Reasoning level control (off / minimal / low / medium / high / xhigh / max)
  • MCP (Model Context Protocol) tools support (HTTP / SSE / Stdio)
  • Custom model providers — register any OpenAI / Anthropic-compatible gateway in settings.json
  • Custom tools — define CLI commands as callable AI tools
  • Skill extension — drop a SKILL.md into the skills directory and enable per agent
  • Context compaction for long conversations
  • Searchable model selection
  • Flexible usage patterns with alias commands

Installation

ifcli is built using Bun.js and requires a Bun environment.

From NPM

npm install -g @vhxnif/ifcli

From Source

bun install && bun run build && bun link

Configuration

Models and providers are discovered automatically by Pi via environment variables, and you can register additional OpenAI / Anthropic-compatible gateways under the providers array. Configure application settings (theme, MCP servers, custom tools, providers, compaction) using ist cf -m or by editing settings.json directly.

The EDITOR environment variable must be set to enable configuration editing and system functions. If not configured, vim is used as the default editor.

Data Directory

Windows: Data and MCP configurations are stored in %APPDATA%\ifcli

macOS/Linux: Data is located in $HOME/.config/ifcli

Sessions and agents are stored in data.sqlite inside the data directory.

Quick Start

# Create an agent (chat) with a model
ict new translator -m openai/gpt-4o-mini

# Chat with it (or without -f to use the current agent)
ict -f translator "translate this sentence"

# Switch the model / system prompt / tools / skills of an agent
ict cf -m
ict cf -s
ict cf -t
ict cf -k

Commands

Setting Commands

Usage: ifsetting|ist [options] [command]

Manage application settings and configuration

Options:
  -V, --version        output the version number
  -h, --help           display help for command

Commands:
  config|cf [options]  manage application configuration
  mcp [options]        manage MCP servers
  tools|ts [options]   manage custom tools
  help [command]       display help for command

ist cf sub-options:

Usage: ifsetting config|cf [options]

Options:
  -m, --modify                  edit application settings JSON
  -t, --theme                   change color theme
  -s, --thinking-level <level>  validate a thinking level; set it per agent with `ict cf -r`

Chat Commands

Usage: ifchat|ict [options] [command] [string...]

Interactive AI chat interface (powered by Pi)

Arguments:
  string                    chat message content (multiple arguments will be joined)

Options:
  -V, --version             output the version number
  -f, --force <id-or-name>  use specified agent by id or name
  -s, --sync-call           use synchronous (non-streaming) mode
  -e, --edit                open editor for input
  -t, --new-session         create a new session under current agent for this message
  -a, --attachment <file>   attach text file content to message
  -c, --clean               run without context message
  -h, --help                display help for command

Commands:
  new [options] <name>      create a new agent (chat)
  remove|rm                 delete an agent (chat) and all its sessions
  switch|st                 switch between agents (chats)
  config|cf [options]       configure current agent (chat) settings
  history|hs [options]      view current session (topic) conversation history
  session|ss                manage sessions (topics) under current agent

ict cf sub-options:

Usage: ifchat config|cf [options]

Options:
  -m, --model                   switch AI model
  -r, --reasoning <level>       set reasoning level
                                (off/minimal/low/medium/high/xhigh/max)
  -t, --tools                   enable/disable tools for this agent
  -s, --system-prompt [prompt]  set or edit system prompt
  -k, --skills                  enable/disable skills for this agent

ict session sub-commands:

Usage: ifchat session|ss [options] [command]

Commands:
  new <name>      create a new session under current agent
  switch|sw       switch session under current agent
  remove|rm       remove a session under current agent

Application Settings

Example

{
    "$schema": "./settings-schema.json",
    "generalSetting": {
        "theme": "Tokyo Night",
        "toolDiscoveryThreshold": 8
    },
    "session": {
        "autoName": {
            "enabled": true,
            "model": "openai/gpt-4o-mini"
        }
    },
    "compaction": {
        "enabled": true,
        "triggerRatio": 0.8,
        "keepRecentRatio": 0.3
    },
    "mcpServers": [
        {
            "name": "weather",
            "version": "v1",
            "enable": true,
            "type": "sse",
            "url": "http://localhost:3000/sse"
        }
    ],
    "customTools": [],
    "providers": []
}

Model Providers

Providers and models are discovered automatically by Pi via environment variables. Common variables:

Provider Environment Variables
DeepSeek DEEPSEEK_API_KEY, DEEPSEEK_BASE_URL
OpenAI OPENAI_API_KEY, OPENAI_BASE_URL
Anthropic ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL
OpenRouter OPENROUTER_API_KEY, OPENROUTER_BASE_URL

Select a per-agent model with:

ict cf -m

Custom Providers

Built-in providers cover the common cases. For anything else — a self-hosted gateway, a proxy, or an endpoint Pi does not ship — add an entry to the providers array. The gateway must speak one of the protocols Pi already implements; API keys are referenced by environment variable name and never stored in settings.json.

{
    "providers": [
        {
            "id": "my-gateway",
            "name": "My Gateway",
            "baseUrl": "https://gateway.example.com/v1",
            "api": "openai-completions",
            "apiKeyEnv": ["MY_GATEWAY_API_KEY"],
            "models": [
                {
                    "id": "deepseek-v4-flash",
                    "contextWindow": 65536,
                    "maxTokens": 4096,
                    "reasoning": true,
                    "thinkingLevelMap": { "minimal": null, "low": "low", "medium": null, "high": "high", "max": "max" },
                    "compat": { "requiresReasoningContentOnAssistantMessages": true }
                }
            ]
        }
    ]
}

Once registered, the gateway's models appear in ict cf -m as my-gateway/<model-id> and can be selected per agent just like built-in models.

Provider fields:

Field Type Required Description
id string true Unique provider id; becomes the provider prefix of model strings
name string false Display name (default: id)
baseUrl string true Gateway base URL
api string true Protocol: openai-completions, openai-responses, anthropic-messages, google-generative-ai, google-vertex, mistral-conversations, azure-openai-responses, bedrock-converse-stream, openai-codex-responses, pi-messages
apiKeyEnv string[] true Environment variable names to try, in order; the first one set wins
headers object false Extra request headers
models object[] true Model declarations (see below)

Model fields:

Field Type Required Description
id string true Model id sent to the gateway
name string false Display name (default: id)
contextWindow number false Context window in tokens (default: 128000)
maxTokens number false Max output tokens (default: 8192)
reasoning boolean false Mark as a reasoning model (default: false)
input ('text' | 'image')[] false Supported input modalities (default: ["text"])
thinkingLevelMap object false Maps Pi thinking levels to gateway-specific values; null marks a level unsupported
compat object false OpenAI-compatible protocol overrides (e.g. thinkingFormat)

Reasoning control: set reasoning: true and a thinkingLevelMap so ict cf -r maps to the gateway's own values. Pi sends the mapped reasoning_effort; off simply omits it. Some gateways pick the thinking depth themselves and do not support disabling it, so a reasoning model on such a gateway may still return reasoning content at level off.

General Settings

Field Type Required Description
theme string true Color theme (see below)
toolDiscoveryThreshold number false When the number of enabled tools for a session exceeds this threshold, only the two discovery tools (list_available_tool_groups / list_available_tools) are injected; otherwise all tool schemas are injected directly (default: 8)

Available themes (via ist cf -t):

Tokyo Night · Tokyo Night Day · Tokyo Night Moon · Tokyo Night Storm · Rose Pine · Rose Pine Moon · Rose Pine Dawn · Catppuccin Latte · Catppuccin Frappe · Catppuccin Macchiato · Catppuccin Mocha

Session Settings

Field Type Required
autoName.enabled boolean true
autoName.model string true

Compaction Settings

Field Type Required
enabled boolean true
triggerRatio number true
keepRecentRatio number true

MCP Server (http)

Field Type Required
name string true
version string true
enable boolean true
type 'http' true
url string true
opts StreamableHTTPClientTransportOptions false

MCP Server (SSE)

Field Type Required
name string true
version string true
enable boolean true
type 'sse' true
url string true
opts SSEClientTransportOptions false

MCP Server (Stdio)

Field Type Required Description
name string true Server name
version string true Server version
enable boolean true Enable/disable server
type 'stdio' true Transport type
params StdioServerParameters true Server parameters
logMode 'ignore' | 'inherit' | 'file' false Log output mode (default: captured silently)

Log Mode Options:

  • (default): Capture stderr silently, preventing log mixing with CLI output
  • ignore: Discard all stderr output from MCP server
  • inherit: Pass stderr output to parent process (may mix with CLI output)

Custom Tools

Custom tools allow you to define CLI commands as callable AI tools. They are configured in settings.json under the customTools array, alongside the rest of the application configuration.

Tool Definition Format

{
    "$schema": "./settings-schema.json",
    "generalSetting": { "theme": "Tokyo Night" },
    "session": { "autoName": { "enabled": true, "model": "openai/gpt-4o-mini" } },
    "compaction": { "enabled": true, "triggerRatio": 0.8, "keepRecentRatio": 0.3 },
    "mcpServers": [],
    "customTools": [
        {
            "def": {
                "type": "function",
                "function": {
                    "name": "get_weather",
                    "description": "Get current weather for a city",
                    "parameters": {
                        "type": "object",
                        "properties": {
                            "city": {
                                "type": "string",
                                "description": "City name"
                            }
                        },
                        "required": ["city"]
                    }
                }
            },
            "tags": ["weather"],
            "command": ["curl", "wttr.in/${city}?format=3"]
        },
        {
            "def": {
                "type": "function",
                "function": {
                    "name": "calc",
                    "description": "Evaluate a mathematical expression",
                    "parameters": {
                        "type": "object",
                        "properties": {
                            "expr": {
                                "type": "string",
                                "description": "Math expression to evaluate"
                            }
                        },
                        "required": ["expr"]
                    }
                }
            },
            "tags": ["math"],
            "command": ["bash", "-c", "echo $((${expr}))"]
        }
    ]
}
Field Type Required Description
def object true OpenAI function tool definition (name, description, parameters)
tags string[] true Tool categories for organization and selection (replaces old group)
command string[] true CLI command array; use ${paramName} for argument interpolation

Usage

# Edit settings (including custom tools) with schema validation in IDE
ist cf -m

# List configured custom tools
ist tools -l

The AI model first discovers available tool groups, then inspects individual tools, and finally invokes them — a three-step discovery process managed automatically by the built-in list_available_tool_groups and list_available_tools functions.

Skills

Skills are Pi-style instruction packs. Drop a SKILL.md into ~/.config/ifcli/skills/<skill>/ (macOS/Linux) or %APPDATA%\ifcli\skills\<skill>\ (Windows), then enable it for an agent:

ict cf -k

Enabled skills are exposed to the model via the built-in Skill tool.

Usage Tips

Agent-based Chat Management

# 'ts' is an agent for translation purposes
alias ts='ict -f ts'

Disable Streaming Output

# Use synchronous output for pipeline operations
ict -sf ts

# Create custom commands for pipelines
alias sts='ict -sf ts'
cat system_prompt.md | sts | tee system_prompt.txt

Edit System Prompts

Per-agent system prompt, using the editor:

ict cf -s

Or pass a prompt directly:

ict cf -s "You are a helpful translator."

New Session Per Message

Start a fresh topic without switching agents:

ict -t "start a new topic with this message"

About

Chat with AI via CLI.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages