tabby-ai-assistant 1.0.0

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 (134) hide show
  1. package/README.md +232 -0
  2. package/dist/components/chat/chat-input.component.d.ts +65 -0
  3. package/dist/components/chat/chat-interface.component.d.ts +71 -0
  4. package/dist/components/chat/chat-message.component.d.ts +53 -0
  5. package/dist/components/chat/chat-settings.component.d.ts +62 -0
  6. package/dist/components/common/error-message.component.d.ts +11 -0
  7. package/dist/components/common/loading-spinner.component.d.ts +4 -0
  8. package/dist/components/security/consent-dialog.component.d.ts +11 -0
  9. package/dist/components/security/password-prompt.component.d.ts +10 -0
  10. package/dist/components/security/risk-confirm-dialog.component.d.ts +36 -0
  11. package/dist/components/settings/ai-settings-tab.component.d.ts +72 -0
  12. package/dist/components/settings/general-settings.component.d.ts +60 -0
  13. package/dist/components/settings/provider-config.component.d.ts +182 -0
  14. package/dist/components/settings/security-settings.component.d.ts +23 -0
  15. package/dist/components/terminal/ai-toolbar-button.component.d.ts +10 -0
  16. package/dist/components/terminal/command-preview.component.d.ts +15 -0
  17. package/dist/components/terminal/command-suggestion.component.d.ts +16 -0
  18. package/dist/index.d.ts +8 -0
  19. package/dist/index.js +2 -0
  20. package/dist/index.js.LICENSE.txt +18 -0
  21. package/dist/main.d.ts +8 -0
  22. package/dist/providers/tabby/ai-config.provider.d.ts +18 -0
  23. package/dist/providers/tabby/ai-hotkey.provider.d.ts +21 -0
  24. package/dist/providers/tabby/ai-settings-tab.provider.d.ts +11 -0
  25. package/dist/providers/tabby/ai-toolbar-button.provider.d.ts +17 -0
  26. package/dist/services/chat/chat-history.service.d.ts +67 -0
  27. package/dist/services/chat/chat-session.service.d.ts +58 -0
  28. package/dist/services/chat/command-generator.service.d.ts +49 -0
  29. package/dist/services/core/ai-assistant.service.d.ts +88 -0
  30. package/dist/services/core/ai-provider-manager.service.d.ts +119 -0
  31. package/dist/services/core/config-provider.service.d.ts +137 -0
  32. package/dist/services/core/logger.service.d.ts +21 -0
  33. package/dist/services/providers/anthropic-provider.service.d.ts +39 -0
  34. package/dist/services/providers/base-provider.service.d.ts +137 -0
  35. package/dist/services/providers/glm-provider.service.d.ts +91 -0
  36. package/dist/services/providers/minimax-provider.service.d.ts +93 -0
  37. package/dist/services/providers/openai-compatible.service.d.ts +39 -0
  38. package/dist/services/providers/openai-provider.service.d.ts +38 -0
  39. package/dist/services/security/consent-manager.service.d.ts +65 -0
  40. package/dist/services/security/password-manager.service.d.ts +67 -0
  41. package/dist/services/security/risk-assessment.service.d.ts +65 -0
  42. package/dist/services/security/security-validator.service.d.ts +36 -0
  43. package/dist/services/terminal/command-analyzer.service.d.ts +20 -0
  44. package/dist/services/terminal/context-menu.service.d.ts +24 -0
  45. package/dist/services/terminal/hotkey.service.d.ts +28 -0
  46. package/dist/services/terminal/terminal-context.service.d.ts +100 -0
  47. package/dist/types/ai.types.d.ts +107 -0
  48. package/dist/types/provider.types.d.ts +105 -0
  49. package/dist/types/security.types.d.ts +85 -0
  50. package/dist/types/terminal.types.d.ts +150 -0
  51. package/dist/utils/encryption.utils.d.ts +83 -0
  52. package/dist/utils/formatting.utils.d.ts +106 -0
  53. package/dist/utils/validation.utils.d.ts +83 -0
  54. package/integration-test-output.txt +50 -0
  55. package/integration-tests/api-integration.test.ts +183 -0
  56. package/jest.config.js +47 -0
  57. package/package.json +73 -0
  58. package/setup-jest.ts +37 -0
  59. package/src/components/chat/chat-input.component.html +61 -0
  60. package/src/components/chat/chat-input.component.scss +183 -0
  61. package/src/components/chat/chat-input.component.ts +149 -0
  62. package/src/components/chat/chat-interface.component.html +119 -0
  63. package/src/components/chat/chat-interface.component.scss +354 -0
  64. package/src/components/chat/chat-interface.component.ts +224 -0
  65. package/src/components/chat/chat-message.component.html +65 -0
  66. package/src/components/chat/chat-message.component.scss +178 -0
  67. package/src/components/chat/chat-message.component.ts +93 -0
  68. package/src/components/chat/chat-settings.component.html +132 -0
  69. package/src/components/chat/chat-settings.component.scss +172 -0
  70. package/src/components/chat/chat-settings.component.ts +168 -0
  71. package/src/components/common/error-message.component.ts +124 -0
  72. package/src/components/common/loading-spinner.component.ts +72 -0
  73. package/src/components/security/consent-dialog.component.ts +77 -0
  74. package/src/components/security/password-prompt.component.ts +79 -0
  75. package/src/components/security/risk-confirm-dialog.component.html +87 -0
  76. package/src/components/security/risk-confirm-dialog.component.scss +360 -0
  77. package/src/components/security/risk-confirm-dialog.component.ts +96 -0
  78. package/src/components/settings/ai-settings-tab.component.html +140 -0
  79. package/src/components/settings/ai-settings-tab.component.scss +371 -0
  80. package/src/components/settings/ai-settings-tab.component.ts +193 -0
  81. package/src/components/settings/general-settings.component.html +103 -0
  82. package/src/components/settings/general-settings.component.scss +285 -0
  83. package/src/components/settings/general-settings.component.ts +123 -0
  84. package/src/components/settings/provider-config.component.html +95 -0
  85. package/src/components/settings/provider-config.component.scss +60 -0
  86. package/src/components/settings/provider-config.component.ts +206 -0
  87. package/src/components/settings/security-settings.component.html +51 -0
  88. package/src/components/settings/security-settings.component.scss +66 -0
  89. package/src/components/settings/security-settings.component.ts +71 -0
  90. package/src/components/terminal/ai-toolbar-button.component.ts +49 -0
  91. package/src/components/terminal/command-preview.component.ts +185 -0
  92. package/src/components/terminal/command-suggestion.component.ts +128 -0
  93. package/src/index.ts +163 -0
  94. package/src/main.ts +16 -0
  95. package/src/providers/tabby/ai-config.provider.ts +70 -0
  96. package/src/providers/tabby/ai-hotkey.provider.ts +55 -0
  97. package/src/providers/tabby/ai-settings-tab.provider.ts +18 -0
  98. package/src/providers/tabby/ai-toolbar-button.provider.ts +49 -0
  99. package/src/services/chat/chat-history.service.ts +239 -0
  100. package/src/services/chat/chat-session.service.spec.ts +249 -0
  101. package/src/services/chat/chat-session.service.ts +180 -0
  102. package/src/services/chat/command-generator.service.ts +301 -0
  103. package/src/services/core/ai-assistant.service.ts +334 -0
  104. package/src/services/core/ai-provider-manager.service.ts +314 -0
  105. package/src/services/core/config-provider.service.ts +347 -0
  106. package/src/services/core/logger.service.ts +104 -0
  107. package/src/services/providers/anthropic-provider.service.ts +373 -0
  108. package/src/services/providers/base-provider.service.ts +369 -0
  109. package/src/services/providers/glm-provider.service.ts +467 -0
  110. package/src/services/providers/minimax-provider.service.ts +427 -0
  111. package/src/services/providers/openai-compatible.service.ts +394 -0
  112. package/src/services/providers/openai-provider.service.ts +376 -0
  113. package/src/services/security/consent-manager.service.ts +332 -0
  114. package/src/services/security/password-manager.service.ts +188 -0
  115. package/src/services/security/risk-assessment.service.ts +340 -0
  116. package/src/services/security/security-validator.service.ts +143 -0
  117. package/src/services/terminal/command-analyzer.service.ts +43 -0
  118. package/src/services/terminal/context-menu.service.ts +45 -0
  119. package/src/services/terminal/hotkey.service.ts +53 -0
  120. package/src/services/terminal/terminal-context.service.ts +317 -0
  121. package/src/styles/ai-assistant.scss +449 -0
  122. package/src/types/ai.types.ts +133 -0
  123. package/src/types/provider.types.ts +147 -0
  124. package/src/types/security.types.ts +103 -0
  125. package/src/types/terminal.types.ts +186 -0
  126. package/src/utils/encryption.utils.spec.ts +250 -0
  127. package/src/utils/encryption.utils.ts +271 -0
  128. package/src/utils/formatting.utils.ts +359 -0
  129. package/src/utils/validation.utils.spec.ts +225 -0
  130. package/src/utils/validation.utils.ts +314 -0
  131. package/tsconfig.json +45 -0
  132. package/webpack-docker.config.js +42 -0
  133. package/webpack.config.js +59 -0
  134. package/webpack.config.js.backup +57 -0
