Skip to content

Commit bd31560

Browse files
committed
feat: show latest version hint on init and activate
Users see "Welcome to ClawWork! (v0.1.33) → latest: v0.1.36, run: clawwork update" so they know immediately when their version is outdated.
1 parent b995fdb commit bd31560

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

cmd/clawwork/main.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ func initCmd() *cobra.Command {
7676
}
7777

7878
func runInit(cmd *cobra.Command, _ []string) error {
79-
fmt.Printf(tr("Welcome to ClawWork! (v%s)\n", "欢迎使用 ClawWork!(v%s)\n"), version)
80-
81-
// Non-blocking remote version check
79+
// Non-blocking remote version check — show alongside welcome
8280
type versionResult struct {
8381
info *updater.VersionInfo
8482
err error
@@ -88,13 +86,15 @@ func runInit(cmd *cobra.Command, _ []string) error {
8886
info, err := updater.CheckUpdate(version)
8987
versionCh <- versionResult{info, err}
9088
}()
89+
var latestHint string
9190
select {
9291
case r := <-versionCh:
9392
if r.err == nil && r.info != nil {
94-
fmt.Printf(tr("Update available: v%s → v%s (run: clawwork update)\n", "发现可用更新:v%s → v%s运行:clawwork update\n"), version, r.info.Version)
93+
latestHint = fmt.Sprintf(tr(" → latest: v%s, run: clawwork update", " → 最新版:v%s运行:clawwork update"), r.info.Version)
9594
}
9695
case <-time.After(2 * time.Second):
9796
}
97+
fmt.Printf(tr("Welcome to ClawWork! (v%s)%s\n", "欢迎使用 ClawWork!(v%s)%s\n"), version, latestHint)
9898
fmt.Println()
9999

100100
scanner := bufio.NewScanner(os.Stdin)
@@ -1331,6 +1331,12 @@ func runActivate(_ *cobra.Command, _ []string) error {
13311331
}
13321332
i18n.ApplyPreference(cfg.UI.Language)
13331333

1334+
// Version hint
1335+
if info, verr := updater.CheckUpdate(version); verr == nil && info != nil {
1336+
fmt.Printf(tr("Current: v%s → latest: v%s (run: clawwork update)\n\n",
1337+
"当前版本:v%s → 最新版:v%s(运行:clawwork update)\n\n"), version, info.Version)
1338+
}
1339+
13341340
// Check if already activated (config.toml keys or legacy keys.json)
13351341
if cfg.Agent.PublicKey != "" && cfg.Agent.PrivateKey != "" {
13361342
fmt.Println(tr("ClawAuth identity already active.", "ClawAuth 身份已激活。"))

0 commit comments

Comments
 (0)