dev3000 0.0.49 → 0.0.51
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 +55 -6
- package/dist/cdp-monitor.d.ts.map +1 -1
- package/dist/cdp-monitor.js +54 -48
- package/dist/cdp-monitor.js.map +1 -1
- package/dist/cli.js +39 -33
- package/dist/cli.js.map +1 -1
- package/dist/dev-environment.d.ts +2 -0
- package/dist/dev-environment.d.ts.map +1 -1
- package/dist/dev-environment.js +212 -181
- package/dist/dev-environment.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/mcp-server/app/api/config/route.ts +7 -7
- package/mcp-server/app/api/logs/append/route.ts +59 -51
- package/mcp-server/app/api/logs/head/route.ts +22 -22
- package/mcp-server/app/api/logs/list/route.ts +39 -42
- package/mcp-server/app/api/logs/rotate/route.ts +28 -38
- package/mcp-server/app/api/logs/stream/route.ts +35 -35
- package/mcp-server/app/api/logs/tail/route.ts +22 -22
- package/mcp-server/app/api/mcp/[transport]/route.ts +189 -188
- package/mcp-server/app/api/replay/route.ts +217 -202
- package/mcp-server/app/layout.tsx +9 -8
- package/mcp-server/app/logs/LogsClient.test.ts +123 -99
- package/mcp-server/app/logs/LogsClient.tsx +724 -562
- package/mcp-server/app/logs/page.tsx +71 -72
- package/mcp-server/app/logs/utils.ts +99 -28
- package/mcp-server/app/page.tsx +10 -14
- package/mcp-server/app/replay/ReplayClient.tsx +120 -119
- package/mcp-server/app/replay/page.tsx +3 -3
- package/mcp-server/next.config.ts +2 -0
- package/mcp-server/package.json +5 -2
- package/mcp-server/pnpm-lock.yaml +37 -5
- package/mcp-server/tsconfig.json +4 -17
- package/package.json +16 -13
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { existsSync, readFileSync, watchFile } from "fs"
|
|
2
|
+
import type { NextRequest } from "next/server"
|
|
3
3
|
|
|
4
4
|
export async function GET(request: NextRequest) {
|
|
5
|
-
const { searchParams } = new URL(request.url)
|
|
6
|
-
const logPath = searchParams.get(
|
|
7
|
-
|
|
5
|
+
const { searchParams } = new URL(request.url)
|
|
6
|
+
const logPath = searchParams.get("logPath") || process.env.LOG_FILE_PATH || "./ai-dev-tools/consolidated.log"
|
|
7
|
+
|
|
8
8
|
if (!existsSync(logPath)) {
|
|
9
|
-
return new Response(
|
|
9
|
+
return new Response("Log file not found", { status: 404 })
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
const encoder = new TextEncoder()
|
|
13
|
-
let lastSize = 0
|
|
12
|
+
const encoder = new TextEncoder()
|
|
13
|
+
let lastSize = 0
|
|
14
14
|
|
|
15
15
|
const stream = new ReadableStream({
|
|
16
16
|
start(controller) {
|
|
17
17
|
// Send initial content
|
|
18
18
|
try {
|
|
19
|
-
const content = readFileSync(logPath,
|
|
20
|
-
const lines = content.split(
|
|
21
|
-
lastSize = content.length
|
|
22
|
-
|
|
19
|
+
const content = readFileSync(logPath, "utf-8")
|
|
20
|
+
const lines = content.split("\n").filter((line) => line.trim())
|
|
21
|
+
lastSize = content.length
|
|
22
|
+
|
|
23
23
|
// Send initial lines
|
|
24
|
-
controller.enqueue(encoder.encode(`data: ${JSON.stringify({ lines })}\n\n`))
|
|
25
|
-
} catch (
|
|
26
|
-
controller.enqueue(encoder.encode(`data: ${JSON.stringify({ error:
|
|
24
|
+
controller.enqueue(encoder.encode(`data: ${JSON.stringify({ lines })}\n\n`))
|
|
25
|
+
} catch (_error) {
|
|
26
|
+
controller.enqueue(encoder.encode(`data: ${JSON.stringify({ error: "Failed to read log" })}\n\n`))
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// Watch for file changes
|
|
30
30
|
const watcher = watchFile(logPath, { interval: 1000 }, () => {
|
|
31
31
|
try {
|
|
32
|
-
const content = readFileSync(logPath,
|
|
32
|
+
const content = readFileSync(logPath, "utf-8")
|
|
33
33
|
if (content.length > lastSize) {
|
|
34
|
-
const newContent = content.slice(lastSize)
|
|
35
|
-
const newLines = newContent.split(
|
|
34
|
+
const newContent = content.slice(lastSize)
|
|
35
|
+
const newLines = newContent.split("\n").filter((line) => line.trim())
|
|
36
36
|
if (newLines.length > 0) {
|
|
37
|
-
controller.enqueue(encoder.encode(`data: ${JSON.stringify({ newLines })}\n\n`))
|
|
37
|
+
controller.enqueue(encoder.encode(`data: ${JSON.stringify({ newLines })}\n\n`))
|
|
38
38
|
}
|
|
39
|
-
lastSize = content.length
|
|
39
|
+
lastSize = content.length
|
|
40
40
|
}
|
|
41
|
-
} catch (
|
|
42
|
-
controller.enqueue(encoder.encode(`data: ${JSON.stringify({ error:
|
|
41
|
+
} catch (_error) {
|
|
42
|
+
controller.enqueue(encoder.encode(`data: ${JSON.stringify({ error: "Failed to read log updates" })}\n\n`))
|
|
43
43
|
}
|
|
44
|
-
})
|
|
44
|
+
})
|
|
45
45
|
|
|
46
46
|
// Cleanup on close
|
|
47
|
-
request.signal.addEventListener(
|
|
48
|
-
watcher.unref()
|
|
49
|
-
controller.close()
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
})
|
|
47
|
+
request.signal.addEventListener("abort", () => {
|
|
48
|
+
watcher.unref()
|
|
49
|
+
controller.close()
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
53
|
|
|
54
54
|
return new Response(stream, {
|
|
55
55
|
headers: {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
}
|
|
56
|
+
"Content-Type": "text/event-stream",
|
|
57
|
+
"Cache-Control": "no-cache",
|
|
58
|
+
Connection: "keep-alive"
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { existsSync, readFileSync } from "fs"
|
|
2
|
+
import type { NextRequest } from "next/server"
|
|
3
|
+
import type { LogsApiError, LogsApiResponse } from "@/types"
|
|
4
4
|
|
|
5
5
|
export async function GET(request: NextRequest): Promise<Response> {
|
|
6
6
|
try {
|
|
7
|
-
const { searchParams } = new URL(request.url)
|
|
8
|
-
const lines = parseInt(searchParams.get(
|
|
9
|
-
const logPath = searchParams.get(
|
|
10
|
-
|
|
7
|
+
const { searchParams } = new URL(request.url)
|
|
8
|
+
const lines = parseInt(searchParams.get("lines") || "50", 10)
|
|
9
|
+
const logPath = searchParams.get("logPath") || process.env.LOG_FILE_PATH || "./ai-dev-tools/consolidated.log"
|
|
10
|
+
|
|
11
11
|
if (!existsSync(logPath)) {
|
|
12
|
-
const errorResponse: LogsApiError = { error:
|
|
13
|
-
return Response.json(errorResponse, { status: 404 })
|
|
12
|
+
const errorResponse: LogsApiError = { error: "Log file not found" }
|
|
13
|
+
return Response.json(errorResponse, { status: 404 })
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
const logContent = readFileSync(logPath,
|
|
17
|
-
const allLines = logContent.split(
|
|
18
|
-
const tailLines = allLines.slice(-lines)
|
|
19
|
-
|
|
15
|
+
|
|
16
|
+
const logContent = readFileSync(logPath, "utf-8")
|
|
17
|
+
const allLines = logContent.split("\n").filter((line) => line.trim())
|
|
18
|
+
const tailLines = allLines.slice(-lines)
|
|
19
|
+
|
|
20
20
|
const response: LogsApiResponse = {
|
|
21
|
-
logs: tailLines.join(
|
|
21
|
+
logs: tailLines.join("\n"),
|
|
22
22
|
total: allLines.length
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return Response.json(response)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return Response.json(response)
|
|
26
26
|
} catch (error) {
|
|
27
27
|
const errorResponse: LogsApiError = {
|
|
28
|
-
error: error instanceof Error ? error.message :
|
|
29
|
-
}
|
|
30
|
-
return Response.json(errorResponse, { status: 500 })
|
|
28
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
29
|
+
}
|
|
30
|
+
return Response.json(errorResponse, { status: 500 })
|
|
31
31
|
}
|
|
32
|
-
}
|
|
32
|
+
}
|