rl-rockcli 0.0.2 → 0.0.4

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.
Files changed (75) hide show
  1. package/README.md +400 -0
  2. package/index.js +51 -21
  3. package/package.json +3 -2
  4. package/commands/log/core/constants.js +0 -237
  5. package/commands/log/core/display.js +0 -370
  6. package/commands/log/core/search.js +0 -330
  7. package/commands/log/core/tail.js +0 -216
  8. package/commands/log/core/utils.js +0 -424
  9. package/commands/log.js +0 -298
  10. package/commands/sandbox/core/log-bridge.js +0 -119
  11. package/commands/sandbox/core/replay/analyzer.js +0 -311
  12. package/commands/sandbox/core/replay/batch-orchestrator.js +0 -536
  13. package/commands/sandbox/core/replay/batch-task.js +0 -369
  14. package/commands/sandbox/core/replay/concurrent-display.js +0 -70
  15. package/commands/sandbox/core/replay/concurrent-orchestrator.js +0 -170
  16. package/commands/sandbox/core/replay/data-source.js +0 -86
  17. package/commands/sandbox/core/replay/display.js +0 -231
  18. package/commands/sandbox/core/replay/executor.js +0 -634
  19. package/commands/sandbox/core/replay/history-fetcher.js +0 -124
  20. package/commands/sandbox/core/replay/index.js +0 -338
  21. package/commands/sandbox/core/replay/loghouse-data-source.js +0 -177
  22. package/commands/sandbox/core/replay/pid-mapping.js +0 -26
  23. package/commands/sandbox/core/replay/request.js +0 -109
  24. package/commands/sandbox/core/replay/worker.js +0 -166
  25. package/commands/sandbox/core/session.js +0 -346
  26. package/commands/sandbox/log-bridge.js +0 -2
  27. package/commands/sandbox/ray.js +0 -2
  28. package/commands/sandbox/replay/analyzer.js +0 -311
  29. package/commands/sandbox/replay/batch-orchestrator.js +0 -536
  30. package/commands/sandbox/replay/batch-task.js +0 -369
  31. package/commands/sandbox/replay/concurrent-display.js +0 -70
  32. package/commands/sandbox/replay/concurrent-orchestrator.js +0 -170
  33. package/commands/sandbox/replay/display.js +0 -231
  34. package/commands/sandbox/replay/executor.js +0 -634
  35. package/commands/sandbox/replay/history-fetcher.js +0 -118
  36. package/commands/sandbox/replay/index.js +0 -338
  37. package/commands/sandbox/replay/pid-mapping.js +0 -26
  38. package/commands/sandbox/replay/request.js +0 -109
  39. package/commands/sandbox/replay/worker.js +0 -166
  40. package/commands/sandbox/replay.js +0 -2
  41. package/commands/sandbox/session.js +0 -2
  42. package/commands/sandbox-original.js +0 -1393
  43. package/commands/sandbox.js +0 -499
  44. package/help/help.json +0 -1071
  45. package/help/middleware.js +0 -71
  46. package/help/renderer.js +0 -800
  47. package/lib/plugin-context.js +0 -40
  48. package/sdks/sandbox/core/client.js +0 -845
  49. package/sdks/sandbox/core/config.js +0 -70
  50. package/sdks/sandbox/core/types.js +0 -74
  51. package/sdks/sandbox/httpLogger.js +0 -251
  52. package/sdks/sandbox/index.js +0 -9
  53. package/utils/asciiArt.js +0 -138
  54. package/utils/bun-compat.js +0 -59
  55. package/utils/ciPipelines.js +0 -138
  56. package/utils/cli.js +0 -17
  57. package/utils/command-router.js +0 -79
  58. package/utils/configManager.js +0 -503
  59. package/utils/dependency-resolver.js +0 -135
  60. package/utils/eagleeye_traceid.js +0 -151
  61. package/utils/envDetector.js +0 -78
  62. package/utils/execution_logger.js +0 -415
  63. package/utils/featureManager.js +0 -68
  64. package/utils/firstTimeTip.js +0 -44
  65. package/utils/hook-manager.js +0 -125
  66. package/utils/http-logger.js +0 -264
  67. package/utils/i18n.js +0 -139
  68. package/utils/image-progress.js +0 -159
  69. package/utils/logger.js +0 -154
  70. package/utils/plugin-loader.js +0 -124
  71. package/utils/plugin-manager.js +0 -348
  72. package/utils/ray_cli_wrapper.js +0 -746
  73. package/utils/sandbox-client.js +0 -419
  74. package/utils/terminal.js +0 -32
  75. package/utils/tips.js +0 -106
