Witty CLI Usage Introduction
Preface
Witty CLI is the AI assistant for openEuler terminal scenarios. It provides two modes: Shell direct input, natural language typed at a regular Bash prompt, and REPL, the interactive CLI started by running witty. Both modes share the same session, rendering, permission, and display core.
Quick Start
Shell Direct Input
After installation, type natural language directly in a Bash terminal to invoke the AI assistant:
check system memoryWitty CLI recognizes it as natural language rather than a shell command, calls the AI assistant, and streams the answer:
systemctl how do I view nginx logsInput that starts with a known command but contains a question phrase is also routed to the AI assistant.
REPL Mode
wittyEnter the interactive REPL; the prompt is witty [<agent>:<model>] > with a trailing space. Continue the conversation:
witty [witty-builtin-agent] > analyze the OOM logs in dmesg
...(streaming answer)...
witty [witty-builtin-agent] > how should I optimize the memory configuration
...(answer continued from the previous context)...Type /exit or press Ctrl+D to leave the REPL.
Single-Shot Query
witty ask "check system memory"Sends one request, streams the answer, and exits.
Pipe Input
echo "explain this function" | witty askdmesg | witty ask "analyze anomalies in this kernel log"Connecting a Provider and Switching Models
witty provider connect deepseek
Enter API key: **** (not echoed)
connected provider deepseekThen enter the REPL and type /model to open the model selector:
witty [witty-builtin-agent] > /model
Select model:
❯ 1) opencode/north-mini-code-free — North Mini Code Free
2) opencode/ling-3.0-flash-free — Ling-3.0-flash Free
...
8) deepseek/deepseek-v4-flash — DeepSeek V4 Flash
9) deepseek/deepseek-v4-pro — DeepSeek V4 Pro
↑/↓ navigate ↵ select esc cancelCommand Reference
Global Options
The following options apply to all subcommands:
| Option | Type | Default | Description |
|---|---|---|---|
--config | string | "" | Path to the configuration file |
--server-url | string | "" | opencode server address |
--agent | string | "" | Default agent |
--model | string | "" | Default model, format provider/model |
--variant | string | "" | Model variant, such as the reasoning level |
--debug | bool | false | Enable debug logging |
--no-color | bool | false | Disable colored output |
--version, -v | — | — | Print version information |
witty (no subcommand) — start the REPL
wittyStarts the interactive REPL and restores the most recent session of the current directory, or creates a new one.
witty ask
witty ask [prompt]Sends a message, streams the answer, and exits when the answer finishes.
Options:
| Option | Type | Description |
|---|---|---|
--new | bool | Create a new session instead of reusing the session of the current directory |
--session | string | Continue the specified session ID |
--newand--sessioncannot be used together.
witty init bash
eval "$(witty init bash)"Prints the Bash integration script to stdout, usually used with eval. The RPM installation already enables the integration through /etc/profile.d/witty.sh.
witty session
witty session list
witty session continue <id>Lists all sessions or switches to the specified session. The top-level shortcut witty continue <id> is also available.
witty provider
Provider management, see "Provider Management" below.
witty server
Server management, see "Server Lifecycle Management" below.
witty doctor
Environment diagnostics, see "Environment Diagnostics" below.
witty version
Prints the version, commit, and build date.
Shell Integration
How It Works
Shell integration uses the Bash DEBUG trap with the extdebug option. It intercepts each command before execution and routes it through a classifier:
| Route | Behavior |
|---|---|
| shell | Passed to Bash as usual, no interference |
| agent | Handed over to witty ask |
| control | Handed over to witty to interpret slash control commands |
Classification follows the rule "Shell first, Agent as fallback": input that cannot be clearly identified as natural language is passed to the Shell.
Routing Examples
| Input | Route | Reason |
|---|---|---|
检查系统内存 | Agent | CJK characters |
systemctl 怎么看 nginx 日志 | Agent | Chinese trigger word 怎么看 |
systemctl status nginx | Shell | Known command, no natural language features |
grep error /var/log/messages | Shell | Known command, no natural language features |
cat /etc/os-release | grep NAME | Shell | Pipeline |
/session | Control | Whitelisted slash command, shows detailed /session usage |
/ask systemctl 怎么看 nginx 日志 | Control | Whitelisted slash command, forces an Agent request internally |
/usr/bin/ls | Shell | Explicit path |
for i in 1; do | Shell | Shell syntax with strong syntax features such as ; |
how do I restart nginx | Agent | English trigger words |
Enabling and Disabling
- Default state: enabled for all users after RPM installation.
- Temporary disable for the current terminal session:
export WITTY_SHELL_ENABLE=0 - Permanent disable: add
export WITTY_SHELL_ENABLE=0to~/.bashrc - Debug mode:
export WITTY_SHELL_DEBUG=1prints classification results to stderr
Forcing the Agent
If the classifier misidentifies natural language as a shell command, use the /ask escape hatch:
/ask how do I delete a docker imageInstallation Prerequisites
Shell integration is installed only when the current shell is Bash, the session is interactive ($- contains i), and stdin and stdout are TTYs. Non-interactive scripts and unsupported shells such as zsh and fish do not get the integration.
Slash Control Commands
The following slash commands are available in both the REPL and Shell direct input:
| Command | Purpose |
|---|---|
/help | Show help |
/exit, /quit, /q | Exit the REPL, no arguments accepted |
/ask <prompt> | Force the current input to be handled as an Agent request |
/agent [name] | Show or switch the default agent |
/model [provider/model] | Show or switch the default model |
/new | Create a new session on the next request |
/session | Show detailed /session usage |
/session list | List sessions |
/session continue <id> | Continue the specified session |
/agent — switch agent
Without arguments, in a TTY terminal, an interactive agent selector is shown, listing all non-hidden agents that are not subagents. With an argument, the switch is immediate:
/agent buildThe selection is persisted to the user configuration file:
[agent] set to "build" (saved to ~/.config/witty/config.toml)/model — switch model
The model format must be provider/model:
/model openai/gpt-4Without arguments, an interactive model selector is shown, listing only models of connected providers. If the selected model supports variants, a variant selector follows. After the selection, a confirmation is printed and persisted to the configuration file:
[model] set to "deepseek/deepseek-v4-flash" (variant: max, saved to ~/.config/witty/config.toml)Argument Validation Rules
| Command | Argument Requirement |
|---|---|
/ask | A prompt is required |
/agent | Optional argument |
/model | Optional argument |
/session | No argument; shows detailed /session usage |
/session list | No argument |
/session continue | A session id is required |
/new | No argument |
/help | No argument |
/exit, /quit, /q | No argument |
Configuration
Configuration Files
Witty CLI uses TOML configuration files, searched in the following order, with later entries overriding earlier ones:
/etc/witty/config.toml(system level)~/.config/witty/config.toml(user level)
Alternatively, specify a file with --config <path> or the environment variable WITTY_CONFIG.
Full Configuration
# Top-level configuration
default_agent = "witty-builtin-agent" # default agent
default_model = "" # default model, format provider/model
default_variant = "" # model variant, such as the reasoning level
debug = false # debug logging
theme = "auto" # theme (auto)
no_color = false # disable colored output
stream_mode = 1 # streaming mode (1=segmented rendering, 2=character-by-character output)
# Server lifecycle management
[server]
auto_start = true # start opencode serve automatically
port = 0 # 0 = choose a port automatically, positive integer = fixed port
hostname = "127.0.0.1" # bind address
startup_timeout_seconds = 10 # maximum time to wait for server startup, in seconds
idle_timeout_minutes = 30 # stop automatically after idle timeout (0 = disabled)
# REPL configuration
[repl]
auto_resume = true # restore the most recent session of the current directory
# Shell integration configuration
[shell]
enabled = true # enable Shell integration
debug = false # Shell integration debug mode
# Diagnostics configuration
[doctor]
timeout_seconds = 5 # diagnostics timeout, in seconds
# Display configuration
[display]
show_reasoning = "show" # reasoning display: show / minimal / hide
tool_mode = "compact" # tool call display: compact / verbose
group_context_tools = true # group consecutive read-only tool calls in the display
step_style = "line" # step display style: line / minimal / noneConfiguration Override Environment Variables
Environment variables take precedence over the configuration file, and CLI options take precedence over environment variables.
| Environment Variable | Configuration Item | Description |
|---|---|---|
WITTY_CONFIG | — | Path to the configuration file |
WITTY_AGENT | default_agent | Default agent |
WITTY_MODEL | default_model | Default model |
WITTY_VARIANT | default_variant | Model variant |
WITTY_DEBUG | debug | Debug logging (true/false) |
WITTY_SHELL_ENABLE | shell.enabled | Enable Shell integration (true/false) |
WITTY_SHELL_DEBUG | shell.debug | Shell integration debug mode (true/false) |
WITTY_SERVER_AUTO_START | server.auto_start | Automatic startup (true/false) |
WITTY_SERVER_PORT | server.port | Server port |
WITTY_SERVER_HOSTNAME | server.hostname | Bind address |
WITTY_DISPLAY_SHOW_REASONING | display.show_reasoning | Reasoning display |
WITTY_DISPLAY_STEP_STYLE | display.step_style | Step display style |
NO_COLOR | no_color | Any value disables colored output, following the NO_COLOR standard |
Provider Management
Listing Providers
witty provider listLists all providers that support API key authentication and shows the connection status:
STATUS ID NAME DEFAULT_MODEL
- openai OpenAI gpt-4
connected deepseek DeepSeek deepseek-chatList connected providers only:
witty provider list --connectedConnecting a Provider
witty provider connect <provider> --key <api-key><provider> can be the provider ID or name; matching is case-insensitive.
Ways to supply the API key, in order of precedence:
- The
--keyoption - Interactive terminal prompt: if stdin is a TTY,
Enter API key:is shown and input is not echoed - Read from the stdin pipe
- Environment variables such as
OPENAI_API_KEYandDEEPSEEK_API_KEY
On success, connected provider deepseek is printed. If the provider is still unavailable, witty restarts the server automatically to reload the credentials.
Server Lifecycle Management
Witty CLI manages the full lifecycle of the opencode serve process; manual intervention is usually unnecessary.
Automatic Startup
When server.auto_start = true, the default, witty starts the opencode serve child process on first use. After startup:
- the server runs as a daemon and keeps running after witty exits
- the state is persisted to
~/.local/state/witty/server-state.jsonwith mode 0600 - the next witty startup reuses the server seamlessly through the state file
Checking Status
witty server statusRunning: yes
Port: 4096
PID: 12345
Managed: no
StartedAt: 2026-08-19T10:30:00+08:00Running: whether the server is running; this field is authoritative for server statusManaged: whether the server was started by the current process; sincewitty server statusis a read-only command,Managedis alwaysnohere, which is expected; rely onRunning
Stop / Restart
witty server stop
witty server restartUse witty server restart after installing or modifying agent / skill / MCP configuration files so that the server reloads the configuration:
sudo dnf install witty-diagnosis-agent
witty server restartDisabling Automatic Startup
[server]
auto_start = falseWith automatic startup disabled, start opencode serve manually; witty probes that address for an existing server. To connect to a server at another address, use the --server-url CLI flag.
Idle Timeout
The server stops automatically after 30 minutes without activity, controlled by server.idle_timeout_minutes = 30. Set it to 0 to disable the feature.
Multi-User Isolation
Server instances of different users on the same host are isolated:
- each user has an independent random password for HTTP Basic Auth
- the state file has mode 0600 and cannot be read by other users
- the password is passed to the child process only through environment variables and never appears in command-line arguments
Environment Diagnostics
witty doctorThe following items are checked, each reporting OK, WARN, FAIL, or SKIP:
| Check | Description |
|---|---|
| config | Configuration loading, current server/agent/model/shell settings |
| server reachable | Whether the opencode server is reachable |
| /doc endpoint | Whether the OpenAPI documentation endpoint is available |
| server management | Server management state (managed/discovered/manual) |
| shell integration | Whether Shell integration is loaded |
| bash environment | TERM setting and Bash version, which must be ≥ 4.0 |
| terminal | stdout TTY state, terminal width, and color support |
witty doctor does not start the server, so it has no side effects and is suitable for troubleshooting.
FAQ
Shell direct input does not work
- Run
witty doctorand check theshell integrationitem - If it reports
not loaded, runeval "$(witty init bash)"manually - Check whether
WITTY_SHELL_ENABLE=0is set
Natural language is executed as a shell command
The classifier uses a "Shell first" strategy, so some edge cases may be misjudged. Use /ask to force the Agent:
/ask how do I delete a docker imageServer unreachable
- Check whether
opencodeis installed:which opencode - Run
witty doctorfor detailed diagnostics - Try
witty server restart - If automatic startup is disabled, the error asks you to start
opencode serve --port 4096manually, or to specify an address with--server-url
Provider still unavailable after connecting
witty server restart
witty provider list --connected # confirm the connection statusSession context is lost
Witty CLI manages sessions by current directory:
- running
wittyor using Shell direct input in the same directory restores the most recent session - sessions are not shared after changing the directory
- use
/neworwitty ask --newto force a new session - use
/session listto view available sessions and/session continue <id>to switch
How to disable Witty CLI completely
export WITTY_SHELL_ENABLE=0 # disable Shell integration
witty server stop # stop the background server
sudo dnf remove witty # uninstallUninstallation removes /etc/profile.d/witty.sh automatically, leaving no residual files.
How to cancel the current request in the REPL
Press Ctrl+C to cancel the ongoing AI request; [cancelled] is printed and the REPL stays open.
