import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);

// src/vault/resolve.ts
import path from "path";
import os from "os";
import { execFileSync } from "child_process";
function resolveVaultDir(cwd = process.cwd()) {
  if (process.env.MYCO_VAULT_DIR) {
    const dir = process.env.MYCO_VAULT_DIR;
    if (dir.startsWith("~/")) {
      return path.join(os.homedir(), dir.slice(2));
    }
    return dir;
  }
  return path.join(resolveRepoRoot(cwd), ".myco");
}
function resolveRepoRoot(cwd) {
  try {
    const gitCommon = execFileSync(
      "git",
      ["rev-parse", "--git-common-dir"],
      { cwd, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
    ).trim();
    return path.resolve(cwd, gitCommon, "..");
  } catch {
    return cwd;
  }
}

export {
  resolveVaultDir
};
//# sourceMappingURL=chunk-N33KUCFP.js.map