vibecodingmachine-cli 1.0.5 → 1.0.6
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/.allnightai/REQUIREMENTS.md +11 -11
- package/.allnightai/temp/auto-status.json +6 -0
- package/.env +7 -0
- package/.eslintrc.js +16 -16
- package/README.md +85 -85
- package/bin/vibecodingmachine.js +274 -274
- package/jest.config.js +8 -8
- package/logs/audit/2025-11-07.jsonl +2 -2
- package/package.json +62 -62
- package/scripts/README.md +128 -128
- package/scripts/auto-start-wrapper.sh +92 -92
- package/scripts/postinstall.js +81 -81
- package/src/commands/auth.js +96 -96
- package/src/commands/auto-direct.js +1748 -1748
- package/src/commands/auto.js +4692 -4692
- package/src/commands/auto.js.bak +710 -710
- package/src/commands/ide.js +70 -70
- package/src/commands/repo.js +159 -159
- package/src/commands/requirements.js +161 -161
- package/src/commands/setup.js +91 -91
- package/src/commands/status.js +88 -88
- package/src/index.js +5 -5
- package/src/utils/auth.js +571 -577
- package/src/utils/auto-mode-ansi-ui.js +238 -238
- package/src/utils/auto-mode-simple-ui.js +161 -161
- package/src/utils/auto-mode-ui.js.bak.blessed +207 -207
- package/src/utils/auto-mode.js +65 -65
- package/src/utils/config.js +64 -64
- package/src/utils/interactive.js +3616 -3616
- package/src/utils/keyboard-handler.js +153 -152
- package/src/utils/logger.js +4 -4
- package/src/utils/persistent-header.js +116 -116
- package/src/utils/provider-registry.js +128 -128
- package/src/utils/status-card.js +120 -120
- package/src/utils/stdout-interceptor.js +127 -127
- package/tests/auto-mode.test.js +37 -37
- package/tests/config.test.js +34 -34
package/package.json
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "vibecodingmachine-cli",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Command-line interface for Vibe Coding Machine - Autonomous development",
|
|
5
|
-
"main": "src/index.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"vibecodingmachine": "./bin/vibecodingmachine.js",
|
|
8
|
-
"vcm": "./bin/vibecodingmachine.js"
|
|
9
|
-
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"postinstall": "node scripts/postinstall.js",
|
|
12
|
-
"test": "jest",
|
|
13
|
-
"test:watch": "jest --watch",
|
|
14
|
-
"lint": "eslint src/ --ext .js",
|
|
15
|
-
"format": "prettier --write \"src/**/*.js\""
|
|
16
|
-
},
|
|
17
|
-
"keywords": [
|
|
18
|
-
"vibecodingmachine",
|
|
19
|
-
"cli",
|
|
20
|
-
"ai",
|
|
21
|
-
"autonomous",
|
|
22
|
-
"development",
|
|
23
|
-
"ide"
|
|
24
|
-
],
|
|
25
|
-
"author": "Vibe Coding Machine Team",
|
|
26
|
-
"license": "MIT",
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"vibecodingmachine-core": "^1.0.1",
|
|
29
|
-
"boxen": "^5.1.2",
|
|
30
|
-
"chalk": "^4.1.2",
|
|
31
|
-
"chokidar": "^3.6.0",
|
|
32
|
-
"commander": "^11.1.0",
|
|
33
|
-
"fs-extra": "^11.2.0",
|
|
34
|
-
"ink": "^6.4.0",
|
|
35
|
-
"inquirer": "^8.2.6",
|
|
36
|
-
"js-yaml": "^4.1.0",
|
|
37
|
-
"jsonwebtoken": "^9.0.2",
|
|
38
|
-
"jwks-rsa": "^3.2.0",
|
|
39
|
-
"node-fetch": "^2.7.0",
|
|
40
|
-
"open": "^11.0.0",
|
|
41
|
-
"ora": "^5.4.1",
|
|
42
|
-
"react": "^19.2.0",
|
|
43
|
-
"table": "^6.8.1"
|
|
44
|
-
},
|
|
45
|
-
"devDependencies": {
|
|
46
|
-
"eslint": "^8.57.0",
|
|
47
|
-
"jest": "^29.7.0",
|
|
48
|
-
"prettier": "^3.2.5"
|
|
49
|
-
},
|
|
50
|
-
"engines": {
|
|
51
|
-
"node": ">=18.0.0"
|
|
52
|
-
},
|
|
53
|
-
"repository": {
|
|
54
|
-
"type": "git",
|
|
55
|
-
"url": "https://github.com/mediawink/vibecodingmachine.git",
|
|
56
|
-
"directory": "packages/cli"
|
|
57
|
-
},
|
|
58
|
-
"homepage": "http://vibecodingmachine-website.s3-website-us-east-1.amazonaws.com",
|
|
59
|
-
"bugs": {
|
|
60
|
-
"url": "https://github.com/mediawink/vibecodingmachine/issues"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "vibecodingmachine-cli",
|
|
3
|
+
"version": "1.0.6",
|
|
4
|
+
"description": "Command-line interface for Vibe Coding Machine - Autonomous development",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"vibecodingmachine": "./bin/vibecodingmachine.js",
|
|
8
|
+
"vcm": "./bin/vibecodingmachine.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"postinstall": "node scripts/postinstall.js",
|
|
12
|
+
"test": "jest",
|
|
13
|
+
"test:watch": "jest --watch",
|
|
14
|
+
"lint": "eslint src/ --ext .js",
|
|
15
|
+
"format": "prettier --write \"src/**/*.js\""
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"vibecodingmachine",
|
|
19
|
+
"cli",
|
|
20
|
+
"ai",
|
|
21
|
+
"autonomous",
|
|
22
|
+
"development",
|
|
23
|
+
"ide"
|
|
24
|
+
],
|
|
25
|
+
"author": "Vibe Coding Machine Team",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"vibecodingmachine-core": "^1.0.1",
|
|
29
|
+
"boxen": "^5.1.2",
|
|
30
|
+
"chalk": "^4.1.2",
|
|
31
|
+
"chokidar": "^3.6.0",
|
|
32
|
+
"commander": "^11.1.0",
|
|
33
|
+
"fs-extra": "^11.2.0",
|
|
34
|
+
"ink": "^6.4.0",
|
|
35
|
+
"inquirer": "^8.2.6",
|
|
36
|
+
"js-yaml": "^4.1.0",
|
|
37
|
+
"jsonwebtoken": "^9.0.2",
|
|
38
|
+
"jwks-rsa": "^3.2.0",
|
|
39
|
+
"node-fetch": "^2.7.0",
|
|
40
|
+
"open": "^11.0.0",
|
|
41
|
+
"ora": "^5.4.1",
|
|
42
|
+
"react": "^19.2.0",
|
|
43
|
+
"table": "^6.8.1"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"eslint": "^8.57.0",
|
|
47
|
+
"jest": "^29.7.0",
|
|
48
|
+
"prettier": "^3.2.5"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=18.0.0"
|
|
52
|
+
},
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "https://github.com/mediawink/vibecodingmachine.git",
|
|
56
|
+
"directory": "packages/cli"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "http://vibecodingmachine-website.s3-website-us-east-1.amazonaws.com",
|
|
59
|
+
"bugs": {
|
|
60
|
+
"url": "https://github.com/mediawink/vibecodingmachine/issues"
|
|
61
|
+
}
|
|
62
|
+
}
|
package/scripts/README.md
CHANGED
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
# Auto Start Wrapper Script
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
The `auto-start-wrapper.sh` script provides **reliable Ctrl+C handling** for `ana auto:start`.
|
|
6
|
-
|
|
7
|
-
## Problem
|
|
8
|
-
|
|
9
|
-
Due to a Node.js limitation, SIGINT (Ctrl+C) signals don't reliably reach the event loop when Node.js is blocked waiting for child processes (like Aider). **This means Ctrl+C does NOT work when running `ana auto:start` directly.**
|
|
10
|
-
|
|
11
|
-
## Recommended Usage
|
|
12
|
-
|
|
13
|
-
**If you want Ctrl+C to work**, use the wrapper script instead of running `ana auto:start` directly:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
# From anywhere (recommended)
|
|
17
|
-
~/.asdf/installs/nodejs/20.19.5/lib/node_modules/@vibecodingmachine/cli/scripts/auto-start-wrapper.sh
|
|
18
|
-
|
|
19
|
-
# Or if you know the package location
|
|
20
|
-
/path/to/vibecodingmachine/packages/cli/scripts/auto-start-wrapper.sh
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### Creating a Convenient Alias
|
|
24
|
-
|
|
25
|
-
Add this to your `~/.zshrc` or `~/.bashrc`:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
# Alias for ana auto:start with Ctrl+C support
|
|
29
|
-
alias ana-start='~/.asdf/installs/nodejs/20.19.5/lib/node_modules/@vibecodingmachine/cli/scripts/auto-start-wrapper.sh'
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Then you can simply run:
|
|
33
|
-
```bash
|
|
34
|
-
ana-start
|
|
35
|
-
ana-start --max-chats 10
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Solution
|
|
39
|
-
|
|
40
|
-
This wrapper script:
|
|
41
|
-
1. Runs `ana auto:start` in the background
|
|
42
|
-
2. Monitors keyboard input in the foreground (in the wrapper's process)
|
|
43
|
-
3. When Ctrl+C, Esc, or 'x' is pressed, creates a `.stop` file
|
|
44
|
-
4. The running `ana` process detects the file (via watchdog timer) and exits gracefully
|
|
45
|
-
|
|
46
|
-
## Usage
|
|
47
|
-
|
|
48
|
-
### Direct Usage
|
|
49
|
-
```bash
|
|
50
|
-
# From the project root
|
|
51
|
-
./packages/cli/scripts/auto-start-wrapper.sh
|
|
52
|
-
|
|
53
|
-
# Or with options
|
|
54
|
-
./packages/cli/scripts/auto-start-wrapper.sh --max-chats 5
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### How to Stop
|
|
58
|
-
- **Ctrl+C**: Stops the process (most common)
|
|
59
|
-
- **Esc key**: Stops the process
|
|
60
|
-
- **'x' key**: Stops the process
|
|
61
|
-
- **`ana auto:stop`**: From another terminal
|
|
62
|
-
|
|
63
|
-
## How It Works
|
|
64
|
-
|
|
65
|
-
1. **Wrapper starts**: Spawns `node ana auto:start` as a background process
|
|
66
|
-
2. **Wrapper monitors**: Uses `read -t 0.5 -n 1` to check for key presses every 500ms
|
|
67
|
-
3. **Key pressed**: Creates `~/.config/vibecodingmachine/.stop` file
|
|
68
|
-
4. **Watchdog detects**: The running ana process has a watchdog that checks for this file every 500ms
|
|
69
|
-
5. **Graceful exit**: When detected, ana kills Aider processes and exits the main loop
|
|
70
|
-
6. **Cleanup**: Wrapper removes the stop file and exits
|
|
71
|
-
|
|
72
|
-
## Alternative: Manual Stop File
|
|
73
|
-
|
|
74
|
-
You can also create the stop file manually:
|
|
75
|
-
```bash
|
|
76
|
-
# Create stop file
|
|
77
|
-
touch ~/.config/vibecodingmachine/.stop
|
|
78
|
-
|
|
79
|
-
# Or use the stop command
|
|
80
|
-
ana auto:stop
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Technical Details
|
|
84
|
-
|
|
85
|
-
### Watchdog Timer
|
|
86
|
-
The watchdog runs every 500ms in the Node.js process:
|
|
87
|
-
```javascript
|
|
88
|
-
const watchdog = setInterval(async () => {
|
|
89
|
-
if (await fs.pathExists(stopFilePath)) {
|
|
90
|
-
console.log('🛑 Stop signal detected (via .stop file)');
|
|
91
|
-
shouldExit = true;
|
|
92
|
-
exitReason = 'user-stop';
|
|
93
|
-
await fs.unlink(stopFilePath);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (shouldExit) {
|
|
97
|
-
clearInterval(watchdog);
|
|
98
|
-
aiderManager.killAllProcesses();
|
|
99
|
-
// Loop breaks naturally
|
|
100
|
-
}
|
|
101
|
-
}, 500);
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### Why Not Direct SIGINT?
|
|
105
|
-
Node.js SIGINT handlers aren't called when:
|
|
106
|
-
- `await` is blocked on a child process
|
|
107
|
-
- The event loop is not running (waiting for I/O)
|
|
108
|
-
- Child processes intercept signals first
|
|
109
|
-
|
|
110
|
-
The wrapper script solves this by handling signals at the shell level (outside Node.js).
|
|
111
|
-
|
|
112
|
-
## Testing
|
|
113
|
-
|
|
114
|
-
Test the wrapper with Ctrl+C:
|
|
115
|
-
```bash
|
|
116
|
-
./packages/cli/scripts/auto-start-wrapper.sh &
|
|
117
|
-
sleep 5
|
|
118
|
-
# Press Ctrl+C
|
|
119
|
-
# Should see: "🛑 Stop signal detected" and process exits
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
Test with stop command:
|
|
123
|
-
```bash
|
|
124
|
-
./packages/cli/scripts/auto-start-wrapper.sh &
|
|
125
|
-
sleep 5
|
|
126
|
-
ana auto:stop
|
|
127
|
-
# Should see process exit within 2 seconds
|
|
128
|
-
```
|
|
1
|
+
# Auto Start Wrapper Script
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The `auto-start-wrapper.sh` script provides **reliable Ctrl+C handling** for `ana auto:start`.
|
|
6
|
+
|
|
7
|
+
## Problem
|
|
8
|
+
|
|
9
|
+
Due to a Node.js limitation, SIGINT (Ctrl+C) signals don't reliably reach the event loop when Node.js is blocked waiting for child processes (like Aider). **This means Ctrl+C does NOT work when running `ana auto:start` directly.**
|
|
10
|
+
|
|
11
|
+
## Recommended Usage
|
|
12
|
+
|
|
13
|
+
**If you want Ctrl+C to work**, use the wrapper script instead of running `ana auto:start` directly:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# From anywhere (recommended)
|
|
17
|
+
~/.asdf/installs/nodejs/20.19.5/lib/node_modules/@vibecodingmachine/cli/scripts/auto-start-wrapper.sh
|
|
18
|
+
|
|
19
|
+
# Or if you know the package location
|
|
20
|
+
/path/to/vibecodingmachine/packages/cli/scripts/auto-start-wrapper.sh
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Creating a Convenient Alias
|
|
24
|
+
|
|
25
|
+
Add this to your `~/.zshrc` or `~/.bashrc`:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Alias for ana auto:start with Ctrl+C support
|
|
29
|
+
alias ana-start='~/.asdf/installs/nodejs/20.19.5/lib/node_modules/@vibecodingmachine/cli/scripts/auto-start-wrapper.sh'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Then you can simply run:
|
|
33
|
+
```bash
|
|
34
|
+
ana-start
|
|
35
|
+
ana-start --max-chats 10
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Solution
|
|
39
|
+
|
|
40
|
+
This wrapper script:
|
|
41
|
+
1. Runs `ana auto:start` in the background
|
|
42
|
+
2. Monitors keyboard input in the foreground (in the wrapper's process)
|
|
43
|
+
3. When Ctrl+C, Esc, or 'x' is pressed, creates a `.stop` file
|
|
44
|
+
4. The running `ana` process detects the file (via watchdog timer) and exits gracefully
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
### Direct Usage
|
|
49
|
+
```bash
|
|
50
|
+
# From the project root
|
|
51
|
+
./packages/cli/scripts/auto-start-wrapper.sh
|
|
52
|
+
|
|
53
|
+
# Or with options
|
|
54
|
+
./packages/cli/scripts/auto-start-wrapper.sh --max-chats 5
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### How to Stop
|
|
58
|
+
- **Ctrl+C**: Stops the process (most common)
|
|
59
|
+
- **Esc key**: Stops the process
|
|
60
|
+
- **'x' key**: Stops the process
|
|
61
|
+
- **`ana auto:stop`**: From another terminal
|
|
62
|
+
|
|
63
|
+
## How It Works
|
|
64
|
+
|
|
65
|
+
1. **Wrapper starts**: Spawns `node ana auto:start` as a background process
|
|
66
|
+
2. **Wrapper monitors**: Uses `read -t 0.5 -n 1` to check for key presses every 500ms
|
|
67
|
+
3. **Key pressed**: Creates `~/.config/vibecodingmachine/.stop` file
|
|
68
|
+
4. **Watchdog detects**: The running ana process has a watchdog that checks for this file every 500ms
|
|
69
|
+
5. **Graceful exit**: When detected, ana kills Aider processes and exits the main loop
|
|
70
|
+
6. **Cleanup**: Wrapper removes the stop file and exits
|
|
71
|
+
|
|
72
|
+
## Alternative: Manual Stop File
|
|
73
|
+
|
|
74
|
+
You can also create the stop file manually:
|
|
75
|
+
```bash
|
|
76
|
+
# Create stop file
|
|
77
|
+
touch ~/.config/vibecodingmachine/.stop
|
|
78
|
+
|
|
79
|
+
# Or use the stop command
|
|
80
|
+
ana auto:stop
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Technical Details
|
|
84
|
+
|
|
85
|
+
### Watchdog Timer
|
|
86
|
+
The watchdog runs every 500ms in the Node.js process:
|
|
87
|
+
```javascript
|
|
88
|
+
const watchdog = setInterval(async () => {
|
|
89
|
+
if (await fs.pathExists(stopFilePath)) {
|
|
90
|
+
console.log('🛑 Stop signal detected (via .stop file)');
|
|
91
|
+
shouldExit = true;
|
|
92
|
+
exitReason = 'user-stop';
|
|
93
|
+
await fs.unlink(stopFilePath);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (shouldExit) {
|
|
97
|
+
clearInterval(watchdog);
|
|
98
|
+
aiderManager.killAllProcesses();
|
|
99
|
+
// Loop breaks naturally
|
|
100
|
+
}
|
|
101
|
+
}, 500);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Why Not Direct SIGINT?
|
|
105
|
+
Node.js SIGINT handlers aren't called when:
|
|
106
|
+
- `await` is blocked on a child process
|
|
107
|
+
- The event loop is not running (waiting for I/O)
|
|
108
|
+
- Child processes intercept signals first
|
|
109
|
+
|
|
110
|
+
The wrapper script solves this by handling signals at the shell level (outside Node.js).
|
|
111
|
+
|
|
112
|
+
## Testing
|
|
113
|
+
|
|
114
|
+
Test the wrapper with Ctrl+C:
|
|
115
|
+
```bash
|
|
116
|
+
./packages/cli/scripts/auto-start-wrapper.sh &
|
|
117
|
+
sleep 5
|
|
118
|
+
# Press Ctrl+C
|
|
119
|
+
# Should see: "🛑 Stop signal detected" and process exits
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Test with stop command:
|
|
123
|
+
```bash
|
|
124
|
+
./packages/cli/scripts/auto-start-wrapper.sh &
|
|
125
|
+
sleep 5
|
|
126
|
+
ana auto:stop
|
|
127
|
+
# Should see process exit within 2 seconds
|
|
128
|
+
```
|
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
#
|
|
3
|
-
# Wrapper script for 'ana auto:start' that properly handles Ctrl+C and other key presses
|
|
4
|
-
# This script runs ana auto:start in the background and monitors keyboard input
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
set -e
|
|
8
|
-
|
|
9
|
-
# Colors
|
|
10
|
-
RED='\033[0;31m'
|
|
11
|
-
GREEN='\033[0;32m'
|
|
12
|
-
YELLOW='\033[1;33m'
|
|
13
|
-
GRAY='\033[0;37m'
|
|
14
|
-
NC='\033[0m' # No Color
|
|
15
|
-
|
|
16
|
-
# Get the directory where this script is located
|
|
17
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
18
|
-
CLI_DIR="$(dirname "$SCRIPT_DIR")"
|
|
19
|
-
|
|
20
|
-
# Path to ana command
|
|
21
|
-
ANA_CMD="$CLI_DIR/bin/vibecodingmachine.js"
|
|
22
|
-
|
|
23
|
-
# Path to stop file
|
|
24
|
-
STOP_FILE="$HOME/.config/vibecodingmachine/.stop"
|
|
25
|
-
|
|
26
|
-
# Cleanup function
|
|
27
|
-
cleanup() {
|
|
28
|
-
echo -e "\n${YELLOW}Stopping auto mode...${NC}"
|
|
29
|
-
|
|
30
|
-
# Create stop file to signal the process
|
|
31
|
-
mkdir -p "$(dirname "$STOP_FILE")"
|
|
32
|
-
echo "Stop requested at $(date)" > "$STOP_FILE"
|
|
33
|
-
|
|
34
|
-
# Send SIGTERM to the ana process if it's running
|
|
35
|
-
if [ -n "$ANA_PID" ] && kill -0 "$ANA_PID" 2>/dev/null; then
|
|
36
|
-
kill -TERM "$ANA_PID" 2>/dev/null || true
|
|
37
|
-
fi
|
|
38
|
-
|
|
39
|
-
# Wait a moment for the process to exit gracefully
|
|
40
|
-
sleep 2
|
|
41
|
-
|
|
42
|
-
# Force kill if still running
|
|
43
|
-
if [ -n "$ANA_PID" ] && kill -0 "$ANA_PID" 2>/dev/null; then
|
|
44
|
-
echo -e "${YELLOW}Force stopping...${NC}"
|
|
45
|
-
kill -9 "$ANA_PID" 2>/dev/null || true
|
|
46
|
-
fi
|
|
47
|
-
|
|
48
|
-
# Also kill any remaining aider processes
|
|
49
|
-
pkill -9 -f "aider.*vibecodingmachine" 2>/dev/null || true
|
|
50
|
-
|
|
51
|
-
echo -e "${GREEN}Auto mode stopped${NC}"
|
|
52
|
-
exit 0
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
# Set up trap for Ctrl+C
|
|
56
|
-
trap cleanup INT TERM
|
|
57
|
-
|
|
58
|
-
# Start ana auto:start in background
|
|
59
|
-
echo -e "${GRAY}Starting auto mode...${NC}"
|
|
60
|
-
echo -e "${GRAY}Press Ctrl+C, Esc, or 'x' to stop${NC}"
|
|
61
|
-
echo ""
|
|
62
|
-
|
|
63
|
-
# Start ana in background, saving its PID
|
|
64
|
-
# Set ANA_WRAPPER_RUNNING to prevent infinite recursion
|
|
65
|
-
export ANA_WRAPPER_RUNNING=1
|
|
66
|
-
node "$ANA_CMD" auto:start "$@" &
|
|
67
|
-
ANA_PID=$!
|
|
68
|
-
|
|
69
|
-
# Monitor for keyboard input AND stop file in the foreground
|
|
70
|
-
# Use a non-blocking read to check for key presses
|
|
71
|
-
while kill -0 "$ANA_PID" 2>/dev/null; do
|
|
72
|
-
# Check for stop file first (created by 'ana auto:stop' or Ctrl+C signal)
|
|
73
|
-
if [ -f "$STOP_FILE" ]; then
|
|
74
|
-
echo -e "\n${YELLOW}Stop signal detected${NC}"
|
|
75
|
-
cleanup
|
|
76
|
-
fi
|
|
77
|
-
|
|
78
|
-
# Read a single character with 0.5 second timeout
|
|
79
|
-
if read -t 0.5 -n 1 -s key 2>/dev/null; then
|
|
80
|
-
# Check if key is 'x', Esc (ASCII 27), or Ctrl+C
|
|
81
|
-
if [ "$key" = "x" ] || [ "$key" = "X" ] || [ "$(printf '%d' "'$key")" = "27" ]; then
|
|
82
|
-
echo -e "\n${YELLOW}Stop key pressed${NC}"
|
|
83
|
-
cleanup
|
|
84
|
-
fi
|
|
85
|
-
fi
|
|
86
|
-
done
|
|
87
|
-
|
|
88
|
-
# Process exited naturally
|
|
89
|
-
echo -e "\n${GREEN}Auto mode completed${NC}"
|
|
90
|
-
wait "$ANA_PID"
|
|
91
|
-
exit_code=$?
|
|
92
|
-
exit $exit_code
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# Wrapper script for 'ana auto:start' that properly handles Ctrl+C and other key presses
|
|
4
|
+
# This script runs ana auto:start in the background and monitors keyboard input
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
set -e
|
|
8
|
+
|
|
9
|
+
# Colors
|
|
10
|
+
RED='\033[0;31m'
|
|
11
|
+
GREEN='\033[0;32m'
|
|
12
|
+
YELLOW='\033[1;33m'
|
|
13
|
+
GRAY='\033[0;37m'
|
|
14
|
+
NC='\033[0m' # No Color
|
|
15
|
+
|
|
16
|
+
# Get the directory where this script is located
|
|
17
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
18
|
+
CLI_DIR="$(dirname "$SCRIPT_DIR")"
|
|
19
|
+
|
|
20
|
+
# Path to ana command
|
|
21
|
+
ANA_CMD="$CLI_DIR/bin/vibecodingmachine.js"
|
|
22
|
+
|
|
23
|
+
# Path to stop file
|
|
24
|
+
STOP_FILE="$HOME/.config/vibecodingmachine/.stop"
|
|
25
|
+
|
|
26
|
+
# Cleanup function
|
|
27
|
+
cleanup() {
|
|
28
|
+
echo -e "\n${YELLOW}Stopping auto mode...${NC}"
|
|
29
|
+
|
|
30
|
+
# Create stop file to signal the process
|
|
31
|
+
mkdir -p "$(dirname "$STOP_FILE")"
|
|
32
|
+
echo "Stop requested at $(date)" > "$STOP_FILE"
|
|
33
|
+
|
|
34
|
+
# Send SIGTERM to the ana process if it's running
|
|
35
|
+
if [ -n "$ANA_PID" ] && kill -0 "$ANA_PID" 2>/dev/null; then
|
|
36
|
+
kill -TERM "$ANA_PID" 2>/dev/null || true
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
# Wait a moment for the process to exit gracefully
|
|
40
|
+
sleep 2
|
|
41
|
+
|
|
42
|
+
# Force kill if still running
|
|
43
|
+
if [ -n "$ANA_PID" ] && kill -0 "$ANA_PID" 2>/dev/null; then
|
|
44
|
+
echo -e "${YELLOW}Force stopping...${NC}"
|
|
45
|
+
kill -9 "$ANA_PID" 2>/dev/null || true
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
# Also kill any remaining aider processes
|
|
49
|
+
pkill -9 -f "aider.*vibecodingmachine" 2>/dev/null || true
|
|
50
|
+
|
|
51
|
+
echo -e "${GREEN}Auto mode stopped${NC}"
|
|
52
|
+
exit 0
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
# Set up trap for Ctrl+C
|
|
56
|
+
trap cleanup INT TERM
|
|
57
|
+
|
|
58
|
+
# Start ana auto:start in background
|
|
59
|
+
echo -e "${GRAY}Starting auto mode...${NC}"
|
|
60
|
+
echo -e "${GRAY}Press Ctrl+C, Esc, or 'x' to stop${NC}"
|
|
61
|
+
echo ""
|
|
62
|
+
|
|
63
|
+
# Start ana in background, saving its PID
|
|
64
|
+
# Set ANA_WRAPPER_RUNNING to prevent infinite recursion
|
|
65
|
+
export ANA_WRAPPER_RUNNING=1
|
|
66
|
+
node "$ANA_CMD" auto:start "$@" &
|
|
67
|
+
ANA_PID=$!
|
|
68
|
+
|
|
69
|
+
# Monitor for keyboard input AND stop file in the foreground
|
|
70
|
+
# Use a non-blocking read to check for key presses
|
|
71
|
+
while kill -0 "$ANA_PID" 2>/dev/null; do
|
|
72
|
+
# Check for stop file first (created by 'ana auto:stop' or Ctrl+C signal)
|
|
73
|
+
if [ -f "$STOP_FILE" ]; then
|
|
74
|
+
echo -e "\n${YELLOW}Stop signal detected${NC}"
|
|
75
|
+
cleanup
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
# Read a single character with 0.5 second timeout
|
|
79
|
+
if read -t 0.5 -n 1 -s key 2>/dev/null; then
|
|
80
|
+
# Check if key is 'x', Esc (ASCII 27), or Ctrl+C
|
|
81
|
+
if [ "$key" = "x" ] || [ "$key" = "X" ] || [ "$(printf '%d' "'$key")" = "27" ]; then
|
|
82
|
+
echo -e "\n${YELLOW}Stop key pressed${NC}"
|
|
83
|
+
cleanup
|
|
84
|
+
fi
|
|
85
|
+
fi
|
|
86
|
+
done
|
|
87
|
+
|
|
88
|
+
# Process exited naturally
|
|
89
|
+
echo -e "\n${GREEN}Auto mode completed${NC}"
|
|
90
|
+
wait "$ANA_PID"
|
|
91
|
+
exit_code=$?
|
|
92
|
+
exit $exit_code
|