Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960package config
import ( "os" "path/filepath")
func isAlbedoRoot(dir string) bool { if dir == "" { return false } if _, err := os.Stat(filepath.Join(dir, "apps", "albedo", "gleam.toml")); err == nil { if _, err := os.Stat(filepath.Join(dir, "apps", "albedo", "src", "albedo.gleam")); err == nil { return true } } return false}
func ProjectRoot(buildRoot string) string { if env := os.Getenv("ALBEDO_ROOT"); env != "" && isAlbedoRoot(env) { return env } if exe, err := os.Executable(); err == nil { if resolved, err := filepath.EvalSymlinks(exe); err == nil { exe = resolved } // Check exe/../.. (e.g. repo/cli/bin/albedo -> repo) parent2 := filepath.Dir(filepath.Dir(exe)) if isAlbedoRoot(parent2) { return parent2 } parent3 := filepath.Dir(parent2) if isAlbedoRoot(parent3) { return parent3 } } if buildRoot != "" && isAlbedoRoot(buildRoot) { return buildRoot } if cwd, err := os.Getwd(); err == nil { cur := cwd for { if isAlbedoRoot(cur) { return cur } parent := filepath.Dir(cur) if parent == cur { break } cur = parent } } if buildRoot != "" { return buildRoot } cwd, _ := os.Getwd() return cwd}