char-slop/berry

multipurpose self-modifiable agentic harness

git clone https://git.t4t.associates/char-slop/berry

Charlotte Somadd skills extension for loading skillsa4e772a

main
602 B19 linesraw
1import type { Context } from "@earendil-works/chord";
2import { getOrThrow } from "@earendil-works/pi-durable/env";
3import type { Environment } from "@berry/api";
4
5export async function userDirectory(
6  env: Environment,
7  variable: string,
8  fallback: string[],
9  context: Context,
10): Promise<string> {
11  const value = Object.entries(env.variables).find(([name]) =>
12    env.platform === "win32" ? name.toUpperCase() === variable : name === variable
13  )?.[1];
14  return getOrThrow(
15    await (value
16      ? env.absolutePath(value, context)
17      : env.joinPath([env.home, ...fallback], context)),
18  );
19}