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:

bash
check system memory

Witty CLI recognizes it as natural language rather than a shell command, calls the AI assistant, and streams the answer:

bash
systemctl how do I view nginx logs

Input that starts with a known command but contains a question phrase is also routed to the AI assistant.

REPL Mode ​

bash
witty

Enter the interactive REPL; the prompt is witty [<agent>:<model>] > with a trailing space. Continue the conversation:

text
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 ​

bash
witty ask "check system memory"

Sends one request, streams the answer, and exits.

Pipe Input ​

bash
echo "explain this function" | witty ask
bash
dmesg | witty ask "analyze anomalies in this kernel log"

Connecting a Provider and Switching Models ​

bash
witty provider connect deepseek
Enter API key: **** (not echoed)
connected provider deepseek

Then enter the REPL and type /model to open the model selector:

text
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 cancel

Command Reference ​

Global Options ​

The following options apply to all subcommands:

OptionTypeDefaultDescription
--configstring""Path to the configuration file
--server-urlstring""opencode server address
--agentstring""Default agent
--modelstring""Default model, format provider/model
--variantstring""Model variant, such as the reasoning level
--debugboolfalseEnable debug logging
--no-colorboolfalseDisable colored output
--version, -v——Print version information

witty (no subcommand) — start the REPL ​

bash
witty

Starts the interactive REPL and restores the most recent session of the current directory, or creates a new one.

witty ask ​

bash
witty ask [prompt]

Sends a message, streams the answer, and exits when the answer finishes.

Options:

OptionTypeDescription
--newboolCreate a new session instead of reusing the session of the current directory
--sessionstringContinue the specified session ID

--new and --session cannot be used together.

witty init bash ​

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 ​

bash
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:

RouteBehavior
shellPassed to Bash as usual, no interference
agentHanded over to witty ask
controlHanded 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 ​

InputRouteReason
检查系统内存AgentCJK characters
systemctl 怎么看 nginx 日志AgentChinese trigger word 怎么看
systemctl status nginxShellKnown command, no natural language features
grep error /var/log/messagesShellKnown command, no natural language features
cat /etc/os-release | grep NAMEShellPipeline
/sessionControlWhitelisted slash command, shows detailed /session usage
/ask systemctl 怎么看 nginx 日志ControlWhitelisted slash command, forces an Agent request internally
/usr/bin/lsShellExplicit path
for i in 1; doShellShell syntax with strong syntax features such as ;
how do I restart nginxAgentEnglish 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=0 to ~/.bashrc
  • Debug mode: export WITTY_SHELL_DEBUG=1 prints classification results to stderr

Forcing the Agent ​

If the classifier misidentifies natural language as a shell command, use the /ask escape hatch:

bash
/ask how do I delete a docker image

Installation 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:

CommandPurpose
/helpShow help
/exit, /quit, /qExit 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
/newCreate a new session on the next request
/sessionShow detailed /session usage
/session listList 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:

text
/agent build

The selection is persisted to the user configuration file:

text
[agent] set to "build" (saved to ~/.config/witty/config.toml)

/model — switch model ​

The model format must be provider/model:

text
/model openai/gpt-4

Without 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:

text
[model] set to "deepseek/deepseek-v4-flash" (variant: max, saved to ~/.config/witty/config.toml)

Argument Validation Rules ​

CommandArgument Requirement
/askA prompt is required
/agentOptional argument
/modelOptional argument
/sessionNo argument; shows detailed /session usage
/session listNo argument
/session continueA session id is required
/newNo argument
/helpNo argument
/exit, /quit, /qNo argument

Configuration ​

Configuration Files ​

Witty CLI uses TOML configuration files, searched in the following order, with later entries overriding earlier ones:

  1. /etc/witty/config.toml (system level)
  2. ~/.config/witty/config.toml (user level)

Alternatively, specify a file with --config <path> or the environment variable WITTY_CONFIG.

Full Configuration ​

toml
# 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 / none

Configuration Override Environment Variables ​

