@opentabs-dev/cli 0.0.12 → 0.0.13
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/dist/commands/logs.d.ts
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The log file is written by `opentabs start` at ~/.opentabs/server.log
|
|
5
5
|
* (or $OPENTABS_CONFIG_DIR/server.log).
|
|
6
|
+
*
|
|
7
|
+
* When --plugin <name> is specified, only lines containing [plugin:<name>]
|
|
8
|
+
* are shown. This filters plugin log entries written by the MCP server's
|
|
9
|
+
* onPluginLog handler.
|
|
6
10
|
*/
|
|
7
11
|
import type { Command } from 'commander';
|
|
8
12
|
declare const registerLogsCommand: (program: Command) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiJzC,QAAA,MAAM,mBAAmB,GAAI,SAAS,OAAO,KAAG,IAiB/C,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
package/dist/commands/logs.js
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The log file is written by `opentabs start` at ~/.opentabs/server.log
|
|
5
5
|
* (or $OPENTABS_CONFIG_DIR/server.log).
|
|
6
|
+
*
|
|
7
|
+
* When --plugin <name> is specified, only lines containing [plugin:<name>]
|
|
8
|
+
* are shown. This filters plugin log entries written by the MCP server's
|
|
9
|
+
* onPluginLog handler.
|
|
6
10
|
*/
|
|
7
11
|
import { getLogFilePath } from '../config.js';
|
|
8
12
|
import { InvalidArgumentError } from 'commander';
|
|
@@ -15,29 +19,40 @@ const TAIL_BUFFER_SIZE = 64 * 1024;
|
|
|
15
19
|
* Read the last N lines from a file using a reverse-seek approach.
|
|
16
20
|
* Reads at most TAIL_BUFFER_SIZE bytes from the end instead of the entire file.
|
|
17
21
|
* Returns the tail content as a string and the file size (for follow offset).
|
|
22
|
+
*
|
|
23
|
+
* When a filter string is provided, only lines containing that string are
|
|
24
|
+
* included in the result. The line count applies to filtered lines.
|
|
18
25
|
*/
|
|
19
|
-
const tailFile = async (filePath, lineCount) => {
|
|
26
|
+
const tailFile = async (filePath, lineCount, filter) => {
|
|
20
27
|
const file = Bun.file(filePath);
|
|
21
28
|
const fileSize = file.size;
|
|
22
29
|
if (lineCount <= 0 || fileSize === 0)
|
|
23
30
|
return { content: '', fileSize };
|
|
24
31
|
const readStart = Math.max(0, fileSize - TAIL_BUFFER_SIZE);
|
|
25
32
|
const chunk = await file.slice(readStart, fileSize).text();
|
|
26
|
-
|
|
33
|
+
let lines = chunk.split('\n');
|
|
27
34
|
// If we didn't read from the start, the first line may be partial — skip it
|
|
28
35
|
if (readStart > 0)
|
|
29
36
|
lines.shift();
|
|
37
|
+
if (filter) {
|
|
38
|
+
lines = lines.filter(line => line.includes(filter));
|
|
39
|
+
}
|
|
30
40
|
const tail = lines.slice(-lineCount);
|
|
31
41
|
return { content: tail.join('\n'), fileSize };
|
|
32
42
|
};
|
|
33
43
|
/**
|
|
34
44
|
* Follow (tail -f) a log file. Watches for changes and streams new content.
|
|
35
45
|
* Returns a promise that never resolves (runs until the process exits).
|
|
46
|
+
*
|
|
47
|
+
* When a filter string is provided, only lines containing that string are
|
|
48
|
+
* written to stdout. Partial lines at the end of a chunk are buffered until
|
|
49
|
+
* the next read completes the line.
|
|
36
50
|
*/
|
|
37
|
-
const followFile = async (filePath, initialOffset) => {
|
|
51
|
+
const followFile = async (filePath, initialOffset, filter) => {
|
|
38
52
|
let offset = initialOffset;
|
|
39
53
|
let reading = false;
|
|
40
54
|
let readRequested = false;
|
|
55
|
+
let partialLine = '';
|
|
41
56
|
const readNewContent = () => {
|
|
42
57
|
if (reading) {
|
|
43
58
|
readRequested = true;
|
|
@@ -47,13 +62,28 @@ const followFile = async (filePath, initialOffset) => {
|
|
|
47
62
|
if (currentSize < offset) {
|
|
48
63
|
// File was truncated (e.g., new server start) — read from beginning
|
|
49
64
|
offset = 0;
|
|
65
|
+
partialLine = '';
|
|
50
66
|
}
|
|
51
67
|
if (currentSize <= offset)
|
|
52
68
|
return;
|
|
53
69
|
reading = true;
|
|
54
70
|
const stream = createReadStream(filePath, { start: offset, encoding: 'utf-8' });
|
|
55
71
|
stream.on('data', (chunk) => {
|
|
56
|
-
|
|
72
|
+
const text = typeof chunk === 'string' ? chunk : chunk.toString('utf-8');
|
|
73
|
+
if (!filter) {
|
|
74
|
+
process.stdout.write(text);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// Filter mode: split into lines and only output matching ones
|
|
78
|
+
const combined = partialLine + text;
|
|
79
|
+
const lines = combined.split('\n');
|
|
80
|
+
// Last element is either empty (if text ended with \n) or a partial line
|
|
81
|
+
partialLine = lines.pop() ?? '';
|
|
82
|
+
for (const line of lines) {
|
|
83
|
+
if (line.includes(filter)) {
|
|
84
|
+
process.stdout.write(line + '\n');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
57
87
|
});
|
|
58
88
|
stream.on('end', () => {
|
|
59
89
|
offset = currentSize;
|
|
@@ -95,12 +125,14 @@ const handleLogs = async (options) => {
|
|
|
95
125
|
console.error(pc.dim('Start the server with: opentabs start'));
|
|
96
126
|
process.exit(1);
|
|
97
127
|
}
|
|
128
|
+
// Build the filter string for --plugin: match lines containing [plugin:<name>]
|
|
129
|
+
const filter = options.plugin ? `[plugin:${options.plugin}]` : undefined;
|
|
98
130
|
const lineCount = options.lines ?? DEFAULT_LINES;
|
|
99
|
-
const { content, fileSize } = await tailFile(logFilePath, lineCount);
|
|
131
|
+
const { content, fileSize } = await tailFile(logFilePath, lineCount, filter);
|
|
100
132
|
if (content)
|
|
101
133
|
process.stdout.write(content);
|
|
102
134
|
if (options.follow !== false) {
|
|
103
|
-
await followFile(logFilePath, fileSize);
|
|
135
|
+
await followFile(logFilePath, fileSize, filter);
|
|
104
136
|
}
|
|
105
137
|
};
|
|
106
138
|
const registerLogsCommand = (program) => {
|
|
@@ -109,11 +141,13 @@ const registerLogsCommand = (program) => {
|
|
|
109
141
|
.description('Tail the MCP server log output')
|
|
110
142
|
.option('--lines <n>', `Number of lines to show (default: ${DEFAULT_LINES})`, parseLines)
|
|
111
143
|
.option('--no-follow', 'Print recent lines and exit (do not follow)')
|
|
144
|
+
.option('--plugin <name>', 'Show only logs from a specific plugin')
|
|
112
145
|
.addHelpText('after', `
|
|
113
146
|
Examples:
|
|
114
|
-
$ opentabs logs
|
|
115
|
-
$ opentabs logs --lines 100
|
|
116
|
-
$ opentabs logs --no-follow
|
|
147
|
+
$ opentabs logs # Tail logs (follows new output)
|
|
148
|
+
$ opentabs logs --lines 100 # Show last 100 lines then follow
|
|
149
|
+
$ opentabs logs --no-follow # Show last 50 lines and exit
|
|
150
|
+
$ opentabs logs --plugin slack # Show only Slack plugin logs (follows)`)
|
|
117
151
|
.action((options) => handleLogs(options));
|
|
118
152
|
};
|
|
119
153
|
export { registerLogsCommand };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AASxE,MAAM,aAAa,GAAG,EAAE,C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M,CAAC,aAAa,EAAE,qCAAqC,aAAa,GAAG,EAAE,UAAU,CAAC;SACxF,MAAM,CAAC,aAAa,EAAE,6CAA6C,CAAC;SACpE,MAAM,CAAC,iBAAiB,EAAE,uCAAuC,CAAC;SAClE,WAAW,CACV,OAAO,EACP;;;;;gFAK0E,CAC3E;SACA,MAAM,CAAC,CAAC,OAAoB,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3D,CAAC,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentabs-dev/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./scaffold": {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"build": "tsc --build"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@opentabs-dev/plugin-sdk": "^0.0.
|
|
25
|
-
"@opentabs-dev/plugin-tools": "^0.0.
|
|
26
|
-
"@opentabs-dev/shared": "^0.0.
|
|
24
|
+
"@opentabs-dev/plugin-sdk": "^0.0.13",
|
|
25
|
+
"@opentabs-dev/plugin-tools": "^0.0.13",
|
|
26
|
+
"@opentabs-dev/shared": "^0.0.13",
|
|
27
27
|
"commander": "^14.0.3",
|
|
28
28
|
"picocolors": "^1.1.1"
|
|
29
29
|
},
|