goatchain-cli 0.0.2-beta.7 → 0.0.2-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +357 -0
- package/dist/index.js +41 -41
- package/dist/repl-BJ1k0t50.js +67 -0
- package/dist/src-Bn5rRoW_.js +1 -0
- package/dist/src-D4Jdivhi.js +284 -0
- package/dist/ui-DXDqNsuQ.js +3 -0
- package/package.json +4 -1
- package/dist/repl-zlpRWQLH.js +0 -70
- package/dist/src-C6lykTfV.js +0 -1
- package/dist/src-CDNnudke.js +0 -258
- package/dist/ui-DM2shvqf.js +0 -3
package/README.md
ADDED
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
# GoatChain CLI 🐐
|
|
2
|
+
|
|
3
|
+
> Interactive AI agent CLI for software engineering tasks with built-in file operations, web search, and planning capabilities
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/goatchain-cli)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## ✨ Features
|
|
9
|
+
|
|
10
|
+
- **🤖 Interactive AI Agent** - Real-time conversation with AI assistant for coding tasks
|
|
11
|
+
- **📁 File Operations** - Read, write, edit files with built-in safety checks
|
|
12
|
+
- **🔍 Code Navigation** - Glob search, grep, and AST-aware code analysis
|
|
13
|
+
- **🌐 Web Search** - Integrated web search for up-to-date information
|
|
14
|
+
- **📋 Plan Mode** - Structured planning workflow (plan → confirm → execute)
|
|
15
|
+
- **💾 Session Management** - Save and restore conversation sessions
|
|
16
|
+
- **🔧 Tool Integration** - Built-in tools for common development tasks
|
|
17
|
+
- **🖼️ Image Support** - Attach and analyze images in conversations
|
|
18
|
+
- **⚙️ Configurable** - Flexible configuration via environment and config files
|
|
19
|
+
|
|
20
|
+
## 🚀 Quick Start
|
|
21
|
+
|
|
22
|
+
### Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Install globally via npm
|
|
26
|
+
npm install -g goatchain-cli
|
|
27
|
+
|
|
28
|
+
# Or use npx (recommended for first-time use)
|
|
29
|
+
npx goatchain-cli
|
|
30
|
+
|
|
31
|
+
# Or install locally in your project
|
|
32
|
+
npm install --save-dev goatchain-cli
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Basic Usage
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Set your OpenAI API key
|
|
39
|
+
export OPENAI_API_KEY=your-api-key-here
|
|
40
|
+
|
|
41
|
+
# Start the CLI
|
|
42
|
+
goatchain
|
|
43
|
+
|
|
44
|
+
# Or with npx
|
|
45
|
+
npx goatchain-cli
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### First Conversation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
$ goatchain
|
|
52
|
+
🤖 GoatChain CLI v0.0.2-beta.6
|
|
53
|
+
|
|
54
|
+
Welcome! I'm your AI assistant. Type /help for commands or ask me anything.
|
|
55
|
+
|
|
56
|
+
> Can you help me understand this TypeScript project?
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 📦 Installation Methods
|
|
60
|
+
|
|
61
|
+
### Method 1: Global Installation (Recommended)
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm install -g goatchain-cli
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Method 2: Project-based Installation
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Add to your project
|
|
71
|
+
npm install --save-dev goatchain-cli
|
|
72
|
+
|
|
73
|
+
# Run from project directory
|
|
74
|
+
npx goatchain
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Method 3: Direct from GitHub
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Run directly from GitHub repository
|
|
81
|
+
npx github:zjywill/GoatChain#main:packages/cli
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## ⚙️ Configuration
|
|
85
|
+
|
|
86
|
+
### Environment Variables
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Required: OpenAI API key
|
|
90
|
+
export OPENAI_API_KEY=sk-...
|
|
91
|
+
|
|
92
|
+
# Optional: Web search (Serper API)
|
|
93
|
+
export SERPER_API_KEY=your-serper-key
|
|
94
|
+
|
|
95
|
+
# Optional: Default model
|
|
96
|
+
export GOATCHAIN_DEFAULT_MODEL=gpt-4o
|
|
97
|
+
|
|
98
|
+
# Optional: Enable plan mode by default
|
|
99
|
+
export GOATCHAIN_PLAN_MODE=1
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Local Configuration File
|
|
103
|
+
|
|
104
|
+
Create `.goatchain/config.json` in your project:
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"model": {
|
|
109
|
+
"provider": "openai",
|
|
110
|
+
"modelId": "gpt-4o"
|
|
111
|
+
},
|
|
112
|
+
"tools": {
|
|
113
|
+
"webSearch": {
|
|
114
|
+
"apiKey": "your-serper-key",
|
|
115
|
+
"numResults": 10
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"planMode": "on"
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## 🎯 Commands Reference
|
|
123
|
+
|
|
124
|
+
### Core Commands
|
|
125
|
+
|
|
126
|
+
| Command | Description |
|
|
127
|
+
|---------|-------------|
|
|
128
|
+
| `/help` | Show help information |
|
|
129
|
+
| `/model <id>` | Switch model (e.g., `gpt-4o`, `gpt-3.5-turbo`) |
|
|
130
|
+
| `/plan [on|off|toggle]` | Toggle plan mode |
|
|
131
|
+
| `/approvals` | Select approval mode |
|
|
132
|
+
| `/set <key> <value>` | Set request parameters |
|
|
133
|
+
| `/unset <key>` | Clear a parameter |
|
|
134
|
+
| `/params` | Show current parameters |
|
|
135
|
+
|
|
136
|
+
### Session Management
|
|
137
|
+
|
|
138
|
+
| Command | Description |
|
|
139
|
+
|---------|-------------|
|
|
140
|
+
| `/sessions` | List saved sessions |
|
|
141
|
+
| `/use <sessionId>` | Restore a session |
|
|
142
|
+
| `/save` | Save current session |
|
|
143
|
+
| `/new` | Start new conversation |
|
|
144
|
+
| `/status` | Show current status |
|
|
145
|
+
|
|
146
|
+
### Tool Configuration
|
|
147
|
+
|
|
148
|
+
| Command | Description |
|
|
149
|
+
|---------|-------------|
|
|
150
|
+
| `/tools` | List enabled tools |
|
|
151
|
+
| `/base-url <url>` | Set API base URL |
|
|
152
|
+
| `/api-key <key>` | Set API key |
|
|
153
|
+
| `/web-search-key <key>` | Set web search API key |
|
|
154
|
+
|
|
155
|
+
## 🔧 Built-in Tools
|
|
156
|
+
|
|
157
|
+
### File Operations
|
|
158
|
+
|
|
159
|
+
- **Read** - Read files and directories
|
|
160
|
+
- **Write** - Create new files
|
|
161
|
+
- **Edit** - Modify existing files
|
|
162
|
+
- **Glob** - Pattern-based file search
|
|
163
|
+
- **Grep** - Content search across files
|
|
164
|
+
|
|
165
|
+
### Development Tools
|
|
166
|
+
|
|
167
|
+
- **WebSearch** - Internet search for current information
|
|
168
|
+
- **AskUserQuestion** - Interactive user prompts for decisions
|
|
169
|
+
- **TodoWrite** - Structured task planning
|
|
170
|
+
- **Bash** - Execute shell commands
|
|
171
|
+
|
|
172
|
+
### Code Analysis
|
|
173
|
+
|
|
174
|
+
- **ast_grep_search** - AST-aware code pattern matching
|
|
175
|
+
- **ast_grep_replace** - AST-aware code refactoring
|
|
176
|
+
|
|
177
|
+
## 📋 Plan Mode
|
|
178
|
+
|
|
179
|
+
Plan mode enables a structured workflow for complex tasks:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# Enable plan mode
|
|
183
|
+
/plan on
|
|
184
|
+
|
|
185
|
+
# Workflow:
|
|
186
|
+
# 1. Agent explores codebase and researches request
|
|
187
|
+
# 2. May ask clarifying questions
|
|
188
|
+
# 3. Creates structured plan (3-8 steps)
|
|
189
|
+
# 4. You review and approve plan
|
|
190
|
+
# 5. Agent executes approved plan
|
|
191
|
+
|
|
192
|
+
# File modifications are blocked during planning phase
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## 💾 Session Management
|
|
196
|
+
|
|
197
|
+
Sessions preserve conversation history and context:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# List available sessions
|
|
201
|
+
/sessions
|
|
202
|
+
|
|
203
|
+
# Restore a specific session
|
|
204
|
+
/use session-id-here
|
|
205
|
+
|
|
206
|
+
# Save current session
|
|
207
|
+
/save
|
|
208
|
+
|
|
209
|
+
# Start fresh
|
|
210
|
+
/new
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Sessions are stored in `.goatchain/sessions/` (gitignored).
|
|
214
|
+
|
|
215
|
+
## 🔍 Web Search Integration
|
|
216
|
+
|
|
217
|
+
Enable web search for current information:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# Set web search API key
|
|
221
|
+
/web-search-key your-serper-api-key
|
|
222
|
+
|
|
223
|
+
# Or set environment variable
|
|
224
|
+
export SERPER_API_KEY=your-key
|
|
225
|
+
|
|
226
|
+
# Web search will be available for weather, news, and current events
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## 🖼️ Image Support
|
|
230
|
+
|
|
231
|
+
Attach images to conversations for analysis:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
# The agent can analyze images you attach
|
|
235
|
+
# Supported formats: PNG, JPG, JPEG
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## 🚀 Advanced Usage
|
|
239
|
+
|
|
240
|
+
### Command Line Arguments
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
# Set API key via command line
|
|
244
|
+
goatchain --api-key sk-...
|
|
245
|
+
|
|
246
|
+
# Specify model
|
|
247
|
+
goatchain --model gpt-4o
|
|
248
|
+
|
|
249
|
+
# Set custom base URL
|
|
250
|
+
goatchain --base-url https://api.openai.com/v1
|
|
251
|
+
|
|
252
|
+
# Configure request parameters
|
|
253
|
+
goatchain --max-tokens 2000 --temperature 0.7
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Integration with Projects
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
# Run in specific directory
|
|
260
|
+
cd /path/to/your/project
|
|
261
|
+
goatchain
|
|
262
|
+
|
|
263
|
+
# The agent will automatically detect and analyze your codebase
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Environment-Specific Configuration
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
# Development environment
|
|
270
|
+
export GOATCHAIN_PLAN_MODE=1
|
|
271
|
+
export GOATCHAIN_DEFAULT_MODEL=gpt-4o
|
|
272
|
+
|
|
273
|
+
# Production-like environment (more conservative)
|
|
274
|
+
export GOATCHAIN_PLAN_MODE=0
|
|
275
|
+
export GOATCHAIN_DEFAULT_MODEL=gpt-3.5-turbo
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## 🛠️ Development
|
|
279
|
+
|
|
280
|
+
### Building from Source
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
# Clone the repository
|
|
284
|
+
git clone https://github.com/zjywill/GoatChain.git
|
|
285
|
+
cd GoatChain/packages/cli
|
|
286
|
+
|
|
287
|
+
# Install dependencies
|
|
288
|
+
npm install
|
|
289
|
+
|
|
290
|
+
# Build the project
|
|
291
|
+
npm run build
|
|
292
|
+
|
|
293
|
+
# Test the CLI
|
|
294
|
+
npm run smoke
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Project Structure
|
|
298
|
+
|
|
299
|
+
```
|
|
300
|
+
packages/cli/
|
|
301
|
+
├── src/
|
|
302
|
+
│ ├── index.ts # Main CLI entry point
|
|
303
|
+
│ ├── args.ts # Command line argument parsing
|
|
304
|
+
│ ├── sdk.ts # GoatChain SDK integration
|
|
305
|
+
│ ├── repl.ts # Interactive REPL implementation
|
|
306
|
+
│ ├── turn.ts # Turn processing logic
|
|
307
|
+
│ └── tools/ # Built-in tool implementations
|
|
308
|
+
├── dist/ # Built output
|
|
309
|
+
└── package.json
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## 🐛 Troubleshooting
|
|
313
|
+
|
|
314
|
+
### Common Issues
|
|
315
|
+
|
|
316
|
+
**"API key not found"**
|
|
317
|
+
```bash
|
|
318
|
+
# Set OpenAI API key
|
|
319
|
+
export OPENAI_API_KEY=your-key
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
**"Model not available"**
|
|
323
|
+
```bash
|
|
324
|
+
# Switch to available model
|
|
325
|
+
/model gpt-3.5-turbo
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
**Web search not working**
|
|
329
|
+
```bash
|
|
330
|
+
# Set Serper API key
|
|
331
|
+
/web-search-key your-key
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
**File operations failing**
|
|
335
|
+
- Check file permissions
|
|
336
|
+
- Ensure files exist and are accessible
|
|
337
|
+
- Verify path correctness
|
|
338
|
+
|
|
339
|
+
### Debug Mode
|
|
340
|
+
|
|
341
|
+
Enable verbose logging:
|
|
342
|
+
```bash
|
|
343
|
+
export DEBUG=goatchain:*
|
|
344
|
+
goatchain
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
## 🤝 Contributing
|
|
348
|
+
|
|
349
|
+
Contributions are welcome! Please see the main [GoatChain repository](https://github.com/zjywill/GoatChain) for contribution guidelines.
|
|
350
|
+
|
|
351
|
+
## 📄 License
|
|
352
|
+
|
|
353
|
+
MIT © [Simon He](https://github.com/Simon-He95)
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
**Need help?** Type `/help` in the CLI or open an issue on GitHub.
|