Skip to content

A programming framework for agentic AI

implement cli commands

Kosta Petanda38ad5dda61
diff --git a/cli/Program.cs b/cli/Program.cs
index fa2fb4d5f..014f5e3a9 100644
--- a/cli/Program.cs
+++ b/cli/Program.cs
@@ -1,4 +1,5 @@
using System;
+using System.CommandLine;
using System.IO;
using System.Net.Http;
using System.Text.Json;
@@ -8,31 +9,57 @@ class Program
{
static async Task Main(string[] args)
{
- if (args.Length != 3)
- {
- Console.WriteLine("Usage: dotnet run <skillName> <functionName> <fileName>");
- return;
- }
+ var fileOption = new Option<FileInfo?>(
+ name: "--file",
+ description: "The file used for input to the skill function");
+
+ var rootCommand = new RootCommand("CLI tool for the AI Dev team");
+ rootCommand.AddGlobalOption(fileOption);
+
+ var pmCommand = new Command("pm", "Commands for the PM team");
+ var pmReadmeCommand = new Command("readme", "Produce a Readme for a given input");
+ pmReadmeCommand.SetHandler(async (file) => await CallFunction(nameof(PM), PM.Readme , file.FullName), fileOption);
+
+ var pmBootstrapCommand = new Command("bootstrap", "Bootstrap a project for a given input");
+ pmBootstrapCommand.SetHandler(async (file) => await CallFunction(nameof(PM), PM.BootstrapProject, file.FullName), fileOption);
- var skillName = args[0];
- var functionName = args[1];
- var filePath = args[2];
+ pmCommand.AddCommand(pmReadmeCommand);
+ pmCommand.AddCommand(pmBootstrapCommand);
- if (!File.Exists(filePath))
+ var devleadCommand = new Command("devlead", "Commands for the Dev Lead team");
+ var devleadPlanCommand = new Command("plan", "Plan the work for a given input");
+ devleadPlanCommand.SetHandler(async (file) => await CallFunction(nameof(DevLead), DevLead.Plan, file.FullName), fileOption);
+ devleadCommand.AddCommand(devleadPlanCommand);
+
+ var devCommand = new Command("dev", "Commands for the Dev team");
+ var devPlanCommand = new Command("plan", "Implement the module for a given input");
+ devPlanCommand.SetHandler(async (file) => await CallFunction(nameof(Developer), Developer.Implement, file.FullName), fileOption);
+ devCommand.AddCommand(devPlanCommand);
+
+ rootCommand.AddCommand(pmCommand);
+ rootCommand.AddCommand(devleadCommand);
+ rootCommand.AddCommand(devCommand);
+
+ await rootCommand.InvokeAsync(args);
+ }
+
+ public static async Task CallFunction(string skillName, string functionName, string file)
+ {
+ if (!File.Exists(file))
{
- Console.WriteLine($"File not found: {filePath}");
+ Console.WriteLine($"File not found: {file}");
return;
}
var variables = new[]
{
- new { key = "input", value = File.ReadAllText(filePath) }
+ new { key = "input", value = File.ReadAllText(file) }
};
var requestBody = new { variables };
var requestBodyJson = JsonSerializer.Serialize(requestBody);
- Console.WriteLine($"Calling skill '{skillName}' function '{functionName}' with file '{filePath}'");
+ Console.WriteLine($"Calling skill '{skillName}' function '{functionName}' with file '{file}'");
Console.WriteLine(requestBodyJson);
using var httpClient = new HttpClient();
@@ -59,5 +86,8 @@ class Program
}
return;
}
+}
-}
\ No newline at end of file
+public static class PM { public static string Readme = "Readme"; public static string BootstrapProject = "BootstrapProject"; }
+public static class DevLead { public static string Plan="Plan"; }
+public static class Developer { public static string Implement="Implement"; }
\ No newline at end of file
diff --git a/cli/cli.csproj b/cli/cli.csproj
index d17defa96..1b19e9dce 100644
--- a/cli/cli.csproj
+++ b/cli/cli.csproj
@@ -2,13 +2,14 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
- <TargetFramework>net7.0</TargetFramework>
+ <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
+ <PublishAot>true</PublishAot>
<Nullable>enable</Nullable>
</PropertyGroup>
- <ItemGroup>
- <PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.1.1" />
+ <ItemGroup>
+ <PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
</ItemGroup>
</Project>