forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
- Loading branch information
Showing
100 changed files
with
1,464 additions
and
795 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -400,10 +400,12 @@ | |
resolved "https://registry.yarnpkg.com/@types/debounce/-/debounce-1.0.0.tgz#417560200331e1bb84d72da85391102c2fcd61b7" | ||
integrity sha1-QXVgIAMx4buE1y2oU5EQLC/NYbc= | ||
|
||
"@types/[email protected]": | ||
version "4.1.5" | ||
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd" | ||
integrity sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ== | ||
"@types/debug@^4.1.5": | ||
version "4.1.9" | ||
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.9.tgz#906996938bc672aaf2fb8c0d3733ae1dda05b005" | ||
integrity sha512-8Hz50m2eoS56ldRlepxSBa6PWEVCtzUo/92HgLc2qTMnotJNIm7xP+UZhyWoYsyOdd5dxZ+NZLb24rsKyFs2ow== | ||
dependencies: | ||
"@types/ms" "*" | ||
|
||
"@types/events@*": | ||
version "1.2.0" | ||
|
@@ -533,6 +535,11 @@ | |
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.1.1.tgz#e7c4f1001eefa4b8afbd1eee27a237fee3bf29c4" | ||
integrity sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw== | ||
|
||
"@types/ms@*": | ||
version "0.7.32" | ||
resolved "https://registry.yarnpkg.com/@types/ms/-/ms-0.7.32.tgz#f6cd08939ae3ad886fcc92ef7f0109dacddf61ab" | ||
integrity sha512-xPSg0jm4mqgEkNhowKgZFBNtwoEwF6gJ4Dhww+GFpm3IgtNseHQZ5IqdNwnquZEoANxyDAKDRAdVo4Z72VvD/g== | ||
|
||
"@types/node-fetch@^2.5.0": | ||
version "2.5.8" | ||
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.8.tgz#e199c835d234c7eb0846f6618012e558544ee2fb" | ||
|
@@ -1116,10 +1123,10 @@ css-what@^6.1.0: | |
resolved "https://registry.yarnpkg.com/css-what/-/css-what-6.1.0.tgz#fb5effcf76f1ddea2c81bdfaa4de44e79bac70f4" | ||
integrity sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw== | ||
|
||
debug@4, debug@^4.1.0, debug@^4.3.2: | ||
version "4.3.2" | ||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b" | ||
integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw== | ||
debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2: | ||
version "4.3.4" | ||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" | ||
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== | ||
dependencies: | ||
ms "2.1.2" | ||
|
||
|
@@ -1130,13 +1137,6 @@ debug@^2.6.8: | |
dependencies: | ||
ms "2.0.0" | ||
|
||
debug@^4.1.1, debug@^4.3.1: | ||
version "4.3.1" | ||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.1.tgz#f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee" | ||
integrity sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ== | ||
dependencies: | ||
ms "2.1.2" | ||
|
||
decompress-response@^3.3.0: | ||
version "3.3.0" | ||
resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" | ||
|
@@ -1657,9 +1657,9 @@ http-proxy-agent@^4.0.1: | |
debug "4" | ||
|
||
https-proxy-agent@^5.0.0: | ||
version "5.0.0" | ||
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2" | ||
integrity sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA== | ||
version "5.0.1" | ||
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz#c59ef224a04fe8b754f3db0063a25ea30d0005d6" | ||
integrity sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA== | ||
dependencies: | ||
agent-base "6" | ||
debug "4" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
extensions/vscode-api-tests/src/singlefolder-tests/chat.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as assert from 'assert'; | ||
import 'mocha'; | ||
import { CancellationToken, chat, ChatAgentRequest, ChatVariableLevel, CompletionItemKind, Disposable, interactive, InteractiveProgress, InteractiveRequest, InteractiveResponseForProgress, InteractiveSession, InteractiveSessionState, Progress, ProviderResult } from 'vscode'; | ||
import { assertNoRpc, closeAllEditors, DeferredPromise, disposeAll } from '../utils'; | ||
|
||
suite('chat', () => { | ||
let disposables: Disposable[] = []; | ||
setup(() => { | ||
disposables = []; | ||
}); | ||
|
||
teardown(async function () { | ||
assertNoRpc(); | ||
await closeAllEditors(); | ||
disposeAll(disposables); | ||
}); | ||
|
||
function getDeferredForRequest(): DeferredPromise<ChatAgentRequest> { | ||
disposables.push(interactive.registerInteractiveSessionProvider('provider', { | ||
prepareSession: (_initialState: InteractiveSessionState | undefined, _token: CancellationToken): ProviderResult<InteractiveSession> => { | ||
return { | ||
requester: { name: 'test' }, | ||
responder: { name: 'test' }, | ||
}; | ||
}, | ||
|
||
provideResponseWithProgress: (_request: InteractiveRequest, _progress: Progress<InteractiveProgress>, _token: CancellationToken): ProviderResult<InteractiveResponseForProgress> => { | ||
return null; | ||
}, | ||
|
||
provideSlashCommands: (_session, _token) => { | ||
return [{ command: 'hello', title: 'Hello', kind: CompletionItemKind.Text }]; | ||
}, | ||
|
||
removeRequest: (_session: InteractiveSession, _requestId: string): void => { | ||
throw new Error('Function not implemented.'); | ||
} | ||
})); | ||
|
||
const deferred = new DeferredPromise<ChatAgentRequest>(); | ||
const agent = chat.createChatAgent('agent', (request, _context, _progress, _token) => { | ||
deferred.complete(request); | ||
return null; | ||
}); | ||
agent.slashCommandProvider = { | ||
provideSlashCommands: (_token) => { | ||
return [{ name: 'hello', description: 'Hello' }]; | ||
} | ||
}; | ||
disposables.push(agent); | ||
return deferred; | ||
} | ||
|
||
test('agent and slash command', async () => { | ||
const deferred = getDeferredForRequest(); | ||
interactive.sendInteractiveRequestToProvider('provider', { message: '@agent /hello friend' }); | ||
const lastResult = await deferred.p; | ||
assert.deepStrictEqual(lastResult.slashCommand, { name: 'hello', description: 'Hello' }); | ||
assert.strictEqual(lastResult.prompt, 'friend'); | ||
}); | ||
|
||
test('agent and variable', async () => { | ||
disposables.push(chat.registerVariable('myVar', 'My variable', { | ||
resolve(_name, _context, _token) { | ||
return [{ level: ChatVariableLevel.Full, value: 'myValue' }]; | ||
} | ||
})); | ||
|
||
const deferred = getDeferredForRequest(); | ||
interactive.sendInteractiveRequestToProvider('provider', { message: '@agent hi #myVar' }); | ||
const lastResult = await deferred.p; | ||
assert.strictEqual(lastResult.prompt, 'hi [#myVar](values:myVar)'); | ||
assert.strictEqual(lastResult.variables['myVar'][0].value, 'myValue'); | ||
}); | ||
}); |
62 changes: 62 additions & 0 deletions
62
extensions/vscode-api-tests/src/singlefolder-tests/interactive.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as assert from 'assert'; | ||
import 'mocha'; | ||
import { CancellationToken, CompletionItemKind, Disposable, interactive, InteractiveProgress, InteractiveRequest, InteractiveResponseForProgress, InteractiveSession, InteractiveSessionState, Progress, ProviderResult } from 'vscode'; | ||
import { assertNoRpc, closeAllEditors, DeferredPromise, disposeAll } from '../utils'; | ||
|
||
suite('InteractiveSessionProvider', () => { | ||
let disposables: Disposable[] = []; | ||
setup(async () => { | ||
disposables = []; | ||
}); | ||
|
||
teardown(async function () { | ||
assertNoRpc(); | ||
await closeAllEditors(); | ||
disposeAll(disposables); | ||
}); | ||
|
||
function getDeferredForRequest(): DeferredPromise<InteractiveRequest> { | ||
const deferred = new DeferredPromise<InteractiveRequest>(); | ||
disposables.push(interactive.registerInteractiveSessionProvider('provider', { | ||
prepareSession: (_initialState: InteractiveSessionState | undefined, _token: CancellationToken): ProviderResult<InteractiveSession> => { | ||
return { | ||
requester: { name: 'test' }, | ||
responder: { name: 'test' }, | ||
}; | ||
}, | ||
|
||
provideResponseWithProgress: (request: InteractiveRequest, _progress: Progress<InteractiveProgress>, _token: CancellationToken): ProviderResult<InteractiveResponseForProgress> => { | ||
deferred.complete(request); | ||
return null; | ||
}, | ||
|
||
provideSlashCommands: (_session, _token) => { | ||
return [{ command: 'hello', title: 'Hello', kind: CompletionItemKind.Text }]; | ||
}, | ||
|
||
removeRequest: (_session: InteractiveSession, _requestId: string): void => { | ||
throw new Error('Function not implemented.'); | ||
} | ||
})); | ||
return deferred; | ||
} | ||
|
||
test('plain text query', async () => { | ||
const deferred = getDeferredForRequest(); | ||
interactive.sendInteractiveRequestToProvider('provider', { message: 'hello' }); | ||
const lastResult = await deferred.p; | ||
assert.strictEqual(lastResult.message, 'hello'); | ||
}); | ||
|
||
test('slash command', async () => { | ||
const deferred = getDeferredForRequest(); | ||
interactive.sendInteractiveRequestToProvider('provider', { message: '/hello' }); | ||
const lastResult = await deferred.p; | ||
assert.strictEqual(lastResult.message, '/hello'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.