netcore-blueprint 0.0.74 → 0.0.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/BlueprintTemplate/Host/Host.API/Host.API.csproj +4 -0
  2. package/BlueprintTemplate/Host/Host.API/Program.cs +4 -0
  3. package/BlueprintTemplate/Modules/AIAssistantModule/Assistants/__ASSISTANT_NAME__/Assets/PlanTemplates.json +12 -0
  4. package/BlueprintTemplate/Modules/AIAssistantModule/Assistants/__ASSISTANT_NAME__/AssistantDependencyInjection.cs +21 -0
  5. package/BlueprintTemplate/Modules/AIAssistantModule/Assistants/__ASSISTANT_NAME__/Domain/Interfaces/IDynamicAssetProvider.cs +9 -0
  6. package/BlueprintTemplate/Modules/AIAssistantModule/Assistants/__ASSISTANT_NAME__/Domain/Static/AssistantContextKeys.cs +13 -0
  7. package/BlueprintTemplate/Modules/AIAssistantModule/Assistants/__ASSISTANT_NAME__/Infrastructure/Helpers/DynamicAssetProvider.cs +27 -0
  8. package/BlueprintTemplate/Modules/AIAssistantModule/Assistants/__ASSISTANT_NAME__/Infrastructure/__ASSISTANT_NAME__Executor.cs +62 -0
  9. package/BlueprintTemplate/Modules/AIAssistantModule/Assistants/__ASSISTANT_NAME__/__ASSISTANT_NAME__.csproj +19 -0
  10. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.API/AIAssistantModule.API.csproj +21 -0
  11. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.API/AIAssistantModule.cs +25 -0
  12. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.API/Controllers/Public/AIAssistantController.cs +59 -0
  13. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.API/Mappers/DtoAIAssistantMappingProfile.cs +26 -0
  14. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/AIAssistantCoreDependencyInjection.cs +19 -0
  15. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/AIAssistantModule.Core.csproj +14 -0
  16. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Dtos/Admin/AIAssistantRequestDto.cs +9 -0
  17. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Dtos/Admin/AIAssistantResponseDto.cs +8 -0
  18. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Entities/AIAssistant.cs +8 -0
  19. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Enums/AssetCategory.cs +7 -0
  20. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Enums/AssetStaticCategory.cs +14 -0
  21. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Enums/PlanStepType.cs +11 -0
  22. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Interfaces/API/IAIAssistantService.cs +9 -0
  23. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Interfaces/SPI/IAssistantExecutor.cs +10 -0
  24. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Interfaces/SPI/ILLMService.cs +10 -0
  25. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Interfaces/SPI/ILLMStepHandler.cs +9 -0
  26. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Interfaces/SPI/IPlanStepHandler.cs +10 -0
  27. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Models/DefaultPlan.cs +8 -0
  28. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Models/PlanDefinition.cs +8 -0
  29. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Models/PlanStep.cs +12 -0
  30. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Models/PlanTemplate.cs +8 -0
  31. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Models/StepContext.cs +36 -0
  32. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Options/OpenAIOptions.cs +10 -0
  33. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Services/AIAssistantService.cs +30 -0
  34. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Infrastructure/AIAssistantInfraDependencyInjection.cs +21 -0
  35. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Infrastructure/AIAssistantModule.Infrastructure.csproj +19 -0
  36. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Infrastructure/Helpers/FileAccessHelper.cs +55 -0
  37. package/BlueprintTemplate/Modules/AIAssistantModule/Engine/AIAssistantModule.Infrastructure/Services/OpenAILLMService.cs +55 -0
  38. package/BlueprintTemplate/MyBlueprint.slnx +10 -0
  39. package/Modules/AIAssistantModule/Assistants/__ASSISTANT_NAME__/Assets/PlanTemplates.json +12 -0
  40. package/Modules/AIAssistantModule/Assistants/__ASSISTANT_NAME__/AssistantDependencyInjection.cs +21 -0
  41. package/Modules/AIAssistantModule/Assistants/__ASSISTANT_NAME__/Domain/Interfaces/IDynamicAssetProvider.cs +9 -0
  42. package/Modules/AIAssistantModule/Assistants/__ASSISTANT_NAME__/Domain/Static/AssistantContextKeys.cs +13 -0
  43. package/Modules/AIAssistantModule/Assistants/__ASSISTANT_NAME__/Infrastructure/Helpers/DynamicAssetProvider.cs +27 -0
  44. package/Modules/AIAssistantModule/Assistants/__ASSISTANT_NAME__/Infrastructure/__ASSISTANT_NAME__Executor.cs +62 -0
  45. package/Modules/AIAssistantModule/Assistants/__ASSISTANT_NAME__/__ASSISTANT_NAME__.csproj +19 -0
  46. package/Modules/AIAssistantModule/Engine/AIAssistantModule.API/AIAssistantModule.API.csproj +21 -0
  47. package/Modules/AIAssistantModule/Engine/AIAssistantModule.API/AIAssistantModule.cs +25 -0
  48. package/Modules/AIAssistantModule/Engine/AIAssistantModule.API/Controllers/Public/AIAssistantController.cs +59 -0
  49. package/Modules/AIAssistantModule/Engine/AIAssistantModule.API/Mappers/DtoAIAssistantMappingProfile.cs +26 -0
  50. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/AIAssistantCoreDependencyInjection.cs +19 -0
  51. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/AIAssistantModule.Core.csproj +14 -0
  52. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Dtos/Admin/AIAssistantRequestDto.cs +9 -0
  53. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Dtos/Admin/AIAssistantResponseDto.cs +8 -0
  54. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Entities/AIAssistant.cs +8 -0
  55. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Enums/AssetCategory.cs +7 -0
  56. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Enums/AssetStaticCategory.cs +14 -0
  57. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Enums/PlanStepType.cs +11 -0
  58. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Interfaces/API/IAIAssistantService.cs +9 -0
  59. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Interfaces/SPI/IAssistantExecutor.cs +10 -0
  60. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Interfaces/SPI/ILLMService.cs +10 -0
  61. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Interfaces/SPI/ILLMStepHandler.cs +9 -0
  62. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Interfaces/SPI/IPlanStepHandler.cs +10 -0
  63. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Models/DefaultPlan.cs +8 -0
  64. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Models/PlanDefinition.cs +8 -0
  65. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Models/PlanStep.cs +12 -0
  66. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Models/PlanTemplate.cs +8 -0
  67. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Models/StepContext.cs +36 -0
  68. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Options/OpenAIOptions.cs +10 -0
  69. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Core/Services/AIAssistantService.cs +30 -0
  70. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Infrastructure/AIAssistantInfraDependencyInjection.cs +21 -0
  71. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Infrastructure/AIAssistantModule.Infrastructure.csproj +19 -0
  72. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Infrastructure/Helpers/FileAccessHelper.cs +55 -0
  73. package/Modules/AIAssistantModule/Engine/AIAssistantModule.Infrastructure/Services/OpenAILLMService.cs +55 -0
  74. package/package.json +1 -1
