import fs from "node:fs/promises" import os from "node:os" import path from "node:path" const APP_DIR = path.join(os.homedir(), ".local", "share", "copilot-api") const GITHUB_TOKEN_PATH = path.join(APP_DIR, "github_token") export const PATHS = { APP_DIR, GITHUB_TOKEN_PATH, } export async function ensurePaths(): Promise { await fs.mkdir(PATHS.APP_DIR, { recursive: true }) await ensureFile(PATHS.GITHUB_TOKEN_PATH) } async function ensureFile(filePath: string): Promise { try { await fs.access(filePath, fs.constants.W_OK) } catch { await fs.writeFile(filePath, "") await fs.chmod(filePath, 0o600) } }