CLI Assistant Integration
Converts natural language queries into shell commands using LLM with streaming output.
Turn plain English into shell commands instantly — build a streaming CLI assistant that speaks your language and runs in your terminal.
Edition
Section titled “Edition”Community — runs on the OSS / Community SDK edition.
Overview
Section titled “Overview”This example demonstrates a practical CLI tool that translates human-readable requests into executable shell commands. It showcases streaming for real-time output as the command is generated.
What this demonstrates
Section titled “What this demonstrates”Difficulty: Starter 🟢 · LLM
- Summary: Interactive CLI assistant with LLM backend
- Scenario: Build an interactive terminal assistant powered by an LLM
tech_tagsin manifest:LLM— example idcli-assistantinconformance/examples_manifest.json.
Prerequisites
Section titled “Prerequisites”- SDK: Use an installed SDK tree (
NXUSKIT_SDK_DIR,NXUSKIT_LIB_PATHas needed);test-examples.shresolves Go/Rust/Python deps from that tree only — see README.md,scripts/setup-sdk.sh, andscripts/test-examples.sh. - Languages in this example: go, rust (paths under this directory; Python may live under a sibling
python/or shared reference per Language Implementations). - Models: Set cloud provider API keys and/or run Ollama locally when you execute the Run steps (interactive flags like
--help/--verboseare documented below).
Real-World Application
Section titled “Real-World Application”Developer productivity tool, command-line copilot.
Technologies
Section titled “Technologies”LLM
Language Implementations
Section titled “Language Implementations”| Language | Path | Status |
|---|---|---|
| Rust | rust/ | Available |
| Go | go/ | Available |
Features
Section titled “Features”- Natural language to shell command translation
- Streaming output shows command as it’s generated
- Safety comments for dangerous operations
- Works with common Unix commands
Example Queries
Section titled “Example Queries”| Query | Generated Command |
|---|---|
| ”find all rust files modified in the last week” | find . -name "*.rs" -mtime -7 |
| ”show disk usage sorted by size” | du -sh * | sort -h |
| ”list all running docker containers” | docker ps |
cd rust && cargo buildcd ../go && make buildLibrary usage
Section titled “Library usage”use nxuskit::prelude::*;
let provider = OllamaProvider::builder().model("llama3").build()?;let command = generate_command(&provider, query).await?;println!("Generated: {}", command);command, err := GenerateCommand(ctx, provider, query)fmt.Println("Generated:", command)cd rustcargo run
# Interactive modecargo run -- "your query here"cd gogo run .
# Interactive modego run . "your query here"Interactive Modes
Section titled “Interactive Modes”All examples support debugging flags:
# Verbose mode - show raw HTTP request/response datacargo run -- --verbose # Rustgo run . --verbose # Go
# Step mode - pause at each step with explanationscargo run -- --step # Rustgo run . --step # Go
# Combined modecargo run -- --verbose --stepOr use environment variables:
export NXUSKIT_VERBOSE=1export NXUSKIT_STEP=1Safety Considerations
Section titled “Safety Considerations”The LLM is instructed to:
- Add warning comments for dangerous operations (rm -rf, etc.)
- Use common, well-known Unix commands
- Provide clarifying comments for ambiguous requests
Important: Always review generated commands before executing them.
Extending the Example
Section titled “Extending the Example”Ideas for enhancement:
- Add command execution with confirmation prompt
- Implement command history
- Add support for platform-specific commands (Windows, macOS, Linux)
- Include command explanation mode
- Add syntax highlighting for output