Environment variables take precedence over the configuration file, and CLI options take precedence over environment variables.

Environment VariableConfiguration ItemDescription
WITTY_CONFIG—Path to the configuration file
WITTY_AGENTdefault_agentDefault agent
WITTY_MODELdefault_modelDefault model
WITTY_VARIANTdefault_variantModel variant
WITTY_DEBUGdebugDebug logging (true/false)
WITTY_SHELL_ENABLEshell.enabledEnable Shell integration (true/false)
WITTY_SHELL_DEBUGshell.debugShell integration debug mode (true/false)
WITTY_SERVER_AUTO_STARTserver.auto_startAutomatic startup (true/false)
WITTY_SERVER_PORTserver.portServer port
WITTY_SERVER_HOSTNAMEserver.hostnameBind address
WITTY_DISPLAY_SHOW_REASONINGdisplay.show_reasoningReasoning display
WITTY_DISPLAY_STEP_STYLEdisplay.step_styleStep display style
NO_COLORno_colorAny value disables colored output, following the NO_COLOR standard

Provider Management ​

Listing Providers ​

bash
witty provider list

Lists all providers that support API key authentication and shows the connection status:

text
STATUS     ID        NAME          DEFAULT_MODEL
-          openai    OpenAI        gpt-4
connected  deepseek  DeepSeek      deepseek-chat

List connected providers only:

bash
witty provider list --connected

Connecting a Provider ​

bash
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:

  1. The --key option
  2. Interactive terminal prompt: if stdin is a TTY, Enter API key: is shown and input is not echoed
  3. Read from the stdin pipe
  4. Environment variables such as OPENAI_API_KEY and DEEPSEEK_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.json with mode 0600
  • the next witty startup reuses the server seamlessly through the state file

Checking Status ​

bash
witty server status
text
Running:    yes
Port:       4096
PID:        12345
Managed:    no
StartedAt:  2026-08-19T10:30:00+08:00
  • Running: whether the server is running; this field is authoritative for server status
  • Managed: whether the server was started by the current process; since witty server status is a read-only command, Managed is always no here, which is expected; rely on Running

Stop / Restart ​

bash
witty server stop
witty server restart

Use witty server restart after installing or modifying agent / skill / MCP configuration files so that the server reloads the configuration:

bash
sudo dnf install witty-diagnosis-agent
witty server restart

Disabling Automatic Startup ​

toml
[server]
auto_start = false

With 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 ​

bash
witty doctor

The following items are checked, each reporting OK, WARN, FAIL, or SKIP:

CheckDescription
configConfiguration loading, current server/agent/model/shell settings
server reachableWhether the opencode server is reachable
/doc endpointWhether the OpenAPI documentation endpoint is available
server managementServer management state (managed/discovered/manual)
shell integrationWhether Shell integration is loaded
bash environmentTERM setting and Bash version, which must be ≥ 4.0
terminalstdout 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 ​

  1. Run witty doctor and check the shell integration item
  2. If it reports not loaded, run eval "$(witty init bash)" manually
  3. Check whether WITTY_SHELL_ENABLE=0 is 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:

bash
/ask how do I delete a docker image

Server unreachable ​

  • Check whether opencode is installed: which opencode
  • Run witty doctor for detailed diagnostics
  • Try witty server restart
  • If automatic startup is disabled, the error asks you to start opencode serve --port 4096 manually, or to specify an address with --server-url

Provider still unavailable after connecting ​

bash
witty server restart
witty provider list --connected  # confirm the connection status

Session context is lost ​

Witty CLI manages sessions by current directory:

  • running witty or using Shell direct input in the same directory restores the most recent session
  • sessions are not shared after changing the directory
  • use /new or witty ask --new to force a new session
  • use /session list to view available sessions and /session continue <id> to switch

How to disable Witty CLI completely ​

bash
export WITTY_SHELL_ENABLE=0   # disable Shell integration
witty server stop             # stop the background server
sudo dnf remove witty         # uninstall

Uninstallation 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.