tabby-ai-assistant 1.0.5 → 1.0.6

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 (116) hide show
  1. package/dist/components/chat/ai-sidebar.component.d.ts +147 -0
  2. package/dist/components/chat/chat-interface.component.d.ts +38 -6
  3. package/dist/components/settings/general-settings.component.d.ts +6 -3
  4. package/dist/components/settings/provider-config.component.d.ts +25 -12
  5. package/dist/components/terminal/command-preview.component.d.ts +38 -0
  6. package/dist/index-full.d.ts +8 -0
  7. package/dist/index-minimal.d.ts +3 -0
  8. package/dist/index.d.ts +7 -3
  9. package/dist/index.js +1 -2
  10. package/dist/providers/tabby/ai-config.provider.d.ts +57 -5
  11. package/dist/providers/tabby/ai-hotkey.provider.d.ts +8 -14
  12. package/dist/providers/tabby/ai-toolbar-button.provider.d.ts +8 -9
  13. package/dist/services/chat/ai-sidebar.service.d.ts +89 -0
  14. package/dist/services/chat/chat-history.service.d.ts +78 -0
  15. package/dist/services/chat/chat-session.service.d.ts +57 -2
  16. package/dist/services/context/compaction.d.ts +90 -0
  17. package/dist/services/context/manager.d.ts +69 -0
  18. package/dist/services/context/memory.d.ts +116 -0
  19. package/dist/services/context/token-budget.d.ts +105 -0
  20. package/dist/services/core/ai-assistant.service.d.ts +40 -1
  21. package/dist/services/core/checkpoint.service.d.ts +130 -0
  22. package/dist/services/platform/escape-sequence.service.d.ts +132 -0
  23. package/dist/services/platform/platform-detection.service.d.ts +146 -0
  24. package/dist/services/providers/anthropic-provider.service.d.ts +5 -0
  25. package/dist/services/providers/base-provider.service.d.ts +6 -1
  26. package/dist/services/providers/glm-provider.service.d.ts +5 -0
  27. package/dist/services/providers/minimax-provider.service.d.ts +10 -1
  28. package/dist/services/providers/ollama-provider.service.d.ts +76 -0
  29. package/dist/services/providers/openai-compatible.service.d.ts +5 -0
  30. package/dist/services/providers/openai-provider.service.d.ts +5 -0
  31. package/dist/services/providers/vllm-provider.service.d.ts +82 -0
  32. package/dist/services/terminal/buffer-analyzer.service.d.ts +128 -0
  33. package/dist/services/terminal/terminal-manager.service.d.ts +185 -0
  34. package/dist/services/terminal/terminal-tools.service.d.ts +79 -0
  35. package/dist/types/ai.types.d.ts +92 -0
  36. package/dist/types/provider.types.d.ts +1 -1
  37. package/package.json +7 -10
  38. package/src/components/chat/ai-sidebar.component.ts +945 -0
  39. package/src/components/chat/chat-input.component.html +9 -24
  40. package/src/components/chat/chat-input.component.scss +3 -2
  41. package/src/components/chat/chat-interface.component.html +77 -69
  42. package/src/components/chat/chat-interface.component.scss +54 -4
  43. package/src/components/chat/chat-interface.component.ts +250 -34
  44. package/src/components/chat/chat-settings.component.scss +4 -4
  45. package/src/components/chat/chat-settings.component.ts +22 -11
  46. package/src/components/common/error-message.component.html +15 -0
  47. package/src/components/common/error-message.component.scss +77 -0
  48. package/src/components/common/error-message.component.ts +2 -96
  49. package/src/components/common/loading-spinner.component.html +4 -0
  50. package/src/components/common/loading-spinner.component.scss +57 -0
  51. package/src/components/common/loading-spinner.component.ts +2 -63
  52. package/src/components/security/consent-dialog.component.html +22 -0
  53. package/src/components/security/consent-dialog.component.scss +34 -0
  54. package/src/components/security/consent-dialog.component.ts +2 -55
  55. package/src/components/security/password-prompt.component.html +19 -0
  56. package/src/components/security/password-prompt.component.scss +30 -0
  57. package/src/components/security/password-prompt.component.ts +2 -54
  58. package/src/components/security/risk-confirm-dialog.component.html +8 -12
  59. package/src/components/security/risk-confirm-dialog.component.scss +8 -5
  60. package/src/components/security/risk-confirm-dialog.component.ts +6 -6
  61. package/src/components/settings/ai-settings-tab.component.html +16 -20
  62. package/src/components/settings/ai-settings-tab.component.scss +8 -5
  63. package/src/components/settings/ai-settings-tab.component.ts +12 -12
  64. package/src/components/settings/general-settings.component.html +8 -17
  65. package/src/components/settings/general-settings.component.scss +6 -3
  66. package/src/components/settings/general-settings.component.ts +62 -22
  67. package/src/components/settings/provider-config.component.html +19 -39
  68. package/src/components/settings/provider-config.component.scss +182 -39
  69. package/src/components/settings/provider-config.component.ts +119 -7
  70. package/src/components/settings/security-settings.component.scss +1 -1
  71. package/src/components/terminal/ai-toolbar-button.component.html +8 -0
  72. package/src/components/terminal/ai-toolbar-button.component.scss +20 -0
  73. package/src/components/terminal/ai-toolbar-button.component.ts +2 -30
  74. package/src/components/terminal/command-preview.component.html +61 -0
  75. package/src/components/terminal/command-preview.component.scss +72 -0
  76. package/src/components/terminal/command-preview.component.ts +127 -140
  77. package/src/components/terminal/command-suggestion.component.html +23 -0
  78. package/src/components/terminal/command-suggestion.component.scss +55 -0
  79. package/src/components/terminal/command-suggestion.component.ts +2 -77
  80. package/src/index-minimal.ts +32 -0
  81. package/src/index.ts +94 -11
  82. package/src/index.ts.backup +165 -0
  83. package/src/providers/tabby/ai-config.provider.ts +60 -51
  84. package/src/providers/tabby/ai-hotkey.provider.ts +23 -39
  85. package/src/providers/tabby/ai-settings-tab.provider.ts +2 -2
  86. package/src/providers/tabby/ai-toolbar-button.provider.ts +29 -24
  87. package/src/services/chat/ai-sidebar.service.ts +258 -0
  88. package/src/services/chat/chat-history.service.ts +308 -0
  89. package/src/services/chat/chat-history.service.ts.backup +239 -0
  90. package/src/services/chat/chat-session.service.ts +276 -3
  91. package/src/services/context/compaction.ts +483 -0
  92. package/src/services/context/manager.ts +442 -0
  93. package/src/services/context/memory.ts +519 -0
  94. package/src/services/context/token-budget.ts +422 -0
  95. package/src/services/core/ai-assistant.service.ts +280 -5
  96. package/src/services/core/ai-provider-manager.service.ts +2 -2
  97. package/src/services/core/checkpoint.service.ts +619 -0
  98. package/src/services/platform/escape-sequence.service.ts +499 -0
  99. package/src/services/platform/platform-detection.service.ts +494 -0
  100. package/src/services/providers/anthropic-provider.service.ts +28 -1
  101. package/src/services/providers/base-provider.service.ts +7 -1
  102. package/src/services/providers/glm-provider.service.ts +28 -1
  103. package/src/services/providers/minimax-provider.service.ts +209 -11
  104. package/src/services/providers/ollama-provider.service.ts +445 -0
  105. package/src/services/providers/openai-compatible.service.ts +9 -0
  106. package/src/services/providers/openai-provider.service.ts +9 -0
  107. package/src/services/providers/vllm-provider.service.ts +463 -0
  108. package/src/services/security/risk-assessment.service.ts +6 -2
  109. package/src/services/terminal/buffer-analyzer.service.ts +594 -0
  110. package/src/services/terminal/terminal-manager.service.ts +748 -0
  111. package/src/services/terminal/terminal-tools.service.ts +441 -0
  112. package/src/styles/ai-assistant.scss +78 -6
  113. package/src/types/ai.types.ts +144 -0
  114. package/src/types/provider.types.ts +1 -1
  115. package/tsconfig.json +9 -9
  116. package/webpack.config.js +28 -6
