@theia/ai-code-completion 1.55.0-next.97 → 1.55.1
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-code-completion-frontend-module.d.ts.map +1 -1
- package/lib/browser/ai-code-completion-frontend-module.js +1 -3
- package/lib/browser/ai-code-completion-frontend-module.js.map +1 -1
- package/lib/browser/ai-code-completion-preference.d.ts +1 -1
- package/lib/browser/ai-code-completion-preference.d.ts.map +1 -1
- package/lib/browser/ai-code-completion-preference.js +5 -7
- package/lib/browser/ai-code-completion-preference.js.map +1 -1
- package/lib/browser/ai-code-frontend-application-contribution.d.ts +2 -3
- package/lib/browser/ai-code-frontend-application-contribution.d.ts.map +1 -1
- package/lib/browser/ai-code-frontend-application-contribution.js +3 -15
- package/lib/browser/ai-code-frontend-application-contribution.js.map +1 -1
- package/lib/common/code-completion-agent.d.ts +1 -1
- package/lib/common/code-completion-agent.d.ts.map +1 -1
- package/lib/common/code-completion-agent.js +15 -14
- package/lib/common/code-completion-agent.js.map +1 -1
- package/package.json +8 -8
- package/src/browser/ai-code-completion-frontend-module.ts +2 -4
- package/src/browser/ai-code-completion-preference.ts +4 -6
- package/src/browser/ai-code-frontend-application-contribution.ts +9 -19
- package/src/common/code-completion-agent.ts +17 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-code-completion-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/ai-code-completion-frontend-module.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAQ/D,
|
|
1
|
+
{"version":3,"file":"ai-code-completion-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/ai-code-completion-frontend-module.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAQ/D,wBAWG"}
|
|
@@ -32,9 +32,7 @@ exports.default = new inversify_1.ContainerModule(bind => {
|
|
|
32
32
|
bind(code_completion_agent_1.CodeCompletionAgent).toService(code_completion_agent_1.CodeCompletionAgentImpl);
|
|
33
33
|
bind(ai_core_1.Agent).toService(code_completion_agent_1.CodeCompletionAgentImpl);
|
|
34
34
|
bind(ai_code_inline_completion_provider_1.AICodeInlineCompletionsProvider).toSelf().inSingletonScope();
|
|
35
|
-
bind(
|
|
36
|
-
bind(browser_1.FrontendApplicationContribution).to(ai_code_frontend_application_contribution_1.AIFrontendApplicationContribution);
|
|
37
|
-
bind(browser_1.KeybindingContribution).toService(ai_code_frontend_application_contribution_1.AIFrontendApplicationContribution);
|
|
35
|
+
bind(browser_1.FrontendApplicationContribution).to(ai_code_frontend_application_contribution_1.AIFrontendApplicationContribution).inSingletonScope();
|
|
38
36
|
bind(browser_1.PreferenceContribution).toConstantValue({ schema: ai_code_completion_preference_1.AICodeCompletionPreferencesSchema });
|
|
39
37
|
});
|
|
40
38
|
//# sourceMappingURL=ai-code-completion-frontend-module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-code-completion-frontend-module.js","sourceRoot":"","sources":["../../src/browser/ai-code-completion-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,sCAAsC;AACtC,4DAA+D;AAC/D,2EAA+F;AAC/F,2GAAgG;AAChG,
|
|
1
|
+
{"version":3,"file":"ai-code-completion-frontend-module.js","sourceRoot":"","sources":["../../src/browser/ai-code-completion-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,sCAAsC;AACtC,4DAA+D;AAC/D,2EAA+F;AAC/F,2GAAgG;AAChG,qDAAkG;AAClG,4CAAuC;AACvC,mFAAoF;AACpF,6FAAuF;AAEvF,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,cAAO,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;QAC/B,MAAM,YAAY,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,CAAU,cAAO,CAAC,CAAC;QACzD,OAAO,YAAY,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC,eAAe,CAAC,uBAAuB,CAAC,CAAC;IAC/D,IAAI,CAAC,+CAAuB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC1D,IAAI,CAAC,2CAAmB,CAAC,CAAC,SAAS,CAAC,+CAAuB,CAAC,CAAC;IAC7D,IAAI,CAAC,eAAK,CAAC,CAAC,SAAS,CAAC,+CAAuB,CAAC,CAAC;IAC/C,IAAI,CAAC,oEAA+B,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAClE,IAAI,CAAC,yCAA+B,CAAC,CAAC,EAAE,CAAC,6EAAiC,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC/F,IAAI,CAAC,gCAAsB,CAAC,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,iEAAiC,EAAE,CAAC,CAAC;AAChG,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PreferenceSchema } from '@theia/core/lib/browser/preferences/preference-contribution';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const PREF_AI_INLINE_COMPLETION_ENABLE = "ai-features.codeCompletion.enableCodeCompletion";
|
|
3
3
|
export declare const PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS = "ai-features.codeCompletion.excludedFileExtensions";
|
|
4
4
|
export declare const AICodeCompletionPreferencesSchema: PreferenceSchema;
|
|
5
5
|
//# sourceMappingURL=ai-code-completion-preference.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-code-completion-preference.d.ts","sourceRoot":"","sources":["../../src/browser/ai-code-completion-preference.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6DAA6D,CAAC;AAG/F,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"ai-code-completion-preference.d.ts","sourceRoot":"","sources":["../../src/browser/ai-code-completion-preference.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6DAA6D,CAAC;AAG/F,eAAO,MAAM,gCAAgC,oDAAoD,CAAC;AAClG,eAAO,MAAM,6CAA6C,sDAAsD,CAAC;AAEjH,eAAO,MAAM,iCAAiC,EAAE,gBAmB/C,CAAC"}
|
|
@@ -15,20 +15,18 @@
|
|
|
15
15
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
16
|
// *****************************************************************************
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.AICodeCompletionPreferencesSchema = exports.PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS = exports.
|
|
18
|
+
exports.AICodeCompletionPreferencesSchema = exports.PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS = exports.PREF_AI_INLINE_COMPLETION_ENABLE = void 0;
|
|
19
19
|
const ai_core_preferences_1 = require("@theia/ai-core/lib/browser/ai-core-preferences");
|
|
20
|
-
exports.
|
|
20
|
+
exports.PREF_AI_INLINE_COMPLETION_ENABLE = 'ai-features.codeCompletion.enableCodeCompletion';
|
|
21
21
|
exports.PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS = 'ai-features.codeCompletion.excludedFileExtensions';
|
|
22
22
|
exports.AICodeCompletionPreferencesSchema = {
|
|
23
23
|
type: 'object',
|
|
24
24
|
properties: {
|
|
25
|
-
[exports.
|
|
25
|
+
[exports.PREF_AI_INLINE_COMPLETION_ENABLE]: {
|
|
26
26
|
title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
|
|
27
27
|
type: 'boolean',
|
|
28
|
-
description: '
|
|
29
|
-
|
|
30
|
-
Alternatively, you can manually trigger the code via the command "Trigger Inline Suggestion" or the default shortcut "SHIFT+Space".',
|
|
31
|
-
default: true
|
|
28
|
+
description: 'Enable AI completions inline within any (Monaco) editor.',
|
|
29
|
+
default: false
|
|
32
30
|
},
|
|
33
31
|
[exports.PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS]: {
|
|
34
32
|
title: 'Excluded File Extensions',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-code-completion-preference.js","sourceRoot":"","sources":["../../src/browser/ai-code-completion-preference.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;;;AAGhF,wFAA2F;AAE9E,QAAA,
|
|
1
|
+
{"version":3,"file":"ai-code-completion-preference.js","sourceRoot":"","sources":["../../src/browser/ai-code-completion-preference.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;;;AAGhF,wFAA2F;AAE9E,QAAA,gCAAgC,GAAG,iDAAiD,CAAC;AACrF,QAAA,6CAA6C,GAAG,mDAAmD,CAAC;AAEpG,QAAA,iCAAiC,GAAqB;IAC/D,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACR,CAAC,wCAAgC,CAAC,EAAE;YAChC,KAAK,EAAE,+CAAyB;YAChC,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,0DAA0D;YACvE,OAAO,EAAE,KAAK;SACjB;QACD,CAAC,qDAA6C,CAAC,EAAE;YAC7C,KAAK,EAAE,0BAA0B;YACjC,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,oFAAoF;YACjG,KAAK,EAAE;gBACH,IAAI,EAAE,QAAQ;aACjB;YACD,OAAO,EAAE,EAAE;SACd;KACJ;CACJ,CAAC"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { FrontendApplicationContribution,
|
|
1
|
+
import { FrontendApplicationContribution, PreferenceService } from '@theia/core/lib/browser';
|
|
2
2
|
import { AIActivationService } from '@theia/ai-core/lib/browser';
|
|
3
3
|
import { Disposable } from '@theia/core';
|
|
4
|
-
export declare class AIFrontendApplicationContribution implements FrontendApplicationContribution
|
|
4
|
+
export declare class AIFrontendApplicationContribution implements FrontendApplicationContribution {
|
|
5
5
|
private inlineCodeCompletionProvider;
|
|
6
6
|
protected readonly preferenceService: PreferenceService;
|
|
7
7
|
protected readonly activationService: AIActivationService;
|
|
8
8
|
private toDispose;
|
|
9
9
|
onDidInitializeLayout(): void;
|
|
10
10
|
protected handlePreferences(): void;
|
|
11
|
-
registerKeybindings(keybindings: KeybindingRegistry): void;
|
|
12
11
|
protected handleInlineCompletions(): Disposable;
|
|
13
12
|
}
|
|
14
13
|
//# sourceMappingURL=ai-code-frontend-application-contribution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-code-frontend-application-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/ai-code-frontend-application-contribution.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,+BAA+B,EAAE,
|
|
1
|
+
{"version":3,"file":"ai-code-frontend-application-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/ai-code-frontend-application-contribution.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,+BAA+B,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,qBACa,iCAAkC,YAAW,+BAA+B;IAErF,OAAO,CAAC,4BAA4B,CAAkC;IAGtE,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAGxD,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,mBAAmB,CAAC;IAE1D,OAAO,CAAC,SAAS,CAAiC;IAElD,qBAAqB,IAAI,IAAI;IAM7B,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAkBnC,SAAS,CAAC,uBAAuB,IAAI,UAAU;CA0BlD"}
|
|
@@ -24,7 +24,6 @@ const browser_2 = require("@theia/ai-core/lib/browser");
|
|
|
24
24
|
const core_1 = require("@theia/core");
|
|
25
25
|
const ai_code_inline_completion_provider_1 = require("./ai-code-inline-completion-provider");
|
|
26
26
|
const ai_code_completion_preference_1 = require("./ai-code-completion-preference");
|
|
27
|
-
const languages_1 = require("@theia/monaco-editor-core/esm/vs/editor/common/languages");
|
|
28
27
|
let AIFrontendApplicationContribution = class AIFrontendApplicationContribution {
|
|
29
28
|
constructor() {
|
|
30
29
|
this.toDispose = new Map();
|
|
@@ -39,8 +38,7 @@ let AIFrontendApplicationContribution = class AIFrontendApplicationContribution
|
|
|
39
38
|
this.toDispose.set('inlineCompletions', handler());
|
|
40
39
|
this.preferenceService.onPreferenceChanged(event => {
|
|
41
40
|
var _a;
|
|
42
|
-
if (event.preferenceName === ai_code_completion_preference_1.
|
|
43
|
-
|| event.preferenceName === ai_code_completion_preference_1.PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS) {
|
|
41
|
+
if (event.preferenceName === ai_code_completion_preference_1.PREF_AI_INLINE_COMPLETION_ENABLE || event.preferenceName === ai_code_completion_preference_1.PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS) {
|
|
44
42
|
(_a = this.toDispose.get('inlineCompletions')) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
45
43
|
this.toDispose.set('inlineCompletions', handler());
|
|
46
44
|
}
|
|
@@ -51,24 +49,14 @@ let AIFrontendApplicationContribution = class AIFrontendApplicationContribution
|
|
|
51
49
|
this.toDispose.set('inlineCompletions', handler());
|
|
52
50
|
});
|
|
53
51
|
}
|
|
54
|
-
registerKeybindings(keybindings) {
|
|
55
|
-
keybindings.registerKeybinding({
|
|
56
|
-
command: 'editor.action.inlineSuggest.trigger',
|
|
57
|
-
keybinding: 'Shift+Space',
|
|
58
|
-
when: '!editorReadonly && editorTextFocus'
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
52
|
handleInlineCompletions() {
|
|
62
|
-
|
|
53
|
+
const enable = this.preferenceService.get(ai_code_completion_preference_1.PREF_AI_INLINE_COMPLETION_ENABLE, false) && this.activationService.isActive;
|
|
54
|
+
if (!enable) {
|
|
63
55
|
return core_1.Disposable.NULL;
|
|
64
56
|
}
|
|
65
|
-
const automatic = this.preferenceService.get(ai_code_completion_preference_1.PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE, true);
|
|
66
57
|
const excludedExtensions = this.preferenceService.get(ai_code_completion_preference_1.PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS, []);
|
|
67
58
|
return monaco.languages.registerInlineCompletionsProvider({ scheme: 'file' }, {
|
|
68
59
|
provideInlineCompletions: (model, position, context, token) => {
|
|
69
|
-
if (!automatic && context.triggerKind === languages_1.InlineCompletionTriggerKind.Automatic) {
|
|
70
|
-
return { items: [] };
|
|
71
|
-
}
|
|
72
60
|
const fileName = model.uri.toString();
|
|
73
61
|
if (excludedExtensions.some(ext => fileName.endsWith(ext))) {
|
|
74
62
|
return { items: [] };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-code-frontend-application-contribution.js","sourceRoot":"","sources":["../../src/browser/ai-code-frontend-application-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;;;;AAEhF,oDAAoD;AAEpD,
|
|
1
|
+
{"version":3,"file":"ai-code-frontend-application-contribution.js","sourceRoot":"","sources":["../../src/browser/ai-code-frontend-application-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;;;;AAEhF,oDAAoD;AAEpD,qDAA6F;AAC7F,4DAAkE;AAClE,wDAAiE;AACjE,sCAAyC;AACzC,6FAAuF;AACvF,mFAAkI;AAG3H,IAAM,iCAAiC,GAAvC,MAAM,iCAAiC;IAAvC;QAUK,cAAS,GAAG,IAAI,GAAG,EAAsB,CAAC;IAoDtD,CAAC;IAlDG,qBAAqB;QACjB,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;YACnC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;IACP,CAAC;IAES,iBAAiB;QACvB,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAErD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AQ,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;gBAEtC,IAAI,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;oBACzD,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;gBACzB,CAAC;gBACD,OAAO,IAAI,CAAC,4BAA4B,CAAC,wBAAwB,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;YACvG,CAAC;YACD,qBAAqB,EAAE,WAAW,CAAC,EAAE;gBACjC,IAAI,CAAC,4BAA4B,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;YACzE,CAAC;SACJ,CACJ,CAAC;IACN,CAAC;CACJ,CAAA;AA9DY,8EAAiC;AAElC;IADP,IAAA,kBAAM,EAAC,oEAA+B,CAAC;sCACF,oEAA+B;uFAAC;AAGnD;IADlB,IAAA,kBAAM,EAAC,2BAAiB,CAAC;;4EAC8B;AAGrC;IADlB,IAAA,kBAAM,EAAC,6BAAmB,CAAC;sCACU,6BAAmB;4EAAC;4CARjD,iCAAiC;IAD7C,IAAA,sBAAU,GAAE;GACA,iCAAiC,CA8D7C"}
|
|
@@ -19,6 +19,6 @@ export declare class CodeCompletionAgentImpl implements CodeCompletionAgent {
|
|
|
19
19
|
readonly variables: string[];
|
|
20
20
|
readonly functions: string[];
|
|
21
21
|
readonly agentSpecificVariables: AgentSpecificVariables[];
|
|
22
|
-
readonly tags?:
|
|
22
|
+
readonly tags?: String[] | undefined;
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=code-completion-agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-completion-agent.d.ts","sourceRoot":"","sources":["../../src/common/code-completion-agent.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,KAAK,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"code-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AyB,EAAE,wBAAwB,EAAE,CAKnD;IACF,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAM;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAM;IAClC,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,CAKvD;IACF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACxC"}
|
|
@@ -29,13 +29,11 @@ let CodeCompletionAgentImpl = class CodeCompletionAgentImpl {
|
|
|
29
29
|
this.promptTemplates = [
|
|
30
30
|
{
|
|
31
31
|
id: 'code-completion-prompt',
|
|
32
|
-
template: `
|
|
33
|
-
https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
|
|
34
|
-
You are a code completion agent. The current file you have to complete is named {{file}}.
|
|
32
|
+
template: `You are a code completion agent. The current file you have to complete is named {{file}}.
|
|
35
33
|
The language of the file is {{language}}. Return your result as plain text without markdown formatting.
|
|
36
34
|
Finish the following code snippet.
|
|
37
35
|
|
|
38
|
-
{{
|
|
36
|
+
{{textUntilCurrentPosition}}[[MARKER]]{{textAfterCurrentPosition}}
|
|
39
37
|
|
|
40
38
|
Only return the exact replacement for [[MARKER]] to complete the snippet.`,
|
|
41
39
|
},
|
|
@@ -51,8 +49,8 @@ Only return the exact replacement for [[MARKER]] to complete the snippet.`,
|
|
|
51
49
|
this.agentSpecificVariables = [
|
|
52
50
|
{ name: 'file', usedInPrompt: true, description: 'The uri of the file being edited.' },
|
|
53
51
|
{ name: 'language', usedInPrompt: true, description: 'The languageId of the file being edited.' },
|
|
54
|
-
{ name: '
|
|
55
|
-
{ name: '
|
|
52
|
+
{ name: 'textUntilCurrentPosition', usedInPrompt: true, description: 'The code before the current position of the cursor.' },
|
|
53
|
+
{ name: 'textAfterCurrentPosition', usedInPrompt: true, description: 'The code after the current position of the cursor.' }
|
|
56
54
|
];
|
|
57
55
|
}
|
|
58
56
|
async provideInlineCompletions(model, position, context, token) {
|
|
@@ -65,14 +63,14 @@ Only return the exact replacement for [[MARKER]] to complete the snippet.`,
|
|
|
65
63
|
return undefined;
|
|
66
64
|
}
|
|
67
65
|
// Get text until the given position
|
|
68
|
-
const
|
|
66
|
+
const textUntilCurrentPosition = model.getValueInRange({
|
|
69
67
|
startLineNumber: 1,
|
|
70
68
|
startColumn: 1,
|
|
71
69
|
endLineNumber: position.lineNumber,
|
|
72
70
|
endColumn: position.column,
|
|
73
71
|
});
|
|
74
72
|
// Get text after the given position
|
|
75
|
-
const
|
|
73
|
+
const textAfterCurrentPosition = model.getValueInRange({
|
|
76
74
|
startLineNumber: position.lineNumber,
|
|
77
75
|
startColumn: position.column,
|
|
78
76
|
endLineNumber: model.getLineCount(),
|
|
@@ -84,7 +82,7 @@ Only return the exact replacement for [[MARKER]] to complete the snippet.`,
|
|
|
84
82
|
return undefined;
|
|
85
83
|
}
|
|
86
84
|
const prompt = await this.promptService
|
|
87
|
-
.getPrompt('code-completion-prompt', {
|
|
85
|
+
.getPrompt('code-completion-prompt', { textUntilCurrentPosition, textAfterCurrentPosition, file, language })
|
|
88
86
|
.then(p => p === null || p === void 0 ? void 0 : p.text);
|
|
89
87
|
if (!prompt) {
|
|
90
88
|
this.logger.error('No prompt found for code-completion-agent');
|
|
@@ -96,15 +94,17 @@ Only return the exact replacement for [[MARKER]] to complete the snippet.`,
|
|
|
96
94
|
const request = {
|
|
97
95
|
messages: [{ type: 'text', actor: 'user', query: prompt }],
|
|
98
96
|
};
|
|
99
|
-
|
|
100
|
-
return undefined;
|
|
101
|
-
}
|
|
102
|
-
this.recordingService.recordRequest({
|
|
97
|
+
const requestEntry = {
|
|
103
98
|
agentId: this.id,
|
|
104
99
|
sessionId,
|
|
100
|
+
timestamp: Date.now(),
|
|
105
101
|
requestId,
|
|
106
102
|
request: prompt,
|
|
107
|
-
}
|
|
103
|
+
};
|
|
104
|
+
if (token.isCancellationRequested) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
this.recordingService.recordRequest(requestEntry);
|
|
108
108
|
const response = await languageModel.request(request, token);
|
|
109
109
|
if (token.isCancellationRequested) {
|
|
110
110
|
return undefined;
|
|
@@ -116,6 +116,7 @@ Only return the exact replacement for [[MARKER]] to complete the snippet.`,
|
|
|
116
116
|
this.recordingService.recordResponse({
|
|
117
117
|
agentId: this.id,
|
|
118
118
|
sessionId,
|
|
119
|
+
timestamp: Date.now(),
|
|
119
120
|
requestId,
|
|
120
121
|
response: completionText,
|
|
121
122
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-completion-agent.js","sourceRoot":"","sources":["../../src/common/code-completion-agent.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,sDAGmC;AACnC,sCAAoD;AACpD,4DAAyE;AAG5D,QAAA,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAO1D,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAA7B;
|
|
1
|
+
{"version":3,"file":"code-completion-agent.js","sourceRoot":"","sources":["../../src/common/code-completion-agent.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,sDAGmC;AACnC,sCAAoD;AACpD,4DAAyE;AAG5D,QAAA,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAO1D,IAAM,uBAAuB,GAA7B,MAAM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6B,CAAC;;iEACoB;kCAnGjD,uBAAuB;IADnC,IAAA,sBAAU,GAAE;GACA,uBAAuB,CAoInC"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/ai-code-completion",
|
|
3
|
-
"version": "1.55.
|
|
3
|
+
"version": "1.55.1",
|
|
4
4
|
"description": "Theia - AI Core",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/ai-core": "1.55.
|
|
7
|
-
"@theia/core": "1.55.
|
|
8
|
-
"@theia/filesystem": "1.55.
|
|
6
|
+
"@theia/ai-core": "1.55.1",
|
|
7
|
+
"@theia/core": "1.55.1",
|
|
8
|
+
"@theia/filesystem": "1.55.1",
|
|
9
9
|
"@theia/monaco-editor-core": "1.83.101",
|
|
10
|
-
"@theia/output": "1.55.
|
|
11
|
-
"@theia/workspace": "1.55.
|
|
10
|
+
"@theia/output": "1.55.1",
|
|
11
|
+
"@theia/workspace": "1.55.1",
|
|
12
12
|
"minimatch": "^5.1.0",
|
|
13
13
|
"tslib": "^2.6.2"
|
|
14
14
|
},
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"watch": "theiaext watch"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@theia/ext-scripts": "1.55.
|
|
49
|
+
"@theia/ext-scripts": "1.55.1"
|
|
50
50
|
},
|
|
51
51
|
"nyc": {
|
|
52
52
|
"extends": "../../configs/nyc.json"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "be4713a778be16ba831af63a6fbd43b2301e882d"
|
|
55
55
|
}
|
|
@@ -18,7 +18,7 @@ import { ILogger } from '@theia/core';
|
|
|
18
18
|
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
19
19
|
import { CodeCompletionAgent, CodeCompletionAgentImpl } from '../common/code-completion-agent';
|
|
20
20
|
import { AIFrontendApplicationContribution } from './ai-code-frontend-application-contribution';
|
|
21
|
-
import { FrontendApplicationContribution,
|
|
21
|
+
import { FrontendApplicationContribution, PreferenceContribution } from '@theia/core/lib/browser';
|
|
22
22
|
import { Agent } from '@theia/ai-core';
|
|
23
23
|
import { AICodeCompletionPreferencesSchema } from './ai-code-completion-preference';
|
|
24
24
|
import { AICodeInlineCompletionsProvider } from './ai-code-inline-completion-provider';
|
|
@@ -32,8 +32,6 @@ export default new ContainerModule(bind => {
|
|
|
32
32
|
bind(CodeCompletionAgent).toService(CodeCompletionAgentImpl);
|
|
33
33
|
bind(Agent).toService(CodeCompletionAgentImpl);
|
|
34
34
|
bind(AICodeInlineCompletionsProvider).toSelf().inSingletonScope();
|
|
35
|
-
bind(
|
|
36
|
-
bind(FrontendApplicationContribution).to(AIFrontendApplicationContribution);
|
|
37
|
-
bind(KeybindingContribution).toService(AIFrontendApplicationContribution);
|
|
35
|
+
bind(FrontendApplicationContribution).to(AIFrontendApplicationContribution).inSingletonScope();
|
|
38
36
|
bind(PreferenceContribution).toConstantValue({ schema: AICodeCompletionPreferencesSchema });
|
|
39
37
|
});
|
|
@@ -17,19 +17,17 @@
|
|
|
17
17
|
import { PreferenceSchema } from '@theia/core/lib/browser/preferences/preference-contribution';
|
|
18
18
|
import { AI_CORE_PREFERENCES_TITLE } from '@theia/ai-core/lib/browser/ai-core-preferences';
|
|
19
19
|
|
|
20
|
-
export const
|
|
20
|
+
export const PREF_AI_INLINE_COMPLETION_ENABLE = 'ai-features.codeCompletion.enableCodeCompletion';
|
|
21
21
|
export const PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS = 'ai-features.codeCompletion.excludedFileExtensions';
|
|
22
22
|
|
|
23
23
|
export const AICodeCompletionPreferencesSchema: PreferenceSchema = {
|
|
24
24
|
type: 'object',
|
|
25
25
|
properties: {
|
|
26
|
-
[
|
|
26
|
+
[PREF_AI_INLINE_COMPLETION_ENABLE]: {
|
|
27
27
|
title: AI_CORE_PREFERENCES_TITLE,
|
|
28
28
|
type: 'boolean',
|
|
29
|
-
description: '
|
|
30
|
-
|
|
31
|
-
Alternatively, you can manually trigger the code via the command "Trigger Inline Suggestion" or the default shortcut "SHIFT+Space".',
|
|
32
|
-
default: true
|
|
29
|
+
description: 'Enable AI completions inline within any (Monaco) editor.',
|
|
30
|
+
default: false
|
|
33
31
|
},
|
|
34
32
|
[PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS]: {
|
|
35
33
|
title: 'Excluded File Extensions',
|
|
@@ -16,16 +16,15 @@
|
|
|
16
16
|
|
|
17
17
|
import * as monaco from '@theia/monaco-editor-core';
|
|
18
18
|
|
|
19
|
-
import { FrontendApplicationContribution,
|
|
19
|
+
import { FrontendApplicationContribution, PreferenceService } from '@theia/core/lib/browser';
|
|
20
20
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
21
21
|
import { AIActivationService } from '@theia/ai-core/lib/browser';
|
|
22
22
|
import { Disposable } from '@theia/core';
|
|
23
23
|
import { AICodeInlineCompletionsProvider } from './ai-code-inline-completion-provider';
|
|
24
|
-
import {
|
|
25
|
-
import { InlineCompletionTriggerKind } from '@theia/monaco-editor-core/esm/vs/editor/common/languages';
|
|
24
|
+
import { PREF_AI_INLINE_COMPLETION_ENABLE, PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS } from './ai-code-completion-preference';
|
|
26
25
|
|
|
27
26
|
@injectable()
|
|
28
|
-
export class AIFrontendApplicationContribution implements FrontendApplicationContribution
|
|
27
|
+
export class AIFrontendApplicationContribution implements FrontendApplicationContribution {
|
|
29
28
|
@inject(AICodeInlineCompletionsProvider)
|
|
30
29
|
private inlineCodeCompletionProvider: AICodeInlineCompletionsProvider;
|
|
31
30
|
|
|
@@ -49,8 +48,7 @@ export class AIFrontendApplicationContribution implements FrontendApplicationCon
|
|
|
49
48
|
this.toDispose.set('inlineCompletions', handler());
|
|
50
49
|
|
|
51
50
|
this.preferenceService.onPreferenceChanged(event => {
|
|
52
|
-
if (event.preferenceName ===
|
|
53
|
-
|| event.preferenceName === PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS) {
|
|
51
|
+
if (event.preferenceName === PREF_AI_INLINE_COMPLETION_ENABLE || event.preferenceName === PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS) {
|
|
54
52
|
this.toDispose.get('inlineCompletions')?.dispose();
|
|
55
53
|
this.toDispose.set('inlineCompletions', handler());
|
|
56
54
|
}
|
|
@@ -62,29 +60,21 @@ export class AIFrontendApplicationContribution implements FrontendApplicationCon
|
|
|
62
60
|
});
|
|
63
61
|
}
|
|
64
62
|
|
|
65
|
-
registerKeybindings(keybindings: KeybindingRegistry): void {
|
|
66
|
-
keybindings.registerKeybinding({
|
|
67
|
-
command: 'editor.action.inlineSuggest.trigger',
|
|
68
|
-
keybinding: 'Shift+Space',
|
|
69
|
-
when: '!editorReadonly && editorTextFocus'
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
63
|
protected handleInlineCompletions(): Disposable {
|
|
74
|
-
|
|
64
|
+
const enable = this.preferenceService.get<boolean>(PREF_AI_INLINE_COMPLETION_ENABLE, false) && this.activationService.isActive;
|
|
65
|
+
|
|
66
|
+
if (!enable) {
|
|
75
67
|
return Disposable.NULL;
|
|
76
68
|
}
|
|
77
|
-
|
|
69
|
+
|
|
78
70
|
const excludedExtensions = this.preferenceService.get<string[]>(PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS, []);
|
|
79
71
|
|
|
80
72
|
return monaco.languages.registerInlineCompletionsProvider(
|
|
81
73
|
{ scheme: 'file' },
|
|
82
74
|
{
|
|
83
75
|
provideInlineCompletions: (model, position, context, token) => {
|
|
84
|
-
if (!automatic && context.triggerKind === InlineCompletionTriggerKind.Automatic) {
|
|
85
|
-
return { items: [] };
|
|
86
|
-
}
|
|
87
76
|
const fileName = model.uri.toString();
|
|
77
|
+
|
|
88
78
|
if (excludedExtensions.some(ext => fileName.endsWith(ext))) {
|
|
89
79
|
return { items: [] };
|
|
90
80
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
|
-
Agent, AgentSpecificVariables, CommunicationRecordingService, getTextOfResponse,
|
|
18
|
+
Agent, AgentSpecificVariables, CommunicationHistoryEntry, CommunicationRecordingService, getTextOfResponse,
|
|
19
19
|
LanguageModelRegistry, LanguageModelRequest, LanguageModelRequirement, PromptService, PromptTemplate
|
|
20
20
|
} from '@theia/ai-core/lib/common';
|
|
21
21
|
import { generateUuid, ILogger } from '@theia/core';
|
|
@@ -49,7 +49,7 @@ export class CodeCompletionAgentImpl implements CodeCompletionAgent {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// Get text until the given position
|
|
52
|
-
const
|
|
52
|
+
const textUntilCurrentPosition = model.getValueInRange({
|
|
53
53
|
startLineNumber: 1,
|
|
54
54
|
startColumn: 1,
|
|
55
55
|
endLineNumber: position.lineNumber,
|
|
@@ -57,7 +57,7 @@ export class CodeCompletionAgentImpl implements CodeCompletionAgent {
|
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
// Get text after the given position
|
|
60
|
-
const
|
|
60
|
+
const textAfterCurrentPosition = model.getValueInRange({
|
|
61
61
|
startLineNumber: position.lineNumber,
|
|
62
62
|
startColumn: position.column,
|
|
63
63
|
endLineNumber: model.getLineCount(),
|
|
@@ -71,7 +71,7 @@ export class CodeCompletionAgentImpl implements CodeCompletionAgent {
|
|
|
71
71
|
return undefined;
|
|
72
72
|
}
|
|
73
73
|
const prompt = await this.promptService
|
|
74
|
-
.getPrompt('code-completion-prompt', {
|
|
74
|
+
.getPrompt('code-completion-prompt', { textUntilCurrentPosition, textAfterCurrentPosition, file, language })
|
|
75
75
|
.then(p => p?.text);
|
|
76
76
|
if (!prompt) {
|
|
77
77
|
this.logger.error('No prompt found for code-completion-agent');
|
|
@@ -84,15 +84,17 @@ export class CodeCompletionAgentImpl implements CodeCompletionAgent {
|
|
|
84
84
|
const request: LanguageModelRequest = {
|
|
85
85
|
messages: [{ type: 'text', actor: 'user', query: prompt }],
|
|
86
86
|
};
|
|
87
|
-
|
|
88
|
-
return undefined;
|
|
89
|
-
}
|
|
90
|
-
this.recordingService.recordRequest({
|
|
87
|
+
const requestEntry: CommunicationHistoryEntry = {
|
|
91
88
|
agentId: this.id,
|
|
92
89
|
sessionId,
|
|
90
|
+
timestamp: Date.now(),
|
|
93
91
|
requestId,
|
|
94
92
|
request: prompt,
|
|
95
|
-
}
|
|
93
|
+
};
|
|
94
|
+
if (token.isCancellationRequested) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
this.recordingService.recordRequest(requestEntry);
|
|
96
98
|
const response = await languageModel.request(request, token);
|
|
97
99
|
if (token.isCancellationRequested) {
|
|
98
100
|
return undefined;
|
|
@@ -104,6 +106,7 @@ export class CodeCompletionAgentImpl implements CodeCompletionAgent {
|
|
|
104
106
|
this.recordingService.recordResponse({
|
|
105
107
|
agentId: this.id,
|
|
106
108
|
sessionId,
|
|
109
|
+
timestamp: Date.now(),
|
|
107
110
|
requestId,
|
|
108
111
|
response: completionText,
|
|
109
112
|
});
|
|
@@ -134,13 +137,11 @@ export class CodeCompletionAgentImpl implements CodeCompletionAgent {
|
|
|
134
137
|
promptTemplates: PromptTemplate[] = [
|
|
135
138
|
{
|
|
136
139
|
id: 'code-completion-prompt',
|
|
137
|
-
template: `
|
|
138
|
-
https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
|
|
139
|
-
You are a code completion agent. The current file you have to complete is named {{file}}.
|
|
140
|
+
template: `You are a code completion agent. The current file you have to complete is named {{file}}.
|
|
140
141
|
The language of the file is {{language}}. Return your result as plain text without markdown formatting.
|
|
141
142
|
Finish the following code snippet.
|
|
142
143
|
|
|
143
|
-
{{
|
|
144
|
+
{{textUntilCurrentPosition}}[[MARKER]]{{textAfterCurrentPosition}}
|
|
144
145
|
|
|
145
146
|
Only return the exact replacement for [[MARKER]] to complete the snippet.`,
|
|
146
147
|
},
|
|
@@ -156,8 +157,8 @@ Only return the exact replacement for [[MARKER]] to complete the snippet.`,
|
|
|
156
157
|
readonly agentSpecificVariables: AgentSpecificVariables[] = [
|
|
157
158
|
{ name: 'file', usedInPrompt: true, description: 'The uri of the file being edited.' },
|
|
158
159
|
{ name: 'language', usedInPrompt: true, description: 'The languageId of the file being edited.' },
|
|
159
|
-
{ name: '
|
|
160
|
-
{ name: '
|
|
160
|
+
{ name: 'textUntilCurrentPosition', usedInPrompt: true, description: 'The code before the current position of the cursor.' },
|
|
161
|
+
{ name: 'textAfterCurrentPosition', usedInPrompt: true, description: 'The code after the current position of the cursor.' }
|
|
161
162
|
];
|
|
162
|
-
readonly tags?:
|
|
163
|
+
readonly tags?: String[] | undefined;
|
|
163
164
|
}
|