@supatest/cli 0.0.2 → 0.0.3
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 +58 -315
- package/dist/agent-runner.js +224 -52
- package/dist/commands/login.js +392 -0
- package/dist/commands/setup.js +234 -0
- package/dist/config.js +29 -0
- package/dist/core/agent.js +270 -0
- package/dist/index.js +118 -31
- package/dist/modes/headless.js +117 -0
- package/dist/modes/interactive.js +430 -0
- package/dist/presenters/composite.js +32 -0
- package/dist/presenters/console.js +163 -0
- package/dist/presenters/react.js +220 -0
- package/dist/presenters/types.js +1 -0
- package/dist/presenters/web.js +78 -0
- package/dist/prompts/builder.js +181 -0
- package/dist/prompts/fixer.js +148 -0
- package/dist/prompts/headless.md +97 -0
- package/dist/prompts/index.js +3 -0
- package/dist/prompts/interactive.md +43 -0
- package/dist/prompts/plan.md +41 -0
- package/dist/prompts/planner.js +70 -0
- package/dist/prompts/prompts/builder.md +97 -0
- package/dist/prompts/prompts/fixer.md +100 -0
- package/dist/prompts/prompts/plan.md +41 -0
- package/dist/prompts/prompts/planner.md +41 -0
- package/dist/services/api-client.js +244 -0
- package/dist/services/event-streamer.js +130 -0
- package/dist/ui/App.js +322 -0
- package/dist/ui/components/AuthBanner.js +20 -0
- package/dist/ui/components/AuthDialog.js +32 -0
- package/dist/ui/components/Banner.js +12 -0
- package/dist/ui/components/ExpandableSection.js +17 -0
- package/dist/ui/components/Header.js +49 -0
- package/dist/ui/components/HelpMenu.js +89 -0
- package/dist/ui/components/InputPrompt.js +292 -0
- package/dist/ui/components/MessageList.js +42 -0
- package/dist/ui/components/QueuedMessageDisplay.js +31 -0
- package/dist/ui/components/Scrollable.js +103 -0
- package/dist/ui/components/SessionSelector.js +196 -0
- package/dist/ui/components/StatusBar.js +45 -0
- package/dist/ui/components/messages/AssistantMessage.js +20 -0
- package/dist/ui/components/messages/ErrorMessage.js +26 -0
- package/dist/ui/components/messages/LoadingMessage.js +28 -0
- package/dist/ui/components/messages/ThinkingMessage.js +17 -0
- package/dist/ui/components/messages/TodoMessage.js +44 -0
- package/dist/ui/components/messages/ToolMessage.js +218 -0
- package/dist/ui/components/messages/UserMessage.js +14 -0
- package/dist/ui/contexts/KeypressContext.js +527 -0
- package/dist/ui/contexts/MouseContext.js +98 -0
- package/dist/ui/contexts/SessionContext.js +131 -0
- package/dist/ui/hooks/useAnimatedScrollbar.js +83 -0
- package/dist/ui/hooks/useBatchedScroll.js +22 -0
- package/dist/ui/hooks/useBracketedPaste.js +31 -0
- package/dist/ui/hooks/useFocus.js +50 -0
- package/dist/ui/hooks/useKeypress.js +26 -0
- package/dist/ui/hooks/useModeToggle.js +25 -0
- package/dist/ui/types/auth.js +13 -0
- package/dist/ui/utils/file-completion.js +56 -0
- package/dist/ui/utils/input.js +50 -0
- package/dist/ui/utils/markdown.js +376 -0
- package/dist/ui/utils/mouse.js +189 -0
- package/dist/ui/utils/theme.js +59 -0
- package/dist/utils/banner.js +7 -14
- package/dist/utils/encryption.js +71 -0
- package/dist/utils/events.js +36 -0
- package/dist/utils/keychain-storage.js +120 -0
- package/dist/utils/logger.js +103 -1
- package/dist/utils/node-version.js +1 -3
- package/dist/utils/plan-file.js +75 -0
- package/dist/utils/project-instructions.js +23 -0
- package/dist/utils/rich-logger.js +1 -1
- package/dist/utils/stdio.js +80 -0
- package/dist/utils/summary.js +1 -5
- package/dist/utils/token-storage.js +242 -0
- package/package.json +35 -15
package/README.md
CHANGED
|
@@ -1,377 +1,120 @@
|
|
|
1
1
|
# Supatest AI CLI
|
|
2
2
|
|
|
3
|
-
> AI
|
|
4
|
-
|
|
5
|
-

