rl-rockcli 0.0.8 → 0.0.10

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 (162) hide show
  1. package/commands/attach/basic-repl.js +212 -0
  2. package/commands/attach/cleanup-history.js +189 -0
  3. package/commands/attach/cleanup-manager.js +163 -0
  4. package/commands/attach/copy-ui/copyRepl.js +195 -0
  5. package/commands/attach/copy-ui/index.js +7 -0
  6. package/commands/attach/copy-ui/render/outputBlock.js +25 -0
  7. package/commands/attach/copy-ui/viewport/viewport.js +23 -0
  8. package/commands/attach/copy-ui/viewport/wheel.js +14 -0
  9. package/commands/attach/history-manager.js +507 -0
  10. package/commands/attach/history-session.js +48 -0
  11. package/commands/attach/ink-repl/InkREPL.js +1507 -0
  12. package/commands/attach/ink-repl/builtinCommands.js +1253 -0
  13. package/commands/attach/ink-repl/components/ConnectingScreen.js +76 -0
  14. package/commands/attach/ink-repl/components/Console.js +191 -0
  15. package/commands/attach/ink-repl/components/DetailView.js +148 -0
  16. package/commands/attach/ink-repl/components/DropdownMenu.js +86 -0
  17. package/commands/attach/ink-repl/components/InputArea.js +125 -0
  18. package/commands/attach/ink-repl/components/InputLine.js +18 -0
  19. package/commands/attach/ink-repl/components/OutputArea.js +22 -0
  20. package/commands/attach/ink-repl/components/OutputItem.js +96 -0
  21. package/commands/attach/ink-repl/components/ShellLayout.js +61 -0
  22. package/commands/attach/ink-repl/components/Spinner.js +79 -0
  23. package/commands/attach/ink-repl/components/StatusBar.js +106 -0
  24. package/commands/attach/ink-repl/components/WelcomeBanner.js +48 -0
  25. package/commands/attach/ink-repl/contexts/LayoutContext.js +12 -0
  26. package/commands/attach/ink-repl/contexts/ThemeContext.js +43 -0
  27. package/commands/attach/ink-repl/hooks/useFunctionKeys.js +70 -0
  28. package/commands/attach/ink-repl/hooks/useMouse.js +162 -0
  29. package/commands/attach/ink-repl/hooks/useResources.js +132 -0
  30. package/commands/attach/ink-repl/hooks/useSpinner.js +49 -0
  31. package/commands/attach/ink-repl/index.js +112 -0
  32. package/commands/attach/ink-repl/package.json +3 -0
  33. package/commands/attach/ink-repl/replState.js +947 -0
  34. package/commands/attach/ink-repl/shortcuts/defaultKeybindings.js +138 -0
  35. package/commands/attach/ink-repl/shortcuts/index.js +332 -0
  36. package/commands/attach/ink-repl/themes/defaultDark.js +18 -0
  37. package/commands/attach/ink-repl/themes/defaultLight.js +18 -0
  38. package/commands/attach/ink-repl/themes/index.js +4 -0
  39. package/commands/attach/ink-repl/themes/themeManager.js +45 -0
  40. package/commands/attach/ink-repl/themes/themeTokens.js +15 -0
  41. package/commands/attach/ink-repl/utils/atCompletion.js +346 -0
  42. package/commands/attach/ink-repl/utils/clipboard.js +50 -0
  43. package/commands/attach/ink-repl/utils/consoleLogger.js +81 -0
  44. package/commands/attach/ink-repl/utils/exitCodeHandler.js +49 -0
  45. package/commands/attach/ink-repl/utils/exitCodeTips.js +56 -0
  46. package/commands/attach/ink-repl/utils/formatTime.js +12 -0
  47. package/commands/attach/ink-repl/utils/outputSelection.js +120 -0
  48. package/commands/attach/ink-repl/utils/outputViewport.js +77 -0
  49. package/commands/attach/ink-repl/utils/paginatedFileLoading.js +76 -0
  50. package/commands/attach/ink-repl/utils/paramHint.js +60 -0
  51. package/commands/attach/ink-repl/utils/parseError.js +174 -0
  52. package/commands/attach/ink-repl/utils/pathCompletion.js +167 -0
  53. package/commands/attach/ink-repl/utils/remotePathSafety.js +56 -0
  54. package/commands/attach/ink-repl/utils/replSelection.js +205 -0
  55. package/commands/attach/ink-repl/utils/responseFormatter.js +127 -0
  56. package/commands/attach/ink-repl/utils/textWrap.js +117 -0
  57. package/commands/attach/ink-repl/utils/truncate.js +115 -0
  58. package/commands/attach/opentui-repl/App.tsx +891 -0
  59. package/commands/attach/opentui-repl/builtinCommands.ts +80 -0
  60. package/commands/attach/opentui-repl/components/ConfirmDialog.tsx +116 -0
  61. package/commands/attach/opentui-repl/components/ConnectingScreen.tsx +131 -0
  62. package/commands/attach/opentui-repl/components/Console.tsx +73 -0
  63. package/commands/attach/opentui-repl/components/DetailView.tsx +45 -0
  64. package/commands/attach/opentui-repl/components/DropdownMenu.tsx +130 -0
  65. package/commands/attach/opentui-repl/components/ExecutionStatus.tsx +66 -0
  66. package/commands/attach/opentui-repl/components/Header.tsx +24 -0
  67. package/commands/attach/opentui-repl/components/OutputArea.tsx +25 -0
  68. package/commands/attach/opentui-repl/components/OutputBlock.tsx +108 -0
  69. package/commands/attach/opentui-repl/components/PromptInput.tsx +109 -0
  70. package/commands/attach/opentui-repl/components/StatusBar.tsx +63 -0
  71. package/commands/attach/opentui-repl/components/Toast.tsx +65 -0
  72. package/commands/attach/opentui-repl/components/WelcomeBanner.tsx +41 -0
  73. package/commands/attach/opentui-repl/contexts/ReplContext.tsx +137 -0
  74. package/commands/attach/opentui-repl/contexts/SessionContext.tsx +32 -0
  75. package/commands/attach/opentui-repl/contexts/ThemeContext.tsx +70 -0
  76. package/commands/attach/opentui-repl/contexts/ToastContext.tsx +69 -0
  77. package/commands/attach/opentui-repl/contexts/toast-logic.js +71 -0
  78. package/commands/attach/opentui-repl/hooks/useResources.ts +102 -0
  79. package/commands/attach/opentui-repl/hooks/useSpinner.ts +46 -0
  80. package/commands/attach/opentui-repl/index.js +99 -0
  81. package/commands/attach/opentui-repl/keybindings.ts +39 -0
  82. package/commands/attach/opentui-repl/package.json +3 -0
  83. package/commands/attach/opentui-repl/render.tsx +72 -0
  84. package/commands/attach/opentui-repl/tsconfig.json +12 -0
  85. package/commands/attach/repl.js +791 -0
  86. package/commands/attach/sandbox-id-resolver.js +56 -0
  87. package/commands/attach/session-manager.js +307 -0
  88. package/commands/attach/ui-mode.js +146 -0
  89. package/commands/log/core/constants.js +237 -0
  90. package/commands/log/core/display.js +370 -0
  91. package/commands/log/core/search.js +330 -0
  92. package/commands/log/core/tail.js +216 -0
  93. package/commands/log/core/utils.js +424 -0
  94. package/commands/log.js +298 -0
  95. package/commands/sandbox/core/log-bridge.js +119 -0
  96. package/commands/sandbox/core/replay/analyzer.js +311 -0
  97. package/commands/sandbox/core/replay/batch-orchestrator.js +536 -0
  98. package/commands/sandbox/core/replay/batch-task.js +369 -0
  99. package/commands/sandbox/core/replay/concurrent-display.js +70 -0
  100. package/commands/sandbox/core/replay/concurrent-orchestrator.js +170 -0
  101. package/commands/sandbox/core/replay/data-source.js +86 -0
  102. package/commands/sandbox/core/replay/display.js +231 -0
  103. package/commands/sandbox/core/replay/executor.js +634 -0
  104. package/commands/sandbox/core/replay/history-fetcher.js +124 -0
  105. package/commands/sandbox/core/replay/index.js +338 -0
  106. package/commands/sandbox/core/replay/loghouse-data-source.js +177 -0
  107. package/commands/sandbox/core/replay/pid-mapping.js +26 -0
  108. package/commands/sandbox/core/replay/request.js +109 -0
  109. package/commands/sandbox/core/replay/worker.js +166 -0
  110. package/commands/sandbox/core/session.js +346 -0
  111. package/commands/sandbox/log-bridge.js +2 -0
  112. package/commands/sandbox/ray.js +2 -0
  113. package/commands/sandbox/replay/analyzer.js +311 -0
  114. package/commands/sandbox/replay/batch-orchestrator.js +536 -0
  115. package/commands/sandbox/replay/batch-task.js +369 -0
  116. package/commands/sandbox/replay/concurrent-display.js +70 -0
  117. package/commands/sandbox/replay/concurrent-orchestrator.js +170 -0
  118. package/commands/sandbox/replay/display.js +231 -0
  119. package/commands/sandbox/replay/executor.js +634 -0
  120. package/commands/sandbox/replay/history-fetcher.js +118 -0
  121. package/commands/sandbox/replay/index.js +338 -0
  122. package/commands/sandbox/replay/pid-mapping.js +26 -0
  123. package/commands/sandbox/replay/request.js +109 -0
  124. package/commands/sandbox/replay/worker.js +166 -0
  125. package/commands/sandbox/replay.js +2 -0
  126. package/commands/sandbox/session.js +2 -0
  127. package/commands/sandbox-original.js +1393 -0
  128. package/commands/sandbox.js +499 -0
  129. package/help/help.json +1071 -0
  130. package/help/middleware.js +71 -0
  131. package/help/renderer.js +800 -0
  132. package/index.js +5 -15
  133. package/lib/plugin-context.js +40 -0
  134. package/package.json +2 -2
  135. package/sdks/sandbox/core/client.js +845 -0
  136. package/sdks/sandbox/core/config.js +70 -0
  137. package/sdks/sandbox/core/types.js +74 -0
  138. package/sdks/sandbox/httpLogger.js +251 -0
  139. package/sdks/sandbox/index.js +9 -0
  140. package/utils/asciiArt.js +138 -0
  141. package/utils/bun-compat.js +59 -0
  142. package/utils/ciPipelines.js +138 -0
  143. package/utils/cli.js +17 -0
  144. package/utils/command-router.js +79 -0
  145. package/utils/configManager.js +503 -0
  146. package/utils/dependency-resolver.js +135 -0
  147. package/utils/eagleeye_traceid.js +151 -0
  148. package/utils/envDetector.js +78 -0
  149. package/utils/execution_logger.js +415 -0
  150. package/utils/featureManager.js +68 -0
  151. package/utils/firstTimeTip.js +44 -0
  152. package/utils/hook-manager.js +125 -0
  153. package/utils/http-logger.js +264 -0
  154. package/utils/i18n.js +139 -0
  155. package/utils/image-progress.js +159 -0
  156. package/utils/logger.js +154 -0
  157. package/utils/plugin-loader.js +124 -0
  158. package/utils/plugin-manager.js +348 -0
  159. package/utils/ray_cli_wrapper.js +746 -0
  160. package/utils/sandbox-client.js +419 -0
  161. package/utils/terminal.js +32 -0
  162. package/utils/tips.js +106 -0