@@ -16,6 +16,10 @@
16
16
  </ItemGroup>
17
17
 
18
18
  <ItemGroup>
19
+ <ProjectReference Include="..\..\Modules\AIAssistantModule\Assistants\__ASSISTANT_NAME__\__ASSISTANT_NAME__.csproj" />
20
+ <ProjectReference Include="..\..\Modules\AIAssistantModule\Engine\AIAssistantModule.API\AIAssistantModule.API.csproj" />
21
+ <ProjectReference Include="..\..\Modules\AIAssistantModule\Engine\AIAssistantModule.Core\AIAssistantModule.Core.csproj" />
22
+ <ProjectReference Include="..\..\Modules\AIAssistantModule\Engine\AIAssistantModule.Infrastructure\AIAssistantModule.Infrastructure.csproj" />
19
23
  <ProjectReference Include="..\..\Modules\UserModule\User.API\UserModule.API.csproj" />
20
24
  <ProjectReference Include="..\..\Modules\UserModule\User.Core\UserModule.Core.csproj" />
21
25
  <ProjectReference Include="..\..\Modules\UserModule\User.Infrastructure\UserModule.Infrastructure.csproj" />
@@ -1,5 +1,6 @@
1
1
  using Host.API.Extensions;
2
2
  using Microsoft.AspNetCore.Mvc.ApplicationParts;