|
|
6
|
-

|
|
7
|
-

|
|
3
|
+
> AI agent for E2E tests - Build, debug, and fix tests with AI assistance
|
|
8
4
|
|
|
9
5
|
## Overview
|
|
10
6
|
|
|
11
|
-
Supatest AI is
|
|
7
|
+
Supatest AI is an AI-powered CLI that helps you write and maintain E2E tests. Use it interactively to build tests from scratch, or integrate it into CI to automatically fix failing tests.
|
|
12
8
|
|
|
13
9
|
## Features
|
|
14
10
|
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
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
|
|
11
|
+
- **Build Tests** - Describe what to test in natural language, get working tests
|
|
12
|
+
- **Debug Failures** - AI investigates and fixes failing tests
|
|
13
|
+
- **Fix in CI** - Pipe test logs and let AI fix issues automatically
|
|
21
14
|
|
|
22
15
|
## Requirements
|
|
23
16
|
|
|
24
|
-
|
|
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/)
|
|
17
|
+
- **Node.js 18+** - [Download Node.js](https://nodejs.org/)
|
|
18
|
+
- **Supatest API Key** - [Get your key](https://supatest.ai)
|
|
43
19
|
|
|
44
20
|
## Installation
|
|
45
21
|
|
|
46
|
-
### Option 1: npm/pnpm/yarn (Recommended)
|
|
47
|
-
|
|
48
|
-
Install globally:
|
|
49
|
-
|
|
50
22
|
```bash
|
|
51
|
-
# npm
|
|
52
23
|
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
24
|
```
|
|
65
25
|
|
|
66
|
-
|
|
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
|
|
26
|
+
Or use npx without installing:
|
|
93
27
|
|
|
94
28
|
```bash
|
|
95
|
-
|
|
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
|
|
29
|
+
npx @supatest/cli
|
|
107
30
|
```
|
|
108
31
|
|
|
109
|
-
##
|
|
110
|
-
|
|
111
|
-
### Set Your Anthropic API Key
|
|
112
|
-
|
|
113
|
-
You can provide your API key in two ways:
|
|
32
|
+
## Usage
|
|
114
33
|
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
export ANTHROPIC_API_KEY="sk-ant-api03-..."
|
|
118
|
-
```
|
|
34
|
+
### Interactive Mode
|
|
119
35
|
|
|
120
|
-
|
|
36
|
+
Run without arguments to start interactive mode:
|
|
121
37
|
|
|
122
|
-
**Option 2: Command-line Flag**
|
|
123
38
|
```bash
|
|
124
|
-
supatest
|
|
39
|
+
supatest
|
|
125
40
|
```
|
|
126
41
|
|
|
127
|
-
|
|
42
|
+
On first run, type `/login` to authenticate with your Supatest account.
|
|
128
43
|
|
|
129
|
-
|
|
44
|
+
Then describe what you want to test:
|
|
130
45
|
|
|
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
46
|
```
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
### Basic Syntax
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
supatest-ai [task] [options]
|
|
47
|
+
> Write a test for the login flow
|
|
48
|
+
> Add a test that verifies users can add items to cart
|
|
49
|
+
> Test the checkout process with a valid credit card
|
|
143
50
|
```
|
|
144
51
|
|
|
145
|
-
###
|
|
52
|
+
### Headless Mode (CI)
|
|
146
53
|
|
|
147
|
-
|
|
54
|
+
For CI/CD pipelines, set your API key and pass a task:
|
|
148
55
|
|
|
149
56
|
```bash
|
|
150
|
-
|
|
151
|
-
supatest-ai "run the tests and fix any failures"
|
|
57
|
+
export SUPATEST_API_KEY="your-api-key"
|
|
152
58
|
|
|
153
|
-
# Fix
|
|
154
|
-
supatest
|
|
59
|
+
# Fix failing tests from a log file
|
|
60
|
+
supatest "fix the failing tests" --logs test-output.log
|
|
155
61
|
|
|
156
|
-
#
|
|
157
|
-
supatest
|
|
62
|
+
# Pipe test output directly
|
|
63
|
+
npm test 2>&1 | supatest "fix any failures" --stdin
|
|
158
64
|
```
|
|
159
65
|
|
|
160
|
-
|
|
66
|
+
### Options
|
|
161
67
|
|
|
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
68
|
```
|
|
69
|
+
supatest [task] [options]
|
|
172
70
|
|
|
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
71
|
Options:
|
|
193
|
-
-l, --logs <file>
|
|
194
|
-
--stdin
|
|
195
|
-
|
|
196
|
-
--
|
|
197
|
-
--
|
|
198
|
-
|
|
199
|
-
-
|
|
200
|
-
|
|
72
|
+
-l, --logs <file> Path to log file to analyze
|
|
73
|
+
--stdin Read logs from stdin
|
|
74
|
+
--headless Force headless mode (no interactive UI)
|
|
75
|
+
-m, --max-iterations Maximum AI turns (default: 100)
|
|
76
|
+
-C, --cwd <path> Working directory
|
|
77
|
+
--verbose Enable verbose logging
|
|
78
|
+
-V, --version Show version
|
|
79
|
+
-h, --help Show help
|
|
201
80
|
|
|
202
|
-
|
|
81
|
+
Commands:
|
|
82
|
+
setup Check prerequisites and set up required tools
|
|
83
|
+
```
|
|
203
84
|
|
|
204
|
-
|
|
85
|
+
## CI/CD Integration
|
|
205
86
|
|
|
206
87
|
**GitHub Actions:**
|
|
88
|
+
|
|
207
89
|
```yaml
|
|
208
|
-
name:
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
|
90
|
+
- name: Run tests
|
|
91
|
+
id: tests
|
|
92
|
+
continue-on-error: true
|
|
93
|
+
run: npm test 2>&1 | tee test-output.log
|
|
94
|
+
|
|
95
|
+
- name: Fix failing tests
|
|
96
|
+
if: steps.tests.outcome == 'failure'
|
|
97
|
+
env:
|
|
98
|
+
SUPATEST_API_KEY: ${{ secrets.SUPATEST_API_KEY }}
|
|
99
|
+
run: npx @supatest/cli "fix the failing tests" --logs test-output.log
|
|
224
100
|
```
|
|
225
101
|
|
|
226
102
|
**GitLab CI:**
|
|
103
|
+
|
|
227
104
|
```yaml
|
|
228
|
-
|
|
229
|
-
image: node:18
|
|
105
|
+
test:
|
|
230
106
|
script:
|
|
231
|
-
- npm test 2>&1 |
|
|
107
|
+
- npm test 2>&1 | tee test-output.log || true
|
|
108
|
+
- npx @supatest/cli "fix failures" --logs test-output.log
|
|
232
109
|
variables:
|
|
233
|
-
|
|
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
|
|
110
|
+
SUPATEST_API_KEY: $SUPATEST_API_KEY
|
|
357
111
|
```
|
|
358
112
|
|
|
359
113
|
## Support
|
|
360
114
|
|
|
361
|
-
-
|
|
362
|
-
-
|
|
115
|
+
- [Documentation](https://supatest.ai/docs)
|
|
116
|
+
- [GitHub Issues](https://github.com/AvereSoftware/supatest/issues)
|
|
363
117
|
|
|
364
118
|
## License
|
|
365
119
|
|
|
366
|
-
ISC
|
|
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**
|
|
120
|
+
ISC
|