@@ -0,0 +1,231 @@
1
+ const { RequestCategory, RequestAction } = require('./request');
2
+
3
+ /**
4
+ * 显示分析摘要
5
+ * @param {ReplayPlan} plan
6
+ * @param {Object} options
7
+ */
8
+ function displayAnalysisSummary(plan, options = {}) {
9
+ const { mode = 'smart', quiet = false } = options;
10
+
11
+ if (quiet) {
12
+ console.log(`Replaying ${plan.executeCount}/${plan.originalCount} requests...`);
13
+ return;
14
+ }
15
+
16
+ console.log(`\n📋 Loaded ${plan.originalCount} requests`);
17
+ console.log(`🔍 Mode: ${mode}\n`);
18
+
19
+ // 显示请求分析表格
20
+ console.log('Request Analysis:');
21
+ console.log('┌─────────────────────────────────┬───────┬─────────────────────────────────┐');
22
+ console.log('│ Category │ Count │ Action │');
23
+ console.log('├─────────────────────────────────┼───────┼─────────────────────────────────┤');
24
+
25
+ const { stats } = plan;
26
+
27
+ // Startup
28
+ if (stats.startup > 0) {
29
+ console.log(`│ Startup (start_async) │ ${padNumber(stats.startup)} │ ✅ Execute + wait for alive │`);
30
+ }
31
+
32
+ // Startup Polling
33
+ if (stats.startupPolling > 0) {
34
+ const skipped = plan.skippedRequests.filter(r => r.category === RequestCategory.STARTUP_POLLING).length;
35
+ if (skipped === stats.startupPolling) {
36
+ console.log(`│ Startup polling (get_status) │ ${padNumber(stats.startupPolling)} │ ⏭️ Skip (built-in wait) │`);
37
+ } else {
38
+ console.log(`│ Startup polling (get_status) │ ${padNumber(stats.startupPolling)} │ ✅ Execute │`);
39
+ }
40
+ }
41
+
42
+ // Session
43
+ if (stats.session > 0) {
44
+ console.log(`│ Session (create/close) │ ${padNumber(stats.session)} │ ✅ Execute │`);
45
+ }
46
+
47
+ // Nohup Commands
48
+ if (stats.nohupCommand > 0) {
49
+ console.log(`│ Nohup commands │ ${padNumber(stats.nohupCommand)} │ ✅ Execute + wait for process │`);
50
+ }
51
+
52
+ // Process Check
53
+ if (stats.processCheck > 0) {
54
+ console.log(`│ Process checks (kill -0) │ ${padNumber(stats.processCheck)} │ ⏭️ Skip (auto wait in nohup) │`);
55
+ }
56
+
57
+ // Log Query
58
+ if (stats.logQuery > 0) {
59
+ const skipped = plan.skippedRequests.filter(r => r.category === RequestCategory.LOG_QUERY).length;
60
+ if (skipped === stats.logQuery) {
61
+ console.log(`│ Log queries (head/tail) │ ${padNumber(stats.logQuery)} │ ⏭️ Skip (minimal mode) │`);
62
+ } else {
63
+ console.log(`│ Log queries (head/tail) │ ${padNumber(stats.logQuery)} │ ✅ Execute │`);
64
+ }
65
+ }
66
+
67
+ // Upload
68
+ if (stats.upload > 0) {
69
+ console.log(`│ Upload files │ ${padNumber(stats.upload)} │ ✅ Execute │`);
70
+ }
71
+
72
+ // Stop
73
+ if (stats.stop > 0) {
74
+ const skipped = plan.skippedRequests.filter(r => r.category === RequestCategory.STOP).length;
75
+ if (skipped === stats.stop) {
76
+ console.log(`│ Stop sandbox │ ${padNumber(stats.stop)} │ ⏭️ Skip (use --stop) │`);
77
+ } else {
78
+ console.log(`│ Stop sandbox │ ${padNumber(stats.stop)} │ ✅ Execute │`);
79
+ }
80
+ }
81
+
82
+ // Other
83
+ if (stats.other > 0) {
84
+ console.log(`│ Other commands │ ${padNumber(stats.other)} │ ✅ Execute │`);
85
+ }
86
+
87
+ console.log('└─────────────────────────────────┴───────┴─────────────────────────────────┘');
88
+
89
+ // 显示摘要
90
+ const reduction = plan.originalCount > 0
91
+ ? Math.round((1 - plan.executeCount / plan.originalCount) * 100)
92
+ : 0;
93
+
94
+ console.log(`\n📊 Summary: ${plan.originalCount} → ${plan.executeCount} requests`);
95
+ if (plan.skippedCount > 0) {
96
+ console.log(` - Skipped: ${plan.skippedCount}`);
97
+ }
98
+ if (plan.mergedCount > 0) {
99
+ console.log(` - Merged: ${plan.mergedCount}`);
100
+ }
101
+ console.log(` - To execute: ${plan.executeCount}`);
102
+ if (reduction > 0) {
103
+ console.log(` - Reduction: ${reduction}%`);
104
+ }
105
+
106
+ console.log('\n⏳ Starting replay...\n');
107
+ }
108
+
109
+ /**
110
+ * 显示结果摘要
111
+ * @param {Object} results - 执行结果
112
+ * @param {Array} pidMappings - PID 映射列表
113
+ * @param {Object} options
114
+ */
115
+ function displayResultsSummary(results, pidMappings = [], options = {}) {
116
+ const { quiet = false, logFile = 'replay.log', sandboxId = null } = options;
117
+
118
+ if (quiet) {
119
+ console.log(`\n✅ Done: ${results.success} success, ${results.failed} failed`);
120
+ return;
121
+ }
122
+
123
+ console.log('\n═══════════════════════════════════════════════════════════════');
124
+ console.log('📊 Replay Summary');
125
+ console.log('═══════════════════════════════════════════════════════════════');
126
+
127
+ console.log(`Total requests: ${results.total}`);
128
+ console.log(`├── ✅ Successful: ${results.success}`);
129
+ console.log(`├── ❌ Failed: ${results.failed}`);
130
+ console.log(`└── ⏭️ Skipped: ${results.skipped}`);
131
+
132
+ if (sandboxId) {
133
+ console.log(`\nNew sandbox_id: ${sandboxId}`);
134
+ }
135
+
136
+ // 显示 PID 映射使用情况
137
+ if (pidMappings.length > 0) {
138
+ console.log('\nPID Mappings Used:');
139
+ pidMappings.forEach((mapping, index) => {
140
+ const prefix = index === pidMappings.length - 1 ? '└──' : '├──';
141
+ console.log(`${prefix} ${mapping.oldPid} → ${mapping.newPid} (used ${mapping.usageCount} times)`);
142
+ });
143
+ }
144
+
145
+ console.log(`\n📝 Log saved to: ${logFile}`);
146
+ console.log('═══════════════════════════════════════════════════════════════');
147
+ }
148
+
149
+ /**
150
+ * 显示 dry-run 摘要
151
+ * @param {ReplayPlan} plan
152
+ * @param {Object} options
153
+ */
154
+ function displayDryRunSummary(plan, options = {}) {
155
+ console.log('\n🔍 Dry Run Mode - No requests will be executed\n');
156
+
157
+ // 显示将要执行的请求
158
+ if (plan.requests.length > 0) {
159
+ console.log('Requests to execute:');
160
+ const maxShow = 20;
161
+ const requests = plan.requests.slice(0, maxShow);
162
+
163
+ requests.forEach((req, index) => {
164
+ const action = getActionLabel(req.action);
165
+ console.log(` ${index + 1}. [${action}] ${req.method} ${req.getShortDescription()}`);
166
+ });
167
+
168
+ if (plan.requests.length > maxShow) {
169
+ console.log(` ... and ${plan.requests.length - maxShow} more`);
170
+ }
171
+ }
172
+
173
+ // 显示将要跳过的请求
174
+ if (plan.skippedRequests.length > 0) {
175
+ console.log(`\nRequests to skip (${plan.skippedRequests.length}):`);
176
+
177
+ // 按跳过原因分组
178
+ const byReason = {};
179
+ plan.skippedRequests.forEach(req => {
180
+ const reason = req.skipReason || 'Unknown';
181
+ byReason[reason] = (byReason[reason] || 0) + 1;
182
+ });
183
+
184
+ Object.entries(byReason).forEach(([reason, count]) => {
185
+ console.log(` - ${reason}: ${count}`);
186
+ });
187
+ }
188
+
189
+ // 显示将要合并的请求
190
+ if (plan.mergedRequests.length > 0) {
191
+ console.log(`\nRequests to merge (${plan.mergedRequests.length}):`);
192
+
193
+ const byReason = {};
194
+ plan.mergedRequests.forEach(req => {
195
+ const reason = req.skipReason || 'Merged into wait logic';
196
+ byReason[reason] = (byReason[reason] || 0) + 1;
197
+ });
198
+
199
+ Object.entries(byReason).forEach(([reason, count]) => {
200
+ console.log(` - ${reason}: ${count}`);
201
+ });
202
+ }
203
+
204
+ console.log('');
205
+ }
206
+
207
+ // 辅助函数
208
+ function padNumber(num, width = 5) {
209
+ return String(num).padStart(width);
210
+ }
211
+
212
+ function getActionLabel(action) {
213
+ switch (action) {
214
+ case RequestAction.EXECUTE:
215
+ return 'EXEC';
216
+ case RequestAction.EXECUTE_WITH_PROCESS_WAIT:
217
+ return 'EXEC+WAIT';
218
+ case RequestAction.SKIP:
219
+ return 'SKIP';
220
+ case RequestAction.MERGE:
221
+ return 'MERGE';
222
+ default:
223
+ return action;
224
+ }
225
+ }
226
+
227
+ module.exports = {
228
+ displayAnalysisSummary,
229
+ displayResultsSummary,
230
+ displayDryRunSummary
231
+ };