centaurus-cli 2.5.2 → 2.5.3

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 (246) hide show
  1. package/AUTH_FLOW.md +138 -0
  2. package/CONFIG_GUIDE.md +249 -0
  3. package/dist/config/models.d.ts +1 -1
  4. package/dist/config/models.d.ts.map +1 -1
  5. package/dist/config/models.js +2 -0
  6. package/dist/config/models.js.map +1 -1
  7. package/dist/ui/components/App.d.ts.map +1 -1
  8. package/dist/ui/components/App.js +104 -62
  9. package/dist/ui/components/App.js.map +1 -1
  10. package/dist/ui/components/FontRecommendation.d.ts +1 -0
  11. package/dist/ui/components/FontRecommendation.d.ts.map +1 -0
  12. package/dist/ui/components/FontRecommendation.js +1 -0
  13. package/dist/ui/components/FontRecommendation.js.map +1 -0
  14. package/dist/ui/components/InputBox.d.ts.map +1 -1
  15. package/dist/ui/components/InputBox.js +3 -2
  16. package/dist/ui/components/InputBox.js.map +1 -1
  17. package/dist/ui/components/MarkdownRenderer.d.ts.map +1 -1
  18. package/dist/ui/components/MarkdownRenderer.js +34 -9
  19. package/dist/ui/components/MarkdownRenderer.js.map +1 -1
  20. package/dist/ui/components/MessageDisplay.js +2 -2
  21. package/dist/ui/components/StreamingMessageDisplay.d.ts.map +1 -1
  22. package/dist/ui/components/StreamingMessageDisplay.js +3 -3
  23. package/dist/ui/components/StreamingMessageDisplay.js.map +1 -1
  24. package/dist/ui/components/ThinkingDisplay.d.ts +13 -0
  25. package/dist/ui/components/ThinkingDisplay.d.ts.map +1 -0
  26. package/dist/ui/components/ThinkingDisplay.js +41 -0
  27. package/dist/ui/components/ThinkingDisplay.js.map +1 -0
  28. package/dist/utils/version-checker.d.ts.map +1 -1
  29. package/dist/utils/version-checker.js +3 -31
  30. package/dist/utils/version-checker.js.map +1 -1
  31. package/package.json +5 -5
  32. package/dist/ai/provider-factory.d.ts +0 -6
  33. package/dist/ai/provider-factory.d.ts.map +0 -1
  34. package/dist/ai/provider-factory.js +0 -27
  35. package/dist/ai/provider-factory.js.map +0 -1
  36. package/dist/ai/providers/base.d.ts +0 -25
  37. package/dist/ai/providers/base.d.ts.map +0 -1
  38. package/dist/ai/providers/base.js +0 -9
  39. package/dist/ai/providers/base.js.map +0 -1
  40. package/dist/ai/providers/gemini.d.ts +0 -34
  41. package/dist/ai/providers/gemini.d.ts.map +0 -1
  42. package/dist/ai/providers/gemini.js +0 -146
  43. package/dist/ai/providers/gemini.js.map +0 -1
  44. package/dist/commands/view-duplication-logs.d.ts +0 -5
  45. package/dist/commands/view-duplication-logs.d.ts.map +0 -1
  46. package/dist/commands/view-duplication-logs.js +0 -14
  47. package/dist/commands/view-duplication-logs.js.map +0 -1
  48. package/dist/context/__tests__/command-detector.test.d.ts +0 -14
  49. package/dist/context/__tests__/command-detector.test.d.ts.map +0 -1
  50. package/dist/context/__tests__/command-detector.test.js +0 -318
  51. package/dist/context/__tests__/command-detector.test.js.map +0 -1
  52. package/dist/context/__tests__/context-manager.test.d.ts +0 -16
  53. package/dist/context/__tests__/context-manager.test.d.ts.map +0 -1
  54. package/dist/context/__tests__/context-manager.test.js +0 -375
  55. package/dist/context/__tests__/context-manager.test.js.map +0 -1
  56. package/dist/context/__tests__/error-handling.test.d.ts +0 -15
  57. package/dist/context/__tests__/error-handling.test.d.ts.map +0 -1
  58. package/dist/context/__tests__/error-handling.test.js +0 -447
  59. package/dist/context/__tests__/error-handling.test.js.map +0 -1
  60. package/dist/context/handlers/__tests__/docker-handler.test.d.ts +0 -13
  61. package/dist/context/handlers/__tests__/docker-handler.test.d.ts.map +0 -1
  62. package/dist/context/handlers/__tests__/docker-handler.test.js +0 -285
  63. package/dist/context/handlers/__tests__/docker-handler.test.js.map +0 -1
  64. package/dist/context/handlers/__tests__/ssh-handler.test.d.ts +0 -13
  65. package/dist/context/handlers/__tests__/ssh-handler.test.d.ts.map +0 -1
  66. package/dist/context/handlers/__tests__/ssh-handler.test.js +0 -251
  67. package/dist/context/handlers/__tests__/ssh-handler.test.js.map +0 -1
  68. package/dist/context/handlers/__tests__/wsl-handler.test.d.ts +0 -7
  69. package/dist/context/handlers/__tests__/wsl-handler.test.d.ts.map +0 -1
  70. package/dist/context/handlers/__tests__/wsl-handler.test.js +0 -331
  71. package/dist/context/handlers/__tests__/wsl-handler.test.js.map +0 -1
  72. package/dist/index-custom.d.ts +0 -3
  73. package/dist/index-custom.d.ts.map +0 -1
  74. package/dist/index-custom.js +0 -65
  75. package/dist/index-custom.js.map +0 -1
  76. package/dist/prompts/system-prompt.d.ts +0 -47
  77. package/dist/prompts/system-prompt.d.ts.map +0 -1
  78. package/dist/prompts/system-prompt.js +0 -377
  79. package/dist/prompts/system-prompt.js.map +0 -1
  80. package/dist/providers/GoogleProvider.d.ts +0 -26
  81. package/dist/providers/GoogleProvider.d.ts.map +0 -1
  82. package/dist/providers/GoogleProvider.js +0 -313
  83. package/dist/providers/GoogleProvider.js.map +0 -1
  84. package/dist/providers/Provider.d.ts +0 -114
  85. package/dist/providers/Provider.d.ts.map +0 -1
  86. package/dist/providers/Provider.js +0 -44
  87. package/dist/providers/Provider.js.map +0 -1
  88. package/dist/services/__tests__/ai-context-injector.test.d.ts +0 -15
  89. package/dist/services/__tests__/ai-context-injector.test.d.ts.map +0 -1
  90. package/dist/services/__tests__/ai-context-injector.test.js +0 -326
  91. package/dist/services/__tests__/ai-context-injector.test.js.map +0 -1
  92. package/dist/src/context/types.js +0 -27
  93. package/dist/src/services/ai-context-injector.js +0 -96
  94. package/dist/src/services/ai-service-client.js +0 -270
  95. package/dist/src/services/api-client.js +0 -349
  96. package/dist/src/tools/types.js +0 -1
  97. package/dist/src/types/index.js +0 -1
  98. package/dist/test/context/types.js +0 -27
  99. package/dist/test/services/__tests__/ai-context-injector.test.js +0 -325
  100. package/dist/test/services/ai-context-injector.js +0 -96
  101. package/dist/test/services/ai-service-client.js +0 -270
  102. package/dist/test/services/api-client.js +0 -349
  103. package/dist/test/tools/types.js +0 -1
  104. package/dist/test/types/index.js +0 -1
  105. package/dist/test-ai-context-injector.js +0 -97
  106. package/dist/tests/automated-verification.d.ts +0 -27
  107. package/dist/tests/automated-verification.d.ts.map +0 -1
  108. package/dist/tests/automated-verification.js +0 -359
  109. package/dist/tests/automated-verification.js.map +0 -1
  110. package/dist/tests/integration-tests.d.ts +0 -50
  111. package/dist/tests/integration-tests.d.ts.map +0 -1
  112. package/dist/tests/integration-tests.js +0 -648
  113. package/dist/tests/integration-tests.js.map +0 -1
  114. package/dist/tools/file-ops-test.d.ts +0 -6
  115. package/dist/tools/file-ops-test.d.ts.map +0 -1
  116. package/dist/tools/file-ops-test.js +0 -197
  117. package/dist/tools/file-ops-test.js.map +0 -1
  118. package/dist/ui/DisplayHistory.d.ts +0 -53
  119. package/dist/ui/DisplayHistory.d.ts.map +0 -1
  120. package/dist/ui/DisplayHistory.js +0 -82
  121. package/dist/ui/DisplayHistory.js.map +0 -1
  122. package/dist/ui/clack-ui.d.ts +0 -83
  123. package/dist/ui/clack-ui.d.ts.map +0 -1
  124. package/dist/ui/clack-ui.js +0 -304
  125. package/dist/ui/clack-ui.js.map +0 -1
  126. package/dist/ui/components/DisplayItemRenderer.d.ts +0 -18
  127. package/dist/ui/components/DisplayItemRenderer.d.ts.map +0 -1
  128. package/dist/ui/components/DisplayItemRenderer.js +0 -53
  129. package/dist/ui/components/DisplayItemRenderer.js.map +0 -1
  130. package/dist/ui/components/DynamicMessage.d.ts +0 -13
  131. package/dist/ui/components/DynamicMessage.d.ts.map +0 -1
  132. package/dist/ui/components/DynamicMessage.js +0 -27
  133. package/dist/ui/components/DynamicMessage.js.map +0 -1
  134. package/dist/ui/components/FileViewerScreen.d.ts +0 -14
  135. package/dist/ui/components/FileViewerScreen.d.ts.map +0 -1
  136. package/dist/ui/components/FileViewerScreen.js +0 -74
  137. package/dist/ui/components/FileViewerScreen.js.map +0 -1
  138. package/dist/ui/components/ScrollableContent.d.ts +0 -7
  139. package/dist/ui/components/ScrollableContent.d.ts.map +0 -1
  140. package/dist/ui/components/ScrollableContent.js +0 -6
  141. package/dist/ui/components/ScrollableContent.js.map +0 -1
  142. package/dist/ui/components/ScrollableMessageList.d.ts +0 -10
  143. package/dist/ui/components/ScrollableMessageList.d.ts.map +0 -1
  144. package/dist/ui/components/ScrollableMessageList.js +0 -133
  145. package/dist/ui/components/ScrollableMessageList.js.map +0 -1
  146. package/dist/ui/components/ScrollableScreen.d.ts +0 -9
  147. package/dist/ui/components/ScrollableScreen.d.ts.map +0 -1
  148. package/dist/ui/components/ScrollableScreen.js +0 -22
  149. package/dist/ui/components/ScrollableScreen.js.map +0 -1
  150. package/dist/ui/components/StaticMessageHistory.d.ts +0 -14
  151. package/dist/ui/components/StaticMessageHistory.d.ts.map +0 -1
  152. package/dist/ui/components/StaticMessageHistory.js +0 -19
  153. package/dist/ui/components/StaticMessageHistory.js.map +0 -1
  154. package/dist/ui/components/code-block.d.ts +0 -10
  155. package/dist/ui/components/code-block.d.ts.map +0 -1
  156. package/dist/ui/components/code-block.js +0 -74
  157. package/dist/ui/components/code-block.js.map +0 -1
  158. package/dist/ui/components/confirm-prompt.d.ts +0 -12
  159. package/dist/ui/components/confirm-prompt.d.ts.map +0 -1
  160. package/dist/ui/components/confirm-prompt.js +0 -104
  161. package/dist/ui/components/confirm-prompt.js.map +0 -1
  162. package/dist/ui/components/diff-viewer.d.ts +0 -9
  163. package/dist/ui/components/diff-viewer.d.ts.map +0 -1
  164. package/dist/ui/components/diff-viewer.js +0 -57
  165. package/dist/ui/components/diff-viewer.js.map +0 -1
  166. package/dist/ui/components/input-box.d.ts +0 -18
  167. package/dist/ui/components/input-box.d.ts.map +0 -1
  168. package/dist/ui/components/input-box.js +0 -157
  169. package/dist/ui/components/input-box.js.map +0 -1
  170. package/dist/ui/components/keyboard-help.d.ts +0 -7
  171. package/dist/ui/components/keyboard-help.d.ts.map +0 -1
  172. package/dist/ui/components/keyboard-help.js +0 -43
  173. package/dist/ui/components/keyboard-help.js.map +0 -1
  174. package/dist/ui/components/loading-indicator.d.ts +0 -3
  175. package/dist/ui/components/loading-indicator.d.ts.map +0 -1
  176. package/dist/ui/components/loading-indicator.js +0 -42
  177. package/dist/ui/components/loading-indicator.js.map +0 -1
  178. package/dist/ui/components/message-display.d.ts +0 -7
  179. package/dist/ui/components/message-display.d.ts.map +0 -1
  180. package/dist/ui/components/message-display.js +0 -104
  181. package/dist/ui/components/message-display.js.map +0 -1
  182. package/dist/ui/components/misc.d.ts +0 -28
  183. package/dist/ui/components/misc.d.ts.map +0 -1
  184. package/dist/ui/components/misc.js +0 -128
  185. package/dist/ui/components/misc.js.map +0 -1
  186. package/dist/ui/components/select-prompt.d.ts +0 -13
  187. package/dist/ui/components/select-prompt.d.ts.map +0 -1
  188. package/dist/ui/components/select-prompt.js +0 -42
  189. package/dist/ui/components/select-prompt.js.map +0 -1
  190. package/dist/ui/components/status-bar.d.ts +0 -11
  191. package/dist/ui/components/status-bar.d.ts.map +0 -1
  192. package/dist/ui/components/status-bar.js +0 -47
  193. package/dist/ui/components/status-bar.js.map +0 -1
  194. package/dist/ui/components/tool-execution.d.ts +0 -3
  195. package/dist/ui/components/tool-execution.d.ts.map +0 -1
  196. package/dist/ui/components/tool-execution.js +0 -374
  197. package/dist/ui/components/tool-execution.js.map +0 -1
  198. package/dist/ui/components/tool-result.d.ts +0 -11
  199. package/dist/ui/components/tool-result.d.ts.map +0 -1
  200. package/dist/ui/components/tool-result.js +0 -58
  201. package/dist/ui/components/tool-result.js.map +0 -1
  202. package/dist/ui/components/welcome-banner.d.ts +0 -3
  203. package/dist/ui/components/welcome-banner.d.ts.map +0 -1
  204. package/dist/ui/components/welcome-banner.js +0 -46
  205. package/dist/ui/components/welcome-banner.js.map +0 -1
  206. package/dist/ui/hooks/useDisplayHistory.d.ts +0 -13
  207. package/dist/ui/hooks/useDisplayHistory.d.ts.map +0 -1
  208. package/dist/ui/hooks/useDisplayHistory.js +0 -45
  209. package/dist/ui/hooks/useDisplayHistory.js.map +0 -1
  210. package/dist/ui/render-engine.d.ts +0 -69
  211. package/dist/ui/render-engine.d.ts.map +0 -1
  212. package/dist/ui/render-engine.js +0 -197
  213. package/dist/ui/render-engine.js.map +0 -1
  214. package/dist/ui/terminal/TerminalRenderer.d.ts +0 -84
  215. package/dist/ui/terminal/TerminalRenderer.d.ts.map +0 -1
  216. package/dist/ui/terminal/TerminalRenderer.js +0 -154
  217. package/dist/ui/terminal/TerminalRenderer.js.map +0 -1
  218. package/dist/ui/terminal/TerminalUI.d.ts +0 -139
  219. package/dist/ui/terminal/TerminalUI.d.ts.map +0 -1
  220. package/dist/ui/terminal/TerminalUI.js +0 -430
  221. package/dist/ui/terminal/TerminalUI.js.map +0 -1
  222. package/dist/ui/terminal/VirtualChatBuffer.d.ts +0 -32
  223. package/dist/ui/terminal/VirtualChatBuffer.d.ts.map +0 -1
  224. package/dist/ui/terminal/VirtualChatBuffer.js +0 -37
  225. package/dist/ui/terminal/VirtualChatBuffer.js.map +0 -1
  226. package/dist/ui/terminal-kit-base.d.ts +0 -117
  227. package/dist/ui/terminal-kit-base.d.ts.map +0 -1
  228. package/dist/ui/terminal-kit-base.js +0 -188
  229. package/dist/ui/terminal-kit-base.js.map +0 -1
  230. package/dist/ui/utils/duplication-detector.d.ts +0 -32
  231. package/dist/ui/utils/duplication-detector.d.ts.map +0 -1
  232. package/dist/ui/utils/duplication-detector.js +0 -227
  233. package/dist/ui/utils/duplication-detector.js.map +0 -1
  234. package/dist/ui/utils/duplication-logger.d.ts +0 -21
  235. package/dist/ui/utils/duplication-logger.d.ts.map +0 -1
  236. package/dist/ui/utils/duplication-logger.js +0 -85
  237. package/dist/ui/utils/duplication-logger.js.map +0 -1
  238. package/dist/ui/utils/terminal-scanner.d.ts +0 -19
  239. package/dist/ui/utils/terminal-scanner.d.ts.map +0 -1
  240. package/dist/ui/utils/terminal-scanner.js +0 -217
  241. package/dist/ui/utils/terminal-scanner.js.map +0 -1
  242. package/dist/version.d.ts +0 -2
  243. package/dist/version.d.ts.map +0 -1
  244. package/dist/version.js +0 -3
  245. package/dist/version.js.map +0 -1
  246. package/scripts/generate-version.js +0 -25
