From 0de7a6bc64e4eb6ca465555399f702bc37ce7af6 Mon Sep 17 00:00:00 2001 From: Saransh Saini <66969478+saranshsaini@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:38:13 -0700 Subject: [PATCH] Proto migrations, ide name fix (#116) * inital move * clean * rename ide * revert absolute_uri document name * note * workign * backwards comp * clean * compatible * breh * version --------- Co-authored-by: Saransh Saini --- CodeiumVS.sln | 4 +- CodeiumVS/LanguageServer/LanguageServer.cs | 4 +- .../LanguageServerController.cs | 12 +- CodeiumVS/LanguageServer/Packets.cs | 314 +++++++++++++++++- CodeiumVS/source.extension.vsixmanifest | 2 +- 5 files changed, 314 insertions(+), 22 deletions(-) diff --git a/CodeiumVS.sln b/CodeiumVS.sln index 8d5c8ea..cf092f6 100644 --- a/CodeiumVS.sln +++ b/CodeiumVS.sln @@ -15,8 +15,8 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B37F2AE5-CDEC-45B3-944D-8EF912810A12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B37F2AE5-CDEC-45B3-944D-8EF912810A12}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B37F2AE5-CDEC-45B3-944D-8EF912810A12}.Debug|Any CPU.ActiveCfg = Release|Any CPU + {B37F2AE5-CDEC-45B3-944D-8EF912810A12}.Debug|Any CPU.Build.0 = Release|Any CPU {B37F2AE5-CDEC-45B3-944D-8EF912810A12}.Debug|arm64.ActiveCfg = Debug|arm64 {B37F2AE5-CDEC-45B3-944D-8EF912810A12}.Debug|arm64.Build.0 = Debug|arm64 {B37F2AE5-CDEC-45B3-944D-8EF912810A12}.Debug|x86.ActiveCfg = Debug|x86 diff --git a/CodeiumVS/LanguageServer/LanguageServer.cs b/CodeiumVS/LanguageServer/LanguageServer.cs index c0a75d7..8136a0e 100644 --- a/CodeiumVS/LanguageServer/LanguageServer.cs +++ b/CodeiumVS/LanguageServer/LanguageServer.cs @@ -66,7 +66,8 @@ public async Task InitializeAsync() await PrepareAsync(); _metadata.request_id = 0; - _metadata.ide_name = "visual_studio"; + // TODO: Change name + _metadata.ide_name = "vscode"; _metadata.ide_version = ideVersion; _metadata.extension_name = Vsix.Name; _metadata.extension_version = _languageServerVersion; @@ -781,6 +782,7 @@ public async Task?> cursor_offset = (ulong)cursorPosition, line_ending = lineEnding, absolute_path = absolutePath, + absolute_path_migrate_me_to_uri = absolutePath, relative_path = Path.GetFileName(absolutePath) }, editor_options = new() { tab_size = (ulong)tabSize, diff --git a/CodeiumVS/LanguageServer/LanguageServerController.cs b/CodeiumVS/LanguageServer/LanguageServerController.cs index 673be61..119a2c4 100644 --- a/CodeiumVS/LanguageServer/LanguageServerController.cs +++ b/CodeiumVS/LanguageServer/LanguageServerController.cs @@ -40,9 +40,10 @@ void OnMessage(object sender, MessageEventArgs msg) if (request.ShouldSerializeopen_file_pointer()) { + var data = request.open_file_pointer; OpenSelection( - data.file_path, data.start_line, data.start_col, data.end_line, data.end_col); + data.file_path_migrate_me_to_uri.IsNullOrEmpty() ? data.file_path : data.file_path_migrate_me_to_uri, data.start_line, data.start_col, data.end_line, data.end_col); } else if (request.ShouldSerializeinsert_at_cursor()) { @@ -64,7 +65,7 @@ void OnMessage(object sender, MessageEventArgs msg) } } - ApplyDiff(data.file_path, data.diff.start_line, data.diff.end_line, replacement); + ApplyDiff(data.file_path_migrate_me_to_uri.IsNullOrEmpty() ? data.file_path : data.file_path_migrate_me_to_uri, data.diff.start_line, data.diff.end_line, replacement); } } @@ -185,6 +186,7 @@ public async Task ExplainCodeBlockAsync(string filePath, Language language, new() { explain_code_block = new() { code_block_info = codeBlockInfo, file_path = filePath, + file_path_migrate_me_to_uri = filePath, language = language, } }; @@ -200,6 +202,7 @@ public async Task ExplainFunctionAsync(string filePath, FunctionInfo functionInf new() { explain_function = new() { function_info = functionInfo, file_path = filePath, + file_path_migrate_me_to_uri = filePath, language = functionInfo.Language, } }; @@ -216,6 +219,7 @@ public async Task GenerateFunctionUnitTestAsync(string instructions, string file new() { function_unit_tests = new() { function_info = functionInfo, file_path = filePath, + file_path_migrate_me_to_uri = filePath, language = functionInfo.Language, instructions = instructions, } }; @@ -232,6 +236,7 @@ public async Task GenerateFunctionDocstringAsync(string filePath, FunctionInfo f new() { function_docstring = new() { function_info = functionInfo, file_path = filePath, + file_path_migrate_me_to_uri = filePath, language = functionInfo.Language, } }; @@ -247,6 +252,7 @@ public async Task RefactorCodeBlockAsync(string prompt, string filePath, Languag request.get_chat_message_request.chat_messages[0].intent = new() { code_block_refactor = new() { code_block_info = codeBlockInfo, file_path = filePath, + file_path_migrate_me_to_uri = filePath, language = language, refactor_description = prompt } }; @@ -262,6 +268,7 @@ public async Task RefactorFunctionAsync(string prompt, string filePath, request.get_chat_message_request.chat_messages[0].intent = new() { function_refactor = new() { function_info = functionInfo, file_path = filePath, + file_path_migrate_me_to_uri = filePath, language = functionInfo.Language, refactor_description = prompt } }; @@ -299,6 +306,7 @@ public async Task ExplainProblemAsync(string problemMessage, SnapshotSpan span) surroundingLineStart.Start, surroundingLineEnd.End - surroundingLineStart.Start), language = Languages.Mapper.GetLanguage(span.Snapshot.TextBuffer.ContentType).Type, file_path = span.Snapshot.TextBuffer.GetFileName(), + file_path_migrate_me_to_uri = span.Snapshot.TextBuffer.GetFileName(), line_number = problemLineStart.LineNumber + 1, } }; diff --git a/CodeiumVS/LanguageServer/Packets.cs b/CodeiumVS/LanguageServer/Packets.cs index b181616..bf8a244 100644 --- a/CodeiumVS/LanguageServer/Packets.cs +++ b/CodeiumVS/LanguageServer/Packets.cs @@ -183,9 +183,31 @@ public partial class Document : global::ProtoBuf.IExtensible [global::System.ComponentModel.DefaultValue("")] public string absolute_path { get; set; } = ""; + [global::ProtoBuf.ProtoMember(1)] + [global::System.ComponentModel.DefaultValue("")] + public string absolute_path_migrate_me_to_uri { get; set; } = ""; + + [global::ProtoBuf.ProtoMember(12)] + [global::System.ComponentModel.DefaultValue("")] + public string absolute_uri { get; set; } = ""; + [global::ProtoBuf.ProtoMember(2)] [global::System.ComponentModel.DefaultValue("")] - public string relative_path { + public string relative_path_migrate_me_to_workspace_uri + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(2)] + [global::System.ComponentModel.DefaultValue("")] + public string relative_path + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(13)] + [global::System.ComponentModel.DefaultValue("")] + public string workspace_uri { get; set; } = ""; @@ -404,6 +426,14 @@ public partial class CodeContextItem : global::ProtoBuf.IExtensible [global::System.ComponentModel.DefaultValue("")] public string absolute_path { get; set; } = ""; + [global::ProtoBuf.ProtoMember(1)] + [global::System.ComponentModel.DefaultValue("")] + public string absolute_path_migrate_me_to_uri { get; set; } = ""; + + [global::ProtoBuf.ProtoMember(16)] + [global::System.ComponentModel.DefaultValue("")] + public string absolute_uri { get; set; } = ""; + [global::ProtoBuf.ProtoMember(2)] public global::System.Collections.Generic.List workspace_paths { get; @@ -480,6 +510,14 @@ public partial class WorkspacePath : global::ProtoBuf.IExtensible [global::System.ComponentModel.DefaultValue("")] public string workspace { get; set; } = ""; + [global::ProtoBuf.ProtoMember(1)] + [global::System.ComponentModel.DefaultValue("")] + public string workspace_migrate_me_to_uri { get; set; } = ""; + + [global::ProtoBuf.ProtoMember(3)] + [global::System.ComponentModel.DefaultValue("")] + public string workspace_uri { get; set; } = ""; + [global::ProtoBuf.ProtoMember(2)] [global::System.ComponentModel.DefaultValue("")] public string relative_path { @@ -750,6 +788,13 @@ public string prompt { get; set; } = ""; + [global::ProtoBuf.ProtoMember(21)] + [global::System.ComponentModel.DefaultValue("")] + public string context_prompt + { + get; set; + } = ""; + [global::ProtoBuf.ProtoMember(8)] public global::System.Collections.Generic.List prompt_element_ranges { get; @@ -771,6 +816,12 @@ public ulong prompt_latency_ms { get; } = new global::System.Collections.Generic.List(); + [global::ProtoBuf.ProtoMember(20)] + public ulong num_tokenized_bytes + { + get; set; + } + [global::ProtoBuf.ProtoMember(3)] [global::System.ComponentModel.DefaultValue("")] public string editor_language { @@ -784,19 +835,40 @@ public Language language { [global::ProtoBuf.ProtoMember(5)] [global::System.ComponentModel.DefaultValue("")] - public string absolute_path { + public string absolute_path + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(5)] + [global::System.ComponentModel.DefaultValue("")] + public string absolute_path_uri_for_telemetry { get; set; } = ""; [global::ProtoBuf.ProtoMember(6)] [global::System.ComponentModel.DefaultValue("")] - public string relative_path { + public string relative_path + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(6)] + [global::System.ComponentModel.DefaultValue("")] + public string relative_path_for_telemetry { get; set; } = ""; [global::ProtoBuf.ProtoMember(13)] [global::System.ComponentModel.DefaultValue("")] - public string workspace { + public string workspace + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(13)] + [global::System.ComponentModel.DefaultValue("")] + public string workspace_uri_for_telemetry { get; set; } = ""; @@ -806,6 +878,20 @@ public string experiment_features_json { get; set; } = ""; + [global::ProtoBuf.ProtoMember(19)] + [global::System.ComponentModel.DefaultValue("")] + public string experiment_variant_json + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(10)] + [global::System.ComponentModel.DefaultValue("")] + public string model + { + get; set; + } = ""; + [global::ProtoBuf.ProtoMember(14)] public bool has_line_suffix { get; set; @@ -831,6 +917,14 @@ public string model_tag { public global::System.Collections.Generic.List experiment_tags { get; } = new global::System.Collections.Generic.List(); + + [global::ProtoBuf.ProtoMember(22)] + [global::System.ComponentModel.DefaultValue("")] + public string eval_suffix + { + get; set; + } = ""; + } [global::ProtoBuf.ProtoContract()] @@ -1252,12 +1346,36 @@ public Document active_document { } [global::ProtoBuf.ProtoMember(6)] - public global::System.Collections.Generic.List open_document_paths { + public global::System.Collections.Generic.List open_document_paths + { + get; + } = new global::System.Collections.Generic.List(); + + [global::ProtoBuf.ProtoMember(6)] + public global::System.Collections.Generic.List open_document_paths_migrate_me_to_uris + { + get; + } = new global::System.Collections.Generic.List(); + + [global::ProtoBuf.ProtoMember(12)] + public global::System.Collections.Generic.List open_document_uris { + get; + } = new global::System.Collections.Generic.List(); + + [global::ProtoBuf.ProtoMember(7)] + public global::System.Collections.Generic.List workspace_paths + { get; } = new global::System.Collections.Generic.List(); [global::ProtoBuf.ProtoMember(7)] - public global::System.Collections.Generic.List workspace_paths { + public global::System.Collections.Generic.List workspace_paths_migrate_me_to_uris + { + get; + } = new global::System.Collections.Generic.List(); + + [global::ProtoBuf.ProtoMember(13)] + public global::System.Collections.Generic.List workspace_uris { get; } = new global::System.Collections.Generic.List(); @@ -1486,7 +1604,21 @@ public Language language { [global::ProtoBuf.ProtoMember(3)] [global::System.ComponentModel.DefaultValue("")] - public string file_path { + public string file_path_migrate_me_to_uri + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(3)] + [global::System.ComponentModel.DefaultValue("")] + public string file_path + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(4)] + [global::System.ComponentModel.DefaultValue("")] + public string uri { get; set; } = ""; } @@ -1561,7 +1693,21 @@ public Language language { [global::ProtoBuf.ProtoMember(3)] [global::System.ComponentModel.DefaultValue("")] - public string file_path { + public string file_path + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(3)] + [global::System.ComponentModel.DefaultValue("")] + public string file_path_migrate_me_to_uri + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(4)] + [global::System.ComponentModel.DefaultValue("")] + public string uri { get; set; } = ""; } @@ -1584,7 +1730,21 @@ public Language language { [global::ProtoBuf.ProtoMember(3)] [global::System.ComponentModel.DefaultValue("")] - public string file_path { + public string file_path_migrate_me_to_uri + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(3)] + [global::System.ComponentModel.DefaultValue("")] + public string file_path + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(5)] + [global::System.ComponentModel.DefaultValue("")] + public string uri { get; set; } = ""; @@ -1613,7 +1773,21 @@ public Language language { [global::ProtoBuf.ProtoMember(3)] [global::System.ComponentModel.DefaultValue("")] - public string file_path { + public string file_path_migrate_me_to_uri + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(3)] + [global::System.ComponentModel.DefaultValue("")] + public string file_path + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(4)] + [global::System.ComponentModel.DefaultValue("")] + public string uri { get; set; } = ""; } @@ -1669,7 +1843,21 @@ public Language language { [global::ProtoBuf.ProtoMember(3)] [global::System.ComponentModel.DefaultValue("")] - public string file_path { + public string file_path_migrate_me_to_uri + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(3)] + [global::System.ComponentModel.DefaultValue("")] + public string file_path + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(5)] + [global::System.ComponentModel.DefaultValue("")] + public string uri { get; set; } = ""; @@ -1696,12 +1884,25 @@ public Language language { get; set; } + [global::ProtoBuf.ProtoMember(3)] + [global::System.ComponentModel.DefaultValue("")] + public string file_path_migrate_me_to_uri + { + get; set; + } = ""; + [global::ProtoBuf.ProtoMember(3)] [global::System.ComponentModel.DefaultValue("")] public string file_path { get; set; } = ""; + [global::ProtoBuf.ProtoMember(5)] + [global::System.ComponentModel.DefaultValue("")] + public string uri { + get; set; + } = ""; + [global::ProtoBuf.ProtoMember(4)] [global::System.ComponentModel.DefaultValue("")] public string instructions { @@ -1739,7 +1940,21 @@ public Language language { [global::ProtoBuf.ProtoMember(5)] [global::System.ComponentModel.DefaultValue("")] - public string file_path { + public string file_path_migrate_me_to_uri + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(5)] + [global::System.ComponentModel.DefaultValue("")] + public string file_path + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(7)] + [global::System.ComponentModel.DefaultValue("")] + public string uri { get; set; } = ""; @@ -1768,7 +1983,21 @@ public Language language { [global::ProtoBuf.ProtoMember(3)] [global::System.ComponentModel.DefaultValue("")] - public string file_path { + public string file_path_migrate_me_to_uri + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(3)] + [global::System.ComponentModel.DefaultValue("")] + public string file_path + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(5)] + [global::System.ComponentModel.DefaultValue("")] + public string uri { get; set; } = ""; @@ -1796,7 +2025,21 @@ public Language language { [global::ProtoBuf.ProtoMember(3)] [global::System.ComponentModel.DefaultValue("")] - public string file_path { + public string file_path_migrate_me_to_uri + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(3)] + [global::System.ComponentModel.DefaultValue("")] + public string file_path + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(4)] + [global::System.ComponentModel.DefaultValue("")] + public string uri { get; set; } = ""; } @@ -1918,7 +2161,21 @@ public partial class ChatMessageActionEdit : global::ProtoBuf.IExtensible [global::ProtoBuf.ProtoMember(1)] [global::System.ComponentModel.DefaultValue("")] - public string file_path { get; set; } = ""; + public string file_path_migrate_me_to_uri + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(1)] + [global::System.ComponentModel.DefaultValue("")] + public string file_path + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(6)] + [global::System.ComponentModel.DefaultValue("")] + public string uri { get; set; } = ""; [global::ProtoBuf.ProtoMember(2)] public DiffBlock diff { @@ -2111,10 +2368,21 @@ public partial class OpenFilePointer : global::ProtoBuf.IExtensible global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) => global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing); + [global::ProtoBuf.ProtoMember(1)] + [global::System.ComponentModel.DefaultValue("")] + public string file_path_migrate_me_to_uri + { + get; set; + } = ""; + [global::ProtoBuf.ProtoMember(1)] [global::System.ComponentModel.DefaultValue("")] public string file_path { get; set; } = ""; + [global::ProtoBuf.ProtoMember(6)] + [global::System.ComponentModel.DefaultValue("")] + public string file_uri { get; set; } = ""; + [global::ProtoBuf.ProtoMember(2)] public int start_line { get; set; @@ -2181,7 +2449,21 @@ public partial class ApplyDiff : global::ProtoBuf.IExtensible [global::ProtoBuf.ProtoMember(2)] [global::System.ComponentModel.DefaultValue("")] - public string file_path { + public string file_path_migrate_me_to_uri + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(2)] + [global::System.ComponentModel.DefaultValue("")] + public string file_path + { + get; set; + } = ""; + + [global::ProtoBuf.ProtoMember(8)] + [global::System.ComponentModel.DefaultValue("")] + public string uri { get; set; } = ""; diff --git a/CodeiumVS/source.extension.vsixmanifest b/CodeiumVS/source.extension.vsixmanifest index 4fcbf5b..97b5d01 100644 --- a/CodeiumVS/source.extension.vsixmanifest +++ b/CodeiumVS/source.extension.vsixmanifest @@ -1,7 +1,7 @@ - + Codeium The modern coding superpower: free AI code acceleration plugin for your favorite languages. Type less. Code more. Ship faster. https://www.codeium.com