rl-rockcli 0.0.4 → 0.0.5

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 (74) hide show
  1. package/commands/log/core/constants.js +237 -0
  2. package/commands/log/core/display.js +370 -0
  3. package/commands/log/core/search.js +330 -0
  4. package/commands/log/core/tail.js +216 -0
  5. package/commands/log/core/utils.js +424 -0
  6. package/commands/log.js +298 -0
  7. package/commands/sandbox/core/log-bridge.js +119 -0
  8. package/commands/sandbox/core/replay/analyzer.js +311 -0
  9. package/commands/sandbox/core/replay/batch-orchestrator.js +536 -0
  10. package/commands/sandbox/core/replay/batch-task.js +369 -0
  11. package/commands/sandbox/core/replay/concurrent-display.js +70 -0
  12. package/commands/sandbox/core/replay/concurrent-orchestrator.js +170 -0
  13. package/commands/sandbox/core/replay/data-source.js +86 -0
  14. package/commands/sandbox/core/replay/display.js +231 -0
  15. package/commands/sandbox/core/replay/executor.js +634 -0
  16. package/commands/sandbox/core/replay/history-fetcher.js +124 -0
  17. package/commands/sandbox/core/replay/index.js +338 -0
  18. package/commands/sandbox/core/replay/loghouse-data-source.js +177 -0
  19. package/commands/sandbox/core/replay/pid-mapping.js +26 -0
  20. package/commands/sandbox/core/replay/request.js +109 -0
  21. package/commands/sandbox/core/replay/worker.js +166 -0
  22. package/commands/sandbox/core/session.js +346 -0
  23. package/commands/sandbox/log-bridge.js +2 -0
  24. package/commands/sandbox/ray.js +2 -0
  25. package/commands/sandbox/replay/analyzer.js +311 -0
  26. package/commands/sandbox/replay/batch-orchestrator.js +536 -0
  27. package/commands/sandbox/replay/batch-task.js +369 -0
  28. package/commands/sandbox/replay/concurrent-display.js +70 -0
  29. package/commands/sandbox/replay/concurrent-orchestrator.js +170 -0
  30. package/commands/sandbox/replay/display.js +231 -0
  31. package/commands/sandbox/replay/executor.js +634 -0
  32. package/commands/sandbox/replay/history-fetcher.js +118 -0
  33. package/commands/sandbox/replay/index.js +338 -0
  34. package/commands/sandbox/replay/pid-mapping.js +26 -0
  35. package/commands/sandbox/replay/request.js +109 -0
  36. package/commands/sandbox/replay/worker.js +166 -0
  37. package/commands/sandbox/replay.js +2 -0
  38. package/commands/sandbox/session.js +2 -0
  39. package/commands/sandbox-original.js +1393 -0
  40. package/commands/sandbox.js +499 -0
  41. package/help/help.json +1071 -0
  42. package/help/middleware.js +71 -0
  43. package/help/renderer.js +800 -0
  44. package/index.js +21 -51
  45. package/lib/plugin-context.js +40 -0
  46. package/package.json +1 -1
  47. package/sdks/sandbox/core/client.js +845 -0
  48. package/sdks/sandbox/core/config.js +70 -0
  49. package/sdks/sandbox/core/types.js +74 -0
  50. package/sdks/sandbox/httpLogger.js +251 -0
  51. package/sdks/sandbox/index.js +9 -0
  52. package/utils/asciiArt.js +138 -0
  53. package/utils/bun-compat.js +59 -0
  54. package/utils/ciPipelines.js +138 -0
  55. package/utils/cli.js +17 -0
  56. package/utils/command-router.js +79 -0
  57. package/utils/configManager.js +503 -0
  58. package/utils/dependency-resolver.js +135 -0
  59. package/utils/eagleeye_traceid.js +151 -0
  60. package/utils/envDetector.js +78 -0
  61. package/utils/execution_logger.js +415 -0
  62. package/utils/featureManager.js +68 -0
  63. package/utils/firstTimeTip.js +44 -0
  64. package/utils/hook-manager.js +125 -0
  65. package/utils/http-logger.js +264 -0
  66. package/utils/i18n.js +139 -0
  67. package/utils/image-progress.js +159 -0
  68. package/utils/logger.js +154 -0
  69. package/utils/plugin-loader.js +124 -0
  70. package/utils/plugin-manager.js +348 -0
  71. package/utils/ray_cli_wrapper.js +746 -0
  72. package/utils/sandbox-client.js +419 -0
  73. package/utils/terminal.js +32 -0
  74. package/utils/tips.js +106 -0