3
+ using __ASSISTANT_NAME__;
3
4
 
4
5
  var builder = WebApplication.CreateBuilder(args);
5
6
 
@@ -29,6 +30,9 @@ builder.Services.AddModules(builder.Configuration, mvcBuilder);
29
30
  // Database
30
31
  builder.Services.AddMySqlDatabase(builder.Configuration);
31
32
 
33
+ // Others
34
+ builder.Services.Add__ASSISTANT_NAME__AssistantModule();
35
+
32
36
  var app = builder.Build();
33
37
 
34
38
  app.UseApiMiddleware();
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": "1.0.0",
3
+ "defaultPlan": {
4
+ "description": "Scan solution and generate SolutionStructure.json",
5
+ "steps": [
6
+ {
7
+ "name": "Prompt",
8
+ "type": "llm"
9
+ }
10
+ ]
11
+ }
12
+ }
@@ -0,0 +1,21 @@
1
+ using __ASSISTANT_NAME__.Domain.Interfaces;
2
+ using __ASSISTANT_NAME__.Infrastructure;
3
+ using __ASSISTANT_NAME__.Infrastructure.Helpers;
4
+ using AIAssistantModule.Core.Interfaces.SPI;
5
+ using Microsoft.Extensions.DependencyInjection;
6
+
7
+ namespace __ASSISTANT_NAME__
8
+ {
9
+ public static class AssistantDependencyInjection
10
+ {
11
+ public static IServiceCollection Add__ASSISTANT_NAME__AssistantModule(
12
+ this IServiceCollection services)
13
+ {
14
+ services.AddScoped<IAssistantExecutor, __ASSISTANT_NAME__Executor>();
15
+
16
+ services.AddScoped<IDynamicAssetProvider, DynamicAssetProvider>();
17
+
18
+ return services;
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,9 @@
1
+ using CoreGen.Domain.Enum;
2
+
3
+ namespace __ASSISTANT_NAME__.Domain.Interfaces
4
+ {
5
+ public interface IDynamicAssetProvider
6
+ {
7
+ string GetPlanTemplate(AssetCategory category);
8
+ }
9
+ }
@@ -0,0 +1,13 @@
1
+ namespace __ASSISTANT_NAME__.Domain.Static
2
+ {
3
+ public static class AssistantContextKeys
4
+ {
5
+ //In & Out
6
+ public const string RootPath = "RootPath";
7
+ public const string Requirement = "Requirement";
8
+ public const string OutputJson = "OutputJson";
9
+
10
+ //Running Id
11
+ public const string RunId = "RunId";
12
+ }
13
+ }
@@ -0,0 +1,27 @@
1
+ using __ASSISTANT_NAME__.Domain.Interfaces;
2
+ using CoreGen.Domain.Enum;
3
+
4
+ namespace __ASSISTANT_NAME__.Infrastructure.Helpers
5
+ {
6
+ public class DynamicAssetProvider : IDynamicAssetProvider
7
+ {
8
+ public string GetPlanTemplate(AssetCategory category)
9
+ {
10
+ string assemblyLocation =
11
+ Path.GetDirectoryName(typeof(__ASSISTANT_NAME__Executor).Assembly.Location)!;
12
+
13
+ var fileName = category switch
14
+ {
15
+ AssetCategory.PlanTemplate => "PlanTemplates.json",
16
+ _ => throw new ArgumentOutOfRangeException()
17
+ };
18
+
19
+ var path = Path.Combine(
20
+ assemblyLocation,
21
+ "Assets",
22
+ fileName);
23
+
24
+ return File.ReadAllText(path);
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,62 @@
1
+ using __ASSISTANT_NAME__.Domain.Interfaces;
2
+ using __ASSISTANT_NAME__.Domain.Static;
3
+ using AIAssistantModule.Core.Dtos.Admin;
4
+ using AIAssistantModule.Core.Interfaces.SPI;
5
+ using AIAssistantModule.Core.Models;
6
+ using CoreGen.Domain.Enum;
7
+ using System.Text.Json;
8
+
9
+ namespace __ASSISTANT_NAME__.Infrastructure
10
+ {
11
+ public class __ASSISTANT_NAME__Executor : IAssistantExecutor
12
+ {
13
+ private readonly IEnumerable<IPlanStepHandler> _handlers;
14
+ private readonly IDynamicAssetProvider _dynamicAssetProvider;
15
+
16
+ public __ASSISTANT_NAME__Executor(
17
+ IEnumerable<IPlanStepHandler> handlers,
18
+ IDynamicAssetProvider dynamicAssetProvider
19
+ )
20
+ {
21
+ _handlers = handlers;
22
+ _dynamicAssetProvider = dynamicAssetProvider;
23
+ }
24
+ public string Name => "__ASSISTANT_NAME__";
25
+
26
+ public async Task ExecuteAsync(AIAssistantRequestDto request)
27
+ {
28
+ // 1️⃣ Create execution context
29
+ var context = new StepContext();
30
+
31
+ context.Set(
32
+ AssistantContextKeys.RootPath,
33
+ request.ProjectPath);
34
+ context.Set(
35
+ AssistantContextKeys.Requirement,
36
+ request.Prompt);
37
+
38
+ // 2️⃣ Build execution plan
39
+ var planTemplateJson = _dynamicAssetProvider.GetPlanTemplate(AssetCategory.PlanTemplate);
40
+
41
+ var planTemplate = JsonSerializer.Deserialize<PlanTemplate>(planTemplateJson, new JsonSerializerOptions
42
+ {
43
+ PropertyNameCaseInsensitive = true
44
+ });
45
+
46
+ var plan = planTemplate?.DefaultPlan?.Steps ?? new List<PlanStep>();
47
+
48
+ // 3️⃣ Execute steps
49
+ foreach (var step in plan)
50
+ {
51
+ var handler = _handlers
52
+ .FirstOrDefault(h => h.StepName == step.Name);
53
+
54
+ if (handler == null)
55
+ throw new InvalidOperationException(
56
+ $"No handler found for step '{step.Name}'.");
57
+
58
+ await handler.ExecuteAsync(step, context);
59
+ }
60
+ }
61
+ }
62
+ }
@@ -0,0 +1,19 @@
1
+ <Project Sdk="Microsoft.NET.Sdk">
2
+
3
+ <PropertyGroup>
4
+ <TargetFramework>net10.0</TargetFramework>
5
+ <ImplicitUsings>enable</ImplicitUsings>
6
+ <Nullable>enable</Nullable>
7
+ </PropertyGroup>
8
+
9
+ <ItemGroup>
10
+ <Folder Include="Assets\Static\" />
11
+ <Folder Include="Domain\Models\" />
12
+ <Folder Include="Infrastructure\Handlers\" />
13
+ </ItemGroup>
14
+
15
+ <ItemGroup>
16
+ <ProjectReference Include="..\..\Engine\AIAssistantModule.Core\AIAssistantModule.Core.csproj" />
17
+ </ItemGroup>
18
+
19
+ </Project>
@@ -0,0 +1,21 @@
1
+ <Project Sdk="Microsoft.NET.Sdk">
2
+
3
+ <PropertyGroup>
4
+ <TargetFramework>net10.0</TargetFramework>
5
+ <ImplicitUsings>enable</ImplicitUsings>
6
+ <Nullable>enable</Nullable>
7
+ </PropertyGroup>
8
+
9
+ <ItemGroup>
10
+ <PackageReference Include="AutoMapper" Version="16.0.0" />
11
+ <PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.9" />
12
+ <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.3.9" />
13
+ </ItemGroup>
14
+
15
+ <ItemGroup>
16
+ <ProjectReference Include="..\AIAssistantModule.Core\AIAssistantModule.Core.csproj" />
17
+ <ProjectReference Include="..\AIAssistantModule.Infrastructure\AIAssistantModule.Infrastructure.csproj" />
18
+ </ItemGroup>
19
+
20
+
21
+ </Project>
@@ -0,0 +1,25 @@
1
+ using AIAssistantModule.API.Controllers.Public;
2
+ using AIAssistantModule.API.Mappers;
3
+ using AIAssistantModule.Core;
4
+ using AIAssistantModule.Infrastructure;
5
+ using Microsoft.Extensions.Configuration;
6
+ using Microsoft.Extensions.DependencyInjection;
7
+ using Shared.Core.Interfaces.Modules;
8
+ using System.Reflection;
9
+
10
+ namespace AIAssistantModule.API
11
+ {
12
+ public class AIAssistantModule : IModule
13
+ {
14
+ public string Name => "AIAssistant";
15
+ public bool RequiresDatabase => false;
16
+ public void Register(IServiceCollection services, IConfiguration config)
17
+ {
18
+ AIAssistantCoreDependencyInjection.AddModule(services);
19
+ AIAssistantInfraDependencyInjection.AddModule(services, config);
20
+ }
21
+
22
+ public Assembly ApiAssembly => typeof(AIAssistantController).Assembly;
23
+ public Assembly MappingAssembly => typeof(DtoAIAssistantMappingProfile).Assembly;
24
+ }
25
+ }
@@ -0,0 +1,59 @@
1
+ using AutoMapper;
2
+ using AIAssistantModule.Core.Dtos.Admin;
3
+ using AIAssistantModule.Core.Interfaces.API;
4
+ using Microsoft.AspNetCore.Http;
5
+ using Microsoft.AspNetCore.Mvc;
6
+ using Microsoft.Extensions.Logging;
7
+ using System.Diagnostics;
8
+
9
+ namespace AIAssistantModule.API.Controllers.Public
10
+ {
11
+ /// <summary>
12
+ /// AIAssistant Controller
13
+ /// </summary>
14
+ [Route("rest/v{version:apiVersion}/aiassistants")]
15
+ [Produces("application/json")]
16
+ [ApiController]
17
+ public class AIAssistantController : Controller
18
+ {
19
+ private readonly IMapper _mapper;
20
+ private ILogger _logger;
21
+ private readonly IAIAssistantService _aiassistantService;
22
+
23
+ /// <summary>
24
+ /// Constructor
25
+ /// </summary>
26
+ /// <param name="logger"></param>
27
+ /// <param name="mapper"></param>
28
+ /// <param name="aiassistantService"></param>
29
+ public AIAssistantController(
30
+ ILogger<AIAssistantController> logger,
31
+ IMapper mapper,
32
+ IAIAssistantService aiassistantService)
33
+ {
34
+ _mapper = mapper;
35
+ _logger = logger;
36
+ _aiassistantService = aiassistantService;
37
+ }
38
+
39
+ /// <summary>
40
+ /// Prompt
41
+ /// </summary>
42
+ /// <param name="request"></param>
43
+ /// <returns></returns>
44
+ [HttpPost("generate")]
45
+ [ProducesResponseType(StatusCodes.Status200OK)]
46
+ public async Task<IActionResult> GetAIAssistants([FromBody] AIAssistantRequestDto request)
47
+ {
48
+ _logger.LogInformation("Start generating code");
49
+ var stopwatch = Stopwatch.StartNew();
50
+
51
+ await _aiassistantService.GenerateCodeAsync(request);
52
+
53
+ stopwatch.Stop();
54
+ _logger.LogInformation($"Getting aiassistants done in {stopwatch.ElapsedMilliseconds}");
55
+
56
+ return Ok();
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,26 @@
1
+ using AutoMapper;
2
+ using AIAssistantModule.Core.Dtos.Admin;
3
+ using AIAssistantModule.Core.Entities;
4
+ using Shared.Core.Shared.Models;
5
+
6
+ namespace AIAssistantModule.API.Mappers
7
+ {
8
+ /// <summary>
9
+ /// DtoAIAssistantMappingProfile
10
+ /// </summary>
11
+ public class DtoAIAssistantMappingProfile : Profile
12
+ {
13
+ /// <summary>
14
+ /// Constructor
15
+ /// </summary>
16
+ public DtoAIAssistantMappingProfile()
17
+ {
18
+ CreateMap<AIAssistant, AIAssistantRequestDto>().ReverseMap();
19
+
20
+ CreateMap<PagerData<AIAssistant>, PagerData<AIAssistantResponseDto>>().ReverseMap();
21
+
22
+ CreateMap<AIAssistant, AIAssistantResponseDto>()
23
+ .ReverseMap();
24
+ }
25
+ }
26
+ }
@@ -0,0 +1,19 @@
1
+ using AIAssistantModule.Core.Interfaces.API;
2
+ using AIAssistantModule.Core.Services;
3
+ using Microsoft.Extensions.DependencyInjection;
4
+ using Shared.Core.Interfaces.API;
5
+ using Shared.Core.Services;
6
+
7
+ namespace AIAssistantModule.Core
8
+ {
9
+ public static class AIAssistantCoreDependencyInjection
10
+ {
11
+ public static IServiceCollection AddModule(
12
+ this IServiceCollection services)
13
+ {
14
+ services.AddScoped(typeof(IItemService<>), typeof(ItemService<>));
15
+ services.AddScoped<IAIAssistantService, AIAssistantService>();
16
+ return services;
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,14 @@
1
+ <Project Sdk="Microsoft.NET.Sdk">
2
+
3
+ <PropertyGroup>
4
+ <TargetFramework>net10.0</TargetFramework>
5
+ <ImplicitUsings>enable</ImplicitUsings>
6
+ <Nullable>enable</Nullable>
7
+ </PropertyGroup>
8
+
9
+ <ItemGroup>
10
+ <ProjectReference Include="..\..\..\..\Shared\Shared.Core\Shared.Core.csproj" />
11
+ </ItemGroup>
12
+
13
+
14
+ </Project>
@@ -0,0 +1,9 @@
1
+ namespace AIAssistantModule.Core.Dtos.Admin
2
+ {
3
+ public class AIAssistantRequestDto
4
+ {
5
+ public string Name { get; set; }
6
+ public string Prompt { get; set; } = @"Add a new GET endpoint /ping that returns pong";
7
+ public string ProjectPath { get; set; } = @"D:\@Projects\@@ [AI]\workspace";
8
+ }
9
+ }
@@ -0,0 +1,8 @@
1
+ using Shared.Core.Dtos.Responses;
2
+
3
+ namespace AIAssistantModule.Core.Dtos.Admin
4
+ {
5
+ public class AIAssistantResponseDto : BaseResponseDto
6
+ {
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ using Shared.Core.Entities;
2
+
3
+ namespace AIAssistantModule.Core.Entities
4
+ {
5
+ public class AIAssistant : BaseEntity
6
+ {
7
+ }
8
+ }
@@ -0,0 +1,7 @@
1
+ namespace CoreGen.Domain.Enum
2
+ {
3
+ public enum AssetCategory
4
+ {
5
+ PlanTemplate,
6
+ }
7
+ }
@@ -0,0 +1,14 @@
1
+ namespace AIAssistantModule.Core.Enums
2
+ {
3
+ public enum AssetStaticCategory
4
+ {
5
+ Identity,
6
+ RulePriority,
7
+ GlobalRules,
8
+ ArchitectureRules,
9
+ CodingConventions,
10
+ ResponseRules,
11
+ OutputSchema,
12
+
13
+ }
14
+ }
@@ -0,0 +1,11 @@
1
+ using System.Text.Json.Serialization;
2
+
3
+ namespace AIAssistantModule.Core.Enums
4
+ {
5
+ [JsonConverter(typeof(JsonStringEnumConverter))]
6
+ public enum PlanStepType
7
+ {
8
+ Action,
9
+ Llm
10
+ }
11
+ }
@@ -0,0 +1,9 @@
1
+ using AIAssistantModule.Core.Dtos.Admin;
2
+
3
+ namespace AIAssistantModule.Core.Interfaces.API
4
+ {
5
+ public interface IAIAssistantService
6
+ {
7
+ Task GenerateCodeAsync(AIAssistantRequestDto request);
8
+ }
9
+ }
@@ -0,0 +1,10 @@
1
+ using AIAssistantModule.Core.Dtos.Admin;
2
+
3
+ namespace AIAssistantModule.Core.Interfaces.SPI
4
+ {
5
+ public interface IAssistantExecutor
6
+ {
7
+ string Name { get; }
8
+ Task ExecuteAsync(AIAssistantRequestDto request);
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ namespace AIAssistantModule.Core.Interfaces.SPI
2
+ {
3
+ public interface ILLMService
4
+ {
5
+ Task<string> CallAsync(
6
+ string prompt,
7
+ string? schema = null,
8
+ CancellationToken cancellationToken = default);
9
+ }
10
+ }
@@ -0,0 +1,9 @@
1
+ using AIAssistantModule.Core.Models;
2
+
3
+ namespace AIAssistantModule.Core.Interfaces.SPI
4
+ {
5
+ public interface ILLMStepHandler: IPlanStepHandler
6
+ {
7
+ string BuildPrompt(StepContext context);
8
+ }
9
+ }
@@ -0,0 +1,10 @@
1
+ using AIAssistantModule.Core.Models;
2
+
3
+ namespace AIAssistantModule.Core.Interfaces.SPI
4
+ {
5
+ public interface IPlanStepHandler
6
+ {
7
+ string StepName { get; }
8
+ Task ExecuteAsync(PlanStep step, StepContext context);
9
+ }
10
+ }
@@ -0,0 +1,8 @@
1
+ namespace AIAssistantModule.Core.Models
2
+ {
3
+ public class DefaultPlan
4
+ {
5
+ public string Description { get; set; } = string.Empty;
6
+ public List<PlanStep> Steps { get; set; } = new();
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ namespace AIAssistantModule.Core.Models
2
+ {
3
+ public class PlanDefinition
4
+ {
5
+ public string Description { get; set; } = string.Empty;
6
+ public List<PlanStep> Steps { get; set; } = new();
7
+ }
8
+ }
@@ -0,0 +1,12 @@
1
+ using AIAssistantModule.Core.Enums;
2
+ using System.Text.Json.Serialization;
3
+
4
+ namespace AIAssistantModule.Core.Models
5
+ {
6
+ public class PlanStep
7
+ {
8
+ public string Name { get; set; } = string.Empty;
9
+ [JsonConverter(typeof(JsonStringEnumConverter))]
10
+ public PlanStepType Type { get; set; }
11
+ }
12
+ }
@@ -0,0 +1,8 @@
1
+ namespace AIAssistantModule.Core.Models
2
+ {
3
+ public class PlanTemplate
4
+ {
5
+ public string Version { get; set; } = string.Empty;
6
+ public PlanDefinition DefaultPlan { get; set; } = new();
7
+ }
8
+ }
@@ -0,0 +1,36 @@
1
+ namespace AIAssistantModule.Core.Models
2
+ {
3
+ public class StepContext
4
+ {
5
+ private readonly Dictionary<string, object> _data = new();
6
+ public void Set<T>(string key, T value)
7
+ {
8
+ _data[key] = value!;
9
+ }
10
+
11
+ public T Get<T>(string key)
12
+ {
13
+ if (!_data.TryGetValue(key, out var value))
14
+ throw new InvalidOperationException(
15
+ $"Context key '{key}' not found.");
16
+
17
+ if (value is not T typedValue)
18
+ throw new InvalidOperationException(
19
+ $"Context key '{key}' is not of type {typeof(T).Name}.");
20
+
21
+ return typedValue;
22
+ }
23
+
24
+ public bool TryGet<T>(string key, out T result)
25
+ {
26
+ if (_data.TryGetValue(key, out var value) && value is T typed)
27
+ {
28
+ result = typed;
29
+ return true;
30
+ }
31
+
32
+ result = default!;
33
+ return false;
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,10 @@
1
+ namespace AIAssistantModule.Core.Options
2
+ {
3
+ public class OpenAIOptions
4
+ {
5
+ public string ApiKey { get; set; } = default!;
6
+ public string Model { get; set; } = "gpt-4o-mini";
7
+ public double Temperature { get; set; } = 0.2;
8
+ public int MaxTokens { get; set; } = 4000;
9
+ }
10
+ }
@@ -0,0 +1,30 @@
1
+ using AIAssistantModule.Core.Dtos.Admin;
2
+ using AIAssistantModule.Core.Entities;
3
+ using AIAssistantModule.Core.Interfaces.API;
4
+ using AIAssistantModule.Core.Interfaces.SPI;
5
+ using Microsoft.Extensions.Logging;
6
+ using Shared.Core.Interfaces.SPI;
7
+
8
+ namespace AIAssistantModule.Core.Services
9
+ {
10
+ public class AIAssistantService : IAIAssistantService
11
+ {
12
+ private readonly IEnumerable<IAssistantExecutor> _executor;
13
+ public AIAssistantService(ILogger<AIAssistantService> logger,
14
+ IRepositoryFactory<AIAssistant> repositoryFactory,
15
+ IEnumerable<IAssistantExecutor> executors)
16
+ {
17
+ _executor = executors;
18
+
19
+ }
20
+
21
+ public async Task GenerateCodeAsync(AIAssistantRequestDto request)
22
+ {
23
+ var assistant = _executor
24
+ .First(x => x.Name == request.Name);
25
+
26
+ //Do Plan
27
+ await assistant.ExecuteAsync(request);
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,21 @@
1
+ using AIAssistantModule.Core.Interfaces.SPI;
2
+ using AIAssistantModule.Core.Options;
3
+ using AIAssistantModule.Infrastructure.Services;
4
+ using Microsoft.Extensions.Configuration;
5
+ using Microsoft.Extensions.DependencyInjection;
6
+
7
+ namespace AIAssistantModule.Infrastructure
8
+ {
9
+ public static class AIAssistantInfraDependencyInjection
10
+ {
11
+ public static IServiceCollection AddModule(
12
+ this IServiceCollection services,
13
+ IConfiguration configuration)
14
+ {
15
+ services.Configure<OpenAIOptions>(
16
+ configuration.GetSection("AIAssistant:LLM"));
17
+ services.AddSingleton<ILLMService, OpenAILLMService>();
18
+ return services;
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,19 @@
1
+ <Project Sdk="Microsoft.NET.Sdk">
2
+
3
+ <PropertyGroup>
4
+ <TargetFramework>net10.0</TargetFramework>
5
+ <ImplicitUsings>enable</ImplicitUsings>
6
+ <Nullable>enable</Nullable>
7
+ </PropertyGroup>
8
+
9
+ <ItemGroup>
10
+ <PackageReference Include="Microsoft.Extensions.Http" Version="10.0.3" />
11
+ <PackageReference Include="OpenAI" Version="2.8.0" />
12
+ </ItemGroup>
13
+
14
+ <ItemGroup>
15
+ <ProjectReference Include="..\AIAssistantModule.Core\AIAssistantModule.Core.csproj" />
16
+ </ItemGroup>
17
+
18
+
19
+ </Project>