add: hci
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<Nullable>disable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
|
||||
USER $APP_UID
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
EXPOSE 8081
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
|
||||
143
Program.cs
143
Program.cs
@@ -1,12 +1,9 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.MapOpenApi();
|
||||
@@ -14,28 +11,128 @@ if (app.Environment.IsDevelopment())
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
var summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
string WelcomeSystemMessage(
|
||||
string role,
|
||||
string giteaAccount,
|
||||
string sshHost,
|
||||
string sshUser
|
||||
) => $$"""
|
||||
You are a {{role}} working remotely. This is a welcome and guide to prepare your work.
|
||||
First you need to establish and maintain an SSH connection to your assigned workspace
|
||||
1. Create a new terminal session using a label begins with {{giteaAccount}}
|
||||
Keep the terminal session id returned by terminal session creation tool.
|
||||
You will reference the session by its session ID, not the label for all future commands.
|
||||
2. Execute the command `ssh {{sshUser}}@{{sshHost}}`
|
||||
Suggest to use this command with one off command tool, with a timeout set to 1000
|
||||
3. Verify if the terminal session connected to your workspace by executing `id -un`, excepted output is {{sshUser}}.
|
||||
4. If you didn't see the expected output, close your terminal session and response to client in the following format:
|
||||
{
|
||||
"status": "error",
|
||||
"info": "ssh connection failed",
|
||||
"reporter": {{role}}
|
||||
}
|
||||
Once your terminal shell successfully connected to the workspace, Have a look at `~/Guides`,
|
||||
this document will give you further instructions on your role and workflow.
|
||||
Check the presence and completeness of this file, if this file is missing, close your terminal session and respond a valid JSON in the following format:
|
||||
{
|
||||
"status": "error",
|
||||
"info": "guide missing/incomplete",
|
||||
"reporter": "{{role}}"
|
||||
}
|
||||
""";
|
||||
|
||||
app.MapGet("/weatherforecast", () =>
|
||||
string ProjectManagerNewNoteSystemMessage() =>
|
||||
"""
|
||||
Your current task is establishing a draft plan for the client's need, client will provide you a initial project description.
|
||||
The description might be naive and not very clear, discuss with the client until it is clear and you both agreed on it.
|
||||
Following `~/Guide` to give this project a name, make a note about the project plan so that team member not presence in the discussion could fully understand the goal.
|
||||
Try your best to make the note short, dont explain any concept in your note that an expert should know, only briefly explain concept created by the client.
|
||||
Once you finished the note, close your working terminal session and respond a valid JSON in the following format:
|
||||
{
|
||||
var forecast = Enumerable.Range(1, 5).Select(index =>
|
||||
new WeatherForecast
|
||||
(
|
||||
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
Random.Shared.Next(-20, 55),
|
||||
summaries[Random.Shared.Next(summaries.Length)]
|
||||
))
|
||||
.ToArray();
|
||||
return forecast;
|
||||
"status": "task_completed",
|
||||
“project”: "(the name you given to this project)"
|
||||
}
|
||||
""";
|
||||
|
||||
string ProjectManagerBreakDownPlanSystemMessage() =>
|
||||
"""
|
||||
Your current task is breaking down the initial draft plan into detailed stages and tasks
|
||||
Following instructions on `~/Guide` to find the note previous project manager made for the project plan.
|
||||
Analyze and break goal down into subgoal of stages(nightly, alpha, beta, rc, release) and design detailed, feasible tasks for each stage.
|
||||
Each task you designed should be clear, short and have as few dependencies on other tasks as possible,
|
||||
Following instructions on `~/Guide` to make another note fully describe tasks designed, keep note brief, an expert should be able to understand your note without any explanation
|
||||
Once you finished the note, close your working terminal session and respond a valid JSON in the following format:
|
||||
{
|
||||
"status": "task_completed"
|
||||
}
|
||||
""";
|
||||
|
||||
string ProjectManagerEstimateCostSystemMessage() =>
|
||||
"""
|
||||
Your current task is to estimate the cost of developing the current stage of project based on the designed tasks.
|
||||
You can find the task design note the previous project manager made following instructions on `~/Guide`.
|
||||
Foreach task, estimate difficulty and effort in hours for a trained developer to accomplish.
|
||||
for easy tasks, it will be $0.25 per hour, middle task will be $0.5 per hour, hard task will be $2 per hour.
|
||||
Calculate the total cost by calculate hours times rate for all tasks in current stage, and sum it up.
|
||||
Once you finished the calculation, close your working terminal session and respond valid JSON in the following format:
|
||||
{
|
||||
"status": "task_completed",
|
||||
"estimated total cost": "(your result, a float number)",
|
||||
"stage": "(current stage, use `~/guide` to find out)"
|
||||
}
|
||||
""";
|
||||
|
||||
string ProjectManagerPostTasksSystemMessage(string giteaAccount) =>
|
||||
$$"""
|
||||
Following instructions on `~/Guide` to get information of the project and its current stage as well as the note of all designed tasks
|
||||
Your current task is posting tasks of this stage to gitea, external tool will help you communicate with gitea, all you need to do is responding valid JSON in the following format:
|
||||
{
|
||||
"status": "posting_tasks",
|
||||
"is_end": (true if this is the last task in the stage to post, false otherwise),
|
||||
"owner": "{{giteaAccount}}",
|
||||
"repo": "(repo name of this project)",
|
||||
"title": "(title of the task, begins with [TASK])",
|
||||
"body": "(full description of this task)"
|
||||
}
|
||||
one response per task, give the next response when you receive a message 'next'
|
||||
when you receive message 'finish'
|
||||
you should close your working terminal session and response
|
||||
{
|
||||
"status": "task_completed"
|
||||
}
|
||||
""";
|
||||
|
||||
app.MapGet("/pm", () =>
|
||||
{
|
||||
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");
|
||||
|
||||
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", WelcomeSystemMessage(pmRole, pmGiteaAccount, pmSshHost, pmSshUser) },
|
||||
{ "system_msg_new_note", ProjectManagerNewNoteSystemMessage() },
|
||||
{ "system_msg_break_down_plan", ProjectManagerBreakDownPlanSystemMessage()},
|
||||
{ "system_msg_estimate_cost", ProjectManagerEstimateCostSystemMessage()},
|
||||
{ "system_msg_post_tasks", ProjectManagerPostTasksSystemMessage(pmGiteaAccount)}
|
||||
}
|
||||
}
|
||||
};
|
||||
return Results.Ok(result);
|
||||
})
|
||||
.WithName("GetWeatherForecast");
|
||||
.WithName("GetProjectManagerVariable");
|
||||
|
||||
app.Run();
|
||||
|
||||
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
|
||||
{
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
}
|
||||
Reference in New Issue
Block a user