rl-rockcli 0.0.6 → 0.0.8
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/index.js +51 -20
- package/package.json +2 -2
- package/commands/log/core/constants.js +0 -237
- package/commands/log/core/display.js +0 -370
- package/commands/log/core/search.js +0 -330
- package/commands/log/core/tail.js +0 -216
- package/commands/log/core/utils.js +0 -424
- package/commands/log.js +0 -298
- package/commands/sandbox/core/log-bridge.js +0 -119
- package/commands/sandbox/core/replay/analyzer.js +0 -311
- package/commands/sandbox/core/replay/batch-orchestrator.js +0 -536
- package/commands/sandbox/core/replay/batch-task.js +0 -369
- package/commands/sandbox/core/replay/concurrent-display.js +0 -70
- package/commands/sandbox/core/replay/concurrent-orchestrator.js +0 -170
- package/commands/sandbox/core/replay/data-source.js +0 -86
- package/commands/sandbox/core/replay/display.js +0 -231
- package/commands/sandbox/core/replay/executor.js +0 -634
- package/commands/sandbox/core/replay/history-fetcher.js +0 -124
- package/commands/sandbox/core/replay/index.js +0 -338
- package/commands/sandbox/core/replay/loghouse-data-source.js +0 -177
- package/commands/sandbox/core/replay/pid-mapping.js +0 -26
- package/commands/sandbox/core/replay/request.js +0 -109
- package/commands/sandbox/core/replay/worker.js +0 -166
- package/commands/sandbox/core/session.js +0 -346
- package/commands/sandbox/log-bridge.js +0 -2
- package/commands/sandbox/ray.js +0 -2
- package/commands/sandbox/replay/analyzer.js +0 -311
- package/commands/sandbox/replay/batch-orchestrator.js +0 -536
- package/commands/sandbox/replay/batch-task.js +0 -369
- package/commands/sandbox/replay/concurrent-display.js +0 -70
- package/commands/sandbox/replay/concurrent-orchestrator.js +0 -170
- package/commands/sandbox/replay/display.js +0 -231
- package/commands/sandbox/replay/executor.js +0 -634
- package/commands/sandbox/replay/history-fetcher.js +0 -118
- package/commands/sandbox/replay/index.js +0 -338
- package/commands/sandbox/replay/pid-mapping.js +0 -26
- package/commands/sandbox/replay/request.js +0 -109
- package/commands/sandbox/replay/worker.js +0 -166
- package/commands/sandbox/replay.js +0 -2
- package/commands/sandbox/session.js +0 -2
- package/commands/sandbox-original.js +0 -1393
- package/commands/sandbox.js +0 -499
- package/help/help.json +0 -1071
- package/help/middleware.js +0 -71
- package/help/renderer.js +0 -800
- package/lib/plugin-context.js +0 -40
- package/sdks/sandbox/core/client.js +0 -845
- package/sdks/sandbox/core/config.js +0 -70
- package/sdks/sandbox/core/types.js +0 -74
- package/sdks/sandbox/httpLogger.js +0 -251
- package/sdks/sandbox/index.js +0 -9
- package/utils/asciiArt.js +0 -138
- package/utils/bun-compat.js +0 -59
- package/utils/ciPipelines.js +0 -138
- package/utils/cli.js +0 -17
- package/utils/command-router.js +0 -79
- package/utils/configManager.js +0 -503
- package/utils/dependency-resolver.js +0 -135
- package/utils/eagleeye_traceid.js +0 -151
- package/utils/envDetector.js +0 -78
- package/utils/execution_logger.js +0 -415
- package/utils/featureManager.js +0 -68
- package/utils/firstTimeTip.js +0 -44
- package/utils/hook-manager.js +0 -125
- package/utils/http-logger.js +0 -264
- package/utils/i18n.js +0 -139
- package/utils/image-progress.js +0 -159
- package/utils/logger.js +0 -154
- package/utils/plugin-loader.js +0 -124
- package/utils/plugin-manager.js +0 -348
- package/utils/ray_cli_wrapper.js +0 -746
- package/utils/sandbox-client.js +0 -419
- package/utils/terminal.js +0 -32
- package/utils/tips.js +0 -106
package/index.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* rl-rockcli - Open Source ROCK CLI Entry Point
|
|
5
|
+
*
|
|
6
|
+
* 这是开源版本的入口文件,它会:
|
|
7
|
+
* 1. 设置 ROCKCLI_MODE=opensource 环境变量
|
|
8
|
+
* 2. **只引用 Core 命令**(不引用 Internal)
|
|
9
|
+
* 3. 过滤掉内网专有功能
|
|
10
|
+
*/
|
|
7
11
|
|
|
8
|
-
//
|
|
12
|
+
// 强制设置开源模式(在任何 require 之前)
|
|
9
13
|
process.env.ROCKCLI_MODE = 'opensource';
|
|
10
14
|
|
|
15
|
+
// 开源版默认配置
|
|
16
|
+
if (!process.env.ROCKCLI_BASE_URL) {
|
|
17
|
+
process.env.ROCKCLI_BASE_URL = 'http://127.0.0.1:8080'; // 本地开发环境
|
|
18
|
+
}
|
|
19
|
+
|
|
11
20
|
const yargs = require('yargs/yargs');
|
|
12
21
|
const { hideBin } = require('yargs/helpers');
|
|
13
|
-
const logCommand = require('./commands/log');
|
|
14
|
-
const sandboxCommand = require('./commands/sandbox');
|
|
15
22
|
|
|
23
|
+
// ⚠️ 关键:只引用 Core 命令,不引用 Internal
|
|
24
|
+
// 这确保打包时不会包含内网代码
|
|
25
|
+
const logCommand = require('../commands/log'); // 已支持 ROCKCLI_MODE 过滤
|
|
26
|
+
const sandboxCommand = require('../commands/sandbox'); // 已支持 ROCKCLI_MODE 过滤
|
|
27
|
+
|
|
28
|
+
// ASCII Art Logo
|
|
16
29
|
const LOGO = `
|
|
17
30
|
██████╗ ██████╗ ██████╗██╗ ██╗ ██████╗██╗ ██╗
|
|
18
31
|
██╔══██╗██╔═══██╗██╔════╝██║ ██╔╝██╔════╝██║ ██║
|
|
@@ -22,16 +35,34 @@ const LOGO = `
|
|
|
22
35
|
╚═╝ ╚═╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝
|
|
23
36
|
`;
|
|
24
37
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
function run() {
|
|
39
|
+
const cli = yargs(hideBin(process.argv));
|
|
40
|
+
|
|
41
|
+
cli
|
|
42
|
+
.scriptName('rockcli')
|
|
43
|
+
.usage(LOGO + '\n\nUsage: $0 <command> [options]')
|
|
44
|
+
.command(logCommand)
|
|
45
|
+
.command(sandboxCommand)
|
|
46
|
+
.demandCommand(1, '请提供一个有效的命令。使用 --help 查看可用命令。')
|
|
47
|
+
.strict()
|
|
48
|
+
.alias('h', 'help')
|
|
49
|
+
.alias('v', 'version')
|
|
50
|
+
.version(require('../opensource/package.json').version)
|
|
51
|
+
.help()
|
|
52
|
+
.epilogue(`
|
|
53
|
+
环境变量:
|
|
54
|
+
ROCKCLI_API_KEY - API 密钥(用于认证)
|
|
55
|
+
ROCKCLI_BASE_URL - 沙箱服务地址(默认: http://127.0.0.1:8080)
|
|
56
|
+
ROCKCLI_LOG_LEVEL - 日志级别(debug/info/warn/error)
|
|
57
|
+
|
|
58
|
+
文档: https://github.com/rock-cli/rockcli
|
|
59
|
+
`);
|
|
60
|
+
|
|
61
|
+
if (typeof cli.terminalWidth === 'function') {
|
|
62
|
+
cli.wrap(cli.terminalWidth());
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
cli.parse();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
run();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rl-rockcli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Open-source ROCK CLI - Sandbox and Log management tool",
|
|
5
5
|
"bin": {
|
|
6
6
|
"rockcli": "./index.js"
|
|
@@ -46,4 +46,4 @@
|
|
|
46
46
|
"registry": "https://registry.npmjs.org",
|
|
47
47
|
"access": "public"
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
}
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
// 日志显示字段配置
|
|
2
|
-
const DISPLAY_FIELDS = [
|
|
3
|
-
'timestamp',
|
|
4
|
-
'time',
|
|
5
|
-
'time_iso8601',
|
|
6
|
-
'ms',
|
|
7
|
-
'level',
|
|
8
|
-
'sandbox_id',
|
|
9
|
-
'trace_id',
|
|
10
|
-
'sent_http_request_id',
|
|
11
|
-
'request_id',
|
|
12
|
-
'callId',
|
|
13
|
-
'logger',
|
|
14
|
-
'thread',
|
|
15
|
-
'field',
|
|
16
|
-
'method',
|
|
17
|
-
'class',
|
|
18
|
-
'request_method',
|
|
19
|
-
'url',
|
|
20
|
-
'request_uri',
|
|
21
|
-
'host',
|
|
22
|
-
'status',
|
|
23
|
-
'status_code',
|
|
24
|
-
'process_time',
|
|
25
|
-
'request_time_usec',
|
|
26
|
-
'request_length',
|
|
27
|
-
'body_bytes_sent',
|
|
28
|
-
'upstream_response_tim',
|
|
29
|
-
'message',
|
|
30
|
-
'request',
|
|
31
|
-
"headers",
|
|
32
|
-
"http_Authorization",
|
|
33
|
-
"http_x_cluster",
|
|
34
|
-
"http_user_id",
|
|
35
|
-
"http_x_experiment_id",
|
|
36
|
-
"http_user_agent",
|
|
37
|
-
'request_body',
|
|
38
|
-
'response',
|
|
39
|
-
'filename',
|
|
40
|
-
'lineno',
|
|
41
|
-
'site',
|
|
42
|
-
'exc_info',
|
|
43
|
-
'exception',
|
|
44
|
-
'command_id',
|
|
45
|
-
'event',
|
|
46
|
-
'content',
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
// 字段颜色映射(ANSI 颜色代码)
|
|
50
|
-
// 1. 内置字段(@ 开头):灰色 - 系统元数据,通常不需要关注
|
|
51
|
-
// 2. 一般情况不需要关注的字段:灰色 - 辅助信息,低价值
|
|
52
|
-
// 3. 普通字段:青色 - 常规字段,有一定价值
|
|
53
|
-
// 4. 重点字段:粗体青色 - 核心标识,最重要的字段
|
|
54
|
-
const FIELD_COLOR_MAP = {
|
|
55
|
-
// 1. 内置字段(@ 开头)- 灰色
|
|
56
|
-
'@timestamp': '\x1b[0;90m',
|
|
57
|
-
'@source': '\x1b[0;90m',
|
|
58
|
-
'@app_group': '\x1b[0;90m',
|
|
59
|
-
'@hostname': '\x1b[0;90m',
|
|
60
|
-
'@filename': '\x1b[0;90m',
|
|
61
|
-
'@packId': '\x1b[0;90m',
|
|
62
|
-
'@logGroupOrder': '\x1b[0;90m',
|
|
63
|
-
'@topic': '\x1b[0;90m',
|
|
64
|
-
'@app_stage': '\x1b[0;90m',
|
|
65
|
-
'@site': '\x1b[0;90m',
|
|
66
|
-
|
|
67
|
-
// 2. 一般情况不需要关注的字段 - 灰色
|
|
68
|
-
'ms': '\x1b[0;90m',
|
|
69
|
-
'logger': '\x1b[0;90m',
|
|
70
|
-
'lineno': '\x1b[0;90m',
|
|
71
|
-
'site': '\x1b[0;90m',
|
|
72
|
-
'command_id': '\x1b[0;90m',
|
|
73
|
-
'sent_http_request_id': '\x1b[0;90m',
|
|
74
|
-
|
|
75
|
-
// 3. 普通字段 - 青色
|
|
76
|
-
'method': '\x1b[0;36m',
|
|
77
|
-
'request_method': '\x1b[0;36m',
|
|
78
|
-
'field': '\x1b[0;36m',
|
|
79
|
-
'url': '\x1b[0;36m',
|
|
80
|
-
'request_uri': '\x1b[0;36m',
|
|
81
|
-
'status_code': '\x1b[0;36m',
|
|
82
|
-
'process_time': '\x1b[0;36m',
|
|
83
|
-
'request': '\x1b[0;36m',
|
|
84
|
-
'request_body': '\x1b[0;36m',
|
|
85
|
-
'response': '\x1b[0;36m',
|
|
86
|
-
'filename': '\x1b[0;36m',
|
|
87
|
-
'event': '\x1b[0;36m',
|
|
88
|
-
'content': '\x1b[0;36m',
|
|
89
|
-
'sandbox_id': '\x1b[0;36m',
|
|
90
|
-
'trace_id': '\x1b[0;36m',
|
|
91
|
-
|
|
92
|
-
// 4. 重点字段 - 粗体青色
|
|
93
|
-
'timestamp': '\x1b[1;36m',
|
|
94
|
-
'time': '\x1b[1;36m',
|
|
95
|
-
'time_iso8601': '\x1b[1;36m',
|
|
96
|
-
'level': '\x1b[1;36m',
|
|
97
|
-
'message': '\x1b[1;36m',
|
|
98
|
-
'exc_info': '\x1b[1;31m', // 异常信息 - 红色粗体
|
|
99
|
-
'exception': '\x1b[1;31m', // 异常 - 红色粗体
|
|
100
|
-
'error': '\x1b[1;31m', // 错误 - 红色粗体
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
// 默认字段颜色
|
|
104
|
-
const DEFAULT_FIELD_COLOR = '\x1b[0;90m';
|
|
105
|
-
|
|
106
|
-
// 字段黑名单(格式化模式下不显示)
|
|
107
|
-
const BLACKLIST_FIELDS = [
|
|
108
|
-
'sent_http_X_App_Id',
|
|
109
|
-
'scheme',
|
|
110
|
-
'remote_user',
|
|
111
|
-
'http_x_opensearch_rem',
|
|
112
|
-
'http_x_opensearch_sec',
|
|
113
|
-
'sent_http_Application',
|
|
114
|
-
'http_Content_Md5',
|
|
115
|
-
'http_date',
|
|
116
|
-
'sent_http_X_App_Name',
|
|
117
|
-
'http_Authorization',
|
|
118
|
-
'http_x_opensearch_non',
|
|
119
|
-
'sent_http_X_Aliyun_Us',
|
|
120
|
-
'sent_http_X_AppGroup_',
|
|
121
|
-
'upstream_response_tim',
|
|
122
|
-
];
|
|
123
|
-
|
|
124
|
-
// 需要截断的字段
|
|
125
|
-
const TRUNCATE_FIELDS = ['message', 'content', 'event'];
|
|
126
|
-
|
|
127
|
-
// Group by field mapping
|
|
128
|
-
const GROUP_BY_FIELDS = {
|
|
129
|
-
'file': '@filename',
|
|
130
|
-
'ip': '@source',
|
|
131
|
-
'app': '@app_group',
|
|
132
|
-
'hostname': '@hostname',
|
|
133
|
-
'cluster': '_cluster',
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
// Group by field display labels
|
|
137
|
-
const GROUP_BY_LABELS = {
|
|
138
|
-
'@filename': 'File',
|
|
139
|
-
'@source': 'IP',
|
|
140
|
-
'@app_group': 'App',
|
|
141
|
-
'@hostname': 'Machine',
|
|
142
|
-
'_cluster': 'Cluster',
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
// ANSI 颜色代码
|
|
146
|
-
const ANSI_COLORS = {
|
|
147
|
-
RESET: '\x1b[0m',
|
|
148
|
-
BOLD: '\x1b[1m',
|
|
149
|
-
CYAN: '\x1b[36m',
|
|
150
|
-
YELLOW: '\x1b[33m',
|
|
151
|
-
GREEN: '\x1b[32m',
|
|
152
|
-
MAGENTA: '\x1b[35m',
|
|
153
|
-
BLUE: '\x1b[34m',
|
|
154
|
-
RED: '\x1b[31m',
|
|
155
|
-
GRAY: '\x1b[90m',
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
// 查询时间范围(分钟)
|
|
159
|
-
const TIME_RANGES = [15, 60, 180, 720, 1800, 43200];
|
|
160
|
-
|
|
161
|
-
// 分页大小
|
|
162
|
-
const PAGE_SIZE = 1000;
|
|
163
|
-
|
|
164
|
-
// 日志文件名
|
|
165
|
-
// 注意:内网专有日志路径已移到 config/internal_log_config.json
|
|
166
|
-
const LOG_FILES = {
|
|
167
|
-
// 保留空对象,由具体命令从配置文件加载
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
// 字段补全列表(用于 -f 参数的自动补全)
|
|
172
|
-
const FIELD_COMPLETION_LIST = [
|
|
173
|
-
// 系统内置字段(@ 开头)
|
|
174
|
-
'@filename',
|
|
175
|
-
'@source',
|
|
176
|
-
'@app_group',
|
|
177
|
-
'@hostname',
|
|
178
|
-
'@timestamp',
|
|
179
|
-
'@packId',
|
|
180
|
-
'@logGroupOrder',
|
|
181
|
-
'@topic',
|
|
182
|
-
'@app_stage',
|
|
183
|
-
'@site',
|
|
184
|
-
|
|
185
|
-
// 常规字段
|
|
186
|
-
'status',
|
|
187
|
-
'status_code',
|
|
188
|
-
'level',
|
|
189
|
-
'message',
|
|
190
|
-
'method',
|
|
191
|
-
'request_method',
|
|
192
|
-
'url',
|
|
193
|
-
'request_uri',
|
|
194
|
-
'host',
|
|
195
|
-
'sandbox_id',
|
|
196
|
-
'trace_id',
|
|
197
|
-
'thread',
|
|
198
|
-
'logger',
|
|
199
|
-
'field',
|
|
200
|
-
'process_time',
|
|
201
|
-
'request_time_usec',
|
|
202
|
-
'request_length',
|
|
203
|
-
'body_bytes_sent',
|
|
204
|
-
'request',
|
|
205
|
-
'headers',
|
|
206
|
-
'http_Authorization',
|
|
207
|
-
'http_x_cluster',
|
|
208
|
-
'http_user_id',
|
|
209
|
-
'http_x_experiment_id',
|
|
210
|
-
'http_user_agent',
|
|
211
|
-
'request_body',
|
|
212
|
-
'response',
|
|
213
|
-
'filename',
|
|
214
|
-
'lineno',
|
|
215
|
-
'site',
|
|
216
|
-
'exc_info',
|
|
217
|
-
'exception',
|
|
218
|
-
'command_id',
|
|
219
|
-
'event',
|
|
220
|
-
'content',
|
|
221
|
-
'error',
|
|
222
|
-
];
|
|
223
|
-
|
|
224
|
-
module.exports = {
|
|
225
|
-
DISPLAY_FIELDS,
|
|
226
|
-
FIELD_COLOR_MAP,
|
|
227
|
-
DEFAULT_FIELD_COLOR,
|
|
228
|
-
BLACKLIST_FIELDS,
|
|
229
|
-
TRUNCATE_FIELDS,
|
|
230
|
-
GROUP_BY_FIELDS,
|
|
231
|
-
GROUP_BY_LABELS,
|
|
232
|
-
ANSI_COLORS,
|
|
233
|
-
TIME_RANGES,
|
|
234
|
-
PAGE_SIZE,
|
|
235
|
-
LOG_FILES,
|
|
236
|
-
FIELD_COMPLETION_LIST,
|
|
237
|
-
};
|