Skip to content

Commit 757326a

Browse files
committed
update README.md
1 parent d54197a commit 757326a

2 files changed

Lines changed: 86 additions & 133 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
vendor/
22

33
# Build output
4-
ai
4+
ai
5+
6+
.idea

README.md

Lines changed: 83 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A command-line tool that generates shell commands from natural language descript
99
- 🛡️ Safety-first approach with read-only preferences
1010
- 📊 Verbose mode with detailed API response information
1111
- 🎯 Interactive command selection
12-
- 🔧 Cross-platform support (Linux, macOS)
12+
- 🔧 Cross-platform support (Linux, macOS, windows etc)
1313

1414
## Installation
1515

@@ -24,106 +24,120 @@ A command-line tool that generates shell commands from natural language descript
2424
go install github.com/brainexe/ai@latest
2525
```
2626

27-
### Option 2: Download Pre-built Binaries
28-
29-
Download the latest release for your platform from the [releases page](https://github.com/brainexe/ai/releases).
30-
31-
Available platforms:
32-
- Linux (amd64, arm64)
33-
- macOS (amd64, arm64)
34-
- Windows (amd64)
35-
36-
### Option 3: Build from Source
27+
### Option 2: Build from Source
3728

3829
```bash
3930
# Clone the repository
4031
git clone https://github.com/brainexe/ai.git
4132
cd ai-cli
4233

43-
# Install dependencies
44-
go mod tidy
45-
46-
# Build the project
4734
make build
4835
```
4936

5037
## Setup
5138

5239
1. Set your OpenAI API token:
53-
```bash
54-
export OPENAI_TOKEN="your-openai-token-here"
55-
```
56-
57-
2. Make the binary executable (if needed):
58-
```bash
59-
chmod +x ai
60-
```
40+
```bash
41+
export OPENAI_TOKEN="your-openai-token-here"
42+
```
6143

6244
## Usage
6345

64-
### Basic Usage
46+
### Examples
6547

6648
```bash
67-
# Find the largest file in current directory
68-
./ai "find biggest file here"
69-
70-
# List files in current directory
71-
./ai "list files in current dir"
72-
73-
# Search for text in files
74-
./ai "search for TODO in all files"
49+
ai "find biggest file here"
50+
Select a command:
51+
1) find . -type f -exec ls -la {} + | sort -k5 -nr | head -1
52+
2) du -ah . | sort -rh | head -1
53+
3) ls -lah | sort -k5 -nr | head -1
54+
Enter number: 1
7555
```
7656

77-
### Command Options
78-
79-
#### Verbose Mode
57+
```bash
58+
ai "search for TODO in all files"
59+
Select a command:
60+
1) grep -r "TODO" .
61+
2) find . -name "*.go" -exec grep -l "TODO" {} +
62+
3) grep -rn "TODO" .
63+
Enter number: 1
64+
```
8065

81-
Use the `-v` flag to see detailed information about API calls and generated commands:
66+
```bash
67+
ai "show files modified in last 24 hours"
68+
Select a command:
69+
1) find . -type f -mtime -1
70+
2) ls -lt | head -10
71+
3) find . -type f -newermt "1 day ago"
72+
Enter number: 1
73+
```
8274

8375
```bash
84-
./ai -v "show disk usage of directories"
76+
ai bpftrace trace all page faults, show pid, application name
77+
Select a command:
78+
1) sudo bpftrace -e 'tracepoint:exceptions:page_fault_user { printf("%d %s\n", pid, comm); }'
79+
2) sudo bpftrace -e 'tracepoint:exceptions:page_fault_user { printf("%d %s %s\n", pid, comm, str(args->address)); }'
80+
3) sudo bpftrace -e 'tracepoint:exceptions:page_fault_user { printf("%d %s %s\n", pid, comm, args->message ? args->message : ""); }'
8581
```
8682

87-
#### Number of Commands
83+
```bash
84+
ai "count lines in all go files"
85+
Select a command:
86+
1) find . -name "*.go" -exec wc -l {} +
87+
2) cloc .
88+
3) find . -name "*.go" | xargs wc -l
89+
Enter number: 1
90+
```
8891

89-
Use the `-n` flag to specify how many commands to generate (default: 3):
92+
```bash
93+
ai "find all TODO comments in source code"
94+
Select a command:
95+
1) grep -r "TODO" .
96+
2) find . -name "*.go" -exec grep -n "TODO" {} +
97+
3) grep -rn "TODO" .
98+
Enter number: 1
99+
```
90100

91101
```bash
92-
# Generate 5 command options
93-
./ai -n 5 "find large files"
102+
ai "replace tabs with spaces in all files"
103+
Select a command:
104+
1) find . -name "*.go" -exec sed -i 's/\t/ /g' {} +
105+
2) find . -type f -name "*.go" -exec expand -t 4 {} \; -exec mv {}.exp {} \;
106+
3) sed -i 's/\t/ /g' *.go
107+
Enter number: 1
108+
```
94109

95-
# Combine with verbose mode
96-
./ai -v -n 2 "show disk usage"
110+
```bash
111+
ai "check if port 8080 is open"
112+
Select a command:
113+
1) netstat -tuln | grep 8080
114+
2) lsof -i :8080
115+
3) ss -tuln | grep 8080
116+
Enter number: 1
97117
```
98118

99-
Verbose mode displays:
100-
- Number of commands generated
101-
- API request timing information
102-
- All generated command options
103-
- Raw API responses (pretty-printed JSON)
119+
### Command Options
104120

105-
### Interactive Selection
121+
#### Verbose Mode
106122

107-
When multiple commands are generated, you'll be prompted to select one:
123+
Use the `-v` flag to see detailed information about API calls and generated commands:
108124

109-
```
125+
#### Number of Commands
126+
127+
Use the `-n` flag to specify how many commands to generate (default: 3):
128+
129+
```bash
130+
# Generate 5 command options
131+
ai -n 5 "find large files"
110132
Select a command:
111-
1) find . -type f -exec ls -la {} + | sort -k5 -nr | head -1
112-
2) du -ah . | sort -rh | head -1
113-
3) ls -lah | sort -k5 -nr | head -1
133+
1) find . -type f -size +100M
134+
2) du -ah . | sort -rh | head -10
135+
3) find . -type f -exec ls -lh {} + | awk '$5 ~ /[0-9]+M/'
136+
4) ls -lah | sort -k5 -hr | head -10
137+
5) find . -type f -size +50M -exec ls -lh {} +
114138
Enter number: 1
115139
```
116140

