bob-expense-tracker-chatbot 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/.env.example +15 -0
- package/README.md +238 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +332 -0
- package/dist/cli.js.map +1 -0
- package/dist/database.d.ts +20 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +127 -0
- package/dist/database.js.map +1 -0
- package/dist/postinstall.d.ts +2 -0
- package/dist/postinstall.d.ts.map +1 -0
- package/dist/postinstall.js +13 -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 +103 -0
- package/dist/routes/aiRoutes.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +101 -0
- package/dist/server.js.map +1 -0
- package/dist/websocket.d.ts +17 -0
- package/dist/websocket.d.ts.map +1 -0
- package/dist/websocket.js +231 -0
- package/dist/websocket.js.map +1 -0
- package/package.json +72 -0
- package/public/dist/assets/index-DaW39zOL.js +40 -0
- package/public/dist/assets/index-DrB7S5OP.css +1 -0
- package/public/dist/index.html +13 -0
- package/public/inject.js +158 -0
package/.env.example
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Bob Expense Tracker ChatBot Configuration
|
|
2
|
+
|
|
3
|
+
# Server Ports
|
|
4
|
+
EXPENSE_BOT_PORT=4600
|
|
5
|
+
EXPENSE_BOT_WS_PORT=4601
|
|
6
|
+
|
|
7
|
+
# Environment
|
|
8
|
+
NODE_ENV=development
|
|
9
|
+
|
|
10
|
+
# Project Configuration
|
|
11
|
+
PROJECT_ROOT=.
|
|
12
|
+
BOB_SHELL_PATH=bob
|
|
13
|
+
|
|
14
|
+
# Database
|
|
15
|
+
# Database file will be created automatically as BobExpenseTrackerChatBot.db
|
package/README.md
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# š° Bob Expense Tracker ChatBot
|
|
2
|
+
|
|
3
|
+
An AI-powered expense tracking chatbot that can be injected into any web application. Built with Node.js, Express, WebSocket, and React.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- š¬ **Conversational Interface** - Natural language expense tracking
|
|
8
|
+
- š **Budget Analysis** - AI-powered spending insights
|
|
9
|
+
- š·ļø **Category Management** - Organize expenses by category
|
|
10
|
+
- š **Real-time Updates** - WebSocket-based live updates
|
|
11
|
+
- šØ **Beautiful UI** - Modern, responsive React interface
|
|
12
|
+
- š **Easy Integration** - Works with any web application
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install bob-expense-tracker-chatbot
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
### 1. Initialize
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx BobExpenseTrackerChatBot init
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
This will:
|
|
29
|
+
- Create configuration files
|
|
30
|
+
- Set up environment variables
|
|
31
|
+
- Inject the chatbot script into your HTML files
|
|
32
|
+
|
|
33
|
+
### 2. Start the Server
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx BobExpenseTrackerChatBot start
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The chatbot will be available at:
|
|
40
|
+
- HTTP Server: `http://localhost:4600`
|
|
41
|
+
- WebSocket Server: `ws://localhost:4601`
|
|
42
|
+
|
|
43
|
+
### 3. Open Your Application
|
|
44
|
+
|
|
45
|
+
Open your web application and the expense tracker chatbot will appear as a sidebar!
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
### CLI Commands
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Initialize in your project
|
|
53
|
+
BobExpenseTrackerChatBot init
|
|
54
|
+
|
|
55
|
+
# Start production server
|
|
56
|
+
BobExpenseTrackerChatBot start
|
|
57
|
+
|
|
58
|
+
# Start development server with auto-reload
|
|
59
|
+
BobExpenseTrackerChatBot dev
|
|
60
|
+
|
|
61
|
+
# Build for production
|
|
62
|
+
BobExpenseTrackerChatBot build
|
|
63
|
+
|
|
64
|
+
# Show help
|
|
65
|
+
BobExpenseTrackerChatBot help
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Manual Integration
|
|
69
|
+
|
|
70
|
+
If automatic injection doesn't work, add this script tag to your HTML:
|
|
71
|
+
|
|
72
|
+
```html
|
|
73
|
+
<script src="http://localhost:4600/public/inject.js"></script>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Configuration
|
|
77
|
+
|
|
78
|
+
Edit `BobExpenseTrackerChatBot.config.json`:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"version": "0.0.1",
|
|
83
|
+
"port": 4600,
|
|
84
|
+
"wsPort": 4601,
|
|
85
|
+
"projectRoot": "/path/to/your/project",
|
|
86
|
+
"bobShellPath": "bob",
|
|
87
|
+
"features": {
|
|
88
|
+
"chat": true,
|
|
89
|
+
"expenseTracking": true,
|
|
90
|
+
"budgetAnalysis": true,
|
|
91
|
+
"categoryManagement": true,
|
|
92
|
+
"reports": true,
|
|
93
|
+
"aiInsights": true
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Environment Variables
|
|
99
|
+
|
|
100
|
+
Create `.env.expense-bot`:
|
|
101
|
+
|
|
102
|
+
```env
|
|
103
|
+
EXPENSE_BOT_PORT=4600
|
|
104
|
+
EXPENSE_BOT_WS_PORT=4601
|
|
105
|
+
NODE_ENV=development
|
|
106
|
+
PROJECT_ROOT=/path/to/your/project
|
|
107
|
+
BOB_SHELL_PATH=bob
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Features in Detail
|
|
111
|
+
|
|
112
|
+
### Expense Tracking
|
|
113
|
+
|
|
114
|
+
Track expenses using natural language:
|
|
115
|
+
- "I spent $50 on groceries"
|
|
116
|
+
- "Add $25 for transportation"
|
|
117
|
+
- "Bought coffee for $5"
|
|
118
|
+
|
|
119
|
+
### Budget Analysis
|
|
120
|
+
|
|
121
|
+
Get insights into your spending:
|
|
122
|
+
- Total expenses
|
|
123
|
+
- Spending by category
|
|
124
|
+
- Trends and patterns
|
|
125
|
+
|
|
126
|
+
### Categories
|
|
127
|
+
|
|
128
|
+
Default categories include:
|
|
129
|
+
- Food & Dining
|
|
130
|
+
- Transportation
|
|
131
|
+
- Entertainment
|
|
132
|
+
- Utilities
|
|
133
|
+
- Shopping
|
|
134
|
+
- Healthcare
|
|
135
|
+
- Others
|
|
136
|
+
|
|
137
|
+
## API Endpoints
|
|
138
|
+
|
|
139
|
+
### HTTP API
|
|
140
|
+
|
|
141
|
+
- `POST /api/ai/chat` - Send chat messages
|
|
142
|
+
- `POST /api/ai/expense` - Add expense
|
|
143
|
+
- `GET /api/ai/expenses/:sessionId` - Get expenses
|
|
144
|
+
- `GET /api/ai/budget-analysis/:sessionId` - Get budget analysis
|
|
145
|
+
|
|
146
|
+
### WebSocket Events
|
|
147
|
+
|
|
148
|
+
- `init` - Initialize session
|
|
149
|
+
- `chat` - Send chat message
|
|
150
|
+
- `add_expense` - Add new expense
|
|
151
|
+
- `get_expenses` - Request expenses
|
|
152
|
+
- `get_budget_analysis` - Request budget analysis
|
|
153
|
+
|
|
154
|
+
## Development
|
|
155
|
+
|
|
156
|
+
### Project Structure
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
BobExpenseTrackerChatBot/
|
|
160
|
+
āāā src/
|
|
161
|
+
ā āāā server.ts # Express server
|
|
162
|
+
ā āāā cli.ts # CLI tool
|
|
163
|
+
ā āāā websocket.ts # WebSocket handler
|
|
164
|
+
ā āāā database.ts # SQLite database
|
|
165
|
+
ā āāā routes/
|
|
166
|
+
ā āāā aiRoutes.ts # API routes
|
|
167
|
+
āāā public/
|
|
168
|
+
ā āāā inject.js # Injection script
|
|
169
|
+
ā āāā dist/ # Built React app
|
|
170
|
+
āāā iframe-app/ # React UI
|
|
171
|
+
ā āāā src/
|
|
172
|
+
ā ā āāā App.tsx
|
|
173
|
+
ā ā āāā main.tsx
|
|
174
|
+
ā āāā package.json
|
|
175
|
+
āāā package.json
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Build from Source
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Install dependencies
|
|
182
|
+
npm install
|
|
183
|
+
|
|
184
|
+
# Build iframe app
|
|
185
|
+
cd iframe-app && npm install && npm run build && cd ..
|
|
186
|
+
|
|
187
|
+
# Build TypeScript
|
|
188
|
+
npm run build
|
|
189
|
+
|
|
190
|
+
# Start development server
|
|
191
|
+
npm run dev
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Compatibility
|
|
195
|
+
|
|
196
|
+
Works with:
|
|
197
|
+
- ā
React
|
|
198
|
+
- ā
Vue.js
|
|
199
|
+
- ā
Angular
|
|
200
|
+
- ā
Next.js
|
|
201
|
+
- ā
Static HTML
|
|
202
|
+
- ā
Any web application!
|
|
203
|
+
|
|
204
|
+
## Requirements
|
|
205
|
+
|
|
206
|
+
- Node.js >= 18.0.0
|
|
207
|
+
- Modern web browser with WebSocket support
|
|
208
|
+
|
|
209
|
+
## Troubleshooting
|
|
210
|
+
|
|
211
|
+
### Chatbot not appearing?
|
|
212
|
+
|
|
213
|
+
1. Check if the script is injected in your HTML
|
|
214
|
+
2. Verify the server is running on port 4600
|
|
215
|
+
3. Check browser console for errors
|
|
216
|
+
|
|
217
|
+
### WebSocket connection failed?
|
|
218
|
+
|
|
219
|
+
1. Ensure port 4601 is not blocked
|
|
220
|
+
2. Check firewall settings
|
|
221
|
+
3. Verify WebSocket URL in configuration
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
MIT
|
|
226
|
+
|
|
227
|
+
## Author
|
|
228
|
+
|
|
229
|
+
Bob AI
|
|
230
|
+
|
|
231
|
+
## Support
|
|
232
|
+
|
|
233
|
+
- GitHub: https://github.com/yourusername/BobExpenseTrackerChatBot
|
|
234
|
+
- Issues: https://github.com/yourusername/BobExpenseTrackerChatBot/issues
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
Made with š° by Bob AI
|
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,332 @@
|
|
|
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 Expense Tracker ChatBot ā', COLORS.cyan);
|
|
55
|
+
log('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n', COLORS.cyan);
|
|
56
|
+
}
|
|
57
|
+
function printHelp() {
|
|
58
|
+
printBanner();
|
|
59
|
+
log('Usage:', COLORS.bright);
|
|
60
|
+
log(' BobExpenseTrackerChatBot <command>\n', COLORS.reset);
|
|
61
|
+
log('Commands:', COLORS.bright);
|
|
62
|
+
log(' init Initialize Expense Tracker ChatBot in your project', COLORS.green);
|
|
63
|
+
log(' start Start the chatbot server', COLORS.green);
|
|
64
|
+
log(' dev Start in development mode with auto-reload', COLORS.green);
|
|
65
|
+
log(' build Build the chatbot for production', COLORS.green);
|
|
66
|
+
log(' help Show this help message\n', COLORS.green);
|
|
67
|
+
log('Examples:', COLORS.bright);
|
|
68
|
+
log(' BobExpenseTrackerChatBot init', COLORS.cyan);
|
|
69
|
+
log(' BobExpenseTrackerChatBot start', COLORS.cyan);
|
|
70
|
+
log(' BobExpenseTrackerChatBot dev\n', COLORS.cyan);
|
|
71
|
+
}
|
|
72
|
+
async function initProject() {
|
|
73
|
+
printBanner();
|
|
74
|
+
log('š Initializing Bob Expense Tracker ChatBot...\n', COLORS.bright);
|
|
75
|
+
const projectRoot = process.cwd();
|
|
76
|
+
const configPath = path.join(projectRoot, 'BobExpenseTrackerChatBot.config.json');
|
|
77
|
+
const envPath = path.join(projectRoot, '.env.expense-bot');
|
|
78
|
+
// Get package version
|
|
79
|
+
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
80
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
81
|
+
const currentVersion = packageJson.version;
|
|
82
|
+
let existingConfig = null;
|
|
83
|
+
let isUpgrade = false;
|
|
84
|
+
// Check if already initialized
|
|
85
|
+
if (fs.existsSync(configPath)) {
|
|
86
|
+
existingConfig = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
87
|
+
const oldVersion = existingConfig.version || '0.0.0';
|
|
88
|
+
if (oldVersion !== currentVersion) {
|
|
89
|
+
isUpgrade = true;
|
|
90
|
+
log(`š¦ Detected upgrade from v${oldVersion} to v${currentVersion}\n`, COLORS.cyan);
|
|
91
|
+
// Backup old config
|
|
92
|
+
const backupPath = `${configPath}.v${oldVersion}.backup`;
|
|
93
|
+
fs.writeFileSync(backupPath, JSON.stringify(existingConfig, null, 2));
|
|
94
|
+
log(`š¾ Backed up old config to: BobExpenseTrackerChatBot.config.json.v${oldVersion}.backup`, COLORS.green);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
log(`š Re-initializing Bob Expense Tracker ChatBot v${currentVersion}...\n`, COLORS.cyan);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// Create default config
|
|
101
|
+
const defaultConfig = {
|
|
102
|
+
version: currentVersion,
|
|
103
|
+
port: 4600,
|
|
104
|
+
wsPort: 4601,
|
|
105
|
+
projectRoot: projectRoot,
|
|
106
|
+
bobShellPath: 'bob',
|
|
107
|
+
features: {
|
|
108
|
+
chat: true,
|
|
109
|
+
expenseTracking: true,
|
|
110
|
+
budgetAnalysis: true,
|
|
111
|
+
categoryManagement: true,
|
|
112
|
+
reports: true,
|
|
113
|
+
aiInsights: true
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
// Smart merge: preserve user settings if upgrading
|
|
117
|
+
let config = defaultConfig;
|
|
118
|
+
if (existingConfig) {
|
|
119
|
+
config = {
|
|
120
|
+
...defaultConfig,
|
|
121
|
+
// Preserve user's custom settings
|
|
122
|
+
port: existingConfig.port || defaultConfig.port,
|
|
123
|
+
wsPort: existingConfig.wsPort || defaultConfig.wsPort,
|
|
124
|
+
projectRoot: existingConfig.projectRoot || defaultConfig.projectRoot,
|
|
125
|
+
bobShellPath: existingConfig.bobShellPath || defaultConfig.bobShellPath,
|
|
126
|
+
// Merge features (preserve user's feature toggles)
|
|
127
|
+
features: {
|
|
128
|
+
...defaultConfig.features,
|
|
129
|
+
...existingConfig.features
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
if (isUpgrade) {
|
|
133
|
+
log('\nš Configuration updated:', COLORS.bright);
|
|
134
|
+
log(` ā Version: ${existingConfig.version || 'none'} ā ${currentVersion}`, COLORS.green);
|
|
135
|
+
log(` ā Preserved: port (${config.port}), wsPort (${config.wsPort})`, COLORS.green);
|
|
136
|
+
log(` ā Preserved: custom feature settings`, COLORS.green);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
140
|
+
log(`\nā
${existingConfig ? 'Updated' : 'Created'} BobExpenseTrackerChatBot.config.json`, COLORS.green);
|
|
141
|
+
// Create .expenses directory for data storage
|
|
142
|
+
const expensesDir = path.join(projectRoot, '.expenses');
|
|
143
|
+
if (!fs.existsSync(expensesDir)) {
|
|
144
|
+
fs.mkdirSync(expensesDir, { recursive: true });
|
|
145
|
+
log('ā
Created .expenses directory', COLORS.green);
|
|
146
|
+
}
|
|
147
|
+
// Create .env file if it doesn't exist
|
|
148
|
+
if (!fs.existsSync(envPath)) {
|
|
149
|
+
const envContent = `# Bob Expense Tracker ChatBot Configuration
|
|
150
|
+
EXPENSE_BOT_PORT=4600
|
|
151
|
+
EXPENSE_BOT_WS_PORT=4601
|
|
152
|
+
NODE_ENV=development
|
|
153
|
+
PROJECT_ROOT=${projectRoot}
|
|
154
|
+
BOB_SHELL_PATH=bob
|
|
155
|
+
`;
|
|
156
|
+
fs.writeFileSync(envPath, envContent);
|
|
157
|
+
log('ā
Created .env.expense-bot', COLORS.green);
|
|
158
|
+
}
|
|
159
|
+
// Add to .gitignore
|
|
160
|
+
const gitignorePath = path.join(projectRoot, '.gitignore');
|
|
161
|
+
if (fs.existsSync(gitignorePath)) {
|
|
162
|
+
let gitignore = fs.readFileSync(gitignorePath, 'utf-8');
|
|
163
|
+
if (!gitignore.includes('.env.expense-bot')) {
|
|
164
|
+
gitignore += '\n# BobExpenseTrackerChatBot\n.env.expense-bot\nBobExpenseTrackerChatBot.db\n.expenses/\n';
|
|
165
|
+
fs.writeFileSync(gitignorePath, gitignore);
|
|
166
|
+
log('ā
Updated .gitignore', COLORS.green);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// Auto-inject script into HTML files
|
|
170
|
+
log('\nš Searching for HTML entry points...\n', COLORS.bright);
|
|
171
|
+
const htmlFiles = findHtmlFiles(projectRoot);
|
|
172
|
+
const injectedFiles = [];
|
|
173
|
+
if (htmlFiles.length > 0) {
|
|
174
|
+
log(`Found ${htmlFiles.length} HTML file(s)\n`, COLORS.cyan);
|
|
175
|
+
// Prioritize common entry points
|
|
176
|
+
const priorityFiles = htmlFiles.filter(file => {
|
|
177
|
+
const basename = path.basename(file);
|
|
178
|
+
return basename === 'index.html' || basename === 'main.html' || basename === 'app.html';
|
|
179
|
+
});
|
|
180
|
+
const filesToInject = priorityFiles.length > 0 ? priorityFiles : htmlFiles;
|
|
181
|
+
for (const file of filesToInject) {
|
|
182
|
+
const relativePath = path.relative(projectRoot, file);
|
|
183
|
+
try {
|
|
184
|
+
let content = fs.readFileSync(file, 'utf-8');
|
|
185
|
+
// Check if already injected
|
|
186
|
+
if (content.includes('http://localhost:4600/public/inject.js')) {
|
|
187
|
+
log(` āļø ${relativePath} - Already injected`, COLORS.yellow);
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
// Find </body> tag and inject before it
|
|
191
|
+
const bodyCloseTag = '</body>';
|
|
192
|
+
if (content.includes(bodyCloseTag)) {
|
|
193
|
+
const scriptTag = ` <!-- Expense Tracker ChatBot Injection -->\n <script src="http://localhost:4600/public/inject.js"></script>\n ${bodyCloseTag}`;
|
|
194
|
+
content = content.replace(bodyCloseTag, scriptTag);
|
|
195
|
+
fs.writeFileSync(file, content, 'utf-8');
|
|
196
|
+
log(` ā
${relativePath} - Script injected`, COLORS.green);
|
|
197
|
+
injectedFiles.push(relativePath);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
log(` ā ļø ${relativePath} - No </body> tag found`, COLORS.yellow);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
log(` ā ${relativePath} - Error: ${error.message}`, COLORS.red);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (injectedFiles.length > 0) {
|
|
208
|
+
log(`\n⨠Successfully injected script into ${injectedFiles.length} file(s)!`, COLORS.green);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
log('\nš” No files were modified. Add this line before </body> manually:', COLORS.yellow);
|
|
212
|
+
log(' <script src="http://localhost:4600/public/inject.js"></script>\n', COLORS.cyan);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
log('ā¹ļø No HTML files found in project.', COLORS.yellow);
|
|
217
|
+
log(' Add this script tag to your HTML files manually:', COLORS.yellow);
|
|
218
|
+
log(' <script src="http://localhost:4600/public/inject.js"></script>\n', COLORS.cyan);
|
|
219
|
+
}
|
|
220
|
+
log('š Bob Expense Tracker ChatBot initialized successfully!\n', COLORS.bright);
|
|
221
|
+
log('Next steps:', COLORS.bright);
|
|
222
|
+
log(' 1. Add the script tag to your HTML files (see above)', COLORS.cyan);
|
|
223
|
+
log(' 2. Run: BobExpenseTrackerChatBot start', COLORS.cyan);
|
|
224
|
+
log(' 3. Open your web app and the Expense Tracker ChatBot will appear!\n', COLORS.cyan);
|
|
225
|
+
log('š Documentation: https://github.com/yourusername/BobExpenseTrackerChatBot\n', COLORS.blue);
|
|
226
|
+
}
|
|
227
|
+
function findHtmlFiles(dir, fileList = []) {
|
|
228
|
+
const files = fs.readdirSync(dir);
|
|
229
|
+
files.forEach(file => {
|
|
230
|
+
const filePath = path.join(dir, file);
|
|
231
|
+
const stat = fs.statSync(filePath);
|
|
232
|
+
// Skip node_modules, .git, and other common directories
|
|
233
|
+
if (stat.isDirectory()) {
|
|
234
|
+
const skipDirs = ['node_modules', '.git', 'dist', 'build', '.next', '.nuxt', 'coverage'];
|
|
235
|
+
if (!skipDirs.includes(file)) {
|
|
236
|
+
findHtmlFiles(filePath, fileList);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
else if (file.endsWith('.html')) {
|
|
240
|
+
fileList.push(filePath);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
return fileList;
|
|
244
|
+
}
|
|
245
|
+
function startServer(dev = false) {
|
|
246
|
+
printBanner();
|
|
247
|
+
const mode = dev ? 'development' : 'production';
|
|
248
|
+
log(`š Starting Bob Expense Tracker ChatBot in ${mode} mode...\n`, COLORS.bright);
|
|
249
|
+
// Check if config exists
|
|
250
|
+
const configPath = path.join(process.cwd(), 'BobExpenseTrackerChatBot.config.json');
|
|
251
|
+
if (!fs.existsSync(configPath)) {
|
|
252
|
+
log('ā Bob Expense Tracker ChatBot not initialized!', COLORS.red);
|
|
253
|
+
log(' Run: BobExpenseTrackerChatBot init\n', COLORS.yellow);
|
|
254
|
+
process.exit(1);
|
|
255
|
+
}
|
|
256
|
+
// Load config
|
|
257
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
258
|
+
// Set environment variables
|
|
259
|
+
process.env.EXPENSE_BOT_PORT = config.port.toString();
|
|
260
|
+
process.env.EXPENSE_BOT_WS_PORT = config.wsPort.toString();
|
|
261
|
+
process.env.PROJECT_ROOT = config.projectRoot;
|
|
262
|
+
process.env.BOB_SHELL_PATH = config.bobShellPath || 'bob';
|
|
263
|
+
// Start server
|
|
264
|
+
const serverPath = path.join(__dirname, 'server.js');
|
|
265
|
+
if (dev) {
|
|
266
|
+
// Development mode with tsx watch
|
|
267
|
+
const child = (0, child_process_1.spawn)('npx', ['tsx', 'watch', serverPath.replace('.js', '.ts')], {
|
|
268
|
+
stdio: 'inherit',
|
|
269
|
+
shell: true,
|
|
270
|
+
env: { ...process.env }
|
|
271
|
+
});
|
|
272
|
+
child.on('error', (error) => {
|
|
273
|
+
log(`ā Failed to start server: ${error.message}`, COLORS.red);
|
|
274
|
+
process.exit(1);
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
// Production mode
|
|
279
|
+
require(serverPath);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function buildProject() {
|
|
283
|
+
printBanner();
|
|
284
|
+
log('šØ Building Bob Expense Tracker ChatBot...\n', COLORS.bright);
|
|
285
|
+
const child = (0, child_process_1.spawn)('npm', ['run', 'build'], {
|
|
286
|
+
stdio: 'inherit',
|
|
287
|
+
shell: true,
|
|
288
|
+
cwd: __dirname
|
|
289
|
+
});
|
|
290
|
+
child.on('close', (code) => {
|
|
291
|
+
if (code === 0) {
|
|
292
|
+
log('\nā
Build completed successfully!', COLORS.green);
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
log('\nā Build failed!', COLORS.red);
|
|
296
|
+
process.exit(1);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
// Main CLI logic
|
|
301
|
+
const args = process.argv.slice(2);
|
|
302
|
+
const command = args[0];
|
|
303
|
+
switch (command) {
|
|
304
|
+
case 'init':
|
|
305
|
+
initProject();
|
|
306
|
+
break;
|
|
307
|
+
case 'start':
|
|
308
|
+
startServer(false);
|
|
309
|
+
break;
|
|
310
|
+
case 'dev':
|
|
311
|
+
startServer(true);
|
|
312
|
+
break;
|
|
313
|
+
case 'build':
|
|
314
|
+
buildProject();
|
|
315
|
+
break;
|
|
316
|
+
case 'help':
|
|
317
|
+
case '--help':
|
|
318
|
+
case '-h':
|
|
319
|
+
printHelp();
|
|
320
|
+
break;
|
|
321
|
+
default:
|
|
322
|
+
if (!command) {
|
|
323
|
+
printHelp();
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
log(`ā Unknown command: ${command}\n`, COLORS.red);
|
|
327
|
+
printHelp();
|
|
328
|
+
process.exit(1);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
// Made with Bob
|
|
332
|
+
//# 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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EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;YACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,iBAAiB;AACjB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAExB,QAAQ,OAAO,EAAE,CAAC;IAChB,KAAK,MAAM;QACT,WAAW,EAAE,CAAC;QACd,MAAM;IAER,KAAK,OAAO;QACV,WAAW,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM;IAER,KAAK,KAAK;QACR,WAAW,CAAC,IAAI,CAAC,CAAC;QAClB,MAAM;IAER,KAAK,OAAO;QACV,YAAY,EAAE,CAAC;QACf,MAAM;IAER,KAAK,MAAM,CAAC;IACZ,KAAK,QAAQ,CAAC;IACd,KAAK,IAAI;QACP,SAAS,EAAE,CAAC;QACZ,MAAM;IAER;QACE,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,SAAS,EAAE,CAAC;QACd,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,sBAAsB,OAAO,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;YACnD,SAAS,EAAE,CAAC;YACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;AACL,CAAC;AAED,gBAAgB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Database from 'better-sqlite3';
|
|
2
|
+
declare const db: Database.Database;
|
|
3
|
+
export declare const sessions: {
|
|
4
|
+
create: (id: string, projectPath: string, settings: any) => void;
|
|
5
|
+
updateActivity: (id: string) => void;
|
|
6
|
+
get: (id: string) => unknown;
|
|
7
|
+
};
|
|
8
|
+
export declare const chatHistory: {
|
|
9
|
+
add: (sessionId: string, role: string, content: string) => void;
|
|
10
|
+
getBySession: (sessionId: string, limit?: number) => unknown[];
|
|
11
|
+
clear: (sessionId: string) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const expenseRecords: {
|
|
14
|
+
add: (sessionId: string, expense: any) => number | bigint;
|
|
15
|
+
getBySession: (sessionId: string, filters?: any) => unknown[];
|
|
16
|
+
delete: (id: number) => void;
|
|
17
|
+
update: (id: number, expense: any) => void;
|
|
18
|
+
};
|
|
19
|
+
export default db;
|
|
20
|
+
//# 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;AAItC,QAAA,MAAM,EAAE,EAAE,QAAQ,CAAC,QAA+B,CAAC;AAkCnD,eAAO,MAAM,QAAQ;iBACN,MAAM,eAAe,MAAM,YAAY,GAAG;yBASlC,MAAM;cAKjB,MAAM;CAIjB,CAAC;AAGF,eAAO,MAAM,WAAW;qBACL,MAAM,QAAQ,MAAM,WAAW,MAAM;8BAQ5B,MAAM,UAAS,MAAM;uBAU5B,MAAM;CAI1B,CAAC;AAGF,eAAO,MAAM,cAAc;qBACR,MAAM,WAAW,GAAG;8BAgBX,MAAM,YAAY,GAAG;iBAyBlC,MAAM;iBAKN,MAAM,WAAW,GAAG;CAQlC,CAAC;AAEF,eAAe,EAAE,CAAC"}
|