@@ -0,0 +1,128 @@
1
+ import { Component, Input, Output, EventEmitter, OnInit, OnDestroy } from '@angular/core';
2
+ import { Subject } from 'rxjs';
3
+ import { debounceTime, takeUntil } from 'rxjs/operators';
4
+ import { CommandResponse } from '../../types/ai.types';
5
+
6
+ @Component({
7
+ selector: 'app-command-suggestion',
8
+ template: `
9
+ <div class="command-suggestion" *ngIf="suggestions.length > 0">
10
+ <div class="suggestion-header">
11
+ <i class="icon-lightbulb"></i>
12
+ <span>AI命令建议</span>
13
+ <button class="btn-close" (click)="close()">
14
+ <i class="icon-x"></i>
15
+ </button>
16
+ </div>
17
+ <div class="suggestion-list">
18
+ <div
19
+ *ngFor="let suggestion of suggestions"
20
+ class="suggestion-item"
21
+ (click)="selectSuggestion(suggestion)">
22
+ <div class="suggestion-command">
23
+ <code>{{ suggestion.command }}</code>
24
+ </div>
25
+ <div class="suggestion-explanation">
26
+ {{ suggestion.explanation }}
27
+ </div>
28
+ <div class="suggestion-confidence">
29
+ <span class="confidence-bar" [style.width.%]="suggestion.confidence * 100"></span>
30
+ <span class="confidence-text">{{ (suggestion.confidence * 100).toFixed(0) }}%</span>
31
+ </div>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ `,
36
+ styles: [`
37
+ .command-suggestion {
38
+ background: var(--ai-bg-primary);
39
+ border: 1px solid var(--ai-border);
40
+ border-radius: 0.5rem;
41
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
42
+ max-width: 600px;
43
+ margin: 0.5rem auto;
44
+ }
45
+ .suggestion-header {
46
+ display: flex;
47
+ align-items: center;
48
+ gap: 0.5rem;
49
+ padding: 0.75rem 1rem;
50
+ background: var(--ai-bg-secondary);
51
+ border-bottom: 1px solid var(--ai-border);
52
+ }
53
+ .suggestion-list {
54
+ max-height: 300px;
55
+ overflow-y: auto;
56
+ }
57
+ .suggestion-item {
58
+ padding: 1rem;
59
+ border-bottom: 1px solid var(--ai-border);
60
+ cursor: pointer;
61
+ transition: background-color 0.2s;
62
+ }
63
+ .suggestion-item:hover {
64
+ background-color: var(--ai-bg-secondary);
65
+ }
66
+ .suggestion-item:last-child {
67
+ border-bottom: none;
68
+ }
69
+ .suggestion-command {
70
+ font-family: monospace;
71
+ margin-bottom: 0.5rem;
72
+ }
73
+ .suggestion-confidence {
74
+ display: flex;
75
+ align-items: center;
76
+ gap: 0.5rem;
77
+ margin-top: 0.5rem;
78
+ }
79
+ .confidence-bar {
80
+ height: 4px;
81
+ background: var(--ai-primary);
82
+ border-radius: 2px;
83
+ }
84
+ `]
85
+ })
86
+ export class CommandSuggestionComponent implements OnInit, OnDestroy {
87
+ @Input() inputText = '';
88
+ @Output() suggestionSelected = new EventEmitter<CommandResponse>();
89
+ @Output() closed = new EventEmitter<void>();
90
+
91
+ suggestions: CommandResponse[] = [];
92
+ private inputSubject = new Subject<string>();
93
+ private destroy$ = new Subject<void>();
94
+
95
+ ngOnInit(): void {
96
+ this.inputSubject.pipe(
97
+ debounceTime(500),
98
+ takeUntil(this.destroy$)
99
+ ).subscribe(text => {
100
+ this.generateSuggestions(text);
101
+ });
102
+ }
103
+
104
+ ngOnDestroy(): void {
105
+ this.destroy$.next();
106
+ this.destroy$.complete();
107
+ }
108
+
109
+ onInputChange(text: string): void {
110
+ this.inputSubject.next(text);
111
+ }
112
+
113
+ private generateSuggestions(text: string): void {
114
+ // TODO: 调用AI生成建议
115
+ // 这里应该调用CommandGeneratorService
116
+ this.suggestions = [];
117
+ }
118
+
119
+ selectSuggestion(suggestion: CommandResponse): void {
120
+ this.suggestionSelected.emit(suggestion);
121
+ this.close();
122
+ }
123
+
124
+ close(): void {
125
+ this.closed.emit();
126
+ this.suggestions = [];
127
+ }
128
+ }
package/src/index.ts ADDED
@@ -0,0 +1,163 @@
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
+
53
+ import { RiskConfirmDialogComponent } from './components/security/risk-confirm-dialog.component';
54
+ import { PasswordPromptComponent } from './components/security/password-prompt.component';
55
+ import { ConsentDialogComponent } from './components/security/consent-dialog.component';
56
+
57
+ import { CommandSuggestionComponent } from './components/terminal/command-suggestion.component';
58
+ import { CommandPreviewComponent } from './components/terminal/command-preview.component';
59
+ import { AiToolbarButtonComponent } from './components/terminal/ai-toolbar-button.component';
60
+
61
+ import { LoadingSpinnerComponent } from './components/common/loading-spinner.component';
62
+ import { ErrorMessageComponent } from './components/common/error-message.component';
63
+
64
+ // Tabby Integration Providers (enabled for proper integration)
65
+ import { AiToolbarButtonProvider } from './providers/tabby/ai-toolbar-button.provider';
66
+ import { AiSettingsTabProvider } from './providers/tabby/ai-settings-tab.provider';
67
+ import { AiConfigProvider } from './providers/tabby/ai-config.provider';
68
+ import { AiHotkeyProvider } from './providers/tabby/ai-hotkey.provider';
69
+
70
+ @NgModule({
71
+ imports: [
72
+ CommonModule,
73
+ FormsModule,
74
+ TabbyCoreModule, // Enabled for Tabby integration
75
+ TabbyTerminalModule, // Required for terminal integration
76
+ NgbModule
77
+ ],
78
+ providers: [
79
+ // Core Services
80
+ AiAssistantService,
81
+ AiProviderManagerService,
82
+ ConfigProviderService,
83
+ LoggerService,
84
+
85
+ // AI Providers
86
+ OpenAiProviderService,
87
+ AnthropicProviderService,
88
+ MinimaxProviderService,
89
+ GlmProviderService,
90
+ OpenAiCompatibleProviderService,
91
+
92
+ // Security Services
93
+ SecurityValidatorService,
94
+ RiskAssessmentService,
95
+ PasswordManagerService,
96
+ ConsentManagerService,
97
+
98
+ // Chat Services
99
+ ChatSessionService,
100
+ ChatHistoryService,
101
+ CommandGeneratorService,
102
+
103
+ // Terminal Services
104
+ CommandAnalyzerService,
105
+ ContextMenuService,
106
+ HotkeyService,
107
+
108
+ // Tabby Integration Providers (enabled for proper integration)
109
+ { provide: ToolbarButtonProvider, useClass: AiToolbarButtonProvider, multi: true },
110
+ { provide: SettingsTabProvider, useClass: AiSettingsTabProvider, multi: true },
111
+ { provide: ConfigProvider, useClass: AiConfigProvider, multi: true },
112
+ { provide: HotkeyProvider, useClass: AiHotkeyProvider, multi: true },
113
+ // { provide: TabContextMenuItemProvider, useClass: AiContextMenuProvider, multi: true }
114
+ ],
115
+ declarations: [
116
+ // Chat Components
117
+ ChatInterfaceComponent,
118
+ ChatMessageComponent,
119
+ ChatInputComponent,
120
+ ChatSettingsComponent,
121
+
122
+ // Settings Components
123
+ AiSettingsTabComponent,
124
+ ProviderConfigComponent,
125
+ SecuritySettingsComponent,
126
+
127
+ // Security Components
128
+ RiskConfirmDialogComponent,
129
+ PasswordPromptComponent,
130
+ ConsentDialogComponent,
131
+
132
+ // Terminal Components
133
+ CommandSuggestionComponent,
134
+ CommandPreviewComponent,
135
+ AiToolbarButtonComponent,
136
+
137
+ // Common Components
138
+ LoadingSpinnerComponent,
139
+ ErrorMessageComponent
140
+ ],
141
+ entryComponents: [
142
+ ChatInterfaceComponent,
143
+ RiskConfirmDialogComponent,
144
+ PasswordPromptComponent,
145
+ ConsentDialogComponent,
146
+ CommandSuggestionComponent,
147
+ CommandPreviewComponent
148
+ ]
149
+ })
150
+ export default class AiAssistantModule {
151
+ constructor(
152
+ private app: any,
153
+ private aiService: AiAssistantService,
154
+ private config: ConfigProviderService
155
+ ) {
156
+ // Wait for Tabby to be ready
157
+ if (this.app && this.app.ready$) {
158
+ this.app.ready$.subscribe(() => {
159
+ this.aiService.initialize();
160
+ });
161
+ }
162
+ }
163
+ }
package/src/main.ts ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Tabby AI Assistant Plugin - Main Entry Point
3
+ *
4
+ * This file serves as the main entry point for the Tabby AI Assistant plugin.
5
+ * It initializes the Angular module and integrates with Tabby's plugin system.
6
+ */
7
+
8
+ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
9
+ import AiAssistantModule from './index';
10
+
11
+ // Bootstrap the Angular application
12
+ platformBrowserDynamic()
13
+ .bootstrapModule(AiAssistantModule)
14
+ .catch(err => console.error('Error starting Tabby AI Assistant:', err));
15
+
16
+ export default AiAssistantModule;
@@ -0,0 +1,70 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { ConfigProvider } from 'tabby-core';
3
+ import { ConfigProviderService } from '../../services/core/config-provider.service';
4
+
5
+ /**
6
+ * Tabby配置提供者
7
+ * 为Tabby提供AI助手配置管理
8
+ */
9
+ @Injectable()
10
+ export class AiConfigProvider extends ConfigProvider {
11
+ constructor(
12
+ private configService: ConfigProviderService
13
+ ) {
14
+ super();
15
+ }
16
+
17
+ /**
18
+ * 提供配置项定义
19
+ */
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
+ }
53
+ },
54
+ security: {
55
+ passwordProtection: false,
56
+ riskAssessmentLevel: 'medium',
57
+ consentPersistenceDays: 30
58
+ }
59
+ }
60
+ };
61
+ }
62
+
63
+ /**
64
+ * 配置就绪后的处理
65
+ */
66
+ async onConfigLoaded(): Promise<void> {
67
+ // 配置已自动加载,无需手动调用
68
+ console.log('[AI Config Provider] Configuration loaded');
69
+ }
70
+ }
@@ -0,0 +1,55 @@
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';
6
+
7
+ /**
8
+ * Tabby热键提供者
9
+ * 为Tabby添加AI助手热键支持
10
+ */
11
+ @Injectable()
12
+ export class AiHotkeyProvider extends HotkeyProvider {
13
+ constructor(
14
+ private modal: NgbModal,
15
+ private aiService: AiAssistantService
16
+ ) {
17
+ super();
18
+ }
19
+
20
+ 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
+ // 可以添加特定的初始化逻辑,比如预填充命令生成提示
54
+ }
55
+ }
@@ -0,0 +1,18 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { SettingsTabProvider } from 'tabby-settings';
3
+ import { AiSettingsTabComponent } from '../../components/settings/ai-settings-tab.component';
4
+
5
+ /**
6
+ * Tabby设置页面提供者
7
+ * 为Tabby添加AI助手设置页面
8
+ */
9
+ @Injectable()
10
+ export class AiSettingsTabProvider extends SettingsTabProvider {
11
+ id = 'ai-assistant';
12
+ icon = 'bi-robot';
13
+ title = 'AI Assistant';
14
+
15
+ getComponentType(): any {
16
+ return AiSettingsTabComponent;
17
+ }
18
+ }
@@ -0,0 +1,49 @@
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';
6
+
7
+ /**
8
+ * Tabby工具栏按钮提供者
9
+ * 为Tabby工具栏添加AI助手按钮
10
+ */
11
+ @Injectable()
12
+ export class AiToolbarButtonProvider extends ToolbarButtonProvider {
13
+ constructor(
14
+ private modal: NgbModal,
15
+ private aiService: AiAssistantService
16
+ ) {
17
+ super();
18
+ }
19
+
20
+ 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
+ return [
28
+ {
29
+ icon: aiIcon,
30
+ weight: 100,
31
+ title: 'AI Assistant',
32
+ click: () => {
33
+ this.openAiChat();
34
+ }
35
+ }
36
+ ];
37
+ }
38
+
39
+ /**
40
+ * 打开AI聊天界面
41
+ */
42
+ private openAiChat(): void {
43
+ this.modal.open(ChatInterfaceComponent, {
44
+ size: 'xl',
45
+ backdrop: true,
46
+ keyboard: true
47
+ });
48
+ }
49
+ }