vibecodingmachine-cli 2026.3.10-1812 → 2026.3.14-1528
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 +85 -85
- package/bin/vibecodingmachine.js +3 -0
- package/package.json +4 -3
- package/scripts/postinstall.js +161 -161
- package/src/commands/auth.js +100 -100
- package/src/commands/auto-direct.js +16 -5
- package/src/commands/auto-execution.js +25 -0
- package/src/commands/auto-requirement-management.js +8 -8
- package/src/commands/auto-status-helpers.js +5 -3
- package/src/commands/computers.js +318 -318
- package/src/commands/feature.js +123 -123
- package/src/commands/locale.js +72 -72
- package/src/commands/repo.js +163 -163
- package/src/commands/setup.js +93 -93
- package/src/commands/sync.js +287 -287
- package/src/index.js +5 -5
- package/src/utils/agent-selector.js +50 -50
- package/src/utils/asset-cleanup.js +60 -60
- package/src/utils/auto-mode-ansi-ui.js +237 -237
- package/src/utils/auto-mode-simple-ui.js +141 -141
- package/src/utils/copy-with-progress.js +167 -167
- package/src/utils/download-with-progress.js +84 -84
- package/src/utils/keyboard-handler.js +153 -153
- package/src/utils/kiro-installer.js +178 -178
- package/src/utils/logger.js +4 -4
- package/src/utils/persistent-header.js +114 -114
- package/src/utils/prompt-helper.js +63 -63
- package/src/utils/provider-checker/agent-checker.js +25 -1
- package/src/utils/provider-checker/agent-runner.js +115 -37
- package/src/utils/provider-checker/agents-manager.js +210 -0
- package/src/utils/provider-checker/provider-validator.js +5 -49
- package/src/utils/provider-checker/requirements-manager.js +86 -65
- package/src/utils/provider-checker/test-requirements.js +25 -17
- package/src/utils/status-card.js +121 -121
- package/src/utils/stdout-interceptor.js +127 -127
- package/src/utils/user-tracking.js +299 -299
|
@@ -1,300 +1,300 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* User Tracking Integration for CLI
|
|
3
|
-
*
|
|
4
|
-
* This module integrates the CLI with the enhanced user tracking system,
|
|
5
|
-
* automatically logging user activities and updating usage statistics.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const auth = require('./auth')
|
|
9
|
-
|
|
10
|
-
class CLIUserTracking {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.sessionStartTime = Date.now()
|
|
13
|
-
this.activityBuffer = []
|
|
14
|
-
this.flushInterval = null
|
|
15
|
-
|
|
16
|
-
// Start periodic flush of activity data
|
|
17
|
-
this.startActivityFlush()
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Track CLI command execution
|
|
22
|
-
*/
|
|
23
|
-
async trackCommand(command, args = [], metadata = {}) {
|
|
24
|
-
try {
|
|
25
|
-
await auth.trackCLIActivity('command_executed', {
|
|
26
|
-
command,
|
|
27
|
-
args: args.filter(arg => !arg.includes('password') && !arg.includes('token')), // Filter sensitive data
|
|
28
|
-
duration: 0,
|
|
29
|
-
...metadata
|
|
30
|
-
})
|
|
31
|
-
} catch (error) {
|
|
32
|
-
// Silently fail - don't disrupt user experience
|
|
33
|
-
console.debug('Failed to track command:', error.message)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Track requirement operations
|
|
39
|
-
*/
|
|
40
|
-
async trackRequirementActivity(action, requirementData = {}) {
|
|
41
|
-
try {
|
|
42
|
-
await auth.trackCLIActivity('requirement_activity', {
|
|
43
|
-
action, // 'created', 'updated', 'completed', 'verified', etc.
|
|
44
|
-
requirementId: requirementData.id,
|
|
45
|
-
package: requirementData.package,
|
|
46
|
-
duration: 0,
|
|
47
|
-
metadata: {
|
|
48
|
-
hasDescription: !!requirementData.description,
|
|
49
|
-
descriptionLength: requirementData.description?.length || 0,
|
|
50
|
-
timestamp: Date.now()
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
} catch (error) {
|
|
54
|
-
console.debug('Failed to track requirement activity:', error.message)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Track auto mode sessions
|
|
60
|
-
*/
|
|
61
|
-
async trackAutoModeSession(action, sessionData = {}) {
|
|
62
|
-
try {
|
|
63
|
-
await auth.trackCLIActivity('auto_mode', {
|
|
64
|
-
action, // 'started', 'stopped', 'iteration_completed'
|
|
65
|
-
duration: sessionData.duration || 0,
|
|
66
|
-
metadata: {
|
|
67
|
-
maxIterations: sessionData.maxIterations,
|
|
68
|
-
completedIterations: sessionData.completedIterations,
|
|
69
|
-
ide: sessionData.ide,
|
|
70
|
-
timestamp: Date.now()
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
} catch (error) {
|
|
74
|
-
console.debug('Failed to track auto mode session:', error.message)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Track IDE interactions
|
|
80
|
-
*/
|
|
81
|
-
async trackIDEInteraction(ide, action, metadata = {}) {
|
|
82
|
-
try {
|
|
83
|
-
await auth.trackCLIActivity('ide_interaction', {
|
|
84
|
-
action, // 'opened', 'sent_message', 'received_response'
|
|
85
|
-
ide,
|
|
86
|
-
duration: metadata.duration || 0,
|
|
87
|
-
metadata: {
|
|
88
|
-
messageLength: metadata.messageLength,
|
|
89
|
-
responseLength: metadata.responseLength,
|
|
90
|
-
success: metadata.success !== false,
|
|
91
|
-
timestamp: Date.now()
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
} catch (error) {
|
|
95
|
-
console.debug('Failed to track IDE interaction:', error.message)
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Track project operations
|
|
101
|
-
*/
|
|
102
|
-
async trackProjectActivity(action, projectData = {}) {
|
|
103
|
-
try {
|
|
104
|
-
await auth.trackCLIActivity('project_activity', {
|
|
105
|
-
action, // 'created', 'opened', 'switched'
|
|
106
|
-
duration: 0,
|
|
107
|
-
metadata: {
|
|
108
|
-
projectPath: projectData.path,
|
|
109
|
-
hasDescription: !!projectData.description,
|
|
110
|
-
techStack: projectData.techStack || [],
|
|
111
|
-
timestamp: Date.now()
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
} catch (error) {
|
|
115
|
-
console.debug('Failed to track project activity:', error.message)
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Track sync operations
|
|
121
|
-
*/
|
|
122
|
-
async trackSyncActivity(action, syncData = {}) {
|
|
123
|
-
try {
|
|
124
|
-
await auth.trackCLIActivity('sync_activity', {
|
|
125
|
-
action, // 'started', 'completed', 'failed'
|
|
126
|
-
duration: syncData.duration || 0,
|
|
127
|
-
metadata: {
|
|
128
|
-
itemsSync: syncData.itemsSync || 0,
|
|
129
|
-
conflicts: syncData.conflicts || 0,
|
|
130
|
-
success: syncData.success !== false,
|
|
131
|
-
timestamp: Date.now()
|
|
132
|
-
}
|
|
133
|
-
})
|
|
134
|
-
} catch (error) {
|
|
135
|
-
console.debug('Failed to track sync activity:', error.message)
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Track session duration and end session
|
|
141
|
-
*/
|
|
142
|
-
async endSession() {
|
|
143
|
-
try {
|
|
144
|
-
const sessionDuration = Date.now() - this.sessionStartTime
|
|
145
|
-
|
|
146
|
-
await auth.trackCLIActivity('session_ended', {
|
|
147
|
-
duration: Math.round(sessionDuration / 1000), // Convert to seconds
|
|
148
|
-
metadata: {
|
|
149
|
-
sessionStartTime: this.sessionStartTime,
|
|
150
|
-
sessionEndTime: Date.now(),
|
|
151
|
-
totalCommands: this.activityBuffer.length,
|
|
152
|
-
timestamp: Date.now()
|
|
153
|
-
}
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
// Stop activity flushing
|
|
157
|
-
if (this.flushInterval) {
|
|
158
|
-
clearInterval(this.flushInterval)
|
|
159
|
-
}
|
|
160
|
-
} catch (error) {
|
|
161
|
-
console.debug('Failed to track session end:', error.message)
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Start periodic flushing of activity data
|
|
167
|
-
*/
|
|
168
|
-
startActivityFlush() {
|
|
169
|
-
// Flush activity buffer every 5 minutes
|
|
170
|
-
this.flushInterval = setInterval(() => {
|
|
171
|
-
this.flushActivityBuffer()
|
|
172
|
-
}, 5 * 60 * 1000)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Flush buffered activity data
|
|
177
|
-
*/
|
|
178
|
-
async flushActivityBuffer() {
|
|
179
|
-
if (this.activityBuffer.length === 0) return
|
|
180
|
-
|
|
181
|
-
try {
|
|
182
|
-
// Update user activity timestamp
|
|
183
|
-
const token = await auth.getToken()
|
|
184
|
-
if (token && token.id_token) {
|
|
185
|
-
await auth._updateUserActivity()
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// Clear buffer after successful flush
|
|
189
|
-
this.activityBuffer = []
|
|
190
|
-
} catch (error) {
|
|
191
|
-
console.debug('Failed to flush activity buffer:', error.message)
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Register project with enhanced tracking
|
|
197
|
-
*/
|
|
198
|
-
async registerProject(projectInfo) {
|
|
199
|
-
try {
|
|
200
|
-
const token = await auth.getToken()
|
|
201
|
-
if (!token || !token.id_token) return null
|
|
202
|
-
|
|
203
|
-
const payload = JSON.parse(Buffer.from(token.id_token.split('.')[1], 'base64').toString())
|
|
204
|
-
|
|
205
|
-
const UserDatabase = require('vibecodingmachine-core/src/database/user-schema')
|
|
206
|
-
const userDb = new UserDatabase()
|
|
207
|
-
|
|
208
|
-
const userId = userDb.generateUserId(payload.email)
|
|
209
|
-
|
|
210
|
-
const project = await userDb.registerProject(userId, {
|
|
211
|
-
name: projectInfo.name || 'Unnamed Project',
|
|
212
|
-
description: projectInfo.description || '',
|
|
213
|
-
path: projectInfo.path || process.cwd(),
|
|
214
|
-
techStack: projectInfo.techStack || [],
|
|
215
|
-
framework: projectInfo.framework || '',
|
|
216
|
-
language: projectInfo.language || '',
|
|
217
|
-
goals: projectInfo.goals || '',
|
|
218
|
-
category: projectInfo.category || 'general'
|
|
219
|
-
})
|
|
220
|
-
|
|
221
|
-
// Track project creation
|
|
222
|
-
await this.trackProjectActivity('created', {
|
|
223
|
-
path: project.path,
|
|
224
|
-
description: project.description,
|
|
225
|
-
techStack: project.techStack
|
|
226
|
-
})
|
|
227
|
-
|
|
228
|
-
return project
|
|
229
|
-
} catch (error) {
|
|
230
|
-
console.debug('Failed to register project:', error.message)
|
|
231
|
-
return null
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Check and prompt for compliance if needed
|
|
237
|
-
*/
|
|
238
|
-
async checkCompliance() {
|
|
239
|
-
try {
|
|
240
|
-
const token = await auth.getToken()
|
|
241
|
-
if (!token || !token.id_token) return { compliant: false }
|
|
242
|
-
|
|
243
|
-
const payload = JSON.parse(Buffer.from(token.id_token.split('.')[1], 'base64').toString())
|
|
244
|
-
|
|
245
|
-
const ComplianceManager = require('vibecodingmachine-core/src/compliance/compliance-manager')
|
|
246
|
-
const compliance = new ComplianceManager()
|
|
247
|
-
|
|
248
|
-
const UserDatabase = require('vibecodingmachine-core/src/database/user-schema')
|
|
249
|
-
const userDb = new UserDatabase()
|
|
250
|
-
const userId = userDb.generateUserId(payload.email)
|
|
251
|
-
|
|
252
|
-
const status = await compliance.checkComplianceStatus(userId)
|
|
253
|
-
|
|
254
|
-
return {
|
|
255
|
-
compliant: !status.needsAcknowledgment,
|
|
256
|
-
termsAccepted: status.termsAccepted,
|
|
257
|
-
privacyAccepted: status.privacyAccepted,
|
|
258
|
-
requiredActions: status.requiredActions
|
|
259
|
-
}
|
|
260
|
-
} catch (error) {
|
|
261
|
-
console.debug('Failed to check compliance:', error.message)
|
|
262
|
-
return { compliant: true } // Default to compliant to not block users
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Record compliance acknowledgment
|
|
268
|
-
*/
|
|
269
|
-
async recordCompliance(acknowledgments) {
|
|
270
|
-
try {
|
|
271
|
-
const token = await auth.getToken()
|
|
272
|
-
if (!token || !token.id_token) return false
|
|
273
|
-
|
|
274
|
-
const payload = JSON.parse(Buffer.from(token.id_token.split('.')[1], 'base64').toString())
|
|
275
|
-
|
|
276
|
-
const ComplianceManager = require('vibecodingmachine-core/src/compliance/compliance-manager')
|
|
277
|
-
const compliance = new ComplianceManager()
|
|
278
|
-
|
|
279
|
-
const UserDatabase = require('vibecodingmachine-core/src/database/user-schema')
|
|
280
|
-
const userDb = new UserDatabase()
|
|
281
|
-
const userId = userDb.generateUserId(payload.email)
|
|
282
|
-
|
|
283
|
-
await compliance.recordAcknowledgment(userId, acknowledgments)
|
|
284
|
-
|
|
285
|
-
// Track compliance activity
|
|
286
|
-
await this.trackCommand('compliance_acknowledged', [], {
|
|
287
|
-
termsAccepted: acknowledgments.terms,
|
|
288
|
-
privacyAccepted: acknowledgments.privacy
|
|
289
|
-
})
|
|
290
|
-
|
|
291
|
-
return true
|
|
292
|
-
} catch (error) {
|
|
293
|
-
console.debug('Failed to record compliance:', error.message)
|
|
294
|
-
return false
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// Export singleton instance
|
|
1
|
+
/**
|
|
2
|
+
* User Tracking Integration for CLI
|
|
3
|
+
*
|
|
4
|
+
* This module integrates the CLI with the enhanced user tracking system,
|
|
5
|
+
* automatically logging user activities and updating usage statistics.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const auth = require('./auth')
|
|
9
|
+
|
|
10
|
+
class CLIUserTracking {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.sessionStartTime = Date.now()
|
|
13
|
+
this.activityBuffer = []
|
|
14
|
+
this.flushInterval = null
|
|
15
|
+
|
|
16
|
+
// Start periodic flush of activity data
|
|
17
|
+
this.startActivityFlush()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Track CLI command execution
|
|
22
|
+
*/
|
|
23
|
+
async trackCommand(command, args = [], metadata = {}) {
|
|
24
|
+
try {
|
|
25
|
+
await auth.trackCLIActivity('command_executed', {
|
|
26
|
+
command,
|
|
27
|
+
args: args.filter(arg => !arg.includes('password') && !arg.includes('token')), // Filter sensitive data
|
|
28
|
+
duration: 0,
|
|
29
|
+
...metadata
|
|
30
|
+
})
|
|
31
|
+
} catch (error) {
|
|
32
|
+
// Silently fail - don't disrupt user experience
|
|
33
|
+
console.debug('Failed to track command:', error.message)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Track requirement operations
|
|
39
|
+
*/
|
|
40
|
+
async trackRequirementActivity(action, requirementData = {}) {
|
|
41
|
+
try {
|
|
42
|
+
await auth.trackCLIActivity('requirement_activity', {
|
|
43
|
+
action, // 'created', 'updated', 'completed', 'verified', etc.
|
|
44
|
+
requirementId: requirementData.id,
|
|
45
|
+
package: requirementData.package,
|
|
46
|
+
duration: 0,
|
|
47
|
+
metadata: {
|
|
48
|
+
hasDescription: !!requirementData.description,
|
|
49
|
+
descriptionLength: requirementData.description?.length || 0,
|
|
50
|
+
timestamp: Date.now()
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.debug('Failed to track requirement activity:', error.message)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Track auto mode sessions
|
|
60
|
+
*/
|
|
61
|
+
async trackAutoModeSession(action, sessionData = {}) {
|
|
62
|
+
try {
|
|
63
|
+
await auth.trackCLIActivity('auto_mode', {
|
|
64
|
+
action, // 'started', 'stopped', 'iteration_completed'
|
|
65
|
+
duration: sessionData.duration || 0,
|
|
66
|
+
metadata: {
|
|
67
|
+
maxIterations: sessionData.maxIterations,
|
|
68
|
+
completedIterations: sessionData.completedIterations,
|
|
69
|
+
ide: sessionData.ide,
|
|
70
|
+
timestamp: Date.now()
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.debug('Failed to track auto mode session:', error.message)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Track IDE interactions
|
|
80
|
+
*/
|
|
81
|
+
async trackIDEInteraction(ide, action, metadata = {}) {
|
|
82
|
+
try {
|
|
83
|
+
await auth.trackCLIActivity('ide_interaction', {
|
|
84
|
+
action, // 'opened', 'sent_message', 'received_response'
|
|
85
|
+
ide,
|
|
86
|
+
duration: metadata.duration || 0,
|
|
87
|
+
metadata: {
|
|
88
|
+
messageLength: metadata.messageLength,
|
|
89
|
+
responseLength: metadata.responseLength,
|
|
90
|
+
success: metadata.success !== false,
|
|
91
|
+
timestamp: Date.now()
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.debug('Failed to track IDE interaction:', error.message)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Track project operations
|
|
101
|
+
*/
|
|
102
|
+
async trackProjectActivity(action, projectData = {}) {
|
|
103
|
+
try {
|
|
104
|
+
await auth.trackCLIActivity('project_activity', {
|
|
105
|
+
action, // 'created', 'opened', 'switched'
|
|
106
|
+
duration: 0,
|
|
107
|
+
metadata: {
|
|
108
|
+
projectPath: projectData.path,
|
|
109
|
+
hasDescription: !!projectData.description,
|
|
110
|
+
techStack: projectData.techStack || [],
|
|
111
|
+
timestamp: Date.now()
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
} catch (error) {
|
|
115
|
+
console.debug('Failed to track project activity:', error.message)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Track sync operations
|
|
121
|
+
*/
|
|
122
|
+
async trackSyncActivity(action, syncData = {}) {
|
|
123
|
+
try {
|
|
124
|
+
await auth.trackCLIActivity('sync_activity', {
|
|
125
|
+
action, // 'started', 'completed', 'failed'
|
|
126
|
+
duration: syncData.duration || 0,
|
|
127
|
+
metadata: {
|
|
128
|
+
itemsSync: syncData.itemsSync || 0,
|
|
129
|
+
conflicts: syncData.conflicts || 0,
|
|
130
|
+
success: syncData.success !== false,
|
|
131
|
+
timestamp: Date.now()
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
} catch (error) {
|
|
135
|
+
console.debug('Failed to track sync activity:', error.message)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Track session duration and end session
|
|
141
|
+
*/
|
|
142
|
+
async endSession() {
|
|
143
|
+
try {
|
|
144
|
+
const sessionDuration = Date.now() - this.sessionStartTime
|
|
145
|
+
|
|
146
|
+
await auth.trackCLIActivity('session_ended', {
|
|
147
|
+
duration: Math.round(sessionDuration / 1000), // Convert to seconds
|
|
148
|
+
metadata: {
|
|
149
|
+
sessionStartTime: this.sessionStartTime,
|
|
150
|
+
sessionEndTime: Date.now(),
|
|
151
|
+
totalCommands: this.activityBuffer.length,
|
|
152
|
+
timestamp: Date.now()
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
// Stop activity flushing
|
|
157
|
+
if (this.flushInterval) {
|
|
158
|
+
clearInterval(this.flushInterval)
|
|
159
|
+
}
|
|
160
|
+
} catch (error) {
|
|
161
|
+
console.debug('Failed to track session end:', error.message)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Start periodic flushing of activity data
|
|
167
|
+
*/
|
|
168
|
+
startActivityFlush() {
|
|
169
|
+
// Flush activity buffer every 5 minutes
|
|
170
|
+
this.flushInterval = setInterval(() => {
|
|
171
|
+
this.flushActivityBuffer()
|
|
172
|
+
}, 5 * 60 * 1000)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Flush buffered activity data
|
|
177
|
+
*/
|
|
178
|
+
async flushActivityBuffer() {
|
|
179
|
+
if (this.activityBuffer.length === 0) return
|
|
180
|
+
|
|
181
|
+
try {
|
|
182
|
+
// Update user activity timestamp
|
|
183
|
+
const token = await auth.getToken()
|
|
184
|
+
if (token && token.id_token) {
|
|
185
|
+
await auth._updateUserActivity()
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Clear buffer after successful flush
|
|
189
|
+
this.activityBuffer = []
|
|
190
|
+
} catch (error) {
|
|
191
|
+
console.debug('Failed to flush activity buffer:', error.message)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Register project with enhanced tracking
|
|
197
|
+
*/
|
|
198
|
+
async registerProject(projectInfo) {
|
|
199
|
+
try {
|
|
200
|
+
const token = await auth.getToken()
|
|
201
|
+
if (!token || !token.id_token) return null
|
|
202
|
+
|
|
203
|
+
const payload = JSON.parse(Buffer.from(token.id_token.split('.')[1], 'base64').toString())
|
|
204
|
+
|
|
205
|
+
const UserDatabase = require('vibecodingmachine-core/src/database/user-schema')
|
|
206
|
+
const userDb = new UserDatabase()
|
|
207
|
+
|
|
208
|
+
const userId = userDb.generateUserId(payload.email)
|
|
209
|
+
|
|
210
|
+
const project = await userDb.registerProject(userId, {
|
|
211
|
+
name: projectInfo.name || 'Unnamed Project',
|
|
212
|
+
description: projectInfo.description || '',
|
|
213
|
+
path: projectInfo.path || process.cwd(),
|
|
214
|
+
techStack: projectInfo.techStack || [],
|
|
215
|
+
framework: projectInfo.framework || '',
|
|
216
|
+
language: projectInfo.language || '',
|
|
217
|
+
goals: projectInfo.goals || '',
|
|
218
|
+
category: projectInfo.category || 'general'
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
// Track project creation
|
|
222
|
+
await this.trackProjectActivity('created', {
|
|
223
|
+
path: project.path,
|
|
224
|
+
description: project.description,
|
|
225
|
+
techStack: project.techStack
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
return project
|
|
229
|
+
} catch (error) {
|
|
230
|
+
console.debug('Failed to register project:', error.message)
|
|
231
|
+
return null
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Check and prompt for compliance if needed
|
|
237
|
+
*/
|
|
238
|
+
async checkCompliance() {
|
|
239
|
+
try {
|
|
240
|
+
const token = await auth.getToken()
|
|
241
|
+
if (!token || !token.id_token) return { compliant: false }
|
|
242
|
+
|
|
243
|
+
const payload = JSON.parse(Buffer.from(token.id_token.split('.')[1], 'base64').toString())
|
|
244
|
+
|
|
245
|
+
const ComplianceManager = require('vibecodingmachine-core/src/compliance/compliance-manager')
|
|
246
|
+
const compliance = new ComplianceManager()
|
|
247
|
+
|
|
248
|
+
const UserDatabase = require('vibecodingmachine-core/src/database/user-schema')
|
|
249
|
+
const userDb = new UserDatabase()
|
|
250
|
+
const userId = userDb.generateUserId(payload.email)
|
|
251
|
+
|
|
252
|
+
const status = await compliance.checkComplianceStatus(userId)
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
compliant: !status.needsAcknowledgment,
|
|
256
|
+
termsAccepted: status.termsAccepted,
|
|
257
|
+
privacyAccepted: status.privacyAccepted,
|
|
258
|
+
requiredActions: status.requiredActions
|
|
259
|
+
}
|
|
260
|
+
} catch (error) {
|
|
261
|
+
console.debug('Failed to check compliance:', error.message)
|
|
262
|
+
return { compliant: true } // Default to compliant to not block users
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Record compliance acknowledgment
|
|
268
|
+
*/
|
|
269
|
+
async recordCompliance(acknowledgments) {
|
|
270
|
+
try {
|
|
271
|
+
const token = await auth.getToken()
|
|
272
|
+
if (!token || !token.id_token) return false
|
|
273
|
+
|
|
274
|
+
const payload = JSON.parse(Buffer.from(token.id_token.split('.')[1], 'base64').toString())
|
|
275
|
+
|
|
276
|
+
const ComplianceManager = require('vibecodingmachine-core/src/compliance/compliance-manager')
|
|
277
|
+
const compliance = new ComplianceManager()
|
|
278
|
+
|
|
279
|
+
const UserDatabase = require('vibecodingmachine-core/src/database/user-schema')
|
|
280
|
+
const userDb = new UserDatabase()
|
|
281
|
+
const userId = userDb.generateUserId(payload.email)
|
|
282
|
+
|
|
283
|
+
await compliance.recordAcknowledgment(userId, acknowledgments)
|
|
284
|
+
|
|
285
|
+
// Track compliance activity
|
|
286
|
+
await this.trackCommand('compliance_acknowledged', [], {
|
|
287
|
+
termsAccepted: acknowledgments.terms,
|
|
288
|
+
privacyAccepted: acknowledgments.privacy
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
return true
|
|
292
|
+
} catch (error) {
|
|
293
|
+
console.debug('Failed to record compliance:', error.message)
|
|
294
|
+
return false
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Export singleton instance
|
|
300
300
|
module.exports = new CLIUserTracking()
|