diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 89e42ea..eb74729 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1,2 @@ -custom: ['https://pag.ae/7ZhEY1xKr'] +github: [Code4Delphi] +custom: ['https://code4delphi.com.br/blog/apoie-com-um-cafe/'] diff --git a/Package/DelphiAIDeveloper.dpk b/Package/DelphiAIDeveloper.dpk index 28b6eda..081931c 100644 --- a/Package/DelphiAIDeveloper.dpk +++ b/Package/DelphiAIDeveloper.dpk @@ -115,6 +115,8 @@ contains DelphiAIDev.Test.Client in '..\Src\Test\DelphiAIDev.Test.Client.pas', DelphiAIDev.CodeCompletion.KeyTab in '..\Src\CodeCompletion\DelphiAIDev.CodeCompletion.KeyTab.pas', DelphiAIDev.AI.Response in '..\Src\AI\DelphiAIDev.AI.Response.pas', - DelphiAIDev.AI.Mistral in '..\Src\AI\DelphiAIDev.AI.Mistral.pas'; + DelphiAIDev.AI.Mistral in '..\Src\AI\DelphiAIDev.AI.Mistral.pas', + DelphiAIDev.Utils.Context in '..\Src\Utils\DelphiAIDev.Utils.Context.pas', + DelphiAIDev.Test.ContextDemo in '..\Src\Test\DelphiAIDev.Test.ContextDemo.pas'; end. diff --git a/Package/DelphiAIDeveloper.dproj b/Package/DelphiAIDeveloper.dproj index cc578f1..11a4ed5 100644 --- a/Package/DelphiAIDeveloper.dproj +++ b/Package/DelphiAIDeveloper.dproj @@ -7,7 +7,7 @@ True Debug Win32 - 1048577 + 1 Package DelphiAIDeveloper @@ -39,11 +39,6 @@ Base true - - true - Base - true - true Base @@ -103,13 +98,6 @@ rtl;bindengine;bindcomp;RESTComponents;vclFireDAC;FireDAC;FireDACCommonDriver;FireDACCommon;FireDACIBDriver;FireDACMySQLDriver;$(DCC_UsePackage) - - Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) - Debug - true - 1033 - true - DEBUG;$(DCC_Define) true @@ -246,6 +234,8 @@ + + BITMAP c4d_Logo @@ -278,6 +268,10 @@ BITMAP c4d_database_execute + + Cfg_2 + Base + Base @@ -285,10 +279,6 @@ Cfg_1 Base - - Cfg_2 - Base - Delphi.Personality.12 @@ -306,11 +296,11 @@ Microsoft Office XP Sample Automation Server Wrapper Components - + - - + + 1 @@ -319,6 +309,16 @@ 0 + + + classes + 1 + + + classes + 1 + + res\xml @@ -329,6 +329,12 @@ 1 + + + library\lib\armeabi-v7a + 1 + + library\lib\armeabi @@ -731,10 +737,6 @@ 1 .framework - - 1 - .framework - 0 @@ -748,10 +750,6 @@ 1 .dylib - - 1 - .dylib - 0 .dll;.bpl @@ -766,7 +764,7 @@ 1 .dylib - + 1 .dylib @@ -778,10 +776,6 @@ 1 .dylib - - 1 - .dylib - 0 .bpl @@ -800,7 +794,7 @@ 0 - + 0 @@ -809,174 +803,157 @@ 0 - - 0 - 0 - - + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - - - - Contents\Resources - 1 - - - Contents\Resources + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - Contents\Resources + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - library\lib\armeabi-v7a + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - library\lib\arm64-v8a + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 + + 1 1 - + 1 - + + + 1 - + 1 - + 1 - + + + 1 - - 0 + + 1 - - - - library\lib\armeabi-v7a + 1 - - + + 1 - + 1 - + 1 - + - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 - - - - + 1 1 - + 1 - - - Assets + + 1 - - Assets + 1 - - - - Assets + 1 - - Assets + + + 1 - - - ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 - + + + 1 + - ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 - + - ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + + + 1 + - ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 @@ -1040,6 +1017,105 @@ 1 + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset @@ -1050,6 +1126,17 @@ 1 + + + 1 + + + 1 + + + 1 + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset @@ -1060,6 +1147,50 @@ 1 + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset @@ -1140,19 +1271,130 @@ 1 - - - + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + + + + + 1 + + + 1 + + + 1 + + + + + + + + Contents\Resources + 1 + + + Contents\Resources + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 0 + + + + + library\lib\armeabi-v7a + 1 + + + + + 1 + + + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + Assets + 1 + + + Assets + 1 + + - - + + - - - + + + + + + False @@ -1160,7 +1402,6 @@ False True False - True 12 diff --git a/Package/DelphiAIDeveloper.res b/Package/DelphiAIDeveloper.res index 4a37369..9273b09 100644 Binary files a/Package/DelphiAIDeveloper.res and b/Package/DelphiAIDeveloper.res differ diff --git a/README.md b/README.md index 55f3554..63399fa 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# Delphi AI Developer (Copilot) -Inspired by GitHub Copilot, Delphi AI Developer is a plugin that adds Artificial intelligence (AI) interaction capabilities to the Delphi IDE, using both the OpenAI API, Gemini API and Groq API, as well as offering offline AI support. +# Delphi AI Developer +Inspired by GitHub Copilot, Delphi AI Developer is a plugin that adds Artificial intelligence (AI) interaction capabilities to the Delphi IDE, using both the OpenAI API, Gemini API, Mistral API and Groq API, as well as offering offline AI support. With Delphi AI Developer, you will have assistance in generating and refactoring code, facilitating and accelerating development. @@ -15,28 +15,6 @@ Receive suggestions for creating and improving code directly in the IDE and take [![Course](https://img.shields.io/badge/Course-Delphi-F00?logo=delphi)](https://go.hotmart.com/U81331747Y?dp=1) [![E-mail](https://img.shields.io/badge/E--mail-Send-yellowgreen?logo=maildotru&logoColor=yellowgreen)](mailto:contato@code4delphi.com.br) -

