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>
This commit is contained in:
57
pkg/config/home.go
Normal file
57
pkg/config/home.go
Normal file
@@ -0,0 +1,57 @@
|
||||
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")
|
||||
}
|
||||
Reference in New Issue
Block a user