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