- - - -   - - - -   - - - -   - - - -   - - - -

- ## 🚀 INSTALLATION 1 - Download Delphi AI Developer. You can download the .zip file or clone the project on your PC. diff --git a/Src/CodeCompletion/DelphiAIDev.CodeCompletion.Search.pas b/Src/CodeCompletion/DelphiAIDev.CodeCompletion.Search.pas index b7c6daf..4b09f0f 100644 --- a/Src/CodeCompletion/DelphiAIDev.CodeCompletion.Search.pas +++ b/Src/CodeCompletion/DelphiAIDev.CodeCompletion.Search.pas @@ -41,6 +41,9 @@ TDelphiAIDevCodeCompletionSearch = class(TInterfacedObject, IDelphiAIDevCodeCo implementation +uses + DelphiAIDev.Utils.Context; + class function TDelphiAIDevCodeCompletionSearch.New: IDelphiAIDevCodeCompletionSearch; begin Result := Self.Create; @@ -83,7 +86,11 @@ procedure TDelphiAIDevCodeCompletionSearch.Process(const AContext: IOTAKeyContex procedure TDelphiAIDevCodeCompletionSearch.ProcessQuestions(const AContext: IOTAKeyContext); begin + FVars.FullUnitInterface := TUtilsContext.GetUnitInterfaceCode; + FQuestions.Clear; + if not FVars.FullUnitInterface.Trim.IsEmpty then + FQuestions.Add('Unit Interface Context:' + sLineBreak + FVars.FullUnitInterface); FQuestions.Add(FSettings.LanguageQuestions.GetLanguageDefinition); FQuestions.Add(FSettings.LanguageQuestions.GetMsgCodeCompletionSuggestion); FQuestions.Add(FSettings.LanguageQuestions.GetMsgCodeOnly); diff --git a/Src/CodeCompletion/DelphiAIDev.CodeCompletion.Vars.pas b/Src/CodeCompletion/DelphiAIDev.CodeCompletion.Vars.pas index e4f13e6..35c73ef 100644 --- a/Src/CodeCompletion/DelphiAIDev.CodeCompletion.Vars.pas +++ b/Src/CodeCompletion/DelphiAIDev.CodeCompletion.Vars.pas @@ -17,6 +17,7 @@ TDelphiAIDevCodeCompletionVars = class FRow: Integer; FColumn: Integer; FContents: TStrings; + FFullUnitInterface: string; constructor Create; public class function GetInstance: TDelphiAIDevCodeCompletionVars; @@ -29,6 +30,7 @@ TDelphiAIDevCodeCompletionVars = class property Row: Integer read FRow write FRow; property Column: Integer read FColumn write FColumn; property Contents: TStrings read FContents write FContents; + property FullUnitInterface: string read FFullUnitInterface write FFullUnitInterface; end; implementation @@ -65,6 +67,7 @@ procedure TDelphiAIDevCodeCompletionVars.Clear; FRow := 0; FColumn := 0; FContents.Clear; + FFullUnitInterface := ''; end; initialization diff --git a/Src/Test/DelphiAIDev.Test.ContextDemo.pas b/Src/Test/DelphiAIDev.Test.ContextDemo.pas new file mode 100644 index 0000000..a4931a1 --- /dev/null +++ b/Src/Test/DelphiAIDev.Test.ContextDemo.pas @@ -0,0 +1,48 @@ +unit DelphiAIDev.Test.ContextDemo; + +interface + +uses + System.SysUtils; + +type + // Classe de exemplo para testar o Contexto Global da IA + TShoppingCartItem = class + private + FItemName: string; + FQuantity: Integer; + FPrice: Currency; + FDiscount: Currency; + FTotal: Currency; + procedure SetTotal(const Value: Currency); + public + // A IA deve ser capaz de ler estas propriedades na interface + // mesmo que o cursor esteja lá embaixo na implementação. + property ItemName: string read FItemName write FItemName; + property Quantity: Integer read FQuantity write FQuantity; + property Price: Currency read FPrice write FPrice; + property Discount: Currency read FDiscount write FDiscount; + property Total: Currency read FTotal write SetTotal; + +// Descomente a linha abaixo antes do teste, parao Delphi não reclamar.. +// procedure CalculateFinalPrice; + end; + +implementation + +{ TShoppingCartItem } + +procedure TShoppingCartItem.SetTotal(const Value: Currency); +begin + FTotal := Value; +end; + +// ----------------------------------------------------------------------------- +// CASO DE TESTE: +// Posicione o cursor na linha abaixo e acione o Code Completion (Alt+Enter padrão) +// Tente algo como: "Implemente o metodo CalculateFinalPrice considerando desconto" +// ----------------------------------------------------------------------------- + +// << PONTO DE TESTE AQUI >> + +end. diff --git a/Src/Utils/DelphiAIDev.Utils.Context.pas b/Src/Utils/DelphiAIDev.Utils.Context.pas new file mode 100644 index 0000000..712a778 --- /dev/null +++ b/Src/Utils/DelphiAIDev.Utils.Context.pas @@ -0,0 +1,75 @@ +unit DelphiAIDev.Utils.Context; + +interface + +uses + System.SysUtils, + System.Classes, + ToolsAPI; + +type + TUtilsContext = class + public + class function GetUnitInterfaceCode: string; + end; + +implementation + +class function TUtilsContext.GetUnitInterfaceCode: string; +const + ChunkSize = 1024; +var + LModule: IOTAModule; + LEditor: IOTASourceEditor; + LReader: IOTAEditReader; + LBuffer: array[0..ChunkSize - 1] of AnsiChar; + LPartStr: AnsiString; + LTotalText: AnsiString; + LPos: Integer; + LBytesRead: Integer; + LImplPos: Integer; + i: Integer; +begin + Result := ''; + if not Assigned(BorlandIDEServices) then Exit; + + LModule := (BorlandIDEServices as IOTAModuleServices).CurrentModule; + if not Assigned(LModule) then Exit; + + LEditor := nil; + for i := 0 to LModule.GetModuleFileCount - 1 do + begin + if Supports(LModule.GetModuleFileEditor(i), IOTASourceEditor, LEditor) then + Break; + end; + + if not Assigned(LEditor) then Exit; + + LReader := LEditor.CreateReader; + if not Assigned(LReader) then Exit; + + try + LPos := 0; + LTotalText := ''; + + repeat + LBytesRead := LReader.GetText(LPos, PAnsiChar(@LBuffer), ChunkSize); + if LBytesRead > 0 then + begin + SetString(LPartStr, PAnsiChar(@LBuffer), LBytesRead); + LTotalText := LTotalText + LPartStr; + Inc(LPos, LBytesRead); + end; + until LBytesRead < ChunkSize; + + Result := String(LTotalText); + + LImplPos := Pos('implementation', LowerCase(Result)); + if LImplPos > 0 then + Result := Copy(Result, 1, LImplPos - 1); + finally + LReader := nil; + end; +end; + +end.