├── .editorconfig ├── .github └── workflows │ ├── Build.yml │ └── PublishExtension.yml ├── .gitignore ├── CCodeAI.QuickActions ├── CCodeAI.QuickActions.CodeFixes │ ├── CCodeAI.QuickActions.CodeFixes.csproj │ ├── CCodeAIQuickActionsCodeFixProvider.cs │ ├── CodeFixResources.Designer.cs │ ├── CodeFixResources.resx │ ├── CodeFixResources.zh.resx │ ├── CodeOptimizationCodeFixProvider.cs │ └── KernelFactory.cs ├── CCodeAI.QuickActions.Package │ ├── CCodeAI.QuickActions.Package.csproj │ └── tools │ │ ├── install.ps1 │ │ └── uninstall.ps1 ├── CCodeAI.QuickActions.Test │ ├── CCodeAI.QuickActions.Test.csproj │ ├── CCodeAIQuickActionsUnitTests.cs │ └── Verifiers │ │ ├── CSharpAnalyzerVerifier`1+Test.cs │ │ ├── CSharpAnalyzerVerifier`1.cs │ │ ├── CSharpCodeFixVerifier`2+Test.cs │ │ ├── CSharpCodeFixVerifier`2.cs │ │ ├── CSharpCodeRefactoringVerifier`1+Test.cs │ │ ├── CSharpCodeRefactoringVerifier`1.cs │ │ ├── CSharpVerifierHelper.cs │ │ ├── VisualBasicAnalyzerVerifier`1+Test.cs │ │ ├── VisualBasicAnalyzerVerifier`1.cs │ │ ├── VisualBasicCodeFixVerifier`2+Test.cs │ │ ├── VisualBasicCodeFixVerifier`2.cs │ │ ├── VisualBasicCodeRefactoringVerifier`1+Test.cs │ │ └── VisualBasicCodeRefactoringVerifier`1.cs └── CCodeAI.QuickActions │ ├── CCodeAI.QuickActions.csproj │ ├── CCodeAIQuickActionsAnalyzer.cs │ ├── CCodeAISkills │ ├── ChatSkill │ │ └── Chat │ │ │ ├── config.json │ │ │ └── skprompt.txt │ └── CoreSkill │ │ ├── Comment │ │ ├── config.json │ │ └── skprompt.txt │ │ ├── Explain │ │ ├── config.json │ │ └── skprompt.txt │ │ ├── Optimize │ │ ├── config.json │ │ └── skprompt.txt │ │ ├── UnitTest │ │ ├── config.json │ │ └── skprompt.txt │ │ └── WirteCode │ │ ├── config.json │ │ └── skprompt.txt │ ├── CodeOptimizationAnalyzer.cs │ ├── ISkillsProvider.cs │ ├── LocalSemanticFunctionModel.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Resources.zh.resx │ ├── SkillModel.cs │ ├── Skills │ ├── .semantic-kernel │ │ └── results │ │ │ ├── GenerateEnum │ │ │ └── Skills.GenerateEnum.results.json │ │ │ ├── MethodSkill │ │ │ └── GenerateMethod │ │ │ │ └── MethodSkill.GenerateMethod.results.json │ │ │ └── WPFSkill │ │ │ └── GenerateWPFStyle │ │ │ └── WPFSkill.GenerateWPFStyle.results.json │ ├── ClassSkill │ │ └── GenerateClass │ │ │ ├── config.json │ │ │ └── skprompt.txt │ ├── CodeOptimization.cs │ ├── EnumSkill │ │ └── GenerateEnum │ │ │ ├── config.json │ │ │ └── skprompt.txt │ ├── GeneralSkill │ │ ├── Empty │ │ │ ├── config.json │ │ │ └── skprompt.txt │ │ └── GenerateCode │ │ │ ├── config.json │ │ │ └── skprompt.txt │ ├── MethodSkill │ │ ├── GenerateMethod │ │ │ ├── config.json │ │ │ └── skprompt.txt │ │ └── GenerateStaticMethod │ │ │ ├── config.json │ │ │ └── skprompt.txt │ └── WPFSkill │ │ └── GenerateWPFStyle │ │ ├── config.json │ │ └── skprompt.txt │ └── SkillsProvider.cs ├── CCodeAI.sln ├── CCodeAI ├── CCodeAI.csproj ├── CCodePackage.cs ├── Commands │ ├── CCodeAICommandId.cs │ ├── CCodeAddAskCommandId.cs │ ├── CCodeCodeGenCommandId.cs │ ├── CCodeContinuationCodeCommand.cs │ ├── CCodeExplainCommand.cs │ ├── CCodeNoteCommand.cs │ └── CCodeOptimizeCommand.cs ├── Converters │ ├── BoolToVisibilityConverter.cs │ ├── StringIsNullOrEmptyToVisibilityConveter.cs │ └── WhoToStringConverter.cs ├── Extension.en-US.vsixlangpack ├── Extension.zh-CN.vsixlangpack ├── Extensions │ ├── CodeExtension.cs │ ├── LocalSemanticFunctionModelExtension.cs │ └── ScrollViewerExtensions.cs ├── ICSharpCode.AvalonEdit.dll ├── MdXaml.Plugins.dll ├── MdXaml.dll ├── Microsoft.Bcl.AsyncInterfaces.dll ├── Models │ ├── ChatData.cs │ ├── ChatListExtension.cs │ ├── ConfigOptions.cs │ ├── EWho.cs │ └── WelcomeChatData.cs ├── Properties │ └── AssemblyInfo.cs ├── Resources │ ├── Icon.png │ ├── Resources.Designer.cs │ ├── Resources.resx │ └── Resources.zh.resx ├── Themes │ └── Converters.xaml ├── ToolWindows │ ├── CCodeExplainWindow.cs │ ├── CCodeExplainWindowControl.xaml │ ├── CCodeExplainWindowControl.xaml.cs │ └── CodeRichTextBox.cs ├── VSCommandTable.cs ├── VSCommandTable.vsct ├── ViewModels │ ├── CCodeExplainWindowControlViewModel.cs │ ├── CodeExplainExtension.cs │ └── CodeGenWindowViewModel.cs ├── Views │ ├── AvalonEditBehaviour.cs │ ├── ChatDataTemplateSelection.cs │ ├── CodeGenWindow.xaml │ └── CodeGenWindow.xaml.cs ├── en │ └── Extension.vsixlangpack ├── source.extension.cs ├── source.extension.vsixmanifest └── zh │ └── Extension.vsixlangpack ├── ChangLog.md ├── LICENSE ├── MdXaml.Test ├── App.xaml ├── App.xaml.cs ├── AssemblyInfo.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── MdXaml.Test.csproj └── Readme.md ├── MdXaml ├── Controls │ ├── ExtendTextEditor.xaml │ └── ExtendTextEditor.xaml.cs ├── DocumentAnchor.cs ├── EmojiTable.cs ├── EmojiTable.txt ├── EnumerableExt.cs ├── Ext │ ├── AlphaExtension.cs │ ├── BrightnessExtension.cs │ ├── ColorExt.cs │ ├── FontSizeScaleExtension.cs │ ├── HSV.cs │ └── SyntaxHighlightWrapperExtension.cs ├── GlobalSuppressions.cs ├── ImageLoaderManager.cs ├── LinkActions │ ├── DiaplayCommand.cs │ ├── FlowDocumentJumpAnchorIfNecessary.cs │ └── OpenCommand.cs ├── Markdown.Style.xaml ├── Markdown.cs ├── MarkdownMigFree.Style.xaml ├── MarkdownScrollViewer.cs ├── MarkdownStyle.cs ├── MdXaml.csproj ├── SimpleBlockParser.cs ├── SimpleInlineParser.cs ├── TableBuilder.cs ├── TextToFlowDocumentConverter.cs └── TextUtil.cs ├── README.md ├── Resources ├── Chatpane.png ├── CodeFix.png ├── ContextMenu.png ├── QuickChat.png └── SimpleHistory.png └── publishManifest.json /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | 3 | # RS1035: Do not use APIs banned for analyzers 4 | dotnet_diagnostic.RS1035.severity = warning 5 | csharp_using_directive_placement = outside_namespace:silent 6 | csharp_style_expression_bodied_methods = false:silent 7 | csharp_style_expression_bodied_constructors = false:silent 8 | csharp_style_expression_bodied_operators = false:silent 9 | csharp_style_expression_bodied_properties = true:silent 10 | csharp_style_expression_bodied_indexers = true:silent 11 | csharp_style_expression_bodied_accessors = true:silent 12 | csharp_style_expression_bodied_lambdas = true:silent 13 | csharp_style_expression_bodied_local_functions = false:silent 14 | csharp_style_conditional_delegate_call = true:suggestion 15 | csharp_style_var_for_built_in_types = false:silent 16 | csharp_style_var_when_type_is_apparent = false:silent 17 | csharp_style_var_elsewhere = false:silent 18 | 19 | [*.{cs,vb}] 20 | end_of_line = crlf 21 | dotnet_style_qualification_for_field = false:silent 22 | dotnet_style_qualification_for_property = false:silent 23 | dotnet_style_qualification_for_method = false:silent 24 | dotnet_style_qualification_for_event = false:silent 25 | [*.cs] 26 | #### 命名样式 #### 27 | 28 | # 命名规则 29 | 30 | dotnet_naming_rule.私有或内部字段_should_be_下划线开头.severity = suggestion 31 | dotnet_naming_rule.私有或内部字段_should_be_下划线开头.symbols = 私有或内部字段 32 | dotnet_naming_rule.私有或内部字段_should_be_下划线开头.style = 下划线开头 33 | 34 | # 符号规范 35 | 36 | dotnet_naming_symbols.私有或内部字段.applicable_kinds = field 37 | dotnet_naming_symbols.私有或内部字段.applicable_accessibilities = internal, private, private_protected 38 | dotnet_naming_symbols.私有或内部字段.required_modifiers = 39 | 40 | # 命名样式 41 | 42 | dotnet_naming_style.下划线开头.required_prefix = _ 43 | dotnet_naming_style.下划线开头.required_suffix = 44 | dotnet_naming_style.下划线开头.word_separator = 45 | dotnet_naming_style.下划线开头.capitalization = camel_case 46 | 47 | [*.{cs,vb}] 48 | #### 命名样式 #### 49 | 50 | # 命名规则 51 | 52 | dotnet_naming_rule.interface_should_be_以_i_开始.severity = suggestion 53 | dotnet_naming_rule.interface_should_be_以_i_开始.symbols = interface 54 | dotnet_naming_rule.interface_should_be_以_i_开始.style = 以_i_开始 55 | 56 | dotnet_naming_rule.类型_should_be_帕斯卡拼写法.severity = suggestion 57 | dotnet_naming_rule.类型_should_be_帕斯卡拼写法.symbols = 类型 58 | dotnet_naming_rule.类型_should_be_帕斯卡拼写法.style = 帕斯卡拼写法 59 | 60 | dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.severity = suggestion 61 | dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.symbols = 非字段成员 62 | dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.style = 帕斯卡拼写法 63 | 64 | # 符号规范 65 | 66 | dotnet_naming_symbols.interface.applicable_kinds = interface 67 | dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected 68 | dotnet_naming_symbols.interface.required_modifiers = 69 | 70 | dotnet_naming_symbols.类型.applicable_kinds = class, struct, interface, enum 71 | dotnet_naming_symbols.类型.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected 72 | dotnet_naming_symbols.类型.required_modifiers = 73 | 74 | dotnet_naming_symbols.非字段成员.applicable_kinds = property, event, method 75 | dotnet_naming_symbols.非字段成员.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected 76 | dotnet_naming_symbols.非字段成员.required_modifiers = 77 | 78 | # 命名样式 79 | 80 | dotnet_naming_style.以_i_开始.required_prefix = I 81 | dotnet_naming_style.以_i_开始.required_suffix = 82 | dotnet_naming_style.以_i_开始.word_separator = 83 | dotnet_naming_style.以_i_开始.capitalization = pascal_case 84 | 85 | dotnet_naming_style.帕斯卡拼写法.required_prefix = 86 | dotnet_naming_style.帕斯卡拼写法.required_suffix = 87 | dotnet_naming_style.帕斯卡拼写法.word_separator = 88 | dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case 89 | 90 | dotnet_naming_style.帕斯卡拼写法.required_prefix = 91 | dotnet_naming_style.帕斯卡拼写法.required_suffix = 92 | dotnet_naming_style.帕斯卡拼写法.word_separator = 93 | dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case 94 | -------------------------------------------------------------------------------- /.github/workflows/Build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: 6 | - '**' 7 | pull_request: 8 | branches: 9 | - '!master' 10 | 11 | jobs: 12 | build: 13 | runs-on: windows-latest 14 | 15 | # Steps represent a sequence of tasks that will be executed as part of the job 16 | steps: 17 | 18 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 19 | - uses: actions/checkout@v2 20 | 21 | # Generate Azure OpenAI key 22 | - name: wirte keys 23 | shell: pwsh 24 | run: | 25 | "public static class AzureConfig{public const string Endpoint = `"${{ secrets.ENDPOINT }}`";public const string AppKey = `"${{ secrets.APP_KEY }}`";}" | Out-File -FilePath .\CCodeAI.QuickActions\CCodeAI.QuickActions.CodeFixes\AzureConfig.cs 26 | 27 | # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild 28 | - name: Setup MSBuild.exe 29 | uses: microsoft/setup-msbuild@v1.0.2 30 | 31 | # Restore the application to populate the obj folder with RuntimeIdentifiers 32 | - name: Restore the application 33 | run: msbuild CCodeAI.sln /t:Restore /p:Configuration=Release 34 | 35 | # build release 36 | - name: Build Relase 37 | run: msbuild CCodeAI.sln /p:Configuration=Release 38 | -------------------------------------------------------------------------------- /.github/workflows/PublishExtension.yml: -------------------------------------------------------------------------------- 1 | name: PublishExtension 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | tags: 7 | - '*' 8 | 9 | jobs: 10 | build: 11 | runs-on: windows-latest 12 | 13 | # Steps represent a sequence of tasks that will be executed as part of the job 14 | steps: 15 | 16 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 17 | - uses: actions/checkout@v2 18 | 19 | # Generate Azure OpenAI key 20 | - name: wirte keys 21 | shell: pwsh 22 | run: | 23 | "public static class AzureConfig{public const string Endpoint = `"${{ secrets.ENDPOINT }}`";public const string AppKey = `"${{ secrets.APP_KEY }}`";}" | Out-File -FilePath .\CCodeAI.QuickActions\CCodeAI.QuickActions.CodeFixes\AzureConfig.cs 24 | 25 | # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild 26 | - name: Setup MSBuild.exe 27 | uses: microsoft/setup-msbuild@v1.0.2 28 | 29 | # Restore the application to populate the obj folder with RuntimeIdentifiers 30 | - name: Restore the application 31 | run: msbuild CCodeAI.sln /t:Restore /p:Configuration=Release 32 | 33 | # build release 34 | - name: Build Relase 35 | run: msbuild CCodeAI.sln /p:Configuration=Release 36 | 37 | # Publish 38 | - name: Publish extension to Marketplace 39 | uses: cezarypiatek/VsixPublisherAction@0.1 40 | with: 41 | extension-file: CCodeAI\bin\Release\CCodeAI.vsix 42 | publish-manifest-file: publishManifest.json 43 | personal-access-code: ${{ secrets.VS_PUBLISHER_ACCESS_TOKEN }} -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.CodeFixes/CCodeAI.QuickActions.CodeFixes.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | false 6 | CCodeAI.QuickActions 7 | latest 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.CodeFixes/CCodeAIQuickActionsCodeFixProvider.cs: -------------------------------------------------------------------------------- 1 | //using Microsoft.CodeAnalysis; 2 | //using Microsoft.CodeAnalysis.CodeActions; 3 | //using Microsoft.CodeAnalysis.CodeFixes; 4 | //using Microsoft.CodeAnalysis.CSharp; 5 | //using Microsoft.CodeAnalysis.CSharp.Syntax; 6 | //using Microsoft.CodeAnalysis.Rename; 7 | //using Microsoft.CodeAnalysis.Text; 8 | //using System; 9 | //using System.Collections.Generic; 10 | //using System.Collections.Immutable; 11 | //using System.Composition; 12 | //using System.Linq; 13 | //using System.Threading; 14 | //using System.Threading.Tasks; 15 | 16 | //namespace CCodeAI.QuickActions 17 | //{ 18 | // [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(CCodeAIQuickActionsCodeFixProvider)), Shared] 19 | // public class CCodeAIQuickActionsCodeFixProvider : CodeFixProvider 20 | // { 21 | // public sealed override ImmutableArray FixableDiagnosticIds 22 | // { 23 | // get { return ImmutableArray.Create(CCodeAIQuickActionsAnalyzer.DiagnosticId); } 24 | // } 25 | 26 | // public sealed override FixAllProvider GetFixAllProvider() 27 | // { 28 | // // See https://github.com/dotnet/roslyn/blob/main/docs/analyzers/FixAllProvider.md for more information on Fix All Providers 29 | // return WellKnownFixAllProviders.BatchFixer; 30 | // } 31 | 32 | // public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) 33 | // { 34 | // var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false); 35 | 36 | // // TODO: Replace the following code with your own analysis, generating a CodeAction for each fix to suggest 37 | // var diagnostic = context.Diagnostics.First(); 38 | // var diagnosticSpan = diagnostic.Location.SourceSpan; 39 | 40 | // // Find the type declaration identified by the diagnostic. 41 | // var declaration = root.FindToken(diagnosticSpan.Start).Parent.AncestorsAndSelf().OfType().First(); 42 | 43 | // // Register a code action that will invoke the fix. 44 | // context.RegisterCodeFix( 45 | // CodeAction.Create( 46 | // title: CodeFixResources.CodeFixTitle, 47 | // createChangedSolution: c => MakeUppercaseAsync(context.Document, declaration, c), 48 | // equivalenceKey: nameof(CodeFixResources.CodeFixTitle)), 49 | // diagnostic); 50 | // } 51 | 52 | // private async Task MakeUppercaseAsync(Document document, TypeDeclarationSyntax typeDecl, CancellationToken cancellationToken) 53 | // { 54 | // // Compute new uppercase name. 55 | // var identifierToken = typeDecl.Identifier; 56 | // var newName = identifierToken.Text.ToUpperInvariant(); 57 | 58 | // // Get the symbol representing the type to be renamed. 59 | // var semanticModel = await document.GetSemanticModelAsync(cancellationToken); 60 | // var typeSymbol = semanticModel.GetDeclaredSymbol(typeDecl, cancellationToken); 61 | 62 | // // Produce a new solution that has all references to that type renamed, including the declaration. 63 | // var originalSolution = document.Project.Solution; 64 | // var optionSet = originalSolution.Workspace.Options; 65 | // var newSolution = await Renamer.RenameSymbolAsync(document.Project.Solution, typeSymbol, newName, optionSet, cancellationToken).ConfigureAwait(false); 66 | 67 | // // Return the new solution with the now-uppercase type name. 68 | // return newSolution; 69 | // } 70 | // } 71 | //} 72 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.CodeFixes/CodeFixResources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace CCodeAI.QuickActions { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class CodeFixResources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal CodeFixResources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CCodeAI.QuickActions.CodeFixResources", typeof(CodeFixResources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 重写当前线程的 CurrentUICulture 属性,对 51 | /// 使用此强类型资源类的所有资源查找执行重写。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// 查找类似 Make uppercase 的本地化字符串。 65 | /// 66 | internal static string CodeFixTitle { 67 | get { 68 | return ResourceManager.GetString("CodeFixTitle", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// 查找类似 Use openai to optimize code 的本地化字符串。 74 | /// 75 | internal static string OptimizeCode { 76 | get { 77 | return ResourceManager.GetString("OptimizeCode", resourceCulture); 78 | } 79 | } 80 | 81 | /// 82 | /// 查找类似 Use openai to optimize method 的本地化字符串。 83 | /// 84 | internal static string OptimizeMethodCode { 85 | get { 86 | return ResourceManager.GetString("OptimizeMethodCode", resourceCulture); 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.CodeFixes/CodeFixResources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | Make uppercase 122 | The title of the code fix. 123 | 124 | 125 | Use openai to optimize code 126 | Optimize selected code 127 | 128 | 129 | Use openai to optimize method 130 | 131 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.CodeFixes/CodeFixResources.zh.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | text/microsoft-resx 90 | 91 | 92 | 1.3 93 | 94 | 95 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 96 | 97 | 98 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 99 | 100 | 101 | 使用AI优化此方法 102 | 103 | 104 | 使用AI优化代码 105 | 106 | 107 | 转换为大写 108 | 109 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.CodeFixes/CodeOptimizationCodeFixProvider.cs: -------------------------------------------------------------------------------- 1 | using CCodeAI.QuickActions.Skills; 2 | using Microsoft.CodeAnalysis; 3 | using Microsoft.CodeAnalysis.CodeActions; 4 | using Microsoft.CodeAnalysis.CodeFixes; 5 | using Microsoft.CodeAnalysis.CSharp; 6 | using Microsoft.CodeAnalysis.CSharp.Syntax; 7 | using Microsoft.CodeAnalysis.Editing; 8 | using Microsoft.CodeAnalysis.Rename; 9 | using Microsoft.CodeAnalysis.Text; 10 | using Microsoft.Extensions.Azure; 11 | using System; 12 | using System.Collections.Immutable; 13 | using System.Composition; 14 | using System.Data; 15 | using System.Linq; 16 | using System.Threading; 17 | using System.Threading.Tasks; 18 | 19 | namespace CCodeAI.QuickActions; 20 | 21 | [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(CodeOptimizationCodeFixProvider)), Shared] 22 | public class CodeOptimizationCodeFixProvider : CodeFixProvider 23 | { 24 | public sealed override ImmutableArray FixableDiagnosticIds 25 | { 26 | get { return ImmutableArray.Create(CodeOptimizationAnalyzer.DiagnosticId); } 27 | } 28 | 29 | public sealed override FixAllProvider GetFixAllProvider() 30 | { 31 | // See https://github.com/dotnet/roslyn/blob/main/docs/analyzers/FixAllProvider.md for more information on Fix All Providers 32 | return WellKnownFixAllProviders.BatchFixer; 33 | } 34 | 35 | public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) 36 | { 37 | var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false); 38 | 39 | var diagnostic = context.Diagnostics.First(); 40 | var diagnosticSpan = diagnostic.Location.SourceSpan; 41 | 42 | if(context.Span.Length > 0) 43 | { 44 | var action = CodeAction.Create( 45 | title: CodeFixResources.OptimizeCode, 46 | createChangedDocument: c => OptimizeCode(context.Document, diagnosticSpan, c), 47 | equivalenceKey: nameof(CodeFixResources.OptimizeCode) 48 | ); 49 | 50 | context.RegisterCodeFix( 51 | action, 52 | diagnostic); 53 | } 54 | else 55 | { 56 | //Optimize Method or class 57 | } 58 | } 59 | 60 | private async Task OptimizeCode( 61 | Document document, 62 | TextSpan diagnosticSpan, 63 | CancellationToken cancellationToken) 64 | { 65 | var sourceText = await document.GetTextAsync(); 66 | var selectedText = sourceText.GetSubText(diagnosticSpan); 67 | 68 | var resultCode = await KernelFactory.InvokeCodeFunctionAsync( 69 | CodeOptimizationSemanticFunction.CodeOptimize, 70 | selectedText.ToString(), 71 | cancellationToken); 72 | 73 | return document.WithText(sourceText.Replace(diagnosticSpan, resultCode)); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.CodeFixes/KernelFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.SemanticKernel; 2 | using Microsoft.SemanticKernel.Memory; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | public class KernelFactory 7 | { 8 | public static bool UseAzureOpenAI { get; } = true; 9 | 10 | public static IKernel SKernel { get; private set; } 11 | 12 | public static void Init() 13 | { 14 | if (SKernel != null) 15 | { 16 | return; 17 | } 18 | 19 | SKernel = Kernel.Builder.Configure(c => 20 | { 21 | if (UseAzureOpenAI) 22 | { 23 | //c.AddAzureTextCompletionService( 24 | // "ccode", 25 | // "text-davinci-003", 26 | // AzureConfig.Endpoint, 27 | // AzureConfig.AppKey 28 | // ); 29 | c.AddAzureChatCompletionService( 30 | "ccode", 31 | "gpt-35-turbo", 32 | AzureConfig.Endpoint, 33 | AzureConfig.AppKey, 34 | true); 35 | c.AddAzureTextEmbeddingGenerationService 36 | ( 37 | "ada", 38 | "text-embedding-ada-002", 39 | AzureConfig.Endpoint, 40 | AzureConfig.AppKey 41 | ); 42 | } 43 | else 44 | { 45 | //c.AddOpenAITextCompletionService( 46 | // "ccode", 47 | // OpenAIConfig.Model, 48 | // OpenAIConfig.OpenAIKey 49 | // ); 50 | } 51 | }) 52 | .WithMemoryStorage(new VolatileMemoryStore()) 53 | .Build(); 54 | } 55 | 56 | public static async Task InvokeCodeFunctionAsync( 57 | string semanticFunction, 58 | string code, 59 | CancellationToken? cancellationToken = null, 60 | string extension = "csharp") 61 | { 62 | Init(); 63 | 64 | var explainFunc = SKernel.CreateSemanticFunction(semanticFunction); 65 | 66 | var context = SKernel.CreateNewContext(); 67 | context.Variables["extension"] = extension; 68 | 69 | var result = await explainFunc.InvokeAsync(code, context,cancel:cancellationToken); 70 | 71 | if (result.ErrorOccurred) 72 | { 73 | throw result.LastException; 74 | } 75 | 76 | return result.ToString().Trim(); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.Package/CCodeAI.QuickActions.Package.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | false 6 | true 7 | true 8 | 9 | 10 | 11 | CCodeAI.QuickActions 12 | 1.0.0.0 13 | WeiGan 14 | http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE 15 | http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE 16 | http://ICON_URL_HERE_OR_DELETE_THIS_LINE 17 | http://REPOSITORY_URL_HERE_OR_DELETE_THIS_LINE 18 | false 19 | CCodeAI.QuickActions 20 | Summary of changes made in this release of the package. 21 | Copyright 22 | CCodeAI.QuickActions, analyzers 23 | true 24 | true 25 | 26 | $(TargetsForTfmSpecificContentInPackage);_AddAnalyzersToOutput 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.Test/CCodeAI.QuickActions.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | true 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.Test/CCodeAIQuickActionsUnitTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using System.Threading.Tasks; 3 | using VerifyCS = CCodeAI.QuickActions.Test.CSharpCodeFixVerifier< 4 | CCodeAI.QuickActions.CodeOptimizationAnalyzer, 5 | CCodeAI.QuickActions.CodeOptimizationCodeFixProvider>; 6 | 7 | namespace CCodeAI.QuickActions.Test 8 | { 9 | [TestClass] 10 | public class CCodeAIQuickActionsUnitTest 11 | { 12 | //No diagnostics expected to show up 13 | [TestMethod] 14 | public async Task TestMethod1() 15 | { 16 | var test = @""; 17 | 18 | await VerifyCS.VerifyAnalyzerAsync(test); 19 | } 20 | 21 | //Diagnostic and CodeFix both triggered and checked for 22 | [TestMethod] 23 | public async Task TestMethod2() 24 | { 25 | var test = @" 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Text; 30 | using System.Threading.Tasks; 31 | using System.Diagnostics; 32 | 33 | namespace ConsoleApplication1 34 | { 35 | class {|#0:TypeName|} 36 | { 37 | } 38 | }"; 39 | 40 | var fixtest = @" 41 | using System; 42 | using System.Collections.Generic; 43 | using System.Linq; 44 | using System.Text; 45 | using System.Threading.Tasks; 46 | using System.Diagnostics; 47 | 48 | namespace ConsoleApplication1 49 | { 50 | class TYPENAME 51 | { 52 | } 53 | }"; 54 | 55 | var expected = VerifyCS.Diagnostic("CodeOptimization").WithLocation(0).WithArguments("TypeName"); 56 | await VerifyCS.VerifyCodeFixAsync(test, expected, fixtest); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.Test/Verifiers/CSharpAnalyzerVerifier`1+Test.cs: -------------------------------------------------------------------------------- 1 | using CCodeAI.QuickActions.Test.Verifiers; 2 | using Microsoft.CodeAnalysis.CSharp.Testing; 3 | using Microsoft.CodeAnalysis.Diagnostics; 4 | using Microsoft.CodeAnalysis.Testing.Verifiers; 5 | 6 | namespace CCodeAI.QuickActions.Test 7 | { 8 | public static partial class CSharpAnalyzerVerifier 9 | where TAnalyzer : DiagnosticAnalyzer, new() 10 | { 11 | public class Test : CSharpAnalyzerTest 12 | { 13 | public Test() 14 | { 15 | SolutionTransforms.Add((solution, projectId) => 16 | { 17 | var compilationOptions = solution.GetProject(projectId).CompilationOptions; 18 | compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( 19 | compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); 20 | solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); 21 | 22 | return solution; 23 | }); 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.Test/Verifiers/CSharpAnalyzerVerifier`1.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis; 2 | using Microsoft.CodeAnalysis.CSharp.Testing; 3 | using Microsoft.CodeAnalysis.Diagnostics; 4 | using Microsoft.CodeAnalysis.Testing; 5 | using Microsoft.CodeAnalysis.Testing.Verifiers; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | namespace CCodeAI.QuickActions.Test 10 | { 11 | public static partial class CSharpAnalyzerVerifier 12 | where TAnalyzer : DiagnosticAnalyzer, new() 13 | { 14 | /// 15 | public static DiagnosticResult Diagnostic() 16 | => CSharpAnalyzerVerifier.Diagnostic(); 17 | 18 | /// 19 | public static DiagnosticResult Diagnostic(string diagnosticId) 20 | => CSharpAnalyzerVerifier.Diagnostic(diagnosticId); 21 | 22 | /// 23 | public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) 24 | => CSharpAnalyzerVerifier.Diagnostic(descriptor); 25 | 26 | /// 27 | public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) 28 | { 29 | var test = new Test 30 | { 31 | TestCode = source, 32 | }; 33 | 34 | test.ExpectedDiagnostics.AddRange(expected); 35 | await test.RunAsync(CancellationToken.None); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.Test/Verifiers/CSharpCodeFixVerifier`2+Test.cs: -------------------------------------------------------------------------------- 1 | using CCodeAI.QuickActions.Test.Verifiers; 2 | using Microsoft.CodeAnalysis.CodeFixes; 3 | using Microsoft.CodeAnalysis.CSharp.Testing; 4 | using Microsoft.CodeAnalysis.Diagnostics; 5 | using Microsoft.CodeAnalysis.Testing.Verifiers; 6 | 7 | namespace CCodeAI.QuickActions.Test 8 | { 9 | public static partial class CSharpCodeFixVerifier 10 | where TAnalyzer : DiagnosticAnalyzer, new() 11 | where TCodeFix : CodeFixProvider, new() 12 | { 13 | public class Test : CSharpCodeFixTest 14 | { 15 | public Test() 16 | { 17 | SolutionTransforms.Add((solution, projectId) => 18 | { 19 | var compilationOptions = solution.GetProject(projectId).CompilationOptions; 20 | compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( 21 | compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); 22 | solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); 23 | 24 | return solution; 25 | }); 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.Test/Verifiers/CSharpCodeFixVerifier`2.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis; 2 | using Microsoft.CodeAnalysis.CodeFixes; 3 | using Microsoft.CodeAnalysis.CSharp.Testing; 4 | using Microsoft.CodeAnalysis.Diagnostics; 5 | using Microsoft.CodeAnalysis.Testing; 6 | using Microsoft.CodeAnalysis.Testing.Verifiers; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | 10 | namespace CCodeAI.QuickActions.Test 11 | { 12 | public static partial class CSharpCodeFixVerifier 13 | where TAnalyzer : DiagnosticAnalyzer, new() 14 | where TCodeFix : CodeFixProvider, new() 15 | { 16 | /// 17 | public static DiagnosticResult Diagnostic() 18 | => CSharpCodeFixVerifier.Diagnostic(); 19 | 20 | /// 21 | public static DiagnosticResult Diagnostic(string diagnosticId) 22 | => CSharpCodeFixVerifier.Diagnostic(diagnosticId); 23 | 24 | /// 25 | public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) 26 | => CSharpCodeFixVerifier.Diagnostic(descriptor); 27 | 28 | /// 29 | public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) 30 | { 31 | var test = new Test 32 | { 33 | TestCode = source, 34 | }; 35 | 36 | test.ExpectedDiagnostics.AddRange(expected); 37 | await test.RunAsync(CancellationToken.None); 38 | } 39 | 40 | /// 41 | public static async Task VerifyCodeFixAsync(string source, string fixedSource) 42 | => await VerifyCodeFixAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource); 43 | 44 | /// 45 | public static async Task VerifyCodeFixAsync(string source, DiagnosticResult expected, string fixedSource) 46 | => await VerifyCodeFixAsync(source, new[] { expected }, fixedSource); 47 | 48 | /// 49 | public static async Task VerifyCodeFixAsync(string source, DiagnosticResult[] expected, string fixedSource) 50 | { 51 | var test = new Test 52 | { 53 | TestCode = source, 54 | FixedCode = fixedSource, 55 | }; 56 | 57 | test.ExpectedDiagnostics.AddRange(expected); 58 | await test.RunAsync(CancellationToken.None); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.Test/Verifiers/CSharpCodeRefactoringVerifier`1+Test.cs: -------------------------------------------------------------------------------- 1 | using CCodeAI.QuickActions.Test.Verifiers; 2 | using Microsoft.CodeAnalysis.CodeRefactorings; 3 | using Microsoft.CodeAnalysis.CSharp.Testing; 4 | using Microsoft.CodeAnalysis.Testing.Verifiers; 5 | 6 | namespace CCodeAI.QuickActions.Test 7 | { 8 | public static partial class CSharpCodeRefactoringVerifier 9 | where TCodeRefactoring : CodeRefactoringProvider, new() 10 | { 11 | public class Test : CSharpCodeRefactoringTest 12 | { 13 | public Test() 14 | { 15 | SolutionTransforms.Add((solution, projectId) => 16 | { 17 | var compilationOptions = solution.GetProject(projectId).CompilationOptions; 18 | compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( 19 | compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); 20 | solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); 21 | 22 | return solution; 23 | }); 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.Test/Verifiers/CSharpCodeRefactoringVerifier`1.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis.CodeRefactorings; 2 | using Microsoft.CodeAnalysis.Testing; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | namespace CCodeAI.QuickActions.Test 7 | { 8 | public static partial class CSharpCodeRefactoringVerifier 9 | where TCodeRefactoring : CodeRefactoringProvider, new() 10 | { 11 | /// 12 | public static async Task VerifyRefactoringAsync(string source, string fixedSource) 13 | { 14 | await VerifyRefactoringAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource); 15 | } 16 | 17 | /// 18 | public static async Task VerifyRefactoringAsync(string source, DiagnosticResult expected, string fixedSource) 19 | { 20 | await VerifyRefactoringAsync(source, new[] { expected }, fixedSource); 21 | } 22 | 23 | /// 24 | public static async Task VerifyRefactoringAsync(string source, DiagnosticResult[] expected, string fixedSource) 25 | { 26 | var test = new Test 27 | { 28 | TestCode = source, 29 | FixedCode = fixedSource, 30 | }; 31 | 32 | test.ExpectedDiagnostics.AddRange(expected); 33 | await test.RunAsync(CancellationToken.None); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.Test/Verifiers/CSharpVerifierHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis; 2 | using Microsoft.CodeAnalysis.CSharp; 3 | using System; 4 | using System.Collections.Immutable; 5 | 6 | namespace CCodeAI.QuickActions.Test.Verifiers 7 | { 8 | internal static class CSharpVerifierHelper 9 | { 10 | /// 11 | /// By default, the compiler reports diagnostics for nullable reference types at 12 | /// , and the analyzer test framework defaults to only validating 13 | /// diagnostics at . This map contains all compiler diagnostic IDs 14 | /// related to nullability mapped to , which is then used to enable all 15 | /// of these warnings for default validation during analyzer and code fix tests. 16 | /// 17 | internal static ImmutableDictionary NullableWarnings { get; } = GetNullableWarningsFromCompiler(); 18 | 19 | private static ImmutableDictionary GetNullableWarningsFromCompiler() 20 | { 21 | string[] args = { "/warnaserror:nullable" }; 22 | var commandLineArguments = CSharpCommandLineParser.Default.Parse(args, baseDirectory: Environment.CurrentDirectory, sdkDirectory: Environment.CurrentDirectory); 23 | var nullableWarnings = commandLineArguments.CompilationOptions.SpecificDiagnosticOptions; 24 | 25 | // Workaround for https://github.com/dotnet/roslyn/issues/41610 26 | nullableWarnings = nullableWarnings 27 | .SetItem("CS8632", ReportDiagnostic.Error) 28 | .SetItem("CS8669", ReportDiagnostic.Error); 29 | 30 | return nullableWarnings; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.Test/Verifiers/VisualBasicAnalyzerVerifier`1+Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis.Diagnostics; 2 | using Microsoft.CodeAnalysis.Testing.Verifiers; 3 | using Microsoft.CodeAnalysis.VisualBasic.Testing; 4 | 5 | namespace CCodeAI.QuickActions.Test 6 | { 7 | public static partial class VisualBasicAnalyzerVerifier 8 | where TAnalyzer : DiagnosticAnalyzer, new() 9 | { 10 | public class Test : VisualBasicAnalyzerTest 11 | { 12 | public Test() 13 | { 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.Test/Verifiers/VisualBasicAnalyzerVerifier`1.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis; 2 | using Microsoft.CodeAnalysis.Diagnostics; 3 | using Microsoft.CodeAnalysis.Testing; 4 | using Microsoft.CodeAnalysis.Testing.Verifiers; 5 | using Microsoft.CodeAnalysis.VisualBasic.Testing; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | namespace CCodeAI.QuickActions.Test 10 | { 11 | public static partial class VisualBasicAnalyzerVerifier 12 | where TAnalyzer : DiagnosticAnalyzer, new() 13 | { 14 | /// 15 | public static DiagnosticResult Diagnostic() 16 | => VisualBasicAnalyzerVerifier.Diagnostic(); 17 | 18 | /// 19 | public static DiagnosticResult Diagnostic(string diagnosticId) 20 | => VisualBasicAnalyzerVerifier.Diagnostic(diagnosticId); 21 | 22 | /// 23 | public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) 24 | => VisualBasicAnalyzerVerifier.Diagnostic(descriptor); 25 | 26 | /// 27 | public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) 28 | { 29 | var test = new Test 30 | { 31 | TestCode = source, 32 | }; 33 | 34 | test.ExpectedDiagnostics.AddRange(expected); 35 | await test.RunAsync(CancellationToken.None); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.Test/Verifiers/VisualBasicCodeFixVerifier`2+Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis.CodeFixes; 2 | using Microsoft.CodeAnalysis.Diagnostics; 3 | using Microsoft.CodeAnalysis.Testing.Verifiers; 4 | using Microsoft.CodeAnalysis.VisualBasic.Testing; 5 | 6 | namespace CCodeAI.QuickActions.Test 7 | { 8 | public static partial class VisualBasicCodeFixVerifier 9 | where TAnalyzer : DiagnosticAnalyzer, new() 10 | where TCodeFix : CodeFixProvider, new() 11 | { 12 | public class Test : VisualBasicCodeFixTest 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.Test/Verifiers/VisualBasicCodeFixVerifier`2.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis; 2 | using Microsoft.CodeAnalysis.CodeFixes; 3 | using Microsoft.CodeAnalysis.Diagnostics; 4 | using Microsoft.CodeAnalysis.Testing; 5 | using Microsoft.CodeAnalysis.Testing.Verifiers; 6 | using Microsoft.CodeAnalysis.VisualBasic.Testing; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | 10 | namespace CCodeAI.QuickActions.Test 11 | { 12 | public static partial class VisualBasicCodeFixVerifier 13 | where TAnalyzer : DiagnosticAnalyzer, new() 14 | where TCodeFix : CodeFixProvider, new() 15 | { 16 | /// 17 | public static DiagnosticResult Diagnostic() 18 | => VisualBasicCodeFixVerifier.Diagnostic(); 19 | 20 | /// 21 | public static DiagnosticResult Diagnostic(string diagnosticId) 22 | => VisualBasicCodeFixVerifier.Diagnostic(diagnosticId); 23 | 24 | /// 25 | public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) 26 | => VisualBasicCodeFixVerifier.Diagnostic(descriptor); 27 | 28 | /// 29 | public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) 30 | { 31 | var test = new Test 32 | { 33 | TestCode = source, 34 | }; 35 | 36 | test.ExpectedDiagnostics.AddRange(expected); 37 | await test.RunAsync(CancellationToken.None); 38 | } 39 | 40 | /// 41 | public static async Task VerifyCodeFixAsync(string source, string fixedSource) 42 | => await VerifyCodeFixAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource); 43 | 44 | /// 45 | public static async Task VerifyCodeFixAsync(string source, DiagnosticResult expected, string fixedSource) 46 | => await VerifyCodeFixAsync(source, new[] { expected }, fixedSource); 47 | 48 | /// 49 | public static async Task VerifyCodeFixAsync(string source, DiagnosticResult[] expected, string fixedSource) 50 | { 51 | var test = new Test 52 | { 53 | TestCode = source, 54 | FixedCode = fixedSource, 55 | }; 56 | 57 | test.ExpectedDiagnostics.AddRange(expected); 58 | await test.RunAsync(CancellationToken.None); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.Test/Verifiers/VisualBasicCodeRefactoringVerifier`1+Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis.CodeRefactorings; 2 | using Microsoft.CodeAnalysis.Testing.Verifiers; 3 | using Microsoft.CodeAnalysis.VisualBasic.Testing; 4 | 5 | namespace CCodeAI.QuickActions.Test 6 | { 7 | public static partial class VisualBasicCodeRefactoringVerifier 8 | where TCodeRefactoring : CodeRefactoringProvider, new() 9 | { 10 | public class Test : VisualBasicCodeRefactoringTest 11 | { 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions.Test/Verifiers/VisualBasicCodeRefactoringVerifier`1.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis.CodeRefactorings; 2 | using Microsoft.CodeAnalysis.Testing; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | namespace CCodeAI.QuickActions.Test 7 | { 8 | public static partial class VisualBasicCodeRefactoringVerifier 9 | where TCodeRefactoring : CodeRefactoringProvider, new() 10 | { 11 | /// 12 | public static async Task VerifyRefactoringAsync(string source, string fixedSource) 13 | { 14 | await VerifyRefactoringAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource); 15 | } 16 | 17 | /// 18 | public static async Task VerifyRefactoringAsync(string source, DiagnosticResult expected, string fixedSource) 19 | { 20 | await VerifyRefactoringAsync(source, new[] { expected }, fixedSource); 21 | } 22 | 23 | /// 24 | public static async Task VerifyRefactoringAsync(string source, DiagnosticResult[] expected, string fixedSource) 25 | { 26 | var test = new Test 27 | { 28 | TestCode = source, 29 | FixedCode = fixedSource, 30 | }; 31 | 32 | test.ExpectedDiagnostics.AddRange(expected); 33 | await test.RunAsync(CancellationToken.None); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/CCodeAI.QuickActions.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | false 6 | true 7 | 8 | *$(MSBuildProjectFile)* 9 | latest 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | PreserveNewest 24 | 25 | 26 | PreserveNewest 27 | 28 | 29 | PreserveNewest 30 | 31 | 32 | PreserveNewest 33 | 34 | 35 | PreserveNewest 36 | 37 | 38 | PreserveNewest 39 | 40 | 41 | 42 | 43 | 44 | all 45 | runtime; build; native; contentfiles; analyzers; buildtransitive 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | PreserveNewest 58 | 59 | 60 | PreserveNewest 61 | 62 | 63 | PreserveNewest 64 | 65 | 66 | PreserveNewest 67 | 68 | 69 | PreserveNewest 70 | 71 | 72 | PreserveNewest 73 | 74 | 75 | PreserveNewest 76 | 77 | 78 | PreserveNewest 79 | 80 | 81 | PreserveNewest 82 | 83 | 84 | PreserveNewest 85 | 86 | 87 | PreserveNewest 88 | 89 | 90 | PreserveNewest 91 | 92 | 93 | PreserveNewest 94 | 95 | 96 | PreserveNewest 97 | 98 | 99 | PreserveNewest 100 | 101 | 102 | PreserveNewest 103 | 104 | 105 | PreserveNewest 106 | 107 | 108 | PreserveNewest 109 | 110 | 111 | PreserveNewest 112 | 113 | 114 | PreserveNewest 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/CCodeAIQuickActionsAnalyzer.cs: -------------------------------------------------------------------------------- 1 | //using Microsoft.CodeAnalysis; 2 | //using Microsoft.CodeAnalysis.CSharp; 3 | //using Microsoft.CodeAnalysis.CSharp.Syntax; 4 | //using Microsoft.CodeAnalysis.Diagnostics; 5 | //using System; 6 | //using System.Collections.Generic; 7 | //using System.Collections.Immutable; 8 | //using System.Linq; 9 | //using System.Threading; 10 | 11 | //namespace CCodeAI.QuickActions 12 | //{ 13 | // [DiagnosticAnalyzer(LanguageNames.CSharp)] 14 | // public class CCodeAIQuickActionsAnalyzer : DiagnosticAnalyzer 15 | // { 16 | // public const string DiagnosticId = "CCodeAIQuickActions"; 17 | 18 | // // You can change these strings in the Resources.resx file. If you do not want your analyzer to be localize-able, you can use regular strings for Title and MessageFormat. 19 | // // See https://github.com/dotnet/roslyn/blob/main/docs/analyzers/Localizing%20Analyzers.md for more on localization 20 | // private static readonly LocalizableString Title = new LocalizableResourceString(nameof(Resources.AnalyzerTitle), Resources.ResourceManager, typeof(Resources)); 21 | // private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(Resources.AnalyzerMessageFormat), Resources.ResourceManager, typeof(Resources)); 22 | // private static readonly LocalizableString Description = new LocalizableResourceString(nameof(Resources.AnalyzerDescription), Resources.ResourceManager, typeof(Resources)); 23 | // private const string Category = "Naming"; 24 | 25 | // private static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, Category, DiagnosticSeverity.Warning, isEnabledByDefault: true, description: Description); 26 | 27 | // public override ImmutableArray SupportedDiagnostics { get { return ImmutableArray.Create(Rule); } } 28 | 29 | // public override void Initialize(AnalysisContext context) 30 | // { 31 | // context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); 32 | // context.EnableConcurrentExecution(); 33 | 34 | // // TODO: Consider registering other actions that act on syntax instead of or in addition to symbols 35 | // // See https://github.com/dotnet/roslyn/blob/main/docs/analyzers/Analyzer%20Actions%20Semantics.md for more information 36 | // context.RegisterSymbolAction(AnalyzeSymbol, SymbolKind.NamedType); 37 | // } 38 | 39 | // private static void AnalyzeSymbol(SymbolAnalysisContext context) 40 | // { 41 | // // TODO: Replace the following code with your own analysis, generating Diagnostic objects for any issues you find 42 | // var namedTypeSymbol = (INamedTypeSymbol)context.Symbol; 43 | 44 | // // Find just those named type symbols with names containing lowercase letters. 45 | // if (namedTypeSymbol.Name.ToCharArray().Any(char.IsLower)) 46 | // { 47 | // // For all such symbols, produce a diagnostic. 48 | // var diagnostic = Diagnostic.Create(Rule, namedTypeSymbol.Locations[0], namedTypeSymbol.Name); 49 | 50 | // context.ReportDiagnostic(diagnostic); 51 | // } 52 | // } 53 | // } 54 | //} 55 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/CCodeAISkills/ChatSkill/Chat/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": 1, 3 | "description": "Chat with the AI", 4 | "type": "completion", 5 | "completion": { 6 | "max_tokens": 2000, 7 | "temperature": 0.9, 8 | "top_p": 0.0, 9 | "presence_penalty": 0.6, 10 | "frequency_penalty": 0.0, 11 | "stop_sequences": [ 12 | "Me:", 13 | "AI:" 14 | ] 15 | } 16 | } -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/CCodeAISkills/ChatSkill/Chat/skprompt.txt: -------------------------------------------------------------------------------- 1 | From now on act as an expert coder, with years of coding experience. 2 | You need to provide accurate and clear answers to the following types of questions. If the question is beyond this scope, you need to remind the user. 3 | 4 | QuestionTypes: 5 | 1.Explain Code. 6 | 2.How to use VS(Visual Studio). 7 | 3.Wirte or generate code. 8 | 4.Fix code or find bugs. 9 | 5 Wirte unit test. 10 | 11 | {Respond in {{$culture}} and markdown format.} -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/CCodeAISkills/CoreSkill/Comment/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": 1, 3 | "description": "Chat with the AI", 4 | "type": "completion", 5 | "completion": { 6 | "max_tokens": 2000, 7 | "temperature": 0.9, 8 | "top_p": 0.0, 9 | "presence_penalty": 0.6, 10 | "frequency_penalty": 0.0, 11 | "stop_sequences": [ 12 | "Me:", 13 | "AI:" 14 | ] 15 | } 16 | } -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/CCodeAISkills/CoreSkill/Comment/skprompt.txt: -------------------------------------------------------------------------------- 1 | ```{{$extension}} 2 | {{$input}} 3 | ``` 4 | Add comments to each line of code: 5 | 6 | {Respond in {{$culture}} and markdown format.} -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/CCodeAISkills/CoreSkill/Explain/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": 1, 3 | "description": "Chat with the AI", 4 | "type": "completion", 5 | "completion": { 6 | "max_tokens": 2000, 7 | "temperature": 0.9, 8 | "top_p": 0.0, 9 | "presence_penalty": 0.6, 10 | "frequency_penalty": 0.0, 11 | "stop_sequences": [ 12 | "Me:", 13 | "AI:" 14 | ] 15 | } 16 | } -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/CCodeAISkills/CoreSkill/Explain/skprompt.txt: -------------------------------------------------------------------------------- 1 | I would like you to serve as a code interpreter with Chinese, and elucidate the syntax and the semantics of the code step-by-step. 2 | 3 | {Respond in {{$culture}} and markdown format.} 4 | 5 | ```{{$extension}} 6 | {{$input}} 7 | ``` -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/CCodeAISkills/CoreSkill/Optimize/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": 1, 3 | "description": "Chat with the AI", 4 | "type": "completion", 5 | "completion": { 6 | "max_tokens": 2000, 7 | "temperature": 0.9, 8 | "top_p": 0.0, 9 | "presence_penalty": 0.6, 10 | "frequency_penalty": 0.0, 11 | "stop_sequences": [ 12 | "Me:", 13 | "AI:" 14 | ] 15 | } 16 | } -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/CCodeAISkills/CoreSkill/Optimize/skprompt.txt: -------------------------------------------------------------------------------- 1 | ```{{$extension}} 2 | {{$input}} 3 | ``` 4 | Optimize the code: 5 | 6 | {Respond in {{$culture}} and markdown format.} -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/CCodeAISkills/CoreSkill/UnitTest/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": 1, 3 | "description": "Chat with the AI", 4 | "type": "completion", 5 | "completion": { 6 | "max_tokens": 2000, 7 | "temperature": 0.9, 8 | "top_p": 0.0, 9 | "presence_penalty": 0.6, 10 | "frequency_penalty": 0.0, 11 | "stop_sequences": [ 12 | "Me:", 13 | "AI:" 14 | ] 15 | } 16 | } -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/CCodeAISkills/CoreSkill/UnitTest/skprompt.txt: -------------------------------------------------------------------------------- 1 | ```{{$extension}} 2 | {{$input}} 3 | ``` 4 | Generate a unittest: -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/CCodeAISkills/CoreSkill/WirteCode/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": 1, 3 | "description": "Chat with the AI", 4 | "type": "completion", 5 | "completion": { 6 | "max_tokens": 2000, 7 | "temperature": 0.9, 8 | "top_p": 0.0, 9 | "presence_penalty": 0.6, 10 | "frequency_penalty": 0.0, 11 | "stop_sequences": [ 12 | "Me:", 13 | "AI:" 14 | ] 15 | } 16 | } -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/CCodeAISkills/CoreSkill/WirteCode/skprompt.txt: -------------------------------------------------------------------------------- 1 | ```{{$extension}} 2 | {{$input}} 3 | ``` 4 | Complete the code based on the comments, and only return the added code, excluding any other content: -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/CodeOptimizationAnalyzer.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis; 2 | using Microsoft.CodeAnalysis.CSharp; 3 | using Microsoft.CodeAnalysis.Diagnostics; 4 | using System; 5 | using System.Collections.Immutable; 6 | using System.Linq; 7 | 8 | namespace CCodeAI.QuickActions; 9 | 10 | [DiagnosticAnalyzer(LanguageNames.CSharp)] 11 | public class CodeOptimizationAnalyzer : DiagnosticAnalyzer 12 | { 13 | public const string DiagnosticId = "CodeOptimization"; 14 | 15 | private static readonly LocalizableString Title = new LocalizableResourceString( 16 | nameof(Resources.CodeOptimizationAnalyzerTitle), 17 | Resources.ResourceManager, 18 | typeof(Resources)); 19 | 20 | private static readonly LocalizableString MessageFormat = new LocalizableResourceString( 21 | nameof(Resources.CodeOptimizationAnalyzerMessageFormat), 22 | Resources.ResourceManager, 23 | typeof(Resources)); 24 | 25 | private static readonly LocalizableString Description = new LocalizableResourceString( 26 | nameof(Resources.CodeOptimizationAnalyzerDescription), 27 | Resources.ResourceManager, 28 | typeof(Resources)); 29 | 30 | private const string Category = "CodeOptimization"; 31 | 32 | private static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor( 33 | DiagnosticId, 34 | Title, 35 | MessageFormat, 36 | Category, 37 | DiagnosticSeverity.Info, 38 | isEnabledByDefault: true, 39 | description: Description); 40 | 41 | public override ImmutableArray SupportedDiagnostics 42 | { 43 | get { return ImmutableArray.Create(Rule); } 44 | } 45 | 46 | public override void Initialize(AnalysisContext context) 47 | { 48 | context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); 49 | context.EnableConcurrentExecution(); 50 | 51 | // TODO: Consider registering other actions that act on syntax instead of or in addition to symbols 52 | // See https://github.com/dotnet/roslyn/blob/main/docs/analyzers/Analyzer%20Actions%20Semantics.md for more information 53 | context.RegisterCodeBlockAction(AnalyzeCodeBlock); 54 | 55 | //context.RegisterOperationBlockAction(AnalyzeOperationBlock); 56 | } 57 | 58 | private void AnalyzeOperationBlock(OperationBlockAnalysisContext context) 59 | { 60 | var diagnostic = Diagnostic.Create( 61 | Rule, 62 | context.OperationBlocks.First().Syntax.GetLocation(), 63 | Title); 64 | 65 | context.ReportDiagnostic(diagnostic); 66 | } 67 | 68 | private void AnalyzeCodeBlock(CodeBlockAnalysisContext context) 69 | { 70 | var diagnostic = Diagnostic.Create( 71 | Rule, 72 | context.CodeBlock.GetLocation(), 73 | Title); 74 | 75 | context.ReportDiagnostic(diagnostic); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/ISkillsProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | public interface ISkillsProvider 4 | { 5 | /// 6 | /// default directory which save skills 7 | /// 8 | string SkillsLocation { get; } 9 | 10 | IEnumerable GetSkills(); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/LocalSemanticFunctionModel.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | /// 3 | /// 本地语义函数 4 | /// 5 | public class LocalSemanticFunctionModel 6 | { 7 | public LocalSemanticFunctionModel( 8 | string pathName, 9 | string category, 10 | string skillDir) 11 | { 12 | PathName = pathName; 13 | Category = category; 14 | SkillDir = skillDir; 15 | Name = new DirectoryInfo(Path.GetDirectoryName(pathName)).Name; 16 | } 17 | 18 | #region Properties 19 | /// 20 | /// Function Name 21 | /// 22 | public string Name { get; } 23 | 24 | /// 25 | /// PathName 26 | /// 27 | public string PathName { get; } 28 | 29 | /// 30 | /// Function Description 31 | /// 32 | public string Description { get; } 33 | 34 | /// 35 | /// Skill Name 36 | /// 37 | public string Category { get; } 38 | 39 | /// 40 | /// Skill dir 41 | /// 42 | public string SkillDir { get; } 43 | 44 | public string RootDir => Directory.GetParent(SkillDir).FullName; 45 | 46 | /// 47 | /// Semantic function Content 48 | /// 49 | public string SemanticString => File.ReadAllText(PathName); 50 | #endregion 51 | 52 | public override string ToString() => Name; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace CCodeAI.QuickActions { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CCodeAI.QuickActions.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 重写当前线程的 CurrentUICulture 属性,对 51 | /// 使用此强类型资源类的所有资源查找执行重写。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// 查找类似 Use openai to optimize Code 的本地化字符串。 65 | /// 66 | internal static string CodeOptimizationAnalyzerDescription { 67 | get { 68 | return ResourceManager.GetString("CodeOptimizationAnalyzerDescription", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// 查找类似 Optimize '{0}' 的本地化字符串。 74 | /// 75 | internal static string CodeOptimizationAnalyzerMessageFormat { 76 | get { 77 | return ResourceManager.GetString("CodeOptimizationAnalyzerMessageFormat", resourceCulture); 78 | } 79 | } 80 | 81 | /// 82 | /// 查找类似 Use openAI to optimize your code 的本地化字符串。 83 | /// 84 | internal static string CodeOptimizationAnalyzerTitle { 85 | get { 86 | return ResourceManager.GetString("CodeOptimizationAnalyzerTitle", resourceCulture); 87 | } 88 | } 89 | 90 | /// 91 | /// 查找类似 Optimize this method. 的本地化字符串。 92 | /// 93 | internal static string CodeOptimizationMethodDescription { 94 | get { 95 | return ResourceManager.GetString("CodeOptimizationMethodDescription", resourceCulture); 96 | } 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Resources.zh.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | text/microsoft-resx 90 | 91 | 92 | 1.3 93 | 94 | 95 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 96 | 97 | 98 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 99 | 100 | 101 | 使用AI来优化代码 102 | 103 | 104 | 优化 '{0}' 105 | 106 | 107 | 使用AI来优化你的代码 108 | 109 | 110 | 优化这个方法 111 | 112 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/SkillModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using System.Linq; 4 | 5 | public class SkillModel 6 | { 7 | /// 8 | /// Create a skill model for ui present 9 | /// 10 | /// propmpt file pathName 11 | public SkillModel(string skillDir) 12 | { 13 | SkillDir = skillDir; 14 | Name = new DirectoryInfo(skillDir).Name; 15 | 16 | var files = Directory.GetFiles(skillDir, "*.txt", SearchOption.AllDirectories) 17 | .Where(f => Path.GetFileNameWithoutExtension(f).EndsWith("skprompt")); 18 | 19 | SemanticFunctions = files 20 | .Select(p => new LocalSemanticFunctionModel(p, Name, skillDir)) 21 | .ToList(); 22 | } 23 | 24 | #region Properties 25 | public List SemanticFunctions { get; } 26 | 27 | /// 28 | /// Skill Name 29 | /// 30 | public string Name { get; } 31 | 32 | /// 33 | /// Skill PathName 34 | /// 35 | public string SkillDir { get; } 36 | 37 | /// 38 | /// index when loop 39 | /// 40 | public int Index { get; internal set; } 41 | #endregion 42 | 43 | public override string ToString() => Name; 44 | } 45 | 46 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/.semantic-kernel/results/GenerateEnum/Skills.GenerateEnum.results.json: -------------------------------------------------------------------------------- 1 | { 2 | "skillName": "Skills", 3 | "functionName": "GenerateEnum", 4 | "description": "Answer any question", 5 | "filePath": "GenerateEnum\\skprompt.txt", 6 | "results": [ 7 | { 8 | "completionConfig": { 9 | "label": "text-davinci-003", 10 | "aiService": "OpenAI", 11 | "deploymentOrModelId": "text-davinci-003", 12 | "endpoint": null 13 | }, 14 | "requestSettings": { 15 | "temperature": 0, 16 | "topP": 0, 17 | "presencePenalty": 0, 18 | "frequencyPenalty": 0, 19 | "maxTokens": 0, 20 | "stopSequences": [] 21 | }, 22 | "variables": [ 23 | { 24 | "key": "input", 25 | "value": "a,b,c" 26 | } 27 | ], 28 | "output": "Prompt:\r\n\t����������������C# enum��������xmlע��:\n\t\n\ta,b,c\n\r\nResult:\r\n\t```C#\n\t/// \n\t/// ö������\n\t/// \n\tpublic enum EnumType\n\t{\n\t /// \n\t /// a\n\t /// \n\t A,\n\t /// \n\t /// b\n\t /// \n\t B,\n\t /// \n\t /// c\n\t /// \n\t C\n\t}\n\t``\n\r\nTokens:\r\n\tInput tokens: 41\r\n\tOutput tokens: 100\r\n\tTotal: 141\n\r\n" 29 | } 30 | ] 31 | } -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/.semantic-kernel/results/MethodSkill/GenerateMethod/MethodSkill.GenerateMethod.results.json: -------------------------------------------------------------------------------- 1 | { 2 | "skillName": "MethodSkill", 3 | "functionName": "GenerateMethod", 4 | "description": "Answer any question", 5 | "filePath": "MethodSkill\\GenerateMethod\\skprompt.txt", 6 | "results": [ 7 | { 8 | "completionConfig": { 9 | "label": "text-davinci-003", 10 | "aiService": "OpenAI", 11 | "deploymentOrModelId": "text-davinci-003", 12 | "endpoint": null 13 | }, 14 | "requestSettings": { 15 | "temperature": 0, 16 | "topP": 0, 17 | "presencePenalty": 0, 18 | "frequencyPenalty": 0, 19 | "maxTokens": 0, 20 | "stopSequences": [] 21 | }, 22 | "variables": [ 23 | { 24 | "key": "input", 25 | "value": "Create a cirlce in solidworks" 26 | } 27 | ], 28 | "output": "warn: Microsoft.SemanticKernel.IKernel[0]\r\n Variable `$language` not found\r\nPrompt:\r\n\tGenerate a method and it's implementation based on the following information and add XML comments:\n\t\n\tCreate a cirlce in solidworks\n\r\nwarn: Microsoft.SemanticKernel.IKernel[0]\r\n Variable `$language` not found\r\nwarn: Microsoft.SemanticKernel.IKernel[0]\r\n Error executing action [attempt 1 of 1]. Reason: System.Net.Http.HttpRequestException. Will retry after 2000ms\r\nResult:\r\n\t/// \n\t/// This method creates a circle in Solidworks\n\t/// \n\t/// The radius of the circle\n\t/// The center point of the circle\n\tpublic void CreateCircle(double radius, Point centerPoint)\n\t{\n\t // Create a new circle in Solidworks\n\t var circle = Solidworks.CreateCircle(radius, centerPoint);\n\t}\n\r\nTokens:\r\n\tInput tokens: 29\r\n\tOutput tokens: 100\r\n\tTotal: 129\n\r\n" 29 | } 30 | ] 31 | } -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/ClassSkill/GenerateClass/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": 1, 3 | "type": "completion", 4 | "description": "Answer any question", 5 | "completion": { 6 | "max_tokens": 1000, 7 | "temperature": 0.0, 8 | "top_p": 0.0, 9 | "presence_penalty": 0.0, 10 | "frequency_penalty": 0.0 11 | } 12 | } -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/ClassSkill/GenerateClass/skprompt.txt: -------------------------------------------------------------------------------- 1 | Generate a {{$language}} class based on the following information and add XML comments: 2 | 3 | {{$input}} -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/CodeOptimization.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CCodeAI.QuickActions.Skills; 6 | 7 | public class CodeOptimizationSemanticFunction 8 | { 9 | public const string CodeOptimize = """ 10 | ```{{$extension}} 11 | {{$input}} 12 | ``` 13 | 优化代码: 14 | """; 15 | } 16 | -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/EnumSkill/GenerateEnum/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": 1, 3 | "type": "completion", 4 | "description": "Answer any question", 5 | "completion": { 6 | "max_tokens": 1000, 7 | "temperature": 0.0, 8 | "top_p": 0.0, 9 | "presence_penalty": 0.0, 10 | "frequency_penalty": 0.0 11 | } 12 | } -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/EnumSkill/GenerateEnum/skprompt.txt: -------------------------------------------------------------------------------- 1 | Generate a {{$language}} enum based on the following information and add XML comments: 2 | 3 | {{$input}} -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/GeneralSkill/Empty/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": 1, 3 | "type": "completion", 4 | "description": "Answer any question", 5 | "completion": { 6 | "max_tokens": 10000, 7 | "temperature": 0.0, 8 | "top_p": 0.0, 9 | "presence_penalty": 0.0, 10 | "frequency_penalty": 0.0 11 | } 12 | } -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/GeneralSkill/Empty/skprompt.txt: -------------------------------------------------------------------------------- 1 | {{$input}} -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/GeneralSkill/GenerateCode/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": 1, 3 | "type": "completion", 4 | "description": "Answer any question", 5 | "completion": { 6 | "max_tokens": 1000, 7 | "temperature": 0.0, 8 | "top_p": 0.0, 9 | "presence_penalty": 0.0, 10 | "frequency_penalty": 0.0 11 | } 12 | } -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/GeneralSkill/GenerateCode/skprompt.txt: -------------------------------------------------------------------------------- 1 | Generate {{$language}} code based on the following information: 2 | 3 | {{$input}} -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/MethodSkill/GenerateMethod/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": 1, 3 | "type": "completion", 4 | "description": "Answer any question", 5 | "completion": { 6 | "max_tokens": 10000, 7 | "temperature": 0.0, 8 | "top_p": 0.0, 9 | "presence_penalty": 0.0, 10 | "frequency_penalty": 0.0 11 | } 12 | } -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/MethodSkill/GenerateMethod/skprompt.txt: -------------------------------------------------------------------------------- 1 | Generate a {{$language}} method and it's implementation based on the following information and add XML comments: 2 | 3 | {{$input}} -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/MethodSkill/GenerateStaticMethod/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": 1, 3 | "type": "completion", 4 | "description": "Answer any question", 5 | "completion": { 6 | "max_tokens": 10000, 7 | "temperature": 0.0, 8 | "top_p": 0.0, 9 | "presence_penalty": 0.0, 10 | "frequency_penalty": 0.0 11 | } 12 | } -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/MethodSkill/GenerateStaticMethod/skprompt.txt: -------------------------------------------------------------------------------- 1 | Generate a static {{$language}} method and it's implementation based on the following information and add XML comments: 2 | 3 | {{$input}} -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/WPFSkill/GenerateWPFStyle/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": 1, 3 | "type": "completion", 4 | "description": "Answer any question", 5 | "completion": { 6 | "max_tokens": 2000, 7 | "temperature": 0.3, 8 | "top_p": 0.0, 9 | "presence_penalty": 0.0, 10 | "frequency_penalty": 0.0 11 | } 12 | } -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/Skills/WPFSkill/GenerateWPFStyle/skprompt.txt: -------------------------------------------------------------------------------- 1 | Generate a WPF style based on the following information: 2 | 3 | [Requirment] 4 | {{$input}} 5 | [End] -------------------------------------------------------------------------------- /CCodeAI.QuickActions/CCodeAI.QuickActions/SkillsProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using System.Linq; 4 | 5 | public class SkillsProvider : ISkillsProvider 6 | { 7 | /// 8 | public string SkillsLocation { get; } 9 | 10 | public string DefaultDir { get; } 11 | 12 | public SkillsProvider() 13 | { 14 | SkillsLocation = Path.Combine( 15 | Path.GetDirectoryName(typeof(SkillsProvider).Assembly.Location), 16 | "Skills"); 17 | } 18 | 19 | public SkillsProvider(string skilldir,string defaultDir = null) 20 | { 21 | SkillsLocation = skilldir; 22 | DefaultDir = defaultDir; 23 | } 24 | 25 | public IEnumerable GetSkills() 26 | { 27 | if (!Directory.Exists(SkillsLocation)) 28 | { 29 | throw new DirectoryNotFoundException($"Skill NotFound:{SkillsLocation}"); 30 | } 31 | 32 | var skillDirs = Directory.GetDirectories(SkillsLocation) 33 | .Where(p => p.EndsWith("Skill")); 34 | 35 | if (!string.IsNullOrEmpty(DefaultDir) && Directory.Exists(DefaultDir)) 36 | { 37 | skillDirs = Directory.GetDirectories(DefaultDir) 38 | .Where(p => p.EndsWith("Skill")) 39 | .Concat(skillDirs); 40 | } 41 | 42 | int index = 1; 43 | foreach (var dir in skillDirs) 44 | { 45 | var model = new SkillModel(dir); 46 | model.Index = index++; 47 | yield return model; 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /CCodeAI/CCodePackage.cs: -------------------------------------------------------------------------------- 1 | global using Community.VisualStudio.Toolkit; 2 | global using Microsoft.VisualStudio.Shell; 3 | global using System; 4 | global using Task = System.Threading.Tasks.Task; 5 | using CCodeAI.Models; 6 | using EnvDTE80; 7 | using System.Runtime.InteropServices; 8 | using System.Threading; 9 | 10 | namespace CCodeAI 11 | { 12 | [PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)] 13 | [InstalledProductRegistration(Vsix.Name, Vsix.Description, Vsix.Version)] 14 | [ProvideMenuResource("Menus.ctmenu", 1)] 15 | [Guid(PackageGuids.CCodeAIString)] 16 | [ProvideToolWindow(typeof(CCodeExplainWindow.Pane))] 17 | [ProvideOptionPage(typeof(ConfigOptions), "CCodeAI", "Config", 0, 0, true)] 18 | public sealed class CCodePackage : ToolkitPackage 19 | { 20 | protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress progress) 21 | { 22 | this.RegisterToolWindows(); 23 | await this.RegisterCommandsAsync(); 24 | 25 | var options = (ConfigOptions)GetDialogPage(typeof(ConfigOptions)); 26 | if (string.IsNullOrEmpty( options.Endpoint)==false && string.IsNullOrEmpty(options.AppKey) == false) 27 | { 28 | AzureConfig.SetConfiguration(options.Endpoint, options.AppKey); 29 | 30 | } 31 | else 32 | { 33 | AzureConfig.DefaultConfiguration(); 34 | } 35 | 36 | 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /CCodeAI/Commands/CCodeAICommandId.cs: -------------------------------------------------------------------------------- 1 | using EnvDTE; 2 | 3 | namespace CCodeAI; 4 | 5 | [Command(PackageIds.CCodeAICommandId)] 6 | internal sealed class CCodeAICommandId : BaseCommand 7 | { 8 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 9 | { 10 | await CCodeExplainWindow.ShowAsync(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CCodeAI/Commands/CCodeAddAskCommandId.cs: -------------------------------------------------------------------------------- 1 | using EnvDTE; 2 | using Microsoft.VisualStudio.Text; 3 | 4 | namespace CCodeAI; 5 | 6 | [Command(PackageIds.CCodeAddAskCommandId)] 7 | internal sealed class CCodeAddAskCommandId : BaseCommand 8 | { 9 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 10 | { 11 | try 12 | { 13 | DocumentView docView = await VS.Documents.GetActiveDocumentViewAsync(); 14 | if (docView?.TextView == null) return; //not a text window 15 | 16 | var selection = docView?.TextView.Selection; 17 | SnapshotSpan selectedSpan = selection.StreamSelectionSpan.SnapshotSpan; 18 | string selectedText = selectedSpan.GetText(); 19 | 20 | if (string.IsNullOrWhiteSpace(selectedText)) 21 | { 22 | // 获取光标所在行的文本 23 | ITextSnapshotLine line = selection.Start.Position.GetContainingLine(); 24 | selectedText = line.GetText(); 25 | } 26 | var tool = await CCodeExplainWindow.ShowAsync(); 27 | 28 | var toolWindows = ((CCodeExplainWindowControl)tool.Content); 29 | 30 | toolWindows.VM.Question += selectedText; 31 | 32 | } 33 | catch (Exception ex) 34 | { 35 | await VS.MessageBox.ShowErrorAsync(ex.Message); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /CCodeAI/Commands/CCodeCodeGenCommandId.cs: -------------------------------------------------------------------------------- 1 | using CCodeAI.Extensions; 2 | using CCodeAI.Views; 3 | using EnvDTE; 4 | using Microsoft.VisualStudio.Text; 5 | using System.IO; 6 | 7 | namespace CCodeAI; 8 | 9 | [Command(PackageIds.CCodeCodeGenCommandId)] 10 | internal sealed class CCodeCodeGenCommandId : BaseCommand 11 | { 12 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 13 | { 14 | try 15 | { 16 | DocumentView docView = await VS.Documents.GetActiveDocumentViewAsync(); 17 | 18 | //programming language 19 | var lang = CodeExtension.GetCodeType(Path.GetExtension(docView?.FilePath)); 20 | 21 | //selection 22 | var selection = docView?.TextView?.Selection; 23 | SnapshotSpan? selectedSpan = selection?.StreamSelectionSpan.SnapshotSpan; 24 | string selectedText = selectedSpan?.GetText(); 25 | 26 | //show dialog 27 | var codeGenWindow = new CodeGenWindow(lang,selectedText); 28 | if (codeGenWindow.ShowDialog() != true) 29 | { 30 | return; 31 | } 32 | 33 | if (docView?.TextView == null) return; //not a text window 34 | 35 | var result = codeGenWindow.ResponseText; 36 | 37 | docView.TextBuffer.Insert(selection.End.Position, "\r\n" + result.Trim('`')); 38 | } 39 | catch (Exception ex) 40 | { 41 | await VS.MessageBox.ShowErrorAsync(ex.Message); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /CCodeAI/Commands/CCodeContinuationCodeCommand.cs: -------------------------------------------------------------------------------- 1 | using CCodeAI.Extensions; 2 | using CCodeAI.ViewModels; 3 | using EnvDTE; 4 | using Microsoft.VisualStudio.Text; 5 | using System.IO; 6 | 7 | namespace CCodeAI; 8 | 9 | [Command(PackageIds.CCodeContinuationCodeCommandId)] 10 | internal sealed class CCodeContinuationCodeCommand : BaseCommand 11 | { 12 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 13 | { 14 | try 15 | { 16 | DocumentView docView = await VS.Documents.GetActiveDocumentViewAsync(); 17 | if (docView?.TextView == null) return; //not a text window 18 | 19 | var selection = docView?.TextView.Selection; 20 | SnapshotSpan selectedSpan = selection.StreamSelectionSpan.SnapshotSpan; 21 | string selectedText = selectedSpan.GetText(); 22 | 23 | if (string.IsNullOrWhiteSpace(selectedText)) 24 | { 25 | ITextSnapshotLine line = selection.Start.Position.GetContainingLine(); 26 | selectedText = line.GetText(); 27 | } 28 | var tool = await CCodeExplainWindow.ShowAsync(); 29 | 30 | var toolWindows = ((CCodeExplainWindowControl)tool.Content); 31 | 32 | var chatData = await toolWindows.VM.CodeSkillAsync( 33 | selectedText, 34 | CodeExtension.GetCodeType(Path.GetExtension(docView.FilePath)), 35 | Resources.Resources.ContinuationCode); 36 | 37 | if (chatData == null) return; 38 | 39 | docView.TextBuffer.Insert(selection.End.Position, "\r\n" + chatData.Trim('`')); 40 | 41 | } 42 | catch (Exception ex) 43 | { 44 | await VS.MessageBox.ShowErrorAsync(ex.Message); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /CCodeAI/Commands/CCodeExplainCommand.cs: -------------------------------------------------------------------------------- 1 | using CCodeAI.Extensions; 2 | using CCodeAI.ViewModels; 3 | using EnvDTE; 4 | using Microsoft.VisualStudio.Text; 5 | using System.IO; 6 | 7 | namespace CCodeAI; 8 | 9 | [Command(PackageIds.CCodeExplainCommandId)] 10 | internal sealed class CCodeExplainCommand : BaseCommand 11 | { 12 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 13 | { 14 | try 15 | { 16 | DocumentView docView = await VS.Documents.GetActiveDocumentViewAsync(); 17 | if (docView?.TextView == null) return; //not a text window 18 | 19 | var selection = docView?.TextView.Selection; 20 | SnapshotSpan selectedSpan = selection.StreamSelectionSpan.SnapshotSpan; 21 | string selectedText = selectedSpan.GetText(); 22 | 23 | if (string.IsNullOrWhiteSpace(selectedText)) 24 | { 25 | ITextSnapshotLine line = selection.Start.Position.GetContainingLine(); 26 | selectedText = line.GetText(); 27 | } 28 | var tool = await CCodeExplainWindow.ShowAsync(); 29 | 30 | var toolWindows = ((CCodeExplainWindowControl)tool.Content); 31 | 32 | await toolWindows.VM.CodeSkillAsync( 33 | selectedText, 34 | CodeExtension.GetCodeType(Path.GetExtension(docView.FilePath)), 35 | Resources.Resources.CodeExplain); 36 | } 37 | catch (Exception ex) 38 | { 39 | await VS.MessageBox.ShowErrorAsync(ex.Message); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /CCodeAI/Commands/CCodeNoteCommand.cs: -------------------------------------------------------------------------------- 1 | using CCodeAI.Extensions; 2 | using CCodeAI.ViewModels; 3 | using EnvDTE; 4 | using Microsoft.VisualStudio.Text; 5 | using System.IO; 6 | 7 | namespace CCodeAI; 8 | 9 | [Command(PackageIds.CCodeNoteCommandId)] 10 | internal sealed class CCodeNoteCommand : BaseCommand 11 | { 12 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 13 | { 14 | DocumentView docView = await VS.Documents.GetActiveDocumentViewAsync(); 15 | if (docView?.TextView == null) return; //not a text window 16 | 17 | var selection = docView?.TextView.Selection; 18 | SnapshotSpan selectedSpan = selection.StreamSelectionSpan.SnapshotSpan; 19 | string selectedText = selectedSpan.GetText(); 20 | 21 | if (string.IsNullOrWhiteSpace(selectedText)) 22 | { 23 | ITextSnapshotLine line = selection.Start.Position.GetContainingLine(); 24 | selectedText = line.GetText(); 25 | } 26 | var tool = await CCodeExplainWindow.ShowAsync(); 27 | 28 | var toolWindows = ((CCodeExplainWindowControl)tool.Content); 29 | 30 | await toolWindows.VM.CodeSkillAsync( 31 | selectedText, 32 | CodeExtension.GetCodeType(Path.GetExtension(docView.FilePath)), 33 | Resources.Resources.CodeNote); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /CCodeAI/Commands/CCodeOptimizeCommand.cs: -------------------------------------------------------------------------------- 1 | using CCodeAI.Extensions; 2 | using CCodeAI.ViewModels; 3 | using EnvDTE; 4 | using Microsoft.VisualStudio.Text; 5 | using System.IO; 6 | 7 | namespace CCodeAI; 8 | 9 | [Command(PackageIds.CCodeOptimizeCommandId)] 10 | internal sealed class CCodeOptimizeCommand : BaseCommand 11 | { 12 | 13 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 14 | { 15 | try 16 | { 17 | DocumentView docView = await VS.Documents.GetActiveDocumentViewAsync(); 18 | if (docView?.TextView == null) return; //not a text window 19 | 20 | var selection = docView?.TextView.Selection; 21 | SnapshotSpan selectedSpan = selection.StreamSelectionSpan.SnapshotSpan; 22 | string selectedText = selectedSpan.GetText(); 23 | 24 | if (string.IsNullOrWhiteSpace(selectedText)) 25 | { 26 | ITextSnapshotLine line = selection.Start.Position.GetContainingLine(); 27 | selectedText = line.GetText(); 28 | } 29 | var tool = await CCodeExplainWindow.ShowAsync(); 30 | 31 | var toolWindows = ((CCodeExplainWindowControl)tool.Content); 32 | 33 | await toolWindows.VM.CodeSkillAsync( 34 | selectedText, 35 | CodeExtension.GetCodeType(Path.GetExtension(docView.FilePath)), 36 | Resources.Resources.CodeOptimize); 37 | } 38 | catch (Exception ex) 39 | { 40 | await VS.MessageBox.ShowErrorAsync(ex.Message); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /CCodeAI/Converters/BoolToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using System.Windows.Data; 3 | using System.Windows; 4 | 5 | namespace CCodeAI.Converters; 6 | 7 | public class BoolToVisibilityConverter : IValueConverter 8 | { 9 | public object Convert( 10 | object value, 11 | Type targetType, 12 | object parameter, 13 | CultureInfo culture) 14 | { 15 | return value is true ? Visibility.Visible : Visibility.Collapsed; 16 | } 17 | 18 | public object ConvertBack( 19 | object value, 20 | Type targetType, 21 | object parameter, 22 | CultureInfo culture) 23 | { 24 | throw new NotImplementedException(); 25 | } 26 | } -------------------------------------------------------------------------------- /CCodeAI/Converters/StringIsNullOrEmptyToVisibilityConveter.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using System.Windows.Data; 3 | using System.Windows; 4 | 5 | namespace CCodeAI.Converters; 6 | 7 | public class StringIsNullOrEmptyToVisibilityConveter : IValueConverter 8 | { 9 | public object Convert( 10 | object value, 11 | Type targetType, 12 | object parameter, 13 | CultureInfo culture) 14 | { 15 | return string.IsNullOrEmpty(value?.ToString()) ? Visibility.Collapsed : Visibility.Visible; 16 | } 17 | 18 | public object ConvertBack( 19 | object value, 20 | Type targetType, 21 | object parameter, 22 | CultureInfo culture) 23 | { 24 | throw new NotImplementedException(); 25 | } 26 | } -------------------------------------------------------------------------------- /CCodeAI/Converters/WhoToStringConverter.cs: -------------------------------------------------------------------------------- 1 | using CCodeAI.Models; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace CCodeAI.ToolWindows; 6 | 7 | public class WhoToStringConverter : IValueConverter 8 | { 9 | public object Convert( 10 | object value, 11 | Type targetType, 12 | object parameter, 13 | CultureInfo culture) 14 | { 15 | if (value is EWho who) 16 | { 17 | return who switch 18 | { 19 | EWho.User => Environment.UserName, 20 | EWho.PlugIn or EWho.Assistant or EWho.Welcome => Resources.Resources.Assistant, 21 | _ => value.ToString(), 22 | }; 23 | } 24 | 25 | return value.ToString(); 26 | } 27 | 28 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 29 | { 30 | throw new NotImplementedException(); 31 | } 32 | } -------------------------------------------------------------------------------- /CCodeAI/Extension.en-US.vsixlangpack: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | CCodeAI 6 | Help you understand and optimize the code 7 | https://github.com/TimChen44/CCodeAI 8 | https://github.com/TimChen44/CCodeAI 9 | https://github.com/TimChen44/CCodeAI 10 | Resources\Icon.png 11 | Resources\Icon.png 12 | OpenAI,ChatGPT,CodeGen 13 | 14 | 15 | 16 | x86 17 | 18 | 19 | x86 20 | 21 | 22 | x86 23 | 24 | 25 | amd64 26 | 27 | 28 | amd64 29 | 30 | 31 | amd64 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /CCodeAI/Extension.zh-CN.vsixlangpack: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | CCodeAI 6 | Help you understand and optimize the code 7 | https://github.com/TimChen44/CCodeAI 8 | https://github.com/TimChen44/CCodeAI 9 | https://github.com/TimChen44/CCodeAI 10 | Resources\Icon.png 11 | Resources\Icon.png 12 | OpenAI,ChatGPT,CodeGen 13 | 14 | 15 | 16 | x86 17 | 18 | 19 | x86 20 | 21 | 22 | x86 23 | 24 | 25 | amd64 26 | 27 | 28 | amd64 29 | 30 | 31 | amd64 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /CCodeAI/Extensions/CodeExtension.cs: -------------------------------------------------------------------------------- 1 | namespace CCodeAI.Extensions; 2 | 3 | public static class CodeExtension 4 | { 5 | public static string GetCodeType(string extension) 6 | { 7 | return extension switch 8 | { 9 | ".cs" => "C#", 10 | ".js" => "JavaScript", 11 | ".ts" => "TypeScript", 12 | ".cpp" => "C++", 13 | ".vb" => "vb", 14 | _ => "" 15 | }; 16 | } 17 | } -------------------------------------------------------------------------------- /CCodeAI/Extensions/LocalSemanticFunctionModelExtension.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text.Json; 3 | using static Microsoft.SemanticKernel.SemanticFunctions.PromptTemplateConfig; 4 | 5 | namespace CCodeAI.Extensions; 6 | 7 | internal static class LocalSemanticFunctionModelExtension 8 | { 9 | public static CompletionConfig GetCompletionConfig( 10 | this LocalSemanticFunctionModel model) 11 | { 12 | var configPathName = Path.Combine(Path.GetDirectoryName(model.PathName), "config.json"); 13 | 14 | if (!File.Exists(configPathName)) 15 | { 16 | return null; 17 | } 18 | 19 | var text = File.ReadAllText(configPathName); 20 | 21 | return JsonSerializer.Deserialize(text); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CCodeAI/Extensions/ScrollViewerExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | using System.Windows; 3 | 4 | namespace CCodeAI.Extensions; 5 | 6 | public class ScrollViewerExtensions 7 | { 8 | private static bool _autoScroll; 9 | 10 | public static readonly DependencyProperty AlwaysScrollToEndProperty = DependencyProperty.RegisterAttached( 11 | "AlwaysScrollToEnd", 12 | typeof(bool), 13 | typeof(ScrollViewerExtensions), 14 | new PropertyMetadata(false, AlwaysScrollToEndChanged)); 15 | 16 | private static void AlwaysScrollToEndChanged(object sender, DependencyPropertyChangedEventArgs e) 17 | { 18 | ScrollViewer scroll = sender as ScrollViewer; 19 | if (scroll != null) 20 | { 21 | bool alwaysScrollToEnd = (e.NewValue != null) && (bool)e.NewValue; 22 | if (alwaysScrollToEnd) 23 | { 24 | scroll.ScrollToEnd(); 25 | scroll.ScrollChanged += ScrollChanged; 26 | // scroll.SizeChanged += Scroll_SizeChanged; 27 | } 28 | else { scroll.ScrollChanged -= ScrollChanged; /*scroll.ScrollChanged -= ScrollChanged; */} 29 | } 30 | else { throw new InvalidOperationException("The attached AlwaysScrollToEnd property can only be applied to ScrollViewer instances."); } 31 | } 32 | 33 | public static bool GetAlwaysScrollToEnd(ScrollViewer scroll) 34 | { 35 | if (scroll == null) { throw new ArgumentNullException("scroll"); } 36 | return (bool)scroll.GetValue(AlwaysScrollToEndProperty); 37 | } 38 | 39 | public static void SetAlwaysScrollToEnd(ScrollViewer scroll, bool alwaysScrollToEnd) 40 | { 41 | if (scroll == null) { throw new ArgumentNullException("scroll"); } 42 | scroll.SetValue(AlwaysScrollToEndProperty, alwaysScrollToEnd); 43 | } 44 | 45 | private static void ScrollChanged(object sender, ScrollChangedEventArgs e) 46 | { 47 | ScrollViewer scroll = sender as ScrollViewer; 48 | if (scroll == null) { throw new InvalidOperationException("The attached AlwaysScrollToEnd property can only be applied to ScrollViewer instances."); } 49 | 50 | 51 | if (e.ExtentHeightChange == 0) { _autoScroll = scroll.VerticalOffset == scroll.ScrollableHeight; } 52 | if (_autoScroll && e.ExtentHeightChange != 0) { scroll.ScrollToVerticalOffset(scroll.ExtentHeight); } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /CCodeAI/ICSharpCode.AvalonEdit.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimChen44/CCodeAI/e1bb774904229e04efd6599bee871baca088050a/CCodeAI/ICSharpCode.AvalonEdit.dll -------------------------------------------------------------------------------- /CCodeAI/MdXaml.Plugins.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimChen44/CCodeAI/e1bb774904229e04efd6599bee871baca088050a/CCodeAI/MdXaml.Plugins.dll -------------------------------------------------------------------------------- /CCodeAI/MdXaml.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimChen44/CCodeAI/e1bb774904229e04efd6599bee871baca088050a/CCodeAI/MdXaml.dll -------------------------------------------------------------------------------- /CCodeAI/Microsoft.Bcl.AsyncInterfaces.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimChen44/CCodeAI/e1bb774904229e04efd6599bee871baca088050a/CCodeAI/Microsoft.Bcl.AsyncInterfaces.dll -------------------------------------------------------------------------------- /CCodeAI/Models/ChatData.cs: -------------------------------------------------------------------------------- 1 | using CommunityToolkit.Mvvm.Input; 2 | using System.Windows; 3 | 4 | namespace CCodeAI.Models; 5 | 6 | public partial class ChatData 7 | { 8 | public EWho Who { get; set; } 9 | 10 | public string Content { get; set; } 11 | 12 | public int Tokens { get; set; } 13 | 14 | public string ToPrompt() 15 | { 16 | return $"<|im_start|>{Who.ToString().ToLower()}{Content}<|im_end|>"; 17 | } 18 | 19 | public override string ToString() => $"{Who}:{Content}"; 20 | 21 | public virtual string History { get 22 | { 23 | return Who switch 24 | { 25 | EWho.User => $"Me: {Content}", 26 | _ => $"AI: {Content}" 27 | }; 28 | } 29 | } 30 | 31 | [RelayCommand] 32 | private void Copy() 33 | { 34 | try 35 | { 36 | Clipboard.SetDataObject(Content); 37 | } 38 | catch (Exception ex) 39 | { 40 | VS.MessageBox.ShowError(ex.Message); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /CCodeAI/Models/ChatListExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.SemanticKernel.AI.ChatCompletion; 2 | using Microsoft.VisualStudio.OLE.Interop; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace CCodeAI.Models; 8 | 9 | public static class ChatListExtension 10 | { 11 | public static ChatHistory GetChatHistory( 12 | this IEnumerable chatList, 13 | string prompt) 14 | { 15 | var chatHistory = new ChatHistory(); 16 | chatHistory.AddMessage(ChatHistory.AuthorRoles.System, prompt); 17 | 18 | 19 | foreach (ChatData chat in chatList.Reverse().Take(7).Reverse()) //TODO:先控制在三次对话中,后续应该根据token控制会话长度 20 | { 21 | if (chat.Who == EWho.Welcome) 22 | { 23 | continue; 24 | } 25 | 26 | if (chat.Who == EWho.User) 27 | { 28 | chatHistory.AddMessage(ChatHistory.AuthorRoles.User, chat.Content); 29 | } 30 | else if(chat.Who == EWho.Assistant) 31 | { 32 | chatHistory.AddMessage(ChatHistory.AuthorRoles.Assistant, chat.Content); 33 | } 34 | } 35 | 36 | return chatHistory; 37 | } 38 | } -------------------------------------------------------------------------------- /CCodeAI/Models/ConfigOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace CCodeAI.Models 10 | { 11 | [ComVisible(true)] 12 | public class ConfigOptions : DialogPage 13 | { 14 | [Category("CCodeAI")] 15 | [DisplayName("Endpoint")] 16 | [Description("Azure OpenAI Endpoint")] 17 | public string Endpoint { get; set; } 18 | 19 | [Category("CCodeAI")] 20 | [DisplayName("AppKey")] 21 | [Description("Azure OpenAI AppKey")] 22 | public string AppKey { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /CCodeAI/Models/EWho.cs: -------------------------------------------------------------------------------- 1 | namespace CCodeAI.Models; 2 | 3 | public enum EWho 4 | { 5 | PlugIn, 6 | User, 7 | Assistant, 8 | Welcome, 9 | } -------------------------------------------------------------------------------- /CCodeAI/Models/WelcomeChatData.cs: -------------------------------------------------------------------------------- 1 | using CCodeAI.Extensions; 2 | using CCodeAI.ViewModels; 3 | using CommunityToolkit.Mvvm.Input; 4 | using Microsoft.SemanticKernel.KernelExtensions; 5 | using Microsoft.VisualStudio.Text; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | using System.Linq; 9 | 10 | namespace CCodeAI.Models; 11 | 12 | public class WelcomeChatData:ChatData 13 | { 14 | private AsyncRelayCommand _executeCoreSkillCommand; 15 | 16 | public WelcomeChatData() 17 | { 18 | } 19 | 20 | public WelcomeChatData(CCodeExplainWindowControlViewModel cCodeExplainWindowControlViewModel) 21 | { 22 | Who = EWho.Welcome; 23 | Content = Resources.Resources.WhenDoubtAI; 24 | 25 | Parent = cCodeExplainWindowControlViewModel; 26 | CoreSkill = Parent.SkillsProvider 27 | ?.GetSkills() 28 | ?.FirstOrDefault(p => p.Name == "CoreSkill"); 29 | SemanticFunctions = CoreSkill?.SemanticFunctions; 30 | } 31 | 32 | public List SemanticFunctions { get; set; } 33 | 34 | public CCodeExplainWindowControlViewModel Parent { get; } 35 | 36 | public SkillModel CoreSkill { get; } 37 | 38 | public AsyncRelayCommand ExecuteCoreSkillCommand => _executeCoreSkillCommand ??= new AsyncRelayCommand(ExcuteCodeSkillSKFunctionAsync); 39 | 40 | private async Task ExcuteCodeSkillSKFunctionAsync( 41 | LocalSemanticFunctionModel localSemanticFunctionModel) 42 | { 43 | if (localSemanticFunctionModel == null || CoreSkill == null) 44 | { 45 | return; 46 | } 47 | 48 | try 49 | { 50 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 51 | 52 | //get document view 53 | DocumentView docView = await VS.Documents.GetActiveDocumentViewAsync(); 54 | if (docView == null) return; 55 | if (docView?.TextView == null) return; //not a text window 56 | 57 | //get selection 58 | var selection = docView?.TextView?.Selection; 59 | if (selection == null) return; 60 | 61 | SnapshotSpan selectedSpan = selection.StreamSelectionSpan.SnapshotSpan; 62 | string selectedText = selectedSpan.GetText(); 63 | 64 | if (string.IsNullOrWhiteSpace(selectedText)) 65 | { 66 | await VS.MessageBox.ShowWarningAsync("Please select some code first."); 67 | return; 68 | } 69 | 70 | var extension = Path.GetExtension(docView.FilePath); 71 | 72 | var codeType = CodeExtension.GetCodeType(extension); 73 | 74 | var coreSkill = KernelFactory.SKernel.ImportSemanticSkillFromDirectory(Parent.SkillsProvider.SkillsLocation, CoreSkill.Name); 75 | 76 | await Parent.CodeSkillAsync(selectedText, codeType, coreSkill[localSemanticFunctionModel.Name]); 77 | } 78 | catch (Exception ex) 79 | { 80 | await VS.MessageBox.ShowErrorAsync(ex.Message); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /CCodeAI/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using CCodeAI; 2 | using System.Reflection; 3 | using System.Resources; 4 | using System.Runtime.InteropServices; 5 | 6 | [assembly: AssemblyTitle(Vsix.Name)] 7 | [assembly: AssemblyDescription(Vsix.Description)] 8 | [assembly: AssemblyConfiguration("")] 9 | [assembly: AssemblyCompany(Vsix.Author)] 10 | [assembly: AssemblyProduct(Vsix.Name)] 11 | [assembly: AssemblyCopyright(Vsix.Author)] 12 | [assembly: AssemblyTrademark("")] 13 | [assembly: AssemblyCulture("")] 14 | 15 | [assembly: ComVisible(false)] 16 | 17 | [assembly: AssemblyVersion(Vsix.Version)] 18 | [assembly: AssemblyFileVersion(Vsix.Version)] 19 | [assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.MainAssembly)] 20 | namespace System.Runtime.CompilerServices 21 | { 22 | public class IsExternalInit { } 23 | } -------------------------------------------------------------------------------- /CCodeAI/Resources/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimChen44/CCodeAI/e1bb774904229e04efd6599bee871baca088050a/CCodeAI/Resources/Icon.png -------------------------------------------------------------------------------- /CCodeAI/Resources/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace CCodeAI.Resources { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | public class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | public static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CCodeAI.Resources.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 重写当前线程的 CurrentUICulture 属性,对 51 | /// 使用此强类型资源类的所有资源查找执行重写。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | public static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// 查找类似 CCodeAI 的本地化字符串。 65 | /// 66 | public static string Assistant { 67 | get { 68 | return ResourceManager.GetString("Assistant", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// 查找类似 Cancel(_C) 的本地化字符串。 74 | /// 75 | public static string CancleBtn { 76 | get { 77 | return ResourceManager.GetString("CancleBtn", resourceCulture); 78 | } 79 | } 80 | 81 | /// 82 | /// 查找类似 以下是与人工智能编码助理的对话。这位助理乐于助人,富有创造力,聪明,而且非常友好。 83 | /// 84 | ///问:我有一个问题。你能帮忙吗? 85 | ///答:当然,我是你的AI编码助理,请继续! 86 | ///问:{{$input}} 87 | ///答: 的本地化字符串。 88 | /// 89 | public static string Chat { 90 | get { 91 | return ResourceManager.GetString("Chat", resourceCulture); 92 | } 93 | } 94 | 95 | /// 96 | /// 查找类似 ```{{$extension}} 97 | ///{{$input}} 98 | ///``` 99 | ///Explain the code: 的本地化字符串。 100 | /// 101 | public static string CodeExplain { 102 | get { 103 | return ResourceManager.GetString("CodeExplain", resourceCulture); 104 | } 105 | } 106 | 107 | /// 108 | /// 查找类似 ```{{$extension}} 109 | ///{{$input}} 110 | ///``` 111 | ///Add comments to each line of code: 的本地化字符串。 112 | /// 113 | public static string CodeNote { 114 | get { 115 | return ResourceManager.GetString("CodeNote", resourceCulture); 116 | } 117 | } 118 | 119 | /// 120 | /// 查找类似 ```{{$extension}} 121 | ///{{$input}} 122 | ///``` 123 | ///Optimize the code: 的本地化字符串。 124 | /// 125 | public static string CodeOptimize { 126 | get { 127 | return ResourceManager.GetString("CodeOptimize", resourceCulture); 128 | } 129 | } 130 | 131 | /// 132 | /// 查找类似 ```{{$extension}} 133 | ///{{$input}} 134 | ///``` 135 | ///Complete the code based on the comments, and only return the added code, excluding any other content: 的本地化字符串。 136 | /// 137 | public static string ContinuationCode { 138 | get { 139 | return ResourceManager.GetString("ContinuationCode", resourceCulture); 140 | } 141 | } 142 | 143 | /// 144 | /// 查找类似 Copy(_C) 的本地化字符串。 145 | /// 146 | public static string Copy { 147 | get { 148 | return ResourceManager.GetString("Copy", resourceCulture); 149 | } 150 | } 151 | 152 | /// 153 | /// 查找类似 Inquiry for AI, please wait... 的本地化字符串。 154 | /// 155 | public static string InquiryAI { 156 | get { 157 | return ResourceManager.GetString("InquiryAI", resourceCulture); 158 | } 159 | } 160 | 161 | /// 162 | /// 查找类似 Insert(_I) 的本地化字符串。 163 | /// 164 | public static string InsertBtn { 165 | get { 166 | return ResourceManager.GetString("InsertBtn", resourceCulture); 167 | } 168 | } 169 | 170 | /// 171 | /// 查找类似 When in doubt, ask AI. 的本地化字符串。 172 | /// 173 | public static string WhenDoubtAI { 174 | get { 175 | return ResourceManager.GetString("WhenDoubtAI", resourceCulture); 176 | } 177 | } 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /CCodeAI/Themes/Converters.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | -------------------------------------------------------------------------------- /CCodeAI/ToolWindows/CCodeExplainWindow.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.Imaging; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using System.Reflection; 5 | using System.Runtime.InteropServices; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | 10 | namespace CCodeAI 11 | { 12 | public class CCodeExplainWindow : BaseToolWindow 13 | { 14 | public override string GetTitle(int toolWindowId) => "CCodeAI"; 15 | 16 | public override Type PaneType => typeof(Pane); 17 | 18 | public override Task CreateAsync(int toolWindowId, CancellationToken cancellationToken) 19 | { 20 | AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; 21 | return Task.FromResult(new CCodeExplainWindowControl()); 22 | } 23 | 24 | private System.Reflection.Assembly CurrentDomain_AssemblyResolve( 25 | object sender, 26 | ResolveEventArgs args) 27 | { 28 | var assemblyName = new AssemblyName(args.Name).Name + ".dll"; 29 | var extensionLocation = Path.GetDirectoryName(typeof(CCodeExplainWindow).Assembly.Location); 30 | 31 | try 32 | { 33 | 34 | var file = Path.Combine(extensionLocation, assemblyName); 35 | 36 | if (File.Exists(file)) 37 | { 38 | return Assembly.LoadFrom(file); 39 | } 40 | else 41 | { 42 | Debug.Print(file); 43 | return null; 44 | } 45 | } 46 | catch (Exception ex) 47 | { 48 | throw new Exception( 49 | string.Format("The location of the assembly, {0} could not be resolved for loading.", 50 | extensionLocation), ex); 51 | } 52 | } 53 | 54 | [Guid("937a7d1d-d10f-4843-80ed-f668ac49cb68")] 55 | internal class Pane : ToolWindowPane 56 | { 57 | public Pane() 58 | { 59 | BitmapImageMoniker = KnownMonikers.ToolWindow; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /CCodeAI/ToolWindows/CCodeExplainWindowControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using CCodeAI.ViewModels; 2 | using ICSharpCode.AvalonEdit; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | 6 | namespace CCodeAI 7 | { 8 | public partial class CCodeExplainWindowControl : UserControl 9 | { 10 | public CCodeExplainWindowControl() 11 | { 12 | #pragma warning disable CS0168 13 | MdXaml.MarkdownScrollViewer m; 14 | TextEditor c; 15 | #pragma warning restore CS0168 16 | InitializeComponent(); 17 | 18 | cChatList.ScrollIntoView(); 19 | DataContext = VM = new CCodeExplainWindowControlViewModel(); 20 | } 21 | 22 | public CCodeExplainWindowControlViewModel VM { get; } 23 | 24 | 25 | 26 | private void SendFeedback_Click(object sender, RoutedEventArgs e) 27 | { 28 | System.Diagnostics.Process.Start("https://github.com/TimChen44/CCodeAI/issues"); 29 | } 30 | 31 | private void TimChen44_Click(object sender, RoutedEventArgs e) 32 | { 33 | System.Diagnostics.Process.Start("https://space.bilibili.com/223212197"); 34 | } 35 | } 36 | 37 | public static class ItemsControlExtensions 38 | { 39 | public static void ScrollIntoView( 40 | this ItemsControl control, 41 | object item) 42 | { 43 | FrameworkElement framework = 44 | control.ItemContainerGenerator.ContainerFromItem(item) 45 | as FrameworkElement; 46 | if (framework == null) { return; } 47 | framework.BringIntoView(); 48 | } 49 | 50 | public static void ScrollIntoView(this ItemsControl control) 51 | { 52 | int count = control.Items.Count; 53 | if (count == 0) { return; } 54 | object item = control.Items[count - 1]; 55 | control.ScrollIntoView(item); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /CCodeAI/ToolWindows/CodeRichTextBox.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.OLE.Interop; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace CCodeAI.ToolWindows 11 | { 12 | public class CodeRichTextBox : RichTextBox 13 | { 14 | public static readonly DependencyProperty CodeTextProperty = 15 | DependencyProperty.Register("CodeText", typeof(string), typeof(CodeRichTextBox), 16 | new PropertyMetadata("Default value")); 17 | 18 | public override void OnApplyTemplate() 19 | { 20 | base.OnApplyTemplate(); 21 | } 22 | 23 | public string CodeText 24 | { 25 | get { 26 | return (string)GetValue(CodeTextProperty); 27 | } 28 | set { 29 | SetValue(CodeTextProperty, value); 30 | } 31 | } 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /CCodeAI/VSCommandTable.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------------------------ 2 | // 3 | // This file was generated by VSIX Synchronizer 4 | // 5 | // ------------------------------------------------------------------------------ 6 | namespace CCodeAI 7 | { 8 | using System; 9 | 10 | /// 11 | /// Helper class that exposes all GUIDs used across VS Package. 12 | /// 13 | internal sealed partial class PackageGuids 14 | { 15 | public const string CCodeAIString = "2bdd3495-3110-42a1-b16c-a967f03684a7"; 16 | public static Guid CCodeAI = new Guid(CCodeAIString); 17 | } 18 | /// 19 | /// Helper class that encapsulates all CommandIDs uses across VS Package. 20 | /// 21 | internal sealed partial class PackageIds 22 | { 23 | public const int CCodeMenu = 0x1001; 24 | public const int CCodeGroup = 0x1011; 25 | public const int CCodeExplainCommandId = 0x1021; 26 | public const int CCodeNoteCommandId = 0x1022; 27 | public const int CCodeOptimizeCommandId = 0x1023; 28 | public const int CCodeAddAskCommandId = 0x1024; 29 | public const int CCodeContinuationCodeCommandId = 0x1025; 30 | public const int CCodeCodeGenCommandId = 0x1026; 31 | 32 | public const int CCodeAICommandId = 0x2001; 33 | } 34 | } -------------------------------------------------------------------------------- /CCodeAI/VSCommandTable.vsct: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | CCodeAI 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 35 | 36 | 37 | 45 | 53 | 61 | 62 | 70 | 71 | 79 | 80 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /CCodeAI/ViewModels/CodeExplainExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.SemanticKernel; 2 | using System.Threading.Tasks; 3 | 4 | namespace CCodeAI.ViewModels 5 | { 6 | public static class CodeExplainExtension 7 | { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /CCodeAI/ViewModels/CodeGenWindowViewModel.cs: -------------------------------------------------------------------------------- 1 | using CCodeAI.Models; 2 | using CommunityToolkit.Mvvm.ComponentModel; 3 | using CommunityToolkit.Mvvm.Input; 4 | using Microsoft.SemanticKernel; 5 | using Microsoft.SemanticKernel.KernelExtensions; 6 | using Microsoft.SemanticKernel.Orchestration; 7 | using System.IO; 8 | using System.Linq; 9 | using System.Threading; 10 | using System.Windows; 11 | using System.Windows.Data; 12 | 13 | namespace CCodeAI.ViewModels; 14 | 15 | public partial class CodeGenWindowViewModel : ObservableObject 16 | { 17 | #region Fields 18 | private IAsyncRelayCommand _sendCommand; 19 | private RelayCommand _insertCommand; 20 | private LocalSemanticFunctionModel _selectedSemanticModel; 21 | private string _input; 22 | private string _output; 23 | #endregion 24 | 25 | #region Ctor 26 | public CodeGenWindowViewModel(string language) 27 | { 28 | KernelFactory.Init(); 29 | 30 | var dir = Path.Combine( 31 | Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), 32 | "CCodeAI", "CCodeAISkills"); 33 | 34 | if (!Directory.Exists(dir)) 35 | { 36 | Directory.CreateDirectory(dir); 37 | } 38 | 39 | var defaultDir = Path.Combine( 40 | Path.GetDirectoryName(typeof(CodeGenWindowViewModel).Assembly.Location), 41 | "Skills"); 42 | 43 | SkillsProvider = new SkillsProvider(dir, defaultDir); 44 | 45 | SemanticFunctions = new ListCollectionView( 46 | SkillsProvider.GetSkills().SelectMany(p => p.SemanticFunctions).ToList()); 47 | SemanticFunctions.GroupDescriptions.Add(new PropertyGroupDescription("Category")); 48 | Language = language; 49 | } 50 | #endregion 51 | 52 | #region Properties 53 | public IKernel SKernel => KernelFactory.SKernel; 54 | 55 | public ISkillsProvider SkillsProvider { get; } 56 | 57 | public ListCollectionView SemanticFunctions { get; set; } 58 | 59 | public IAsyncRelayCommand SendCommand 60 | { 61 | get => _sendCommand ??= new AsyncRelayCommand(SendAsync, () => SelectedSemanticModel != null && !string.IsNullOrEmpty(Input)); 62 | } 63 | 64 | public RelayCommand InsertCommand 65 | { 66 | get => _insertCommand ??= new RelayCommand(Insert, w => !string.IsNullOrWhiteSpace(Output)); 67 | } 68 | 69 | public Action CloseAction { get; internal set; } 70 | 71 | public Action DialogResult { get; internal set; } 72 | 73 | public string Language { get; } 74 | 75 | public bool JustCopy { get; internal set; } 76 | 77 | public string ActionBtnName => JustCopy ? Resources.Resources.Copy : Resources.Resources.InsertBtn; 78 | 79 | public LocalSemanticFunctionModel SelectedSemanticModel 80 | { 81 | get => _selectedSemanticModel; set 82 | { 83 | SetProperty(ref _selectedSemanticModel, value); 84 | SendCommand.NotifyCanExecuteChanged(); 85 | } 86 | } 87 | 88 | public string Input 89 | { 90 | get => _input; set 91 | { 92 | SetProperty(ref _input, value); 93 | SendCommand?.NotifyCanExecuteChanged(); 94 | } 95 | } 96 | 97 | public string Output 98 | { 99 | get => _output; set 100 | { 101 | SetProperty(ref _output, value); 102 | InsertCommand.NotifyCanExecuteChanged(); 103 | } 104 | } 105 | #endregion 106 | 107 | #region Methods 108 | private async Task SendAsync(CancellationToken cancellationToken) 109 | { 110 | if (SelectedSemanticModel == null || string.IsNullOrWhiteSpace(Input)) 111 | { 112 | return; 113 | } 114 | 115 | if (AzureConfig.AllowCalls() == false) 116 | { 117 | Output = AzureConfig.OverLimitMsg; 118 | return; 119 | } 120 | 121 | var skill = SKernel.ImportSemanticSkillFromDirectory(SelectedSemanticModel.RootDir, SelectedSemanticModel.Category); 122 | 123 | var variables = new ContextVariables(); 124 | variables["input"] = Input; 125 | variables["language"] = Language; 126 | variables["culture"] = System.Globalization.CultureInfo.CurrentCulture.EnglishName; 127 | 128 | var result = await SKernel.RunAsync( 129 | variables, 130 | cancellationToken, 131 | skill[SelectedSemanticModel.Name]); 132 | 133 | if (result.ErrorOccurred) 134 | { 135 | await VS.MessageBox.ShowErrorAsync(result.LastErrorDescription); 136 | } 137 | 138 | Output = result.ToString().Trim(); 139 | } 140 | 141 | [RelayCommand] 142 | private void Stop() 143 | { 144 | if (SendCommand.IsRunning) 145 | { 146 | SendCommand.Cancel(); 147 | } 148 | } 149 | 150 | private void Insert(Window window) 151 | { 152 | window.DialogResult = true; 153 | } 154 | #endregion 155 | } 156 | -------------------------------------------------------------------------------- /CCodeAI/Views/AvalonEditBehaviour.cs: -------------------------------------------------------------------------------- 1 | using ICSharpCode.AvalonEdit; 2 | using Microsoft.Xaml.Behaviors; 3 | using System; 4 | using System.Windows; 5 | 6 | namespace CCodeAI.Views; 7 | 8 | public sealed class AvalonEditBehavior : Behavior 9 | { 10 | public static readonly DependencyProperty CodeTextProperty = 11 | DependencyProperty.Register("CodeText", typeof(string), typeof(AvalonEditBehavior), 12 | new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, PropertyChangedCallback)); 13 | 14 | public string CodeText 15 | { 16 | get { return (string)GetValue(CodeTextProperty); } 17 | set { SetValue(CodeTextProperty, value); } 18 | } 19 | 20 | protected override void OnAttached() 21 | { 22 | base.OnAttached(); 23 | if (AssociatedObject != null) 24 | AssociatedObject.TextChanged += AssociatedObjectOnTextChanged; 25 | } 26 | 27 | protected override void OnDetaching() 28 | { 29 | base.OnDetaching(); 30 | if (AssociatedObject != null) 31 | AssociatedObject.TextChanged -= AssociatedObjectOnTextChanged; 32 | } 33 | 34 | private void AssociatedObjectOnTextChanged(object sender, EventArgs eventArgs) 35 | { 36 | if (sender is TextEditor textEditor) 37 | { 38 | if (textEditor.Document != null) 39 | CodeText = textEditor.Document.Text; 40 | } 41 | } 42 | 43 | private static void PropertyChangedCallback( 44 | DependencyObject dependencyObject, 45 | DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) 46 | { 47 | var behavior = dependencyObject as AvalonEditBehavior; 48 | if (behavior.AssociatedObject != null) 49 | { 50 | var editor = behavior.AssociatedObject; 51 | if (editor.Document != null) 52 | { 53 | var caretOffset = editor.CaretOffset; 54 | editor.Document.Text = dependencyPropertyChangedEventArgs.NewValue.ToString(); 55 | if (caretOffset <= editor.Document.Text.Length) editor.CaretOffset = caretOffset; 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /CCodeAI/Views/ChatDataTemplateSelection.cs: -------------------------------------------------------------------------------- 1 | using CCodeAI.Models; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | 5 | namespace CCodeAI.Views; 6 | 7 | internal class ChatDataTemplateSelector:DataTemplateSelector 8 | { 9 | public override DataTemplate SelectTemplate(object item, DependencyObject container) 10 | { 11 | if (item == null) { return null; } 12 | 13 | return item switch 14 | { 15 | WelcomeChatData => WelcomeChatDataTemplate, 16 | _ => ChatDataTemplate 17 | }; 18 | } 19 | 20 | public DataTemplate WelcomeChatDataTemplate { get; set; } 21 | 22 | public DataTemplate ChatDataTemplate { get; set; } 23 | } 24 | -------------------------------------------------------------------------------- /CCodeAI/Views/CodeGenWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using CCodeAI.ViewModels; 2 | using Microsoft.VisualStudio.Shell.Interop; 3 | using System.Windows; 4 | 5 | namespace CCodeAI.Views; 6 | 7 | /// 8 | /// CodeGenWindow.xaml 的交互逻辑 9 | /// 10 | public partial class CodeGenWindow : Window 11 | { 12 | public CodeGenWindow( 13 | string language, 14 | string input = "", 15 | bool justCopy = false) 16 | { 17 | InitializeComponent(); 18 | 19 | DataContext = VM = new CodeGenWindowViewModel(language) 20 | { 21 | Input = input, 22 | DialogResult = (b) => { DialogResult = b; }, 23 | JustCopy = justCopy, 24 | }; 25 | } 26 | 27 | /// 28 | /// Generated code by LLM Model 29 | /// 30 | public string ResponseText => VM.Output; 31 | 32 | internal CodeGenWindowViewModel VM { get; } 33 | } 34 | -------------------------------------------------------------------------------- /CCodeAI/en/Extension.vsixlangpack: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | CCodeAI 5 | Help you understand and optimize the code 6 | 7 | -------------------------------------------------------------------------------- /CCodeAI/source.extension.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------------------------ 2 | // 3 | // This file was generated by VSIX Synchronizer 4 | // 5 | // ------------------------------------------------------------------------------ 6 | namespace CCodeAI 7 | { 8 | internal sealed partial class Vsix 9 | { 10 | public const string Id = "CCode.ee1b2319-5a85-4ecc-bc6e-4264f753f94e"; 11 | public const string Name = "CCodeAI"; 12 | public const string Description = @"Help you understand and optimize the code"; 13 | public const string Language = "en-US"; 14 | public const string Version = "2023.514.1"; 15 | public const string Author = "TimChen"; 16 | public const string Tags = "ChatGPT, Copilot, OpenAI, GPT4, GPT, Copilot X, Github Copilot"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CCodeAI/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CCodeAI 6 | Help you understand and optimize the code 7 | https://github.com/TimChen44/CCodeAI 8 | https://github.com/TimChen44/CCodeAI 9 | https://github.com/TimChen44/CCodeAI 10 | Resources\Icon.png 11 | Resources\Icon.png 12 | ChatGPT, Copilot, OpenAI, GPT4, GPT, Copilot X, Github Copilot 13 | 14 | 15 | 16 | x86 17 | 18 | 19 | x86 20 | 21 | 22 | x86 23 | 24 | 25 | amd64 26 | 27 | 28 | amd64 29 | 30 | 31 | amd64 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /CCodeAI/zh/Extension.vsixlangpack: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | CCodeAI 5 | 帮助你理解和优化代码 6 | 7 | -------------------------------------------------------------------------------- /ChangLog.md: -------------------------------------------------------------------------------- 1 | # Update Log 2 | 3 | ### 2023.430.1 4 | 5 | - Added adaptive VS theme color 6 | 7 | ### 2023.12.0408 8 | 9 | - Added code continuation based on comments 10 | - Added support for cs, js, ts, and cpp files for question answering 11 | - Added exception handling to avoid plugin crashes 12 | 13 | ### 2023.6.329 14 | 15 | - Adjusted smooth scrolling 16 | - Added record clearing feature -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 TimChen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MdXaml.Test/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | -------------------------------------------------------------------------------- /MdXaml.Test/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace MdXaml.Test 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /MdXaml.Test/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /MdXaml.Test/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /MdXaml.Test/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Windows; 3 | 4 | namespace MdXaml.Test; 5 | 6 | /// 7 | /// Interaction logic for MainWindow.xaml 8 | /// 9 | public partial class MainWindow : Window 10 | { 11 | public MainWindow() 12 | { 13 | InitializeComponent(); 14 | Markdown = File.ReadAllText("./Readme.md"); 15 | DataContext = this; 16 | } 17 | 18 | public string Markdown { get; set; } 19 | } 20 | -------------------------------------------------------------------------------- /MdXaml.Test/MdXaml.Test.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net48 6 | enable 7 | true 8 | latest 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Always 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /MdXaml.Test/Readme.md: -------------------------------------------------------------------------------- 1 | 遇事不决,问AI 2 | 3 | # Head1 4 | 5 | Text 6 | 中文 7 | 8 | ## Head2 9 | 10 | Text 11 | 中文 12 | 13 | > Note 14 | 15 | ### Head3 16 | 17 | Test 18 | 中文 19 | 20 | #### Head4 21 | 22 | Test 23 | 中文 24 | 25 | ```c# 26 | public class Test 27 | { 28 | public void Test() 29 | { 30 | int a = 5; 31 | } 32 | } 33 | ``` -------------------------------------------------------------------------------- /MdXaml/Controls/ExtendTextEditor.xaml.cs: -------------------------------------------------------------------------------- 1 | using Community.VisualStudio.Toolkit; 2 | using ICSharpCode.AvalonEdit; 3 | using Microsoft.VisualStudio.PlatformUI; 4 | using Microsoft.VisualStudio.Shell; 5 | using Microsoft.VisualStudio.Text; 6 | using Microsoft.VisualStudio.Threading; 7 | using System; 8 | using System.Threading.Tasks; 9 | using System.Windows; 10 | using System.Windows.Controls; 11 | 12 | namespace MdXaml.Controls; 13 | 14 | /// 15 | /// ExtendTextEditor.xaml 的交互逻辑 16 | /// 17 | public partial class ExtendTextEditor : UserControl 18 | { 19 | private DelegateCommand? _copyCommand; 20 | private DelegateCommand? _insertCommand; 21 | 22 | public ExtendTextEditor() 23 | { 24 | InitializeComponent(); 25 | DataContext = this; 26 | } 27 | 28 | public string Text 29 | { 30 | get => _editor.Text; set 31 | { 32 | _editor.Text = value; 33 | } 34 | } 35 | 36 | public TextEditor TextEditor => _editor; 37 | 38 | public DelegateCommand CopyCommand => _copyCommand ??= new DelegateCommand(Copy); 39 | 40 | public DelegateCommand InsertCommand => _insertCommand ??= new DelegateCommand(InsertAsync); 41 | 42 | private async void InsertAsync() 43 | { 44 | try 45 | { 46 | //check 47 | if (string.IsNullOrWhiteSpace(Text)) { return; } 48 | 49 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 50 | 51 | //get document view 52 | DocumentView? docView = await VS.Documents.GetActiveDocumentViewAsync(); 53 | if (docView == null) return; 54 | if (docView?.TextView == null) return; //not a text window 55 | 56 | //get selection 57 | var selection = docView?.TextView?.Selection; 58 | if (selection == null) return; 59 | 60 | //insert code block 61 | var startIndex = selection.End.Position; 62 | ITextSnapshot? textSnapshot = docView?.TextBuffer?.Insert(startIndex, Text); 63 | 64 | if(textSnapshot == null) return; 65 | 66 | //Formart text 67 | docView.TextView.Selection.Select(new SnapshotSpan(textSnapshot, new Span(startIndex, Text.Length)),false); 68 | await VS.Commands.ExecuteAsync(Microsoft.VisualStudio.VSConstants.VSStd2KCmdID.FORMATSELECTION); 69 | } 70 | catch (Exception ex) 71 | { 72 | await VS.MessageBox.ShowErrorAsync(ex.Message); 73 | } 74 | } 75 | 76 | private void Copy(object obj) 77 | { 78 | try 79 | { 80 | Clipboard.SetDataObject(_editor.Text); 81 | } 82 | catch (Exception ex) 83 | { 84 | VS.MessageBox.ShowError(ex.Message); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /MdXaml/DocumentAnchor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Text.RegularExpressions; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Automation; 9 | using System.Windows.Controls; 10 | using System.Windows.Documents; 11 | 12 | namespace MdXaml 13 | { 14 | public class DocumentAnchor 15 | { 16 | public static readonly DependencyProperty HyperlinkAnchorProperty = 17 | DependencyProperty.RegisterAttached( 18 | "HyperlinkAnchor", 19 | typeof(string), 20 | typeof(DocumentAnchor), 21 | new PropertyMetadata(null)); 22 | 23 | public static void SetHyperlinkAnchor(DependencyObject dobj, string text) 24 | => dobj.SetValue(HyperlinkAnchorProperty, text); 25 | 26 | public static string GetHyperlinkAnchor(DependencyObject dobj) 27 | => (string)dobj.GetValue(HyperlinkAnchorProperty); 28 | 29 | public static TextElement? FindAnchor(FlowDocument doc, string identifier) 30 | { 31 | var generatedId = new HashSet(); 32 | 33 | foreach (var element in WalkElement(doc)) 34 | { 35 | if (GetHyperlinkAnchor(element) is string anchorText) 36 | { 37 | if (identifier == anchorText) 38 | return element; 39 | } 40 | 41 | if (element is Paragraph paragraph 42 | && paragraph.Tag is string tagText 43 | && tagText.StartsWith("Heading")) 44 | { 45 | var paragraphText = GetTextFrom(paragraph); 46 | paragraphText = GenerateId(paragraphText, generatedId); 47 | 48 | if (identifier == paragraphText) 49 | return element; 50 | } 51 | } 52 | 53 | return null; 54 | } 55 | 56 | private static IEnumerable WalkElement(FlowDocument doc) 57 | { 58 | TextPointer element = doc.ContentStart; 59 | while (element is not null) 60 | { 61 | if (element.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart) 62 | if (element.Parent is TextElement textElement) 63 | yield return textElement; 64 | 65 | element = element.GetNextContextPosition(LogicalDirection.Forward); 66 | } 67 | } 68 | 69 | 70 | private static string GenerateId(string paragraphText, HashSet generated) 71 | { 72 | // https://github.com/xoofx/markdig/blob/master/src/Markdig.Tests/Specs/AutoIdentifierSpecs.md 73 | 74 | var buff = new StringBuilder(); 75 | 76 | foreach (var c in paragraphText) 77 | { 78 | if (char.IsLetter(c)) 79 | { 80 | buff.Append(Char.ToLower(c)); 81 | } 82 | else if (buff.Length > 0) 83 | { 84 | if (char.IsDigit(c)) 85 | { 86 | buff.Append(Char.ToLower(c)); 87 | } 88 | else if (c == '.' || c == '-' || c == '_') 89 | { 90 | if (buff[buff.Length - 1] == c) 91 | continue; 92 | 93 | buff.Append(c); 94 | } 95 | else if (c == ' ') 96 | { 97 | if (buff[buff.Length - 1] == '-') 98 | continue; 99 | 100 | buff.Append('-'); 101 | } 102 | } 103 | } 104 | 105 | while (buff.Length > 0 && !char.IsLetterOrDigit(buff[buff.Length - 1])) 106 | buff.Length--; 107 | 108 | if (buff.Length == 0) 109 | buff.Append("section"); 110 | 111 | 112 | if (generated.Add(buff.ToString())) 113 | { 114 | return buff.ToString(); 115 | } 116 | else 117 | { 118 | buff.Append('-'); 119 | 120 | var lenBack = buff.Length; 121 | 122 | foreach (var num in Enumerable.Range(1, 100000)) 123 | { 124 | buff.Append(num); 125 | 126 | if (generated.Add(buff.ToString())) 127 | return buff.ToString(); 128 | 129 | buff.Length = lenBack; 130 | } 131 | 132 | return buff.ToString(); 133 | } 134 | } 135 | 136 | 137 | private static string GetTextFrom(Paragraph paragraph) 138 | { 139 | var builder = new StringBuilder(); 140 | 141 | foreach (var child in paragraph.Inlines) 142 | GetTextFrom(child, builder); 143 | 144 | return builder.ToString(); 145 | 146 | static void GetTextFrom(Inline inline, StringBuilder outto) 147 | { 148 | if (inline is Run run) 149 | { 150 | outto.Append(run.Text); 151 | } 152 | else if (inline is LineBreak) 153 | { 154 | outto.AppendLine(); 155 | } 156 | else if (inline is Span span) 157 | { 158 | foreach (var descendant in span.Inlines) 159 | GetTextFrom(descendant, outto); 160 | } 161 | } 162 | } 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /MdXaml/EmojiTable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | using System.Collections.Generic; 4 | using System.Diagnostics.CodeAnalysis; 5 | using System.IO; 6 | using System.Reflection; 7 | using System.Text; 8 | 9 | #if MIG_FREE 10 | namespace Markdown.Xaml 11 | #else 12 | namespace MdXaml 13 | #endif 14 | { 15 | public static class EmojiTable 16 | { 17 | private static ConcurrentDictionary? s_keywords; 18 | 19 | static EmojiTable() 20 | { 21 | s_keywords = LoadTxt(); 22 | } 23 | 24 | 25 | /* 26 | Workaround for Visual Studio Xaml Designer. 27 | When you open MarkdownStyle from Xaml Designer, 28 | A null error occurs. Perhaps static constructor is not executed. 29 | */ 30 | static ConcurrentDictionary LoadTxt() 31 | { 32 | #if MIG_FREE 33 | var resourceName = "Markdown.Xaml.EmojiTable.txt"; 34 | #else 35 | var resourceName = "MdXaml.EmojiTable.txt"; 36 | #endif 37 | var dic = new ConcurrentDictionary(); 38 | 39 | Assembly asm = Assembly.GetCallingAssembly(); 40 | using var stream = asm.GetManifestResourceStream(resourceName); 41 | if (stream is null) 42 | throw new InvalidOperationException($"fail to load '{resourceName}'"); 43 | 44 | using var reader = new StreamReader(stream, true); 45 | 46 | string? line; 47 | while ((line = reader.ReadLine()) != null) 48 | { 49 | var elms = line.Split('\t'); 50 | dic[elms[1]] = elms[0]; 51 | } 52 | 53 | return dic; 54 | } 55 | 56 | public static bool TryGet( 57 | string keyword, 58 | #if !NETFRAMEWORK 59 | [MaybeNullWhen(false)] 60 | #endif 61 | out string emoji) 62 | { 63 | if (s_keywords is null) s_keywords = LoadTxt(); 64 | return s_keywords.TryGetValue(keyword, out emoji); 65 | } 66 | 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /MdXaml/EnumerableExt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | #if MIG_FREE 6 | namespace Markdown.Xaml 7 | #else 8 | namespace MdXaml 9 | #endif 10 | { 11 | internal static class EnumerableExt 12 | { 13 | public static T[] Empty() => EmptyArray.Value; 14 | } 15 | 16 | internal class EmptyArray 17 | { 18 | // net45 dosen't have Array.Empty() 19 | #pragma warning disable CA1825 20 | public static T[] Value = new T[0]; 21 | #pragma warning restore CA1825 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /MdXaml/Ext/AlphaExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Markup; 5 | using System.Windows.Media; 6 | 7 | #if MIG_FREE 8 | namespace Markdown.Xaml.Ext 9 | #else 10 | namespace MdXaml.Ext 11 | #endif 12 | { 13 | class AlphaExtension : MarkupExtension 14 | { 15 | private readonly string _key; 16 | private readonly float _power; 17 | 18 | public Type? TargetType { set; get; } 19 | 20 | public AlphaExtension(string key) : this(key, 1f) { } 21 | 22 | public AlphaExtension(string key, float power) 23 | { 24 | this._key = key; 25 | this._power = power; 26 | } 27 | 28 | public override object ProvideValue(IServiceProvider serviceProvider) 29 | { 30 | return new Binding(_key) 31 | { 32 | RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor) { AncestorType = TargetType }, 33 | Converter = new AlphaConverter(_power) 34 | }; 35 | } 36 | 37 | class AlphaConverter : IValueConverter 38 | { 39 | readonly float Power; 40 | 41 | public AlphaConverter(float power) 42 | { 43 | this.Power = power; 44 | } 45 | 46 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 47 | { 48 | Color baseColor; 49 | 50 | if (value is SolidColorBrush cBrush) 51 | { 52 | baseColor = cBrush.Color; 53 | } 54 | else 55 | { 56 | baseColor = Colors.Black; 57 | } 58 | 59 | var srcAlpha = baseColor.A / 255f; 60 | var newAlpha = srcAlpha * Power; 61 | 62 | var newColor = Color.FromArgb((byte)(255 * newAlpha), baseColor.R, baseColor.G, baseColor.B); 63 | 64 | return new SolidColorBrush(newColor); 65 | } 66 | 67 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 68 | { 69 | throw new NotImplementedException(); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /MdXaml/Ext/BrightnessExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Text; 5 | using System.Windows.Data; 6 | using System.Windows.Markup; 7 | using System.Windows.Media; 8 | 9 | #if MIG_FREE 10 | namespace Markdown.Xaml.Ext 11 | #else 12 | namespace MdXaml.Ext 13 | #endif 14 | { 15 | class BrightnessExtension : MarkupExtension 16 | { 17 | public Color Base { get; } 18 | public string Foreground { get; } 19 | public Type? TargetType { set; get; } 20 | 21 | public BrightnessExtension(Color @base, string foreground) 22 | { 23 | this.Base = @base; 24 | this.Foreground = foreground; 25 | } 26 | 27 | public override object ProvideValue(IServiceProvider serviceProvider) 28 | { 29 | return new Binding(Foreground) 30 | { 31 | RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor) { AncestorType = TargetType }, 32 | Converter = new BrightnessConverter(Base) 33 | }; 34 | } 35 | 36 | class BrightnessConverter : IValueConverter 37 | { 38 | readonly Color Base; 39 | 40 | public BrightnessConverter(Color @base) 41 | { 42 | Base = @base; 43 | } 44 | 45 | 46 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 47 | { 48 | Color foregroundColor; 49 | 50 | if (value is SolidColorBrush cBrush) 51 | { 52 | foregroundColor = cBrush.Color; 53 | } 54 | else 55 | { 56 | foregroundColor = Colors.Black; 57 | } 58 | 59 | var newColor = Base.Brightness(foregroundColor); 60 | return new SolidColorBrush(newColor); 61 | } 62 | 63 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 64 | { 65 | throw new NotImplementedException(); 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /MdXaml/Ext/ColorExt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Windows.Media; 5 | 6 | #if MIG_FREE 7 | namespace Markdown.Xaml.Ext 8 | #else 9 | namespace MdXaml.Ext 10 | #endif 11 | { 12 | static class ColorExt 13 | { 14 | public static Color Brightness(this Color color, Color fore) 15 | { 16 | var foreMax = Math.Max(fore.R, Math.Max(fore.G, fore.B)); 17 | var tgtHsv = new HSV(color); 18 | 19 | int newValue = tgtHsv.Value + foreMax; 20 | int newSaturation = tgtHsv.Saturation; 21 | if (newValue > 255) 22 | { 23 | var newSaturation2 = newSaturation - (newValue - 255); 24 | newValue = 255; 25 | 26 | var sChRtLm = (color.R >= color.G && color.R >= color.B) ? 0.95f * 0.7f : 27 | (color.G >= color.R && color.G >= color.B) ? 0.95f : 28 | 0.95f * 0.5f; 29 | 30 | var sChRt = Math.Max(sChRtLm, newSaturation2 / (float)newSaturation); 31 | if (Single.IsInfinity(sChRt)) sChRt = sChRtLm; 32 | 33 | newSaturation = (int)(newSaturation * sChRt); 34 | } 35 | 36 | tgtHsv.Value = (byte)newValue; 37 | tgtHsv.Saturation = (byte)newSaturation; 38 | 39 | var newColor = tgtHsv.ToColor(); 40 | return newColor; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /MdXaml/Ext/FontSizeScaleExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Text; 5 | using System.Windows.Controls; 6 | using System.Windows.Data; 7 | using System.Windows.Markup; 8 | 9 | #if MIG_FREE 10 | namespace Markdown.Xaml.Ext 11 | #else 12 | namespace MdXaml.Ext 13 | #endif 14 | { 15 | class FontSizeScaleExtension : MarkupExtension 16 | { 17 | private readonly float power; 18 | 19 | public Type? TargetType { set; get; } 20 | 21 | public FontSizeScaleExtension(float power) 22 | { 23 | this.power = power; 24 | } 25 | 26 | public override object ProvideValue(IServiceProvider serviceProvider) 27 | { 28 | return new Binding(nameof(Control.FontSize)) 29 | { 30 | RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor) { AncestorType = TargetType }, 31 | Converter = new FontSizeScaleConverter(power) 32 | }; 33 | } 34 | 35 | class FontSizeScaleConverter : IValueConverter 36 | { 37 | readonly float Power; 38 | 39 | public FontSizeScaleConverter(float power) 40 | { 41 | this.Power = power; 42 | } 43 | 44 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 45 | { 46 | return System.Convert.ToSingle(value) * Power; 47 | } 48 | 49 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 50 | { 51 | throw new NotImplementedException(); 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /MdXaml/Ext/HSV.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Media; 3 | 4 | #if MIG_FREE 5 | namespace Markdown.Xaml.Ext 6 | #else 7 | namespace MdXaml.Ext 8 | #endif 9 | { 10 | struct HSV 11 | { 12 | public int Hue; 13 | public byte Saturation; 14 | public byte Value; 15 | 16 | public HSV(Color color) 17 | { 18 | int max = Math.Max(color.R, Math.Max(color.G, color.B)); 19 | int min = Math.Min(color.R, Math.Min(color.G, color.B)); 20 | int div = max - min; 21 | 22 | if (div == 0) 23 | { 24 | Hue = 0; 25 | Saturation = 0; 26 | } 27 | else 28 | { 29 | Hue = 30 | (min == color.B) ? 60 * (color.G - color.R) / div + 60 : 31 | (min == color.R) ? 60 * (color.B - color.G) / div + 180 : 32 | 60 * (color.R - color.B) / div + 300; 33 | Saturation = (byte)div; 34 | } 35 | 36 | Value = (byte)max; 37 | } 38 | 39 | public Color ToColor() 40 | { 41 | if (Hue == 0 && Saturation == 0) 42 | { 43 | return Color.FromRgb(Value, Value, Value); 44 | } 45 | 46 | //byte c = Saturation; 47 | 48 | int HueInt = Hue / 60; 49 | 50 | int x = (int)(Saturation * (1 - Math.Abs((Hue / 60f) % 2 - 1))); 51 | 52 | Color FromRgb(int r, int g, int b) 53 | => Color.FromRgb((byte)r, (byte)g, (byte)b); 54 | 55 | 56 | switch (Hue / 60) 57 | { 58 | default: 59 | case 0: return FromRgb(Value, Value - Saturation + x, Value - Saturation); 60 | case 1: return FromRgb(Value - Saturation + x, Value, Value - Saturation); 61 | case 2: return FromRgb(Value - Saturation, Value, Value - Saturation + x); 62 | case 3: return FromRgb(Value - Saturation, Value - Saturation + x, Value); 63 | case 4: return FromRgb(Value - Saturation + x, Value - Saturation, Value); 64 | case 5: 65 | case 6: return FromRgb(Value, Value - Saturation, Value - Saturation + x); 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /MdXaml/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | // This file is used by Code Analysis to maintain SuppressMessage 2 | // attributes that are applied to this project. 3 | // Project-level suppressions either have no target or are given 4 | // a specific target and scoped to a namespace, type, member, etc. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | [assembly: SuppressMessage("Style", "IDE0056:インデックス演算子を使用", Justification = "<保留中>", Scope = "member", Target = "~M:Markdown.Xaml.Markdown.TableEvalutor(System.Text.RegularExpressions.Match)~System.Windows.Documents.Block")] 9 | -------------------------------------------------------------------------------- /MdXaml/LinkActions/DiaplayCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Windows.Input; 4 | 5 | #if MIG_FREE 6 | using Markdown.Xaml; 7 | 8 | namespace Markdown.Xaml.LinkActions 9 | #else 10 | using MdXaml; 11 | 12 | namespace MdXaml.LinkActions 13 | #endif 14 | { 15 | // set `public` access level for #29. 16 | public class DiaplayCommand : ICommand 17 | { 18 | private MarkdownScrollViewer Owner; 19 | private bool OpenBrowserWithAbsolutePath; 20 | 21 | public DiaplayCommand(MarkdownScrollViewer owner, bool openBrowserWithAbsolutePath) 22 | { 23 | Owner = owner; 24 | OpenBrowserWithAbsolutePath = openBrowserWithAbsolutePath; 25 | } 26 | 27 | public event EventHandler? CanExecuteChanged; 28 | 29 | private bool _isExecutable = true; 30 | public bool IsExecutable 31 | { 32 | get => _isExecutable; 33 | set 34 | { 35 | if (_isExecutable != value) 36 | { 37 | _isExecutable = value; 38 | CanExecuteChanged?.Invoke(this, new EventArgs()); 39 | } 40 | } 41 | } 42 | 43 | public bool CanExecute(object? parameter) => _isExecutable; 44 | 45 | public void Execute(object? parameter) 46 | { 47 | var path = parameter?.ToString(); 48 | if (path is null) throw new ArgumentNullException(nameof(parameter)); 49 | 50 | var isAbs = Uri.IsWellFormedUriString(path, UriKind.Absolute); 51 | 52 | if (OpenBrowserWithAbsolutePath & isAbs) 53 | { 54 | Process.Start(new ProcessStartInfo(path) 55 | { 56 | UseShellExecute = true, 57 | Verb = "open" 58 | }); 59 | } 60 | else if (isAbs) 61 | { 62 | Owner.Open(new Uri(path), true); 63 | } 64 | else 65 | { 66 | Owner.Open(new Uri(path, UriKind.Relative), true); 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /MdXaml/LinkActions/FlowDocumentJumpAnchorIfNecessary.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Documents; 8 | using System.Windows.Input; 9 | 10 | namespace MdXaml.LinkActions 11 | { 12 | // set `public` access level for #29. 13 | public class FlowDocumentJumpAnchorIfNecessary : ICommand 14 | { 15 | private MarkdownScrollViewer _viewer; 16 | private ICommand _command; 17 | 18 | public event EventHandler? CanExecuteChanged 19 | { 20 | add => _command.CanExecuteChanged += value; 21 | remove => _command.CanExecuteChanged -= value; 22 | } 23 | 24 | public FlowDocumentJumpAnchorIfNecessary(MarkdownScrollViewer viewer, ICommand defaultAct) 25 | { 26 | _viewer = viewer; 27 | _command = defaultAct; 28 | } 29 | 30 | public bool CanExecute(object? parameter) => _command.CanExecute(parameter); 31 | 32 | public void Execute(object? parameter) 33 | { 34 | if (parameter is string linkText && linkText.StartsWith("#")) 35 | { 36 | var identifier = linkText.Substring(1); 37 | if (_viewer.Document is null) 38 | { 39 | Debug.Print($"MarkdownScrollViewer is uninitialized."); 40 | return; 41 | } 42 | 43 | var anchor = DocumentAnchor.FindAnchor(_viewer.Document, identifier); 44 | 45 | if (anchor is null) 46 | { 47 | Debug.Print($"Not found linkanchor: {identifier}"); 48 | return; 49 | } 50 | 51 | anchor.BringIntoView(); 52 | } 53 | else _command.Execute(parameter); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /MdXaml/LinkActions/OpenCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Windows.Input; 4 | 5 | #if MIG_FREE 6 | namespace Markdown.Xaml.LinkActions 7 | #else 8 | namespace MdXaml.LinkActions 9 | #endif 10 | { 11 | // set `public` access level for #29. 12 | public class OpenCommand : ICommand 13 | { 14 | public event EventHandler? CanExecuteChanged; 15 | 16 | private bool _isExecutable = true; 17 | public bool IsExecutable 18 | { 19 | get => _isExecutable; 20 | set 21 | { 22 | if (_isExecutable != value) 23 | { 24 | _isExecutable = value; 25 | CanExecuteChanged?.Invoke(this, new EventArgs()); 26 | } 27 | } 28 | } 29 | 30 | public bool CanExecute(object? parameter) => _isExecutable; 31 | 32 | public void Execute(object? parameter) 33 | { 34 | var path = parameter?.ToString(); 35 | if (path is null) throw new ArgumentNullException(nameof(parameter)); 36 | 37 | Process.Start(new ProcessStartInfo(path) 38 | { 39 | UseShellExecute = true, 40 | Verb = "open" 41 | }); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /MdXaml/MarkdownStyle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Windows; 4 | using System.Windows.Documents; 5 | using System.Windows.Markup; 6 | 7 | #if MIG_FREE 8 | namespace Markdown.Xaml 9 | #else 10 | namespace MdXaml 11 | #endif 12 | { 13 | public static class MarkdownStyle 14 | { 15 | private const string DocumentStyleStandard = "DocumentStyleStandard"; 16 | private const string DocumentStyleCompact = "DocumentStyleCompact"; 17 | private const string DocumentStyleGithubLike = "DocumentStyleGithubLike"; 18 | private const string DocumentStyleSasabune = "DocumentStyleSasabune"; 19 | private const string DocumentStyleSasabuneStandard = "DocumentStyleSasabuneStandard"; 20 | private const string DocumentStyleSasabuneCompact = "DocumentStyleSasabuneCompact"; 21 | 22 | static MarkdownStyle() 23 | { 24 | var resources = LoadDictionary(); 25 | _standard = (Style)resources[DocumentStyleStandard]; 26 | _compact = (Style)resources[DocumentStyleCompact]; 27 | _githublike = (Style)resources[DocumentStyleGithubLike]; 28 | _sasabune = (Style)resources[DocumentStyleSasabune]; 29 | _sasabuneStandard = (Style)resources[DocumentStyleSasabuneStandard]; 30 | _sasabuneCompact = (Style)resources[DocumentStyleSasabuneCompact]; 31 | } 32 | 33 | static ResourceDictionary LoadDictionary() 34 | { 35 | #if MIG_FREE 36 | var resourceName = "/Markdown.Xaml;component/MarkdownMigFree.Style.xaml"; 37 | #else 38 | /* 39 | Workaround for XamlParseException. 40 | When you don't load 'ICSharpCode.AvalonEdit.dll', 41 | XamlReader fail to read xmlns:avalonEdit="http://icsharpcode.net..." 42 | */ 43 | var txtedit = typeof(ICSharpCode.AvalonEdit.TextEditor); 44 | txtedit.ToString(); 45 | 46 | var resourceName = "/MdXaml;component/Markdown.Style.xaml"; 47 | #endif 48 | 49 | var resourceUri = new Uri(resourceName, UriKind.RelativeOrAbsolute); 50 | return (ResourceDictionary)Application.LoadComponent(resourceUri); 51 | } 52 | 53 | /* 54 | Workaround for Visual Studio Xaml Designer. 55 | When you open MarkdownStyle from Xaml Designer, 56 | A null error occurs. Perhaps static constructor is not executed. 57 | */ 58 | static Style LoadXaml(string name) 59 | { 60 | return (Style)LoadDictionary()[name]; 61 | } 62 | 63 | private static readonly Style _standard; 64 | private static readonly Style _compact; 65 | private static readonly Style _githublike; 66 | private static readonly Style _sasabune; 67 | private static readonly Style _sasabuneCompact; 68 | private static readonly Style _sasabuneStandard; 69 | 70 | public static Style Standard => _standard is null ? LoadXaml(DocumentStyleStandard) : _standard; 71 | public static Style Compact => _compact is null ? LoadXaml(DocumentStyleCompact) : _compact; 72 | public static Style GithubLike => _githublike is null ? LoadXaml(DocumentStyleGithubLike) : _githublike; 73 | public static Style Sasabune => _sasabune is null ? LoadXaml(DocumentStyleSasabune) : _sasabune; 74 | public static Style SasabuneStandard => _sasabuneStandard is null ? LoadXaml(DocumentStyleSasabuneStandard) : _sasabuneStandard; 75 | public static Style SasabuneCompact => _sasabuneCompact is null ? LoadXaml(DocumentStyleSasabuneCompact) : _sasabuneCompact; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /MdXaml/MdXaml.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | Library 4 | net48 5 | true 6 | MdXaml 7 | 1.18.1 8 | Bevan Arps(original); whistyun 9 | Markdown XAML processor 10 | Copyright (c) 2010 Bevan Arps, 2020 whistyun 11 | https://github.com/whistyun/MdXaml 12 | MIT 13 | MdXaml.md 14 | Markdown WPF Xaml FlowDocument 15 | latest 16 | enable 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /MdXaml/SimpleBlockParser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Net.Cache; 6 | using System.Text; 7 | using System.Text.RegularExpressions; 8 | using System.Threading; 9 | using System.Windows; 10 | using System.Windows.Controls; 11 | using System.Windows.Data; 12 | using System.Windows.Documents; 13 | using System.Windows.Input; 14 | using System.Windows.Markup; 15 | using System.Windows.Media; 16 | using System.Windows.Media.Imaging; 17 | using MdXaml.Plugins; 18 | 19 | #if MIG_FREE 20 | namespace Markdown.Xaml 21 | #else 22 | namespace MdXaml 23 | #endif 24 | { 25 | internal delegate Block InternalConverter(Match matchResult, bool supportTextAlignment); 26 | 27 | internal static class SimpleBlockParser 28 | { 29 | private sealed class Parser1 : IBlockParser 30 | { 31 | private readonly InternalConverter _converter; 32 | 33 | public Regex FirstMatchPattern { get; } 34 | 35 | public Parser1(Regex firstMatch, InternalConverter converter) 36 | { 37 | FirstMatchPattern = firstMatch; 38 | _converter = converter; 39 | } 40 | 41 | public IEnumerable Parse(string text, Match firstMatch, bool supportAlignment, IMarkdown engine, out int parseTextBegin, out int parseTextEnd) 42 | { 43 | parseTextBegin = firstMatch.Index; 44 | parseTextEnd = firstMatch.Index + firstMatch.Length; 45 | return new[] { _converter(firstMatch, supportAlignment) }; 46 | } 47 | } 48 | 49 | private sealed class Parser2 : IBlockParser 50 | { 51 | private readonly Func> _converter; 52 | 53 | public Regex FirstMatchPattern { get; } 54 | 55 | public Parser2(Regex firstMatch, Func> converter) 56 | { 57 | FirstMatchPattern = firstMatch; 58 | _converter = converter; 59 | } 60 | 61 | public IEnumerable Parse(string text, Match firstMatch, bool supportAlignment, IMarkdown engine, out int parseTextBegin, out int parseTextEnd) 62 | { 63 | parseTextBegin = firstMatch.Index; 64 | parseTextEnd = firstMatch.Index + firstMatch.Length; 65 | return _converter(firstMatch); 66 | } 67 | } 68 | 69 | private sealed class Parser3 : IBlockParser 70 | { 71 | private readonly Func _converter; 72 | 73 | public Regex FirstMatchPattern { get; } 74 | 75 | public Parser3(Regex firstMatch, Func converter) 76 | { 77 | FirstMatchPattern = firstMatch; 78 | _converter = converter; 79 | } 80 | 81 | public IEnumerable Parse(string text, Match firstMatch, bool supportAlignment, IMarkdown engine, out int parseTextBegin, out int parseTextEnd) 82 | { 83 | parseTextBegin = firstMatch.Index; 84 | parseTextEnd = firstMatch.Index + firstMatch.Length; 85 | return new[] { _converter(firstMatch) }; 86 | } 87 | } 88 | 89 | public static IBlockParser New(Regex pattern, InternalConverter converter) 90 | => new Parser1(pattern, converter); 91 | 92 | public static IBlockParser New(Regex pattern, Func> converter) 93 | => new Parser2(pattern, converter); 94 | 95 | public static IBlockParser New(Regex pattern, Func converter) 96 | => new Parser3(pattern, converter); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /MdXaml/SimpleInlineParser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Net.Cache; 6 | using System.Text; 7 | using System.Text.RegularExpressions; 8 | using System.Threading; 9 | using System.Windows; 10 | using System.Windows.Controls; 11 | using System.Windows.Data; 12 | using System.Windows.Documents; 13 | using System.Windows.Input; 14 | using System.Windows.Markup; 15 | using System.Windows.Media; 16 | using System.Windows.Media.Imaging; 17 | using MdXaml.Plugins; 18 | 19 | #if MIG_FREE 20 | namespace Markdown.Xaml 21 | #else 22 | namespace MdXaml 23 | #endif 24 | { 25 | internal static class SimpleInlineParser 26 | { 27 | private sealed class Parser1 : IInlineParser 28 | { 29 | private readonly Func> _converter; 30 | 31 | public Regex FirstMatchPattern { get; } 32 | 33 | public Parser1(Regex firstMatch, Func> converter) 34 | { 35 | FirstMatchPattern = firstMatch; 36 | _converter = converter; 37 | } 38 | 39 | public IEnumerable Parse(string text, Match firstMatch, IMarkdown engine, out int parseTextBegin, out int parseTextEnd) 40 | { 41 | parseTextBegin = firstMatch.Index; 42 | parseTextEnd = firstMatch.Index + firstMatch.Length; 43 | return _converter(firstMatch); 44 | } 45 | } 46 | 47 | private sealed class Parser2 : IInlineParser 48 | { 49 | private readonly Func _converter; 50 | 51 | public Regex FirstMatchPattern { get; } 52 | 53 | public Parser2(Regex firstMatch, Func converter) 54 | { 55 | FirstMatchPattern = firstMatch; 56 | _converter = converter; 57 | } 58 | 59 | public IEnumerable Parse(string text, Match firstMatch, IMarkdown engine, out int parseTextBegin, out int parseTextEnd) 60 | { 61 | parseTextBegin = firstMatch.Index; 62 | parseTextEnd = firstMatch.Index + firstMatch.Length; 63 | return new[] { _converter(firstMatch) }; 64 | } 65 | } 66 | 67 | public static IInlineParser New(Regex pattern, Func> converter) 68 | => new Parser1(pattern, converter); 69 | 70 | public static IInlineParser New(Regex pattern, Func converter) 71 | => new Parser2(pattern, converter); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /MdXaml/TextToFlowDocumentConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics.Contracts; 4 | using System.Globalization; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Data; 10 | 11 | #if MIG_FREE 12 | namespace Markdown.Xaml 13 | #else 14 | namespace MdXaml 15 | #endif 16 | { 17 | public class TextToFlowDocumentConverter : DependencyObject, IValueConverter 18 | { 19 | // Using a DependencyProperty as the backing store for Markdown. This enables animation, styling, binding, etc... 20 | public static readonly DependencyProperty MarkdownProperty = 21 | DependencyProperty.Register("Markdown", typeof(Markdown), typeof(TextToFlowDocumentConverter), new PropertyMetadata(null, MarkdownUpdate)); 22 | 23 | private static void MarkdownUpdate(DependencyObject d, DependencyPropertyChangedEventArgs e) 24 | { 25 | if (e.NewValue is not null) 26 | { 27 | var owner = (TextToFlowDocumentConverter)d; 28 | if (owner.MarkdownStyle != null) 29 | { 30 | ((Markdown)e.NewValue).DocumentStyle = owner.MarkdownStyle; 31 | } 32 | } 33 | } 34 | 35 | private Lazy _markdown; 36 | private Style? _markdownStyle; 37 | 38 | public TextToFlowDocumentConverter() 39 | { 40 | _markdown = new Lazy(MakeMarkdown); 41 | } 42 | 43 | public Markdown Markdown 44 | { 45 | get { return (Markdown)GetValue(MarkdownProperty); } 46 | set { SetValue(MarkdownProperty, value); } 47 | } 48 | public Style? MarkdownStyle 49 | { 50 | get { return _markdownStyle; } 51 | set 52 | { 53 | _markdownStyle = value; 54 | if (value is not null && Markdown is not null) 55 | { 56 | Markdown.DocumentStyle = value; 57 | } 58 | } 59 | } 60 | 61 | /// 62 | /// Converts a value. 63 | /// 64 | /// 65 | /// A converted value. If the method returns null, the valid null value is used. 66 | /// 67 | /// The value produced by the binding source. 68 | /// The type of the binding target property. 69 | /// The converter parameter to use. 70 | /// The culture to use in the converter. 71 | public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) 72 | { 73 | if (value is null) 74 | { 75 | return null; 76 | } 77 | 78 | var text = (string)value; 79 | 80 | var engine = Markdown ?? _markdown.Value; 81 | 82 | return engine.Transform(text); 83 | } 84 | 85 | /// 86 | /// Converts a value. 87 | /// 88 | /// 89 | /// A converted value. If the method returns null, the valid null value is used. 90 | /// 91 | /// The value that is produced by the binding target. 92 | /// The type to convert to. 93 | /// The converter parameter to use. 94 | /// The culture to use in the converter. 95 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 96 | { 97 | throw new NotImplementedException(); 98 | } 99 | 100 | private Markdown MakeMarkdown() 101 | { 102 | var markdown = new Markdown(); 103 | if (MarkdownStyle is not null) 104 | { 105 | markdown.DocumentStyle = MarkdownStyle; 106 | } 107 | return markdown; 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Icon](https://user-images.githubusercontent.com/7581981/236966660-3589cd14-2b41-427d-baad-0c182d156584.png) 2 | 3 | ![Visual Studio Marketplace Version](https://img.shields.io/visual-studio-marketplace/v/TimChen44.CCodeAI) 4 | ![Visual Studio Marketplace Installs](https://img.shields.io/visual-studio-marketplace/i/TimChen44.CCodeAI) 5 | ![Visual Studio Marketplace Rating (Stars)](https://img.shields.io/visual-studio-marketplace/stars/TimChen44.CCodeAI) 6 | 7 | # CCodeAI 8 | 9 | **Build AI Epxerience in Visual Studio** 10 | 11 | A Visual Studio extension that, like GitHub Copilot, enables you to chat with OpenAI and generate code. 12 | Get started with **CCodeAI** is easy, just install the extension in visual studio marketplace, and then you can chat with OpenAI in the Visual Studio. 13 | 14 | ## Use the ability of ChatGPT to assist in coding 15 | 16 | Download:[Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=TimChen44.CCodeAI) 17 | 18 | ## Features 19 | 20 | * Chat 21 | * Explain the code 22 | * Comment the code 23 | * Optimize the code 24 | * Continue writing code according to the comments 25 | * Ask for clarification about the code 26 | 27 | ## Chat in Visual Studio 28 | 29 | [Tools] -> [CCodeAI] -> Chat with OpenAI 30 | 31 |
32 | 33 | ## Generate code 34 | 35 | You can use the CodeGen window to generate code, which includes some preset prompts to help you generate different types of code. 36 | 37 |
38 | 39 | ## Quick Chat 40 | 41 | Of course, you can also quickly start a conversation with AI by selecting the code directly in the editor. 42 | 43 |
44 | 45 | ## Context Menu 46 | 47 | You can also access CCodeAI's features by right-clicking in the editor. 48 | 49 | ![Context Menu](./Resources/ContextMenu.png) 50 | 51 | ## CodeFixes - Under development 52 | 53 | ![](./Resources/CodeFix.png) 54 | 55 | ## TODO 56 | 57 | - [ ] Generating commit messages and generating pull request feedback. 58 | - [ ] More codefixes. 59 | - [ ] Use codex model to generatecode. 60 | - [ ] Code Completion whick like github copilot. 61 | - [ ] Provide annotation translation 62 | 63 | # Update Log 64 | 65 | [ChangLog](./ChangLog.md) 66 | -------------------------------------------------------------------------------- /Resources/Chatpane.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimChen44/CCodeAI/e1bb774904229e04efd6599bee871baca088050a/Resources/Chatpane.png -------------------------------------------------------------------------------- /Resources/CodeFix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimChen44/CCodeAI/e1bb774904229e04efd6599bee871baca088050a/Resources/CodeFix.png -------------------------------------------------------------------------------- /Resources/ContextMenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimChen44/CCodeAI/e1bb774904229e04efd6599bee871baca088050a/Resources/ContextMenu.png -------------------------------------------------------------------------------- /Resources/QuickChat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimChen44/CCodeAI/e1bb774904229e04efd6599bee871baca088050a/Resources/QuickChat.png -------------------------------------------------------------------------------- /Resources/SimpleHistory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimChen44/CCodeAI/e1bb774904229e04efd6599bee871baca088050a/Resources/SimpleHistory.png -------------------------------------------------------------------------------- /publishManifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/vsix-publish", 3 | "categories": [ 4 | "coding", 5 | "visual studio extensions" 6 | ], 7 | "identity": { 8 | "internalName": "CCodeAI" 9 | }, 10 | "overview": "README.md", 11 | "priceCategory": "free", 12 | "publisher": "dududu", 13 | "private": false, 14 | "qna": true, 15 | "repo": "https://github.com/TimChen44/CCodeAI" 16 | } --------------------------------------------------------------------------------