@theia/ai-code-completion 1.55.1 → 1.57.0-next.112

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 (40) hide show
  1. package/README.md +2 -1
  2. package/lib/browser/ai-code-completion-frontend-module.d.ts.map +1 -1
  3. package/lib/browser/ai-code-completion-frontend-module.js +6 -2
  4. package/lib/browser/ai-code-completion-frontend-module.js.map +1 -1
  5. package/lib/browser/ai-code-completion-preference.d.ts +3 -1
  6. package/lib/browser/ai-code-completion-preference.d.ts.map +1 -1
  7. package/lib/browser/ai-code-completion-preference.js +23 -4
  8. package/lib/browser/ai-code-completion-preference.js.map +1 -1
  9. package/lib/browser/ai-code-frontend-application-contribution.d.ts +3 -2
  10. package/lib/browser/ai-code-frontend-application-contribution.d.ts.map +1 -1
  11. package/lib/browser/ai-code-frontend-application-contribution.js +15 -3
  12. package/lib/browser/ai-code-frontend-application-contribution.js.map +1 -1
  13. package/lib/browser/ai-code-inline-completion-provider.d.ts +1 -1
  14. package/lib/browser/ai-code-inline-completion-provider.d.ts.map +1 -1
  15. package/lib/browser/ai-code-inline-completion-provider.js +1 -1
  16. package/lib/browser/ai-code-inline-completion-provider.js.map +1 -1
  17. package/lib/{common → browser}/code-completion-agent.d.ts +7 -2
  18. package/lib/browser/code-completion-agent.d.ts.map +1 -0
  19. package/lib/browser/code-completion-agent.js +211 -0
  20. package/lib/browser/code-completion-agent.js.map +1 -0
  21. package/lib/browser/code-completion-postprocessor.d.ts +11 -0
  22. package/lib/browser/code-completion-postprocessor.d.ts.map +1 -0
  23. package/lib/browser/code-completion-postprocessor.js +49 -0
  24. package/lib/browser/code-completion-postprocessor.js.map +1 -0
  25. package/lib/browser/code-completion-postprocessor.spec.d.ts +2 -0
  26. package/lib/browser/code-completion-postprocessor.spec.d.ts.map +1 -0
  27. package/lib/browser/code-completion-postprocessor.spec.js +73 -0
  28. package/lib/browser/code-completion-postprocessor.spec.js.map +1 -0
  29. package/package.json +9 -9
  30. package/src/browser/ai-code-completion-frontend-module.ts +7 -3
  31. package/src/browser/ai-code-completion-preference.ts +22 -3
  32. package/src/browser/ai-code-frontend-application-contribution.ts +19 -9
  33. package/src/browser/ai-code-inline-completion-provider.ts +1 -1
  34. package/src/browser/code-completion-agent.ts +233 -0
  35. package/src/browser/code-completion-postprocessor.spec.ts +84 -0
  36. package/src/browser/code-completion-postprocessor.ts +48 -0
  37. package/lib/common/code-completion-agent.d.ts.map +0 -1
  38. package/lib/common/code-completion-agent.js +0 -150
  39. package/lib/common/code-completion-agent.js.map +0 -1
  40. package/src/common/code-completion-agent.ts +0 -164
