@theia/ai-chat 1.58.3 → 1.59.0-next.72
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-module.d.ts.map +1 -1
- package/lib/browser/ai-chat-frontend-module.js +16 -13
- package/lib/browser/ai-chat-frontend-module.js.map +1 -1
- package/lib/browser/ai-chat-preferences.d.ts +1 -0
- package/lib/browser/ai-chat-preferences.d.ts.map +1 -1
- package/lib/browser/ai-chat-preferences.js +12 -3
- package/lib/browser/ai-chat-preferences.js.map +1 -1
- package/lib/browser/change-set-file-element.d.ts +31 -6
- package/lib/browser/change-set-file-element.d.ts.map +1 -1
- package/lib/browser/change-set-file-element.js +108 -15
- package/lib/browser/change-set-file-element.js.map +1 -1
- package/lib/browser/change-set-file-resource.d.ts +40 -8
- package/lib/browser/change-set-file-resource.d.ts.map +1 -1
- package/lib/browser/change-set-file-resource.js +123 -37
- package/lib/browser/change-set-file-resource.js.map +1 -1
- package/lib/browser/change-set-file-service.d.ts +9 -3
- package/lib/browser/change-set-file-service.d.ts.map +1 -1
- package/lib/browser/change-set-file-service.js +35 -13
- package/lib/browser/change-set-file-service.js.map +1 -1
- package/lib/browser/change-set-variable.d.ts +11 -0
- package/lib/browser/change-set-variable.d.ts.map +1 -0
- package/lib/browser/change-set-variable.js +56 -0
- package/lib/browser/change-set-variable.js.map +1 -0
- package/lib/browser/context-file-variable-label-provider.d.ts +14 -0
- package/lib/browser/context-file-variable-label-provider.d.ts.map +1 -0
- package/lib/browser/context-file-variable-label-provider.js +63 -0
- package/lib/browser/context-file-variable-label-provider.js.map +1 -0
- package/lib/browser/context-variable-label-provider.d.ts +9 -0
- package/lib/browser/context-variable-label-provider.d.ts.map +1 -0
- package/lib/browser/context-variable-label-provider.js +55 -0
- package/lib/browser/context-variable-label-provider.js.map +1 -0
- package/lib/browser/file-chat-variable-contribution.d.ts +18 -0
- package/lib/browser/file-chat-variable-contribution.d.ts.map +1 -0
- package/lib/browser/file-chat-variable-contribution.js +135 -0
- package/lib/browser/file-chat-variable-contribution.js.map +1 -0
- package/lib/browser/frontend-chat-service.d.ts +10 -3
- package/lib/browser/frontend-chat-service.d.ts.map +1 -1
- package/lib/browser/frontend-chat-service.js +39 -19
- package/lib/browser/frontend-chat-service.js.map +1 -1
- package/lib/common/chat-agents.d.ts +54 -24
- package/lib/common/chat-agents.d.ts.map +1 -1
- package/lib/common/chat-agents.js +58 -20
- package/lib/common/chat-agents.js.map +1 -1
- package/lib/common/chat-history-entry.js +1 -1
- package/lib/common/chat-history-entry.js.map +1 -1
- package/lib/common/chat-model.d.ts +84 -36
- package/lib/common/chat-model.d.ts.map +1 -1
- package/lib/common/chat-model.js +142 -51
- package/lib/common/chat-model.js.map +1 -1
- package/lib/common/chat-service.d.ts +27 -10
- package/lib/common/chat-service.d.ts.map +1 -1
- package/lib/common/chat-service.js +80 -20
- package/lib/common/chat-service.js.map +1 -1
- package/lib/common/chat-string-utils.d.ts +3 -0
- package/lib/common/chat-string-utils.d.ts.map +1 -0
- package/lib/common/chat-string-utils.js +27 -0
- package/lib/common/chat-string-utils.js.map +1 -0
- package/lib/common/chat-tool-request-service.d.ts +5 -5
- package/lib/common/chat-tool-request-service.d.ts.map +1 -1
- package/lib/common/chat-tool-request-service.js.map +1 -1
- package/lib/common/context-details-variable.d.ts +9 -0
- package/lib/common/context-details-variable.d.ts.map +1 -0
- package/lib/common/context-details-variable.js +57 -0
- package/lib/common/context-details-variable.js.map +1 -0
- package/lib/common/context-summary-variable.d.ts +9 -0
- package/lib/common/context-summary-variable.d.ts.map +1 -0
- package/lib/common/context-summary-variable.js +57 -0
- package/lib/common/context-summary-variable.js.map +1 -0
- package/lib/common/context-variables.d.ts +4 -0
- package/lib/common/context-variables.d.ts.map +1 -0
- package/lib/common/context-variables.js +22 -0
- package/lib/common/context-variables.js.map +1 -0
- package/lib/common/custom-chat-agent.d.ts +6 -10
- package/lib/common/custom-chat-agent.d.ts.map +1 -1
- package/lib/common/custom-chat-agent.js +8 -11
- package/lib/common/custom-chat-agent.js.map +1 -1
- package/lib/common/index.d.ts +1 -3
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +1 -3
- package/lib/common/index.js.map +1 -1
- package/lib/common/parse-contents.d.ts +2 -2
- package/lib/common/parse-contents.d.ts.map +1 -1
- package/lib/common/parse-contents.js.map +1 -1
- package/lib/common/parse-contents.spec.d.ts.map +1 -1
- package/lib/common/parse-contents.spec.js.map +1 -1
- package/lib/common/response-content-matcher.d.ts +3 -3
- package/lib/common/response-content-matcher.d.ts.map +1 -1
- package/lib/common/response-content-matcher.js.map +1 -1
- package/package.json +12 -10
- package/src/browser/ai-chat-frontend-module.ts +20 -18
- package/src/browser/ai-chat-preferences.ts +13 -2
- package/src/browser/change-set-file-element.ts +109 -20
- package/src/browser/change-set-file-resource.ts +125 -39
- package/src/browser/change-set-file-service.ts +38 -16
- package/src/browser/change-set-variable.ts +54 -0
- package/src/browser/context-file-variable-label-provider.ts +62 -0
- package/src/browser/context-variable-label-provider.ts +56 -0
- package/src/browser/file-chat-variable-contribution.ts +143 -0
- package/src/browser/frontend-chat-service.ts +40 -26
- package/src/common/chat-agents.ts +87 -30
- package/src/common/chat-history-entry.ts +1 -1
- package/src/common/chat-model.ts +204 -70
- package/src/common/chat-service.ts +92 -24
- package/src/common/chat-string-utils.ts +23 -0
- package/src/common/chat-tool-request-service.ts +5 -5
- package/src/common/context-details-variable.ts +53 -0
- package/src/common/context-summary-variable.ts +53 -0
- package/src/common/context-variables.ts +19 -0
- package/src/common/custom-chat-agent.ts +9 -20
- package/src/common/index.ts +1 -3
- package/src/common/parse-contents.spec.ts +2 -2
- package/src/common/parse-contents.ts +2 -2
- package/src/common/response-content-matcher.ts +3 -3
- package/lib/common/command-chat-agents.d.ts +0 -33
- package/lib/common/command-chat-agents.d.ts.map +0 -1
- package/lib/common/command-chat-agents.js +0 -329
- package/lib/common/command-chat-agents.js.map +0 -1
- package/lib/common/orchestrator-chat-agent.d.ts +0 -22
- package/lib/common/orchestrator-chat-agent.d.ts.map +0 -1
- package/lib/common/orchestrator-chat-agent.js +0 -167
- package/lib/common/orchestrator-chat-agent.js.map +0 -1
- package/lib/common/universal-chat-agent.d.ts +0 -16
- package/lib/common/universal-chat-agent.d.ts.map +0 -1
- package/lib/common/universal-chat-agent.js +0 -109
- package/lib/common/universal-chat-agent.js.map +0 -1
- package/src/common/command-chat-agents.ts +0 -354
- package/src/common/orchestrator-chat-agent.ts +0 -179
- package/src/common/universal-chat-agent.ts +0 -117
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-contents.d.ts","sourceRoot":"","sources":["../../src/common/parse-contents.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"parse-contents.d.ts","sourceRoot":"","sources":["../../src/common/parse-contents.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAA8C,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAExI,UAAU,KAAK;IACX,OAAO,EAAE,sBAAsB,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,aAAa,CACzB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,uBAAuB,EAChC,eAAe,GAAE,sBAAsB,EAAyB,EAChE,qBAAqB,GAAE,sBAA+C,GACvE,mBAAmB,EAAE,CA8BvB;AAED,wBAAgB,cAAc,CAAC,eAAe,EAAE,sBAAsB,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CA8BzG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-contents.js","sourceRoot":"","sources":["../../src/common/parse-contents.ts"],"names":[],"mappings":";;;AAgBA,yEAAwI;AAQxI,SAAgB,aAAa,CACzB,IAAY,EAC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E,OAAO,EAAE,CAAC;QAC7C,CAAC;IACL,CAAC;IACD,OAAO,UAAU,CAAC;AACtB,CAAC;AA9BD,wCA8BC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-contents.spec.d.ts","sourceRoot":"","sources":["../../src/common/parse-contents.spec.ts"],"names":[],"mappings":"AAiBA,OAAO,
|
|
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 +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,
|
|
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,gFAA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,GAAG,EAAE;QAC5E,MAAM,IAAI,GAAG,8IAA8I,CAAC;QAC5J,MAAM,MAAM,GAAG,IAAA,8BAAa,EAAC,IAAI,EAAE,WAAW,EAAE,CAAC,6CAAkB,EAAE,6BAAqB,CAAC,CAAC,CAAC;QAC7F,IAAA,aAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;YACzB,IAAI,8BAA8B,CAAC,oBAAoB,CAAC;YACxD,IAAI,4CAA+B,CAAC,qBAAqB,CAAC;YAC1D,IAAI,wCAA2B,CAAC,sBAAsB,EAAE,QAAQ,CAAC;YACjE,IAAI,8BAA8B,CAAC,qBAAqB,CAAC;SAC5D,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type ResponseContentFactory = (content: string, request:
|
|
1
|
+
import { MutableChatRequestModel, ChatResponseContent } from './chat-model';
|
|
2
|
+
export type ResponseContentFactory = (content: string, request: MutableChatRequestModel) => ChatResponseContent;
|
|
3
3
|
export declare const MarkdownContentFactory: ResponseContentFactory;
|
|
4
4
|
/**
|
|
5
5
|
* Default response content factory used if no other `ResponseContentMatcher` applies.
|
|
@@ -8,7 +8,7 @@ export declare const MarkdownContentFactory: ResponseContentFactory;
|
|
|
8
8
|
* @see MarkdownChatResponseContentImpl
|
|
9
9
|
*/
|
|
10
10
|
export declare class DefaultResponseContentFactory {
|
|
11
|
-
create(content: string, request:
|
|
11
|
+
create(content: string, request: MutableChatRequestModel): ChatResponseContent;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Clients can contribute response content matchers to parse a chat response into specific
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-content-matcher.d.ts","sourceRoot":"","sources":["../../src/common/response-content-matcher.ts"],"names":[],"mappings":"AAeA,OAAO,EACH,
|
|
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;CAC1C;AAED,eAAO,MAAM,kBAAkB,EAAE,sBAQhC,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"}
|
|
@@ -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,CAC9E,IAAI,4CAA+B,CAAC,OAAO,CAAC,CAAC;AADpC,QAAA,sBAAsB,0BACc;AAEjD;;;;;GAKG;AAEI,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IACtC,MAAM,CAAC,OAAe,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,EAAE,CAC9E,IAAI,4CAA+B,CAAC,OAAO,CAAC,CAAC;AADpC,QAAA,sBAAsB,0BACc;AAEjD;;;;;GAKG;AAEI,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IACtC,MAAM,CAAC,OAAe,EAAE,OAAgC;QACpD,OAAO,IAAA,8BAAsB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;CACJ,CAAA;AAJY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,sBAAU,GAAE;GACA,6BAA6B,CAIzC;AAkBY,QAAA,kBAAkB,GAA2B;IACtD,KAAK,EAAE,WAAW;IAClB,GAAG,EAAE,QAAQ;IACb,cAAc,EAAE,CAAC,OAAe,EAAE,EAAE;;QAChC,MAAM,QAAQ,GAAG,CAAA,MAAA,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,0CAAG,CAAC,CAAC,KAAI,EAAE,CAAC;QACvD,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;QACtD,OAAO,IAAI,wCAA2B,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,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,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/ai-chat",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.59.0-next.72+f41d8efcd",
|
|
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/
|
|
11
|
-
"@theia/
|
|
12
|
-
"@theia/
|
|
6
|
+
"@theia/ai-core": "1.59.0-next.72+f41d8efcd",
|
|
7
|
+
"@theia/ai-history": "1.59.0-next.72+f41d8efcd",
|
|
8
|
+
"@theia/core": "1.59.0-next.72+f41d8efcd",
|
|
9
|
+
"@theia/editor": "1.59.0-next.72+f41d8efcd",
|
|
10
|
+
"@theia/file-search": "1.59.0-next.72+f41d8efcd",
|
|
11
|
+
"@theia/filesystem": "1.59.0-next.72+f41d8efcd",
|
|
12
|
+
"@theia/monaco": "1.59.0-next.72+f41d8efcd",
|
|
13
|
+
"@theia/monaco-editor-core": "1.96.302",
|
|
14
|
+
"@theia/workspace": "1.59.0-next.72+f41d8efcd",
|
|
13
15
|
"minimatch": "^5.1.0",
|
|
14
16
|
"tslib": "^2.6.2"
|
|
15
17
|
},
|
|
@@ -47,10 +49,10 @@
|
|
|
47
49
|
"watch": "theiaext watch"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
50
|
-
"@theia/ext-scripts": "1.58.
|
|
52
|
+
"@theia/ext-scripts": "1.58.0"
|
|
51
53
|
},
|
|
52
54
|
"nyc": {
|
|
53
55
|
"extends": "../../configs/nyc.json"
|
|
54
56
|
},
|
|
55
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "f41d8efcd4abb79167b74bf476eafc7857e97306"
|
|
56
58
|
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { Agent, AgentService, AIVariableContribution } from '@theia/ai-core/lib/common';
|
|
18
18
|
import { bindContributionProvider, ResourceResolver } from '@theia/core';
|
|
19
|
-
import { FrontendApplicationContribution, PreferenceContribution } from '@theia/core/lib/browser';
|
|
19
|
+
import { FrontendApplicationContribution, LabelProviderContribution, PreferenceContribution } from '@theia/core/lib/browser';
|
|
20
20
|
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
21
21
|
import {
|
|
22
22
|
ChatAgent,
|
|
@@ -25,14 +25,12 @@ import {
|
|
|
25
25
|
ChatRequestParser,
|
|
26
26
|
ChatRequestParserImpl,
|
|
27
27
|
ChatService,
|
|
28
|
-
|
|
28
|
+
ToolCallChatResponseContentFactory,
|
|
29
|
+
PinChatAgent
|
|
29
30
|
} from '../common';
|
|
30
31
|
import { ChatAgentsVariableContribution } from '../common/chat-agents-variable-contribution';
|
|
31
|
-
import { CommandChatAgent } from '../common/command-chat-agents';
|
|
32
32
|
import { CustomChatAgent } from '../common/custom-chat-agent';
|
|
33
|
-
import { OrchestratorChatAgent, OrchestratorChatAgentId } from '../common/orchestrator-chat-agent';
|
|
34
33
|
import { DefaultResponseContentFactory, DefaultResponseContentMatcherProvider, ResponseContentMatcherProvider } from '../common/response-content-matcher';
|
|
35
|
-
import { UniversalChatAgent } from '../common/universal-chat-agent';
|
|
36
34
|
import { aiChatPreferences } from './ai-chat-preferences';
|
|
37
35
|
import { ChangeSetElementArgs, ChangeSetFileElement, ChangeSetFileElementFactory } from './change-set-file-element';
|
|
38
36
|
import { AICustomAgentsFrontendApplicationContribution } from './custom-agent-frontend-application-contribution';
|
|
@@ -41,6 +39,12 @@ import { CustomAgentFactory } from './custom-agent-factory';
|
|
|
41
39
|
import { ChatToolRequestService } from '../common/chat-tool-request-service';
|
|
42
40
|
import { ChangeSetFileResourceResolver } from './change-set-file-resource';
|
|
43
41
|
import { ChangeSetFileService } from './change-set-file-service';
|
|
42
|
+
import { ContextVariableLabelProvider } from './context-variable-label-provider';
|
|
43
|
+
import { ContextFileVariableLabelProvider } from './context-file-variable-label-provider';
|
|
44
|
+
import { FileChatVariableContribution } from './file-chat-variable-contribution';
|
|
45
|
+
import { ContextSummaryVariableContribution } from '../common/context-summary-variable';
|
|
46
|
+
import { ContextDetailsVariableContribution } from '../common/context-details-variable';
|
|
47
|
+
import { ChangeSetVariableContribution } from './change-set-variable';
|
|
44
48
|
|
|
45
49
|
export default new ContainerModule(bind => {
|
|
46
50
|
bindContributionProvider(bind, Agent);
|
|
@@ -50,7 +54,7 @@ export default new ContainerModule(bind => {
|
|
|
50
54
|
|
|
51
55
|
bind(ChatAgentServiceImpl).toSelf().inSingletonScope();
|
|
52
56
|
bind(ChatAgentService).toService(ChatAgentServiceImpl);
|
|
53
|
-
bind(
|
|
57
|
+
bind(PinChatAgent).toConstantValue(true);
|
|
54
58
|
|
|
55
59
|
bindContributionProvider(bind, ResponseContentMatcherProvider);
|
|
56
60
|
bind(DefaultResponseContentMatcherProvider).toSelf().inSingletonScope();
|
|
@@ -65,18 +69,6 @@ export default new ContainerModule(bind => {
|
|
|
65
69
|
bind(FrontendChatServiceImpl).toSelf().inSingletonScope();
|
|
66
70
|
bind(ChatService).toService(FrontendChatServiceImpl);
|
|
67
71
|
|
|
68
|
-
bind(OrchestratorChatAgent).toSelf().inSingletonScope();
|
|
69
|
-
bind(Agent).toService(OrchestratorChatAgent);
|
|
70
|
-
bind(ChatAgent).toService(OrchestratorChatAgent);
|
|
71
|
-
|
|
72
|
-
bind(UniversalChatAgent).toSelf().inSingletonScope();
|
|
73
|
-
bind(Agent).toService(UniversalChatAgent);
|
|
74
|
-
bind(ChatAgent).toService(UniversalChatAgent);
|
|
75
|
-
|
|
76
|
-
bind(CommandChatAgent).toSelf().inSingletonScope();
|
|
77
|
-
bind(Agent).toService(CommandChatAgent);
|
|
78
|
-
bind(ChatAgent).toService(CommandChatAgent);
|
|
79
|
-
|
|
80
72
|
bind(PreferenceContribution).toConstantValue({ schema: aiChatPreferences });
|
|
81
73
|
|
|
82
74
|
bind(CustomChatAgent).toSelf();
|
|
@@ -97,6 +89,11 @@ export default new ContainerModule(bind => {
|
|
|
97
89
|
});
|
|
98
90
|
bind(FrontendApplicationContribution).to(AICustomAgentsFrontendApplicationContribution).inSingletonScope();
|
|
99
91
|
|
|
92
|
+
bind(ContextVariableLabelProvider).toSelf().inSingletonScope();
|
|
93
|
+
bind(LabelProviderContribution).toService(ContextVariableLabelProvider);
|
|
94
|
+
bind(ContextFileVariableLabelProvider).toSelf().inSingletonScope();
|
|
95
|
+
bind(LabelProviderContribution).toService(ContextFileVariableLabelProvider);
|
|
96
|
+
|
|
100
97
|
bind(ChangeSetFileService).toSelf().inSingletonScope();
|
|
101
98
|
bind(ChangeSetFileElementFactory).toFactory(ctx => (args: ChangeSetElementArgs) => {
|
|
102
99
|
const container = ctx.container.createChild();
|
|
@@ -106,4 +103,9 @@ export default new ContainerModule(bind => {
|
|
|
106
103
|
});
|
|
107
104
|
bind(ChangeSetFileResourceResolver).toSelf().inSingletonScope();
|
|
108
105
|
bind(ResourceResolver).toService(ChangeSetFileResourceResolver);
|
|
106
|
+
bind(ToolCallChatResponseContentFactory).toSelf().inSingletonScope();
|
|
107
|
+
bind(AIVariableContribution).to(FileChatVariableContribution).inSingletonScope();
|
|
108
|
+
bind(AIVariableContribution).to(ContextSummaryVariableContribution).inSingletonScope();
|
|
109
|
+
bind(AIVariableContribution).to(ContextDetailsVariableContribution).inSingletonScope();
|
|
110
|
+
bind(AIVariableContribution).to(ChangeSetVariableContribution).inSingletonScope();
|
|
109
111
|
});
|
|
@@ -15,17 +15,28 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { AI_CORE_PREFERENCES_TITLE } from '@theia/ai-core/lib/browser/ai-core-preferences';
|
|
18
|
+
import { nls } from '@theia/core';
|
|
18
19
|
import { PreferenceSchema } from '@theia/core/lib/browser/preferences/preference-contribution';
|
|
19
20
|
|
|
20
21
|
export const DEFAULT_CHAT_AGENT_PREF = 'ai-features.chat.defaultChatAgent';
|
|
22
|
+
export const PIN_CHAT_AGENT_PREF = 'ai-features.chat.pinChatAgent';
|
|
21
23
|
|
|
22
24
|
export const aiChatPreferences: PreferenceSchema = {
|
|
23
25
|
type: 'object',
|
|
24
26
|
properties: {
|
|
25
27
|
[DEFAULT_CHAT_AGENT_PREF]: {
|
|
26
28
|
type: 'string',
|
|
27
|
-
description: '
|
|
28
|
-
|
|
29
|
+
description: nls.localize('theia/ai/chat/defaultAgent/description',
|
|
30
|
+
'Optional: <agent-name> of the Chat Agent that shall be invoked, if no agent is explicitly mentioned with @<agent-name> in the user query. \
|
|
31
|
+
If no Default Agent is configured, Theia´s defaults will be applied.'),
|
|
32
|
+
title: AI_CORE_PREFERENCES_TITLE,
|
|
33
|
+
},
|
|
34
|
+
[PIN_CHAT_AGENT_PREF]: {
|
|
35
|
+
type: 'boolean',
|
|
36
|
+
description: nls.localize('theia/ai/chat/pinChatAgent/description',
|
|
37
|
+
'Enable agent pinning to automatically keep a mentioned chat agent active across prompts, reducing the need for repeated mentions.\
|
|
38
|
+
You can manually unpin or switch agents anytime.'),
|
|
39
|
+
default: true,
|
|
29
40
|
title: AI_CORE_PREFERENCES_TITLE,
|
|
30
41
|
}
|
|
31
42
|
}
|
|
@@ -14,14 +14,18 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { URI } from '@theia/core';
|
|
17
|
+
import { DisposableCollection, Emitter, URI } from '@theia/core';
|
|
18
18
|
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
19
|
+
import { Replacement } from '@theia/core/lib/common/content-replacer';
|
|
19
20
|
import { ChangeSetElement, ChangeSetImpl } from '../common';
|
|
20
|
-
import { createChangeSetFileUri } from './change-set-file-resource';
|
|
21
|
+
import { ChangeSetFileResourceResolver, createChangeSetFileUri, UpdatableReferenceResource } from './change-set-file-resource';
|
|
21
22
|
import { ChangeSetFileService } from './change-set-file-service';
|
|
23
|
+
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
24
|
+
import { ConfirmDialog } from '@theia/core/lib/browser';
|
|
22
25
|
|
|
23
26
|
export const ChangeSetFileElementFactory = Symbol('ChangeSetFileElementFactory');
|
|
24
27
|
export type ChangeSetFileElementFactory = (elementProps: ChangeSetElementArgs) => ChangeSetFileElement;
|
|
28
|
+
type ChangeSetElementState = ChangeSetElement['state'];
|
|
25
29
|
|
|
26
30
|
export const ChangeSetElementArgs = Symbol('ChangeSetElementArgs');
|
|
27
31
|
export interface ChangeSetElementArgs extends Partial<ChangeSetElement> {
|
|
@@ -36,34 +40,94 @@ export interface ChangeSetElementArgs extends Partial<ChangeSetElement> {
|
|
|
36
40
|
* If `undefined`, there is no change.
|
|
37
41
|
*/
|
|
38
42
|
targetState?: string;
|
|
43
|
+
/**
|
|
44
|
+
* An array of replacements used to create the new content for the targetState.
|
|
45
|
+
* This is only available if the agent was able to provide replacements and we were able to apply them.
|
|
46
|
+
*/
|
|
47
|
+
replacements?: Replacement[];
|
|
39
48
|
};
|
|
40
49
|
|
|
41
50
|
@injectable()
|
|
42
51
|
export class ChangeSetFileElement implements ChangeSetElement {
|
|
43
52
|
|
|
53
|
+
static toReadOnlyUri(baseUri: URI, sessionId: string): URI {
|
|
54
|
+
return baseUri.withScheme('change-set-immutable').withAuthority(sessionId);
|
|
55
|
+
}
|
|
56
|
+
|
|
44
57
|
@inject(ChangeSetElementArgs)
|
|
45
58
|
protected readonly elementProps: ChangeSetElementArgs;
|
|
46
59
|
|
|
47
60
|
@inject(ChangeSetFileService)
|
|
48
61
|
protected readonly changeSetFileService: ChangeSetFileService;
|
|
49
62
|
|
|
50
|
-
|
|
63
|
+
@inject(FileService)
|
|
64
|
+
protected readonly fileService: FileService;
|
|
65
|
+
|
|
66
|
+
@inject(ChangeSetFileResourceResolver)
|
|
67
|
+
protected readonly resourceResolver: ChangeSetFileResourceResolver;
|
|
68
|
+
|
|
69
|
+
protected readonly toDispose = new DisposableCollection();
|
|
70
|
+
protected _state: ChangeSetElementState;
|
|
51
71
|
|
|
52
72
|
protected originalContent: string | undefined;
|
|
53
73
|
|
|
74
|
+
protected readonly onDidChangeEmitter = new Emitter<void>();
|
|
75
|
+
readonly onDidChange = this.onDidChangeEmitter.event;
|
|
76
|
+
protected readOnlyResource: UpdatableReferenceResource;
|
|
77
|
+
protected changeResource: UpdatableReferenceResource;
|
|
78
|
+
|
|
54
79
|
@postConstruct()
|
|
55
80
|
init(): void {
|
|
81
|
+
this.getResources();
|
|
56
82
|
this.obtainOriginalContent();
|
|
83
|
+
this.listenForOriginalFileChanges();
|
|
84
|
+
this.toDispose.push(this.onDidChangeEmitter);
|
|
57
85
|
}
|
|
58
86
|
|
|
59
87
|
protected async obtainOriginalContent(): Promise<void> {
|
|
60
88
|
this.originalContent = await this.changeSetFileService.read(this.uri);
|
|
89
|
+
this.readOnlyResource.update({ contents: this.originalContent ?? '' });
|
|
90
|
+
if (this.state === 'applied') {
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
protected getResources(): void {
|
|
96
|
+
this.readOnlyResource = this.resourceResolver.tryGet(this.readOnlyUri) ?? this.resourceResolver.add(this.readOnlyUri, { autosaveable: false, readOnly: true });
|
|
97
|
+
let changed = this.resourceResolver.tryGet(this.changedUri);
|
|
98
|
+
if (changed) {
|
|
99
|
+
changed.update({ contents: this.targetState, onSave: content => this.writeChanges(content) });
|
|
100
|
+
} else {
|
|
101
|
+
changed = this.resourceResolver.add(this.changedUri, { contents: this.targetState, onSave: content => this.writeChanges(content), autosaveable: false });
|
|
102
|
+
}
|
|
103
|
+
this.changeResource = changed;
|
|
104
|
+
this.toDispose.pushAll([this.readOnlyResource, this.changeResource]);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
protected listenForOriginalFileChanges(): void {
|
|
108
|
+
this.toDispose.push(this.fileService.onDidFilesChange(async event => {
|
|
109
|
+
if (!event.contains(this.uri)) { return; }
|
|
110
|
+
// If we are applied, the tricky thing becomes the question what to revert to; otherwise, what to apply.
|
|
111
|
+
const newContent = await this.changeSetFileService.read(this.uri).catch(() => '');
|
|
112
|
+
this.readOnlyResource.update({ contents: newContent });
|
|
113
|
+
if (newContent === this.originalContent) {
|
|
114
|
+
this.state = 'pending';
|
|
115
|
+
} else if (newContent === this.targetState) {
|
|
116
|
+
this.state = 'applied';
|
|
117
|
+
} else {
|
|
118
|
+
this.state = 'stale';
|
|
119
|
+
}
|
|
120
|
+
}));
|
|
61
121
|
}
|
|
62
122
|
|
|
63
123
|
get uri(): URI {
|
|
64
124
|
return this.elementProps.uri;
|
|
65
125
|
}
|
|
66
126
|
|
|
127
|
+
get readOnlyUri(): URI {
|
|
128
|
+
return ChangeSetFileElement.toReadOnlyUri(this.uri, this.elementProps.chatSessionId);
|
|
129
|
+
}
|
|
130
|
+
|
|
67
131
|
get changedUri(): URI {
|
|
68
132
|
return createChangeSetFileUri(this.elementProps.chatSessionId, this.uri);
|
|
69
133
|
}
|
|
@@ -80,13 +144,19 @@ export class ChangeSetFileElement implements ChangeSetElement {
|
|
|
80
144
|
return this.changeSetFileService.getAdditionalInfo(this.uri);
|
|
81
145
|
}
|
|
82
146
|
|
|
83
|
-
get state():
|
|
147
|
+
get state(): ChangeSetElementState {
|
|
84
148
|
return this._state ?? this.elementProps.state;
|
|
85
149
|
}
|
|
86
150
|
|
|
87
|
-
protected set state(value:
|
|
88
|
-
this._state
|
|
89
|
-
|
|
151
|
+
protected set state(value: ChangeSetElementState) {
|
|
152
|
+
if (this._state !== value) {
|
|
153
|
+
this._state = value;
|
|
154
|
+
this.onDidChangeEmitter.fire();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
get replacements(): Replacement[] | undefined {
|
|
159
|
+
return this.elementProps.replacements;
|
|
90
160
|
}
|
|
91
161
|
|
|
92
162
|
get type(): 'add' | 'modify' | 'delete' | undefined {
|
|
@@ -107,31 +177,50 @@ export class ChangeSetFileElement implements ChangeSetElement {
|
|
|
107
177
|
|
|
108
178
|
async openChange(): Promise<void> {
|
|
109
179
|
this.changeSetFileService.openDiff(
|
|
110
|
-
this.
|
|
180
|
+
this.readOnlyUri,
|
|
111
181
|
this.changedUri
|
|
112
182
|
);
|
|
113
183
|
}
|
|
114
184
|
|
|
115
|
-
async
|
|
116
|
-
this.
|
|
117
|
-
if (this.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
185
|
+
async apply(contents?: string): Promise<void> {
|
|
186
|
+
if (!await this.confirm('Apply')) { return; }
|
|
187
|
+
if (!(await this.changeSetFileService.trySave(this.changedUri))) {
|
|
188
|
+
if (this.type === 'delete') {
|
|
189
|
+
await this.changeSetFileService.delete(this.uri);
|
|
190
|
+
this.state = 'applied';
|
|
191
|
+
} else {
|
|
192
|
+
await this.writeChanges(contents);
|
|
193
|
+
}
|
|
121
194
|
}
|
|
195
|
+
this.changeSetFileService.closeDiff(this.readOnlyUri);
|
|
196
|
+
}
|
|
122
197
|
|
|
123
|
-
|
|
198
|
+
async writeChanges(contents?: string): Promise<void> {
|
|
199
|
+
await this.changeSetFileService.writeFrom(this.changedUri, this.uri, contents ?? this.targetState);
|
|
200
|
+
this.state = 'applied';
|
|
124
201
|
}
|
|
125
202
|
|
|
126
|
-
async
|
|
127
|
-
this.
|
|
203
|
+
async revert(): Promise<void> {
|
|
204
|
+
if (!await this.confirm('Revert')) { return; }
|
|
205
|
+
this.state = 'pending';
|
|
128
206
|
if (this.type === 'add') {
|
|
129
207
|
await this.changeSetFileService.delete(this.uri);
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
if (this.originalContent) {
|
|
208
|
+
} else if (this.originalContent) {
|
|
133
209
|
await this.changeSetFileService.write(this.uri, this.originalContent);
|
|
134
210
|
}
|
|
135
211
|
}
|
|
136
212
|
|
|
213
|
+
async confirm(verb: string): Promise<boolean> {
|
|
214
|
+
if (this._state !== 'stale') { return true; }
|
|
215
|
+
await this.openChange();
|
|
216
|
+
const thing = await new ConfirmDialog({
|
|
217
|
+
title: `${verb} suggestion.`,
|
|
218
|
+
msg: `The file ${this.uri.path.toString()} has changed since this suggestion was created. Are you certain you wish to ${verb.toLowerCase()} the change?`
|
|
219
|
+
}).open(true);
|
|
220
|
+
return !!thing;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
dispose(): void {
|
|
224
|
+
this.toDispose.dispose();
|
|
225
|
+
}
|
|
137
226
|
}
|
|
@@ -14,61 +14,147 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { Resource, ResourceResolver,
|
|
18
|
-
import {
|
|
19
|
-
import { ChatService } from '../common';
|
|
20
|
-
import { ChangeSetFileElement } from './change-set-file-element';
|
|
17
|
+
import { MutableResource, Reference, ReferenceMutableResource, Resource, ResourceResolver, URI } from '@theia/core';
|
|
18
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
21
19
|
|
|
22
20
|
export const CHANGE_SET_FILE_RESOURCE_SCHEME = 'changeset-file';
|
|
23
|
-
|
|
21
|
+
export type ResourceInitializationOptions = Pick<Resource, 'autosaveable' | 'initiallyDirty' | 'readOnly'> & { contents?: string, onSave?: Resource['saveContents'] };
|
|
22
|
+
export type ResourceUpdateOptions = Pick<ResourceInitializationOptions, 'contents' | 'onSave'>;
|
|
24
23
|
|
|
25
24
|
export function createChangeSetFileUri(chatSessionId: string, elementUri: URI): URI {
|
|
26
|
-
return
|
|
25
|
+
return elementUri.withScheme(CHANGE_SET_FILE_RESOURCE_SCHEME).withAuthority(chatSessionId);
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
export class UpdatableReferenceResource extends ReferenceMutableResource {
|
|
29
|
+
static acquire(resource: UpdatableReferenceResource): UpdatableReferenceResource {
|
|
30
|
+
DisposableRefCounter.acquire(resource.reference);
|
|
31
|
+
return resource;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
constructor(protected override reference: DisposableRefCounter<DisposableMutableResource>) {
|
|
35
|
+
super(reference);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
update(options: ResourceUpdateOptions): void {
|
|
39
|
+
this.reference.object.update(options);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get readOnly(): Resource['readOnly'] {
|
|
43
|
+
return this.reference.object.readOnly;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get initiallyDirty(): boolean {
|
|
47
|
+
return this.reference.object.initiallyDirty;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get autosaveable(): boolean {
|
|
51
|
+
return this.reference.object.autosaveable;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export class DisposableMutableResource extends MutableResource {
|
|
56
|
+
onSave: Resource['saveContents'] | undefined;
|
|
57
|
+
constructor(uri: URI, protected readonly options?: ResourceInitializationOptions) {
|
|
58
|
+
super(uri);
|
|
59
|
+
this.onSave = options?.onSave;
|
|
60
|
+
this.contents = options?.contents ?? '';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
get readOnly(): Resource['readOnly'] {
|
|
64
|
+
return this.options?.readOnly || !this.onSave;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
get autosaveable(): boolean {
|
|
68
|
+
return this.options?.autosaveable !== false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get initiallyDirty(): boolean {
|
|
72
|
+
return !!this.options?.initiallyDirty;
|
|
73
|
+
}
|
|
35
74
|
|
|
36
|
-
|
|
37
|
-
|
|
75
|
+
override async saveContents(contents: string): Promise<void> {
|
|
76
|
+
if (this.options?.onSave) {
|
|
77
|
+
await this.options.onSave(contents);
|
|
78
|
+
this.update({ contents });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
38
81
|
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
|
|
82
|
+
update(options: ResourceUpdateOptions): void {
|
|
83
|
+
if (options.contents !== undefined && options.contents !== this.contents) {
|
|
84
|
+
this.contents = options.contents;
|
|
85
|
+
this.fireDidChangeContents();
|
|
42
86
|
}
|
|
87
|
+
if ('onSave' in options && options.onSave !== this.onSave) {
|
|
88
|
+
this.onSave = options.onSave;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
43
91
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
92
|
+
override dispose(): void {
|
|
93
|
+
this.onDidChangeContentsEmitter.dispose();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export class DisposableRefCounter<V = unknown> implements Reference<V> {
|
|
98
|
+
static acquire<V>(item: DisposableRefCounter<V>): DisposableRefCounter<V> {
|
|
99
|
+
item.refs++;
|
|
100
|
+
return item;
|
|
101
|
+
}
|
|
102
|
+
static create<V>(value: V, onDispose: () => void): DisposableRefCounter<V> {
|
|
103
|
+
return this.acquire(new this(value, onDispose));
|
|
104
|
+
}
|
|
105
|
+
readonly object: V;
|
|
106
|
+
protected refs = 0;
|
|
107
|
+
protected constructor(value: V, protected readonly onDispose: () => void) {
|
|
108
|
+
this.object = value;
|
|
109
|
+
}
|
|
110
|
+
dispose(): void {
|
|
111
|
+
this.refs--;
|
|
112
|
+
if (this.refs === 0) {
|
|
113
|
+
this.onDispose();
|
|
48
114
|
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@injectable()
|
|
119
|
+
export class ChangeSetFileResourceResolver implements ResourceResolver {
|
|
120
|
+
protected readonly cache = new Map<string, UpdatableReferenceResource>();
|
|
49
121
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
122
|
+
add(uri: URI, options?: ResourceInitializationOptions): UpdatableReferenceResource {
|
|
123
|
+
const key = uri.toString();
|
|
124
|
+
if (this.cache.has(key)) {
|
|
125
|
+
throw new Error(`Resource ${key} already exists.`);
|
|
53
126
|
}
|
|
127
|
+
const underlyingResource = new DisposableMutableResource(uri, options);
|
|
128
|
+
const ref = DisposableRefCounter.create(underlyingResource, () => {
|
|
129
|
+
underlyingResource.dispose();
|
|
130
|
+
this.cache.delete(key);
|
|
131
|
+
});
|
|
132
|
+
const refResource = new UpdatableReferenceResource(ref);
|
|
133
|
+
this.cache.set(key, refResource);
|
|
134
|
+
return refResource;
|
|
135
|
+
}
|
|
54
136
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
137
|
+
tryGet(uri: URI): UpdatableReferenceResource | undefined {
|
|
138
|
+
try {
|
|
139
|
+
return this.resolve(uri);
|
|
140
|
+
} catch {
|
|
141
|
+
return undefined;
|
|
59
142
|
}
|
|
143
|
+
}
|
|
60
144
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
},
|
|
69
|
-
dispose: () => { }
|
|
70
|
-
};
|
|
145
|
+
update(uri: URI, contents: string): void {
|
|
146
|
+
const key = uri.toString();
|
|
147
|
+
const resource = this.cache.get(key);
|
|
148
|
+
if (!resource) {
|
|
149
|
+
throw new Error(`No resource for ${key}.`);
|
|
150
|
+
}
|
|
151
|
+
resource.update({ contents });
|
|
71
152
|
}
|
|
72
153
|
|
|
154
|
+
resolve(uri: URI): UpdatableReferenceResource {
|
|
155
|
+
const key = uri.toString();
|
|
156
|
+
const ref = this.cache.get(key);
|
|
157
|
+
if (!ref) { throw new Error(`No resource for ${key}.`); }
|
|
158
|
+
return UpdatableReferenceResource.acquire(ref);
|
|
159
|
+
}
|
|
73
160
|
}
|
|
74
|
-
|