Ship as tm with install to GOPATH/bin and sandbox env overrides.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Skruecken
2026-10-19 13:55:54 +02:00
co-authored by Cursor
parent 2dcab9e4d8
commit f3a592f3ea
8 changed files with 110 additions and 19 deletions
+24 -5
View File
@@ -5,14 +5,28 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
)
// ResolveHome returns the effective home for config/data paths.
// TASK_MASTER_HOME overrides the real user home (useful for demos/dev sandboxes).
func ResolveHome() (string, error) {
if h := strings.TrimSpace(os.Getenv(envHome)); h != "" {
return filepath.Clean(h), nil
}
home, err := os.UserHomeDir()
if err != nil {
return "", fmt.Errorf("resolve home directory: %w", err)
}
return home, nil
}
// LoadOrCreate loads the config from disk, creating defaults if missing.
// It also ensures DataDir and the active project directory exist.
func LoadOrCreate() (*Config, error) {
home, err := os.UserHomeDir()
home, err := ResolveHome()
if err != nil {
return nil, fmt.Errorf("resolve home directory: %w", err)
return nil, err
}
cfgPath := Path(home)
@@ -26,6 +40,10 @@ func LoadOrCreate() (*Config, error) {
return nil, err
}
if d := strings.TrimSpace(os.Getenv(envDataDir)); d != "" {
cfg.DataDir = filepath.Clean(d)
}
if err := ensureDataDirs(cfg); err != nil {
return nil, err
}
@@ -54,11 +72,12 @@ func readOrCreate(cfgPath, home string) (*Config, error) {
return &cfg, nil
}
// Save writes the config to ~/.config/task-master/config.json.
// Save writes the config to ~/.config/task-master/config.json
// (or under TASK_MASTER_HOME when set).
func Save(cfg *Config) error {
home, err := os.UserHomeDir()
home, err := ResolveHome()
if err != nil {
return fmt.Errorf("resolve home directory: %w", err)
return err
}
cfgPath := Path(home)