open-design/tools/launcher/OpenDesignLauncher.cs
marco 5dd70b5016
Some checks failed
ci / Validate workspace (push) Successful in 12m32s
landing-page-ci / Validate landing page (push) Successful in 9m41s
landing-page-deploy / Deploy landing page (push) Failing after 5m23s
github-metrics / Generate repository metrics SVG (push) Failing after 2m3s
refresh-contributors-wall / Refresh contributors wall cache bust (push) Failing after 11s
Initial import: open-design source for helix-mind.ai distribution
This repository contains the open-design daemon CLI source code, built
and packaged at https://helix-mind.ai/cli/open-design/latest.tgz for use
by the HelixMind /design slash command.

Licenses: Apache-2.0 (root) + MIT (skills/*)
2026-05-06 20:50:24 +02:00

96 lines
3.4 KiB
C#

using System;
using System.Diagnostics;
using System.IO;
namespace OpenDesignLauncher
{
internal static class Program
{
private static int Main()
{
Console.Title = "Open Design Launcher";
Console.WriteLine("Open Design launcher");
Console.WriteLine();
string repoRoot = FindRepoRoot(AppDomain.CurrentDomain.BaseDirectory);
if (repoRoot == null)
{
Console.Error.WriteLine("Could not find the Open Design repository root.");
Console.Error.WriteLine("Place OpenDesign.exe in the repository root next to package.json.");
Pause();
return 1;
}
Console.WriteLine("Repository: " + repoRoot);
if (!Directory.Exists(Path.Combine(repoRoot, "node_modules", ".pnpm")))
{
Console.WriteLine("Dependencies are missing. Running pnpm install first...");
// Requires corepack (bundled with Node 16.9+) so future maintainers know the dependency.
int installExit = RunCommand(repoRoot, "corepack pnpm install");
if (installExit != 0)
{
Console.Error.WriteLine("pnpm install failed with exit code " + installExit + ".");
Pause();
return installExit;
}
}
Console.WriteLine("Starting Open Design with pnpm tools-dev...");
Console.WriteLine();
int exitCode = RunCommand(repoRoot, "corepack pnpm tools-dev");
if (exitCode != 0)
{
Console.Error.WriteLine();
Console.Error.WriteLine("Open Design exited with code " + exitCode + ".");
Pause();
}
else
{
Console.WriteLine();
Console.WriteLine("Open Design command completed. Press any key to close this window.");
Console.ReadKey(true);
}
return exitCode;
}
private static string FindRepoRoot(string startDirectory)
{
DirectoryInfo current = new DirectoryInfo(startDirectory);
while (current != null)
{
string packageJson = Path.Combine(current.FullName, "package.json");
string workspace = Path.Combine(current.FullName, "pnpm-workspace.yaml");
if (File.Exists(packageJson) && File.Exists(workspace))
{
return current.FullName;
}
current = current.Parent;
}
return null;
}
private static int RunCommand(string workingDirectory, string command)
{
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = "cmd.exe";
info.Arguments = "/d /c \"" + command + "\"";
info.WorkingDirectory = workingDirectory;
info.UseShellExecute = false;
using (Process process = Process.Start(info))
{
process.WaitForExit();
return process.ExitCode;
}
}
private static void Pause()
{
Console.WriteLine("Press any key to close this window.");
Console.ReadKey(true);
}
}
}