+
-
-
+
+
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
[](https://go.hotmart.com/U81331747Y?dp=1)
[](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.