package/src/index.ts CHANGED
@@ -3,8 +3,11 @@ import { CommonModule } from '@angular/common';
3
3
  import { FormsModule } from '@angular/forms';
4
4
  import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
5
5
 
6
+ // 全局样式
7
+ import './styles/ai-assistant.scss';
8
+
6
9
  // Tabby modules
7
- import TabbyCoreModule, { ToolbarButtonProvider, ConfigProvider, HotkeyProvider } from 'tabby-core';
10
+ import TabbyCoreModule, { AppService, ConfigService, ToolbarButtonProvider, ConfigProvider, HotkeyProvider, HotkeysService } from 'tabby-core';
8
11
  import TabbyTerminalModule from 'tabby-terminal';
9
12
  import { SettingsTabProvider } from 'tabby-settings';
10
13
 
@@ -21,6 +24,8 @@ import { AnthropicProviderService } from './services/providers/anthropic-provide
21
24
  import { MinimaxProviderService } from './services/providers/minimax-provider.service';
22
25
  import { GlmProviderService } from './services/providers/glm-provider.service';
23
26
  import { OpenAiCompatibleProviderService } from './services/providers/openai-compatible.service';
27
+ import { OllamaProviderService } from './services/providers/ollama-provider.service';
28
+ import { VllmProviderService } from './services/providers/vllm-provider.service';
24
29
 
