From 76030031eb85f3ca09b30ff3636e7661d1422569 Mon Sep 17 00:00:00 2001 From: Stella Huang Date: Fri, 13 Sep 2024 10:40:03 -0700 Subject: [PATCH 1/8] add new property to codeAction --- client/package.json | 2 +- client/src/common/client.ts | 2 ++ client/src/common/codeAction.ts | 1 + client/src/common/codeConverter.ts | 2 ++ client/src/common/protocolConverter.ts | 1 + protocol/metaModel.json | 22 ++++++++++++++++++++++ protocol/src/common/protocol.ts | 7 +++++++ types/src/main.ts | 14 +++++++++++++- 8 files changed, 49 insertions(+), 2 deletions(-) diff --git a/client/package.json b/client/package.json index 23c225c2..e68e1c88 100644 --- a/client/package.json +++ b/client/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/Microsoft/vscode-languageserver-node/issues" }, - "enabledApiProposals": [], + "enabledApiProposals": ["codeActionAI"], "exports": { ".": { "types": "./lib/common/api.d.ts", diff --git a/client/src/common/client.ts b/client/src/common/client.ts index 6a54fb14..bb4127f1 100644 --- a/client/src/common/client.ts +++ b/client/src/common/client.ts @@ -2,6 +2,8 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ +/// + import { workspace as Workspace, window as Window, languages as Languages, version as VSCodeVersion, TextDocument, Disposable, OutputChannel, FileSystemWatcher as VFileSystemWatcher, DiagnosticCollection, Diagnostic as VDiagnostic, Uri, CancellationToken, WorkspaceEdit as VWorkspaceEdit, diff --git a/client/src/common/codeAction.ts b/client/src/common/codeAction.ts index c0d42ac0..c4240a80 100644 --- a/client/src/common/codeAction.ts +++ b/client/src/common/codeAction.ts @@ -41,6 +41,7 @@ export class CodeActionFeature extends TextDocumentLanguageFeature Date: Fri, 13 Sep 2024 10:40:24 -0700 Subject: [PATCH 2/8] add proposed api --- client/typings/vscode.proposed.codeActionAI.d.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 client/typings/vscode.proposed.codeActionAI.d.ts diff --git a/client/typings/vscode.proposed.codeActionAI.d.ts b/client/typings/vscode.proposed.codeActionAI.d.ts new file mode 100644 index 00000000..f6d7817e --- /dev/null +++ b/client/typings/vscode.proposed.codeActionAI.d.ts @@ -0,0 +1,16 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +declare module 'vscode' { + + export interface CodeAction { + /** + * Marks this as an AI action. + * + * Ex: A quick fix should be marked AI if it invokes AI. + */ + isAI?: boolean; + } +} From b87814a89b698c9fd50704f69c09d0a3507f3ad2 Mon Sep 17 00:00:00 2001 From: Stella Huang Date: Mon, 16 Sep 2024 16:11:22 -0700 Subject: [PATCH 3/8] change to use codeActionTag --- client-node-tests/src/converter.test.ts | 20 ++++++++++++ client/src/common/codeAction.ts | 1 - client/src/common/codeConverter.ts | 10 ++++-- client/src/common/protocolConverter.ts | 5 ++- protocol/metaModel.json | 41 +++++++++++++++---------- protocol/src/common/protocol.ts | 7 ----- types/src/main.ts | 32 ++++++++++++++----- 7 files changed, 80 insertions(+), 36 deletions(-) diff --git a/client-node-tests/src/converter.test.ts b/client-node-tests/src/converter.test.ts index 51afdb13..82a7f79e 100644 --- a/client-node-tests/src/converter.test.ts +++ b/client-node-tests/src/converter.test.ts @@ -1547,6 +1547,26 @@ suite('Code Converter', () => { strictEqual(result.triggerKind, proto.CodeActionTriggerKind.Automatic); }); + test('CodeAction - LLMGenerated tag c2p', () => { + const item: vscode.CodeAction = { + title: 'title', + isAI: true + }; + + const result = c2p.asCodeActionSync(item); + strictEqual(result.tags![0], proto.CodeActionTag.LLMGenerated); + }); + + test('CodeAction - LLMGenerated tag p2c', async () => { + const item: proto.CodeAction = { + title: 'title', + tags: [proto.CodeActionTag.LLMGenerated] + }; + + const result = await p2c.asCodeAction(item); + strictEqual(result.isAI, true); + }); + test('Uri Rewrite', () => { const converter = codeConverter.createConverter((value: vscode.Uri) => { return `${value.toString()}.vscode`; diff --git a/client/src/common/codeAction.ts b/client/src/common/codeAction.ts index c4240a80..c0d42ac0 100644 --- a/client/src/common/codeAction.ts +++ b/client/src/common/codeAction.ts @@ -41,7 +41,6 @@ export class CodeActionFeature extends TextDocumentLanguageFeature Date: Mon, 16 Sep 2024 16:22:46 -0700 Subject: [PATCH 4/8] add proposed --- types/src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/src/main.ts b/types/src/main.ts index ee954794..e246b880 100644 --- a/types/src/main.ts +++ b/types/src/main.ts @@ -3375,7 +3375,7 @@ export type CodeActionDisabled = { /** * Code action tags are extra annotations that tweak the rendering of a code action. * - * @since 3.18.0 + * @since 3.18.0 - proposed */ export namespace CodeActionTag { /** From 0aadb5b8d531f940175abfc6f96c0b72c2b2edec Mon Sep 17 00:00:00 2001 From: Stella Huang Date: Mon, 16 Sep 2024 16:26:45 -0700 Subject: [PATCH 5/8] add proposed to metaModel --- protocol/metaModel.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/protocol/metaModel.json b/protocol/metaModel.json index 53971825..d4074338 100644 --- a/protocol/metaModel.json +++ b/protocol/metaModel.json @@ -5824,7 +5824,8 @@ }, "optional": true, "documentation": "Tags for this code action.\n\n@since 3.18.0 - proposed", - "since": "3.18.0 - proposed" + "since": "3.18.0 - proposed", + "proposed": true } ], "documentation": "A code action represents a change that can be performed in code, e.g. to fix a problem or\nto refactor code.\n\nA CodeAction must set either `edit` and/or a `command`. If both are supplied, the `edit` is applied first, then the `command` is executed." @@ -14799,7 +14800,8 @@ } ], "documentation": "Code action tags are extra annotations that tweak the rendering of a code action.\n\n@since 3.18.0", - "since": "3.18.0" + "since": "3.18.0", + "proposed": true }, { "name": "TraceValue", From 1879b918ae70483d6dd0de3068ec1860fa786ebe Mon Sep 17 00:00:00 2001 From: Stella Huang Date: Tue, 17 Sep 2024 12:53:09 -0700 Subject: [PATCH 6/8] wording tweaks --- client/src/common/client.ts | 1 - client/src/common/codeConverter.ts | 1 + client/src/common/protocolConverter.ts | 1 + protocol/metaModel.json | 4 ++-- types/src/main.ts | 4 ++-- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/client/src/common/client.ts b/client/src/common/client.ts index bb4127f1..f7d7947f 100644 --- a/client/src/common/client.ts +++ b/client/src/common/client.ts @@ -2,7 +2,6 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ -/// import { workspace as Workspace, window as Window, languages as Languages, version as VSCodeVersion, TextDocument, Disposable, OutputChannel, diff --git a/client/src/common/codeConverter.ts b/client/src/common/codeConverter.ts index 3f36f04b..58e72ee8 100644 --- a/client/src/common/codeConverter.ts +++ b/client/src/common/codeConverter.ts @@ -2,6 +2,7 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ +/// import * as code from 'vscode'; import * as proto from 'vscode-languageserver-protocol'; diff --git a/client/src/common/protocolConverter.ts b/client/src/common/protocolConverter.ts index 6f17b646..f7ef491e 100644 --- a/client/src/common/protocolConverter.ts +++ b/client/src/common/protocolConverter.ts @@ -2,6 +2,7 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ +/// import * as code from 'vscode'; import * as ls from 'vscode-languageserver-protocol'; diff --git a/protocol/metaModel.json b/protocol/metaModel.json index d4074338..2ea1dbbc 100644 --- a/protocol/metaModel.json +++ b/protocol/metaModel.json @@ -14796,10 +14796,10 @@ { "name": "LLMGenerated", "value": 1, - "documentation": "Render a code action as LLM-generated, usually using a sparkle icon." + "documentation": "Marks the code action as LLM-generated." } ], - "documentation": "Code action tags are extra annotations that tweak the rendering of a code action.\n\n@since 3.18.0", + "documentation": "Code action tags are extra annotations that tweak the behavior of a code action.\n\n@since 3.18.0", "since": "3.18.0", "proposed": true }, diff --git a/types/src/main.ts b/types/src/main.ts index e246b880..dffa8582 100644 --- a/types/src/main.ts +++ b/types/src/main.ts @@ -3373,13 +3373,13 @@ export type CodeActionDisabled = { }; /** - * Code action tags are extra annotations that tweak the rendering of a code action. + * Code action tags are extra annotations that tweak the behavior of a code action. * * @since 3.18.0 - proposed */ export namespace CodeActionTag { /** - * Render a code action as LLM-generated, usually using a sparkle icon. + * Marks the code action as LLM-generated. */ export const LLMGenerated = 1; From d98a64b1b1d212513b199027d6e280e27f8f1e48 Mon Sep 17 00:00:00 2001 From: Stella Huang Date: Tue, 17 Sep 2024 12:56:47 -0700 Subject: [PATCH 7/8] hygiene --- client/src/common/client.ts | 1 - protocol/metaModel.json | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/client/src/common/client.ts b/client/src/common/client.ts index f7d7947f..6a54fb14 100644 --- a/client/src/common/client.ts +++ b/client/src/common/client.ts @@ -2,7 +2,6 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ - import { workspace as Workspace, window as Window, languages as Languages, version as VSCodeVersion, TextDocument, Disposable, OutputChannel, FileSystemWatcher as VFileSystemWatcher, DiagnosticCollection, Diagnostic as VDiagnostic, Uri, CancellationToken, WorkspaceEdit as VWorkspaceEdit, diff --git a/protocol/metaModel.json b/protocol/metaModel.json index 2ea1dbbc..d259ab54 100644 --- a/protocol/metaModel.json +++ b/protocol/metaModel.json @@ -5824,8 +5824,7 @@ }, "optional": true, "documentation": "Tags for this code action.\n\n@since 3.18.0 - proposed", - "since": "3.18.0 - proposed", - "proposed": true + "since": "3.18.0 - proposed" } ], "documentation": "A code action represents a change that can be performed in code, e.g. to fix a problem or\nto refactor code.\n\nA CodeAction must set either `edit` and/or a `command`. If both are supplied, the `edit` is applied first, then the `command` is executed." @@ -14799,9 +14798,8 @@ "documentation": "Marks the code action as LLM-generated." } ], - "documentation": "Code action tags are extra annotations that tweak the behavior of a code action.\n\n@since 3.18.0", - "since": "3.18.0", - "proposed": true + "documentation": "Code action tags are extra annotations that tweak the behavior of a code action.\n\n@since 3.18.0 - proposed", + "since": "3.18.0 - proposed" }, { "name": "TraceValue", From 26f538e94172374e7e1e4b911b342b370c39440d Mon Sep 17 00:00:00 2001 From: Stella Huang Date: Mon, 23 Sep 2024 13:37:00 -0700 Subject: [PATCH 8/8] add client capability --- client/src/common/codeAction.ts | 6 +++++- protocol/metaModel.json | 28 ++++++++++++++++++++++++++++ protocol/src/common/protocol.ts | 21 ++++++++++++++++++++- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/client/src/common/codeAction.ts b/client/src/common/codeAction.ts index c0d42ac0..3eb6d48c 100644 --- a/client/src/common/codeAction.ts +++ b/client/src/common/codeAction.ts @@ -9,7 +9,8 @@ import { } from 'vscode'; import { - ClientCapabilities, CancellationToken, ServerCapabilities, DocumentSelector, CodeActionRequest, CodeActionOptions, CodeActionRegistrationOptions, CodeActionParams, CodeActionResolveRequest, CodeActionKind + ClientCapabilities, CancellationToken, ServerCapabilities, DocumentSelector, CodeActionRequest, CodeActionOptions, CodeActionRegistrationOptions, CodeActionParams, CodeActionResolveRequest, CodeActionKind, + CodeActionTag } from 'vscode-languageserver-protocol'; import * as UUID from './utils/uuid'; @@ -63,6 +64,9 @@ export class CodeActionFeature extends TextDocumentLanguageFeature