@@ -1,159 +0,0 @@
1
- /**
2
- * ProgressBar class for displaying image dump progress
3
- *
4
- * Supports three output modes:
5
- * - Default: Beautiful progress bar with detailed counters
6
- * - Verbose: Progress bar + current image details
7
- * - Quiet: Minimal output with just counters
8
- */
9
- class ProgressBar {
10
- /**
11
- * Create a new ProgressBar instance
12
- * @param {Object} options - Progress bar options
13
- * @param {number} options.total - Total number of items
14
- * @param {boolean} [options.verbose=false] - Verbose mode
15
- * @param {boolean} [options.quiet=false] - Quiet mode
16
- */
17
- constructor({ total, verbose = false, quiet = false }) {
18
- this.total = total;
19
- // Quiet mode takes precedence over verbose mode
20
- this.verbose = !quiet && verbose;
21
- this.quiet = quiet;
22
-
23
- // Progress bar width
24
- this.progressBarWidth = 50;
25
- }
26
-
27
- /**
28
- * Update progress display
29
- * @param {ProgressTracker} tracker - Progress tracker with current state
30
- */
31
- update(tracker) {
32
- if (this.quiet) {
33
- this._updateQuiet(tracker);
34
- } else {
35
- this._updateDefault(tracker);
36
- }
37
- }
38
-
39
- /**
40
- * Show current processing image (verbose mode only)
41
- * @param {string} source - Source image name
42
- * @param {string} target - Target image name
43
- * @param {string} status - Status: 'processing', 'success', 'failed', 'skipped'
44
- */
45
- showCurrent(source, target, status) {
46
- if (!this.verbose) {
47
- return;
48
- }
49
-
50
- const icons = {
51
- processing: '⏳',
52
- success: '✅',
53
- failed: '❌',
54
- skipped: '⏭️'
55
- };
56
-
57
- const icon = icons[status] || '⏳';
58
- console.log(`${icon} ${source} -> ${target} [${status}]`);
59
- }
60
-
61
- /**
62
- * Show summary of results
63
- * @param {ProgressTracker} tracker - Progress tracker with results
64
- */
65
- showSummary(tracker) {
66
- if (this.quiet) {
67
- return;
68
- }
69
-
70
- const summary = [
71
- '',
72
- '=== Image Dump Summary ===',
73
- `Total: ${tracker.total}`,
74
- `Success: ${tracker.completed}`,
75
- `Failed: ${tracker.failed}`,
76
- `Skipped: ${tracker.skipped}`,
77
- ''
78
- ];
79
-
80
- console.log(summary.join('\n'));
81
-
82
- // Suggest verbose mode if there are failures and not in verbose mode
83
- if (!this.verbose && tracker.failed > 0) {
84
- console.log('Use --verbose for detailed error messages');
85
- }
86
-
87
- // Show detailed results in verbose mode
88
- if (this.verbose && tracker.results.length > 0) {
89
- console.log('=== Details ===');
90
- tracker.results.forEach((result, index) => {
91
- const icon = result.status === 'success' ? '✅' : result.status === 'failed' ? '❌' : '⏭️';
92
- console.log(`${icon} ${index + 1}. ${result.source} -> ${result.target}`);
93
-
94
- if (result.status === 'failed') {
95
- console.log(` Error: ${result.error}`);
96
- console.log(` Retries: ${result.retryCount}`);
97
- }
98
-
99
- if (result.duration) {
100
- console.log(` Duration: ${result.duration}ms`);
101
- }
102
-
103
- if (result.reason) {
104
- console.log(` Reason: ${result.reason}`);
105
- }
106
- });
107
- console.log('');
108
- }
109
- }
110
-
111
- /**
112
- * Update progress in default mode
113
- * @private
114
- * @param {ProgressTracker} tracker - Progress tracker with current state
115
- */
116
- _updateDefault(tracker) {
117
- const processed = tracker.completed + tracker.failed + tracker.skipped;
118
- const percentage = tracker.total > 0 ? Math.round((processed / tracker.total) * 100) : 0;
119
-
120
- // Build progress bar
121
- const filledWidth = Math.round((processed / tracker.total) * this.progressBarWidth);
122
- const emptyWidth = this.progressBarWidth - filledWidth;
123
- const progressBar = '━'.repeat(filledWidth) + '─'.repeat(emptyWidth);
124
-
125
- // Build status line
126
- const statusLine = [
127
- `✅ 成功: ${tracker.completed}`,
128
- `⏳ 处理中: ${tracker.pending}`,
129
- `❌ 失败: ${tracker.failed}`,
130
- `⏭️ 跳过: ${tracker.skipped}`
131
- ].join(' ');
132
-
133
- // Output
134
- console.log(`${progressBar} ${processed}/${tracker.total} (${percentage}%)`);
135
- console.log(statusLine);
136
- }
137
-
138
- /**
139
- * Update progress in quiet mode
140
- * @private
141
- * @param {ProgressTracker} tracker - Progress tracker with current state
142
- */
143
- _updateQuiet(tracker) {
144
- const processed = tracker.completed + tracker.failed + tracker.skipped;
145
- const percentage = tracker.total > 0 ? Math.round((processed / tracker.total) * 100) : 0;
146
-
147
- // Build minimal status line
148
- const statusLine = [
149
- `${processed}/${tracker.total} (${percentage}%)`,
150
- `✅ ${tracker.completed}`,
151
- `⏳ ${tracker.pending}`,
152
- `❌ ${tracker.failed}`
153
- ].join(' - ');
154
-
155
- console.log(statusLine);
156
- }
157
- }
158
-
159
- module.exports = { ProgressBar };
package/utils/logger.js DELETED
@@ -1,154 +0,0 @@
1
- /**
2
- * 日志工具模块
3
- * 基于 winston 实现,支持通过 verbose 级别控制日志输出
4
- */
5
-
6
- const winston = require('winston');
7
-
8
- // 日志级别枚举
9
- const LogLevel = {
10
- ERROR: 0,
11
- WARNING: 1,
12
- INFO: 2,
13
- DEBUG: 3
14
- };
15
-
16
- // 默认 verbose 级别 (0 = 只输出 error)
17
- let verboseLevel = 0;
18
-
19
- // TUI 模式标志:当启用时,抑制所有日志输出以避免干扰 TUI 渲染
20
- let tuiModeEnabled = false;
21
-
22
- // 创建 winston logger 实例
23
- const logger = winston.createLogger({
24
- levels: {
25
- error: 0,
26
- warn: 1,
27
- info: 2,
28
- debug: 3
29
- },
30
- transports: [
31
- new winston.transports.Console({
32
- stderrLevels: ['error', 'warn'],
33
- consoleWarnLevels: ['warn'],
34
- format: winston.format.combine(
35
- winston.format.printf(({ level, message, ...meta }) => {
36
- // 只输出消息部分,不包含 winston 的额外格式
37
- const metaStr = Object.keys(meta).length > 0 ? ` ${JSON.stringify(meta)}` : '';
38
- return `${message}${metaStr}`;
39
- })
40
- )
41
- })
42
- ]
43
- });
44
-
45
- // 初始设置为 info 级别,用户可见输出默认显示
46
- logger.level = 'info';
47
-
48
- /**
49
- * 设置 verbose 级别
50
- * @param {number} level - verbose 级别 (0-3)
51
- */
52
- function setVerboseLevel(level) {
53
- verboseLevel = Math.min(Math.max(level, 0), 3);
54
- // 映射到 winston 的日志级别
55
- // 默认 (0) = info, -v = debug
56
- const levelMap = ['info', 'info', 'debug', 'debug'];
57
- logger.level = levelMap[verboseLevel];
58
- }
59
-
60
- /**
61
- * 获取当前 verbose 级别
62
- * @returns {number}
63
- */
64
- function getVerboseLevel() {
65
- return verboseLevel;
66
- }
67
-
68
- /**
69
- * 判断是否应该输出指定级别的日志
70
- * @param {number} level - 日志级别
71
- * @returns {boolean}
72
- */
73
- function shouldLog(level) {
74
- return level <= verboseLevel;
75
- }
76
-
77
- /**
78
- * 启用 TUI 模式,抑制所有日志输出
79
- * @param {boolean} enabled - 是否启用
80
- */
81
- function setTUIMode(enabled) {
82
- tuiModeEnabled = !!enabled;
83
- }
84
-
85
- /**
86
- * 获取 TUI 模式状态
87
- * @returns {boolean}
88
- */
89
- function getTUIMode() {
90
- return tuiModeEnabled;
91
- }
92
-
93
- /**
94
- * 输出 ERROR 级别日志
95
- * @param {...any} args - 日志参数
96
- */
97
- function error(...args) {
98
- if (tuiModeEnabled) return;
99
- logger.error(args.join(' '));
100
- }
101
-
102
- /**
103
- * 输出 WARNING 级别日志
104
- * @param {...any} args - 日志参数
105
- */
106
- function warn(...args) {
107
- if (tuiModeEnabled) return;
108
- logger.warn(args.join(' '));
109
- }
110
-
111
- /**
112
- * 输出 INFO 级别日志
113
- * @param {...any} args - 日志参数
114
- */
115
- function info(...args) {
116
- if (tuiModeEnabled) return;
117
- logger.info(args.join(' '));
118
- }
119
-
120
- /**
121
- * 输出 DEBUG 级别日志
122
- * @param {...any} args - 日志参数
123
- */
124
- function debug(...args) {
125
- if (tuiModeEnabled) return;
126
- logger.debug(args.join(' '));
127
- }
128
-
129
- /**
130
- * 从命令行参数解析 verbose 级别
131
- * @param {Object} argv - yargs 解析的参数对象
132
- * @returns {number} - verbose 级别 (0-3)
133
- */
134
- function parseVerboseLevel(argv) {
135
- // yargs 会将 -v 解析为 verbose: true
136
- // 但我们需要统计 -v 的出现次数
137
- // yargs 的 count() 方法可以做到这一点
138
- const vCount = argv.v || 0;
139
- return Math.min(vCount, 3);
140
- }
141
-
142
- module.exports = {
143
- LogLevel,
144
- setVerboseLevel,
145
- getVerboseLevel,
146
- shouldLog,
147
- error,
148
- warn,
149
- info,
150
- debug,
151
- parseVerboseLevel,
152
- setTUIMode,
153
- getTUIMode
154
- };
@@ -1,124 +0,0 @@
1
- const fs = require('fs-extra');
2
- const path = require('path');
3
- const logger = require('./logger');
4
-
5
- /**
6
- * 插件加载器
7
- * 负责加载插件模块并调用插件导出函数
8
- */
9
- class PluginLoader {
10
- /**
11
- * 加载单个插件
12
- * @param {string} pluginPath - 插件路径
13
- * @param {string} pluginName - 插件名称
14
- * @param {Object} registerAPI - 注册 API
15
- * @returns {Promise<Object>} - 插件信息
16
- */
17
- async loadPlugin(pluginPath, pluginName, registerAPI) {
18
- try {
19
- // 检查插件路径是否存在
20
- if (!fs.existsSync(pluginPath)) {
21
- throw new Error(`Plugin path does not exist: ${pluginPath}`);
22
- }
23
-
24
- // 解析插件入口文件
25
- const entryPath = this._resolveEntryPath(pluginPath);
26
- if (!fs.existsSync(entryPath)) {
27
- throw new Error(`Plugin entry file not found: ${entryPath}`);
28
- }
29
-
30
- // 加载插件模块
31
- const pluginModule = require(entryPath);
32
-
33
- // 验证插件导出
34
- if (typeof pluginModule !== 'function') {
35
- throw new Error(`Plugin must export a function, got ${typeof pluginModule}`);
36
- }
37
-
38
- // 调用插件导出函数
39
- await pluginModule(registerAPI);
40
-
41
- logger.debug(`Plugin loaded successfully: ${pluginName}`);
42
-
43
- return {
44
- name: pluginName,
45
- path: pluginPath,
46
- entry: entryPath
47
- };
48
- } catch (error) {
49
- logger.warn(`Failed to load plugin: ${pluginName}`);
50
- logger.warn(error.message);
51
- throw error;
52
- }
53
- }
54
-
55
- /**
56
- * 解析插件入口文件路径
57
- * @private
58
- */
59
- _resolveEntryPath(pluginPath) {
60
- // 优先尝试 index.js
61
- const indexPath = path.join(pluginPath, 'index.js');
62
- if (fs.existsSync(indexPath)) {
63
- return indexPath;
64
- }
65
-
66
- // 尝试 package.json 中的 main 字段
67
- const pkgPath = path.join(pluginPath, 'package.json');
68
- if (fs.existsSync(pkgPath)) {
69
- try {
70
- const pkg = fs.readJsonSync(pkgPath);
71
- if (pkg.main) {
72
- const mainPath = path.join(pluginPath, pkg.main);
73
- if (fs.existsSync(mainPath)) {
74
- return mainPath;
75
- }
76
- }
77
- } catch (error) {
78
- // 忽略 package.json 解析错误
79
- }
80
- }
81
-
82
- // 默认返回 index.js
83
- return indexPath;
84
- }
85
-
86
- /**
87
- * 解析插件元数据
88
- * @param {string} pluginPath - 插件路径
89
- * @returns {Promise<Object>} - 插件元数据
90
- */
91
- async parsePluginMetadata(pluginPath) {
92
- const metadata = {
93
- name: path.basename(pluginPath),
94
- version: '0.0.0',
95
- description: '',
96
- dependsOn: [],
97
- priority: 0
98
- };
99
-
100
- // 尝试从 package.json 读取元数据
101
- const pkgPath = path.join(pluginPath, 'package.json');
102
- if (fs.existsSync(pkgPath)) {
103
- try {
104
- const pkg = fs.readJsonSync(pkgPath);
105
- metadata.name = pkg.name || metadata.name;
106
- metadata.version = pkg.version || metadata.version;
107
- metadata.description = pkg.description || metadata.description;
108
-
109
- // 从 rock-plugin 字段读取插件特定的元数据
110
- if (pkg['rock-plugin']) {
111
- const rockPlugin = pkg['rock-plugin'];
112
- metadata.dependsOn = rockPlugin.dependsOn || [];
113
- metadata.priority = rockPlugin.priority || 0;
114
- }
115
- } catch (error) {
116
- logger.warn(`Failed to parse package.json for ${pluginPath}: ${error.message}`);
117
- }
118
- }
119
-
120
- return metadata;
121
- }
122
- }
123
-
124
- module.exports = PluginLoader;