From b1642aa6a33631468a3e68f9b57e6530761ccedc Mon Sep 17 00:00:00 2001 From: hzhang Date: Thu, 8 May 2025 01:14:41 +0100 Subject: [PATCH] add: gitea tools --- Alchegos.ProjectManager.csproj | 13 ++---- Dockerfile | 6 +-- Guide/Tasks/Task1.md | 35 ++++++++++++++ Guide/index.md | 15 ++++++ NuGet.Config | 7 +++ Program.cs | 85 ++++++++++++++++++++++++++++++++-- Worker.cs | 24 ---------- appsettings.Development.json | 5 +- appsettings.json | 5 +- 9 files changed, 150 insertions(+), 45 deletions(-) create mode 100644 Guide/Tasks/Task1.md create mode 100644 Guide/index.md create mode 100644 NuGet.Config delete mode 100644 Worker.cs diff --git a/Alchegos.ProjectManager.csproj b/Alchegos.ProjectManager.csproj index d30edbe..ea89e63 100644 --- a/Alchegos.ProjectManager.csproj +++ b/Alchegos.ProjectManager.csproj @@ -1,20 +1,15 @@ - + net9.0 - enable + disable enable - dotnet-Alchegos.ProjectManager-dadb124f-e818-4185-b3a6-9bed4c585ae8 Linux - - + - - - .dockerignore - + diff --git a/Dockerfile b/Dockerfile index f4d1ffb..61c7854 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,15 +5,15 @@ WORKDIR /app FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src -COPY ["Alchegos.ProjectManager/Alchegos.ProjectManager.csproj", "Alchegos.ProjectManager/"] +COPY ["Alchegos.ProjectManager/Alchegos.ProjectManager.csproj", "./"] RUN dotnet restore "Alchegos.ProjectManager/Alchegos.ProjectManager.csproj" COPY . . -WORKDIR "/src/Alchegos.ProjectManager" +WORKDIR "/src/" RUN dotnet build "Alchegos.ProjectManager.csproj" -c $BUILD_CONFIGURATION -o /app/build FROM build AS publish ARG BUILD_CONFIGURATION=Release -RUN dotnet publish "Alchegos.ProjectManager.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false +RUN dotnet publish "./Alchegos.ProjectManager.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false FROM base AS final WORKDIR /app diff --git a/Guide/Tasks/Task1.md b/Guide/Tasks/Task1.md new file mode 100644 index 0000000..d52e6b5 --- /dev/null +++ b/Guide/Tasks/Task1.md @@ -0,0 +1,35 @@ +## Task 1 + +### In this task you have to do the following +1. Analysis client's project description +2. Determine if client's goal is achievable +3. Take a name for this project +4. Make comprehensive note of project description +5. Create repo on gitea with gitea tool +6. Post your note as wiki page to the repo, with title 'Initial Note' + + +--- +### Rules to Analysis Project Description + +--- +### Rules to Determine Goal Achievability + +--- +### Project Naming Rules +1. No white space +2. No repo whose owner is you has the same name +3. No preposition +4. No numeric character +5. No special character + +--- +### Note Rules +1. Short, direct. +2. Cover every point in client's project description. +3. List potential conflicts. +4. Note possible technology stack. +5. Expert can understand client's purpose by just reading your note. +6. List codebase in our gitea server can be reused in this project. + +--- diff --git a/Guide/index.md b/Guide/index.md new file mode 100644 index 0000000..b08c9b5 --- /dev/null +++ b/Guide/index.md @@ -0,0 +1,15 @@ +### Tasks Instruction +#### This section contains all types of task you might encounter. Find the corresponding guide markdown for details +#### Each line is in format `task id`. `task name` => `guide markdown path` + +--- +1. Create initial note => ~/Guide/Tasks/Task1.md +2. Establish project plan => ~/Guide/Tasks/Task2.md +3. Breakdown the goal => ~/Guide/Tasks/Task3.md +4. Estimate the cost => ~/Guide/Tasks/Task4.md +5. Bargain with client => ~/Guide/Tasks/Task5.md +6. Post project tasks => ~/Guide/Tasks/Task6.md +7. Daily progress report => ~/Guide/Tasks/Task7.md +8. Stage release => ~/Guide/Tasks/Task8.md +9. Version release => ~/Guide/Tasks/Task9.md +10. Update readme => ~/Guide/Tasks/Task10.md \ No newline at end of file diff --git a/NuGet.Config b/NuGet.Config new file mode 100644 index 0000000..e9328aa --- /dev/null +++ b/NuGet.Config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Program.cs b/Program.cs index 3d0e8ff..8806932 100644 --- a/Program.cs +++ b/Program.cs @@ -1,7 +1,82 @@ -using Alchegos.ProjectManager; +var builder = WebApplication.CreateBuilder(args); -var builder = Host.CreateApplicationBuilder(args); -builder.Services.AddHostedService(); +var app = builder.Build(); -var host = builder.Build(); -host.Run(); \ No newline at end of file +app.UseHttpsRedirection(); + +app.MapGet("/variables", () => +{ + string pmRole = Environment.GetEnvironmentVariable("PM_ROLE"); + string pmGiteaAccount = Environment.GetEnvironmentVariable("PM_GITEA_ACCOUNT"); + string pmGiteaPassword = Environment.GetEnvironmentVariable("PM_GITEA_PASSWORD"); + string pmGiteaToken = Environment.GetEnvironmentVariable("PM_GITEA_ACCESS_TOKEN"); + string pmSshHost = Environment.GetEnvironmentVariable("PM_SSH_HOST"); + string pmSshUser = Environment.GetEnvironmentVariable("PM_SSH_USER"); + string InitialNoteSystemMessage() => + """ + Your current task is to establish a draft plan for the client's need, client will provide you a initial project description in user message. + The description might be preliminary or lack detail. + + But if you are sure that the client is making non-scene, or his goal is not achievable, refer (b) to reject the task, close terminal and chat session. + + Otherwise, Following `~/Guide/index.md` to give this project a name, create a repo on gitea with the project name, set it to private. + Draft a note about the project and by creating a wiki page on this repo with title 'initial note'. + + If the creation of gitea repo or wiki page is not a success, save your note to `~/_initial_note.md`, then report the issue refer to (1) + + In this note, you should: + 1. Describe the goal of client's project description. + 2. Summerize client's project description, reader of your note should be able to fully understand client's propose without referring client's original description. + 3. Make a check list point out details in client's description that need to be clarified or discussed. + 4. List your suggestion to the project description. + 5. Keep the note short as possible, expect readers of your note are experts. + + Once you published the note, refer (b) to complete your current task with the URL of created repo in the additionalInfo.structuredOutput.repoUrl + """; + + string FirstDiscussionSystemMessage() => + """ + Your current task is to discuss with the client about their project description based on a note previous project manager made. + + In any of following step, if client ask you to cancel the task, reject the task refer to (c) + + Step 1: Take a look at the wiki page named 'initial note' in the repo mentioned in system message, report an issue refer to (a) if not found. + + Step 1.1 Keep on discussing with client focus on completing the checklist in the initial note, make sure everything is cleared. + + Step 2: Once everything on the checklist is cleared, make a project plan in markdown, save it to `~/temp_proj_plan.md` + + Step 3: Send the content of your project plan to client in plain text and require their confirmation refer to (d) + + Step 3.1: If they do not agree with your plan, ask them for more information to improve and refine your project plan draft, always save the latest version to ~/temp_proj_plan.md and repeat step 3 + + Step 4: If they approved your project plan, post the approved version to wiki page with title 'project plan' under repo mentioned in system message. + + Step 4.1 If the creation of wiki page is not a successful, report issue refer to (a) + + Step 4.2 If wiki page created successfully, delete `~/temp_proj_plan.md` + + Step 5: Complete the task refer to (b) + + """; + + Dictionary> result = + new Dictionary>() + { + { + "variable", + new Dictionary() + { + { "gitea_account", pmGiteaAccount}, + { "gitea_password", pmGiteaPassword }, + { "gitea_token", pmGiteaToken }, + { "ssh_workspace", pmSshHost }, + { "ssh_user", pmSshUser }, + { "system_msg_welcome", Alchegos.Core.SystemMessages.General.WelcomeSystemMessage(pmRole, pmGiteaAccount, pmSshHost, pmSshUser) }, + { "system_msg_initial_note", InitialNoteSystemMessage()}, + { "system_msg_first_discussion", FirstDiscussionSystemMessage() }, + } + } + }; + return Results.Ok(result); +}).WithName("GetVariables"); \ No newline at end of file diff --git a/Worker.cs b/Worker.cs deleted file mode 100644 index ad21c02..0000000 --- a/Worker.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Alchegos.ProjectManager; - -public class Worker : BackgroundService -{ - private readonly ILogger _logger; - - public Worker(ILogger logger) - { - _logger = logger; - } - - protected override async Task ExecuteAsync(CancellationToken stoppingToken) - { - while (!stoppingToken.IsCancellationRequested) - { - if (_logger.IsEnabled(LogLevel.Information)) - { - _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); - } - - await Task.Delay(1000, stoppingToken); - } - } -} \ No newline at end of file diff --git a/appsettings.Development.json b/appsettings.Development.json index b2dcdb6..10f68b8 100644 --- a/appsettings.Development.json +++ b/appsettings.Development.json @@ -2,7 +2,8 @@ "Logging": { "LogLevel": { "Default": "Information", - "Microsoft.Hosting.Lifetime": "Information" + "Microsoft.AspNetCore": "Warning" } - } + }, + "AllowedHosts": "*" } diff --git a/appsettings.json b/appsettings.json index b2dcdb6..10f68b8 100644 --- a/appsettings.json +++ b/appsettings.json @@ -2,7 +2,8 @@ "Logging": { "LogLevel": { "Default": "Information", - "Microsoft.Hosting.Lifetime": "Information" + "Microsoft.AspNetCore": "Warning" } - } + }, + "AllowedHosts": "*" }