var builder = WebApplication.CreateBuilder(args); builder.Services.AddOpenApi(); var app = builder.Build(); if (app.Environment.IsDevelopment()) { app.MapOpenApi(); } app.UseHttpsRedirection(); string WelcomeSystemMessage( string role, string giteaAccount, string sshHost, string sshUser ) => $$$""" You are a {{role}} working remotely. This message serves as a welcome and a guide to prepare for your work. additional info instructions: (a) - If you encounter any issue listed in this guide, report them in the additionalInfo field of your response. Use '{{{role}}}' as reporter. Also fill the workflow session with issueEncountered (b) - If you are asked to complete or reject your current task by system message, use the workflow field of your response to indicate that For every task, you should: First, establish and maintain an SSH connection to your assigned workspace by: 1. Create a new terminal session with a label that 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 subsequent commands. When executing command with terminal session tool, be aware of interactive commands. The terminal session tool cannot automatically determine if a command has completed normally, is still running, or is waiting for input. You can also use command execution tools to interact with a running command (e.g., sending 'y' or 'n' for confirmations) 2. Execute the command `ssh {{{sshUser}}}@{{{sshHost}}}` Suggest to execute this command with the one off command tool, setting timeout to 1000 You should be able to login without password, if not so, refer (a) to report 3. Verify if the terminal session connected to your workspace by executing `id -un`, expected output is {{{sshUser}}}. 4. If you don't see the expected output, close your terminal session/chat session(if any) and to report the issue, refer (a) Once your terminal shell successfully connected to the workspace, Have a look at `~/Guide/index.md`. That document contains further instructions regarding your role and workflow Check the presence of that file, if it is missing, close your terminal session and refer (a) to report it as an issue. """; string ProjectManagerBreakDownPlanSystemMessage() => """ Your current task is breaking down the initial draft plan into detailed stages and tasks Following instructions on `~/Guide/index.md` 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/index.md` 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> result = new Dictionary>() { { "variable", new Dictionary() { { "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_break_down_plan", ProjectManagerBreakDownPlanSystemMessage()}, { "system_msg_estimate_cost", ProjectManagerEstimateCostSystemMessage()}, { "system_msg_post_tasks", ProjectManagerPostTasksSystemMessage(pmGiteaAccount)} } } }; return Results.Ok(result); }) .WithName("GetProjectManagerVariable"); app.Run();