117-
## How It Works
118-
119-
1. **Context Gathering**: Collects system information (OS, shell, architecture)
120-
2. **Prompt Building**: Creates a safety-focused prompt with task description
121-
3. **Concurrent API Calls**: Makes multiple concurrent requests to OpenAI API
122-
4. **Command Generation**: Extracts and sanitizes shell commands from responses
123-
5. **Deduplication**: Removes duplicate commands across API responses
124-
6. **Interactive Selection**: Allows user to choose from available options
125-
7. **Safe Execution**: Runs the selected command with inherited stdio
126-
127141
## Safety Features
128142

129143
- **Read-only preference**: Prioritizes non-destructive commands
@@ -137,85 +151,22 @@ Enter number: 1
137151
### Build Commands
138152

139153
```bash
140-
# Build the project
154+
# build the "ai" binary
141155
make build
142156

143-
# Clean build artifacts
144-
make clean
145-
146157
# Run linter
147158
make lint
148159
```
149160

150-
### CI/CD Pipeline
151-
152-
The project uses GitHub Actions for continuous integration and deployment:
153-
154-
- **CI Pipeline**: Runs on every push and pull request
155-
- Builds and tests the code
156-
- Runs linter checks
157-
- Creates build artifacts for all supported platforms
158-
159-
- **Release Pipeline**: Triggered on version tags
160-
- Builds binaries for all platforms (Linux, macOS, Windows)
161-
- Creates GitHub releases with downloadable artifacts
162-
- Supports both amd64 and arm64 architectures
163-
164-
### Code Style
165-
166-
- Follow Go standard formatting (`gofmt`)
167-
- Adhere to `golangci-lint` rules
168-
- Use single responsibility functions
169-
- Employ clear variable names
170-
171-
## Examples
172-
173-
```bash
174-
# File operations
175-
./ai "show files modified in last 24 hours"
176-
./ai "count lines in all go files"
177-
178-
# System information
179-
./ai "show memory usage"
180-
./ai "list running processes"
181-
182-
# Text processing
183-
./ai "find all TODO comments in source code"
184-
./ai "replace tabs with spaces in all files"
185-
186-
# Network operations
187-
./ai "check if port 8080 is open"
188-
./ai "show network connections"
189-
```
190-
191161
## Configuration
192162

193163
The tool uses the following environment variables:
194164

195-
- `OPENAI_TOKEN`: Your OpenAI API token (required)
196-
- `SHELL`: Shell to use for command execution (defaults to system shell)
197-
198-
## API Details
199-
200-
- **Model**: gpt-5-mini
201-
- **Endpoint**: OpenAI Responses API
202-
- **Concurrent calls**: Configurable (default: 3)
203-
- **Timeout**: 30 seconds per request
204-
- **Max output tokens**: 500
165+
- `OPENAI_TOKEN`: Your OpenAI API token in env vars (required)
205166

206167
## License
207168

208-
This project is licensed under the terms specified in the LICENSE file.
209-
210-
## Contributing
211-
212-
1. Fork the repository
213-
2. Create a feature branch
214-
3. Make your changes
215-
4. Run `make lint` to ensure code quality
216-
5. Submit a pull request
217-
218-
## Troubleshooting
169+
This project is licensed under MIT License, see the LICENSE file.
219170

220171
### Common Issues
221172

@@ -228,15 +179,15 @@ This project is licensed under the terms specified in the LICENSE file.
228179
- Verify your OpenAI API token is valid
229180

230181
**Command not found**
231-
- Make sure the binary is in your PATH or use the full path `./ai`
182+
- Make sure the binary is in your PATH or use the full path `ai`
232183
- Verify the binary has execute permissions
233184

234185
### Verbose Mode for Debugging
235186

236187
Use the `-v` flag to see detailed information about what's happening:
237188

238189
```bash
239-
./ai -v "your command description"
190+
ai -v "your command description"
240191
```
241192

242193
This will show API response times, generated commands, and raw API responses to help diagnose issues.

0 commit comments

Comments
 (0)