diff --git a/cmd/agent.go b/cmd/agent.go index ff4ecce7..8c4ad462 100644 --- a/cmd/agent.go +++ b/cmd/agent.go @@ -15,7 +15,7 @@ import ( var agentCmd = &cobra.Command{ Use: "agent", Short: "Manage custom agent personas", - Long: "Create, list, and manage custom agent personas stored in ~/.hawk/agents/.", + Long: "Create, list, and manage custom agent personas stored in Hawk user state.", } var agentListCmd = &cobra.Command{ diff --git a/cmd/audit.go b/cmd/audit.go index d3c9d537..e3332bf6 100644 --- a/cmd/audit.go +++ b/cmd/audit.go @@ -10,6 +10,7 @@ import ( "time" "github.com/GrayCodeAI/hawk/internal/hooks/audit" + "github.com/GrayCodeAI/hawk/internal/storage" "github.com/spf13/cobra" ) @@ -175,16 +176,11 @@ type SessionInfo struct { } func discoverSessions(days int, projectFilter string) ([]SessionInfo, error) { - home, err := os.UserHomeDir() - if err != nil { - return nil, err - } - cutoff := time.Now().AddDate(0, 0, -days) var sessions []SessionInfo // Scan hawk sessions directory - hawkDir := filepath.Join(home, ".hawk", "sessions") + hawkDir := storage.SessionsDir() entries, err := os.ReadDir(hawkDir) if err != nil && !os.IsNotExist(err) { return nil, err diff --git a/cmd/bg_sessions.go b/cmd/bg_sessions.go index 1ea3357b..c4822cd5 100644 --- a/cmd/bg_sessions.go +++ b/cmd/bg_sessions.go @@ -10,7 +10,7 @@ import ( "strings" "time" - "github.com/GrayCodeAI/hawk/internal/home" + "github.com/GrayCodeAI/hawk/internal/storage" "github.com/spf13/cobra" ) @@ -19,8 +19,7 @@ import ( // ───────────────────────────────────────────────────────────────────────────── func bgSessionsDir() string { - home := home.Dir() - return filepath.Join(home, ".hawk", "bg-sessions") + return filepath.Join(storage.StateDir(), "bg-sessions") } // BGSessionInfo tracks a running background session. diff --git a/cmd/chat.go b/cmd/chat.go index c6c8bb22..2f658f3c 100644 --- a/cmd/chat.go +++ b/cmd/chat.go @@ -30,7 +30,6 @@ import ( "github.com/GrayCodeAI/hawk/internal/engine" "github.com/GrayCodeAI/hawk/internal/feature/shellmode" "github.com/GrayCodeAI/hawk/internal/feature/taste" - "github.com/GrayCodeAI/hawk/internal/home" "github.com/GrayCodeAI/hawk/internal/intelligence/memory" "github.com/GrayCodeAI/hawk/internal/intelligence/repomap" "github.com/GrayCodeAI/hawk/internal/observability/logger" @@ -38,6 +37,7 @@ import ( "github.com/GrayCodeAI/hawk/internal/sandbox" "github.com/GrayCodeAI/hawk/internal/session" "github.com/GrayCodeAI/hawk/internal/startup" + hawkstorage "github.com/GrayCodeAI/hawk/internal/storage" "github.com/GrayCodeAI/hawk/internal/system/staleness" "github.com/GrayCodeAI/hawk/internal/ui/icons" ) @@ -152,11 +152,9 @@ func newChatModel(ref *progRef, systemPrompt string, settings hawkconfig.Setting // Initialize conversation DAG for branching support startup.MarkPhase("newChatModel:dag") - if home, err := os.UserHomeDir(); err == nil { - dagPath := filepath.Join(home, ".hawk", "sessions", "convo.db") - if dag, err := storage.NewDAG(dagPath, sid); err == nil { - sess.SetConvoDAG(dag) - } + dagPath := filepath.Join(hawkstorage.SessionsDir(), "convo.db") + if dag, err := storage.NewDAG(dagPath, sid); err == nil { + sess.SetConvoDAG(dag) } startup.EndPhase("newChatModel:dag") @@ -241,8 +239,7 @@ func newChatModel(ref *progRef, systemPrompt string, settings hawkconfig.Setting // Check for crash recovery startup.MarkPhase("newChatModel:crash-recovery") if recovered := session.CheckForRecovery(); len(recovered) > 0 { - home := home.Dir() - walDir := filepath.Join(home, ".hawk", "sessions") + walDir := hawkstorage.SessionsDir() for _, rid := range recovered { if rid == sid { continue // current session WAL diff --git a/cmd/chat_commands_session.go b/cmd/chat_commands_session.go index e1330f41..e2ea8680 100644 --- a/cmd/chat_commands_session.go +++ b/cmd/chat_commands_session.go @@ -12,8 +12,8 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/GrayCodeAI/eyrie/client" - "github.com/GrayCodeAI/hawk/internal/home" "github.com/GrayCodeAI/hawk/internal/session" + "github.com/GrayCodeAI/hawk/internal/storage" ) // saveSession persists the current session to disk. @@ -234,8 +234,7 @@ func (m *chatModel) handleSessionCommand(cmd string, parts []string, text string return m, nil case "/export": - homeDir := home.Dir() - exportDir := filepath.Join(homeDir, ".hawk", "exports") + exportDir := filepath.Join(storage.StateDir(), "exports") _ = os.MkdirAll(exportDir, 0o755) exportPath := filepath.Join(exportDir, m.sessionID+".md") var md strings.Builder @@ -258,8 +257,7 @@ func (m *chatModel) handleSessionCommand(cmd string, parts []string, text string return m, nil case "/share": - homeDir := home.Dir() - exportDir := filepath.Join(homeDir, ".hawk", "exports") + exportDir := filepath.Join(storage.StateDir(), "exports") _ = os.MkdirAll(exportDir, 0o755) exportPath := filepath.Join(exportDir, m.sessionID+".md") var md strings.Builder @@ -286,8 +284,7 @@ func (m *chatModel) handleSessionCommand(cmd string, parts []string, text string return m, nil } newName := parts[1] - homeDir := home.Dir() - sessDir := filepath.Join(homeDir, ".hawk", "sessions") + sessDir := storage.SessionsDir() oldPath := filepath.Join(sessDir, m.sessionID+".jsonl") newPath := filepath.Join(sessDir, newName+".jsonl") if err := os.Rename(oldPath, newPath); err != nil { @@ -303,8 +300,7 @@ func (m *chatModel) handleSessionCommand(cmd string, parts []string, text string m.messages = append(m.messages, displayMsg{role: "system", content: "Usage: /tag