package/README.md CHANGED
@@ -26,5 +26,6 @@ The user can separately enable code completion items as well as inline code comp
26
26
  - [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
27
27
 
28
28
  ## Trademark
29
+
29
30
  "Theia" is a trademark of the Eclipse Foundation
30
- https://www.eclipse.org/theia
31
+ <https://www.eclipse.org/theia>
@@ -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,wBAWG"}
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;;AAS/D,wBAcG"}
@@ -17,12 +17,13 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const core_1 = require("@theia/core");
19
19
  const inversify_1 = require("@theia/core/shared/inversify");
20
- const code_completion_agent_1 = require("../common/code-completion-agent");
20
+ const code_completion_agent_1 = require("./code-completion-agent");
21
21
  const ai_code_frontend_application_contribution_1 = require("./ai-code-frontend-application-contribution");
22
22
  const browser_1 = require("@theia/core/lib/browser");
23
23
  const ai_core_1 = require("@theia/ai-core");
24
24
  const ai_code_completion_preference_1 = require("./ai-code-completion-preference");
25
25
  const ai_code_inline_completion_provider_1 = require("./ai-code-inline-completion-provider");
26
+ const code_completion_postprocessor_1 = require("./code-completion-postprocessor");
26
27
  exports.default = new inversify_1.ContainerModule(bind => {
27
28
  bind(core_1.ILogger).toDynamicValue(ctx => {
28
29
  const parentLogger = ctx.container.get(core_1.ILogger);
@@ -32,7 +33,10 @@ exports.default = new inversify_1.ContainerModule(bind => {
32
33
  bind(code_completion_agent_1.CodeCompletionAgent).toService(code_completion_agent_1.CodeCompletionAgentImpl);
33
34
  bind(ai_core_1.Agent).toService(code_completion_agent_1.CodeCompletionAgentImpl);
34
35
  bind(ai_code_inline_completion_provider_1.AICodeInlineCompletionsProvider).toSelf().inSingletonScope();
35
- bind(browser_1.FrontendApplicationContribution).to(ai_code_frontend_application_contribution_1.AIFrontendApplicationContribution).inSingletonScope();
36
+ bind(ai_code_frontend_application_contribution_1.AIFrontendApplicationContribution).toSelf().inSingletonScope();
37
+ bind(browser_1.FrontendApplicationContribution).to(ai_code_frontend_application_contribution_1.AIFrontendApplicationContribution);
38
+ bind(browser_1.KeybindingContribution).toService(ai_code_frontend_application_contribution_1.AIFrontendApplicationContribution);
36
39
  bind(browser_1.PreferenceContribution).toConstantValue({ schema: ai_code_completion_preference_1.AICodeCompletionPreferencesSchema });
40
+ bind(code_completion_postprocessor_1.CodeCompletionPostProcessor).to(code_completion_postprocessor_1.DefaultCodeCompletionPostProcessor).inSingletonScope();
37
41
  });
38
42
  //# 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,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
+ {"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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C5F,IAAI,CAAC,2DAA2B,CAAC,CAAC,EAAE,CAAC,kEAAkC,CAAC,CAAC,gBAAgB,EAAE,CAAC;AAChG,CAAC,CAAC,CAAC"}
@@ -1,5 +1,7 @@
1
1
  import { PreferenceSchema } from '@theia/core/lib/browser/preferences/preference-contribution';
2
- export declare const PREF_AI_INLINE_COMPLETION_ENABLE = "ai-features.codeCompletion.enableCodeCompletion";
2
+ export declare const PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE = "ai-features.codeCompletion.automaticCodeCompletion";
3
3
  export declare const PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS = "ai-features.codeCompletion.excludedFileExtensions";
4
+ export declare const PREF_AI_INLINE_COMPLETION_MAX_CONTEXT_LINES = "ai-features.codeCompletion.maxContextLines";
5
+ export declare const PREF_AI_INLINE_COMPLETION_STRIP_BACKTICKS = "ai-features.codeCompletion.stripBackticks";
4
6
  export declare const AICodeCompletionPreferencesSchema: PreferenceSchema;
5
7
  //# 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,gCAAgC,oDAAoD,CAAC;AAClG,eAAO,MAAM,6CAA6C,sDAAsD,CAAC;AAEjH,eAAO,MAAM,iCAAiC,EAAE,gBAmB/C,CAAC"}
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,0CAA0C,uDAAuD,CAAC;AAC/G,eAAO,MAAM,6CAA6C,sDAAsD,CAAC;AACjH,eAAO,MAAM,2CAA2C,+CAA+C,CAAC;AACxG,eAAO,MAAM,yCAAyC,8CAA8C,CAAC;AAErG,eAAO,MAAM,iCAAiC,EAAE,gBAoC/C,CAAC"}
@@ -15,17 +15,21 @@
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.PREF_AI_INLINE_COMPLETION_ENABLE = void 0;
18
+ exports.AICodeCompletionPreferencesSchema = exports.PREF_AI_INLINE_COMPLETION_STRIP_BACKTICKS = exports.PREF_AI_INLINE_COMPLETION_MAX_CONTEXT_LINES = exports.PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS = exports.PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE = void 0;
19
19
  const ai_core_preferences_1 = require("@theia/ai-core/lib/browser/ai-core-preferences");
20
- exports.PREF_AI_INLINE_COMPLETION_ENABLE = 'ai-features.codeCompletion.enableCodeCompletion';
20
+ exports.PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE = 'ai-features.codeCompletion.automaticCodeCompletion';
21
21
  exports.PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS = 'ai-features.codeCompletion.excludedFileExtensions';
22
+ exports.PREF_AI_INLINE_COMPLETION_MAX_CONTEXT_LINES = 'ai-features.codeCompletion.maxContextLines';
23
+ exports.PREF_AI_INLINE_COMPLETION_STRIP_BACKTICKS = 'ai-features.codeCompletion.stripBackticks';
22
24
  exports.AICodeCompletionPreferencesSchema = {
23
25
  type: 'object',
24
26
  properties: {
25
- [exports.PREF_AI_INLINE_COMPLETION_ENABLE]: {
27
+ [exports.PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE]: {
26
28
  title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
27
29
  type: 'boolean',
28
- description: 'Enable AI completions inline within any (Monaco) editor.',
30
+ description: 'Automatically trigger AI completions inline within any (Monaco) editor while editing.\
31
+ \n\
32
+ Alternatively, you can manually trigger the code via the command "Trigger Inline Suggestion" or the default shortcut "Ctrl+Alt+Space".',
29
33
  default: false
30
34
  },
31
35
  [exports.PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS]: {
@@ -36,6 +40,21 @@ exports.AICodeCompletionPreferencesSchema = {
36
40
  type: 'string'
37
41
  },
38
42
  default: []
43
+ },
44
+ [exports.PREF_AI_INLINE_COMPLETION_MAX_CONTEXT_LINES]: {
45
+ title: 'Maximum Context Lines',
46
+ type: 'number',
47
+ description: 'The maximum number of lines used as context, distributed among the lines before and after the cursor position (prefix and suffix).\
48
+ Set this to -1 to use the full file as context without any line limit and 0 to only use the current line.',
49
+ default: -1,
50
+ minimum: -1
51
+ },
52
+ [exports.PREF_AI_INLINE_COMPLETION_STRIP_BACKTICKS]: {
53
+ title: 'Strip Backticks from Inline Completions',
54
+ type: 'boolean',
55
+ description: 'Remove surrounding backticks from the code returned by some LLMs. If a backtick is detected, all content after the closing\
56
+ backtick is stripped as well. This setting helps ensure plain code is returned when language models use markdown-like formatting.',
57
+ default: true
39
58
  }
40
59
  }
41
60
  };
@@ -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,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
+ {"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,0CAA0C,GAAG,oDAAoD,CAAC;AAClG,QAAA,6CAA6C,GAAG,mDAAmD,CAAC;AACpG,QAAA,2CAA2C,GAAG,4CAA4C,CAAC;AAC3F,QAAA,yCAAyC,GAAG,2CAA2C,CAAC;AAExF,QAAA,iCAAiC,GAAqB;IAC/D,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACR,CAAC,kDAA0C,CAAC,EAAE;YAC1C,KAAK,EAAE,+CAAyB;YAChC,IAAI,EAAE,SAAS;YACf,WAAW,EAAE;;mJAE0H;YACvI,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;QACD,CAAC,mDAA2C,CAAC,EAAE;YAC3C,KAAK,EAAE,uBAAuB;YAC9B,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE;sHAC6F;YAC1G,OAAO,EAAE,CAAC,CAAC;YACX,OAAO,EAAE,CAAC,CAAC;SACd;QACD,CAAC,iDAAyC,CAAC,EAAE;YACzC,KAAK,EAAE,yCAAyC;YAChD,IAAI,EAAE,SAAS;YACf,WAAW,EAAE;+IACsH;YACnI,OAAO,EAAE,IAAI;SAChB;KACJ;CACJ,CAAC"}
@@ -1,13 +1,14 @@
1
- import { FrontendApplicationContribution, PreferenceService } from '@theia/core/lib/browser';
1
+ import { FrontendApplicationContribution, KeybindingContribution, KeybindingRegistry, 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, KeybindingContribution {
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;
11
12
  protected handleInlineCompletions(): Disposable;
12
13
  }
13
14
  //# 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,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"}
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,sBAAsB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEzI,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKzC,qBACa,iCAAkC,YAAW,+BAA+B,EAAE,sBAAsB;IAE7G,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;IAmBnC,mBAAmB,CAAC,WAAW,EAAE,kBAAkB,GAAG,IAAI;IAQ1D,SAAS,CAAC,uBAAuB,IAAI,UAAU;CA0BlD"}
@@ -24,6 +24,7 @@ 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");
27
28
  let AIFrontendApplicationContribution = class AIFrontendApplicationContribution {
28
29
  constructor() {
29
30
  this.toDispose = new Map();
@@ -38,7 +39,8 @@ let AIFrontendApplicationContribution = class AIFrontendApplicationContribution
38
39
  this.toDispose.set('inlineCompletions', handler());
39
40
  this.preferenceService.onPreferenceChanged(event => {
40
41
  var _a;
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) {
42
+ if (event.preferenceName === ai_code_completion_preference_1.PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE
43
+ || event.preferenceName === ai_code_completion_preference_1.PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS) {
42
44
  (_a = this.toDispose.get('inlineCompletions')) === null || _a === void 0 ? void 0 : _a.dispose();
43
45
  this.toDispose.set('inlineCompletions', handler());
44
46
  }
@@ -49,14 +51,24 @@ let AIFrontendApplicationContribution = class AIFrontendApplicationContribution
49
51
  this.toDispose.set('inlineCompletions', handler());
50
52
  });
51
53
  }
54
+ registerKeybindings(keybindings) {
55
+ keybindings.registerKeybinding({
56
+ command: 'editor.action.inlineSuggest.trigger',
57
+ keybinding: 'Ctrl+Alt+Space',
58
+ when: '!editorReadonly && editorTextFocus'
59
+ });
60
+ }
52
61
  handleInlineCompletions() {
53
- const enable = this.preferenceService.get(ai_code_completion_preference_1.PREF_AI_INLINE_COMPLETION_ENABLE, false) && this.activationService.isActive;
54
- if (!enable) {
62
+ if (!this.activationService.isActive) {
55
63
  return core_1.Disposable.NULL;
56
64
  }
65
+ const automatic = this.preferenceService.get(ai_code_completion_preference_1.PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE, true);
57
66
  const excludedExtensions = this.preferenceService.get(ai_code_completion_preference_1.PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS, []);
58
67
  return monaco.languages.registerInlineCompletionsProvider({ scheme: 'file' }, {
59
68
  provideInlineCompletions: (model, position, context, token) => {
69
+ if (!automatic && context.triggerKind === languages_1.InlineCompletionTriggerKind.Automatic) {
70
+ return { items: [] };
71
+ }
60
72
  const fileName = model.uri.toString();
61
73
  if (excludedExtensions.some(ext => fileName.endsWith(ext))) {
62
74
  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,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,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,EAAE,CAAC,CAAC;QAEnD,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE;;YAC/C,IAAI,KAAK,CAAC,cAAc,KAAK,gEAAgC,IAAI,KAAK,CAAC,cAAc,KAAK,6EAA6C,EAAE,CAAC;gBACtI,MAAA,IAAI,CAAC,SAAS,CAAC,GA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AAwB,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"}
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,qDAAyI;AACzI,4DAAkE;AAClE,wDAAiE;AACjE,sCAAyC;AACzC,6FAAuF;AACvF,mFAA4I;AAC5I,wFAAuG;AAGhG,IAAM,iCAAiC,GAAvC,MAAM,iCAAiC;IAAvC;QAUK,cAAS,GAAG,IAAI,GAAG,EAAsB,CAAC;IA6DtD,CAAC;IA3DG,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,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letionAgent } from '../common/code-completion-agent';
2
+ import { CodeCompletionAgent } from './code-completion-agent';
3
3
  export declare class AICodeInlineCompletionsProvider implements monaco.languages.InlineCompletionsProvider {
4
4
  protected readonly agent: CodeCompletionAgent;
5
5
  private readonly agentService;
@@ -1 +1 @@
1
- {"version":3,"file":"ai-code-inline-completion-provider.d.ts","sourceRoot":"","sources":["../../src/browser/ai-code-inline-completion-provider.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAC;AAGpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,qBACa,+BACT,YAAW,MAAM,CAAC,SAAS,CAAC,yBAAyB;IAErD,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;IAE9C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAEtC,wBAAwB,CAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,EAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,uBAAuB,EACjD,KAAK,EAAE,MAAM,CAAC,iBAAiB,GAChC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAY1D,qBAAqB,CACjB,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,GACnF,IAAI;CAGV"}
1
+ {"version":3,"file":"ai-code-inline-completion-provider.d.ts","sourceRoot":"","sources":["../../src/browser/ai-code-inline-completion-provider.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAC;AAGpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG9D,qBACa,+BACT,YAAW,MAAM,CAAC,SAAS,CAAC,yBAAyB;IAErD,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;IAE9C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAEtC,wBAAwB,CAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,EAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,uBAAuB,EACjD,KAAK,EAAE,MAAM,CAAC,iBAAiB,GAChC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAY1D,qBAAqB,CACjB,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,GACnF,IAAI;CAGV"}
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.AICodeInlineCompletionsProvider = void 0;
19
19
  const tslib_1 = require("tslib");
20
20
  const inversify_1 = require("@theia/core/shared/inversify");
21
- const code_completion_agent_1 = require("../common/code-completion-agent");
21
+ const code_completion_agent_1 = require("./code-completion-agent");
22
22
  const ai_core_1 = require("@theia/ai-core");
23
23
  let AICodeInlineCompletionsProvider = class AICodeInlineCompletionsProvider {
24
24
  async provideInlineCompletions(model, position, context, token) {
@@ -1 +1 @@
1
- {"version":3,"file":"ai-code-inline-completion-provider.js","sourceRoot":"","sources":["../../src/browser/ai-code-inline-completion-provider.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,2EAAsE;AACtE,4CAA8C;AAGvC,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAOxC,KAAK,CAAC,wBAAwB,CAC1B,KAA+B,EAC/B,QAAyB,EACzB,OAAiD,EACjD,KAA+B;QAE/B,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;YAC9C,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,CACtC,KAAK,EACL,QAAQ,EACR,OAAO,EACP,KAAK,CACR,CAAC;IACN,CAAC;IAED,qBAAqB,CACjB,WAAkF;QAElF,gBAAgB;IACpB,CAAC;CACJ,CAAA;AA7BY,0EAA+B;AAGrB;IADlB,IAAA,kBAAM,EAAC,2CAAmB,CAAC;;8DACkB;AAE7B;IADhB,IAAA,kBAAM,EAAC,sBAAY,CAAC;;qEACuB;0CALnC,+BAA+B;IAD3C,IAAA,sBAAU,GAAE;GACA,+BAA+B,CA6B3C"}
1
+ {"version":3,"file":"ai-code-inline-completion-provider.js","sourceRoot":"","sources":["../../src/browser/ai-code-inline-completion-provider.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,mEAA8D;AAC9D,4CAA8C;AAGvC,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAOxC,KAAK,CAAC,wBAAwB,CAC1B,KAA+B,EAC/B,QAAyB,EACzB,OAAiD,EACjD,KAA+B;QAE/B,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;YAC9C,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,CACtC,KAAK,EACL,QAAQ,EACR,OAAO,EACP,KAAK,CACR,CAAC;IACN,CAAC;IAED,qBAAqB,CACjB,WAAkF;QAElF,gBAAgB;IACpB,CAAC;CACJ,CAAA;AA7BY,0EAA+B;AAGrB;IADlB,IAAA,kBAAM,EAAC,2CAAmB,CAAC;;8DACkB;AAE7B;IADhB,IAAA,kBAAM,EAAC,sBAAY,CAAC;;qEACuB;0CALnC,+BAA+B;IAD3C,IAAA,sBAAU,GAAE;GACA,+BAA+B,CA6B3C"}
@@ -1,6 +1,8 @@
1
1
  import { Agent, AgentSpecificVariables, CommunicationRecordingService, LanguageModelRegistry, LanguageModelRequirement, PromptService, PromptTemplate } from '@theia/ai-core/lib/common';
2
- import { ILogger } from '@theia/core';
2
+ import { ILogger, ProgressService } from '@theia/core';
3
3
  import * as monaco from '@theia/monaco-editor-core';
4
+ import { PreferenceService } from '@theia/core/lib/browser';
5
+ import { CodeCompletionPostProcessor } from './code-completion-postprocessor';
4
6
  export declare const CodeCompletionAgent: unique symbol;
5
7
  export interface CodeCompletionAgent extends Agent {
6
8
  provideInlineCompletions(model: monaco.editor.ITextModel, position: monaco.Position, context: monaco.languages.InlineCompletionContext, token: monaco.CancellationToken): Promise<monaco.languages.InlineCompletions | undefined>;
@@ -11,6 +13,9 @@ export declare class CodeCompletionAgentImpl implements CodeCompletionAgent {
11
13
  protected languageModelRegistry: LanguageModelRegistry;
12
14
  protected promptService: PromptService;
13
15
  protected recordingService: CommunicationRecordingService;
16
+ protected progressService: ProgressService;
17
+ protected preferences: PreferenceService;
18
+ protected postProcessor: CodeCompletionPostProcessor;
14
19
  id: string;
15
20
  name: string;
16
21
  description: string;
@@ -19,6 +24,6 @@ export declare class CodeCompletionAgentImpl implements CodeCompletionAgent {
19
24
  readonly variables: string[];
20
25
  readonly functions: string[];
21
26
  readonly agentSpecificVariables: AgentSpecificVariables[];
22
- readonly tags?: String[] | undefined;
27
+ readonly tags?: string[] | undefined;
23
28
  }
24
29
  //# sourceMappingURL=code-completion-agent.d.ts.map
@@ -0,0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C,SAAS,CAAC,gBAAgB,EAAE,6BAA6B,CAAC;IAG1D,SAAS,CAAC,eAAe,EAAE,eAAe,CAAC;IAG3C,SAAS,CAAC,WAAW,EAAE,iBAAiB,CAAC;IAGzC,SAAS,CAAC,aAAa,EAAE,2BAA2B,CAAC;IAErD,EAAE,SAAqB;IACvB,IAAI,SAAqB;IACzB,WAAW,SAC2E;IACtF,eAAe,EAAE,cAAc,EAAE,CA6B/B;IACF,yBAAyB,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"}
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2024 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.CodeCompletionAgentImpl = exports.CodeCompletionAgent = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const common_1 = require("@theia/ai-core/lib/common");
21
+ const core_1 = require("@theia/core");
22
+ const inversify_1 = require("@theia/core/shared/inversify");
23
+ const ai_code_completion_preference_1 = require("./ai-code-completion-preference");
24
+ const browser_1 = require("@theia/core/lib/browser");
25
+ const code_completion_postprocessor_1 = require("./code-completion-postprocessor");
26
+ exports.CodeCompletionAgent = Symbol('CodeCompletionAgent');
27
+ let CodeCompletionAgentImpl = class CodeCompletionAgentImpl {
28
+ constructor() {
29
+ this.id = 'Code Completion';
30
+ this.name = 'Code Completion';
31
+ this.description = 'This agent provides inline code completion in the code editor in the Theia IDE.';
32
+ this.promptTemplates = [
33
+ {
34
+ id: 'code-completion-prompt',
35
+ template: `{{!-- Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
36
+ https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
37
+ You are a code completion agent. The current file you have to complete is named {{file}}.
38
+ The language of the file is {{language}}. Return your result as plain text without markdown formatting.
39
+ Finish the following code snippet.
40
+
41
+ {{prefix}}[[MARKER]]{{suffix}}
42
+
43
+ Only return the exact replacement for [[MARKER]] to complete the snippet.`
44
+ },
45
+ {
46
+ id: 'code-completion-prompt-next',
47
+ variantOf: 'code-completion-prompt',
48
+ template: `{{!-- Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
49
+ https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
50
+ ## Code snippet
51
+ \`\`\`
52
+ {{ prefix }}[[MARKER]]{{ suffix }}
53
+ \`\`\`
54
+
55
+ ## Meta Data
56
+ - File: {{file}}
57
+ - Language: {{language}}
58
+
59
+ Replace [[MARKER]] with the exact code to complete the code snippet. Return only the replacement of [[MAKRER]] as plain text.`,
60
+ },
61
+ ];
62
+ this.languageModelRequirements = [
63
+ {
64
+ purpose: 'code-completion',
65
+ identifier: 'openai/gpt-4o',
66
+ },
67
+ ];
68
+ this.variables = [];
69
+ this.functions = [];
70
+ this.agentSpecificVariables = [
71
+ { name: 'file', usedInPrompt: true, description: 'The uri of the file being edited.' },
72
+ { name: 'language', usedInPrompt: true, description: 'The languageId of the file being edited.' },
73
+ { name: 'prefix', usedInPrompt: true, description: 'The code before the current position of the cursor.' },
74
+ { name: 'suffix', usedInPrompt: true, description: 'The code after the current position of the cursor.' }
75
+ ];
76
+ }
77
+ async provideInlineCompletions(model, position, context, token) {
78
+ const progress = await this.progressService.showProgress({ text: 'Calculating AI code completion...', options: { location: 'window' } });
79
+ try {
80
+ const languageModel = await this.languageModelRegistry.selectLanguageModel({
81
+ agent: this.id,
82
+ ...this.languageModelRequirements[0],
83
+ });
84
+ if (!languageModel) {
85
+ this.logger.error('No language model found for code-completion-agent');
86
+ return undefined;
87
+ }
88
+ const maxContextLines = this.preferences.get(ai_code_completion_preference_1.PREF_AI_INLINE_COMPLETION_MAX_CONTEXT_LINES, -1);
89
+ let prefixStartLine = 1;
90
+ let suffixEndLine = model.getLineCount();
91
+ // if maxContextLines is -1, use the full file as context without any line limit
92
+ if (maxContextLines === 0) {
93
+ // Only the cursor line
94
+ prefixStartLine = position.lineNumber;
95
+ suffixEndLine = position.lineNumber;
96
+ }
97
+ else if (maxContextLines > 0) {
98
+ const linesBeforeCursor = position.lineNumber - 1;
99
+ const linesAfterCursor = model.getLineCount() - position.lineNumber;
100
+ // Allocate one more line to the prefix in case of an odd maxContextLines
101
+ const prefixLines = Math.min(Math.ceil(maxContextLines / 2), linesBeforeCursor);
102
+ const suffixLines = Math.min(Math.floor(maxContextLines / 2), linesAfterCursor);
103
+ prefixStartLine = Math.max(1, position.lineNumber - prefixLines);
104
+ suffixEndLine = Math.min(model.getLineCount(), position.lineNumber + suffixLines);
105
+ }
106
+ const prefix = model.getValueInRange({
107
+ startLineNumber: prefixStartLine,
108
+ startColumn: 1,
109
+ endLineNumber: position.lineNumber,
110
+ endColumn: position.column,
111
+ });
112
+ const suffix = model.getValueInRange({
113
+ startLineNumber: position.lineNumber,
114
+ startColumn: position.column,
115
+ endLineNumber: suffixEndLine,
116
+ endColumn: model.getLineMaxColumn(suffixEndLine),
117
+ });
118
+ const file = model.uri.toString(false);
119
+ const language = model.getLanguageId();
120
+ if (token.isCancellationRequested) {
121
+ return undefined;
122
+ }
123
+ const prompt = await this.promptService
124
+ .getPrompt('code-completion-prompt', { prefix, suffix, file, language })
125
+ .then(p => p === null || p === void 0 ? void 0 : p.text);
126
+ if (!prompt) {
127
+ this.logger.error('No prompt found for code-completion-agent');
128
+ return undefined;
129
+ }
130
+ // since we do not actually hold complete conversions, the request/response pair is considered a session
131
+ const sessionId = (0, core_1.generateUuid)();
132
+ const requestId = (0, core_1.generateUuid)();
133
+ const request = {
134
+ messages: [{ type: 'text', actor: 'user', query: prompt }],
135
+ settings: {
136
+ stream: false
137
+ }
138
+ };
139
+ if (token.isCancellationRequested) {
140
+ return undefined;
141
+ }
142
+ this.recordingService.recordRequest({
143
+ agentId: this.id,
144
+ sessionId,
145
+ requestId,
146
+ request: prompt,
147
+ });
148
+ const response = await languageModel.request(request, token);
149
+ if (token.isCancellationRequested) {
150
+ return undefined;
151
+ }
152
+ const completionText = await (0, common_1.getTextOfResponse)(response);
153
+ if (token.isCancellationRequested) {
154
+ return undefined;
155
+ }
156
+ this.recordingService.recordResponse({
157
+ agentId: this.id,
158
+ sessionId,
159
+ requestId,
160
+ response: completionText,
161
+ });
162
+ const postProcessedCompletionText = this.postProcessor.postProcess(completionText);
163
+ return {
164
+ items: [{ insertText: postProcessedCompletionText }],
165
+ enableForwardStability: true,
166
+ };
167
+ }
168
+ catch (e) {
169
+ if (!token.isCancellationRequested) {
170
+ console.error(e.message, e);
171
+ }
172
+ }
173
+ finally {
174
+ progress.cancel();
175
+ }
176
+ }
177
+ };
178
+ exports.CodeCompletionAgentImpl = CodeCompletionAgentImpl;
179
+ tslib_1.__decorate([
180
+ (0, inversify_1.inject)(core_1.ILogger),
181
+ (0, inversify_1.named)('code-completion-agent'),
182
+ tslib_1.__metadata("design:type", Object)
183
+ ], CodeCompletionAgentImpl.prototype, "logger", void 0);
184
+ tslib_1.__decorate([
185
+ (0, inversify_1.inject)(common_1.LanguageModelRegistry),
186
+ tslib_1.__metadata("design:type", Object)
187
+ ], CodeCompletionAgentImpl.prototype, "languageModelRegistry", void 0);
188
+ tslib_1.__decorate([
189
+ (0, inversify_1.inject)(common_1.PromptService),
190
+ tslib_1.__metadata("design:type", Object)
191
+ ], CodeCompletionAgentImpl.prototype, "promptService", void 0);
192
+ tslib_1.__decorate([
193
+ (0, inversify_1.inject)(common_1.CommunicationRecordingService),
194
+ tslib_1.__metadata("design:type", Object)
195
+ ], CodeCompletionAgentImpl.prototype, "recordingService", void 0);
196
+ tslib_1.__decorate([
197
+ (0, inversify_1.inject)(core_1.ProgressService),
198
+ tslib_1.__metadata("design:type", core_1.ProgressService)
199
+ ], CodeCompletionAgentImpl.prototype, "progressService", void 0);
200
+ tslib_1.__decorate([
201
+ (0, inversify_1.inject)(browser_1.PreferenceService),
202
+ tslib_1.__metadata("design:type", Object)
203
+ ], CodeCompletionAgentImpl.prototype, "preferences", void 0);
204
+ tslib_1.__decorate([
205
+ (0, inversify_1.inject)(code_completion_postprocessor_1.CodeCompletionPostProcessor),
206
+ tslib_1.__metadata("design:type", Object)
207
+ ], CodeCompletionAgentImpl.prototype, "postProcessor", void 0);
208
+ exports.CodeCompletionAgentImpl = CodeCompletionAgentImpl = tslib_1.__decorate([
209
+ (0, inversify_1.injectable)()
210
+ ], CodeCompletionAgentImpl);
211
+ //# sourceMappingURL=code-completion-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-completion-agent.js","sourceRoot":"","sources":["../../src/browser/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,sCAAqE;AACrE,4DAAyE;AAEzE,mFAA8F;AAC9F,qDAA4D;AAC5D,mFAA8E;AAEjE,QAAA,mBAAmB,GAAG,M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AAO,EAAE,CAAC,CAAC,CAAC;YAChC,CAAC;QACL,CAAC;gBACO,CAAC;YACL,QAAQ,CAAC,MAAM,EAAE,CAAC;QACtB,CAAC;IACL,CAAC;CAyEJ,CAAA;AAtMY,0DAAuB;AAiItB;IAFT,IAAA,kBAAM,EAAC,cAAO,CAAC;IACf,IAAA,iBAAK,EAAC,uBAAuB,CAAC;;uDACL;AAGhB;IADT,IAAA,kBAAM,EAAC,8BAAqB,CAAC;;sEACyB;AAG7C;IADT,IAAA,kBAAM,EAAC,sBAAa,CAAC;;8DACiB;AAG7B;IADT,IAAA,kBAAM,EAAC,sCAA6B,CAAC;;iEACoB;AAGhD;IADT,IAAA,kBAAM,EAAC,sBAAe,CAAC;sCACG,sBAAe;gEAAC;AAGjC;IADT,IAAA,kBAAM,EAAC,2BAAiB,CAAC;;4DACe;AAG/B;IADT,IAAA,kBAAM,EAAC,2DAA2B,CAAC;;8DACiB;kCAnJ5C,uBAAuB;IADnC,IAAA,sBAAU,GAAE;GACA,uBAAuB,CAsMnC"}
@@ -0,0 +1,11 @@
1
+ import { PreferenceService } from '@theia/core/lib/browser';
2
+ export interface CodeCompletionPostProcessor {
3
+ postProcess(text: string): string;
4
+ }
5
+ export declare const CodeCompletionPostProcessor: unique symbol;
6
+ export declare class DefaultCodeCompletionPostProcessor {
7
+ protected readonly preferenceService: PreferenceService;
8
+ postProcess(text: string): string;
9
+ stripBackticks(text: string): string;
10
+ }
11
+ //# sourceMappingURL=code-completion-postprocessor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-completion-postprocessor.d.ts","sourceRoot":"","sources":["../../src/browser/code-completion-postprocessor.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,MAAM,WAAW,2BAA2B;IACxC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACrC;AACD,eAAO,MAAM,2BAA2B,eAAwC,CAAC;AAEjF,qBACa,kCAAkC;IAG3C,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAEjD,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAOjC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAS9C"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2024 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.DefaultCodeCompletionPostProcessor = exports.CodeCompletionPostProcessor = 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 ai_code_completion_preference_1 = require("./ai-code-completion-preference");
23
+ exports.CodeCompletionPostProcessor = Symbol('CodeCompletionPostProcessor');
24
+ let DefaultCodeCompletionPostProcessor = class DefaultCodeCompletionPostProcessor {
25
+ postProcess(text) {
26
+ if (this.preferenceService.get(ai_code_completion_preference_1.PREF_AI_INLINE_COMPLETION_STRIP_BACKTICKS, true)) {
27
+ return this.stripBackticks(text);
28
+ }
29
+ return text;
30
+ }
31
+ stripBackticks(text) {
32
+ if (text.startsWith('```')) {
33
+ // Remove the first backticks and any language identifier
34
+ const startRemoved = text.slice(3).replace(/^\w*\n/, '');
35
+ const lastBacktickIndex = startRemoved.lastIndexOf('```');
36
+ return lastBacktickIndex !== -1 ? startRemoved.slice(0, lastBacktickIndex).trim() : startRemoved.trim();
37
+ }
38
+ return text;
39
+ }
40
+ };
41
+ exports.DefaultCodeCompletionPostProcessor = DefaultCodeCompletionPostProcessor;
42
+ tslib_1.__decorate([
43
+ (0, inversify_1.inject)(browser_1.PreferenceService),
44
+ tslib_1.__metadata("design:type", Object)
45
+ ], DefaultCodeCompletionPostProcessor.prototype, "preferenceService", void 0);
46
+ exports.DefaultCodeCompletionPostProcessor = DefaultCodeCompletionPostProcessor = tslib_1.__decorate([
47
+ (0, inversify_1.injectable)()
48
+ ], DefaultCodeCompletionPostProcessor);
49
+ //# sourceMappingURL=code-completion-postprocessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-completion-postprocessor.js","sourceRoot":"","sources":["../../src/browser/code-completion-postprocessor.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,4DAAkE;AAClE,qDAA4D;AAC5D,mFAA4F;AAK/E,QAAA,2BAA2B,GAAG,MAAM,CAAC,6BAA6B,CAAC,CAAC;AAG1E,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IAKpC,WAAW,CAAC,IAAY;QAC3B,IAAI,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAU,yEAAyC,EAAE,IAAI,CAAC,EAAE,CAAC;YACvF,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,cAAc,CAAC,IAAY;QAC9B,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,yDAAyD;YACzD,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACzD,MAAM,iBAAiB,GAAG,YAAY,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YAC1D,OAAO,iBAAiB,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;QAC5G,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ,CAAA;AArBY,gFAAkC;AAGxB;IADlB,IAAA,kBAAM,EAAC,2BAAiB,CAAC;;6EAC8B;6CAH/C,kCAAkC;IAD9C,IAAA,sBAAU,GAAE;GACA,kCAAkC,CAqB9C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=code-completion-postprocessor.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-completion-postprocessor.spec.d.ts","sourceRoot":"","sources":["../../src/browser/code-completion-postprocessor.spec.ts"],"names":[],"mappings":""}