25
30
  // Security Services
26
31
  import { SecurityValidatorService } from './services/security/security-validator.service';
@@ -32,11 +37,28 @@ import { ConsentManagerService } from './services/security/consent-manager.servi
32
37
  import { ChatSessionService } from './services/chat/chat-session.service';
33
38
  import { ChatHistoryService } from './services/chat/chat-history.service';
34
39
  import { CommandGeneratorService } from './services/chat/command-generator.service';
40
+ import { AiSidebarService } from './services/chat/ai-sidebar.service';
35
41
 
36
42
  // Terminal Services
37
43
  import { CommandAnalyzerService } from './services/terminal/command-analyzer.service';
38
44
  import { ContextMenuService } from './services/terminal/context-menu.service';
39
45
  import { HotkeyService } from './services/terminal/hotkey.service';
46
+ import { TerminalManagerService } from './services/terminal/terminal-manager.service';
47
+
48
+ // Context Engineering Services
49
+ import { ContextManager } from './services/context/manager';
50
+ import { Compaction } from './services/context/compaction';
51
+ import { Memory } from './services/context/memory';
52
+ import { TokenBudget } from './services/context/token-budget';
53
+
54
+ // Platform Services
55
+ import { PlatformDetectionService } from './services/platform/platform-detection.service';
56
+
57
+ // Core Services
58
+ import { CheckpointManager } from './services/core/checkpoint.service';
59
+
60
+ // Enhanced Terminal Services
61
+ import { BufferAnalyzerService } from './services/terminal/buffer-analyzer.service';
40
62
 
41
63
  // Tabby Providers (enabled for proper integration)
42
64
 
@@ -45,10 +67,12 @@ import { ChatInterfaceComponent } from './components/chat/chat-interface.compone
45
67
  import { ChatMessageComponent } from './components/chat/chat-message.component';
46
68
  import { ChatInputComponent } from './components/chat/chat-input.component';
47
69
  import { ChatSettingsComponent } from './components/chat/chat-settings.component';
70
+ import { AiSidebarComponent } from './components/chat/ai-sidebar.component';
48
71
 
49
72
  import { AiSettingsTabComponent } from './components/settings/ai-settings-tab.component';
50
73
  import { ProviderConfigComponent } from './components/settings/provider-config.component';
51
74
  import { SecuritySettingsComponent } from './components/settings/security-settings.component';
75
+ import { GeneralSettingsComponent } from './components/settings/general-settings.component';
52
76
 
53
77
  import { RiskConfirmDialogComponent } from './components/security/risk-confirm-dialog.component';
54
78
  import { PasswordPromptComponent } from './components/security/password-prompt.component';
@@ -71,8 +95,8 @@ import { AiHotkeyProvider } from './providers/tabby/ai-hotkey.provider';
71
95
  imports: [
72
96
  CommonModule,
73
97
  FormsModule,
74
- TabbyCoreModule, // Enabled for Tabby integration
75
- TabbyTerminalModule, // Required for terminal integration
98
+ TabbyCoreModule,
99
+ TabbyTerminalModule,
76
100
  NgbModule
77
101
  ],
78
102
  providers: [
@@ -88,6 +112,8 @@ import { AiHotkeyProvider } from './providers/tabby/ai-hotkey.provider';
88
112
  MinimaxProviderService,
89
113
  GlmProviderService,
90
114
  OpenAiCompatibleProviderService,
115
+ OllamaProviderService,
116
+ VllmProviderService,
91
117
 
92
118
  // Security Services
93
119
  SecurityValidatorService,
@@ -99,18 +125,34 @@ import { AiHotkeyProvider } from './providers/tabby/ai-hotkey.provider';
99
125
  ChatSessionService,
100
126
  ChatHistoryService,
101
127
  CommandGeneratorService,
128
+ AiSidebarService,
102
129
 
103
130
  // Terminal Services
104
131
  CommandAnalyzerService,
105
132
  ContextMenuService,
106
133
  HotkeyService,
134
+ TerminalManagerService,
135
+
136
+ // Context Engineering Services
137
+ ContextManager,
138
+ Compaction,
139
+ Memory,
140
+ TokenBudget,
141
+
142
+ // Platform Services
143
+ PlatformDetectionService,
107
144
 
108
- // Tabby Integration Providers (enabled for proper integration)
145
+ // Core Services
146
+ CheckpointManager,
147
+
148
+ // Enhanced Terminal Services
149
+ BufferAnalyzerService,
150
+
151
+ // Tabby Integration Providers
109
152
  { provide: ToolbarButtonProvider, useClass: AiToolbarButtonProvider, multi: true },
110
153
  { provide: SettingsTabProvider, useClass: AiSettingsTabProvider, multi: true },
111
154
  { provide: ConfigProvider, useClass: AiConfigProvider, multi: true },
112
155
  { provide: HotkeyProvider, useClass: AiHotkeyProvider, multi: true },
113
- // { provide: TabContextMenuItemProvider, useClass: AiContextMenuProvider, multi: true }
114
156
  ],
