@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.
Files changed (75) hide show
  1. package/README.md +58 -315
  2. package/dist/agent-runner.js +224 -52
  3. package/dist/commands/login.js +392 -0
  4. package/dist/commands/setup.js +234 -0
  5. package/dist/config.js +29 -0
  6. package/dist/core/agent.js +270 -0
  7. package/dist/index.js +118 -31
  8. package/dist/modes/headless.js +117 -0
  9. package/dist/modes/interactive.js +430 -0
  10. package/dist/presenters/composite.js +32 -0
  11. package/dist/presenters/console.js +163 -0
  12. package/dist/presenters/react.js +220 -0
  13. package/dist/presenters/types.js +1 -0
  14. package/dist/presenters/web.js +78 -0
  15. package/dist/prompts/builder.js +181 -0
  16. package/dist/prompts/fixer.js +148 -0
  17. package/dist/prompts/headless.md +97 -0
  18. package/dist/prompts/index.js +3 -0
  19. package/dist/prompts/interactive.md +43 -0
  20. package/dist/prompts/plan.md +41 -0
  21. package/dist/prompts/planner.js +70 -0
  22. package/dist/prompts/prompts/builder.md +97 -0
  23. package/dist/prompts/prompts/fixer.md +100 -0
  24. package/dist/prompts/prompts/plan.md +41 -0
  25. package/dist/prompts/prompts/planner.md +41 -0
  26. package/dist/services/api-client.js +244 -0
  27. package/dist/services/event-streamer.js +130 -0
  28. package/dist/ui/App.js +322 -0
  29. package/dist/ui/components/AuthBanner.js +20 -0
  30. package/dist/ui/components/AuthDialog.js +32 -0
  31. package/dist/ui/components/Banner.js +12 -0
  32. package/dist/ui/components/ExpandableSection.js +17 -0
  33. package/dist/ui/components/Header.js +49 -0
  34. package/dist/ui/components/HelpMenu.js +89 -0
  35. package/dist/ui/components/InputPrompt.js +292 -0
  36. package/dist/ui/components/MessageList.js +42 -0
  37. package/dist/ui/components/QueuedMessageDisplay.js +31 -0
  38. package/dist/ui/components/Scrollable.js +103 -0
  39. package/dist/ui/components/SessionSelector.js +196 -0
  40. package/dist/ui/components/StatusBar.js +45 -0
  41. package/dist/ui/components/messages/AssistantMessage.js +20 -0
  42. package/dist/ui/components/messages/ErrorMessage.js +26 -0
  43. package/dist/ui/components/messages/LoadingMessage.js +28 -0
  44. package/dist/ui/components/messages/ThinkingMessage.js +17 -0
  45. package/dist/ui/components/messages/TodoMessage.js +44 -0
  46. package/dist/ui/components/messages/ToolMessage.js +218 -0
  47. package/dist/ui/components/messages/UserMessage.js +14 -0
  48. package/dist/ui/contexts/KeypressContext.js +527 -0
  49. package/dist/ui/contexts/MouseContext.js +98 -0
  50. package/dist/ui/contexts/SessionContext.js +131 -0
  51. package/dist/ui/hooks/useAnimatedScrollbar.js +83 -0
  52. package/dist/ui/hooks/useBatchedScroll.js +22 -0
  53. package/dist/ui/hooks/useBracketedPaste.js +31 -0
  54. package/dist/ui/hooks/useFocus.js +50 -0
  55. package/dist/ui/hooks/useKeypress.js +26 -0
  56. package/dist/ui/hooks/useModeToggle.js +25 -0
  57. package/dist/ui/types/auth.js +13 -0
  58. package/dist/ui/utils/file-completion.js +56 -0
  59. package/dist/ui/utils/input.js +50 -0
  60. package/dist/ui/utils/markdown.js +376 -0
  61. package/dist/ui/utils/mouse.js +189 -0
  62. package/dist/ui/utils/theme.js +59 -0
  63. package/dist/utils/banner.js +7 -14
  64. package/dist/utils/encryption.js +71 -0
  65. package/dist/utils/events.js +36 -0
  66. package/dist/utils/keychain-storage.js +120 -0
  67. package/dist/utils/logger.js +103 -1
  68. package/dist/utils/node-version.js +1 -3
  69. package/dist/utils/plan-file.js +75 -0
  70. package/dist/utils/project-instructions.js +23 -0
  71. package/dist/utils/rich-logger.js +1 -1
  72. package/dist/utils/stdio.js +80 -0
  73. package/dist/utils/summary.js +1 -5
  74. package/dist/utils/token-storage.js +242 -0
  75. package/package.json +35 -15