@@ -1,326 +0,0 @@
1
- /**
2
- * Unit tests for AI Context Injector
3
- *
4
- * These tests verify:
5
- * - Context message format
6
- * - Context injection into message history
7
- * - Local context (no injection)
8
- * - Different subshell types (SSH, WSL, Docker)
9
- */
10
- import { AIContextInjector } from '../ai-context-injector.js';
11
- /**
12
- * Test: No injection for local context
13
- */
14
- async function testLocalContextNoInjection() {
15
- console.log('Test: No injection for local context');
16
- const injector = new AIContextInjector();
17
- const messages = [
18
- { role: 'user', content: 'Hello' },
19
- { role: 'assistant', content: 'Hi there!' },
20
- { role: 'user', content: 'List files' },
21
- ];
22
- const localContext = {
23
- type: 'local',
24
- metadata: {
25
- workingDirectory: '/home/user',
26
- shell: 'bash',
27
- os: 'linux',
28
- },
29
- connectionState: 'connected',
30
- sessionId: 'local-session',
31
- };
32
- const result = injector.injectSubshellContext(messages, localContext);
33
- // Should return the same messages without modification
34
- if (result.length !== messages.length) {
35
- throw new Error('Expected no additional messages for local context');
36
- }
37
- if (result !== messages) {
38
- throw new Error('Expected same array reference for local context');
39
- }
40
- console.log('✓ Local context does not inject additional messages');
41
- }
42
- /**
43
- * Test: SSH context injection
44
- */
45
- async function testSSHContextInjection() {
46
- console.log('\nTest: SSH context injection');
47
- const injector = new AIContextInjector();
48
- const messages = [
49
- { role: 'user', content: 'Hello' },
50
- { role: 'assistant', content: 'Hi there!' },
51
- { role: 'user', content: 'List files' },
52
- ];
53
- const sshContext = {
54
- type: 'ssh',
55
- metadata: {
56
- hostname: 'example.com',
57
- username: 'testuser',
58
- workingDirectory: '/home/testuser',
59
- shell: 'bash',
60
- os: 'linux',
61
- port: 22,
62
- },
63
- connectionState: 'connected',
64
- sessionId: 'ssh-session',
65
- };
66
- const result = injector.injectSubshellContext(messages, sshContext);
67
- // Should have one additional message (context message)
68
- if (result.length !== messages.length + 1) {
69
- throw new Error(`Expected ${messages.length + 1} messages, got ${result.length}`);
70
- }
71
- // Context message should be inserted before the last user message
72
- const contextMessage = result[result.length - 2];
73
- if (contextMessage.role !== 'system') {
74
- throw new Error('Expected context message to have role "system"');
75
- }
76
- // Verify context message content
77
- const content = contextMessage.content;
78
- if (!content.includes('SSH')) {
79
- throw new Error('Expected context message to mention SSH');
80
- }
81
- if (!content.includes('example.com')) {
82
- throw new Error('Expected context message to include hostname');
83
- }
84
- if (!content.includes('testuser')) {
85
- throw new Error('Expected context message to include username');
86
- }
87
- if (!content.includes('/home/testuser')) {
88
- throw new Error('Expected context message to include working directory');
89
- }
90
- if (!content.includes('bash')) {
91
- throw new Error('Expected context message to include shell type');
92
- }
93
- if (!content.includes('linux')) {
94
- throw new Error('Expected context message to include OS type');
95
- }
96
- if (!content.includes('22')) {
97
- throw new Error('Expected context message to include port');
98
- }
99
- // Last message should still be the user message
100
- const lastMessage = result[result.length - 1];
101
- if (lastMessage.role !== 'user' || lastMessage.content !== 'List files') {
102
- throw new Error('Expected last message to be the original user message');
103
- }
104
- console.log('✓ SSH context injects correct message with all details');
105
- }
106
- /**
107
- * Test: WSL context injection
108
- */
109
- async function testWSLContextInjection() {
110
- console.log('\nTest: WSL context injection');
111
- const injector = new AIContextInjector();
112
- const messages = [
113
- { role: 'user', content: 'Run command' },
114
- ];
115
- const wslContext = {
116
- type: 'wsl',
117
- metadata: {
118
- distroName: 'Ubuntu-20.04',
119
- workingDirectory: '/home/user',
120
- shell: 'bash',
121
- os: 'linux',
122
- },
123
- connectionState: 'connected',
124
- sessionId: 'wsl-session',
125
- };
126
- const result = injector.injectSubshellContext(messages, wslContext);
127
- // Should have one additional message
128
- if (result.length !== 2) {
129
- throw new Error('Expected 2 messages after injection');
130
- }
131
- const contextMessage = result[0];
132
- if (contextMessage.role !== 'system') {
133
- throw new Error('Expected context message to have role "system"');
134
- }
135
- const content = contextMessage.content;
136
- if (!content.includes('WSL')) {
137
- throw new Error('Expected context message to mention WSL');
138
- }
139
- if (!content.includes('Ubuntu-20.04')) {
140
- throw new Error('Expected context message to include distribution name');
141
- }
142
- console.log('✓ WSL context injects correct message with distribution info');
143
- }
144
- /**
145
- * Test: Docker context injection
146
- */
147
- async function testDockerContextInjection() {
148
- console.log('\nTest: Docker context injection');
149
- const injector = new AIContextInjector();
150
- const messages = [
151
- { role: 'user', content: 'Check container' },
152
- ];
153
- const dockerContext = {
154
- type: 'docker',
155
- metadata: {
156
- containerId: 'abc123def456',
157
- workingDirectory: '/app',
158
- shell: 'sh',
159
- os: 'linux',
160
- },
161
- connectionState: 'connected',
162
- sessionId: 'docker-session',
163
- };
164
- const result = injector.injectSubshellContext(messages, dockerContext);
165
- // Should have one additional message
166
- if (result.length !== 2) {
167
- throw new Error('Expected 2 messages after injection');
168
- }
169
- const contextMessage = result[0];
170
- const content = contextMessage.content;
171
- if (!content.includes('DOCKER')) {
172
- throw new Error('Expected context message to mention DOCKER');
173
- }
174
- if (!content.includes('abc123def456')) {
175
- throw new Error('Expected context message to include container ID');
176
- }
177
- if (!content.includes('/app')) {
178
- throw new Error('Expected context message to include working directory');
179
- }
180
- console.log('✓ Docker context injects correct message with container info');
181
- }
182
- /**
183
- * Test: Context message inserted before last user message
184
- */
185
- async function testContextMessagePosition() {
186
- console.log('\nTest: Context message inserted before last user message');
187
- const injector = new AIContextInjector();
188
- const messages = [
189
- { role: 'user', content: 'First message' },
190
- { role: 'assistant', content: 'First response' },
191
- { role: 'user', content: 'Second message' },
192
- { role: 'assistant', content: 'Second response' },
193
- { role: 'tool', content: 'Tool result' },
194
- { role: 'user', content: 'Third message' },
195
- ];
196
- const sshContext = {
197
- type: 'ssh',
198
- metadata: {
199
- hostname: 'server.com',
200
- username: 'admin',
201
- workingDirectory: '/root',
202
- shell: 'zsh',
203
- os: 'linux',
204
- },
205
- connectionState: 'connected',
206
- sessionId: 'test-session',
207
- };
208
- const result = injector.injectSubshellContext(messages, sshContext);
209
- // Should have 7 messages (6 original + 1 context)
210
- if (result.length !== 7) {
211
- throw new Error(`Expected 7 messages, got ${result.length}`);
212
- }
213
- // Context message should be at index 5 (before last user message at index 6)
214
- const contextMessage = result[5];
215
- if (contextMessage.role !== 'system') {
216
- throw new Error('Expected context message at index 5');
217
- }
218
- // Last message should still be the user message
219
- const lastMessage = result[6];
220
- if (lastMessage.role !== 'user' || lastMessage.content !== 'Third message') {
221
- throw new Error('Expected last message to be the original user message');
222
- }
223
- // Previous messages should be unchanged
224
- if (result[0].content !== 'First message') {
225
- throw new Error('Expected first message to be unchanged');
226
- }
227
- if (result[4].role !== 'tool') {
228
- throw new Error('Expected tool message to remain at correct position');
229
- }
230
- console.log('✓ Context message inserted at correct position');
231
- }
232
- /**
233
- * Test: Context message when no user messages exist
234
- */
235
- async function testContextMessageNoUserMessages() {
236
- console.log('\nTest: Context message when no user messages exist');
237
- const injector = new AIContextInjector();
238
- const messages = [
239
- { role: 'system', content: 'System message' },
240
- { role: 'assistant', content: 'Assistant message' },
241
- ];
242
- const sshContext = {
243
- type: 'ssh',
244
- metadata: {
245
- hostname: 'test.com',
246
- username: 'user',
247
- workingDirectory: '/home/user',
248
- shell: 'bash',
249
- os: 'linux',
250
- },
251
- connectionState: 'connected',
252
- sessionId: 'test-session',
253
- };
254
- const result = injector.injectSubshellContext(messages, sshContext);
255
- // Should append context message to the end
256
- if (result.length !== 3) {
257
- throw new Error('Expected 3 messages');
258
- }
259
- const lastMessage = result[2];
260
- if (lastMessage.role !== 'system') {
261
- throw new Error('Expected context message to be appended');
262
- }
263
- console.log('✓ Context message appended when no user messages exist');
264
- }
265
- /**
266
- * Test: Important warning in context message
267
- */
268
- async function testContextMessageWarning() {
269
- console.log('\nTest: Important warning in context message');
270
- const injector = new AIContextInjector();
271
- const messages = [
272
- { role: 'user', content: 'Test' },
273
- ];
274
- const sshContext = {
275
- type: 'ssh',
276
- metadata: {
277
- hostname: 'remote.com',
278
- username: 'user',
279
- workingDirectory: '/tmp',
280
- shell: 'bash',
281
- os: 'linux',
282
- },
283
- connectionState: 'connected',
284
- sessionId: 'test-session',
285
- };
286
- const result = injector.injectSubshellContext(messages, sshContext);
287
- const contextMessage = result[0];
288
- const content = contextMessage.content;
289
- // Should contain important warning about execution environment
290
- if (!content.includes('IMPORTANT')) {
291
- throw new Error('Expected context message to contain IMPORTANT warning');
292
- }
293
- if (!content.includes('not on the local machine')) {
294
- throw new Error('Expected warning about remote execution');
295
- }
296
- if (!content.includes('ssh environment')) {
297
- throw new Error('Expected mention of ssh environment in warning');
298
- }
299
- console.log('✓ Context message includes important warning');
300
- }
301
- /**
302
- * Run all tests
303
- */
304
- async function runTests() {
305
- console.log('=== AI Context Injector Tests ===\n');
306
- try {
307
- await testLocalContextNoInjection();
308
- await testSSHContextInjection();
309
- await testWSLContextInjection();
310
- await testDockerContextInjection();
311
- await testContextMessagePosition();
312
- await testContextMessageNoUserMessages();
313
- await testContextMessageWarning();
314
- console.log('\n=== All tests passed! ===');
315
- }
316
- catch (error) {
317
- console.error('\n❌ Test failed:', error);
318
- process.exit(1);
319
- }
320
- }
321
- // Run tests if this file is executed directly
322
- if (import.meta.url === `file://${process.argv[1]}`) {
323
- runTests();
324
- }
325
- export { runTests };
326
- //# sourceMappingURL=ai-context-injector.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ai-context-injector.test.js","sourceRoot":"","sources":["../../../src/services/__tests__/ai-context-injector.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAI9D;;GAEG;AACH,KAAK,UAAU,2BAA2B;IACxC,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;IAEpD,MAAM,QAAQ,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAEzC,MAAM,QAAQ,GAAc;QAC1B,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE;QAClC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE;QAC3C,EAAE,IAAI,EAAE,M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zC,MAAM,yBAAyB,EAAE,CAAC;QAElC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAC7C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;QACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,8CAA8C;AAC9C,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACpD,QAAQ,EAAE,CAAC;AACb,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -1,27 +0,0 @@
1
- /**
2
- * Core types for the subshell context management system
3
- */
4
- /**
5
- * Error thrown when a subshell connection fails
6
- */
7
- export class SubshellConnectionError extends Error {
8
- constructor(type, reason, recoverable) {
9
- super(`${type} connection failed: ${reason}`);
10
- this.type = type;
11
- this.reason = reason;
12
- this.recoverable = recoverable;
13
- this.name = 'SubshellConnectionError';
14
- }
15
- }
16
- /**
17
- * Error thrown when a subshell command execution fails
18
- */
19
- export class SubshellExecutionError extends Error {
20
- constructor(command, reason, exitCode) {
21
- super(`Command execution failed: ${reason}`);
22
- this.command = command;
23
- this.reason = reason;
24
- this.exitCode = exitCode;
25
- this.name = 'SubshellExecutionError';
26
- }
27
- }
@@ -1,96 +0,0 @@
1
- /**
2
- * AI Context Injector
3
- *
4
- * Injects subshell context into AI message history to make the AI aware
5
- * of the current execution environment (SSH, WSL, Docker, etc.)
6
- */
7
- /**
8
- * AI Context Injector class
9
- * Handles injection of subshell context into message history before AI calls
10
- */
11
- export class AIContextInjector {
12
- /**
13
- * Inject subshell context into message history
14
- *
15
- * If the current context is a subshell (not local), this method inserts
16
- * a system message describing the environment before the last user message.
17
- * This ensures the AI is aware of where commands will execute.
18
- *
19
- * @param messages - The conversation history
20
- * @param context - The current subshell context
21
- * @returns Modified message array with context injected (if applicable)
22
- */
23
- injectSubshellContext(messages, context) {
24
- // Don't inject context for local environment
25
- if (context.type === 'local') {
26
- return messages;
27
- }
28
- // Build context message
29
- const contextMessage = {
30
- role: 'system',
31
- content: this.buildContextMessage(context),
32
- };
33
- // Insert context message before the last user message
34
- // This ensures the AI sees the context right before processing the request
35
- const result = [...messages];
36
- // Find the last user message index
37
- let lastUserMessageIndex = -1;
38
- for (let i = result.length - 1; i >= 0; i--) {
39
- if (result[i].role === 'user') {
40
- lastUserMessageIndex = i;
41
- break;
42
- }
43
- }
44
- // If we found a user message, insert context before it
45
- // Otherwise, append to the end
46
- if (lastUserMessageIndex >= 0) {
47
- result.splice(lastUserMessageIndex, 0, contextMessage);
48
- }
49
- else {
50
- result.push(contextMessage);
51
- }
52
- return result;
53
- }
54
- /**
55
- * Build context message describing the current subshell environment
56
- *
57
- * Creates a formatted message that informs the AI about:
58
- * - Environment type (SSH, WSL, Docker)
59
- * - Working directory
60
- * - Shell type
61
- * - Operating system
62
- * - Connection details (hostname, username, etc.)
63
- *
64
- * @param context - The current subshell context
65
- * @returns Formatted context message string
66
- */
67
- buildContextMessage(context) {
68
- const { type, metadata } = context;
69
- let message = `\n\n## CURRENT EXECUTION ENVIRONMENT\n\n`;
70
- message += `You are currently operating in a ${type.toUpperCase()} environment.\n\n`;
71
- message += `**Environment Details:**\n`;
72
- message += `- Type: ${type}\n`;
73
- message += `- Working Directory: ${metadata.workingDirectory}\n`;
74
- message += `- Shell: ${metadata.shell}\n`;
75
- message += `- OS: ${metadata.os}\n`;
76
- // Add type-specific details
77
- if (metadata.hostname) {
78
- message += `- Hostname: ${metadata.hostname}\n`;
79
- }
80
- if (metadata.username) {
81
- message += `- Username: ${metadata.username}\n`;
82
- }
83
- if (metadata.distroName) {
84
- message += `- Distribution: ${metadata.distroName}\n`;
85
- }
86
- if (metadata.containerId) {
87
- message += `- Container: ${metadata.containerId}\n`;
88
- }
89
- if (metadata.port) {
90
- message += `- Port: ${metadata.port}\n`;
91
- }
92
- message += `\n**IMPORTANT:** All commands and file operations you execute will run in this ${type} environment, not on the local machine.\n`;
93
- message += `When reading files, writing files, executing commands, or performing any operations, they will all happen in the ${type} environment.\n`;
94
- return message;
95
- }
96
- }