115
157
  declarations: [
116
158
  // Chat Components
@@ -118,11 +160,13 @@ import { AiHotkeyProvider } from './providers/tabby/ai-hotkey.provider';
118
160
  ChatMessageComponent,
119
161
  ChatInputComponent,
120
162
  ChatSettingsComponent,
163
+ AiSidebarComponent,
121
164
 
122
165
  // Settings Components
123
166
  AiSettingsTabComponent,
124
167
  ProviderConfigComponent,
125
168
  SecuritySettingsComponent,
169
+ GeneralSettingsComponent,
126
170
 
127
171
  // Security Components
128
172
  RiskConfirmDialogComponent,
@@ -140,6 +184,7 @@ import { AiHotkeyProvider } from './providers/tabby/ai-hotkey.provider';
140
184
  ],
141
185
  entryComponents: [
142
186
  ChatInterfaceComponent,
187
+ AiSidebarComponent,
143
188
  RiskConfirmDialogComponent,
144
189
  PasswordPromptComponent,
145
190
  ConsentDialogComponent,
@@ -149,15 +194,53 @@ import { AiHotkeyProvider } from './providers/tabby/ai-hotkey.provider';
149
194
  })
150
195
  export default class AiAssistantModule {
151
196
  constructor(
152
- private app: any,
197
+ private app: AppService,
198
+ private config: ConfigService,
153
199
  private aiService: AiAssistantService,
154
- private config: ConfigProviderService
200
+ private sidebarService: AiSidebarService,
201
+ hotkeys: HotkeysService
155
202
  ) {
156
- // Wait for Tabby to be ready
157
- if (this.app && this.app.ready$) {
158
- this.app.ready$.subscribe(() => {
203
+ console.log('[AiAssistantModule] Module initialized');
204
+
205
+ // 等待应用就绪后初始化
206
+ this.app.ready$.subscribe(() => {
207
+ this.config.ready$.toPromise().then(() => {
208
+ // 初始化 AI 服务
159
209
  this.aiService.initialize();
210
+
211
+ // 延迟 1 秒初始化侧边栏,等待 Tabby DOM 完全准备好
212
+ // 这与 tabby-ssh-sidebar 的实现保持一致
213
+ setTimeout(() => {
214
+ this.sidebarService.initialize();
215
+ }, 1000);
160
216
  });
161
- }
217
+ });
218
+
219
+ // 订阅热键事件
220
+ hotkeys.hotkey$.subscribe(hotkey => {
221
+ if (hotkey === 'ai-assistant-toggle') {
222
+ this.sidebarService.toggle();
223
+ } else if (hotkey === 'ai-command-generation') {
224
+ // 打开侧边栏并聚焦输入
225
+ if (!this.sidebarService.sidebarVisible) {
226
+ this.sidebarService.show();
227
+ }
228
+ } else if (hotkey === 'ai-explain-command') {
229
+ // 打开侧边栏
230
+ if (!this.sidebarService.sidebarVisible) {
231
+ this.sidebarService.show();
232
+ }
233
+ }
234
+ });
162
235
  }
163
236
  }
237
+
238
+ export const forRoot = (): typeof AiAssistantModule => {
239
+ return AiAssistantModule;
240
+ };
241
+
242
+ declare const module: any;
243
+ if (typeof module !== 'undefined' && module.exports) {
244
+ module.exports.forRoot = forRoot;
245
+ module.exports.default = AiAssistantModule;
246
+ }
@@ -0,0 +1,165 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { FormsModule } from '@angular/forms';
4
+ import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
5
+
6
+ // Tabby modules
7
+ import TabbyCoreModule, { ToolbarButtonProvider, ConfigProvider, HotkeyProvider } from 'tabby-core';
8
+ import TabbyTerminalModule from 'tabby-terminal';
9
+ import { SettingsTabProvider } from 'tabby-settings';
10
+
11
+ // Core Services
12
+ import { AiAssistantService } from './services/core/ai-assistant.service';
13
+ import { AiProviderManagerService } from './services/core/ai-provider-manager.service';
14
+ import { ConfigProviderService } from './services/core/config-provider.service';
15
+ import { LoggerService } from './services/core/logger.service';
16
+
17
+ // Providers
18
+ import { BaseAiProvider } from './services/providers/base-provider.service';
19
+ import { OpenAiProviderService } from './services/providers/openai-provider.service';
20
+ import { AnthropicProviderService } from './services/providers/anthropic-provider.service';
21
+ import { MinimaxProviderService } from './services/providers/minimax-provider.service';
22
+ import { GlmProviderService } from './services/providers/glm-provider.service';
23
+ import { OpenAiCompatibleProviderService } from './services/providers/openai-compatible.service';
24
+
25
+ // Security Services
26
+ import { SecurityValidatorService } from './services/security/security-validator.service';
27
+ import { RiskAssessmentService } from './services/security/risk-assessment.service';
28
+ import { PasswordManagerService } from './services/security/password-manager.service';
29
+ import { ConsentManagerService } from './services/security/consent-manager.service';
30
+
31
+ // Chat Services
32
+ import { ChatSessionService } from './services/chat/chat-session.service';
33
+ import { ChatHistoryService } from './services/chat/chat-history.service';
34
+ import { CommandGeneratorService } from './services/chat/command-generator.service';
35
+
36
+ // Terminal Services
37
+ import { CommandAnalyzerService } from './services/terminal/command-analyzer.service';
38
+ import { ContextMenuService } from './services/terminal/context-menu.service';
39
+ import { HotkeyService } from './services/terminal/hotkey.service';
40
+
41
+ // Tabby Providers (enabled for proper integration)
42
+
43
+ // Components
44
+ import { ChatInterfaceComponent } from './components/chat/chat-interface.component';
45
+ import { ChatMessageComponent } from './components/chat/chat-message.component';
46
+ import { ChatInputComponent } from './components/chat/chat-input.component';
47
+ import { ChatSettingsComponent } from './components/chat/chat-settings.component';
48
+
49
+ import { AiSettingsTabComponent } from './components/settings/ai-settings-tab.component';
50
+ import { ProviderConfigComponent } from './components/settings/provider-config.component';
51
+ import { SecuritySettingsComponent } from './components/settings/security-settings.component';
52
+ import { GeneralSettingsComponent } from './components/settings/general-settings.component';
53
+
54
+ import { RiskConfirmDialogComponent } from './components/security/risk-confirm-dialog.component';
55
+ import { PasswordPromptComponent } from './components/security/password-prompt.component';
56
+ import { ConsentDialogComponent } from './components/security/consent-dialog.component';
57
+
58
+ import { CommandSuggestionComponent } from './components/terminal/command-suggestion.component';
59
+ import { CommandPreviewComponent } from './components/terminal/command-preview.component';
60
+ import { AiToolbarButtonComponent } from './components/terminal/ai-toolbar-button.component';
61
+
62
+ import { LoadingSpinnerComponent } from './components/common/loading-spinner.component';
63
+ import { ErrorMessageComponent } from './components/common/error-message.component';
64
+
65
+ // Tabby Integration Providers (enabled for proper integration)
66
+ import { AiToolbarButtonProvider } from './providers/tabby/ai-toolbar-button.provider';
67
+ import { AiSettingsTabProvider } from './providers/tabby/ai-settings-tab.provider';
68
+ import { AiConfigProvider } from './providers/tabby/ai-config.provider';
69
+ import { AiHotkeyProvider } from './providers/tabby/ai-hotkey.provider';
70
+
71
+ @NgModule({
72
+ imports: [
73
+ CommonModule,
74
+ FormsModule,
75
+ TabbyCoreModule, // Enabled for Tabby integration
76
+ TabbyTerminalModule, // Required for terminal integration
77
+ NgbModule
78
+ ],
79
+ providers: [
80
+ // Core Services
81
+ AiAssistantService,
82
+ AiProviderManagerService,
83
+ ConfigProviderService,
84
+ LoggerService,
85
+
86
+ // AI Providers
87
+ OpenAiProviderService,
88
+ AnthropicProviderService,
89
+ MinimaxProviderService,
90
+ GlmProviderService,
91
+ OpenAiCompatibleProviderService,
92
+
93
+ // Security Services
94
+ SecurityValidatorService,
95
+ RiskAssessmentService,
96
+ PasswordManagerService,
97
+ ConsentManagerService,
98
+
99
+ // Chat Services
100
+ ChatSessionService,
101
+ ChatHistoryService,
102
+ CommandGeneratorService,
103
+
104
+ // Terminal Services
105
+ CommandAnalyzerService,
106
+ ContextMenuService,
107
+ HotkeyService,
108
+
109
+ // Tabby Integration Providers (enabled for proper integration)
110
+ { provide: ToolbarButtonProvider, useClass: AiToolbarButtonProvider, multi: true },
111
+ { provide: SettingsTabProvider, useClass: AiSettingsTabProvider, multi: true },
112
+ { provide: ConfigProvider, useClass: AiConfigProvider, multi: true },
113
+ { provide: HotkeyProvider, useClass: AiHotkeyProvider, multi: true },
114
+ // { provide: TabContextMenuItemProvider, useClass: AiContextMenuProvider, multi: true }
115
+ ],
116
+ declarations: [
117
+ // Chat Components
118
+ ChatInterfaceComponent,
119
+ ChatMessageComponent,
120
+ ChatInputComponent,
121
+ ChatSettingsComponent,
122
+
123
+ // Settings Components
124
+ AiSettingsTabComponent,
125
+ ProviderConfigComponent,
126
+ SecuritySettingsComponent,
127
+ GeneralSettingsComponent,
128
+
129
+ // Security Components
130
+ RiskConfirmDialogComponent,
131
+ PasswordPromptComponent,
132
+ ConsentDialogComponent,
133
+
134
+ // Terminal Components
135
+ CommandSuggestionComponent,
136
+ CommandPreviewComponent,
137
+ AiToolbarButtonComponent,
138
+
139
+ // Common Components
140
+ LoadingSpinnerComponent,
141
+ ErrorMessageComponent
142
+ ],
143
+ entryComponents: [
144
+ ChatInterfaceComponent,
145
+ RiskConfirmDialogComponent,
146
+ PasswordPromptComponent,
147
+ ConsentDialogComponent,
148
+ CommandSuggestionComponent,
149
+ CommandPreviewComponent
150
+ ]
151
+ })
152
+ export default class AiAssistantModule {
153
+ constructor(
154
+ private app: any,
155
+ private aiService: AiAssistantService,
156
+ private config: ConfigProviderService
157
+ ) {
158
+ // Wait for Tabby to be ready
159
+ if (this.app && this.app.ready$) {
160
+ this.app.ready$.subscribe(() => {
161
+ this.aiService.initialize();
162
+ });
163
+ }
164
+ }
165
+ }
@@ -1,5 +1,5 @@
1
1
  import { Injectable } from '@angular/core';
2
- import { ConfigProvider } from 'tabby-core';
2
+ import { ConfigProvider, Platform } from 'tabby-core';
3
3
  import { ConfigProviderService } from '../../services/core/config-provider.service';
4
4
 
5
5
  /**
@@ -8,63 +8,72 @@ import { ConfigProviderService } from '../../services/core/config-provider.servi
8
8
  */
9
9
  @Injectable()
10
10
  export class AiConfigProvider extends ConfigProvider {
11
- constructor(
12
- private configService: ConfigProviderService
13
- ) {
14
- super();
15
- }
16
-
17
11
  /**
18
- * 提供配置项定义
12
+ * 默认配置
19
13
  */
20
- provideConfig(): any {
21
- return {
22
- aiAssistant: {
23
- enabled: true,
24
- defaultProvider: 'openai',
25
- autoSuggestCommands: true,
26
- enableSecurityChecks: true,
27
- providers: {
28
- openai: {
29
- apiKey: '',
30
- model: 'gpt-3.5-turbo',
31
- baseURL: 'https://api.openai.com/v1'
32
- },
33
- anthropic: {
34
- apiKey: '',
35
- model: 'claude-3-sonnet',
36
- baseURL: 'https://api.anthropic.com'
37
- },
38
- minimax: {
39
- apiKey: '',
40
- model: 'abab6.5s-chat',
41
- baseURL: 'https://api.minimaxi.com/anthropic'
42
- },
43
- glm: {
44
- apiKey: '',
45
- model: 'glm-4.6',
46
- baseURL: 'https://open.bigmodel.cn/api/anthropic'
47
- },
48
- openaiCompatible: {
49
- apiKey: '',
50
- model: 'gpt-3.5-turbo',
51
- baseURL: ''
52
- }
14
+ defaults = {
15
+ hotkeys: {
16
+ 'ai-assistant-toggle': ['Ctrl-Shift-A'],
17
+ 'ai-command-generation': ['Ctrl-Shift-G'],
18
+ 'ai-explain-command': ['Ctrl-Shift-E'],
19
+ },
20
+ aiAssistant: {
21
+ enabled: true,
22
+ defaultProvider: 'openai',
23
+ autoSuggestCommands: true,
24
+ enableSecurityChecks: true,
25
+ providers: {
26
+ openai: {
27
+ apiKey: '',
28
+ model: 'gpt-3.5-turbo',
29
+ baseURL: 'https://api.openai.com/v1'
30
+ },
31
+ anthropic: {
32
+ apiKey: '',
33
+ model: 'claude-3-sonnet',
34
+ baseURL: 'https://api.anthropic.com'
35
+ },
36
+ minimax: {
37
+ apiKey: '',
38
+ model: 'MiniMax-M2',
39
+ baseURL: 'https://api.minimaxi.com/anthropic'
40
+ },
41
+ glm: {
42
+ apiKey: '',
43
+ model: 'glm-4',
44
+ baseURL: 'https://open.bigmodel.cn/api/paas/v4'
53
45
  },
54
- security: {
55
- passwordProtection: false,
56
- riskAssessmentLevel: 'medium',
57
- consentPersistenceDays: 30
46
+ openaiCompatible: {
47
+ apiKey: '',
48
+ model: 'gpt-3.5-turbo',
49
+ baseURL: ''
58
50
  }
51
+ },
52
+ security: {
53
+ passwordProtection: false,
54
+ riskAssessmentLevel: 'medium',
55
+ consentPersistenceDays: 30
59
56
  }
60
- };
61
- }
57
+ }
58
+ };
62
59
 
63
60
  /**
64
- * 配置就绪后的处理
61
+ * 平台特定默认配置
65
62
  */
66
- async onConfigLoaded(): Promise<void> {
67
- // 配置已自动加载,无需手动调用
68
- console.log('[AI Config Provider] Configuration loaded');
63
+ platformDefaults = {
64
+ [Platform.macOS]: {
65
+ hotkeys: {
66
+ 'ai-assistant-toggle': ['⌘-Shift-A'],
67
+ 'ai-command-generation': ['⌘-Shift-G'],
68
+ 'ai-explain-command': ['⌘-Shift-E'],
69
+ }
70
+ }
71
+ };
72
+
73
+ constructor(
74
+ private configService: ConfigProviderService
75
+ ) {
76
+ super();
69
77
  }
70
78
  }
79
+
@@ -1,55 +1,39 @@
1
1
  import { Injectable } from '@angular/core';
2
- import { HotkeyProvider, HotkeyDescription } from 'tabby-core';
3
- import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
4
- import { AiAssistantService } from '../../services/core/ai-assistant.service';
5
- import { ChatInterfaceComponent } from '../../components/chat/chat-interface.component';
2
+ import { HotkeyProvider, HotkeyDescription, TranslateService } from 'tabby-core';
3
+ import { AiSidebarService } from '../../services/chat/ai-sidebar.service';
6
4
 
7
5
  /**
8
6
  * Tabby热键提供者
9
7
  * 为Tabby添加AI助手热键支持
8
+ *
9
+ * 注意:热键 ID 必须与 AiConfigProvider.defaults.hotkeys 中定义的一致
10
10
  */
11
11
  @Injectable()
12
12
  export class AiHotkeyProvider extends HotkeyProvider {
13
+ hotkeys: HotkeyDescription[] = [
14
+ {
15
+ id: 'ai-assistant-toggle',
16
+ name: '打开AI助手',
17
+ },
18
+ {
19
+ id: 'ai-command-generation',
20
+ name: '生成命令',
21
+ },
22
+ {
23
+ id: 'ai-explain-command',
24
+ name: '解释命令',
25
+ }
26
+ ];
27
+
13
28
  constructor(
14
- private modal: NgbModal,
15
- private aiService: AiAssistantService
29
+ private sidebarService: AiSidebarService,
30
+ private translate: TranslateService
16
31
  ) {
17
32
  super();
18
33
  }
19
34
 
20
35
  async provide(): Promise<HotkeyDescription[]> {
21
- return [
22
- {
23
- id: 'ai-assistant-chat',
24
- name: 'Open AI Assistant Chat'
25
- },
26
- {
27
- id: 'ai-command-generation',
28
- name: 'Generate Command from Natural Language'
29
- }
30
- ];
31
- }
32
-
33
- /**
34
- * 打开AI聊天界面
35
- */
36
- private openAiChat(): void {
37
- this.modal.open(ChatInterfaceComponent, {
38
- size: 'xl',
39
- backdrop: true,
40
- keyboard: true
41
- });
42
- }
43
-
44
- /**
45
- * 打开命令生成功能
46
- */
47
- private openCommandGeneration(): void {
48
- this.modal.open(ChatInterfaceComponent, {
49
- size: 'lg',
50
- backdrop: true,
51
- keyboard: true
52
- });
53
- // 可以添加特定的初始化逻辑,比如预填充命令生成提示
36
+ return this.hotkeys;
54
37
  }
55
38
  }
39
+
@@ -9,8 +9,8 @@ import { AiSettingsTabComponent } from '../../components/settings/ai-settings-ta
9
9
  @Injectable()
10
10
  export class AiSettingsTabProvider extends SettingsTabProvider {
11
11
  id = 'ai-assistant';
12
- icon = 'bi-robot';
13
- title = 'AI Assistant';
12
+ icon = 'fa fa-robot';
13
+ title = 'AI 助手';
14
14
 
15
15
  getComponentType(): any {
16
16
  return AiSettingsTabComponent;
@@ -1,49 +1,54 @@
1
1
  import { Injectable } from '@angular/core';
2
- import { ToolbarButtonProvider, ToolbarButton } from 'tabby-core';
3
- import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
4
- import { AiAssistantService } from '../../services/core/ai-assistant.service';
5
- import { ChatInterfaceComponent } from '../../components/chat/chat-interface.component';
2
+ import { ToolbarButtonProvider, ToolbarButton, AppService } from 'tabby-core';
3
+ import { AiSidebarService } from '../../services/chat/ai-sidebar.service';
6
4
 
7
5
  /**
8
6
  * Tabby工具栏按钮提供者
9
- * 为Tabby工具栏添加AI助手按钮
7
+ * 为Tabby工具栏添加AI助手按钮,使用侧边栏方式
10
8
  */
11
9
  @Injectable()
12
10
  export class AiToolbarButtonProvider extends ToolbarButtonProvider {
11
+
13
12
  constructor(
14
- private modal: NgbModal,
15
- private aiService: AiAssistantService
13
+ private app: AppService,
14
+ private sidebarService: AiSidebarService
16
15
  ) {
17
16
  super();
18
17
  }
19
18
 
20
19
  provide(): ToolbarButton[] {
21
- const aiIcon = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-robot" viewBox="0 0 16 16">
22
- <path d="M6 12.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5M4 14a.5.5 0 0 1-.5-.5v-2a.5.5 0 0 1 1 0v2a.5.5 0 0 1-.5.5m0 1a1.5 1.5 0 0 0-1.5 1.5v2a1.5 1.5 0 0 0 3 0v-2A1.5 1.5 0 0 0 4 15"/>
23
- <path d="M8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0m3 2a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1 0-1h3a.5.5 0 0 1 .5.5M11 7.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5M12 8.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5M13 9.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5"/>
24
- <path d="M16 6.5a.5.5 0 0 1-.5-.5v-2a.5.5 0 0 0-1 0v2a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1 0-1h3a1.5 1.5 0 0 0 1.5-1.5v-2a1.5 1.5 0 0 0-3 0v2a.5.5 0 0 1-.5.5z"/>
25
- </svg>`;
26
-
27
20
  return [
28
21
  {
29
- icon: aiIcon,
22
+ icon: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
23
+ <path d="M6 12.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5ZM3 8.062C3 6.76 4.235 5.765 5.53 5.886a26.58 26.58 0 0 0 4.94 0C11.765 5.765 13 6.76 13 8.062v1.157a.933.933 0 0 1-.765.935c-.845.147-2.34.346-4.235.346-1.895 0-3.39-.2-4.235-.346A.933.933 0 0 1 3 9.219V8.062Zm4.542-.827a.25.25 0 0 0-.217.068l-.92.9a24.767 24.767 0 0 1-1.871-.183.25.25 0 0 0-.068.495c.55.076 1.232.149 2.02.193a.25.25 0 0 0 .189-.071l.754-.736.847 1.71a.25.25 0 0 0 .404.062l.932-.97a25.286 25.286 0 0 0 1.922-.188.25.25 0 0 0-.068-.495c-.538.074-1.207.145-1.98.189a.25.25 0 0 0-.166.076l-.754.785-.842-1.7a.25.25 0 0 0-.182-.135Z"/>
24
+ <path d="M8.5 1.866a1 1 0 1 0-1 0V3h-2A4.5 4.5 0 0 0 1 7.5V8a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1v1a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-1a1 1 0 0 0 1-1V9a1 1 0 0 0-1-1v-.5A4.5 4.5 0 0 0 10.5 3h-2V1.866ZM14 7.5V13a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V7.5A3.5 3.5 0 0 1 5.5 4h5A3.5 3.5 0 0 1 14 7.5Z"/>
25
+ </svg>`,
30
26
  weight: 100,
31
- title: 'AI Assistant',
27
+ title: 'AI 助手',
28
+ touchBarTitle: 'AI',
32
29
  click: () => {
33
- this.openAiChat();
34
- }
30
+ this.sidebarService.toggle();
31
+ },
32
+ submenu: async () => [
33
+ {
34
+ title: this.sidebarService.visible ? '隐藏侧边栏' : '显示侧边栏',
35
+ click: () => this.sidebarService.toggle()
36
+ },
37
+ {
38
+ title: '设置...',
39
+ click: () => this.openSettings()
40
+ }
41
+ ]
35
42
  }
36
43
  ];
37
44
  }
38
45
 
39
46
  /**
40
- * 打开AI聊天界面
47
+ * 打开设置页面
41
48
  */
42
- private openAiChat(): void {
43
- this.modal.open(ChatInterfaceComponent, {
44
- size: 'xl',
45
- backdrop: true,
46
- keyboard: true
47
- });
49
+ private openSettings(): void {
50
+ // TODO: 实现打开设置页面的逻辑
51
+ // 可以通过事件或服务来触发设置页面显示
52
+ console.log('Opening AI settings...');
48
53
  }
49
54
  }