Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

670 B
Raw Blame
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Logger from "effect/Logger";
import { Path } from "effect/Path";
import { AlchemyContext } from "../AlchemyContext.ts";

export const fileLogger = Effect.fn(function* (
  ...segments: ReadonlyArray<string>
) {
  const { dotAlchemy } = yield* AlchemyContext;
  const fs = yield* FileSystem.FileSystem;
  const path = yield* Path;
  const logFile = path.join(dotAlchemy, "log", ...segments);

  yield* fs.makeDirectory(path.dirname(logFile), { recursive: true });

  return yield* Logger.formatLogFmt.pipe(
    Logger.toFile(logFile, {
      flag: "a",
    }),
  );
});