Files
factory/pkg/config/home.go
vitya 561a7fd66f feat: L0b bootstrap scripts + L1 Go CLI structure
L0b (factory bootstrap):
- bootstrap.ps1 (Windows): pre-checks, interactive config, clone .factory, home.toml
- bootstrap.sh (Linux/Mac): same functionality for bash
- Idempotent re-run with home.toml verification

L1 (Go CLI):
- factory.yaml: manifest schema with components, deps, health-checks
- cmd/factory: Cobra CLI (install/update/status/diagnose)
- pkg/config: home.toml reader
- pkg/manifest: factory.yaml parser + topological sort
- pkg/health: health-check logic (file/dir/mcp_tool/command)

Scripts:
- build.sh: cross-compile for linux/win/darwin × amd64/arm64
- build.ps1: PowerShell cross-compile

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 23:59:09 +03:00

58 lines
1.2 KiB
Go

package config
import (
"fmt"
"os"
"path/filepath"
"time"
"github.com/BurntSushi/toml"
)
type HomeConfig struct {
ProjectsDir string `toml:"projects_dir"`
Client string `toml:"client"`
InstalledAt time.Time `toml:"installed_at"`
}
func GetHomePath() string {
homeDir, _ := os.UserHomeDir()
return filepath.Join(homeDir, ".config", "factory", "home.toml")
}
func LoadHome() (*HomeConfig, error) {
path := GetHomePath()
data, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("home.toml not found at %s (run L0b bootstrap first)", path)
}
var cfg HomeConfig
if err := toml.Unmarshal(data, &cfg); err != nil {
return nil, fmt.Errorf("failed to parse home.toml: %w", err)
}
// Validate
if cfg.ProjectsDir == "" {
return nil, fmt.Errorf("projects_dir is required in home.toml")
}
if cfg.Client == "" {
cfg.Client = "claude-code"
}
return &cfg, nil
}
func (h *HomeConfig) GetFactoryDir() string {
return filepath.Join(h.ProjectsDir, ".factory")
}
func (h *HomeConfig) GetManifestPath() string {
return filepath.Join(h.GetFactoryDir(), "factory.yaml")
}
func (h *HomeConfig) GetCommonDir() string {
return filepath.Join(h.ProjectsDir, ".common")
}