package/index.js CHANGED
@@ -1,31 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- /**
4
- * rl-rockcli - Open Source ROCK CLI Entry Point
5
- *
6
- * 这是开源版本的入口文件,它会:
7
- * 1. 设置 ROCKCLI_MODE=opensource 环境变量
8
- * 2. **只引用 Core 命令**(不引用 Internal)
9
- * 3. 过滤掉内网专有功能
10
- */
11
-
12
- // 强制设置开源模式(在任何 require 之前)
13
- process.env.ROCKCLI_MODE = 'opensource';
14
-
15
- // 开源版默认配置
3
+ // 开源版默认配置(只在环境变量未设置时才设置)
16
4
  if (!process.env.ROCKCLI_BASE_URL) {
17
- process.env.ROCKCLI_BASE_URL = 'http://127.0.0.1:8080'; // 本地开发环境
5
+ process.env.ROCKCLI_BASE_URL = 'http://127.0.0.1:8080';
18
6
  }
19
7
 
8
+ // 强制设置开源模式(放在环境变量读取之后)
9
+ process.env.ROCKCLI_MODE = 'opensource';
10
+
20
11
  const yargs = require('yargs/yargs');
21
12
  const { hideBin } = require('yargs/helpers');
13
+ const logCommand = require('./commands/log');
14
+ const sandboxCommand = require('./commands/sandbox');
22
15
 
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
29
16
  const LOGO = `
30
17
  ██████╗ ██████╗ ██████╗██╗ ██╗ ██████╗██╗ ██╗
31
18
  ██╔══██╗██╔═══██╗██╔════╝██║ ██╔╝██╔════╝██║ ██║
@@ -33,36 +20,19 @@ const LOGO = `
33
20
  ██╔══██╗██║ ██║██║ ██╔═██╗ ██║ ██║ ██║
34
21
  ██║ ██║╚██████╔╝╚██████╗██║ ██╗╚██████╗███████╗██║
35
22
  ╚═╝ ╚═╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝
23
+ Open Source
36
24
  `;
37
25
 
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('./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();
26
+ yargs(hideBin(process.argv))
27
+ .scriptName('rockcli')
28
+ .usage(LOGO + '\n\nUsage: $0 <command> [options]')
29
+ .command(logCommand)
30
+ .command(sandboxCommand)
31
+ .demandCommand(1)
32
+ .strict()
33
+ .alias('h', 'help')
34
+ .alias('v', 'version')
35
+ .version('0.1.0')
36
+ .help()
37
+ .wrap(null)
38
+ .parse();
@@ -0,0 +1,40 @@
1
+ /**
2
+ * 创建插件钩子 context 对象
3
+ * @param {Object} baseContext - 基础上下文
4
+ * @returns {Object} - context 对象
5
+ */
6
+ function createPluginContext(baseContext = {}) {
7
+ const context = { ...baseContext };
8
+
9
+ let _prevented = false;
10
+ let _preventMessage = null;
11
+
12
+ /**
13
+ * 阻止当前行为执行
14
+ * @param {string} message - 阻止原因的消息
15
+ */
16
+ context.preventDefault = function(message) {
17
+ _prevented = true;
18
+ _preventMessage = message || null;
19
+ };
20
+
21
+ /**
22
+ * 是否已阻止
23
+ */
24
+ Object.defineProperty(context, 'isPrevented', {
25
+ get: () => _prevented,
26
+ enumerable: true
27
+ });
28
+
29
+ /**
30
+ * 阻止消息
31
+ */
32
+ Object.defineProperty(context, 'preventMessage', {
33
+ get: () => _preventMessage,
34
+ enumerable: true
35
+ });
36
+
37
+ return context;
38
+ }
39
+
40
+ module.exports = { createPluginContext };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rl-rockcli",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Open-source ROCK CLI - Sandbox and Log management tool",
5
5
  "bin": {
6
6
  "rockcli": "./index.js"