mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-16 23:02:04 +00:00
Integrate OpenHandoff factory workspace
This commit is contained in:
parent
3d9476ed0b
commit
049504986b
251 changed files with 42824 additions and 692 deletions
25
factory/packages/cli/src/workspace/config.ts
Normal file
25
factory/packages/cli/src/workspace/config.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { dirname } from "node:path";
|
||||
import { homedir } from "node:os";
|
||||
import * as toml from "@iarna/toml";
|
||||
import { ConfigSchema, resolveWorkspaceId, type AppConfig } from "@openhandoff/shared";
|
||||
|
||||
export const CONFIG_PATH = `${homedir()}/.config/openhandoff/config.toml`;
|
||||
|
||||
export function loadConfig(path = CONFIG_PATH): AppConfig {
|
||||
if (!existsSync(path)) {
|
||||
return ConfigSchema.parse({});
|
||||
}
|
||||
|
||||
const raw = readFileSync(path, "utf8");
|
||||
return ConfigSchema.parse(toml.parse(raw));
|
||||
}
|
||||
|
||||
export function saveConfig(config: AppConfig, path = CONFIG_PATH): void {
|
||||
mkdirSync(dirname(path), { recursive: true });
|
||||
writeFileSync(path, toml.stringify(config), "utf8");
|
||||
}
|
||||
|
||||
export function resolveWorkspace(flagWorkspace: string | undefined, config: AppConfig): string {
|
||||
return resolveWorkspaceId(flagWorkspace, config);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue