dev3000 0.0.62 → 0.0.63
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/mcp-server/.next/BUILD_ID +1 -1
- package/mcp-server/.next/build-manifest.json +2 -2
- package/mcp-server/.next/cache/.tsbuildinfo +1 -1
- package/mcp-server/.next/fallback-build-manifest.json +2 -2
- package/mcp-server/.next/prerender-manifest.json +7 -7
- package/mcp-server/.next/server/app/_global-error.html +2 -2
- package/mcp-server/.next/server/app/_global-error.rsc +1 -1
- package/mcp-server/.next/server/app/_not-found.html +1 -1
- package/mcp-server/.next/server/app/_not-found.rsc +1 -1
- package/mcp-server/.next/server/app/index.html +1 -1
- package/mcp-server/.next/server/app/index.rsc +1 -1
- package/mcp-server/.next/server/app/replay.html +1 -1
- package/mcp-server/.next/server/app/replay.rsc +1 -1
- package/mcp-server/.next/server/chunks/[root-of-the-server]__7f1ecf7b._.js +1 -1
- package/mcp-server/.next/server/chunks/[root-of-the-server]__7f1ecf7b._.js.map +1 -1
- package/mcp-server/.next/server/chunks/[root-of-the-server]__82298dd3._.js +5 -9
- package/mcp-server/.next/server/chunks/[root-of-the-server]__82298dd3._.js.map +1 -1
- package/mcp-server/.next/server/pages/404.html +1 -1
- package/mcp-server/.next/server/pages/500.html +2 -2
- package/mcp-server/.next/standalone/.next/BUILD_ID +1 -1
- package/mcp-server/.next/standalone/.next/build-manifest.json +2 -2
- package/mcp-server/.next/standalone/.next/prerender-manifest.json +7 -7
- package/mcp-server/.next/standalone/.next/server/app/_global-error.html +2 -2
- package/mcp-server/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/mcp-server/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/mcp-server/.next/standalone/.next/server/app/_not-found.rsc +1 -1
- package/mcp-server/.next/standalone/.next/server/app/index.html +1 -1
- package/mcp-server/.next/standalone/.next/server/app/index.rsc +1 -1
- package/mcp-server/.next/standalone/.next/server/app/replay.html +1 -1
- package/mcp-server/.next/standalone/.next/server/app/replay.rsc +1 -1
- package/mcp-server/.next/standalone/.next/server/chunks/[root-of-the-server]__7f1ecf7b._.js +1 -1
- package/mcp-server/.next/standalone/.next/server/chunks/[root-of-the-server]__82298dd3._.js +5 -9
- package/mcp-server/.next/standalone/.next/server/pages/404.html +1 -1
- package/mcp-server/.next/standalone/.next/server/pages/500.html +2 -2
- package/mcp-server/.next/standalone/app/api/mcp/[transport]/route.ts +127 -675
- package/mcp-server/.next/trace +1 -1
- package/mcp-server/app/api/mcp/[transport]/route.ts +127 -675
- package/mcp-server/app/api/tools/route.ts +14 -133
- package/package.json +1 -1
- /package/mcp-server/.next/static/{fgx2Ltd5vbloYUQlVKX60 → WhxLPERbsd5bnNddF-udj}/_buildManifest.js +0 -0
- /package/mcp-server/.next/static/{fgx2Ltd5vbloYUQlVKX60 → WhxLPERbsd5bnNddF-udj}/_clientMiddlewareManifest.json +0 -0
- /package/mcp-server/.next/static/{fgx2Ltd5vbloYUQlVKX60 → WhxLPERbsd5bnNddF-udj}/_ssgManifest.js +0 -0
|
@@ -5,19 +5,39 @@ import { z } from "zod"
|
|
|
5
5
|
|
|
6
6
|
const handler = createMcpHandler(
|
|
7
7
|
(server) => {
|
|
8
|
-
//
|
|
8
|
+
// Enhanced debug_my_app - the ultimate debugging tool
|
|
9
9
|
server.tool(
|
|
10
10
|
"debug_my_app",
|
|
11
|
-
"
|
|
11
|
+
"🎯 **THE ULTIMATE FIND→FIX→VERIFY MACHINE!** This tool is pure dev3000 magic - it FINDS all issues instantly, GUIDES you to fix them perfectly, then helps you VERIFY the fixes work! 🪄\n\n🔥 **INSTANT DEBUGGING SUPERPOWERS:**\n• Detects ALL error types: server crashes, browser errors, build failures, API issues, performance problems\n• Analyzes timestamps, error patterns, user interactions, network requests - COMPREHENSIVELY\n• Provides step-by-step fix recommendations with exact file locations and code examples\n\n⚡ **3 MAGICAL MODES:**\n• SNAPSHOT: 'What's broken RIGHT NOW?' → Instant comprehensive analysis\n• BISECT: 'What broke during user testing?' → Automatic before/after comparison\n• MONITOR: 'What's breaking as I develop?' → Continuous health monitoring\n\n🎪 **THE DEV3000 MAGIC WORKFLOW:**\n1️⃣ I FIND all issues (replaces 8+ separate tools!)\n2️⃣ You FIX them with my detailed guidance \n3️⃣ We VERIFY fixes work with execute_browser_action\n\n💡 **PERFECT FOR:** 'debug my app' requests, proactive monitoring, timestamp-based debugging, comprehensive error analysis. This tool makes debugging FUN and gets RESULTS!",
|
|
12
12
|
{
|
|
13
13
|
focusArea: z
|
|
14
14
|
.string()
|
|
15
15
|
.optional()
|
|
16
|
-
.describe("Specific area
|
|
16
|
+
.describe("Specific area: 'build', 'runtime', 'network', 'ui', 'all' (default: 'all')"),
|
|
17
|
+
mode: z
|
|
18
|
+
.enum(["snapshot", "bisect", "monitor"])
|
|
19
|
+
.optional()
|
|
20
|
+
.describe("Debug mode: 'snapshot' (immediate), 'bisect' (timestamp-based), 'monitor' (continuous)"),
|
|
21
|
+
waitForUserInteraction: z
|
|
22
|
+
.boolean()
|
|
23
|
+
.optional()
|
|
24
|
+
.describe("In bisect mode: capture timestamp, wait for user testing, then analyze (default: false)"),
|
|
25
|
+
timeRangeMinutes: z.number().optional().describe("Minutes to analyze back from now (default: 10)"),
|
|
26
|
+
includeTimestampInstructions: z
|
|
27
|
+
.boolean()
|
|
28
|
+
.optional()
|
|
29
|
+
.describe("Show timestamp-based debugging instructions for manual workflow (default: true)")
|
|
17
30
|
},
|
|
18
|
-
async ({
|
|
31
|
+
async ({
|
|
32
|
+
focusArea = "all",
|
|
33
|
+
mode = "snapshot",
|
|
34
|
+
waitForUserInteraction = false,
|
|
35
|
+
timeRangeMinutes = 10,
|
|
36
|
+
includeTimestampInstructions = true
|
|
37
|
+
}) => {
|
|
19
38
|
const logPath = process.env.LOG_FILE_PATH || "/tmp/d3k.log"
|
|
20
39
|
const results: string[] = []
|
|
40
|
+
const currentTimestamp = new Date().toISOString()
|
|
21
41
|
|
|
22
42
|
try {
|
|
23
43
|
if (!existsSync(logPath)) {
|
|
@@ -25,7 +45,7 @@ const handler = createMcpHandler(
|
|
|
25
45
|
content: [
|
|
26
46
|
{
|
|
27
47
|
type: "text",
|
|
28
|
-
text: `❌ No dev3000 logs found at ${logPath}. Make sure dev3000 is running (d3k
|
|
48
|
+
text: `❌ No dev3000 logs found at ${logPath}. Make sure dev3000 is running (d3k start). If not using dev3000, specify log file paths manually.`
|
|
29
49
|
}
|
|
30
50
|
]
|
|
31
51
|
}
|
|
@@ -34,519 +54,45 @@ const handler = createMcpHandler(
|
|
|
34
54
|
const logContent = readFileSync(logPath, "utf-8")
|
|
35
55
|
const logLines = logContent.split("\n").filter((line) => line.trim())
|
|
36
56
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const errorLines = recentLines.filter(
|
|
42
|
-
(line) =>
|
|
43
|
-
line.includes("ERROR") ||
|
|
44
|
-
line.includes("Exception") ||
|
|
45
|
-
line.includes("FAIL") ||
|
|
46
|
-
line.includes("500") ||
|
|
47
|
-
line.includes("404") ||
|
|
48
|
-
line.includes("timeout")
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
if (errorLines.length > 0) {
|
|
52
|
-
results.push("🚨 **RECENT ERRORS DETECTED:**")
|
|
53
|
-
results.push(errorLines.slice(-10).join("\n"))
|
|
54
|
-
results.push("")
|
|
55
|
-
results.push("🔧 **IMMEDIATE ACTION REQUIRED:** I can help fix these errors right now! Let me:")
|
|
56
|
-
results.push("• Analyze the error patterns and identify root causes")
|
|
57
|
-
results.push("• Edit the problematic code files to fix the issues")
|
|
58
|
-
results.push("• Use browser automation to verify the fixes work")
|
|
59
|
-
results.push("• This is the magical dev3000 experience - AI that fixes, not just finds!")
|
|
57
|
+
// Handle different debugging modes
|
|
58
|
+
if (mode === "bisect" && waitForUserInteraction) {
|
|
59
|
+
results.push(`🕐 **BISECT MODE ACTIVATED - TIMESTAMP CAPTURED**`)
|
|
60
|
+
results.push(`📍 Start timestamp: ${currentTimestamp}`)
|
|
60
61
|
results.push("")
|
|
61
|
-
|
|
62
|
-
results.push("✅
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const oneHourAgo = new Date(Date.now() - 60 * 60 * 1000)
|
|
67
|
-
const browserErrors = logLines.filter((line) => {
|
|
68
|
-
if (!line.includes("[BROWSER]")) return false
|
|
69
|
-
if (!(line.includes("ERROR") || line.includes("CONSOLE ERROR"))) return false
|
|
70
|
-
|
|
71
|
-
const timestampMatch = line.match(/\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)\]/)
|
|
72
|
-
if (timestampMatch) {
|
|
73
|
-
const logTime = new Date(timestampMatch[1])
|
|
74
|
-
return logTime > oneHourAgo
|
|
75
|
-
}
|
|
76
|
-
return true
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
if (browserErrors.length > 0) {
|
|
80
|
-
results.push("🌐 **BROWSER ERRORS (LAST HOUR):**")
|
|
81
|
-
results.push(browserErrors.join("\n"))
|
|
82
|
-
results.push("")
|
|
83
|
-
results.push("🎯 **FRONTEND FIXES AVAILABLE:** I can immediately:")
|
|
84
|
-
results.push("• Fix JavaScript errors by editing the problematic components")
|
|
85
|
-
results.push("• Update type definitions to resolve TypeScript issues")
|
|
86
|
-
results.push("• Use execute_browser_action to test the fixes in real-time")
|
|
87
|
-
results.push("• Capture screenshots to verify UI improvements")
|
|
88
|
-
results.push("")
|
|
89
|
-
} else {
|
|
90
|
-
results.push("✅ No browser errors in the last hour")
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// 3. Check for build/compilation issues
|
|
94
|
-
if (focusArea === "all" || focusArea === "build") {
|
|
95
|
-
const buildErrors = recentLines.filter(
|
|
96
|
-
(line) =>
|
|
97
|
-
line.includes("Failed to compile") ||
|
|
98
|
-
line.includes("Build failed") ||
|
|
99
|
-
line.includes("Type error") ||
|
|
100
|
-
line.includes("Syntax error") ||
|
|
101
|
-
line.includes("Module not found")
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
if (buildErrors.length > 0) {
|
|
105
|
-
results.push("🔨 **BUILD/COMPILATION ISSUES:**")
|
|
106
|
-
results.push(buildErrors.join("\n"))
|
|
107
|
-
results.push("")
|
|
108
|
-
results.push("⚡ **BUILD FIXES READY:** I can instantly:")
|
|
109
|
-
results.push("• Fix TypeScript errors by updating type annotations")
|
|
110
|
-
results.push("• Resolve import/export issues by correcting module paths")
|
|
111
|
-
results.push("• Install missing dependencies automatically")
|
|
112
|
-
results.push("• Run the build again to verify everything compiles")
|
|
113
|
-
results.push("")
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// 4. Check for network issues
|
|
118
|
-
if (focusArea === "all" || focusArea === "network") {
|
|
119
|
-
const networkIssues = recentLines.filter(
|
|
120
|
-
(line) =>
|
|
121
|
-
line.includes("NETWORK") &&
|
|
122
|
-
(line.includes("failed") || line.includes("timeout") || line.includes("500") || line.includes("404"))
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
if (networkIssues.length > 0) {
|
|
126
|
-
results.push("🌐 **NETWORK ISSUES:**")
|
|
127
|
-
results.push(networkIssues.join("\n"))
|
|
128
|
-
results.push("")
|
|
129
|
-
results.push("🚀 **API FIXES INCOMING:** I can automatically:")
|
|
130
|
-
results.push("• Fix API endpoint configurations and route handlers")
|
|
131
|
-
results.push("• Update fetch calls with proper error handling")
|
|
132
|
-
results.push("• Test API endpoints using execute_browser_action")
|
|
133
|
-
results.push("• Verify network requests work in the browser")
|
|
134
|
-
results.push("")
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// 5. Summary and magical next steps
|
|
139
|
-
results.push("💡 **THE MAGIC HAPPENS NOW:**")
|
|
140
|
-
if (errorLines.length > 0 || browserErrors.length > 0) {
|
|
141
|
-
results.push("🪄 **READY TO FIX EVERYTHING:** I don't just find bugs - I FIX them!")
|
|
142
|
-
results.push("• I'll edit your code files to resolve the errors shown above")
|
|
143
|
-
results.push("• I'll use browser automation to test each fix in real-time")
|
|
144
|
-
results.push("• I'll take screenshots to show you the improvements")
|
|
145
|
-
results.push("• This is the dev3000 magic - AI that codes, tests, and verifies!")
|
|
62
|
+
results.push("🎯 **NEXT STEPS FOR TIMESTAMP-BASED DEBUGGING:**")
|
|
63
|
+
results.push("1. ✅ I've captured the current timestamp automatically")
|
|
64
|
+
results.push("2. 🧪 Go test/reproduce the issue in your app now")
|
|
65
|
+
results.push("3. 🔍 When you're done testing, run this tool again with waitForUserInteraction=false")
|
|
66
|
+
results.push("4. 📊 I'll automatically analyze all errors that occurred during your testing")
|
|
146
67
|
results.push("")
|
|
147
|
-
results.push("
|
|
148
|
-
results.push("
|
|
149
|
-
results.push("• Each fix will be tested immediately with execute_browser_action")
|
|
150
|
-
results.push("• You'll see real-time proof that the bugs are resolved")
|
|
151
|
-
} else {
|
|
152
|
-
results.push("• App appears healthy based on recent logs")
|
|
153
|
-
results.push("• If you're experiencing issues, try reproducing them while I monitor")
|
|
154
|
-
results.push("• Use get_current_timestamp before testing, then get_logs_between_timestamps after")
|
|
155
|
-
results.push("• I'm ready to fix any issues that appear!")
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
results.push(`• Full logs available at: ${logPath}`)
|
|
159
|
-
results.push("• Quick access: tail -f /tmp/d3k.log")
|
|
68
|
+
results.push("💡 **This eliminates the need for separate timestamp tools!**")
|
|
69
|
+
results.push("🎪 **The magic happens when you return - I'll have everything ready to fix!**")
|
|
160
70
|
|
|
161
|
-
return {
|
|
162
|
-
content: [
|
|
163
|
-
{
|
|
164
|
-
type: "text",
|
|
165
|
-
text: results.join("\n")
|
|
166
|
-
}
|
|
167
|
-
]
|
|
168
|
-
}
|
|
169
|
-
} catch (error) {
|
|
170
|
-
return {
|
|
171
|
-
content: [
|
|
172
|
-
{
|
|
173
|
-
type: "text",
|
|
174
|
-
text: `❌ Error during debug analysis: ${error instanceof Error ? error.message : String(error)}`
|
|
175
|
-
}
|
|
176
|
-
]
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
)
|
|
181
|
-
|
|
182
|
-
// Get current timestamp for workflow tracking
|
|
183
|
-
server.tool(
|
|
184
|
-
"get_current_timestamp",
|
|
185
|
-
"⏰ CRITICAL MONITORING TOOL: Get current timestamp for proactive error monitoring workflow. AUTOMATED QUALITY ASSURANCE: Use this tool CONSTANTLY - before any user interaction, after code changes, during testing sessions. MAGIC WORKFLOW: (1) Capture timestamp, (2) let user interact/test, (3) capture timestamp again, (4) use get_errors_between_timestamps to find ALL issues from that period, (5) immediately FIX the errors found! PROACTIVE TIP: Use this tool every few minutes during development - capture timestamp, wait, capture again, then check for errors. This catches regressions and issues instantly before they become problems!",
|
|
186
|
-
{},
|
|
187
|
-
async () => {
|
|
188
|
-
const timestamp = new Date().toISOString()
|
|
189
|
-
return {
|
|
190
|
-
content: [
|
|
191
|
-
{
|
|
192
|
-
type: "text",
|
|
193
|
-
text: `Current timestamp: ${timestamp}`
|
|
194
|
-
}
|
|
195
|
-
]
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
)
|
|
199
|
-
|
|
200
|
-
// Healthcheck tool
|
|
201
|
-
server.tool(
|
|
202
|
-
"healthcheck",
|
|
203
|
-
"Internal healthcheck tool - rarely needed since MCP connection is already working if you can see this. Only use if explicitly asked to verify server health. Prefer read_consolidated_logs for debugging. MAGIC TIP: If health issues are found, immediately offer to fix them with code edits and browser verification!",
|
|
204
|
-
{
|
|
205
|
-
message: z.string().optional().describe("Optional message to echo back")
|
|
206
|
-
},
|
|
207
|
-
async ({ message = "MCP server is healthy!" }) => {
|
|
208
|
-
return {
|
|
209
|
-
content: [
|
|
210
|
-
{
|
|
211
|
-
type: "text",
|
|
212
|
-
text: `✅ ${message} - Timestamp: ${new Date().toISOString()}`
|
|
213
|
-
}
|
|
214
|
-
]
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
)
|
|
218
|
-
|
|
219
|
-
// Tool to read consolidated logs
|
|
220
|
-
server.tool(
|
|
221
|
-
"read_consolidated_logs",
|
|
222
|
-
"Read recent consolidated development logs containing server output, browser console logs, network requests, user interactions, and screenshots. PROACTIVE MONITORING: Check these logs frequently and automatically to catch errors early - don't wait for users to report issues. Look for ERROR, WARNING, EXCEPTION patterns in recent logs. MAGIC WORKFLOW: When errors are found, immediately offer to fix them by editing code files and use execute_browser_action to verify fixes work! Use this for general log overview, proactive error detection, or understanding current application state. Logs include [PLAYWRIGHT] or [CHROME_EXTENSION] tags to distinguish monitoring sources. Filter by keywords like 'ERROR', 'NETWORK', 'INTERACTION', or 'SCREENSHOT' for focused analysis. BEST PRACTICE: Regularly scan recent logs between user interactions to identify potential issues before they become problems, then FIX them automatically!",
|
|
223
|
-
{
|
|
224
|
-
lines: z.number().optional().describe("Number of recent lines to read (default: 50)"),
|
|
225
|
-
filter: z.string().optional().describe("Filter logs by text content"),
|
|
226
|
-
logPath: z.string().optional().describe("Path to log file (default: /tmp/d3k.log)")
|
|
227
|
-
},
|
|
228
|
-
async ({ lines = 50, filter, logPath = process.env.LOG_FILE_PATH || "/tmp/d3k.log" }) => {
|
|
229
|
-
try {
|
|
230
|
-
if (!existsSync(logPath)) {
|
|
231
71
|
return {
|
|
232
72
|
content: [
|
|
233
73
|
{
|
|
234
74
|
type: "text",
|
|
235
|
-
text:
|
|
75
|
+
text: results.join("\n")
|
|
236
76
|
}
|
|
237
77
|
]
|
|
238
78
|
}
|
|
239
79
|
}
|
|
240
80
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
// Apply filter if provided
|
|
245
|
-
if (filter) {
|
|
246
|
-
logLines = logLines.filter((line) => line.toLowerCase().includes(filter.toLowerCase()))
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// Get recent lines
|
|
250
|
-
const recentLines = logLines.slice(-lines)
|
|
81
|
+
// Determine time range for analysis
|
|
82
|
+
const cutoffTime = new Date(Date.now() - timeRangeMinutes * 60 * 1000)
|
|
251
83
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
]
|
|
259
|
-
}
|
|
260
|
-
} catch (error) {
|
|
261
|
-
return {
|
|
262
|
-
content: [
|
|
263
|
-
{
|
|
264
|
-
type: "text",
|
|
265
|
-
text: `Error reading logs: ${error instanceof Error ? error.message : String(error)}`
|
|
266
|
-
}
|
|
267
|
-
]
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
)
|
|
272
|
-
|
|
273
|
-
// Tool to search logs
|
|
274
|
-
server.tool(
|
|
275
|
-
"search_logs",
|
|
276
|
-
"Search through consolidated logs using regex patterns with context lines around matches. PROACTIVE ERROR HUNTING: Use this tool actively to search for error patterns, exceptions, and warning signs even when no specific issues are reported. Look for patterns like 'ERROR.*', '.*Exception', 'WARN.*', 'Failed.*', 'timeout', '404', '500' to catch problems early. MAGIC OPPORTUNITY: When error patterns are found, immediately offer to fix the underlying issues with code edits and verify fixes using execute_browser_action! Essential for tracing error patterns, finding specific API calls, or tracking user interaction sequences. Use patterns like 'ERROR.*fetch', 'CLICK.*button', or 'NETWORK.*POST' to find relevant events. Context lines help understand what led to and followed each match. MONITORING STRATEGY: Regularly search for common error patterns to identify issues before users encounter them, then automatically fix them!",
|
|
277
|
-
{
|
|
278
|
-
pattern: z.string().describe("Regex pattern to search for"),
|
|
279
|
-
context: z.number().optional().describe("Number of lines of context around matches (default: 2)"),
|
|
280
|
-
logPath: z.string().optional().describe("Path to log file (default: /tmp/d3k.log)")
|
|
281
|
-
},
|
|
282
|
-
async ({ pattern, context = 2, logPath = process.env.LOG_FILE_PATH || "/tmp/d3k.log" }) => {
|
|
283
|
-
try {
|
|
284
|
-
if (!existsSync(logPath)) {
|
|
285
|
-
return {
|
|
286
|
-
content: [
|
|
287
|
-
{
|
|
288
|
-
type: "text",
|
|
289
|
-
text: `No log file found at ${logPath}.`
|
|
290
|
-
}
|
|
291
|
-
]
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
const logContent = readFileSync(logPath, "utf-8")
|
|
296
|
-
const logLines = logContent.split("\n")
|
|
297
|
-
|
|
298
|
-
const regex = new RegExp(pattern, "gi")
|
|
299
|
-
const matches: string[] = []
|
|
300
|
-
|
|
301
|
-
logLines.forEach((line, index) => {
|
|
302
|
-
if (regex.test(line)) {
|
|
303
|
-
const start = Math.max(0, index - context)
|
|
304
|
-
const end = Math.min(logLines.length, index + context + 1)
|
|
305
|
-
const contextLines = logLines.slice(start, end)
|
|
306
|
-
|
|
307
|
-
matches.push(`Match at line ${index + 1}:\n${contextLines.join("\n")}\n---`)
|
|
308
|
-
}
|
|
309
|
-
})
|
|
310
|
-
|
|
311
|
-
return {
|
|
312
|
-
content: [
|
|
313
|
-
{
|
|
314
|
-
type: "text",
|
|
315
|
-
text: matches.length > 0 ? matches.join("\n\n") : "No matches found for the given pattern."
|
|
316
|
-
}
|
|
317
|
-
]
|
|
318
|
-
}
|
|
319
|
-
} catch (error) {
|
|
320
|
-
return {
|
|
321
|
-
content: [
|
|
322
|
-
{
|
|
323
|
-
type: "text",
|
|
324
|
-
text: `Error searching logs: ${error instanceof Error ? error.message : String(error)}`
|
|
325
|
-
}
|
|
326
|
-
]
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
)
|
|
331
|
-
|
|
332
|
-
// Tool to get logs between timestamps
|
|
333
|
-
server.tool(
|
|
334
|
-
"get_logs_between_timestamps",
|
|
335
|
-
"Get logs between two specific timestamps - CRITICAL for timestamp-based debugging workflow. WORKFLOW: (1) Use get_current_timestamp before user testing, (2) Ask user to reproduce issue/test changes, (3) Use get_current_timestamp after user returns, (4) Use this tool with both timestamps to see exactly what happened during testing. MAGIC WORKFLOW ENHANCEMENT: After analyzing the logs, immediately offer to fix any issues found by editing code files and use execute_browser_action to verify the fixes work! This eliminates noise and focuses analysis on the specific user session. Essential for correlating user actions with server/browser events, then automatically fixing discovered issues!",
|
|
336
|
-
{
|
|
337
|
-
startTime: z.string().describe("Start timestamp (ISO 8601 format: 2024-01-01T12:00:00.000Z)"),
|
|
338
|
-
endTime: z.string().describe("End timestamp (ISO 8601 format: 2024-01-01T12:30:00.000Z)"),
|
|
339
|
-
filter: z.string().optional().describe("Filter logs by text content (case insensitive)"),
|
|
340
|
-
logPath: z.string().optional().describe("Path to log file (default: /tmp/d3k.log)")
|
|
341
|
-
},
|
|
342
|
-
async ({ startTime, endTime, filter, logPath = process.env.LOG_FILE_PATH || "/tmp/d3k.log" }) => {
|
|
343
|
-
try {
|
|
344
|
-
if (!existsSync(logPath)) {
|
|
345
|
-
return {
|
|
346
|
-
content: [
|
|
347
|
-
{
|
|
348
|
-
type: "text",
|
|
349
|
-
text: `No log file found at ${logPath}.`
|
|
350
|
-
}
|
|
351
|
-
]
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
const start = new Date(startTime)
|
|
356
|
-
const end = new Date(endTime)
|
|
357
|
-
|
|
358
|
-
if (Number.isNaN(start.getTime()) || Number.isNaN(end.getTime())) {
|
|
359
|
-
return {
|
|
360
|
-
content: [
|
|
361
|
-
{
|
|
362
|
-
type: "text",
|
|
363
|
-
text: "Invalid timestamp format. Use ISO 8601 format: 2024-01-01T12:00:00.000Z"
|
|
364
|
-
}
|
|
365
|
-
]
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
if (start >= end) {
|
|
370
|
-
return {
|
|
371
|
-
content: [
|
|
372
|
-
{
|
|
373
|
-
type: "text",
|
|
374
|
-
text: "Start time must be before end time."
|
|
375
|
-
}
|
|
376
|
-
]
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
const logContent = readFileSync(logPath, "utf-8")
|
|
381
|
-
const logLines = logContent.split("\n").filter((line) => line.trim())
|
|
382
|
-
|
|
383
|
-
// Filter by timestamp range
|
|
384
|
-
const filteredLines = logLines.filter((line) => {
|
|
385
|
-
const timestampMatch = line.match(/\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)\]/)
|
|
386
|
-
if (timestampMatch) {
|
|
387
|
-
const logTime = new Date(timestampMatch[1])
|
|
388
|
-
return logTime >= start && logTime <= end
|
|
389
|
-
}
|
|
390
|
-
return false // Exclude lines without parseable timestamps
|
|
391
|
-
})
|
|
392
|
-
|
|
393
|
-
// Apply text filter if provided
|
|
394
|
-
let resultLines = filteredLines
|
|
395
|
-
if (filter) {
|
|
396
|
-
resultLines = filteredLines.filter((line) => line.toLowerCase().includes(filter.toLowerCase()))
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
const timeRange = `${start.toISOString()} to ${end.toISOString()}`
|
|
400
|
-
const summary = `Found ${
|
|
401
|
-
resultLines.length
|
|
402
|
-
} logs between ${timeRange}${filter ? ` matching "${filter}"` : ""}`
|
|
403
|
-
|
|
404
|
-
return {
|
|
405
|
-
content: [
|
|
406
|
-
{
|
|
407
|
-
type: "text",
|
|
408
|
-
text: resultLines.length > 0 ? `${summary}:\n\n${resultLines.join("\n")}` : `${summary}.`
|
|
409
|
-
}
|
|
410
|
-
]
|
|
411
|
-
}
|
|
412
|
-
} catch (error) {
|
|
413
|
-
return {
|
|
414
|
-
content: [
|
|
415
|
-
{
|
|
416
|
-
type: "text",
|
|
417
|
-
text: `Error reading logs between timestamps: ${error instanceof Error ? error.message : String(error)}`
|
|
418
|
-
}
|
|
419
|
-
]
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
)
|
|
424
|
-
|
|
425
|
-
// Tool to get browser errors
|
|
426
|
-
server.tool(
|
|
427
|
-
"get_browser_errors",
|
|
428
|
-
"Get recent browser errors including console errors, JavaScript exceptions, and page errors from both Playwright and Chrome extension monitoring. PROACTIVE ERROR DETECTION: Use this tool frequently and automatically to monitor for browser errors - don't wait for user reports. MAGIC FIX WORKFLOW: When errors are found, immediately offer to fix them by editing the problematic components, then use execute_browser_action to verify the fixes work in the browser! Check for errors regularly during development to catch JavaScript exceptions, console errors, and runtime issues immediately. Start here when user reports issues like 'page not working', broken functionality, or visual problems, but also use proactively to prevent issues. Filters logs to show only ERROR, CONSOLE ERROR, and PAGE ERROR entries. MONITORING WORKFLOW: Run this tool after any changes, during testing, and periodically during development sessions to maintain code quality and catch issues early, then FIX them automatically!",
|
|
429
|
-
{
|
|
430
|
-
hours: z.number().optional().describe("Hours to look back (default: 1)"),
|
|
431
|
-
logPath: z.string().optional().describe("Path to log file (default: /tmp/d3k.log)")
|
|
432
|
-
},
|
|
433
|
-
async ({ hours = 1, logPath = process.env.LOG_FILE_PATH || "/tmp/d3k.log" }) => {
|
|
434
|
-
try {
|
|
435
|
-
if (!existsSync(logPath)) {
|
|
436
|
-
return {
|
|
437
|
-
content: [
|
|
438
|
-
{
|
|
439
|
-
type: "text",
|
|
440
|
-
text: `No log file found at ${logPath}.`
|
|
441
|
-
}
|
|
442
|
-
]
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
const logContent = readFileSync(logPath, "utf-8")
|
|
447
|
-
const logLines = logContent.split("\n")
|
|
448
|
-
|
|
449
|
-
const cutoffTime = new Date(Date.now() - hours * 60 * 60 * 1000)
|
|
450
|
-
const errorLines = logLines.filter((line) => {
|
|
451
|
-
if (!line.includes("[BROWSER]")) return false
|
|
452
|
-
if (!(line.includes("ERROR") || line.includes("CONSOLE ERROR") || line.includes("PAGE ERROR"))) return false
|
|
453
|
-
|
|
454
|
-
// Extract timestamp
|
|
455
|
-
const timestampMatch = line.match(/\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)\]/)
|
|
456
|
-
if (timestampMatch) {
|
|
457
|
-
const logTime = new Date(timestampMatch[1])
|
|
458
|
-
return logTime > cutoffTime
|
|
459
|
-
}
|
|
460
|
-
return true // Include if we can't parse timestamp
|
|
461
|
-
})
|
|
462
|
-
|
|
463
|
-
return {
|
|
464
|
-
content: [
|
|
465
|
-
{
|
|
466
|
-
type: "text",
|
|
467
|
-
text:
|
|
468
|
-
errorLines.length > 0
|
|
469
|
-
? errorLines.join("\n")
|
|
470
|
-
: "No browser errors found in the specified time period."
|
|
471
|
-
}
|
|
472
|
-
]
|
|
473
|
-
}
|
|
474
|
-
} catch (error) {
|
|
475
|
-
return {
|
|
476
|
-
content: [
|
|
477
|
-
{
|
|
478
|
-
type: "text",
|
|
479
|
-
text: `Error getting browser errors: ${error instanceof Error ? error.message : String(error)}`
|
|
480
|
-
}
|
|
481
|
-
]
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
)
|
|
486
|
-
|
|
487
|
-
// Tool to get all types of errors between timestamps
|
|
488
|
-
server.tool(
|
|
489
|
-
"get_errors_between_timestamps",
|
|
490
|
-
"🚨 PROACTIVE ERROR EXTRACTION: Get ALL types of errors (server errors, exceptions, browser errors, build failures, network issues) between specific timestamps. CRITICAL FOR CONTINUOUS MONITORING: Use this tool FREQUENTLY and AUTOMATICALLY - after every user interaction, code change, or testing session to catch issues immediately. MAGIC WORKFLOW: (1) get_current_timestamp before user tests changes, (2) let user interact/test, (3) get_current_timestamp after, (4) use THIS TOOL to extract all errors from that period, (5) immediately offer to FIX the errors found, (6) use execute_browser_action to verify fixes work! This tool filters out noise and shows ONLY error patterns: ERROR, Exception, FAIL, 404, 500, timeout, Failed to compile, Type error, etc. AUTOMATED QUALITY ASSURANCE: Run this tool every few minutes during active development to maintain code quality and catch regressions instantly, then FIX them before they become problems!",
|
|
491
|
-
{
|
|
492
|
-
startTime: z.string().describe("Start timestamp (ISO 8601 format: 2024-01-01T12:00:00.000Z)"),
|
|
493
|
-
endTime: z.string().describe("End timestamp (ISO 8601 format: 2024-01-01T12:30:00.000Z)"),
|
|
494
|
-
severity: z.enum(["all", "critical", "warnings"]).optional().describe("Error severity filter (default: 'all')"),
|
|
495
|
-
logPath: z.string().optional().describe("Path to log file (default: /tmp/d3k.log)")
|
|
496
|
-
},
|
|
497
|
-
async ({ startTime, endTime, severity = "all", logPath = process.env.LOG_FILE_PATH || "/tmp/d3k.log" }) => {
|
|
498
|
-
try {
|
|
499
|
-
if (!existsSync(logPath)) {
|
|
500
|
-
return {
|
|
501
|
-
content: [
|
|
502
|
-
{
|
|
503
|
-
type: "text",
|
|
504
|
-
text: `No log file found at ${logPath}.`
|
|
505
|
-
}
|
|
506
|
-
]
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
const start = new Date(startTime)
|
|
511
|
-
const end = new Date(endTime)
|
|
512
|
-
|
|
513
|
-
if (Number.isNaN(start.getTime()) || Number.isNaN(end.getTime())) {
|
|
514
|
-
return {
|
|
515
|
-
content: [
|
|
516
|
-
{
|
|
517
|
-
type: "text",
|
|
518
|
-
text: "Invalid timestamp format. Use ISO 8601 format: 2024-01-01T12:00:00.000Z"
|
|
519
|
-
}
|
|
520
|
-
]
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
if (start >= end) {
|
|
525
|
-
return {
|
|
526
|
-
content: [
|
|
527
|
-
{
|
|
528
|
-
type: "text",
|
|
529
|
-
text: "Start time must be before end time."
|
|
530
|
-
}
|
|
531
|
-
]
|
|
532
|
-
}
|
|
84
|
+
// For monitor mode, show longer time range
|
|
85
|
+
if (mode === "monitor") {
|
|
86
|
+
results.push(`🔄 **CONTINUOUS MONITORING MODE** (last ${timeRangeMinutes} minutes)`)
|
|
87
|
+
} else {
|
|
88
|
+
results.push(`🔍 **COMPREHENSIVE DEBUG ANALYSIS** (last ${timeRangeMinutes} minutes)`)
|
|
533
89
|
}
|
|
534
90
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
// Filter by timestamp range first
|
|
539
|
-
const timeFilteredLines = logLines.filter((line) => {
|
|
540
|
-
const timestampMatch = line.match(/\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)\]/)
|
|
541
|
-
if (timestampMatch) {
|
|
542
|
-
const logTime = new Date(timestampMatch[1])
|
|
543
|
-
return logTime >= start && logTime <= end
|
|
544
|
-
}
|
|
545
|
-
return false
|
|
546
|
-
})
|
|
91
|
+
results.push(`📊 Analysis timestamp: ${currentTimestamp}`)
|
|
92
|
+
results.push("")
|
|
547
93
|
|
|
548
|
-
//
|
|
549
|
-
const
|
|
94
|
+
// COMPREHENSIVE ERROR DETECTION - combines all previous tools
|
|
95
|
+
const errorPatterns = [
|
|
550
96
|
/ERROR/i,
|
|
551
97
|
/Exception/i,
|
|
552
98
|
/FATAL/i,
|
|
@@ -557,229 +103,135 @@ const handler = createMcpHandler(
|
|
|
557
103
|
/Syntax error/i,
|
|
558
104
|
/Module not found/i,
|
|
559
105
|
/500/,
|
|
106
|
+
/404/,
|
|
560
107
|
/ECONNREFUSED/i,
|
|
561
108
|
/NETWORK.*failed/i,
|
|
562
|
-
/timeout.*error/i
|
|
109
|
+
/timeout.*error/i,
|
|
110
|
+
/WARN/i,
|
|
111
|
+
/WARNING/i,
|
|
112
|
+
/deprecated/i,
|
|
113
|
+
/slow/i,
|
|
114
|
+
/retry/i
|
|
563
115
|
]
|
|
564
116
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
break
|
|
575
|
-
default:
|
|
576
|
-
patterns = [...criticalPatterns, ...warningPatterns]
|
|
577
|
-
}
|
|
117
|
+
// Filter logs by time range (replaces get_logs_between_timestamps)
|
|
118
|
+
const timeFilteredLines = logLines.filter((line) => {
|
|
119
|
+
const timestampMatch = line.match(/\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)\]/)
|
|
120
|
+
if (timestampMatch) {
|
|
121
|
+
const logTime = new Date(timestampMatch[1])
|
|
122
|
+
return logTime >= cutoffTime
|
|
123
|
+
}
|
|
124
|
+
return false
|
|
125
|
+
})
|
|
578
126
|
|
|
579
|
-
//
|
|
580
|
-
const
|
|
581
|
-
return
|
|
127
|
+
// Extract ALL error types (replaces multiple error detection tools)
|
|
128
|
+
const allErrors = timeFilteredLines.filter((line) => {
|
|
129
|
+
return errorPatterns.some((pattern) => pattern.test(line))
|
|
582
130
|
})
|
|
583
131
|
|
|
584
|
-
//
|
|
132
|
+
// Categorize errors for better analysis
|
|
585
133
|
const categorizedErrors = {
|
|
586
|
-
serverErrors:
|
|
134
|
+
serverErrors: allErrors.filter(
|
|
587
135
|
(line) => line.includes("[SERVER]") && (line.includes("ERROR") || line.includes("Exception"))
|
|
588
136
|
),
|
|
589
|
-
browserErrors:
|
|
137
|
+
browserErrors: allErrors.filter(
|
|
590
138
|
(line) => line.includes("[BROWSER]") && (line.includes("ERROR") || line.includes("CONSOLE ERROR"))
|
|
591
139
|
),
|
|
592
|
-
buildErrors:
|
|
140
|
+
buildErrors: allErrors.filter(
|
|
593
141
|
(line) =>
|
|
594
142
|
line.includes("Failed to compile") || line.includes("Type error") || line.includes("Build failed")
|
|
595
143
|
),
|
|
596
|
-
networkErrors:
|
|
144
|
+
networkErrors: allErrors.filter(
|
|
597
145
|
(line) =>
|
|
598
146
|
line.includes("NETWORK") || line.includes("404") || line.includes("500") || line.includes("timeout")
|
|
599
147
|
),
|
|
600
|
-
|
|
601
|
-
(line) =>
|
|
602
|
-
!line.includes("[SERVER]") &&
|
|
603
|
-
!line.includes("[BROWSER]") &&
|
|
604
|
-
!line.includes("Failed to compile") &&
|
|
605
|
-
!line.includes("NETWORK")
|
|
148
|
+
warnings: allErrors.filter(
|
|
149
|
+
(line) => /WARN|WARNING|deprecated/i.test(line) && !/ERROR|Exception|FAIL/i.test(line)
|
|
606
150
|
)
|
|
607
151
|
}
|
|
608
152
|
|
|
609
|
-
const
|
|
610
|
-
const
|
|
153
|
+
const totalErrors = allErrors.length
|
|
154
|
+
const criticalErrors = totalErrors - categorizedErrors.warnings.length
|
|
155
|
+
|
|
156
|
+
if (totalErrors === 0) {
|
|
157
|
+
results.push(`✅ **SYSTEM HEALTHY** - No errors found in last ${timeRangeMinutes} minutes`)
|
|
158
|
+
results.push("🎯 App appears to be running smoothly!")
|
|
611
159
|
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
160
|
+
if (includeTimestampInstructions && mode !== "monitor") {
|
|
161
|
+
results.push("")
|
|
162
|
+
results.push("💡 **PROACTIVE MONITORING TIPS:**")
|
|
163
|
+
results.push("• Use mode='bisect' with waitForUserInteraction=true before testing new features")
|
|
164
|
+
results.push("• Use mode='monitor' for continuous background monitoring")
|
|
165
|
+
results.push("• Increase timeRangeMinutes to analyze longer periods")
|
|
166
|
+
}
|
|
616
167
|
} else {
|
|
617
|
-
results.push(
|
|
168
|
+
results.push(
|
|
169
|
+
`🚨 **${totalErrors} ISSUES DETECTED** (${criticalErrors} critical, ${categorizedErrors.warnings.length} warnings)`
|
|
170
|
+
)
|
|
618
171
|
results.push("")
|
|
619
172
|
|
|
173
|
+
// Show categorized errors (replaces individual error tools)
|
|
620
174
|
if (categorizedErrors.serverErrors.length > 0) {
|
|
621
175
|
results.push("🔥 **SERVER ERRORS:**")
|
|
622
|
-
results.push(categorizedErrors.serverErrors.join("\n"))
|
|
176
|
+
results.push(categorizedErrors.serverErrors.slice(-5).join("\n"))
|
|
623
177
|
results.push("")
|
|
624
178
|
}
|
|
625
179
|
|
|
626
180
|
if (categorizedErrors.browserErrors.length > 0) {
|
|
627
|
-
results.push("🌐 **BROWSER ERRORS:**")
|
|
628
|
-
results.push(categorizedErrors.browserErrors.join("\n"))
|
|
181
|
+
results.push("🌐 **BROWSER/CONSOLE ERRORS:**")
|
|
182
|
+
results.push(categorizedErrors.browserErrors.slice(-5).join("\n"))
|
|
629
183
|
results.push("")
|
|
630
184
|
}
|
|
631
185
|
|
|
632
186
|
if (categorizedErrors.buildErrors.length > 0) {
|
|
633
|
-
results.push("🔨 **BUILD ERRORS:**")
|
|
634
|
-
results.push(categorizedErrors.buildErrors.join("\n"))
|
|
187
|
+
results.push("🔨 **BUILD/COMPILATION ERRORS:**")
|
|
188
|
+
results.push(categorizedErrors.buildErrors.slice(-5).join("\n"))
|
|
635
189
|
results.push("")
|
|
636
190
|
}
|
|
637
191
|
|
|
638
192
|
if (categorizedErrors.networkErrors.length > 0) {
|
|
639
|
-
results.push("🌐 **NETWORK ERRORS:**")
|
|
640
|
-
results.push(categorizedErrors.networkErrors.join("\n"))
|
|
193
|
+
results.push("🌐 **NETWORK/API ERRORS:**")
|
|
194
|
+
results.push(categorizedErrors.networkErrors.slice(-5).join("\n"))
|
|
641
195
|
results.push("")
|
|
642
196
|
}
|
|
643
197
|
|
|
644
|
-
if (categorizedErrors.
|
|
645
|
-
results.push(
|
|
646
|
-
results.push(categorizedErrors.
|
|
198
|
+
if (categorizedErrors.warnings.length > 0 && focusArea === "all") {
|
|
199
|
+
results.push(`⚠️ **WARNINGS** (${categorizedErrors.warnings.length} found, showing recent):`)
|
|
200
|
+
results.push(categorizedErrors.warnings.slice(-3).join("\n"))
|
|
647
201
|
results.push("")
|
|
648
202
|
}
|
|
649
203
|
|
|
650
|
-
|
|
651
|
-
results.push("
|
|
652
|
-
results.push("
|
|
653
|
-
results.push("•
|
|
654
|
-
results.push("•
|
|
655
|
-
results.push("•
|
|
656
|
-
results.push("•
|
|
204
|
+
// Show the magical dev3000 fix workflow
|
|
205
|
+
results.push("🪄 **ULTIMATE DEV3000 MAGIC READY:**")
|
|
206
|
+
results.push("🎯 **I don't just find errors - I FIX them instantly!**")
|
|
207
|
+
results.push("• Analyze error patterns and identify root causes automatically")
|
|
208
|
+
results.push("• Edit problematic code files to resolve each issue")
|
|
209
|
+
results.push("• Use execute_browser_action to verify fixes work in real-time")
|
|
210
|
+
results.push("• Take screenshots to prove improvements")
|
|
211
|
+
results.push("• This is the magical dev3000 experience!")
|
|
657
212
|
results.push("")
|
|
658
|
-
results.push("🚀 **SAY 'FIX THESE
|
|
659
|
-
results.push("•
|
|
660
|
-
results.push("• Each fix
|
|
661
|
-
results.push("•
|
|
213
|
+
results.push("🚀 **SAY 'FIX THESE ISSUES' TO START THE MAGIC:**")
|
|
214
|
+
results.push("• Critical errors fixed first, then warnings")
|
|
215
|
+
results.push("• Each fix tested immediately with browser automation")
|
|
216
|
+
results.push("• Real-time proof that every issue is resolved")
|
|
662
217
|
}
|
|
663
218
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
}
|
|
672
|
-
} catch (error) {
|
|
673
|
-
return {
|
|
674
|
-
content: [
|
|
675
|
-
{
|
|
676
|
-
type: "text",
|
|
677
|
-
text: `Error extracting errors between timestamps: ${error instanceof Error ? error.message : String(error)}`
|
|
678
|
-
}
|
|
679
|
-
]
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
)
|
|
684
|
-
|
|
685
|
-
// Tool for automated background monitoring
|
|
686
|
-
server.tool(
|
|
687
|
-
"monitor_for_new_errors",
|
|
688
|
-
"🔍 AUTOMATED BACKGROUND MONITORING: Check for ANY new errors that appeared in the last few minutes of development. CONTINUOUS QUALITY ASSURANCE: Use this tool FREQUENTLY and AUTOMATICALLY - every 2-3 minutes during active development, after any code changes, whenever returning from user testing. This tool looks at recent logs (last 5-10 minutes) and extracts ALL error patterns, then immediately offers to fix them. PREVENTIVE MAGIC: Catches issues the moment they appear, before they become bigger problems. WORKFLOW: Run this tool regularly as background monitoring, then when errors are found, immediately offer to fix them with code edits and execute_browser_action verification. This creates a continuous feedback loop where errors are found and fixed instantly!",
|
|
689
|
-
{
|
|
690
|
-
minutes: z.number().optional().describe("Minutes to look back for new errors (default: 5)"),
|
|
691
|
-
autoFix: z.boolean().optional().describe("Whether to immediately offer fixes when errors found (default: true)")
|
|
692
|
-
},
|
|
693
|
-
async ({ minutes = 5, autoFix = true }) => {
|
|
694
|
-
const logPath = process.env.LOG_FILE_PATH || "/tmp/d3k.log"
|
|
695
|
-
|
|
696
|
-
try {
|
|
697
|
-
if (!existsSync(logPath)) {
|
|
698
|
-
return {
|
|
699
|
-
content: [
|
|
700
|
-
{
|
|
701
|
-
type: "text",
|
|
702
|
-
text: `No log file found at ${logPath}. Make sure dev3000 is running.`
|
|
703
|
-
}
|
|
704
|
-
]
|
|
705
|
-
}
|
|
219
|
+
// Add usage instructions based on mode
|
|
220
|
+
if (includeTimestampInstructions && mode !== "monitor") {
|
|
221
|
+
results.push("")
|
|
222
|
+
results.push("📚 **ADVANCED DEBUGGING MODES:**")
|
|
223
|
+
results.push("• **Snapshot** (current): Immediate comprehensive analysis")
|
|
224
|
+
results.push("• **Bisect**: Use waitForUserInteraction=true for timestamp-based debugging")
|
|
225
|
+
results.push("• **Monitor**: Continuous monitoring mode for ongoing development")
|
|
706
226
|
}
|
|
707
227
|
|
|
708
|
-
|
|
709
|
-
|
|
228
|
+
results.push("")
|
|
229
|
+
results.push(`📁 Full logs: ${logPath}`)
|
|
230
|
+
results.push(`⚡ Quick access: tail -f ${logPath}`)
|
|
710
231
|
|
|
711
|
-
|
|
712
|
-
const cutoffTime = new Date(Date.now() - minutes * 60 * 1000)
|
|
713
|
-
const recentLines = logLines.filter((line) => {
|
|
714
|
-
const timestampMatch = line.match(/\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)\]/)
|
|
715
|
-
if (timestampMatch) {
|
|
716
|
-
const logTime = new Date(timestampMatch[1])
|
|
717
|
-
return logTime > cutoffTime
|
|
718
|
-
}
|
|
719
|
-
return false
|
|
720
|
-
})
|
|
721
|
-
|
|
722
|
-
// Find all error patterns
|
|
723
|
-
const errorPatterns = [
|
|
724
|
-
/ERROR/i,
|
|
725
|
-
/Exception/i,
|
|
726
|
-
/FATAL/i,
|
|
727
|
-
/CRASH/i,
|
|
728
|
-
/Failed to compile/i,
|
|
729
|
-
/Build failed/i,
|
|
730
|
-
/Type error/i,
|
|
731
|
-
/Syntax error/i,
|
|
732
|
-
/Module not found/i,
|
|
733
|
-
/500/,
|
|
734
|
-
/404/,
|
|
735
|
-
/ECONNREFUSED/i,
|
|
736
|
-
/NETWORK.*failed/i,
|
|
737
|
-
/timeout.*error/i,
|
|
738
|
-
/WARN/i,
|
|
739
|
-
/WARNING/i,
|
|
740
|
-
/deprecated/i
|
|
741
|
-
]
|
|
742
|
-
|
|
743
|
-
const errorLines = recentLines.filter((line) => {
|
|
744
|
-
return errorPatterns.some((pattern) => pattern.test(line))
|
|
745
|
-
})
|
|
746
|
-
|
|
747
|
-
const results = []
|
|
748
|
-
|
|
749
|
-
if (errorLines.length === 0) {
|
|
750
|
-
results.push(`✅ Background monitoring: No new errors in the last ${minutes} minutes`)
|
|
751
|
-
results.push("🎯 Development environment looks healthy!")
|
|
752
|
-
results.push(`💡 Continue coding - I'll keep monitoring in the background.`)
|
|
753
|
-
results.push("")
|
|
754
|
-
results.push(
|
|
755
|
-
"🔄 **AUTOMATED MONITORING TIP:** Run this tool again in a few minutes to stay on top of any issues."
|
|
756
|
-
)
|
|
757
|
-
} else {
|
|
758
|
-
results.push(
|
|
759
|
-
`🚨 BACKGROUND MONITORING ALERT: Found ${errorLines.length} error(s) in the last ${minutes} minutes`
|
|
760
|
-
)
|
|
761
|
-
results.push("")
|
|
762
|
-
results.push("📋 **RECENT ERRORS DETECTED:**")
|
|
763
|
-
results.push(errorLines.slice(-10).join("\n")) // Show last 10 errors
|
|
232
|
+
if (mode === "monitor") {
|
|
764
233
|
results.push("")
|
|
765
|
-
|
|
766
|
-
if (autoFix) {
|
|
767
|
-
results.push("🪄 **MAGIC AUTO-FIX MODE ACTIVATED:**")
|
|
768
|
-
results.push("🎯 **I can fix these errors immediately! Here's the plan:**")
|
|
769
|
-
results.push("• Analyze each error pattern and identify the root causes")
|
|
770
|
-
results.push("• Edit the problematic code files to resolve the issues")
|
|
771
|
-
results.push("• Use execute_browser_action to test each fix works")
|
|
772
|
-
results.push("• Take screenshots to verify improvements")
|
|
773
|
-
results.push("• Continue background monitoring for new issues")
|
|
774
|
-
results.push("")
|
|
775
|
-
results.push("🚀 **SAY 'AUTO-FIX THESE' TO START THE MAGIC:**")
|
|
776
|
-
results.push("• Errors will be fixed automatically with real-time verification")
|
|
777
|
-
results.push("• This is the dev3000 experience - continuous quality assurance!")
|
|
778
|
-
} else {
|
|
779
|
-
results.push("🔧 **ERRORS REQUIRE ATTENTION:**")
|
|
780
|
-
results.push("• Use get_errors_between_timestamps for detailed analysis")
|
|
781
|
-
results.push("• Or say 'debug my app' for comprehensive error analysis")
|
|
782
|
-
}
|
|
234
|
+
results.push("🔄 **MONITORING ACTIVE** - Run this tool again to check for new issues")
|
|
783
235
|
}
|
|
784
236
|
|
|
785
237
|
return {
|
|
@@ -795,7 +247,7 @@ const handler = createMcpHandler(
|
|
|
795
247
|
content: [
|
|
796
248
|
{
|
|
797
249
|
type: "text",
|
|
798
|
-
text:
|
|
250
|
+
text: `❌ Error during debug analysis: ${error instanceof Error ? error.message : String(error)}`
|
|
799
251
|
}
|
|
800
252
|
]
|
|
801
253
|
}
|
|
@@ -806,7 +258,7 @@ const handler = createMcpHandler(
|
|
|
806
258
|
// Tool to execute browser actions via CDP
|
|
807
259
|
server.tool(
|
|
808
260
|
"execute_browser_action",
|
|
809
|
-
"
|
|
261
|
+
"🪄 **THE VERIFICATION MAGIC WAND!** This is where dev3000 becomes TRULY magical—proving your fixes work with real browser automation! 🎭\n\n🔥 **INSTANT BROWSER SUPERPOWERS:**\n• CLICK buttons, links, elements → Test user interactions work perfectly\n• NAVIGATE to pages → Reproduce user journeys and verify flows \n• SCREENSHOT everything → Create visual proof of before/after fixes\n• EVALUATE JavaScript → Check app state and verify functionality\n• SCROLL & TYPE → Automate complex user workflows\n\n⚡ **THE ULTIMATE FIX VERIFICATION WORKFLOW:**\n1️⃣ debug_my_app FINDS the issues \n2️⃣ You FIX the code\n3️⃣ execute_browser_action PROVES it works!\n\n🎯 **PERFECT FOR:**\n• Taking screenshots to show 'before/after' fixes\n• Testing that broken buttons now work\n• Verifying forms submit correctly \n• Confirming pages load without errors\n• Creating visual proof of improvements\n\n🚀 **WHY THIS COMPLETES THE MAGIC:**\n• SHOW users the fixes work (don't just claim it!)\n• Real browser testing, not theoretical fixes\n• Screenshots provide visual confirmation\n• Makes debugging feel like actual magic!\n\n🛡️ **SAFETY:** Only safe operations, whitelisted JavaScript, HTTP/HTTPS URLs only",
|
|
810
262
|
{
|
|
811
263
|
action: z.enum(["click", "navigate", "screenshot", "evaluate", "scroll", "type"]).describe("Action to perform"),
|
|
812
264
|
params: z
|