add: gitea tools

This commit is contained in:
h z
2025-05-08 01:14:41 +01:00
parent d73a724ce9
commit b1642aa6a3
9 changed files with 150 additions and 45 deletions

View File

@@ -1,20 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Worker"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>dotnet-Alchegos.ProjectManager-dadb124f-e818-4185-b3a6-9bed4c585ae8</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2"/> <None Include="NuGet.Config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="..\.dockerignore"> <PackageReference Include="Alchegos.Core" Version="0.0.4" />
<Link>.dockerignore</Link>
</Content>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -5,15 +5,15 @@ WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Release ARG BUILD_CONFIGURATION=Release
WORKDIR /src WORKDIR /src
COPY ["Alchegos.ProjectManager/Alchegos.ProjectManager.csproj", "Alchegos.ProjectManager/"] COPY ["Alchegos.ProjectManager/Alchegos.ProjectManager.csproj", "./"]
RUN dotnet restore "Alchegos.ProjectManager/Alchegos.ProjectManager.csproj" RUN dotnet restore "Alchegos.ProjectManager/Alchegos.ProjectManager.csproj"
COPY . . COPY . .
WORKDIR "/src/Alchegos.ProjectManager" WORKDIR "/src/"
RUN dotnet build "Alchegos.ProjectManager.csproj" -c $BUILD_CONFIGURATION -o /app/build RUN dotnet build "Alchegos.ProjectManager.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish FROM build AS publish
ARG BUILD_CONFIGURATION=Release 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 FROM base AS final
WORKDIR /app WORKDIR /app

35
Guide/Tasks/Task1.md Normal file
View File

@@ -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.
---

15
Guide/index.md Normal file
View File

@@ -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

7
NuGet.Config Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="hangman-lab" value="https://git.hangman-lab.top/api/packages/hzhang/nuget/index.json" />
</packageSources>
</configuration>

View File

@@ -1,7 +1,82 @@
using Alchegos.ProjectManager; var builder = WebApplication.CreateBuilder(args);
var builder = Host.CreateApplicationBuilder(args); var app = builder.Build();
builder.Services.AddHostedService<Worker>();
var host = builder.Build(); app.UseHttpsRedirection();
host.Run();
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 `~/<projectname>_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<string, Dictionary<string, string>> result =
new Dictionary<string, Dictionary<string, string>>()
{
{
"variable",
new Dictionary<string, string>()
{
{ "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");

View File

@@ -1,24 +0,0 @@
namespace Alchegos.ProjectManager;
public class Worker : BackgroundService
{
private readonly ILogger<Worker> _logger;
public Worker(ILogger<Worker> 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);
}
}
}

View File

@@ -2,7 +2,8 @@
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",
"Microsoft.Hosting.Lifetime": "Information" "Microsoft.AspNetCore": "Warning"
}
} }
},
"AllowedHosts": "*"
} }

View File

@@ -2,7 +2,8 @@
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",
"Microsoft.Hosting.Lifetime": "Information" "Microsoft.AspNetCore": "Warning"
}
} }
},
"AllowedHosts": "*"
} }