@theia/ai-editor 1.63.0-next.24
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.
- package/lib/browser/ai-editor-command-contribution.d.ts +18 -0
- package/lib/browser/ai-editor-command-contribution.d.ts.map +1 -0
- package/lib/browser/ai-editor-command-contribution.js +85 -0
- package/lib/browser/ai-editor-command-contribution.js.map +1 -0
- package/lib/browser/ai-editor-context-variable.d.ts +13 -0
- package/lib/browser/ai-editor-context-variable.d.ts.map +1 -0
- package/lib/browser/ai-editor-context-variable.js +104 -0
- package/lib/browser/ai-editor-context-variable.js.map +1 -0
- package/lib/browser/ai-editor-frontend-module.d.ts +5 -0
- package/lib/browser/ai-editor-frontend-module.d.ts.map +1 -0
- package/lib/browser/ai-editor-frontend-module.js +30 -0
- package/lib/browser/ai-editor-frontend-module.js.map +1 -0
- package/lib/browser/ask-ai-input-widget.d.ts +26 -0
- package/lib/browser/ask-ai-input-widget.d.ts.map +1 -0
- package/lib/browser/ask-ai-input-widget.js +101 -0
- package/lib/browser/ask-ai-input-widget.js.map +1 -0
- package/lib/browser/index.d.ts +3 -0
- package/lib/browser/index.d.ts.map +1 -0
- package/lib/browser/index.js +21 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +26 -0
- package/lib/package.spec.js.map +1 -0
- package/package.json +57 -0
- package/src/browser/ai-editor-command-contribution.ts +91 -0
- package/src/browser/ai-editor-context-variable.ts +110 -0
- package/src/browser/ai-editor-frontend-module.ts +31 -0
- package/src/browser/ask-ai-input-widget.ts +127 -0
- package/src/browser/index.ts +18 -0
- package/src/package.spec.ts +28 -0
- package/style/ask-ai-input.css +41 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MenuContribution, MenuModelRegistry } from '@theia/core';
|
|
2
|
+
import { Command, CommandContribution, CommandRegistry } from '@theia/core/lib/common';
|
|
3
|
+
import { MonacoCommandRegistry, MonacoEditorCommandHandler } from '@theia/monaco/lib/browser/monaco-command-registry';
|
|
4
|
+
import { ChatService } from '@theia/ai-chat';
|
|
5
|
+
export declare namespace AI_EDITOR_COMMANDS {
|
|
6
|
+
const AI_EDITOR_ASK_AI: Command;
|
|
7
|
+
}
|
|
8
|
+
export declare class AiEditorCommandContribution implements CommandContribution, MenuContribution {
|
|
9
|
+
protected readonly monacoCommandRegistry: MonacoCommandRegistry;
|
|
10
|
+
protected readonly chatService: ChatService;
|
|
11
|
+
private askAiInputWidget;
|
|
12
|
+
registerCommands(registry: CommandRegistry): void;
|
|
13
|
+
protected showInputWidgetHandler(): MonacoEditorCommandHandler;
|
|
14
|
+
private showInputWidget;
|
|
15
|
+
private cleanupInputWidget;
|
|
16
|
+
registerMenus(menus: MenuModelRegistry): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ai-editor-command-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-editor-command-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/ai-editor-command-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAIvF,OAAO,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,mDAAmD,CAAC;AAGtH,OAAO,EAAqB,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEhE,yBAAiB,kBAAkB,CAAC;IACzB,MAAM,gBAAgB,EAAE,OAG9B,CAAC;CACL;AAED,qBACa,2BAA4B,YAAW,mBAAmB,EAAE,gBAAgB;IAGrF,SAAS,CAAC,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IAGhE,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAE5C,OAAO,CAAC,gBAAgB,CAA+B;IAEvD,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAKjD,SAAS,CAAC,sBAAsB,IAAI,0BAA0B;IAQ9D,OAAO,CAAC,eAAe;IAmBvB,OAAO,CAAC,kBAAkB;IAO1B,aAAa,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;CAMhD"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AiEditorCommandContribution = exports.AI_EDITOR_COMMANDS = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const nls_1 = require("@theia/core/lib/common/nls");
|
|
21
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
22
|
+
const browser_1 = require("@theia/editor/lib/browser");
|
|
23
|
+
const monaco_command_registry_1 = require("@theia/monaco/lib/browser/monaco-command-registry");
|
|
24
|
+
const ask_ai_input_widget_1 = require("./ask-ai-input-widget");
|
|
25
|
+
const ai_chat_1 = require("@theia/ai-chat");
|
|
26
|
+
var AI_EDITOR_COMMANDS;
|
|
27
|
+
(function (AI_EDITOR_COMMANDS) {
|
|
28
|
+
AI_EDITOR_COMMANDS.AI_EDITOR_ASK_AI = {
|
|
29
|
+
id: 'ai-editor.contextAction',
|
|
30
|
+
label: nls_1.nls.localize('theia/ai-editor/contextMenu', 'Ask AI [Experimental]')
|
|
31
|
+
};
|
|
32
|
+
})(AI_EDITOR_COMMANDS || (exports.AI_EDITOR_COMMANDS = AI_EDITOR_COMMANDS = {}));
|
|
33
|
+
;
|
|
34
|
+
let AiEditorCommandContribution = class AiEditorCommandContribution {
|
|
35
|
+
registerCommands(registry) {
|
|
36
|
+
registry.registerCommand(AI_EDITOR_COMMANDS.AI_EDITOR_ASK_AI);
|
|
37
|
+
this.monacoCommandRegistry.registerHandler(AI_EDITOR_COMMANDS.AI_EDITOR_ASK_AI.id, this.showInputWidgetHandler());
|
|
38
|
+
}
|
|
39
|
+
showInputWidgetHandler() {
|
|
40
|
+
return {
|
|
41
|
+
execute: (_editor, position) => {
|
|
42
|
+
this.showInputWidget({ x: position.x, y: position.y + 10 });
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
showInputWidget(coordinates) {
|
|
47
|
+
this.cleanupInputWidget();
|
|
48
|
+
this.askAiInputWidget = new ask_ai_input_widget_1.AskAIInputWidget();
|
|
49
|
+
this.askAiInputWidget.onSubmit(event => {
|
|
50
|
+
const session = this.chatService.createSession(ai_chat_1.ChatAgentLocation.Panel, { focus: true });
|
|
51
|
+
this.chatService.sendRequest(session.id, {
|
|
52
|
+
text: `${event.userInput} #editorContext`
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
this.askAiInputWidget.show(coordinates);
|
|
56
|
+
this.askAiInputWidget.onCancel(() => {
|
|
57
|
+
this.cleanupInputWidget();
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
cleanupInputWidget() {
|
|
61
|
+
if (this.askAiInputWidget) {
|
|
62
|
+
this.askAiInputWidget.dispose();
|
|
63
|
+
this.askAiInputWidget = undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
registerMenus(menus) {
|
|
67
|
+
menus.registerMenuAction(browser_1.EditorContextMenu.NAVIGATION, {
|
|
68
|
+
commandId: AI_EDITOR_COMMANDS.AI_EDITOR_ASK_AI.id,
|
|
69
|
+
label: AI_EDITOR_COMMANDS.AI_EDITOR_ASK_AI.label
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.AiEditorCommandContribution = AiEditorCommandContribution;
|
|
74
|
+
tslib_1.__decorate([
|
|
75
|
+
(0, inversify_1.inject)(monaco_command_registry_1.MonacoCommandRegistry),
|
|
76
|
+
tslib_1.__metadata("design:type", monaco_command_registry_1.MonacoCommandRegistry)
|
|
77
|
+
], AiEditorCommandContribution.prototype, "monacoCommandRegistry", void 0);
|
|
78
|
+
tslib_1.__decorate([
|
|
79
|
+
(0, inversify_1.inject)(ai_chat_1.ChatService),
|
|
80
|
+
tslib_1.__metadata("design:type", Object)
|
|
81
|
+
], AiEditorCommandContribution.prototype, "chatService", void 0);
|
|
82
|
+
exports.AiEditorCommandContribution = AiEditorCommandContribution = tslib_1.__decorate([
|
|
83
|
+
(0, inversify_1.injectable)()
|
|
84
|
+
], AiEditorCommandContribution);
|
|
85
|
+
//# sourceMappingURL=ai-editor-command-contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-editor-command-contribution.js","sourceRoot":"","sources":["../../src/browser/ai-editor-command-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAKhF,oDAAiD;AACjD,4DAAkE;AAClE,uDAA8D;AAC9D,+FAAsH;AAEtH,+DAAyD;AACzD,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AAC;QACP,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAExC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,EAAE;YAChC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,kBAAkB;QACtB,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxB,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;YAChC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;QACtC,CAAC;IACL,CAAC;IAED,aAAa,CAAC,KAAwB;QAClC,KAAK,CAAC,kBAAkB,CAAC,2BAAiB,CAAC,UAAU,EAAE;YACnD,SAAS,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,EAAE;YACjD,KAAK,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,KAAK;SACnD,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AAvDY,kEAA2B;AAGjB;IADlB,IAAA,kBAAM,EAAC,+CAAqB,CAAC;sCACY,+CAAqB;0EAAC;AAG7C;IADlB,IAAA,kBAAM,EAAC,qBAAW,CAAC;;gEACwB;sCANnC,2BAA2B;IADvC,IAAA,sBAAU,GAAE;GACA,2BAA2B,CAuDvC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AIVariable, AIVariableContext, AIVariableContribution, AIVariableResolutionRequest, AIVariableResolver, ResolvedAIContextVariable } from '@theia/ai-core';
|
|
2
|
+
import { FrontendVariableService } from '@theia/ai-core/lib/browser';
|
|
3
|
+
import { MonacoEditorProvider } from '@theia/monaco/lib/browser/monaco-editor-provider';
|
|
4
|
+
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
|
|
5
|
+
export declare const EDITOR_CONTEXT_VARIABLE: AIVariable;
|
|
6
|
+
export declare class EditorContextVariableContribution implements AIVariableContribution, AIVariableResolver {
|
|
7
|
+
protected readonly monacoEditors: MonacoEditorProvider;
|
|
8
|
+
protected readonly workspaceService: WorkspaceService;
|
|
9
|
+
registerVariables(service: FrontendVariableService): void;
|
|
10
|
+
canResolve(request: AIVariableResolutionRequest, _: AIVariableContext): Promise<number>;
|
|
11
|
+
resolve(request: AIVariableResolutionRequest, _: AIVariableContext): Promise<ResolvedAIContextVariable | undefined>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=ai-editor-context-variable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-editor-context-variable.d.ts","sourceRoot":"","sources":["../../src/browser/ai-editor-context-variable.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AACnK,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAGrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAElF,eAAO,MAAM,uBAAuB,EAAE,UAQrC,CAAC;AAEF,qBACa,iCAAkC,YAAW,sBAAsB,EAAE,kBAAkB;IAGhG,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,oBAAoB,CAAC;IAGvD,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAEtD,iBAAiB,CAAC,OAAO,EAAE,uBAAuB,GAAG,IAAI;IAInD,UAAU,CAAC,OAAO,EAAE,2BAA2B,EAAE,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIvF,OAAO,CAAC,OAAO,EAAE,2BAA2B,EAAE,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,yBAAyB,GAAG,SAAS,CAAC;CA2D5H"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.EditorContextVariableContribution = exports.EDITOR_CONTEXT_VARIABLE = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
22
|
+
const monaco_editor_provider_1 = require("@theia/monaco/lib/browser/monaco-editor-provider");
|
|
23
|
+
const workspace_service_1 = require("@theia/workspace/lib/browser/workspace-service");
|
|
24
|
+
exports.EDITOR_CONTEXT_VARIABLE = {
|
|
25
|
+
id: 'editorContext',
|
|
26
|
+
description: 'Resolves editor specific context information',
|
|
27
|
+
name: 'editorContext',
|
|
28
|
+
label: 'EditorContext',
|
|
29
|
+
iconClasses: (0, browser_1.codiconArray)('file'),
|
|
30
|
+
isContextVariable: true,
|
|
31
|
+
args: []
|
|
32
|
+
};
|
|
33
|
+
let EditorContextVariableContribution = class EditorContextVariableContribution {
|
|
34
|
+
registerVariables(service) {
|
|
35
|
+
service.registerResolver(exports.EDITOR_CONTEXT_VARIABLE, this);
|
|
36
|
+
}
|
|
37
|
+
async canResolve(request, _) {
|
|
38
|
+
return request.variable.name === exports.EDITOR_CONTEXT_VARIABLE.name ? 1 : 0;
|
|
39
|
+
}
|
|
40
|
+
async resolve(request, _) {
|
|
41
|
+
const editor = this.monacoEditors.current;
|
|
42
|
+
if (!editor) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
const model = editor.getControl().getModel();
|
|
46
|
+
const selection = editor.getControl().getSelection();
|
|
47
|
+
if (!model || !selection) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
// Extract file information
|
|
51
|
+
const uri = editor.getResourceUri();
|
|
52
|
+
const languageId = model.getLanguageId();
|
|
53
|
+
// Extract selection information
|
|
54
|
+
const selectedText = model.getValueInRange(selection);
|
|
55
|
+
const hasSelection = !selection.isEmpty();
|
|
56
|
+
// Text position information
|
|
57
|
+
const position = editor.getControl().getPosition();
|
|
58
|
+
const lineNumber = position ? position.lineNumber : 0;
|
|
59
|
+
const column = position ? position.column : 0;
|
|
60
|
+
// Get workspace-relative path
|
|
61
|
+
const workspaceRelativePath = uri ? await this.workspaceService.getWorkspaceRelativePath(uri) : '';
|
|
62
|
+
// Create contextValue with all editor information
|
|
63
|
+
const contextValue = `
|
|
64
|
+
Metadata provided by the user:
|
|
65
|
+
${JSON.stringify({
|
|
66
|
+
file: {
|
|
67
|
+
uri: workspaceRelativePath,
|
|
68
|
+
languageId,
|
|
69
|
+
fileName: uri ? uri.path.base : ''
|
|
70
|
+
},
|
|
71
|
+
selection: {
|
|
72
|
+
text: selectedText,
|
|
73
|
+
isEmpty: !hasSelection,
|
|
74
|
+
startLineNumber: selection.startLineNumber,
|
|
75
|
+
startColumn: selection.startColumn,
|
|
76
|
+
endLineNumber: selection.endLineNumber,
|
|
77
|
+
endColumn: selection.endColumn
|
|
78
|
+
},
|
|
79
|
+
position: {
|
|
80
|
+
lineNumber,
|
|
81
|
+
column,
|
|
82
|
+
lineContent: position ? model.getLineContent(position.lineNumber) : ''
|
|
83
|
+
}
|
|
84
|
+
}, undefined, 2)}`;
|
|
85
|
+
return {
|
|
86
|
+
variable: request.variable,
|
|
87
|
+
value: contextValue, // Simplified visible value
|
|
88
|
+
contextValue // Full detailed context for AI processing
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
exports.EditorContextVariableContribution = EditorContextVariableContribution;
|
|
93
|
+
tslib_1.__decorate([
|
|
94
|
+
(0, inversify_1.inject)(monaco_editor_provider_1.MonacoEditorProvider),
|
|
95
|
+
tslib_1.__metadata("design:type", monaco_editor_provider_1.MonacoEditorProvider)
|
|
96
|
+
], EditorContextVariableContribution.prototype, "monacoEditors", void 0);
|
|
97
|
+
tslib_1.__decorate([
|
|
98
|
+
(0, inversify_1.inject)(workspace_service_1.WorkspaceService),
|
|
99
|
+
tslib_1.__metadata("design:type", workspace_service_1.WorkspaceService)
|
|
100
|
+
], EditorContextVariableContribution.prototype, "workspaceService", void 0);
|
|
101
|
+
exports.EditorContextVariableContribution = EditorContextVariableContribution = tslib_1.__decorate([
|
|
102
|
+
(0, inversify_1.injectable)()
|
|
103
|
+
], EditorContextVariableContribution);
|
|
104
|
+
//# sourceMappingURL=ai-editor-context-variable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-editor-context-variable.js","sourceRoot":"","sources":["../../src/browser/ai-editor-context-variable.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAIhF,4DAAkE;AAClE,qDAAuD;AACvD,6FAAwF;AACxF,sFAAkF;AAErE,QAAA,uBAAuB,GAAe;IAC/C,EAAE,EAAE,eAAe;IACnB,WAAW,EAAE,8CAA8C;IAC3D,IAAI,EA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,IAAA,kBAAM,EAAC,6CAAoB,CAAC;sCACK,6CAAoB;wEAAC;AAGpC;IADlB,IAAA,kBAAM,EAAC,oCAAgB,CAAC;sCACY,oCAAgB;2EAAC;4CAN7C,iCAAiC;IAD7C,IAAA,sBAAU,GAAE;GACA,iCAAiC,CA2E7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-editor-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/ai-editor-frontend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D,OAAO,8BAA8B,CAAC;;AAItC,wBAOG"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
19
|
+
const common_1 = require("@theia/core/lib/common");
|
|
20
|
+
const ai_editor_command_contribution_1 = require("./ai-editor-command-contribution");
|
|
21
|
+
require("../../style/ask-ai-input.css");
|
|
22
|
+
const ai_editor_context_variable_1 = require("./ai-editor-context-variable");
|
|
23
|
+
const ai_core_1 = require("@theia/ai-core");
|
|
24
|
+
exports.default = new inversify_1.ContainerModule(bind => {
|
|
25
|
+
bind(ai_editor_command_contribution_1.AiEditorCommandContribution).toSelf().inSingletonScope();
|
|
26
|
+
bind(common_1.CommandContribution).toService(ai_editor_command_contribution_1.AiEditorCommandContribution);
|
|
27
|
+
bind(common_1.MenuContribution).toService(ai_editor_command_contribution_1.AiEditorCommandContribution);
|
|
28
|
+
bind(ai_core_1.AIVariableContribution).to(ai_editor_context_variable_1.EditorContextVariableContribution).inSingletonScope();
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=ai-editor-frontend-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-editor-frontend-module.js","sourceRoot":"","sources":["../../src/browser/ai-editor-frontend-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,4DAA+D;AAC/D,mDAA+E;AAC/E,qFAA+E;AAC/E,wCAAsC;AACtC,6EAAiF;AACjF,4CAAwD;AAExD,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,4DAA2B,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAE9D,IAAI,CAAC,4BAAmB,CAAC,CAAC,SAAS,CAAC,4DAA2B,CAAC,CAAC;IACjE,IAAI,CAAC,yBAAgB,CAAC,CAAC,SAAS,CAAC,4DAA2B,CAAC,CAAC;IAE9D,IAAI,CAAC,gCAAsB,CAAC,CAAC,EAAE,CAAC,8DAAiC,CAAC,CAAC,gBAAgB,EAAE,CAAC;AAC1F,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Coordinate } from '@theia/core/lib/browser/context-menu-renderer';
|
|
2
|
+
import { Disposable } from '@theia/core/lib/common/disposable';
|
|
3
|
+
import { Event } from '@theia/core/lib/common/event';
|
|
4
|
+
export interface InputSubmitEvent {
|
|
5
|
+
userInput: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class AskAIInputWidget implements Disposable {
|
|
8
|
+
private readonly element;
|
|
9
|
+
private readonly inputElement;
|
|
10
|
+
private readonly disposables;
|
|
11
|
+
private readonly onSubmitEmitter;
|
|
12
|
+
private readonly onCancelEmitter;
|
|
13
|
+
readonly onSubmit: Event<InputSubmitEvent>;
|
|
14
|
+
readonly onCancel: Event<void>;
|
|
15
|
+
constructor();
|
|
16
|
+
private addInputEventListeners;
|
|
17
|
+
private addDocumentEventListeners;
|
|
18
|
+
show(coordinates: Coordinate): void;
|
|
19
|
+
hide(): void;
|
|
20
|
+
setValue(value: string): void;
|
|
21
|
+
getValue(): string;
|
|
22
|
+
private handleSubmit;
|
|
23
|
+
private handleCancel;
|
|
24
|
+
dispose(): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ask-ai-input-widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-ai-input-widget.d.ts","sourceRoot":"","sources":["../../src/browser/ask-ai-input-widget.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAwB,MAAM,mCAAmC,CAAC;AACrF,OAAO,EAAW,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAE9D,MAAM,WAAW,gBAAgB;IAC7B,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,gBAAiB,YAAW,UAAU;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAmB;IAChD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA8B;IAE1D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAmC;IACnE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAuB;IAEvD,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAA8B;IACxE,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,CAA8B;;IAkB5D,OAAO,CAAC,sBAAsB;IAiB9B,OAAO,CAAC,yBAAyB;IAcjC,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,IAAI;IAWnC,IAAI,IAAI,IAAI;IAMZ,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI7B,QAAQ,IAAI,MAAM;IAIlB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,YAAY;IAKpB,OAAO,IAAI,IAAI;CAMlB"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AskAIInputWidget = void 0;
|
|
19
|
+
const disposable_1 = require("@theia/core/lib/common/disposable");
|
|
20
|
+
const event_1 = require("@theia/core/lib/common/event");
|
|
21
|
+
class AskAIInputWidget {
|
|
22
|
+
constructor() {
|
|
23
|
+
this.disposables = new disposable_1.DisposableCollection();
|
|
24
|
+
this.onSubmitEmitter = new event_1.Emitter();
|
|
25
|
+
this.onCancelEmitter = new event_1.Emitter();
|
|
26
|
+
this.onSubmit = this.onSubmitEmitter.event;
|
|
27
|
+
this.onCancel = this.onCancelEmitter.event;
|
|
28
|
+
this.element = document.createElement('div');
|
|
29
|
+
this.element.className = 'ask-ai-input-widget';
|
|
30
|
+
// Create input element
|
|
31
|
+
this.inputElement = document.createElement('input');
|
|
32
|
+
this.inputElement.type = 'text';
|
|
33
|
+
this.inputElement.className = 'ask-ai-input-widget-input-field';
|
|
34
|
+
this.inputElement.placeholder = 'Type your prompt...';
|
|
35
|
+
this.element.appendChild(this.inputElement);
|
|
36
|
+
this.addInputEventListeners();
|
|
37
|
+
this.addDocumentEventListeners();
|
|
38
|
+
}
|
|
39
|
+
addInputEventListeners() {
|
|
40
|
+
const keydownListener = (e) => {
|
|
41
|
+
if (e.key === 'Enter') {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
this.handleSubmit();
|
|
44
|
+
}
|
|
45
|
+
else if (e.key === 'Escape') {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
this.handleCancel();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
this.inputElement.addEventListener('keydown', keydownListener);
|
|
51
|
+
this.disposables.push(disposable_1.Disposable.create(() => this.inputElement.removeEventListener('keydown', keydownListener)));
|
|
52
|
+
}
|
|
53
|
+
addDocumentEventListeners() {
|
|
54
|
+
// Handle clicks outside the input field
|
|
55
|
+
const mousedownListener = (e) => {
|
|
56
|
+
if (this.element.parentElement && !this.element.contains(e.target)) {
|
|
57
|
+
this.handleCancel();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
document.addEventListener('mousedown', mousedownListener);
|
|
61
|
+
this.disposables.push(disposable_1.Disposable.create(() => document.removeEventListener('mousedown', mousedownListener)));
|
|
62
|
+
}
|
|
63
|
+
show(coordinates) {
|
|
64
|
+
if (!this.element.parentElement) {
|
|
65
|
+
document.body.appendChild(this.element);
|
|
66
|
+
}
|
|
67
|
+
this.element.style.left = `${coordinates.x}px`;
|
|
68
|
+
this.element.style.top = `${coordinates.y}px`;
|
|
69
|
+
setTimeout(() => this.inputElement.focus(), 50);
|
|
70
|
+
}
|
|
71
|
+
hide() {
|
|
72
|
+
if (this.element.parentElement) {
|
|
73
|
+
this.element.parentElement.removeChild(this.element);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
setValue(value) {
|
|
77
|
+
this.inputElement.value = value;
|
|
78
|
+
}
|
|
79
|
+
getValue() {
|
|
80
|
+
return this.inputElement.value;
|
|
81
|
+
}
|
|
82
|
+
handleSubmit() {
|
|
83
|
+
const userInput = this.inputElement.value.trim();
|
|
84
|
+
if (userInput) {
|
|
85
|
+
this.onSubmitEmitter.fire({ userInput });
|
|
86
|
+
}
|
|
87
|
+
this.hide();
|
|
88
|
+
}
|
|
89
|
+
handleCancel() {
|
|
90
|
+
this.onCancelEmitter.fire();
|
|
91
|
+
this.hide();
|
|
92
|
+
}
|
|
93
|
+
dispose() {
|
|
94
|
+
this.hide();
|
|
95
|
+
this.disposables.dispose();
|
|
96
|
+
this.onSubmitEmitter.dispose();
|
|
97
|
+
this.onCancelEmitter.dispose();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.AskAIInputWidget = AskAIInputWidget;
|
|
101
|
+
//# sourceMappingURL=ask-ai-input-widget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-ai-input-widget.js","sourceRoot":"","sources":["../../src/browser/ask-ai-input-widget.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,y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,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,IAAI;QACA,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;YAC7B,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzD,CAAC;IACL,CAAC;IAED,QAAQ,CAAC,KAAa;QAClB,IAAI,CAAC,YAAY,CAAC,KAAK,GAAG,KAAK,CAAC;IACpC,CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;IACnC,CAAC;IAEO,YAAY;QAChB,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACjD,IAAI,SAAS,EAAE,CAAC;YACZ,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,CAAC,IAAI,EAAE,CAAC;IAChB,CAAC;IAEO,YAAY;QAChB,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,IAAI,EAAE,CAAC;IAChB,CAAC;IAED,OAAO;QACH,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;CACJ;AAtGD,4CAsGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAgBA,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const tslib_1 = require("tslib");
|
|
19
|
+
tslib_1.__exportStar(require("./ai-editor-command-contribution"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./ask-ai-input-widget"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,2EAAiD;AACjD,gEAAsC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=package.spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.spec.d.ts","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 EclipseSource GmbH and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
/* note: this bogus test file is required so that
|
|
17
|
+
we are able to run mocha unit tests on this
|
|
18
|
+
package, without having any actual unit tests in it.
|
|
19
|
+
This way a coverage report will be generated,
|
|
20
|
+
showing 0% coverage, instead of no report.
|
|
21
|
+
This file can be removed once we have real unit
|
|
22
|
+
tests in place. */
|
|
23
|
+
describe('ai-editor package', () => {
|
|
24
|
+
it('support code coverage statistics', () => true);
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=package.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.spec.js","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAEhF;;;;;;qBAMqB;AAErB,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAE/B,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AACvD,CAAC,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@theia/ai-editor",
|
|
3
|
+
"version": "1.63.0-next.24+83b50cc66",
|
|
4
|
+
"description": "Theia - AI Editor",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@theia/ai-chat": "1.63.0-next.24+83b50cc66",
|
|
7
|
+
"@theia/ai-core": "1.63.0-next.24+83b50cc66",
|
|
8
|
+
"@theia/core": "1.63.0-next.24+83b50cc66",
|
|
9
|
+
"@theia/editor": "1.63.0-next.24+83b50cc66",
|
|
10
|
+
"@theia/filesystem": "1.63.0-next.24+83b50cc66",
|
|
11
|
+
"@theia/monaco": "1.63.0-next.24+83b50cc66",
|
|
12
|
+
"@theia/monaco-editor-core": "1.96.302",
|
|
13
|
+
"@theia/workspace": "1.63.0-next.24+83b50cc66"
|
|
14
|
+
},
|
|
15
|
+
"main": "lib/common",
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"theiaExtensions": [
|
|
20
|
+
{
|
|
21
|
+
"frontend": "lib/browser/ai-editor-frontend-module"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"theia-extension"
|
|
26
|
+
],
|
|
27
|
+
"license": "EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/eclipse-theia/theia.git"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/eclipse-theia/theia/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/eclipse-theia/theia",
|
|
36
|
+
"files": [
|
|
37
|
+
"data",
|
|
38
|
+
"lib",
|
|
39
|
+
"src",
|
|
40
|
+
"style"
|
|
41
|
+
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "theiaext build",
|
|
44
|
+
"clean": "theiaext clean",
|
|
45
|
+
"compile": "theiaext compile",
|
|
46
|
+
"lint": "theiaext lint",
|
|
47
|
+
"test": "theiaext test",
|
|
48
|
+
"watch": "theiaext watch"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@theia/ext-scripts": "1.62.0"
|
|
52
|
+
},
|
|
53
|
+
"nyc": {
|
|
54
|
+
"extends": "../../configs/nyc.json"
|
|
55
|
+
},
|
|
56
|
+
"gitHead": "83b50cc66b001a5b9100ccd944dcace04cd4ae2e"
|
|
57
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { MenuContribution, MenuModelRegistry } from '@theia/core';
|
|
18
|
+
import { Coordinate } from '@theia/core/lib/browser/context-menu-renderer';
|
|
19
|
+
import { Command, CommandContribution, CommandRegistry } from '@theia/core/lib/common';
|
|
20
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
21
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
22
|
+
import { EditorContextMenu } from '@theia/editor/lib/browser';
|
|
23
|
+
import { MonacoCommandRegistry, MonacoEditorCommandHandler } from '@theia/monaco/lib/browser/monaco-command-registry';
|
|
24
|
+
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
|
|
25
|
+
import { AskAIInputWidget } from './ask-ai-input-widget';
|
|
26
|
+
import { ChatAgentLocation, ChatService } from '@theia/ai-chat';
|
|
27
|
+
|
|
28
|
+
export namespace AI_EDITOR_COMMANDS {
|
|
29
|
+
export const AI_EDITOR_ASK_AI: Command = {
|
|
30
|
+
id: 'ai-editor.contextAction',
|
|
31
|
+
label: nls.localize('theia/ai-editor/contextMenu', 'Ask AI [Experimental]')
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
@injectable()
|
|
36
|
+
export class AiEditorCommandContribution implements CommandContribution, MenuContribution {
|
|
37
|
+
|
|
38
|
+
@inject(MonacoCommandRegistry)
|
|
39
|
+
protected readonly monacoCommandRegistry: MonacoCommandRegistry;
|
|
40
|
+
|
|
41
|
+
@inject(ChatService)
|
|
42
|
+
protected readonly chatService: ChatService;
|
|
43
|
+
|
|
44
|
+
private askAiInputWidget: AskAIInputWidget | undefined;
|
|
45
|
+
|
|
46
|
+
registerCommands(registry: CommandRegistry): void {
|
|
47
|
+
registry.registerCommand(AI_EDITOR_COMMANDS.AI_EDITOR_ASK_AI);
|
|
48
|
+
this.monacoCommandRegistry.registerHandler(AI_EDITOR_COMMANDS.AI_EDITOR_ASK_AI.id, this.showInputWidgetHandler());
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected showInputWidgetHandler(): MonacoEditorCommandHandler {
|
|
52
|
+
return {
|
|
53
|
+
execute: (_editor: MonacoEditor, position: { x: number, y: number }) => {
|
|
54
|
+
this.showInputWidget({ x: position.x, y: position.y + 10 });
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private showInputWidget(coordinates: Coordinate): void {
|
|
60
|
+
this.cleanupInputWidget();
|
|
61
|
+
|
|
62
|
+
this.askAiInputWidget = new AskAIInputWidget();
|
|
63
|
+
|
|
64
|
+
this.askAiInputWidget.onSubmit(event => {
|
|
65
|
+
const session = this.chatService.createSession(ChatAgentLocation.Panel, { focus: true });
|
|
66
|
+
this.chatService.sendRequest(session.id, {
|
|
67
|
+
text: `${event.userInput} #editorContext`
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
this.askAiInputWidget.show(coordinates);
|
|
72
|
+
|
|
73
|
+
this.askAiInputWidget.onCancel(() => {
|
|
74
|
+
this.cleanupInputWidget();
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private cleanupInputWidget(): void {
|
|
79
|
+
if (this.askAiInputWidget) {
|
|
80
|
+
this.askAiInputWidget.dispose();
|
|
81
|
+
this.askAiInputWidget = undefined;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
registerMenus(menus: MenuModelRegistry): void {
|
|
86
|
+
menus.registerMenuAction(EditorContextMenu.NAVIGATION, {
|
|
87
|
+
commandId: AI_EDITOR_COMMANDS.AI_EDITOR_ASK_AI.id,
|
|
88
|
+
label: AI_EDITOR_COMMANDS.AI_EDITOR_ASK_AI.label
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { AIVariable, AIVariableContext, AIVariableContribution, AIVariableResolutionRequest, AIVariableResolver, ResolvedAIContextVariable } from '@theia/ai-core';
|
|
18
|
+
import { FrontendVariableService } from '@theia/ai-core/lib/browser';
|
|
19
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
20
|
+
import { codiconArray } from '@theia/core/lib/browser';
|
|
21
|
+
import { MonacoEditorProvider } from '@theia/monaco/lib/browser/monaco-editor-provider';
|
|
22
|
+
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
|
|
23
|
+
|
|
24
|
+
export const EDITOR_CONTEXT_VARIABLE: AIVariable = {
|
|
25
|
+
id: 'editorContext',
|
|
26
|
+
description: 'Resolves editor specific context information',
|
|
27
|
+
name: 'editorContext',
|
|
28
|
+
label: 'EditorContext',
|
|
29
|
+
iconClasses: codiconArray('file'),
|
|
30
|
+
isContextVariable: true,
|
|
31
|
+
args: []
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
@injectable()
|
|
35
|
+
export class EditorContextVariableContribution implements AIVariableContribution, AIVariableResolver {
|
|
36
|
+
|
|
37
|
+
@inject(MonacoEditorProvider)
|
|
38
|
+
protected readonly monacoEditors: MonacoEditorProvider;
|
|
39
|
+
|
|
40
|
+
@inject(WorkspaceService)
|
|
41
|
+
protected readonly workspaceService: WorkspaceService;
|
|
42
|
+
|
|
43
|
+
registerVariables(service: FrontendVariableService): void {
|
|
44
|
+
service.registerResolver(EDITOR_CONTEXT_VARIABLE, this);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async canResolve(request: AIVariableResolutionRequest, _: AIVariableContext): Promise<number> {
|
|
48
|
+
return request.variable.name === EDITOR_CONTEXT_VARIABLE.name ? 1 : 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async resolve(request: AIVariableResolutionRequest, _: AIVariableContext): Promise<ResolvedAIContextVariable | undefined> {
|
|
52
|
+
const editor = this.monacoEditors.current;
|
|
53
|
+
if (!editor) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const model = editor.getControl().getModel();
|
|
58
|
+
const selection = editor.getControl().getSelection();
|
|
59
|
+
|
|
60
|
+
if (!model || !selection) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Extract file information
|
|
65
|
+
const uri = editor.getResourceUri();
|
|
66
|
+
const languageId = model.getLanguageId();
|
|
67
|
+
|
|
68
|
+
// Extract selection information
|
|
69
|
+
const selectedText = model.getValueInRange(selection);
|
|
70
|
+
const hasSelection = !selection.isEmpty();
|
|
71
|
+
|
|
72
|
+
// Text position information
|
|
73
|
+
const position = editor.getControl().getPosition();
|
|
74
|
+
const lineNumber = position ? position.lineNumber : 0;
|
|
75
|
+
const column = position ? position.column : 0;
|
|
76
|
+
|
|
77
|
+
// Get workspace-relative path
|
|
78
|
+
const workspaceRelativePath = uri ? await this.workspaceService.getWorkspaceRelativePath(uri) : '';
|
|
79
|
+
|
|
80
|
+
// Create contextValue with all editor information
|
|
81
|
+
const contextValue = `
|
|
82
|
+
Metadata provided by the user:
|
|
83
|
+
${JSON.stringify({
|
|
84
|
+
file: {
|
|
85
|
+
uri: workspaceRelativePath,
|
|
86
|
+
languageId,
|
|
87
|
+
fileName: uri ? uri.path.base : ''
|
|
88
|
+
},
|
|
89
|
+
selection: {
|
|
90
|
+
text: selectedText,
|
|
91
|
+
isEmpty: !hasSelection,
|
|
92
|
+
startLineNumber: selection.startLineNumber,
|
|
93
|
+
startColumn: selection.startColumn,
|
|
94
|
+
endLineNumber: selection.endLineNumber,
|
|
95
|
+
endColumn: selection.endColumn
|
|
96
|
+
},
|
|
97
|
+
position: {
|
|
98
|
+
lineNumber,
|
|
99
|
+
column,
|
|
100
|
+
lineContent: position ? model.getLineContent(position.lineNumber) : ''
|
|
101
|
+
}
|
|
102
|
+
}, undefined, 2)}`;
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
variable: request.variable,
|
|
106
|
+
value: contextValue, // Simplified visible value
|
|
107
|
+
contextValue // Full detailed context for AI processing
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
+
import { CommandContribution, MenuContribution } from '@theia/core/lib/common';
|
|
19
|
+
import { AiEditorCommandContribution } from './ai-editor-command-contribution';
|
|
20
|
+
import '../../style/ask-ai-input.css';
|
|
21
|
+
import { EditorContextVariableContribution } from './ai-editor-context-variable';
|
|
22
|
+
import { AIVariableContribution } from '@theia/ai-core';
|
|
23
|
+
|
|
24
|
+
export default new ContainerModule(bind => {
|
|
25
|
+
bind(AiEditorCommandContribution).toSelf().inSingletonScope();
|
|
26
|
+
|
|
27
|
+
bind(CommandContribution).toService(AiEditorCommandContribution);
|
|
28
|
+
bind(MenuContribution).toService(AiEditorCommandContribution);
|
|
29
|
+
|
|
30
|
+
bind(AIVariableContribution).to(EditorContextVariableContribution).inSingletonScope();
|
|
31
|
+
});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { Coordinate } from '@theia/core/lib/browser/context-menu-renderer';
|
|
18
|
+
import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposable';
|
|
19
|
+
import { Emitter, Event } from '@theia/core/lib/common/event';
|
|
20
|
+
|
|
21
|
+
export interface InputSubmitEvent {
|
|
22
|
+
userInput: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class AskAIInputWidget implements Disposable {
|
|
26
|
+
private readonly element: HTMLDivElement;
|
|
27
|
+
private readonly inputElement: HTMLInputElement;
|
|
28
|
+
private readonly disposables = new DisposableCollection();
|
|
29
|
+
|
|
30
|
+
private readonly onSubmitEmitter = new Emitter<InputSubmitEvent>();
|
|
31
|
+
private readonly onCancelEmitter = new Emitter<void>();
|
|
32
|
+
|
|
33
|
+
readonly onSubmit: Event<InputSubmitEvent> = this.onSubmitEmitter.event;
|
|
34
|
+
readonly onCancel: Event<void> = this.onCancelEmitter.event;
|
|
35
|
+
|
|
36
|
+
constructor() {
|
|
37
|
+
this.element = document.createElement('div');
|
|
38
|
+
this.element.className = 'ask-ai-input-widget';
|
|
39
|
+
|
|
40
|
+
// Create input element
|
|
41
|
+
this.inputElement = document.createElement('input');
|
|
42
|
+
this.inputElement.type = 'text';
|
|
43
|
+
this.inputElement.className = 'ask-ai-input-widget-input-field';
|
|
44
|
+
this.inputElement.placeholder = 'Type your prompt...';
|
|
45
|
+
this.element.appendChild(this.inputElement);
|
|
46
|
+
|
|
47
|
+
this.addInputEventListeners();
|
|
48
|
+
|
|
49
|
+
this.addDocumentEventListeners();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private addInputEventListeners(): void {
|
|
53
|
+
const keydownListener = (e: KeyboardEvent) => {
|
|
54
|
+
if (e.key === 'Enter') {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
this.handleSubmit();
|
|
57
|
+
} else if (e.key === 'Escape') {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
this.handleCancel();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
this.inputElement.addEventListener('keydown', keydownListener);
|
|
64
|
+
this.disposables.push(Disposable.create(() =>
|
|
65
|
+
this.inputElement.removeEventListener('keydown', keydownListener)
|
|
66
|
+
));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private addDocumentEventListeners(): void {
|
|
70
|
+
// Handle clicks outside the input field
|
|
71
|
+
const mousedownListener = (e: MouseEvent) => {
|
|
72
|
+
if (this.element.parentElement && !this.element.contains(e.target as Node)) {
|
|
73
|
+
this.handleCancel();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
document.addEventListener('mousedown', mousedownListener);
|
|
78
|
+
this.disposables.push(Disposable.create(() =>
|
|
79
|
+
document.removeEventListener('mousedown', mousedownListener)
|
|
80
|
+
));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
show(coordinates: Coordinate): void {
|
|
84
|
+
if (!this.element.parentElement) {
|
|
85
|
+
document.body.appendChild(this.element);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
this.element.style.left = `${coordinates.x}px`;
|
|
89
|
+
this.element.style.top = `${coordinates.y}px`;
|
|
90
|
+
|
|
91
|
+
setTimeout(() => this.inputElement.focus(), 50);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
hide(): void {
|
|
95
|
+
if (this.element.parentElement) {
|
|
96
|
+
this.element.parentElement.removeChild(this.element);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
setValue(value: string): void {
|
|
101
|
+
this.inputElement.value = value;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getValue(): string {
|
|
105
|
+
return this.inputElement.value;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private handleSubmit(): void {
|
|
109
|
+
const userInput = this.inputElement.value.trim();
|
|
110
|
+
if (userInput) {
|
|
111
|
+
this.onSubmitEmitter.fire({ userInput });
|
|
112
|
+
}
|
|
113
|
+
this.hide();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private handleCancel(): void {
|
|
117
|
+
this.onCancelEmitter.fire();
|
|
118
|
+
this.hide();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
dispose(): void {
|
|
122
|
+
this.hide();
|
|
123
|
+
this.disposables.dispose();
|
|
124
|
+
this.onSubmitEmitter.dispose();
|
|
125
|
+
this.onCancelEmitter.dispose();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
export * from './ai-editor-command-contribution';
|
|
18
|
+
export * from './ask-ai-input-widget';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 EclipseSource GmbH and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
/* note: this bogus test file is required so that
|
|
18
|
+
we are able to run mocha unit tests on this
|
|
19
|
+
package, without having any actual unit tests in it.
|
|
20
|
+
This way a coverage report will be generated,
|
|
21
|
+
showing 0% coverage, instead of no report.
|
|
22
|
+
This file can be removed once we have real unit
|
|
23
|
+
tests in place. */
|
|
24
|
+
|
|
25
|
+
describe('ai-editor package', () => {
|
|
26
|
+
|
|
27
|
+
it('support code coverage statistics', () => true);
|
|
28
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2025 EclipseSource GmbH.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the terms
|
|
5
|
+
* of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
.ask-ai-input-widget {
|
|
18
|
+
background-color: var(--theia-editorWidget-background);
|
|
19
|
+
border: 1px solid var(--theia-editorWidget-border);
|
|
20
|
+
box-shadow: 0 2px 8px var(--theia-widget-shadow);
|
|
21
|
+
padding: 6px;
|
|
22
|
+
border-radius: 3px;
|
|
23
|
+
position: absolute;
|
|
24
|
+
z-index: 10000;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.ask-ai-input-widget-input-field {
|
|
28
|
+
width: 240px;
|
|
29
|
+
height: 24px;
|
|
30
|
+
padding: 2px 6px;
|
|
31
|
+
border: 1px solid var(--theia-input-border);
|
|
32
|
+
background-color: var(--theia-input-background);
|
|
33
|
+
color: var(--theia-input-foreground);
|
|
34
|
+
font-family: var(--theia-ui-font-family);
|
|
35
|
+
font-size: var(--theia-ui-font-size1);
|
|
36
|
+
outline: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.ask-ai-input-widget-input-field:focus {
|
|
40
|
+
border-color: var(--theia-focusBorder);
|
|
41
|
+
}
|