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
@@ -0,0 +1,138 @@
1
+ /**
2
+ * CI Pipeline Configuration Module
3
+ * Defines all available CI pipelines with their configurations
4
+ */
5
+
6
+ const configManager = require('../utils/configManager');
7
+
8
+ // Predefined pipeline configurations
9
+ const PIPELINES = {
10
+ 'py-unity-rock-test': {
11
+ projectId: 3123094,
12
+ pipelineId: 57001,
13
+ defaultBranch: 'master',
14
+ defaultParams: {},
15
+ requires: ['private_token']
16
+ },
17
+ 'ScaleAligner-rock-smoke-test': {
18
+ projectId: 2891731,
19
+ pipelineId: 51668,
20
+ defaultBranch: 'feature/rock-smoke-test',
21
+ defaultParams: {},
22
+ requires: ['private_token']
23
+ },
24
+ 'ScaleAligner-rock-health': {
25
+ projectId: 2891731,
26
+ pipelineId: 57233,
27
+ defaultBranch: 'jingyu/health_check',
28
+ defaultParams: {
29
+ cluster: 'zb-a'
30
+ },
31
+ injectFromConfig: {
32
+ 'apikey': 'whale_apikey' // 表示从 settings.json 的 whale_apikey 字段注入
33
+ },
34
+ requires: ['private_token', 'whale_apikey']
35
+ },
36
+ 'rock-xrl-ut': {
37
+ projectId: 3567319,
38
+ pipelineId: 42305,
39
+ defaultBranch: 'master',
40
+ defaultParams: {},
41
+ requires: ['private_token']
42
+ }
43
+ };
44
+
45
+ /**
46
+ * Get pipeline configuration by name
47
+ */
48
+ function getPipelineConfig(name) {
49
+ return PIPELINES[name];
50
+ }
51
+
52
+ /**
53
+ * Get all pipeline names
54
+ */
55
+ function getAllPipelineNames() {
56
+ return Object.keys(PIPELINES);
57
+ }
58
+
59
+ /**
60
+ * Validate that required configurations are present for a pipeline
61
+ */
62
+ function validatePipelineRequirements(pipelineName) {
63
+ const config = getPipelineConfig(pipelineName);
64
+ if (!config) {
65
+ throw new Error(`Pipeline '${pipelineName}' not found`);
66
+ }
67
+
68
+ const missingConfigs = [];
69
+ for (const required of config.requires) {
70
+ let value;
71
+ // Check if it's a test config (CI related) or sandbox config
72
+ if (required === 'private_token') {
73
+ value = configManager.getTestConfig('code_private_token');
74
+ } else if (required === 'whale_apikey') {
75
+ value = configManager.getTestConfig('whale_api_key');
76
+ } else {
77
+ // Fallback to original config manager if needed
78
+ value = configManager.getSandboxConfig(required);
79
+ }
80
+
81
+ if (!value) {
82
+ missingConfigs.push(required);
83
+ }
84
+ }
85
+
86
+ if (missingConfigs.length > 0) {
87
+ throw new Error(`Missing required configurations: ${missingConfigs.join(', ')}`);
88
+ }
89
+
90
+ return true;
91
+ }
92
+
93
+ /**
94
+ * Get merged parameters for a pipeline (defaults + injected + user-provided)
95
+ */
96
+ function getMergedParams(pipelineName, userParams = {}) {
97
+ const config = getPipelineConfig(pipelineName);
98
+ if (!config) {
99
+ return {};
100
+ }
101
+
102
+ // Start with default params
103
+ const mergedParams = { ...config.defaultParams };
104
+
105
+ // Add user params (they override defaults)
106
+ Object.assign(mergedParams, userParams);
107
+
108
+ // Inject values from config if needed
109
+ // Only inject if the parameter is not already provided by user
110
+ if (config.injectFromConfig) {
111
+ for (const [paramKey, configKey] of Object.entries(config.injectFromConfig)) {
112
+ // Check if the parameter is already provided by user
113
+ if (!(paramKey in mergedParams)) {
114
+ let configValue;
115
+ // Map configKey to the new naming scheme
116
+ if (configKey === 'whale_apikey') {
117
+ configValue = configManager.getTestConfig('whale_api_key');
118
+ } else {
119
+ configValue = configManager.getTestConfig(configKey);
120
+ }
121
+
122
+ if (configValue) {
123
+ mergedParams[paramKey] = configValue;
124
+ }
125
+ }
126
+ }
127
+ }
128
+
129
+ return mergedParams;
130
+ }
131
+
132
+ module.exports = {
133
+ PIPELINES,
134
+ getPipelineConfig,
135
+ getAllPipelineNames,
136
+ validatePipelineRequirements,
137
+ getMergedParams
138
+ };
package/utils/cli.js ADDED
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * CLI 常量定义
5
+ * 统一管理命令行工具的名称和相关常量
6
+ */
7
+
8
+ // CLI 命令名称 - 用户可见的命令
9
+ const CLI_NAME = 'rockcli';
10
+
11
+ // NPM 包名 - 用于安装和升级
12
+ const NPM_PACKAGE = '@ali/rockcli';
13
+
14
+ module.exports = {
15
+ CLI_NAME,
16
+ NPM_PACKAGE,
17
+ };
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Command Router for Sandbox commands
3
+ * Handles both old and new command formats
4
+ */
5
+
6
+ const logger = require('./logger');
7
+
8
+ const KNOWN_ACTIONS = ['start', 'stop', 'status', 'attach', 'exec', 'upload', 'download',
9
+ 'write-file', 'read-file', 'log', 'history', 'session'];
10
+
11
+ /**
12
+ * Route sandbox command to appropriate handler
13
+ * @param {Object} argv - Command line arguments
14
+ * @returns {string|null} Command type ('sandbox-start', 'sandbox-id-first', 'sandbox-session', 'sandbox-log', 'help', or null)
15
+ */
16
+ function routeSandboxCommand(argv) {
17
+ const args = argv._ || [];
18
+
19
+ // No arguments
20
+ if (args.length < 1) {
21
+ return 'help';
22
+ }
23
+
24
+ // Not a sandbox command
25
+ if (args[0] !== 'sandbox') {
26
+ return null;
27
+ }
28
+
29
+ // Only 'sandbox' without subcommand
30
+ if (args.length < 2) {
31
+ return 'help';
32
+ }
33
+
34
+ const secondArg = args[1];
35
+
36
+ // sandbox start [options]
37
+ if (secondArg === 'start') {
38
+ return 'sandbox-start';
39
+ }
40
+
41
+ // sandbox session <action> [args] (deprecated)
42
+ if (secondArg === 'session') {
43
+ logger.warn('Warning: "sandbox session" is deprecated. Use "sandbox <id> exec --session <action>" instead.');
44
+ return 'sandbox-session';
45
+ }
46
+
47
+ // sandbox <id> log <action> [args]
48
+ if (secondArg === 'log') {
49
+ // This is handled by the positional parameter logic
50
+ return 'sandbox-log';
51
+ }
52
+
53
+ // sandbox <id> <command> [args]
54
+ // Try to identify if secondArg is a command or an ID
55
+ if (KNOWN_ACTIONS.includes(secondArg)) {
56
+ // This is actually: sandbox <id> <command>
57
+ // The yargs positional parser will handle this
58
+ return 'sandbox-id-first';
59
+ }
60
+
61
+ // Default: treat as sandbox <id> <command>
62
+ return 'sandbox-id-first';
63
+ }
64
+
65
+ /**
66
+ * Show deprecated warning and suggest new format
67
+ * @param {string} oldFormat - Old command format
68
+ * @param {string} newFormat - New command format
69
+ */
70
+ function showDeprecatedWarning(oldFormat, newFormat) {
71
+ logger.warn(`Warning: "${oldFormat}" is deprecated.`);
72
+ logger.info(`New format: ${newFormat}`);
73
+ }
74
+
75
+ module.exports = {
76
+ routeSandboxCommand,
77
+ showDeprecatedWarning,
78
+ KNOWN_ACTIONS,
79
+ };