package/README.md CHANGED
@@ -1,377 +1,120 @@
1
1
  # Supatest AI CLI
2
2
 
3
- > AI-powered test automation for CI/CD - Fix failing tests, analyze logs, and automate debugging with Claude Sonnet 4.5
4
-
5
- ![Supatest AI Banner](https://img.shields.io/badge/AI-Powered-blue?style=for-the-badge)
6
- ![Node.js](https://img.shields.io/badge/Node.js-18%2B-brightgreen?style=for-the-badge)
7
- ![License](https://img.shields.io/badge/License-ISC-yellow?style=for-the-badge)
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 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.
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
- - 🤖 **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
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
- 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/)
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
- **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
26
+ Or use npx without installing:
93
27
 
94
28
  ```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
29
+ npx @supatest/cli
107
30
  ```
108
31
 
109
- ## Configuration
110
-
111
- ### Set Your Anthropic API Key
112
-
113
- You can provide your API key in two ways:
32
+ ## Usage
114
33
 
115
- **Option 1: Environment Variable (Recommended)**
116
- ```bash
117
- export ANTHROPIC_API_KEY="sk-ant-api03-..."
118
- ```
34
+ ### Interactive Mode
119
35
 
120
- Add this to your `~/.bashrc`, `~/.zshrc`, or `~/.profile` to persist it.
36
+ Run without arguments to start interactive mode:
121
37
 
122
- **Option 2: Command-line Flag**
123
38
  ```bash
124
- supatest-ai "your task" --api-key="sk-ant-api03-..."
39
+ supatest
125
40
  ```
126
41
 
127
- ### Optional: Set Default Model
42
+ On first run, type `/login` to authenticate with your Supatest account.
128
43
 
129
- By default, Supatest uses Claude Sonnet 4.5. To use a different model:
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
- ## Usage
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
- ### Common Examples
52
+ ### Headless Mode (CI)
146
53
 
147
- #### Fix Failing Tests
54
+ For CI/CD pipelines, set your API key and pass a task:
148
55
 
149
56
  ```bash
150
- # Automatically detect and fix test failures
151
- supatest-ai "run the tests and fix any failures"
57
+ export SUPATEST_API_KEY="your-api-key"
152
58
 
153
- # Fix specific test file
154
- supatest-ai "fix the failing tests in calculator.test.js"
59
+ # Fix failing tests from a log file
60
+ supatest "fix the failing tests" --logs test-output.log
155
61
 
156
- # With verbose logging
157
- supatest-ai "fix failing tests" --verbose
62
+ # Pipe test output directly
63
+ npm test 2>&1 | supatest "fix any failures" --stdin
158
64
  ```
159
65
 
160
- #### Analyze Log Files
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> 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
- ```
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
- ## Examples by Use Case
81
+ Commands:
82
+ setup Check prerequisites and set up required tools
83
+ ```
203
84
 
204
- ### CI/CD Integration
85
+ ## CI/CD Integration
205
86
 
206
87
  **GitHub Actions:**
88
+
207
89
  ```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
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
- fix_tests:
229
- image: node:18
105
+ test:
230
106
  script:
231
- - npm test 2>&1 | npx @supatest/cli "analyze and fix test failures" --stdin
107
+ - npm test 2>&1 | tee test-output.log || true
108
+ - npx @supatest/cli "fix failures" --logs test-output.log
232
109
  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
110
+ SUPATEST_API_KEY: $SUPATEST_API_KEY
357
111
  ```
358
112
 
359
113
  ## Support
360
114
 
361
- - **Issues**: [GitHub Issues](https://github.com/your-org/supatest/issues)
362
- - **Discussions**: [GitHub Discussions](https://github.com/your-org/supatest/discussions)
115
+ - [Documentation](https://supatest.ai/docs)
116
+ - [GitHub Issues](https://github.com/AvereSoftware/supatest/issues)
363
117
 
364
118
  ## License
365
119
 
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**
120
+ ISC