CLI: Fix onboard advisory to update the configuration and security files

This commit is contained in:
Michel Santos 2026-04-12 13:21:00 -04:00
parent 6d03791929
commit 30cac9006f

View file

@ -2,9 +2,12 @@ package cliui
import ( import (
"fmt" "fmt"
"path/filepath"
"strings" "strings"
"github.com/charmbracelet/lipgloss" "github.com/charmbracelet/lipgloss"
"github.com/sipeed/picoclaw/pkg/config"
) )
// PrintOnboardComplete prints the post-onboard “ready” message and next steps. // PrintOnboardComplete prints the post-onboard “ready” message and next steps.
@ -24,9 +27,11 @@ func printOnboardPlain(logo string, encrypt bool, configPath string) {
fmt.Println(" export PICOCLAW_KEY_PASSPHRASE=<your-passphrase> # Linux/macOS") fmt.Println(" export PICOCLAW_KEY_PASSPHRASE=<your-passphrase> # Linux/macOS")
fmt.Println(" set PICOCLAW_KEY_PASSPHRASE=<your-passphrase> # Windows cmd") fmt.Println(" set PICOCLAW_KEY_PASSPHRASE=<your-passphrase> # Windows cmd")
fmt.Println("") fmt.Println("")
fmt.Println(" 2. Add your API key to", configPath) fmt.Println(" 2. Add your selected LLM to the `model_name` field in", configPath)
fmt.Println(" 3. Add your API key to", securityPath(configPath))
} else { } else {
fmt.Println(" 1. Add your API key to", configPath) fmt.Println(" 1. Add your selected LLM to the `model_name` field in", configPath)
fmt.Println(" 2. Add your API key to", securityPath(configPath))
} }
fmt.Println("") fmt.Println("")
fmt.Println(" Recommended:") fmt.Println(" Recommended:")
@ -36,9 +41,9 @@ func printOnboardPlain(logo string, encrypt bool, configPath string) {
fmt.Println(" See README.md for 17+ supported providers.") fmt.Println(" See README.md for 17+ supported providers.")
fmt.Println("") fmt.Println("")
if encrypt { if encrypt {
fmt.Println(" 3. Chat: picoclaw agent -m \"Hello!\"") fmt.Println(" 4. Chat: picoclaw agent -m \"Hello!\"")
} else { } else {
fmt.Println(" 2. Chat: picoclaw agent -m \"Hello!\"") fmt.Println(" 3. Chat: picoclaw agent -m \"Hello!\"")
} }
} }
@ -85,13 +90,19 @@ func buildOnboardingSteps(encrypt bool, configPath string) string {
b.WriteString("1. Set your encryption passphrase before starting picoclaw:\n") b.WriteString("1. Set your encryption passphrase before starting picoclaw:\n")
b.WriteString(" export PICOCLAW_KEY_PASSPHRASE=<your-passphrase> # Linux/macOS\n") b.WriteString(" export PICOCLAW_KEY_PASSPHRASE=<your-passphrase> # Linux/macOS\n")
b.WriteString(" set PICOCLAW_KEY_PASSPHRASE=<your-passphrase> # Windows cmd\n\n") b.WriteString(" set PICOCLAW_KEY_PASSPHRASE=<your-passphrase> # Windows cmd\n\n")
b.WriteString("2. Add your API key to\n ") b.WriteString("2. Add your selected LLM to the `model_name` field in\n ")
b.WriteString(configPath) b.WriteString(configPath)
b.WriteString("\n") b.WriteString("\n")
b.WriteString("3. Add your API key to\n ")
b.WriteString(securityPath(configPath))
b.WriteString("\n")
} else { } else {
b.WriteString("1. Add your API key to\n ") b.WriteString("1. Add your selected LLM to the `model_name` field in\n ")
b.WriteString(configPath) b.WriteString(configPath)
b.WriteString("\n") b.WriteString("\n")
b.WriteString("2. Add your API key to\n ")
b.WriteString(securityPath(configPath))
b.WriteString("\n")
} }
return b.String() return b.String()
} }
@ -104,7 +115,15 @@ func recommendedBlock() string {
func chatStep(encrypt bool) string { func chatStep(encrypt bool) string {
if encrypt { if encrypt {
return "4. Chat:\n picoclaw agent -m \"Hello!\""
}
return "3. Chat:\n picoclaw agent -m \"Hello!\"" return "3. Chat:\n picoclaw agent -m \"Hello!\""
} }
return "2. Chat:\n picoclaw agent -m \"Hello!\""
// Derive the expected path of the security configuration file
// from the general configuration file path.
// NOTE: Function duplicated from config/security.go#securityPath()
func securityPath(configPath string) string {
configDir := filepath.Dir(configPath)
return filepath.Join(configDir, config.SecurityConfigFile)
} }