@vite-plugin-opencode-assistant/shared 1.0.64 → 1.0.66
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/es/file-log-watcher.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export interface FileLogEntry {
|
|
2
2
|
level: "info" | "warn" | "error";
|
|
3
3
|
message: string;
|
|
4
|
-
timestamp: string;
|
|
5
4
|
source: string;
|
|
6
5
|
}
|
|
7
6
|
export interface LogFileOptions {
|
|
@@ -12,12 +11,10 @@ export declare function readLogFile(options: LogFileOptions & {
|
|
|
12
11
|
projectRoot?: string;
|
|
13
12
|
level?: ("info" | "warn" | "error") | ("info" | "warn" | "error")[];
|
|
14
13
|
limit?: number;
|
|
15
|
-
since?: string;
|
|
16
14
|
}): Promise<FileLogEntry[]>;
|
|
17
15
|
export declare function readLogFileTail(options: LogFileOptions & {
|
|
18
16
|
projectRoot?: string;
|
|
19
17
|
lines?: number;
|
|
20
18
|
limit?: number;
|
|
21
19
|
level?: ("info" | "warn" | "error") | ("info" | "warn" | "error")[];
|
|
22
|
-
since?: string;
|
|
23
20
|
}): Promise<FileLogEntry[]>;
|
package/es/file-log-watcher.mjs
CHANGED
|
@@ -32,32 +32,9 @@ function detectLogLevel(line) {
|
|
|
32
32
|
}
|
|
33
33
|
return "info";
|
|
34
34
|
}
|
|
35
|
-
function parseLogTimestamp(line) {
|
|
36
|
-
const timestampPatterns = [
|
|
37
|
-
/(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}[+-]\d{2}:\d{2})/,
|
|
38
|
-
/(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z?)/,
|
|
39
|
-
/(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z)/,
|
|
40
|
-
/(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/,
|
|
41
|
-
/(\d{2}\/\w{3}\/\d{4}:\d{2}:\d{2}:\d{2} [+-]\d{4})/,
|
|
42
|
-
/(\d{2}\/\d{2}\/\d{4},\s*\d{1,2}:\d{2}:\d{2}\s*(?:AM|PM))/i,
|
|
43
|
-
/([A-Z]{3}, \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} GMT)/,
|
|
44
|
-
/(\[([^\]]+)\])/
|
|
45
|
-
];
|
|
46
|
-
for (const pattern of timestampPatterns) {
|
|
47
|
-
const match = line.match(pattern);
|
|
48
|
-
if (match) {
|
|
49
|
-
const timestampStr = match[1];
|
|
50
|
-
const date = new Date(timestampStr);
|
|
51
|
-
if (!isNaN(date.getTime())) {
|
|
52
|
-
return date.toISOString();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
35
|
function readLogFile(options) {
|
|
59
36
|
return __async(this, null, function* () {
|
|
60
|
-
const { name, filePath, projectRoot, level, limit
|
|
37
|
+
const { name, filePath, projectRoot, level, limit } = options;
|
|
61
38
|
const resolvedPath = resolvePath(filePath, projectRoot);
|
|
62
39
|
if (!fs.existsSync(resolvedPath)) {
|
|
63
40
|
log.debug(`Log file does not exist: ${resolvedPath}`);
|
|
@@ -67,22 +44,12 @@ function readLogFile(options) {
|
|
|
67
44
|
const content = yield fs.promises.readFile(resolvedPath, "utf-8");
|
|
68
45
|
const lines = content.split("\n").filter((line) => line.trim());
|
|
69
46
|
const entries = [];
|
|
70
|
-
const sinceDate = since ? new Date(since) : null;
|
|
71
|
-
let lastTimestamp = null;
|
|
72
47
|
for (const line of lines) {
|
|
73
|
-
const parsedTimestamp = parseLogTimestamp(line);
|
|
74
|
-
if (parsedTimestamp) {
|
|
75
|
-
lastTimestamp = parsedTimestamp;
|
|
76
|
-
}
|
|
77
48
|
const entry = {
|
|
78
49
|
level: detectLogLevel(line),
|
|
79
50
|
message: line,
|
|
80
|
-
timestamp: parsedTimestamp || lastTimestamp || (/* @__PURE__ */ new Date()).toISOString(),
|
|
81
51
|
source: `file:${name}`
|
|
82
52
|
};
|
|
83
|
-
if (sinceDate && new Date(entry.timestamp) < sinceDate) {
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
53
|
if (level) {
|
|
87
54
|
const levels = Array.isArray(level) ? level : [level];
|
|
88
55
|
if (!levels.includes(entry.level)) {
|
|
@@ -103,7 +70,7 @@ function readLogFile(options) {
|
|
|
103
70
|
}
|
|
104
71
|
function readLogFileTail(options) {
|
|
105
72
|
return __async(this, null, function* () {
|
|
106
|
-
const { name, filePath, projectRoot, lines = 200, limit, level
|
|
73
|
+
const { name, filePath, projectRoot, lines = 200, limit, level } = options;
|
|
107
74
|
const resolvedPath = resolvePath(filePath, projectRoot);
|
|
108
75
|
if (!fs.existsSync(resolvedPath)) {
|
|
109
76
|
log.debug(`Log file does not exist: ${resolvedPath}`);
|
|
@@ -143,17 +110,12 @@ function readLogFileTail(options) {
|
|
|
143
110
|
const content = buffer.toString("utf-8").trim();
|
|
144
111
|
const logLines = content.split("\n").filter((line) => line.trim());
|
|
145
112
|
const entries = [];
|
|
146
|
-
const sinceDate = since ? new Date(since) : null;
|
|
147
113
|
for (const line of logLines) {
|
|
148
114
|
const entry = {
|
|
149
115
|
level: detectLogLevel(line),
|
|
150
116
|
message: line,
|
|
151
|
-
timestamp: parseLogTimestamp(line) || (/* @__PURE__ */ new Date()).toISOString(),
|
|
152
117
|
source: `file:${name}`
|
|
153
118
|
};
|
|
154
|
-
if (sinceDate && new Date(entry.timestamp) < sinceDate) {
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
119
|
if (level) {
|
|
158
120
|
const levels = Array.isArray(level) ? level : [level];
|
|
159
121
|
if (!levels.includes(entry.level)) {
|
package/lib/file-log-watcher.cjs
CHANGED
|
@@ -65,32 +65,9 @@ function detectLogLevel(line) {
|
|
|
65
65
|
}
|
|
66
66
|
return "info";
|
|
67
67
|
}
|
|
68
|
-
function parseLogTimestamp(line) {
|
|
69
|
-
const timestampPatterns = [
|
|
70
|
-
/(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}[+-]\d{2}:\d{2})/,
|
|
71
|
-
/(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z?)/,
|
|
72
|
-
/(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z)/,
|
|
73
|
-
/(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/,
|
|
74
|
-
/(\d{2}\/\w{3}\/\d{4}:\d{2}:\d{2}:\d{2} [+-]\d{4})/,
|
|
75
|
-
/(\d{2}\/\d{2}\/\d{4},\s*\d{1,2}:\d{2}:\d{2}\s*(?:AM|PM))/i,
|
|
76
|
-
/([A-Z]{3}, \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} GMT)/,
|
|
77
|
-
/(\[([^\]]+)\])/
|
|
78
|
-
];
|
|
79
|
-
for (const pattern of timestampPatterns) {
|
|
80
|
-
const match = line.match(pattern);
|
|
81
|
-
if (match) {
|
|
82
|
-
const timestampStr = match[1];
|
|
83
|
-
const date = new Date(timestampStr);
|
|
84
|
-
if (!isNaN(date.getTime())) {
|
|
85
|
-
return date.toISOString();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
68
|
function readLogFile(options) {
|
|
92
69
|
return __async(this, null, function* () {
|
|
93
|
-
const { name, filePath, projectRoot, level, limit
|
|
70
|
+
const { name, filePath, projectRoot, level, limit } = options;
|
|
94
71
|
const resolvedPath = resolvePath(filePath, projectRoot);
|
|
95
72
|
if (!import_fs.default.existsSync(resolvedPath)) {
|
|
96
73
|
log.debug(`Log file does not exist: ${resolvedPath}`);
|
|
@@ -100,22 +77,12 @@ function readLogFile(options) {
|
|
|
100
77
|
const content = yield import_fs.default.promises.readFile(resolvedPath, "utf-8");
|
|
101
78
|
const lines = content.split("\n").filter((line) => line.trim());
|
|
102
79
|
const entries = [];
|
|
103
|
-
const sinceDate = since ? new Date(since) : null;
|
|
104
|
-
let lastTimestamp = null;
|
|
105
80
|
for (const line of lines) {
|
|
106
|
-
const parsedTimestamp = parseLogTimestamp(line);
|
|
107
|
-
if (parsedTimestamp) {
|
|
108
|
-
lastTimestamp = parsedTimestamp;
|
|
109
|
-
}
|
|
110
81
|
const entry = {
|
|
111
82
|
level: detectLogLevel(line),
|
|
112
83
|
message: line,
|
|
113
|
-
timestamp: parsedTimestamp || lastTimestamp || (/* @__PURE__ */ new Date()).toISOString(),
|
|
114
84
|
source: `file:${name}`
|
|
115
85
|
};
|
|
116
|
-
if (sinceDate && new Date(entry.timestamp) < sinceDate) {
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
86
|
if (level) {
|
|
120
87
|
const levels = Array.isArray(level) ? level : [level];
|
|
121
88
|
if (!levels.includes(entry.level)) {
|
|
@@ -136,7 +103,7 @@ function readLogFile(options) {
|
|
|
136
103
|
}
|
|
137
104
|
function readLogFileTail(options) {
|
|
138
105
|
return __async(this, null, function* () {
|
|
139
|
-
const { name, filePath, projectRoot, lines = 200, limit, level
|
|
106
|
+
const { name, filePath, projectRoot, lines = 200, limit, level } = options;
|
|
140
107
|
const resolvedPath = resolvePath(filePath, projectRoot);
|
|
141
108
|
if (!import_fs.default.existsSync(resolvedPath)) {
|
|
142
109
|
log.debug(`Log file does not exist: ${resolvedPath}`);
|
|
@@ -176,17 +143,12 @@ function readLogFileTail(options) {
|
|
|
176
143
|
const content = buffer.toString("utf-8").trim();
|
|
177
144
|
const logLines = content.split("\n").filter((line) => line.trim());
|
|
178
145
|
const entries = [];
|
|
179
|
-
const sinceDate = since ? new Date(since) : null;
|
|
180
146
|
for (const line of logLines) {
|
|
181
147
|
const entry = {
|
|
182
148
|
level: detectLogLevel(line),
|
|
183
149
|
message: line,
|
|
184
|
-
timestamp: parseLogTimestamp(line) || (/* @__PURE__ */ new Date()).toISOString(),
|
|
185
150
|
source: `file:${name}`
|
|
186
151
|
};
|
|
187
|
-
if (sinceDate && new Date(entry.timestamp) < sinceDate) {
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
152
|
if (level) {
|
|
191
153
|
const levels = Array.isArray(level) ? level : [level];
|
|
192
154
|
if (!levels.includes(entry.level)) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export interface FileLogEntry {
|
|
2
2
|
level: "info" | "warn" | "error";
|
|
3
3
|
message: string;
|
|
4
|
-
timestamp: string;
|
|
5
4
|
source: string;
|
|
6
5
|
}
|
|
7
6
|
export interface LogFileOptions {
|
|
@@ -12,12 +11,10 @@ export declare function readLogFile(options: LogFileOptions & {
|
|
|
12
11
|
projectRoot?: string;
|
|
13
12
|
level?: ("info" | "warn" | "error") | ("info" | "warn" | "error")[];
|
|
14
13
|
limit?: number;
|
|
15
|
-
since?: string;
|
|
16
14
|
}): Promise<FileLogEntry[]>;
|
|
17
15
|
export declare function readLogFileTail(options: LogFileOptions & {
|
|
18
16
|
projectRoot?: string;
|
|
19
17
|
lines?: number;
|
|
20
18
|
limit?: number;
|
|
21
19
|
level?: ("info" | "warn" | "error") | ("info" | "warn" | "error")[];
|
|
22
|
-
since?: string;
|
|
23
20
|
}): Promise<FileLogEntry[]>;
|