A truly autonomous AI assistant for your terminal. Like ChatGPT, but for command-line operations.
- π€ Autonomous AI Agent - AI can gather information and make decisions
- π¬ Conversational Interface - Chat naturally with your CLI
- π§ Execute Commands - AI can run shell commands with your permission
- π Gather Information - AI automatically gets the info it needs
- π¨ Beautiful UI - Clean, colorful output
- π Safe - Always asks for confirmation before executing
# 1. Clone or download the project
cd smartcli
# 2. Install dependencies
npm install
# 3. Set your OpenAI API key
export OPENAI_API_KEY="sk-your-key-here"
# 4. Build
npm run build
# 5. Link globally (optional)
npm link
# 6. Run!
smartcliInteractive Mode:
smartcliOne-Shot Commands:
smartcli create a folder named notes
smartcli generate a commit message
smartcli explain recursionThe AI has three modes of operation:
When you ask it to do something:
You: Create a file named app.js with hello world
AI: I'll create a file with console.log
ββ Command:
β echo 'console.log("Hello World");' > app.js
ββ
? Execute this command? Yes
β Done
When AI needs data, it automatically gathers it:
You: Generate a commit message
AI: I'll check your staged changes first.
π€ AI gathering information...
βοΈ git diff --cached --name-only
β Done
βοΈ git diff --cached
β Done
π§ Processing information...
AI: Based on your changes, I suggest:
"feat: add user authentication module
- Implement login functionality
- Add JWT token handling"
Would you like me to commit with this message?
For questions and explanations:
You: Explain recursion
AI: Recursion is a programming technique where a function calls
itself to solve a problem. It consists of two parts:
1. Base case: The condition that stops recursion
2. Recursive case: The function calling itself
Example:
function factorial(n) {
if (n === 0) return 1; // base case
return n * factorial(n - 1); // recursive case
}
smartcli create a folder structure for a react project
smartcli find all javascript files larger than 100kb
smartcli backup all my config filessmartcli generate a commit message
smartcli show me what changed in the last commit
smartcli create a new branch called feature-authsmartcli what's taking up disk space
smartcli show me all running node processes
smartcli check if port 3000 is availablesmartcli count lines of code in my project
smartcli find all TODO comments
smartcli check for console.log statementssmartcli explain docker containers
smartcli what is a closure in javascript
smartcli how does git rebase workThe AI uses special markers to communicate its intentions:
```execute
mkdir notesAI uses this when it wants to run a command that modifies something.
### Gather Block
```markdown
```gather
git status
AI uses this to silently get information it needs.
You'll see the AI's reasoning and can approve or deny any execution.
## ποΈ Architecture
User Input β AI Agent (GPT-4) β βββββββββββββββ¬ββββββββββββββ¬βββββββββββββββ β Gather β Execute β Respond β β (silent) β (confirmed) β (direct) β βββββββββββββββ΄ββββββββββββββ΄βββββββββββββββ β Result to User
The AI can:
1. Run commands to gather info (automatically)
2. Execute commands with user approval
3. Respond with explanations (no commands)
## π Project Structure
smartcli/ βββ src/ β βββ index.ts # Main entry point β βββ ai-agent.ts # AI logic β βββ ui.ts # Display utilities βββ package.json βββ tsconfig.json βββ README.md
**That's it!** Simple, clean architecture.
## π¨ UI Examples
### Welcome Screen
ββββββββββββββββββββββββββββββββββββββββββββββ β SmartCLI - AI Assistant β ββββββββββββββββββββββββββββββββββββββββββββββ
An intelligent CLI powered by GPT-4 Ask me anything or tell me what to do!
### AI Response
π€ AI: I'll create that folder for you.
ββ Command: β mkdir notes ββ
? Execute this command? Yes β Done
### Information Gathering
π€ AI gathering information... βοΈ git diff --cached --name-only β Done βοΈ git diff --cached β Done π§ Processing information...
π€ AI: Based on your changes...
## βοΈ Configuration
### Environment Variables
Create `.env` file:
```bash
OPENAI_API_KEY=sk-your-key-here
Or export:
export OPENAI_API_KEY="sk-your-key-here"Make it permanent (add to ~/.zshrc or ~/.bashrc):
echo 'export OPENAI_API_KEY="sk-your-key-here"' >> ~/.zshrc
source ~/.zshrcTry these commands to test functionality:
# Simple command
smartcli create a test file
# Needs information gathering
smartcli generate a commit message
# Pure explanation
smartcli explain promises in javascript
# Complex operation
smartcli find and list all large files
# Interactive conversation
smartcli
> create a new project structure
> what files do I have
> explain the last command
> exitexport OPENAI_API_KEY="sk-your-key"npm link
# or run directly:
npm run devrm -rf node_modules dist
npm install
npm run build- Be conversational - "Create a folder named notes" or just "make a notes folder"
- Ask questions - AI will gather info it needs automatically
- Multi-step operations - AI can handle complex workflows
- Review before executing - Always check what AI wants to run
- Iterate - If something doesn't work, just ask AI to fix it
- AI always asks before executing commands
- You can see exactly what will run
- No commands are hidden
- Uses bash for execution (same as your terminal)
# Development mode
npm run dev
# Build
npm run build
# Watch mode
npm run watchThis is a simple, clean codebase. Feel free to:
- Add features
- Improve AI prompts
- Enhance UI
- Fix bugs
MIT
- OpenAI for GPT-4
- The Node.js community
Built with β€οΈ for developers who want AI assistance in their terminal