@theia/ai-chat 1.60.2 → 1.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/ai-chat-frontend-contribution.d.ts +11 -0
- package/lib/browser/ai-chat-frontend-contribution.d.ts.map +1 -0
- package/lib/browser/ai-chat-frontend-contribution.js +56 -0
- package/lib/browser/ai-chat-frontend-contribution.js.map +1 -0
- package/lib/browser/ai-chat-frontend-module.d.ts.map +1 -1
- package/lib/browser/ai-chat-frontend-module.js +21 -3
- package/lib/browser/ai-chat-frontend-module.js.map +1 -1
- package/lib/browser/change-set-decorator-service.d.ts +24 -0
- package/lib/browser/change-set-decorator-service.d.ts.map +1 -0
- package/lib/browser/change-set-decorator-service.js +66 -0
- package/lib/browser/change-set-decorator-service.js.map +1 -0
- package/lib/browser/change-set-file-element.d.ts +7 -4
- package/lib/browser/change-set-file-element.d.ts.map +1 -1
- package/lib/browser/change-set-file-element.js +20 -12
- package/lib/browser/change-set-file-element.js.map +1 -1
- package/lib/browser/change-set-file-resource.d.ts +1 -42
- package/lib/browser/change-set-file-resource.d.ts.map +1 -1
- package/lib/browser/change-set-file-resource.js +1 -136
- package/lib/browser/change-set-file-resource.js.map +1 -1
- package/lib/browser/change-set-variable.d.ts.map +1 -1
- package/lib/browser/change-set-variable.js +13 -4
- package/lib/browser/change-set-variable.js.map +1 -1
- package/lib/browser/context-file-variable-label-provider.js +1 -1
- package/lib/browser/context-file-variable-label-provider.js.map +1 -1
- package/lib/browser/file-chat-variable-contribution.d.ts.map +1 -1
- package/lib/browser/file-chat-variable-contribution.js +29 -27
- package/lib/browser/file-chat-variable-contribution.js.map +1 -1
- package/lib/browser/task-context-service.d.ts +40 -0
- package/lib/browser/task-context-service.d.ts.map +1 -0
- package/lib/browser/task-context-service.js +148 -0
- package/lib/browser/task-context-service.js.map +1 -0
- package/lib/browser/task-context-storage-service.d.ts +18 -0
- package/lib/browser/task-context-storage-service.d.ts.map +1 -0
- package/lib/browser/task-context-storage-service.js +77 -0
- package/lib/browser/task-context-storage-service.js.map +1 -0
- package/lib/browser/task-context-variable-contribution.d.ts +20 -0
- package/lib/browser/task-context-variable-contribution.d.ts.map +1 -0
- package/lib/browser/task-context-variable-contribution.js +101 -0
- package/lib/browser/task-context-variable-contribution.js.map +1 -0
- package/lib/browser/task-context-variable-label-provider.d.ts +21 -0
- package/lib/browser/task-context-variable-label-provider.d.ts.map +1 -0
- package/lib/browser/task-context-variable-label-provider.js +83 -0
- package/lib/browser/task-context-variable-label-provider.js.map +1 -0
- package/lib/browser/task-context-variable.d.ts +3 -0
- package/lib/browser/task-context-variable.d.ts.map +1 -0
- package/lib/browser/task-context-variable.js +29 -0
- package/lib/browser/task-context-variable.js.map +1 -0
- package/lib/common/chat-agents.d.ts +2 -1
- package/lib/common/chat-agents.d.ts.map +1 -1
- package/lib/common/chat-agents.js +32 -20
- package/lib/common/chat-agents.js.map +1 -1
- package/lib/common/chat-model.d.ts +191 -8
- package/lib/common/chat-model.d.ts.map +1 -1
- package/lib/common/chat-model.js +369 -12
- package/lib/common/chat-model.js.map +1 -1
- package/lib/common/chat-request-parser.d.ts +1 -1
- package/lib/common/chat-request-parser.d.ts.map +1 -1
- package/lib/common/chat-request-parser.js +1 -1
- package/lib/common/chat-request-parser.js.map +1 -1
- package/lib/common/chat-service.d.ts +2 -0
- package/lib/common/chat-service.d.ts.map +1 -1
- package/lib/common/chat-service.js +18 -25
- package/lib/common/chat-service.js.map +1 -1
- package/lib/common/chat-session-naming-service.d.ts.map +1 -1
- package/lib/common/chat-session-naming-service.js +9 -11
- package/lib/common/chat-session-naming-service.js.map +1 -1
- package/lib/common/chat-session-summary-agent-prompt.d.ts +5 -0
- package/lib/common/chat-session-summary-agent-prompt.d.ts.map +1 -0
- package/lib/common/chat-session-summary-agent-prompt.js +30 -0
- package/lib/common/chat-session-summary-agent-prompt.js.map +1 -0
- package/lib/common/chat-session-summary-agent.d.ts +17 -0
- package/lib/common/chat-session-summary-agent.d.ts.map +1 -0
- package/lib/common/chat-session-summary-agent.js +48 -0
- package/lib/common/chat-session-summary-agent.js.map +1 -0
- package/lib/common/context-summary-variable.js +1 -1
- package/lib/common/context-summary-variable.js.map +1 -1
- package/lib/common/parse-contents-with-incomplete-parts.spec.d.ts +2 -0
- package/lib/common/parse-contents-with-incomplete-parts.spec.d.ts.map +1 -0
- package/lib/common/parse-contents-with-incomplete-parts.spec.js +103 -0
- package/lib/common/parse-contents-with-incomplete-parts.spec.js.map +1 -0
- package/lib/common/parse-contents.d.ts +1 -0
- package/lib/common/parse-contents.d.ts.map +1 -1
- package/lib/common/parse-contents.js +45 -5
- package/lib/common/parse-contents.js.map +1 -1
- package/lib/common/parse-contents.spec.d.ts +1 -0
- package/lib/common/parse-contents.spec.d.ts.map +1 -1
- package/lib/common/parse-contents.spec.js +25 -13
- package/lib/common/parse-contents.spec.js.map +1 -1
- package/lib/common/response-content-matcher.d.ts +6 -0
- package/lib/common/response-content-matcher.d.ts.map +1 -1
- package/lib/common/response-content-matcher.js +14 -3
- package/lib/common/response-content-matcher.js.map +1 -1
- package/package.json +11 -11
- package/src/browser/ai-chat-frontend-contribution.ts +49 -0
- package/src/browser/ai-chat-frontend-module.ts +25 -4
- package/src/browser/change-set-decorator-service.ts +72 -0
- package/src/browser/change-set-file-element.ts +18 -13
- package/src/browser/change-set-file-resource.ts +1 -138
- package/src/browser/change-set-variable.ts +14 -6
- package/src/browser/context-file-variable-label-provider.ts +1 -1
- package/src/browser/file-chat-variable-contribution.ts +26 -29
- package/src/browser/task-context-service.ts +144 -0
- package/src/browser/task-context-storage-service.ts +75 -0
- package/src/browser/task-context-variable-contribution.ts +93 -0
- package/src/browser/task-context-variable-label-provider.ts +67 -0
- package/src/browser/task-context-variable.ts +28 -0
- package/src/common/chat-agents.ts +38 -22
- package/src/common/chat-model.ts +566 -17
- package/src/common/chat-request-parser.ts +2 -2
- package/src/common/chat-service.ts +17 -26
- package/src/common/chat-session-naming-service.ts +13 -15
- package/src/common/chat-session-summary-agent-prompt.ts +28 -0
- package/src/common/chat-session-summary-agent.ts +42 -0
- package/src/common/context-summary-variable.ts +1 -1
- package/src/common/parse-contents-with-incomplete-parts.spec.ts +114 -0
- package/src/common/parse-contents.spec.ts +24 -12
- package/src/common/parse-contents.ts +52 -6
- package/src/common/response-content-matcher.ts +21 -3
|
@@ -24,7 +24,18 @@ function parseContents(text, request, contentMatchers = [response_content_matche
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
// 2. Add the matched content object
|
|
27
|
-
|
|
27
|
+
if (match.isComplete) {
|
|
28
|
+
// Complete match, use regular content factory
|
|
29
|
+
result.push(match.matcher.contentFactory(match.content, request));
|
|
30
|
+
}
|
|
31
|
+
else if (match.matcher.incompleteContentFactory) {
|
|
32
|
+
// Incomplete match with an incomplete content factory available
|
|
33
|
+
result.push(match.matcher.incompleteContentFactory(match.content, request));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// Incomplete match but no incomplete content factory available, use default
|
|
37
|
+
result.push(defaultContentFactory(match.content, request));
|
|
38
|
+
}
|
|
28
39
|
// Update currentIndex to the end of the end of the match
|
|
29
40
|
// And continue with the search after the end of the match
|
|
30
41
|
currentIndex += match.index + match.content.length;
|
|
@@ -34,6 +45,7 @@ function parseContents(text, request, contentMatchers = [response_content_matche
|
|
|
34
45
|
exports.parseContents = parseContents;
|
|
35
46
|
function findFirstMatch(contentMatchers, text) {
|
|
36
47
|
let firstMatch;
|
|
48
|
+
let firstIncompleteMatch;
|
|
37
49
|
for (const matcher of contentMatchers) {
|
|
38
50
|
const startMatch = matcher.start.exec(text);
|
|
39
51
|
if (!startMatch) {
|
|
@@ -43,13 +55,35 @@ function findFirstMatch(contentMatchers, text) {
|
|
|
43
55
|
const endOfStartMatch = startMatch.index + startMatch[0].length;
|
|
44
56
|
if (endOfStartMatch >= text.length) {
|
|
45
57
|
// There is no text after the start match.
|
|
46
|
-
//
|
|
58
|
+
// This is an incomplete match if the matcher has an incompleteContentFactory
|
|
59
|
+
if (matcher.incompleteContentFactory) {
|
|
60
|
+
const incompleteMatch = {
|
|
61
|
+
matcher,
|
|
62
|
+
index: startMatch.index,
|
|
63
|
+
content: text.substring(startMatch.index),
|
|
64
|
+
isComplete: false
|
|
65
|
+
};
|
|
66
|
+
if (!firstIncompleteMatch || incompleteMatch.index < firstIncompleteMatch.index) {
|
|
67
|
+
firstIncompleteMatch = incompleteMatch;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
47
70
|
continue;
|
|
48
71
|
}
|
|
49
72
|
const remainingTextAfterStartMatch = text.substring(endOfStartMatch);
|
|
50
73
|
const endMatch = matcher.end.exec(remainingTextAfterStartMatch);
|
|
51
74
|
if (!endMatch) {
|
|
52
|
-
// No end match found,
|
|
75
|
+
// No end match found, this is an incomplete match
|
|
76
|
+
if (matcher.incompleteContentFactory) {
|
|
77
|
+
const incompleteMatch = {
|
|
78
|
+
matcher,
|
|
79
|
+
index: startMatch.index,
|
|
80
|
+
content: text.substring(startMatch.index),
|
|
81
|
+
isComplete: false
|
|
82
|
+
};
|
|
83
|
+
if (!firstIncompleteMatch || incompleteMatch.index < firstIncompleteMatch.index) {
|
|
84
|
+
firstIncompleteMatch = incompleteMatch;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
53
87
|
continue;
|
|
54
88
|
}
|
|
55
89
|
// Found start and end match.
|
|
@@ -57,11 +91,17 @@ function findFirstMatch(contentMatchers, text) {
|
|
|
57
91
|
const index = startMatch.index;
|
|
58
92
|
const contentEnd = index + startMatch[0].length + endMatch.index + endMatch[0].length;
|
|
59
93
|
const content = text.substring(index, contentEnd);
|
|
94
|
+
const completeMatch = { matcher, index, content, isComplete: true };
|
|
60
95
|
if (!firstMatch || index < firstMatch.index) {
|
|
61
|
-
firstMatch =
|
|
96
|
+
firstMatch = completeMatch;
|
|
62
97
|
}
|
|
63
98
|
}
|
|
64
|
-
return
|
|
99
|
+
// If we found a complete match, return it
|
|
100
|
+
if (firstMatch) {
|
|
101
|
+
return firstMatch;
|
|
102
|
+
}
|
|
103
|
+
// Otherwise, return the first incomplete match if one exists
|
|
104
|
+
return firstIncompleteMatch;
|
|
65
105
|
}
|
|
66
106
|
exports.findFirstMatch = findFirstMatch;
|
|
67
107
|
//# sourceMappingURL=parse-contents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-contents.js","sourceRoot":"","sources":["../../src/common/parse-contents.ts"],"names":[],"mappings":";;;AAgBA,yEAAwI;
|
|
1
|
+
{"version":3,"file":"parse-contents.js","sourceRoot":"","sources":["../../src/common/parse-contents.ts"],"names":[],"mappings":";;;AAgBA,yEAAwI;AASxI,SAAgB,aAAa,CACzB,IAAY,EACZ,OAAgC,EAChC,kBAA4C,CAAC,6CAAkB,CAAC,EAChE,wBAAgD,iDAAsB;IAEtE,MAAM,MAAM,GAA0B,EAAE,CAAC;IAEzC,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,OAAO,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAChC,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QACnD,MAAM,KAAK,GAAG,cAAc,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QAC7D,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,4CAA4C;YAC5C,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3B,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;YAC/D,CAAC;YACD,MAAM;QACV,CAAC;QACD,kBAAkB;QAClB,2CAA2C;QAC3C,IAAI,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;YAClB,MAAM,gBAAgB,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;YACjE,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,MAAM,GA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AC,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACtF,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAClD,MAAM,aAAa,GAAU,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QAE3E,IAAI,CAAC,UAAU,IAAI,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC;YAC1C,UAAU,GAAG,aAAa,CAAC;QAC/B,CAAC;IACL,CAAC;IAED,0CAA0C;IAC1C,IAAI,UAAU,EAAE,CAAC;QACb,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,6DAA6D;IAC7D,OAAO,oBAAoB,CAAC;AAChC,CAAC;AAlED,wCAkEC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ChatResponseContent } from './chat-model';
|
|
2
2
|
import { ResponseContentMatcher } from './response-content-matcher';
|
|
3
|
+
export declare const TestCodeContentMatcher: ResponseContentMatcher;
|
|
3
4
|
export declare class CommandChatResponseContentImpl implements ChatResponseContent {
|
|
4
5
|
readonly command: string;
|
|
5
6
|
constructor(command: string);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-contents.spec.d.ts","sourceRoot":"","sources":["../../src/common/parse-contents.spec.ts"],"names":[],"mappings":"AAiBA,OAAO,EAA2B,mBAAmB,EAAgE,MAAM,cAAc,CAAC;AAE1I,OAAO,EAAsB,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAExF,qBAAa,8BAA+B,YAAW,mBAAmB;aAC1C,OAAO,EAAE,MAAM;gBAAf,OAAO,EAAE,MAAM;IAC3C,IAAI,SAAa;CACpB;AAED,eAAO,MAAM,qBAAqB,EAAE,sBAOnC,CAAC"}
|
|
1
|
+
{"version":3,"file":"parse-contents.spec.d.ts","sourceRoot":"","sources":["../../src/common/parse-contents.spec.ts"],"names":[],"mappings":"AAiBA,OAAO,EAA2B,mBAAmB,EAAgE,MAAM,cAAc,CAAC;AAE1I,OAAO,EAAsB,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAExF,eAAO,MAAM,sBAAsB,EAAE,sBAQpC,CAAC;AAEF,qBAAa,8BAA+B,YAAW,mBAAmB;aAC1C,OAAO,EAAE,MAAM;gBAAf,OAAO,EAAE,MAAM;IAC3C,IAAI,SAAa;CACpB;AAED,eAAO,MAAM,qBAAqB,EAAE,sBAOnC,CAAC"}
|
|
@@ -15,11 +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.CommandContentMatcher = exports.CommandChatResponseContentImpl = void 0;
|
|
18
|
+
exports.CommandContentMatcher = exports.CommandChatResponseContentImpl = exports.TestCodeContentMatcher = void 0;
|
|
19
19
|
const chai_1 = require("chai");
|
|
20
20
|
const chat_model_1 = require("./chat-model");
|
|
21
21
|
const parse_contents_1 = require("./parse-contents");
|
|
22
22
|
const response_content_matcher_1 = require("./response-content-matcher");
|
|
23
|
+
exports.TestCodeContentMatcher = {
|
|
24
|
+
start: /^```.*?$/m,
|
|
25
|
+
end: /^```$/m,
|
|
26
|
+
contentFactory: (content) => {
|
|
27
|
+
var _a;
|
|
28
|
+
const language = ((_a = content.match(/^```(\w+)/)) === null || _a === void 0 ? void 0 : _a[1]) || '';
|
|
29
|
+
const code = content.replace(/^```(\w+)\n|```$/g, '');
|
|
30
|
+
return new chat_model_1.CodeChatResponseContentImpl(code.trim(), language);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
23
33
|
class CommandChatResponseContentImpl {
|
|
24
34
|
constructor(command) {
|
|
25
35
|
this.command = command;
|
|
@@ -39,17 +49,17 @@ const fakeRequest = {};
|
|
|
39
49
|
describe('parseContents', () => {
|
|
40
50
|
it('should parse code content', () => {
|
|
41
51
|
const text = '```typescript\nconsole.log("Hello World");\n```';
|
|
42
|
-
const result = (0, parse_contents_1.parseContents)(text, fakeRequest);
|
|
52
|
+
const result = (0, parse_contents_1.parseContents)(text, fakeRequest, [exports.TestCodeContentMatcher]);
|
|
43
53
|
(0, chai_1.expect)(result).to.deep.equal([new chat_model_1.CodeChatResponseContentImpl('console.log("Hello World");', 'typescript')]);
|
|
44
54
|
});
|
|
45
55
|
it('should parse markdown content', () => {
|
|
46
56
|
const text = 'Hello **World**';
|
|
47
|
-
const result = (0, parse_contents_1.parseContents)(text, fakeRequest);
|
|
57
|
+
const result = (0, parse_contents_1.parseContents)(text, fakeRequest, [exports.TestCodeContentMatcher]);
|
|
48
58
|
(0, chai_1.expect)(result).to.deep.equal([new chat_model_1.MarkdownChatResponseContentImpl('Hello **World**')]);
|
|
49
59
|
});
|
|
50
60
|
it('should parse multiple content blocks', () => {
|
|
51
61
|
const text = '```typescript\nconsole.log("Hello World");\n```\nHello **World**';
|
|
52
|
-
const result = (0, parse_contents_1.parseContents)(text, fakeRequest);
|
|
62
|
+
const result = (0, parse_contents_1.parseContents)(text, fakeRequest, [exports.TestCodeContentMatcher]);
|
|
53
63
|
(0, chai_1.expect)(result).to.deep.equal([
|
|
54
64
|
new chat_model_1.CodeChatResponseContentImpl('console.log("Hello World");', 'typescript'),
|
|
55
65
|
new chat_model_1.MarkdownChatResponseContentImpl('\nHello **World**')
|
|
@@ -57,7 +67,7 @@ describe('parseContents', () => {
|
|
|
57
67
|
});
|
|
58
68
|
it('should parse multiple content blocks with different languages', () => {
|
|
59
69
|
const text = '```typescript\nconsole.log("Hello World");\n```\n```python\nprint("Hello World")\n```';
|
|
60
|
-
const result = (0, parse_contents_1.parseContents)(text, fakeRequest);
|
|
70
|
+
const result = (0, parse_contents_1.parseContents)(text, fakeRequest, [exports.TestCodeContentMatcher]);
|
|
61
71
|
(0, chai_1.expect)(result).to.deep.equal([
|
|
62
72
|
new chat_model_1.CodeChatResponseContentImpl('console.log("Hello World");', 'typescript'),
|
|
63
73
|
new chat_model_1.CodeChatResponseContentImpl('print("Hello World")', 'python')
|
|
@@ -65,7 +75,7 @@ describe('parseContents', () => {
|
|
|
65
75
|
});
|
|
66
76
|
it('should parse multiple content blocks with different languages and markdown', () => {
|
|
67
77
|
const text = '```typescript\nconsole.log("Hello World");\n```\nHello **World**\n```python\nprint("Hello World")\n```';
|
|
68
|
-
const result = (0, parse_contents_1.parseContents)(text, fakeRequest);
|
|
78
|
+
const result = (0, parse_contents_1.parseContents)(text, fakeRequest, [exports.TestCodeContentMatcher]);
|
|
69
79
|
(0, chai_1.expect)(result).to.deep.equal([
|
|
70
80
|
new chat_model_1.CodeChatResponseContentImpl('console.log("Hello World");', 'typescript'),
|
|
71
81
|
new chat_model_1.MarkdownChatResponseContentImpl('\nHello **World**\n'),
|
|
@@ -74,7 +84,7 @@ describe('parseContents', () => {
|
|
|
74
84
|
});
|
|
75
85
|
it('should parse content blocks with empty content', () => {
|
|
76
86
|
const text = '```typescript\n```\nHello **World**\n```python\nprint("Hello World")\n```';
|
|
77
|
-
const result = (0, parse_contents_1.parseContents)(text, fakeRequest);
|
|
87
|
+
const result = (0, parse_contents_1.parseContents)(text, fakeRequest, [exports.TestCodeContentMatcher]);
|
|
78
88
|
(0, chai_1.expect)(result).to.deep.equal([
|
|
79
89
|
new chat_model_1.CodeChatResponseContentImpl('', 'typescript'),
|
|
80
90
|
new chat_model_1.MarkdownChatResponseContentImpl('\nHello **World**\n'),
|
|
@@ -83,7 +93,7 @@ describe('parseContents', () => {
|
|
|
83
93
|
});
|
|
84
94
|
it('should parse content with markdown, code, and markdown', () => {
|
|
85
95
|
const text = 'Hello **World**\n```typescript\nconsole.log("Hello World");\n```\nGoodbye **World**';
|
|
86
|
-
const result = (0, parse_contents_1.parseContents)(text, fakeRequest);
|
|
96
|
+
const result = (0, parse_contents_1.parseContents)(text, fakeRequest, [exports.TestCodeContentMatcher]);
|
|
87
97
|
(0, chai_1.expect)(result).to.deep.equal([
|
|
88
98
|
new chat_model_1.MarkdownChatResponseContentImpl('Hello **World**\n'),
|
|
89
99
|
new chat_model_1.CodeChatResponseContentImpl('console.log("Hello World");', 'typescript'),
|
|
@@ -92,30 +102,32 @@ describe('parseContents', () => {
|
|
|
92
102
|
});
|
|
93
103
|
it('should handle text with no special content', () => {
|
|
94
104
|
const text = 'Just some plain text.';
|
|
95
|
-
const result = (0, parse_contents_1.parseContents)(text, fakeRequest);
|
|
105
|
+
const result = (0, parse_contents_1.parseContents)(text, fakeRequest, [exports.TestCodeContentMatcher]);
|
|
96
106
|
(0, chai_1.expect)(result).to.deep.equal([new chat_model_1.MarkdownChatResponseContentImpl('Just some plain text.')]);
|
|
97
107
|
});
|
|
98
108
|
it('should handle text with only start code block', () => {
|
|
99
109
|
const text = '```typescript\nconsole.log("Hello World");';
|
|
110
|
+
// We're using the standard CodeContentMatcher which has incompleteContentFactory
|
|
100
111
|
const result = (0, parse_contents_1.parseContents)(text, fakeRequest);
|
|
101
|
-
(0, chai_1.expect)(result).to.deep.equal([new chat_model_1.
|
|
112
|
+
(0, chai_1.expect)(result).to.deep.equal([new chat_model_1.CodeChatResponseContentImpl('console.log("Hello World");', 'typescript')]);
|
|
102
113
|
});
|
|
103
114
|
it('should handle text with only end code block', () => {
|
|
104
115
|
const text = 'console.log("Hello World");\n```';
|
|
105
|
-
const result = (0, parse_contents_1.parseContents)(text, fakeRequest);
|
|
116
|
+
const result = (0, parse_contents_1.parseContents)(text, fakeRequest, [exports.TestCodeContentMatcher]);
|
|
106
117
|
(0, chai_1.expect)(result).to.deep.equal([new chat_model_1.MarkdownChatResponseContentImpl('console.log("Hello World");\n```')]);
|
|
107
118
|
});
|
|
108
119
|
it('should handle text with unmatched code block', () => {
|
|
109
120
|
const text = '```typescript\nconsole.log("Hello World");\n```\n```python\nprint("Hello World")';
|
|
121
|
+
// We're using the standard CodeContentMatcher which has incompleteContentFactory
|
|
110
122
|
const result = (0, parse_contents_1.parseContents)(text, fakeRequest);
|
|
111
123
|
(0, chai_1.expect)(result).to.deep.equal([
|
|
112
124
|
new chat_model_1.CodeChatResponseContentImpl('console.log("Hello World");', 'typescript'),
|
|
113
|
-
new chat_model_1.
|
|
125
|
+
new chat_model_1.CodeChatResponseContentImpl('print("Hello World")', 'python')
|
|
114
126
|
]);
|
|
115
127
|
});
|
|
116
128
|
it('should parse code block without newline after language', () => {
|
|
117
129
|
const text = '```typescript console.log("Hello World");```';
|
|
118
|
-
const result = (0, parse_contents_1.parseContents)(text, fakeRequest);
|
|
130
|
+
const result = (0, parse_contents_1.parseContents)(text, fakeRequest, [exports.TestCodeContentMatcher]);
|
|
119
131
|
(0, chai_1.expect)(result).to.deep.equal([
|
|
120
132
|
new chat_model_1.MarkdownChatResponseContentImpl('```typescript console.log("Hello World");```')
|
|
121
133
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-contents.spec.js","sourceRoot":"","sources":["../../src/common/parse-contents.spec.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,+BAA8B;AAC9B,6CAA0I;AAC1I,qDAAiD;AACjD,yEAAwF;
|
|
1
|
+
{"version":3,"file":"parse-contents.spec.js","sourceRoot":"","sources":["../../src/common/parse-contents.spec.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,+BAA8B;AAC9B,6CAA0I;AAC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seContentMatcher {
|
|
|
24
24
|
* from start index to end index of the match (including delimiters).
|
|
25
25
|
*/
|
|
26
26
|
contentFactory: ResponseContentFactory;
|
|
27
|
+
/**
|
|
28
|
+
* Optional factory for creating a response content when only the start delimiter has been matched,
|
|
29
|
+
* but not yet the end delimiter. Used during streaming to provide better visual feedback.
|
|
30
|
+
* If not provided, the default content factory will be used until the end delimiter is matched.
|
|
31
|
+
*/
|
|
32
|
+
incompleteContentFactory?: ResponseContentFactory;
|
|
27
33
|
}
|
|
28
34
|
export declare const CodeContentMatcher: ResponseContentMatcher;
|
|
29
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-content-matcher.d.ts","sourceRoot":"","sources":["../../src/common/response-content-matcher.ts"],"names":[],"mappings":"AAeA,OAAO,EACH,uBAAuB,EACvB,mBAAmB,EAGtB,MAAM,cAAc,CAAC;AAGtB,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,KAAK,mBAAmB,CAAC;AAEhH,eAAO,MAAM,sBAAsB,EAAE,sBACW,CAAC;AAEjD;;;;;GAKG;AACH,qBACa,6BAA6B;IACtC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,mBAAmB;CAGjF;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACnC,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,cAAc,EAAE,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"response-content-matcher.d.ts","sourceRoot":"","sources":["../../src/common/response-content-matcher.ts"],"names":[],"mappings":"AAeA,OAAO,EACH,uBAAuB,EACvB,mBAAmB,EAGtB,MAAM,cAAc,CAAC;AAGtB,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,KAAK,mBAAmB,CAAC;AAEhH,eAAO,MAAM,sBAAsB,EAAE,sBACW,CAAC;AAEjD;;;;;GAKG;AACH,qBACa,6BAA6B;IACtC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,mBAAmB;CAGjF;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACnC,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,cAAc,EAAE,sBAAsB,CAAC;IACvC;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,sBAAsB,CAAC;CACrD;AAED,eAAO,MAAM,kBAAkB,EAAE,sBAoBhC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,8BAA8B,eAA2C,CAAC;AACvF,MAAM,WAAW,8BAA8B;IAC3C,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,EAAE,CAAC;CAC/C;AAED,qBACa,qCAAsC,YAAW,8BAA8B;IACxF,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,EAAE,CAAwB;CACtE"}
|
|
@@ -19,7 +19,7 @@ const tslib_1 = require("tslib");
|
|
|
19
19
|
*/
|
|
20
20
|
const chat_model_1 = require("./chat-model");
|
|
21
21
|
const inversify_1 = require("@theia/core/shared/inversify");
|
|
22
|
-
const MarkdownContentFactory = (content) => new chat_model_1.MarkdownChatResponseContentImpl(content);
|
|
22
|
+
const MarkdownContentFactory = (content, request) => new chat_model_1.MarkdownChatResponseContentImpl(content);
|
|
23
23
|
exports.MarkdownContentFactory = MarkdownContentFactory;
|
|
24
24
|
/**
|
|
25
25
|
* Default response content factory used if no other `ResponseContentMatcher` applies.
|
|
@@ -37,13 +37,24 @@ exports.DefaultResponseContentFactory = DefaultResponseContentFactory = tslib_1.
|
|
|
37
37
|
(0, inversify_1.injectable)()
|
|
38
38
|
], DefaultResponseContentFactory);
|
|
39
39
|
exports.CodeContentMatcher = {
|
|
40
|
-
|
|
40
|
+
// Only match when we have the complete first line ending with a newline
|
|
41
|
+
// This ensures we have the full language specification before creating the editor
|
|
42
|
+
start: /^```.*\n/m,
|
|
41
43
|
end: /^```$/m,
|
|
42
|
-
contentFactory: (content) => {
|
|
44
|
+
contentFactory: (content, request) => {
|
|
43
45
|
var _a;
|
|
44
46
|
const language = ((_a = content.match(/^```(\w+)/)) === null || _a === void 0 ? void 0 : _a[1]) || '';
|
|
45
47
|
const code = content.replace(/^```(\w+)\n|```$/g, '');
|
|
46
48
|
return new chat_model_1.CodeChatResponseContentImpl(code.trim(), language);
|
|
49
|
+
},
|
|
50
|
+
incompleteContentFactory: (content, request) => {
|
|
51
|
+
var _a;
|
|
52
|
+
// By this point, we know we have at least the complete first line with ```
|
|
53
|
+
const firstLine = content.split('\n')[0];
|
|
54
|
+
const language = ((_a = firstLine.match(/^```(\w+)/)) === null || _a === void 0 ? void 0 : _a[1]) || '';
|
|
55
|
+
// Remove the first line to get just the code content
|
|
56
|
+
const code = content.substring(content.indexOf('\n') + 1);
|
|
57
|
+
return new chat_model_1.CodeChatResponseContentImpl(code.trim(), language);
|
|
47
58
|
}
|
|
48
59
|
};
|
|
49
60
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-content-matcher.js","sourceRoot":"","sources":["../../src/common/response-content-matcher.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,6CAKsB;AACtB,4DAA0D;AAInD,MAAM,sBAAsB,GAA2B,CAAC,OAAe,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"response-content-matcher.js","sourceRoot":"","sources":["../../src/common/response-content-matcher.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,6CAKsB;AACtB,4DAA0D;AAInD,MAAM,sBAAsB,GAA2B,CAAC,OAAe,EAAE,OAAgC,EAAE,EAAE,CAChH,IAAI,4CAA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,CAAC;IAClE,CAAC;CACJ,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACU,QAAA,8BAA8B,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC;AAMhF,IAAM,qCAAqC,GAA3C,MAAM,qCAAqC;IAA3C;QACM,aAAQ,GAA6B,CAAC,0BAAkB,CAAC,CAAC;IACvE,CAAC;CAAA,CAAA;AAFY,sFAAqC;gDAArC,qCAAqC;IADjD,IAAA,sBAAU,GAAE;GACA,qCAAqC,CAEjD"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/ai-chat",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.61.0",
|
|
4
4
|
"description": "Theia - AI Chat Extension",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/ai-core": "1.
|
|
7
|
-
"@theia/ai-history": "1.
|
|
8
|
-
"@theia/core": "1.
|
|
9
|
-
"@theia/editor": "1.
|
|
10
|
-
"@theia/file-search": "1.
|
|
11
|
-
"@theia/filesystem": "1.
|
|
12
|
-
"@theia/monaco": "1.
|
|
6
|
+
"@theia/ai-core": "1.61.0",
|
|
7
|
+
"@theia/ai-history": "1.61.0",
|
|
8
|
+
"@theia/core": "1.61.0",
|
|
9
|
+
"@theia/editor": "1.61.0",
|
|
10
|
+
"@theia/file-search": "1.61.0",
|
|
11
|
+
"@theia/filesystem": "1.61.0",
|
|
12
|
+
"@theia/monaco": "1.61.0",
|
|
13
13
|
"@theia/monaco-editor-core": "1.96.302",
|
|
14
|
-
"@theia/workspace": "1.
|
|
14
|
+
"@theia/workspace": "1.61.0",
|
|
15
15
|
"minimatch": "^5.1.0",
|
|
16
16
|
"tslib": "^2.6.2"
|
|
17
17
|
},
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"watch": "theiaext watch"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@theia/ext-scripts": "1.
|
|
52
|
+
"@theia/ext-scripts": "1.61.0"
|
|
53
53
|
},
|
|
54
54
|
"nyc": {
|
|
55
55
|
"extends": "../../configs/nyc.json"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "c99af52568c2e1f453c80c1b0d1fb73c3a23dcc0"
|
|
58
58
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 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
|
+
import { AIContextVariable, AIVariableService } from '@theia/ai-core';
|
|
18
|
+
import { Command, CommandContribution, CommandRegistry } from '@theia/core';
|
|
19
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
20
|
+
import { ChatService } from '../common';
|
|
21
|
+
|
|
22
|
+
export const VARIABLE_ADD_CONTEXT_COMMAND: Command = Command.toLocalizedCommand({
|
|
23
|
+
id: 'add-context-variable',
|
|
24
|
+
label: 'Add context variable'
|
|
25
|
+
}, 'theia/ai/chat-ui/addContextVariable');
|
|
26
|
+
|
|
27
|
+
@injectable()
|
|
28
|
+
export class AIChatFrontendContribution implements CommandContribution {
|
|
29
|
+
@inject(AIVariableService)
|
|
30
|
+
protected readonly variableService: AIVariableService;
|
|
31
|
+
@inject(ChatService)
|
|
32
|
+
protected readonly chatService: ChatService;
|
|
33
|
+
|
|
34
|
+
registerCommands(registry: CommandRegistry): void {
|
|
35
|
+
registry.registerCommand(VARIABLE_ADD_CONTEXT_COMMAND, {
|
|
36
|
+
execute: (...args) => args.length > 1 && this.addContextVariable(args[0], args[1]),
|
|
37
|
+
isVisible: () => false,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async addContextVariable(variableName: string, arg: string | undefined): Promise<void> {
|
|
42
|
+
const variable = this.variableService.getVariable(variableName);
|
|
43
|
+
if (!variable || !AIContextVariable.is(variable)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
this.chatService.getActiveSession()?.model.context.addVariables({ variable, arg });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { Agent, AgentService, AIVariableContribution } from '@theia/ai-core/lib/common';
|
|
18
|
-
import { bindContributionProvider,
|
|
18
|
+
import { bindContributionProvider, CommandContribution } from '@theia/core';
|
|
19
19
|
import { FrontendApplicationContribution, LabelProviderContribution, PreferenceContribution } from '@theia/core/lib/browser';
|
|
20
20
|
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
21
21
|
import {
|
|
@@ -37,7 +37,6 @@ import { AICustomAgentsFrontendApplicationContribution } from './custom-agent-fr
|
|
|
37
37
|
import { FrontendChatServiceImpl } from './frontend-chat-service';
|
|
38
38
|
import { CustomAgentFactory } from './custom-agent-factory';
|
|
39
39
|
import { ChatToolRequestService } from '../common/chat-tool-request-service';
|
|
40
|
-
import { ChangeSetFileResourceResolver } from './change-set-file-resource';
|
|
41
40
|
import { ChangeSetFileService } from './change-set-file-service';
|
|
42
41
|
import { ContextVariableLabelProvider } from './context-variable-label-provider';
|
|
43
42
|
import { ContextFileVariableLabelProvider } from './context-file-variable-label-provider';
|
|
@@ -46,6 +45,13 @@ import { ContextSummaryVariableContribution } from '../common/context-summary-va
|
|
|
46
45
|
import { ContextDetailsVariableContribution } from '../common/context-details-variable';
|
|
47
46
|
import { ChangeSetVariableContribution } from './change-set-variable';
|
|
48
47
|
import { ChatSessionNamingAgent, ChatSessionNamingService } from '../common/chat-session-naming-service';
|
|
48
|
+
import { ChangeSetDecorator, ChangeSetDecoratorService } from './change-set-decorator-service';
|
|
49
|
+
import { ChatSessionSummaryAgent } from '../common/chat-session-summary-agent';
|
|
50
|
+
import { TaskContextVariableContribution } from './task-context-variable-contribution';
|
|
51
|
+
import { TaskContextVariableLabelProvider } from './task-context-variable-label-provider';
|
|
52
|
+
import { TaskContextService, TaskContextStorageService } from './task-context-service';
|
|
53
|
+
import { InMemoryTaskContextStorage } from './task-context-storage-service';
|
|
54
|
+
import { AIChatFrontendContribution } from './ai-chat-frontend-contribution';
|
|
49
55
|
|
|
50
56
|
export default new ContainerModule(bind => {
|
|
51
57
|
bindContributionProvider(bind, Agent);
|
|
@@ -106,11 +112,26 @@ export default new ContainerModule(bind => {
|
|
|
106
112
|
container.bind(ChangeSetFileElement).toSelf().inSingletonScope();
|
|
107
113
|
return container.get(ChangeSetFileElement);
|
|
108
114
|
});
|
|
109
|
-
|
|
110
|
-
bind(
|
|
115
|
+
|
|
116
|
+
bind(ChangeSetDecoratorService).toSelf().inSingletonScope();
|
|
117
|
+
bind(FrontendApplicationContribution).toService(ChangeSetDecoratorService);
|
|
118
|
+
bindContributionProvider(bind, ChangeSetDecorator);
|
|
111
119
|
bind(ToolCallChatResponseContentFactory).toSelf().inSingletonScope();
|
|
112
120
|
bind(AIVariableContribution).to(FileChatVariableContribution).inSingletonScope();
|
|
113
121
|
bind(AIVariableContribution).to(ContextSummaryVariableContribution).inSingletonScope();
|
|
114
122
|
bind(AIVariableContribution).to(ContextDetailsVariableContribution).inSingletonScope();
|
|
115
123
|
bind(AIVariableContribution).to(ChangeSetVariableContribution).inSingletonScope();
|
|
124
|
+
|
|
125
|
+
bind(ChatSessionSummaryAgent).toSelf().inSingletonScope();
|
|
126
|
+
bind(Agent).toService(ChatSessionSummaryAgent);
|
|
127
|
+
bind(TaskContextVariableContribution).toSelf().inSingletonScope();
|
|
128
|
+
bind(AIVariableContribution).toService(TaskContextVariableContribution);
|
|
129
|
+
bind(TaskContextVariableLabelProvider).toSelf().inSingletonScope();
|
|
130
|
+
bind(LabelProviderContribution).toService(TaskContextVariableLabelProvider);
|
|
131
|
+
|
|
132
|
+
bind(TaskContextService).toSelf().inSingletonScope();
|
|
133
|
+
bind(InMemoryTaskContextStorage).toSelf().inSingletonScope();
|
|
134
|
+
bind(TaskContextStorageService).toService(InMemoryTaskContextStorage);
|
|
135
|
+
bind(AIChatFrontendContribution).toSelf().inSingletonScope();
|
|
136
|
+
bind(CommandContribution).toService(AIChatFrontendContribution);
|
|
116
137
|
});
|
|
@@ -0,0 +1,72 @@
|
|
|
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 { ContributionProvider, Emitter, type Event } from '@theia/core';
|
|
18
|
+
import { type FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
19
|
+
import { inject, injectable, named } from '@theia/core/shared/inversify';
|
|
20
|
+
import debounce = require('@theia/core/shared/lodash.debounce');
|
|
21
|
+
import type { ChangeSetDecoration, ChangeSetElement } from '../common';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A decorator for a change set element.
|
|
25
|
+
* It allows to add additional information to the element, such as icons.
|
|
26
|
+
*/
|
|
27
|
+
export const ChangeSetDecorator = Symbol('ChangeSetDecorator');
|
|
28
|
+
export interface ChangeSetDecorator {
|
|
29
|
+
readonly id: string;
|
|
30
|
+
|
|
31
|
+
readonly onDidChangeDecorations: Event<void>;
|
|
32
|
+
|
|
33
|
+
decorate(element: ChangeSetElement): ChangeSetDecoration | undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@injectable()
|
|
37
|
+
export class ChangeSetDecoratorService implements FrontendApplicationContribution {
|
|
38
|
+
|
|
39
|
+
protected readonly onDidChangeDecorationsEmitter = new Emitter<void>();
|
|
40
|
+
readonly onDidChangeDecorations = this.onDidChangeDecorationsEmitter.event;
|
|
41
|
+
|
|
42
|
+
@inject(ContributionProvider) @named(ChangeSetDecorator)
|
|
43
|
+
protected readonly contributions: ContributionProvider<ChangeSetDecorator>;
|
|
44
|
+
|
|
45
|
+
initialize(): void {
|
|
46
|
+
this.contributions.getContributions().map(decorator => decorator.onDidChangeDecorations(this.fireDidChangeDecorations));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
protected readonly fireDidChangeDecorations = debounce(() => {
|
|
50
|
+
this.onDidChangeDecorationsEmitter.fire(undefined);
|
|
51
|
+
}, 150);
|
|
52
|
+
|
|
53
|
+
getDecorations(element: ChangeSetElement): ChangeSetDecoration[] {
|
|
54
|
+
const decorators = this.contributions.getContributions();
|
|
55
|
+
const decorations: ChangeSetDecoration[] = [];
|
|
56
|
+
for (const decorator of decorators) {
|
|
57
|
+
const decoration = decorator.decorate(element);
|
|
58
|
+
if (decoration) {
|
|
59
|
+
decorations.push(decoration);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
decorations.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
64
|
+
|
|
65
|
+
return decorations;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
getAdditionalInfoSuffixIcon(element: ChangeSetElement): string[] | undefined {
|
|
69
|
+
const decorations = this.getDecorations(element);
|
|
70
|
+
return decorations.find(d => d.additionalInfoSuffixIcon)?.additionalInfoSuffixIcon;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -17,11 +17,13 @@
|
|
|
17
17
|
import { DisposableCollection, Emitter, URI } from '@theia/core';
|
|
18
18
|
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
19
19
|
import { Replacement } from '@theia/core/lib/common/content-replacer';
|
|
20
|
+
import { ConfigurableInMemoryResources, ConfigurableMutableReferenceResource } from '@theia/ai-core';
|
|
20
21
|
import { ChangeSetElement, ChangeSetImpl } from '../common';
|
|
21
|
-
import {
|
|
22
|
+
import { createChangeSetFileUri } from './change-set-file-resource';
|
|
22
23
|
import { ChangeSetFileService } from './change-set-file-service';
|
|
23
24
|
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
24
25
|
import { ConfirmDialog } from '@theia/core/lib/browser';
|
|
26
|
+
import { ChangeSetDecoratorService } from './change-set-decorator-service';
|
|
25
27
|
|
|
26
28
|
export const ChangeSetFileElementFactory = Symbol('ChangeSetFileElementFactory');
|
|
27
29
|
export type ChangeSetFileElementFactory = (elementProps: ChangeSetElementArgs) => ChangeSetFileElement;
|
|
@@ -60,11 +62,14 @@ export class ChangeSetFileElement implements ChangeSetElement {
|
|
|
60
62
|
@inject(ChangeSetFileService)
|
|
61
63
|
protected readonly changeSetFileService: ChangeSetFileService;
|
|
62
64
|
|
|
65
|
+
@inject(ChangeSetDecoratorService)
|
|
66
|
+
protected readonly changeSetDecoratorService: ChangeSetDecoratorService;
|
|
67
|
+
|
|
63
68
|
@inject(FileService)
|
|
64
69
|
protected readonly fileService: FileService;
|
|
65
70
|
|
|
66
|
-
@inject(
|
|
67
|
-
protected readonly
|
|
71
|
+
@inject(ConfigurableInMemoryResources)
|
|
72
|
+
protected readonly inMemoryResources: ConfigurableInMemoryResources;
|
|
68
73
|
|
|
69
74
|
protected readonly toDispose = new DisposableCollection();
|
|
70
75
|
protected _state: ChangeSetElementState;
|
|
@@ -73,8 +78,8 @@ export class ChangeSetFileElement implements ChangeSetElement {
|
|
|
73
78
|
|
|
74
79
|
protected readonly onDidChangeEmitter = new Emitter<void>();
|
|
75
80
|
readonly onDidChange = this.onDidChangeEmitter.event;
|
|
76
|
-
protected readOnlyResource:
|
|
77
|
-
protected changeResource:
|
|
81
|
+
protected readOnlyResource: ConfigurableMutableReferenceResource;
|
|
82
|
+
protected changeResource: ConfigurableMutableReferenceResource;
|
|
78
83
|
|
|
79
84
|
@postConstruct()
|
|
80
85
|
init(): void {
|
|
@@ -93,17 +98,17 @@ export class ChangeSetFileElement implements ChangeSetElement {
|
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
protected getResources(): void {
|
|
96
|
-
this.readOnlyResource = this.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
} else {
|
|
101
|
-
changed = this.resourceResolver.add(this.changedUri, { contents: this.targetState, onSave: content => this.writeChanges(content), autosaveable: false });
|
|
102
|
-
}
|
|
103
|
-
this.changeResource = changed;
|
|
101
|
+
this.readOnlyResource = this.getInMemoryUri(this.readOnlyUri);
|
|
102
|
+
this.readOnlyResource.update({ autosaveable: false, readOnly: true });
|
|
103
|
+
this.changeResource = this.getInMemoryUri(this.changedUri);
|
|
104
|
+
this.changeResource.update({ contents: this.targetState, onSave: content => this.writeChanges(content), autosaveable: false });
|
|
104
105
|
this.toDispose.pushAll([this.readOnlyResource, this.changeResource]);
|
|
105
106
|
}
|
|
106
107
|
|
|
108
|
+
protected getInMemoryUri(uri: URI): ConfigurableMutableReferenceResource {
|
|
109
|
+
try { return this.inMemoryResources.resolve(uri); } catch { return this.inMemoryResources.add(uri, { contents: '' }); }
|
|
110
|
+
}
|
|
111
|
+
|
|
107
112
|
protected listenForOriginalFileChanges(): void {
|
|
108
113
|
this.toDispose.push(this.fileService.onDidFilesChange(async event => {
|
|
109
114
|
if (!event.contains(this.uri)) { return; }
|