bob-app-assistant 0.0.1
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 +292 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +296 -0
- package/dist/cli.js.map +1 -0
- package/dist/database.d.ts +42 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +199 -0
- package/dist/database.js.map +1 -0
- package/dist/postinstall.d.ts +3 -0
- package/dist/postinstall.d.ts.map +1 -0
- package/dist/postinstall.js +48 -0
- package/dist/postinstall.js.map +1 -0
- package/dist/routes/aiRoutes.d.ts +3 -0
- package/dist/routes/aiRoutes.d.ts.map +1 -0
- package/dist/routes/aiRoutes.js +1277 -0
- package/dist/routes/aiRoutes.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +120 -0
- package/dist/server.js.map +1 -0
- package/dist/services/apiTestingService.d.ts +90 -0
- package/dist/services/apiTestingService.d.ts.map +1 -0
- package/dist/services/apiTestingService.js +351 -0
- package/dist/services/apiTestingService.js.map +1 -0
- package/dist/services/backupService.d.ts +63 -0
- package/dist/services/backupService.d.ts.map +1 -0
- package/dist/services/backupService.js +235 -0
- package/dist/services/backupService.js.map +1 -0
- package/dist/services/bobShellService.d.ts +91 -0
- package/dist/services/bobShellService.d.ts.map +1 -0
- package/dist/services/bobShellService.js +534 -0
- package/dist/services/bobShellService.js.map +1 -0
- package/dist/services/codeQualityService.d.ts +105 -0
- package/dist/services/codeQualityService.d.ts.map +1 -0
- package/dist/services/codeQualityService.js +432 -0
- package/dist/services/codeQualityService.js.map +1 -0
- package/dist/services/dependencyService.d.ts +127 -0
- package/dist/services/dependencyService.d.ts.map +1 -0
- package/dist/services/dependencyService.js +499 -0
- package/dist/services/dependencyService.js.map +1 -0
- package/dist/services/diffService.d.ts +48 -0
- package/dist/services/diffService.d.ts.map +1 -0
- package/dist/services/diffService.js +175 -0
- package/dist/services/diffService.js.map +1 -0
- package/dist/services/documentationService.d.ts +124 -0
- package/dist/services/documentationService.d.ts.map +1 -0
- package/dist/services/documentationService.js +628 -0
- package/dist/services/documentationService.js.map +1 -0
- package/dist/services/promptEnhancerService.d.ts +92 -0
- package/dist/services/promptEnhancerService.d.ts.map +1 -0
- package/dist/services/promptEnhancerService.js +459 -0
- package/dist/services/promptEnhancerService.js.map +1 -0
- package/dist/services/securityService.d.ts +99 -0
- package/dist/services/securityService.d.ts.map +1 -0
- package/dist/services/securityService.js +467 -0
- package/dist/services/securityService.js.map +1 -0
- package/dist/websocket.d.ts +17 -0
- package/dist/websocket.d.ts.map +1 -0
- package/dist/websocket.js +242 -0
- package/dist/websocket.js.map +1 -0
- package/package.json +74 -0
- package/public/assistant-ui.html +211 -0
- package/public/dist/assets/index-BdGvFYpE.css +1 -0
- package/public/dist/assets/index-Dfe7xGmm.js +55 -0
- package/public/dist/index.html +13 -0
- package/public/inject.js +241 -0
package/README.md
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# ๐ค Bob AI Sidecar
|
|
2
|
+
|
|
3
|
+
> An intelligent AI assistant that injects into any web application, providing powerful development tools and AI-powered features.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@bob-ai/sidecar)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## โจ Features
|
|
9
|
+
|
|
10
|
+
- **๐ค AI Chat Assistant** - Conversational AI for code help and questions
|
|
11
|
+
- **๐ Code Quality Analysis** - Automated code review and quality metrics
|
|
12
|
+
- **๐ Security Scanning** - Detect vulnerabilities and security issues
|
|
13
|
+
- **๐ฆ Dependency Management** - Analyze and manage project dependencies
|
|
14
|
+
- **๐ Documentation Generator** - Auto-generate comprehensive documentation
|
|
15
|
+
- **โจ Prompt Enhancer** - Improve AI prompts for better results
|
|
16
|
+
- **๐งช Testing Tools** - Generate and manage tests
|
|
17
|
+
- **๐ Diff Viewer** - Visual diff comparison with syntax highlighting
|
|
18
|
+
- **๐พ Backup & Restore** - Automatic backup and restore functionality
|
|
19
|
+
- **๐ Permission Management** - Control access to sensitive operations
|
|
20
|
+
|
|
21
|
+
## ๐ Quick Start
|
|
22
|
+
|
|
23
|
+
### Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install @bob-ai/sidecar
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Initialize
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx BobAppAssistant init
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
This creates:
|
|
36
|
+
- `BobAppAssistant.config.json` - Configuration file
|
|
37
|
+
- `.env.sidecar` - Environment variables
|
|
38
|
+
- Updates `.gitignore`
|
|
39
|
+
|
|
40
|
+
### Start the Server
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npx BobAppAssistant start
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The sidecar will:
|
|
47
|
+
1. Start HTTP server on port 4500
|
|
48
|
+
2. Start WebSocket server on port 4501
|
|
49
|
+
3. Inject AI Assistant UI into your web application automatically
|
|
50
|
+
|
|
51
|
+
### Development Mode
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx BobAppAssistant dev
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Runs with auto-reload on file changes.
|
|
58
|
+
|
|
59
|
+
## ๐ Usage
|
|
60
|
+
|
|
61
|
+
### Basic Setup
|
|
62
|
+
|
|
63
|
+
1. **Install the package:**
|
|
64
|
+
```bash
|
|
65
|
+
npm install @bob-ai/sidecar
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
2. **Initialize in your project:**
|
|
69
|
+
```bash
|
|
70
|
+
npx BobAppAssistant init
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
3. **Configure (optional):**
|
|
74
|
+
Edit `BobAppAssistant.config.json`:
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"port": 4500,
|
|
78
|
+
"wsPort": 4501,
|
|
79
|
+
"projectRoot": "/path/to/your/project",
|
|
80
|
+
"bobShellPath": "bob",
|
|
81
|
+
"features": {
|
|
82
|
+
"chat": true,
|
|
83
|
+
"codeQuality": true,
|
|
84
|
+
"security": true,
|
|
85
|
+
"dependencies": true,
|
|
86
|
+
"documentation": true,
|
|
87
|
+
"promptEnhancer": true,
|
|
88
|
+
"testing": true,
|
|
89
|
+
"diff": true,
|
|
90
|
+
"backup": true,
|
|
91
|
+
"permissions": true
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
4. **Start the server:**
|
|
97
|
+
```bash
|
|
98
|
+
npx BobAppAssistant start
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
5. **Open your web application:**
|
|
102
|
+
The AI Assistant panel will automatically appear on the right side!
|
|
103
|
+
|
|
104
|
+
### Integration with Existing Apps
|
|
105
|
+
|
|
106
|
+
The sidecar automatically injects into any web page served from your project. No code changes required!
|
|
107
|
+
|
|
108
|
+
#### Manual Integration (Optional)
|
|
109
|
+
|
|
110
|
+
If you want to manually control the injection:
|
|
111
|
+
|
|
112
|
+
```html
|
|
113
|
+
<!-- Add to your HTML -->
|
|
114
|
+
<script src="http://localhost:4500/public/inject.js"></script>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Using with Bob-Shell
|
|
118
|
+
|
|
119
|
+
For AI-powered features, install [Bob-Shell](https://github.com/bob-shell):
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
npm install -g bob-shell
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Then enable Bob-Shell mode in the AI Assistant UI for enhanced capabilities.
|
|
126
|
+
|
|
127
|
+
## ๐ฏ Features in Detail
|
|
128
|
+
|
|
129
|
+
### AI Chat Assistant
|
|
130
|
+
- Natural language conversations
|
|
131
|
+
- Code explanations and help
|
|
132
|
+
- Context-aware responses
|
|
133
|
+
- Image upload support
|
|
134
|
+
|
|
135
|
+
### Code Quality Analysis
|
|
136
|
+
- Automated code review
|
|
137
|
+
- Quality metrics and scoring
|
|
138
|
+
- Best practice recommendations
|
|
139
|
+
- Refactoring suggestions
|
|
140
|
+
|
|
141
|
+
### Security Scanning
|
|
142
|
+
- Vulnerability detection
|
|
143
|
+
- Secret scanning
|
|
144
|
+
- Security best practices
|
|
145
|
+
- OWASP compliance checks
|
|
146
|
+
|
|
147
|
+
### Documentation Generator
|
|
148
|
+
- API documentation
|
|
149
|
+
- README generation
|
|
150
|
+
- Code documentation
|
|
151
|
+
- Architecture diagrams
|
|
152
|
+
|
|
153
|
+
### And More!
|
|
154
|
+
See the full feature list in the UI after starting the sidecar.
|
|
155
|
+
|
|
156
|
+
## ๐ง Configuration
|
|
157
|
+
|
|
158
|
+
### Environment Variables
|
|
159
|
+
|
|
160
|
+
Create `.env.sidecar`:
|
|
161
|
+
|
|
162
|
+
```env
|
|
163
|
+
PORT=4500
|
|
164
|
+
WS_PORT=4501
|
|
165
|
+
NODE_ENV=development
|
|
166
|
+
PROJECT_ROOT=/path/to/project
|
|
167
|
+
BOB_SHELL_PATH=bob
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Config File
|
|
171
|
+
|
|
172
|
+
`BobAppAssistant.config.json`:
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"port": 4500,
|
|
177
|
+
"wsPort": 4501,
|
|
178
|
+
"projectRoot": ".",
|
|
179
|
+
"bobShellPath": "bob",
|
|
180
|
+
"features": {
|
|
181
|
+
"chat": true,
|
|
182
|
+
"codeQuality": true,
|
|
183
|
+
"security": true,
|
|
184
|
+
"dependencies": true,
|
|
185
|
+
"documentation": true,
|
|
186
|
+
"promptEnhancer": true,
|
|
187
|
+
"testing": true,
|
|
188
|
+
"diff": true,
|
|
189
|
+
"backup": true,
|
|
190
|
+
"permissions": true
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## ๐ก API Endpoints
|
|
196
|
+
|
|
197
|
+
The sidecar exposes REST and WebSocket APIs:
|
|
198
|
+
|
|
199
|
+
### HTTP Endpoints (Port 4500)
|
|
200
|
+
|
|
201
|
+
- `POST /api/ai/chat` - AI chat
|
|
202
|
+
- `POST /api/ai/analyze-quality` - Code quality analysis
|
|
203
|
+
- `POST /api/ai/scan-security` - Security scan
|
|
204
|
+
- `POST /api/ai/analyze-dependencies` - Dependency analysis
|
|
205
|
+
- `POST /api/ai/generate-docs` - Generate documentation
|
|
206
|
+
- `POST /api/ai/enhance-prompt` - Enhance prompts
|
|
207
|
+
- `GET /api/ai/pending-approvals` - Get pending approvals
|
|
208
|
+
- `POST /api/ai/approve` - Approve operation
|
|
209
|
+
- `POST /api/ai/reject` - Reject operation
|
|
210
|
+
|
|
211
|
+
### WebSocket (Port 4501)
|
|
212
|
+
|
|
213
|
+
Real-time updates for:
|
|
214
|
+
- Chat messages
|
|
215
|
+
- Analysis progress
|
|
216
|
+
- Approval requests
|
|
217
|
+
- System notifications
|
|
218
|
+
|
|
219
|
+
## ๐ ๏ธ CLI Commands
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Initialize project
|
|
223
|
+
npx BobAppAssistant init
|
|
224
|
+
|
|
225
|
+
# Start server
|
|
226
|
+
npx BobAppAssistant start
|
|
227
|
+
|
|
228
|
+
# Development mode
|
|
229
|
+
npx BobAppAssistant dev
|
|
230
|
+
|
|
231
|
+
# Build for production
|
|
232
|
+
npx BobAppAssistant build
|
|
233
|
+
|
|
234
|
+
# Show help
|
|
235
|
+
npx BobAppAssistant help
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## ๐๏ธ Architecture
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
242
|
+
โ Your Web Application โ
|
|
243
|
+
โ (React, Vue, Angular, etc.) โ
|
|
244
|
+
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโ
|
|
245
|
+
โ
|
|
246
|
+
โ Auto-injection
|
|
247
|
+
โผ
|
|
248
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
249
|
+
โ Bob AI Sidecar (Port 4500/4501) โ
|
|
250
|
+
โ โ
|
|
251
|
+
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
252
|
+
โ โ React Iframe App (UI) โ โ
|
|
253
|
+
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
254
|
+
โ โ
|
|
255
|
+
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
256
|
+
โ โ AI Services โ โ
|
|
257
|
+
โ โ - Chat โ โ
|
|
258
|
+
โ โ - Code Quality โ โ
|
|
259
|
+
โ โ - Security โ โ
|
|
260
|
+
โ โ - Documentation โ โ
|
|
261
|
+
โ โ - etc. โ โ
|
|
262
|
+
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
263
|
+
โ โ
|
|
264
|
+
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
265
|
+
โ โ Bob-Shell Integration โ โ
|
|
266
|
+
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
267
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## ๐ค Contributing
|
|
271
|
+
|
|
272
|
+
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
273
|
+
|
|
274
|
+
## ๐ License
|
|
275
|
+
|
|
276
|
+
MIT ยฉ Bob AI
|
|
277
|
+
|
|
278
|
+
## ๐ Links
|
|
279
|
+
|
|
280
|
+
- [Documentation](https://github.com/yourusername/BobAppAssistant)
|
|
281
|
+
- [Issues](https://github.com/yourusername/BobAppAssistant/issues)
|
|
282
|
+
- [Changelog](CHANGELOG.md)
|
|
283
|
+
|
|
284
|
+
## ๐ฌ Support
|
|
285
|
+
|
|
286
|
+
- GitHub Issues: [Report a bug](https://github.com/yourusername/BobAppAssistant/issues)
|
|
287
|
+
- Email: support@bob-ai.com
|
|
288
|
+
- Discord: [Join our community](https://discord.gg/bob-ai)
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
Made with โค๏ธ by the Bob AI team
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const child_process_1 = require("child_process");
|
|
40
|
+
const COLORS = {
|
|
41
|
+
reset: '\x1b[0m',
|
|
42
|
+
bright: '\x1b[1m',
|
|
43
|
+
green: '\x1b[32m',
|
|
44
|
+
blue: '\x1b[34m',
|
|
45
|
+
yellow: '\x1b[33m',
|
|
46
|
+
red: '\x1b[31m',
|
|
47
|
+
cyan: '\x1b[36m',
|
|
48
|
+
};
|
|
49
|
+
function log(message, color = COLORS.reset) {
|
|
50
|
+
console.log(`${color}${message}${COLORS.reset}`);
|
|
51
|
+
}
|
|
52
|
+
function printBanner() {
|
|
53
|
+
log('\nโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ', COLORS.cyan);
|
|
54
|
+
log('โ ๐ค Bob AI Assistant โ', COLORS.cyan);
|
|
55
|
+
log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n', COLORS.cyan);
|
|
56
|
+
}
|
|
57
|
+
function printHelp() {
|
|
58
|
+
printBanner();
|
|
59
|
+
log('Usage:', COLORS.bright);
|
|
60
|
+
log(' BobAppAssistant <command>\n', COLORS.reset);
|
|
61
|
+
log('Commands:', COLORS.bright);
|
|
62
|
+
log(' init Initialize BobAppAssistant in your project', COLORS.green);
|
|
63
|
+
log(' start Start the assistant server', COLORS.green);
|
|
64
|
+
log(' dev Start in development mode with auto-reload', COLORS.green);
|
|
65
|
+
log(' build Build the assistant for production', COLORS.green);
|
|
66
|
+
log(' help Show this help message\n', COLORS.green);
|
|
67
|
+
log('Examples:', COLORS.bright);
|
|
68
|
+
log(' BobAppAssistant init', COLORS.cyan);
|
|
69
|
+
log(' BobAppAssistant start', COLORS.cyan);
|
|
70
|
+
log(' BobAppAssistant dev\n', COLORS.cyan);
|
|
71
|
+
}
|
|
72
|
+
async function initProject() {
|
|
73
|
+
printBanner();
|
|
74
|
+
log('๐ Initializing BobAppAssistant...\n', COLORS.bright);
|
|
75
|
+
const projectRoot = process.cwd();
|
|
76
|
+
const configPath = path.join(projectRoot, 'BobAppAssistant.config.json');
|
|
77
|
+
const envPath = path.join(projectRoot, '.env.assistant');
|
|
78
|
+
// Check if already initialized
|
|
79
|
+
if (fs.existsSync(configPath)) {
|
|
80
|
+
log('โ ๏ธ BobAppAssistant is already initialized in this project.', COLORS.yellow);
|
|
81
|
+
log(' Config file: BobAppAssistant.config.json\n', COLORS.yellow);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// Create config file
|
|
85
|
+
const config = {
|
|
86
|
+
port: 4500,
|
|
87
|
+
wsPort: 4501,
|
|
88
|
+
projectRoot: projectRoot,
|
|
89
|
+
bobShellPath: 'bob',
|
|
90
|
+
features: {
|
|
91
|
+
chat: true,
|
|
92
|
+
codeQuality: true,
|
|
93
|
+
security: true,
|
|
94
|
+
dependencies: true,
|
|
95
|
+
documentation: true,
|
|
96
|
+
promptEnhancer: true,
|
|
97
|
+
testing: true,
|
|
98
|
+
diff: true,
|
|
99
|
+
backup: true,
|
|
100
|
+
permissions: true
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
104
|
+
log('โ
Created BobAppAssistant.config.json', COLORS.green);
|
|
105
|
+
// Create .backups directory
|
|
106
|
+
const backupsDir = path.join(projectRoot, '.backups');
|
|
107
|
+
if (!fs.existsSync(backupsDir)) {
|
|
108
|
+
fs.mkdirSync(backupsDir, { recursive: true });
|
|
109
|
+
log('โ
Created .backups directory', COLORS.green);
|
|
110
|
+
}
|
|
111
|
+
// Create .env file if it doesn't exist
|
|
112
|
+
if (!fs.existsSync(envPath)) {
|
|
113
|
+
const envContent = `# Bob AI Assistant Configuration
|
|
114
|
+
PORT=4500
|
|
115
|
+
WS_PORT=4501
|
|
116
|
+
NODE_ENV=development
|
|
117
|
+
PROJECT_ROOT=${projectRoot}
|
|
118
|
+
BOB_SHELL_PATH=bob
|
|
119
|
+
`;
|
|
120
|
+
fs.writeFileSync(envPath, envContent);
|
|
121
|
+
log('โ
Created .env.assistant', COLORS.green);
|
|
122
|
+
}
|
|
123
|
+
// Add to .gitignore
|
|
124
|
+
const gitignorePath = path.join(projectRoot, '.gitignore');
|
|
125
|
+
if (fs.existsSync(gitignorePath)) {
|
|
126
|
+
let gitignore = fs.readFileSync(gitignorePath, 'utf-8');
|
|
127
|
+
if (!gitignore.includes('.env.assistant')) {
|
|
128
|
+
gitignore += '\n# BobAppAssistant\n.env.assistant\nBobAppAssistant.db\n.bob-generated/\n.backups/\n';
|
|
129
|
+
fs.writeFileSync(gitignorePath, gitignore);
|
|
130
|
+
log('โ
Updated .gitignore', COLORS.green);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Auto-inject script into HTML files
|
|
134
|
+
log('\n๐ Searching for HTML entry points...\n', COLORS.bright);
|
|
135
|
+
const htmlFiles = findHtmlFiles(projectRoot);
|
|
136
|
+
const injectedFiles = [];
|
|
137
|
+
if (htmlFiles.length > 0) {
|
|
138
|
+
log(`Found ${htmlFiles.length} HTML file(s)\n`, COLORS.cyan);
|
|
139
|
+
// Prioritize common entry points
|
|
140
|
+
const priorityFiles = htmlFiles.filter(file => {
|
|
141
|
+
const basename = path.basename(file);
|
|
142
|
+
return basename === 'index.html' || basename === 'main.html' || basename === 'app.html';
|
|
143
|
+
});
|
|
144
|
+
const filesToInject = priorityFiles.length > 0 ? priorityFiles : htmlFiles;
|
|
145
|
+
for (const file of filesToInject) {
|
|
146
|
+
const relativePath = path.relative(projectRoot, file);
|
|
147
|
+
try {
|
|
148
|
+
let content = fs.readFileSync(file, 'utf-8');
|
|
149
|
+
// Check if already injected
|
|
150
|
+
if (content.includes('http://localhost:4500/public/inject.js')) {
|
|
151
|
+
log(` โญ๏ธ ${relativePath} - Already injected`, COLORS.yellow);
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
// Find </body> tag and inject before it
|
|
155
|
+
const bodyCloseTag = '</body>';
|
|
156
|
+
if (content.includes(bodyCloseTag)) {
|
|
157
|
+
const scriptTag = ` <!-- AI Assistant Sidecar Injection -->\n <script src="http://localhost:4500/public/inject.js"></script>\n ${bodyCloseTag}`;
|
|
158
|
+
content = content.replace(bodyCloseTag, scriptTag);
|
|
159
|
+
fs.writeFileSync(file, content, 'utf-8');
|
|
160
|
+
log(` โ
${relativePath} - Script injected`, COLORS.green);
|
|
161
|
+
injectedFiles.push(relativePath);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
log(` โ ๏ธ ${relativePath} - No </body> tag found`, COLORS.yellow);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
log(` โ ${relativePath} - Error: ${error.message}`, COLORS.red);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (injectedFiles.length > 0) {
|
|
172
|
+
log(`\nโจ Successfully injected script into ${injectedFiles.length} file(s)!`, COLORS.green);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
log('\n๐ก No files were modified. Add this line before </body> manually:', COLORS.yellow);
|
|
176
|
+
log(' <script src="http://localhost:4500/public/inject.js"></script>\n', COLORS.cyan);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
log('โน๏ธ No HTML files found in project.', COLORS.yellow);
|
|
181
|
+
log(' Add this script tag to your HTML files manually:', COLORS.yellow);
|
|
182
|
+
log(' <script src="http://localhost:4500/public/inject.js"></script>\n', COLORS.cyan);
|
|
183
|
+
}
|
|
184
|
+
log('๐ BobAppAssistant initialized successfully!\n', COLORS.bright);
|
|
185
|
+
log('Next steps:', COLORS.bright);
|
|
186
|
+
log(' 1. Add the script tag to your HTML files (see above)', COLORS.cyan);
|
|
187
|
+
log(' 2. Run: BobAppAssistant start', COLORS.cyan);
|
|
188
|
+
log(' 3. Open your web app and the AI Assistant will appear!\n', COLORS.cyan);
|
|
189
|
+
log('๐ Documentation: https://github.com/yourusername/BobAppAssistant\n', COLORS.blue);
|
|
190
|
+
}
|
|
191
|
+
function findHtmlFiles(dir, fileList = []) {
|
|
192
|
+
const files = fs.readdirSync(dir);
|
|
193
|
+
files.forEach(file => {
|
|
194
|
+
const filePath = path.join(dir, file);
|
|
195
|
+
const stat = fs.statSync(filePath);
|
|
196
|
+
// Skip node_modules, .git, and other common directories
|
|
197
|
+
if (stat.isDirectory()) {
|
|
198
|
+
const skipDirs = ['node_modules', '.git', 'dist', 'build', '.next', '.nuxt', 'coverage'];
|
|
199
|
+
if (!skipDirs.includes(file)) {
|
|
200
|
+
findHtmlFiles(filePath, fileList);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
else if (file.endsWith('.html')) {
|
|
204
|
+
fileList.push(filePath);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
return fileList;
|
|
208
|
+
}
|
|
209
|
+
function startServer(dev = false) {
|
|
210
|
+
printBanner();
|
|
211
|
+
const mode = dev ? 'development' : 'production';
|
|
212
|
+
log(`๐ Starting BobAppAssistant in ${mode} mode...\n`, COLORS.bright);
|
|
213
|
+
// Check if config exists
|
|
214
|
+
const configPath = path.join(process.cwd(), 'BobAppAssistant.config.json');
|
|
215
|
+
if (!fs.existsSync(configPath)) {
|
|
216
|
+
log('โ BobAppAssistant not initialized!', COLORS.red);
|
|
217
|
+
log(' Run: BobAppAssistant init\n', COLORS.yellow);
|
|
218
|
+
process.exit(1);
|
|
219
|
+
}
|
|
220
|
+
// Load config
|
|
221
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
222
|
+
// Set environment variables
|
|
223
|
+
process.env.PORT = config.port.toString();
|
|
224
|
+
process.env.WS_PORT = config.wsPort.toString();
|
|
225
|
+
process.env.PROJECT_ROOT = config.projectRoot;
|
|
226
|
+
process.env.BOB_SHELL_PATH = config.bobShellPath || 'bob';
|
|
227
|
+
// Start server
|
|
228
|
+
const serverPath = path.join(__dirname, 'server.js');
|
|
229
|
+
if (dev) {
|
|
230
|
+
// Development mode with tsx watch
|
|
231
|
+
const child = (0, child_process_1.spawn)('npx', ['tsx', 'watch', serverPath.replace('.js', '.ts')], {
|
|
232
|
+
stdio: 'inherit',
|
|
233
|
+
shell: true,
|
|
234
|
+
env: { ...process.env }
|
|
235
|
+
});
|
|
236
|
+
child.on('error', (error) => {
|
|
237
|
+
log(`โ Failed to start server: ${error.message}`, COLORS.red);
|
|
238
|
+
process.exit(1);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
// Production mode
|
|
243
|
+
require(serverPath);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function buildProject() {
|
|
247
|
+
printBanner();
|
|
248
|
+
log('๐จ Building Bob AI Sidecar...\n', COLORS.bright);
|
|
249
|
+
const child = (0, child_process_1.spawn)('npm', ['run', 'build'], {
|
|
250
|
+
stdio: 'inherit',
|
|
251
|
+
shell: true,
|
|
252
|
+
cwd: __dirname
|
|
253
|
+
});
|
|
254
|
+
child.on('close', (code) => {
|
|
255
|
+
if (code === 0) {
|
|
256
|
+
log('\nโ
Build completed successfully!', COLORS.green);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
log('\nโ Build failed!', COLORS.red);
|
|
260
|
+
process.exit(1);
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
// Main CLI logic
|
|
265
|
+
const args = process.argv.slice(2);
|
|
266
|
+
const command = args[0];
|
|
267
|
+
switch (command) {
|
|
268
|
+
case 'init':
|
|
269
|
+
initProject();
|
|
270
|
+
break;
|
|
271
|
+
case 'start':
|
|
272
|
+
startServer(false);
|
|
273
|
+
break;
|
|
274
|
+
case 'dev':
|
|
275
|
+
startServer(true);
|
|
276
|
+
break;
|
|
277
|
+
case 'build':
|
|
278
|
+
buildProject();
|
|
279
|
+
break;
|
|
280
|
+
case 'help':
|
|
281
|
+
case '--help':
|
|
282
|
+
case '-h':
|
|
283
|
+
printHelp();
|
|
284
|
+
break;
|
|
285
|
+
default:
|
|
286
|
+
if (!command) {
|
|
287
|
+
printHelp();
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
log(`โ Unknown command: ${command}\n`, COLORS.red);
|
|
291
|
+
printHelp();
|
|
292
|
+
process.exit(1);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// Made with Bob
|
|
296
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uCAAyB;AACzB,2CAA6B;AAC7B,iDAAsC;AAEtC,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,UAAU;IACjB,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,UAAU;IAClB,GAAG,EAAE,UAAU;IACf,IAAI,EAAE,UAAU;CACjB,CAAC;AAEF,SAAS,GAAG,CAAC,OAAe,EAAE,QAAgB,MAAM,CAAC,KAAK;IACxD,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC,KAAK,EA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AAG,CAAC,CAAC;YACnD,SAAS,EAAE,CAAC;YACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;AACL,CAAC;AAED,gBAAgB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import Database from 'better-sqlite3';
|
|
2
|
+
declare const db: Database.Database;
|
|
3
|
+
export declare const chatHistory: {
|
|
4
|
+
add: (sessionId: string, role: string, content: string) => Database.RunResult;
|
|
5
|
+
getBySession: (sessionId: string, limit?: number) => unknown[];
|
|
6
|
+
clear: (sessionId: string) => Database.RunResult;
|
|
7
|
+
deleteOlderThan: (days: number) => Database.RunResult;
|
|
8
|
+
};
|
|
9
|
+
export declare const pendingApprovals: {
|
|
10
|
+
add: (sessionId: string, operationType: string, operationData: any, diffContent?: string) => Database.RunResult;
|
|
11
|
+
getBySession: (sessionId: string) => any[];
|
|
12
|
+
getById: (id: number) => any;
|
|
13
|
+
resolve: (id: number, status: "approved" | "rejected") => Database.RunResult;
|
|
14
|
+
clear: (sessionId: string) => Database.RunResult;
|
|
15
|
+
};
|
|
16
|
+
export declare const sessions: {
|
|
17
|
+
create: (id: string, projectPath: string, settings?: any) => Database.RunResult;
|
|
18
|
+
get: (id: string) => any;
|
|
19
|
+
updateActivity: (id: string) => Database.RunResult;
|
|
20
|
+
updateSettings: (id: string, settings: any) => Database.RunResult;
|
|
21
|
+
delete: (id: string) => Database.RunResult;
|
|
22
|
+
getAll: () => any[];
|
|
23
|
+
cleanupInactive: (daysInactive: number) => Database.RunResult;
|
|
24
|
+
};
|
|
25
|
+
export declare const backups: {
|
|
26
|
+
add: (sessionId: string, backupName: string, backupPath: string, fileCount: number, sizeBytes: number) => Database.RunResult;
|
|
27
|
+
getBySession: (sessionId: string) => unknown[];
|
|
28
|
+
delete: (id: number) => Database.RunResult;
|
|
29
|
+
getAll: () => unknown[];
|
|
30
|
+
};
|
|
31
|
+
export declare const utils: {
|
|
32
|
+
vacuum: () => void;
|
|
33
|
+
getStats: () => {
|
|
34
|
+
chatMessages: any;
|
|
35
|
+
pendingApprovals: any;
|
|
36
|
+
activeSessions: any;
|
|
37
|
+
backups: any;
|
|
38
|
+
};
|
|
39
|
+
close: () => void;
|
|
40
|
+
};
|
|
41
|
+
export default db;
|
|
42
|
+
//# sourceMappingURL=database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAYtC,QAAA,MAAM,EAAE,EAAE,QAAQ,CAAC,QAAgC,CAAC;AAoDpD,eAAO,MAAM,WAAW;qBACL,MAAM,QAAQ,MAAM,WAAW,MAAM;8BAO5B,MAAM;uBAOb,MAAM;4BAKD,MAAM;CAK/B,CAAC;AAGF,eAAO,MAAM,gBAAgB;qBACV,MAAM,iBAAiB,MAAM,iBAAiB,GAAG,gBAAgB,MAAM;8BAY9D,MAAM;kBAWlB,MAAM;kBASN,MAAM,UAAU,UAAU,GAAG,UAAU;uBAOlC,MAAM;CAI1B,CAAC;AAGF,eAAO,MAAM,QAAQ;iBACN,MAAM,eAAe,MAAM,aAAa,GAAG;cAO9C,MAAM;yBASK,MAAM;yBAKN,MAAM,YAAY,GAAG;iBAK7B,MAAM;;oCAgBa,MAAM;CAKvC,CAAC;AAGF,eAAO,MAAM,OAAO;qBACD,MAAM,cAAc,MAAM,cAAc,MAAM,aAAa,MAAM,aAAa,MAAM;8BAO3E,MAAM;iBAOnB,MAAM;;CASpB,CAAC;AAGF,eAAO,MAAM,KAAK;;;;;;;;;CAsBjB,CAAC;AAEF,eAAe,EAAE,CAAC"}
|