@supatest/cli 0.0.2
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 +377 -0
- package/dist/agent-runner.js +417 -0
- package/dist/index.js +82 -0
- package/dist/types.js +1 -0
- package/dist/utils/banner.js +16 -0
- package/dist/utils/logger.js +107 -0
- package/dist/utils/node-version.js +91 -0
- package/dist/utils/rich-logger.js +208 -0
- package/dist/utils/stdin.js +25 -0
- package/dist/utils/summary.js +98 -0
- package/package.json +71 -0
package/README.md
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
# Supatest AI CLI
|
|
2
|
+
|
|
3
|
+
> AI-powered test automation for CI/CD - Fix failing tests, analyze logs, and automate debugging with Claude Sonnet 4.5
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
Supatest AI is a command-line tool that uses Claude's Agent SDK to automatically fix failing tests, debug issues, and perform code-related tasks in your CI/CD pipelines. Simply point it at your logs or describe your issue, and let AI handle the rest.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- 🤖 **Autonomous AI Agent** - Powered by Claude Sonnet 4.5
|
|
16
|
+
- 🔧 **Auto-Fix Tests** - Analyzes failures and fixes them automatically
|
|
17
|
+
- 📊 **Log Analysis** - Understands error logs and suggests fixes
|
|
18
|
+
- 🚀 **CI/CD Ready** - Perfect for automated pipelines
|
|
19
|
+
- 💻 **File Operations** - Can read, edit, and create files
|
|
20
|
+
- ⚡ **Fast Execution** - Compiled with Bun for speed
|
|
21
|
+
|
|
22
|
+
## Requirements
|
|
23
|
+
|
|
24
|
+
Before installing, ensure you have:
|
|
25
|
+
|
|
26
|
+
- **Node.js 18 or higher** - [Download Node.js](https://nodejs.org/)
|
|
27
|
+
- **Anthropic API Key** - [Get your key](https://console.anthropic.com/)
|
|
28
|
+
|
|
29
|
+
### Why Node.js?
|
|
30
|
+
|
|
31
|
+
The Supatest CLI is compiled with Bun for maximum performance, but it uses the Claude Agent SDK which requires Node.js to run the AI agent subprocess. This is similar to how other modern CLI tools (Next.js, Vercel, Turbo) work.
|
|
32
|
+
|
|
33
|
+
**Verify your Node.js version:**
|
|
34
|
+
```bash
|
|
35
|
+
node --version
|
|
36
|
+
# Should output: v18.0.0 or higher
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
If you need to install or upgrade Node.js:
|
|
40
|
+
- **macOS**: `brew install node` or download from [nodejs.org](https://nodejs.org/)
|
|
41
|
+
- **Linux**: Use your package manager or [nvm](https://github.com/nvm-sh/nvm)
|
|
42
|
+
- **Windows**: Download installer from [nodejs.org](https://nodejs.org/)
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
### Option 1: npm/pnpm/yarn (Recommended)
|
|
47
|
+
|
|
48
|
+
Install globally:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# npm
|
|
52
|
+
npm install -g @supatest/cli
|
|
53
|
+
|
|
54
|
+
# pnpm
|
|
55
|
+
pnpm add -g @supatest/cli
|
|
56
|
+
|
|
57
|
+
# yarn
|
|
58
|
+
yarn global add @supatest/cli
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Verify installation:
|
|
62
|
+
```bash
|
|
63
|
+
supatest-ai --version
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Or use npx without installation:**
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx @supatest/cli "your task here"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Option 2: Download Binary
|
|
73
|
+
|
|
74
|
+
1. **Download the latest release** from the [releases page](#)
|
|
75
|
+
|
|
76
|
+
2. **Make it executable** (macOS/Linux):
|
|
77
|
+
```bash
|
|
78
|
+
chmod +x supatest-ai
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
3. **Move to your PATH** (optional but recommended):
|
|
82
|
+
```bash
|
|
83
|
+
sudo mv supatest-ai /usr/local/bin/
|
|
84
|
+
sudo mv claude-code-cli.js /usr/local/bin/
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
4. **Verify installation**:
|
|
88
|
+
```bash
|
|
89
|
+
supatest-ai --version
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Option 3: Build from Source
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Clone the repository
|
|
96
|
+
git clone https://github.com/your-org/supatest
|
|
97
|
+
cd supatest/cli
|
|
98
|
+
|
|
99
|
+
# Install dependencies
|
|
100
|
+
pnpm install
|
|
101
|
+
|
|
102
|
+
# Build with Bun
|
|
103
|
+
pnpm build:bun
|
|
104
|
+
|
|
105
|
+
# The binary will be in dist/supatest-ai
|
|
106
|
+
./dist/supatest-ai --version
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Configuration
|
|
110
|
+
|
|
111
|
+
### Set Your Anthropic API Key
|
|
112
|
+
|
|
113
|
+
You can provide your API key in two ways:
|
|
114
|
+
|
|
115
|
+
**Option 1: Environment Variable (Recommended)**
|
|
116
|
+
```bash
|
|
117
|
+
export ANTHROPIC_API_KEY="sk-ant-api03-..."
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Add this to your `~/.bashrc`, `~/.zshrc`, or `~/.profile` to persist it.
|
|
121
|
+
|
|
122
|
+
**Option 2: Command-line Flag**
|
|
123
|
+
```bash
|
|
124
|
+
supatest-ai "your task" --api-key="sk-ant-api03-..."
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Optional: Set Default Model
|
|
128
|
+
|
|
129
|
+
By default, Supatest uses Claude Sonnet 4.5. To use a different model:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
export ANTHROPIC_MODEL_NAME="claude-haiku-4-5" # Faster, cheaper
|
|
133
|
+
# or
|
|
134
|
+
export ANTHROPIC_MODEL_NAME="claude-opus-4-5" # Most capable
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Usage
|
|
138
|
+
|
|
139
|
+
### Basic Syntax
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
supatest-ai [task] [options]
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Common Examples
|
|
146
|
+
|
|
147
|
+
#### Fix Failing Tests
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Automatically detect and fix test failures
|
|
151
|
+
supatest-ai "run the tests and fix any failures"
|
|
152
|
+
|
|
153
|
+
# Fix specific test file
|
|
154
|
+
supatest-ai "fix the failing tests in calculator.test.js"
|
|
155
|
+
|
|
156
|
+
# With verbose logging
|
|
157
|
+
supatest-ai "fix failing tests" --verbose
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### Analyze Log Files
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# From a log file
|
|
164
|
+
supatest-ai "analyze and fix the errors" --logs error.log
|
|
165
|
+
|
|
166
|
+
# From stdin (pipe logs)
|
|
167
|
+
npm test 2>&1 | supatest-ai "fix the test failures" --stdin
|
|
168
|
+
|
|
169
|
+
# CI/CD example
|
|
170
|
+
./run-tests.sh 2>&1 | supatest-ai "analyze failures and suggest fixes" --stdin
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### Code Tasks
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Add functionality
|
|
177
|
+
supatest-ai "add error handling to the divide function"
|
|
178
|
+
|
|
179
|
+
# Refactor code
|
|
180
|
+
supatest-ai "refactor math.js to use modern ES6 syntax"
|
|
181
|
+
|
|
182
|
+
# Create files
|
|
183
|
+
supatest-ai "create a new test file for the user authentication module"
|
|
184
|
+
|
|
185
|
+
# Update dependencies
|
|
186
|
+
supatest-ai "update all package imports to use the new package structure"
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Command-line Options
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
Options:
|
|
193
|
+
-l, --logs <file> Path to log file to analyze
|
|
194
|
+
--stdin Read logs from stdin
|
|
195
|
+
-m, --max-iterations <number> Maximum number of iterations (default: 100)
|
|
196
|
+
--api-key <key> Anthropic API key (or use ANTHROPIC_API_KEY env)
|
|
197
|
+
--verbose Enable verbose logging for debugging
|
|
198
|
+
-V, --version Output the version number
|
|
199
|
+
-h, --help Display help information
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Examples by Use Case
|
|
203
|
+
|
|
204
|
+
### CI/CD Integration
|
|
205
|
+
|
|
206
|
+
**GitHub Actions:**
|
|
207
|
+
```yaml
|
|
208
|
+
name: Fix Tests with AI
|
|
209
|
+
on: [push]
|
|
210
|
+
jobs:
|
|
211
|
+
fix-tests:
|
|
212
|
+
runs-on: ubuntu-latest
|
|
213
|
+
steps:
|
|
214
|
+
- uses: actions/checkout@v3
|
|
215
|
+
- uses: actions/setup-node@v3
|
|
216
|
+
with:
|
|
217
|
+
node-version: '18'
|
|
218
|
+
|
|
219
|
+
- name: Run tests and fix failures
|
|
220
|
+
env:
|
|
221
|
+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
222
|
+
run: |
|
|
223
|
+
npm test 2>&1 | npx @supatest/cli "fix any test failures" --stdin --verbose
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**GitLab CI:**
|
|
227
|
+
```yaml
|
|
228
|
+
fix_tests:
|
|
229
|
+
image: node:18
|
|
230
|
+
script:
|
|
231
|
+
- npm test 2>&1 | npx @supatest/cli "analyze and fix test failures" --stdin
|
|
232
|
+
variables:
|
|
233
|
+
ANTHROPIC_API_KEY: $ANTHROPIC_API_KEY
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Local Development
|
|
237
|
+
|
|
238
|
+
**Quick test fix:**
|
|
239
|
+
```bash
|
|
240
|
+
# Run tests, capture output, and auto-fix
|
|
241
|
+
npm test 2>&1 | tee test.log && supatest-ai "fix failures" --logs test.log
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Debug build errors:**
|
|
245
|
+
```bash
|
|
246
|
+
npm run build 2>&1 | supatest-ai "analyze build errors and fix" --stdin
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**Interactive development:**
|
|
250
|
+
```bash
|
|
251
|
+
# Let AI help with your task
|
|
252
|
+
supatest-ai "help me implement pagination for the user list"
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Troubleshooting
|
|
256
|
+
|
|
257
|
+
### "Node.js 18+ is required"
|
|
258
|
+
|
|
259
|
+
**Problem:** You see an error about Node.js version.
|
|
260
|
+
|
|
261
|
+
**Solution:**
|
|
262
|
+
1. Check your version: `node --version`
|
|
263
|
+
2. Install/upgrade Node.js: [nodejs.org](https://nodejs.org/)
|
|
264
|
+
3. Use nvm to manage versions: `nvm install 18`
|
|
265
|
+
|
|
266
|
+
### "ANTHROPIC_API_KEY environment variable required"
|
|
267
|
+
|
|
268
|
+
**Problem:** API key not set.
|
|
269
|
+
|
|
270
|
+
**Solution:**
|
|
271
|
+
```bash
|
|
272
|
+
# Set the environment variable
|
|
273
|
+
export ANTHROPIC_API_KEY="sk-ant-api03-your-key-here"
|
|
274
|
+
|
|
275
|
+
# Or use the flag
|
|
276
|
+
supatest-ai "task" --api-key="sk-ant-api03-your-key-here"
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### "Claude Code process exited with code 1"
|
|
280
|
+
|
|
281
|
+
**Problem:** The AI agent subprocess failed.
|
|
282
|
+
|
|
283
|
+
**Solutions:**
|
|
284
|
+
1. Check Node.js is properly installed: `which node`
|
|
285
|
+
2. Verify your API key is valid
|
|
286
|
+
3. Run with `--verbose` to see detailed errors
|
|
287
|
+
4. Ensure you have internet connectivity
|
|
288
|
+
5. Check the task is code-related and actionable
|
|
289
|
+
|
|
290
|
+
Example verbose run:
|
|
291
|
+
```bash
|
|
292
|
+
supatest-ai "your task" --verbose 2>&1 | tee debug.log
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Task Keeps Running
|
|
296
|
+
|
|
297
|
+
**Problem:** The agent doesn't stop.
|
|
298
|
+
|
|
299
|
+
**Solutions:**
|
|
300
|
+
- Use `--max-iterations` to limit turns
|
|
301
|
+
- Make your task more specific
|
|
302
|
+
- Press Ctrl+C to abort
|
|
303
|
+
|
|
304
|
+
### Files Not Being Modified
|
|
305
|
+
|
|
306
|
+
**Problem:** Agent doesn't make expected changes.
|
|
307
|
+
|
|
308
|
+
**Solutions:**
|
|
309
|
+
1. Make your request more specific:
|
|
310
|
+
- ❌ "fix tests"
|
|
311
|
+
- ✅ "fix the failing test in calculator.test.js by correcting the divide function"
|
|
312
|
+
|
|
313
|
+
2. Check file permissions:
|
|
314
|
+
```bash
|
|
315
|
+
ls -la calculator.test.js
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
3. Ensure files exist in the working directory
|
|
319
|
+
|
|
320
|
+
## Distribution Files
|
|
321
|
+
|
|
322
|
+
When you build or download Supatest AI, you get:
|
|
323
|
+
|
|
324
|
+
```
|
|
325
|
+
dist/
|
|
326
|
+
├── supatest-ai # Main binary (Bun-compiled)
|
|
327
|
+
└── claude-code-cli.js # Claude Agent SDK CLI (10MB)
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
**Both files must be distributed together.** The binary needs `claude-code-cli.js` to function.
|
|
331
|
+
|
|
332
|
+
## System Requirements
|
|
333
|
+
|
|
334
|
+
- **OS**: macOS, Linux, or Windows (WSL recommended)
|
|
335
|
+
- **Node.js**: 18.0.0 or higher
|
|
336
|
+
- **Memory**: 512MB minimum, 2GB recommended
|
|
337
|
+
- **Disk**: 50MB for binaries
|
|
338
|
+
- **Network**: Internet connection required for API calls
|
|
339
|
+
|
|
340
|
+
## Development
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
# Run in dev mode
|
|
344
|
+
pnpm dev -- "Your task here"
|
|
345
|
+
|
|
346
|
+
# Build with TypeScript
|
|
347
|
+
pnpm build
|
|
348
|
+
|
|
349
|
+
# Build standalone binary
|
|
350
|
+
pnpm build:bun
|
|
351
|
+
|
|
352
|
+
# Type check
|
|
353
|
+
pnpm type-check
|
|
354
|
+
|
|
355
|
+
# Clean build artifacts
|
|
356
|
+
pnpm clean:bundle
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
## Support
|
|
360
|
+
|
|
361
|
+
- **Issues**: [GitHub Issues](https://github.com/your-org/supatest/issues)
|
|
362
|
+
- **Discussions**: [GitHub Discussions](https://github.com/your-org/supatest/discussions)
|
|
363
|
+
|
|
364
|
+
## License
|
|
365
|
+
|
|
366
|
+
ISC License - see LICENSE file for details
|
|
367
|
+
|
|
368
|
+
## Acknowledgments
|
|
369
|
+
|
|
370
|
+
Built with:
|
|
371
|
+
- [Claude Agent SDK](https://docs.claude.com/en/docs/agent-sdk/overview) by Anthropic
|
|
372
|
+
- [Bun](https://bun.sh) - Fast JavaScript runtime and bundler
|
|
373
|
+
- [Commander.js](https://github.com/tj/commander.js) - CLI framework
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
**Made with ❤️ for developers who want AI-powered automation**
|