Skip to content

Commit 4c3f682

Browse files
committed
refactor: simplify clawwork status to clean two-column table
1 parent 95dff7e commit 4c3f682

1 file changed

Lines changed: 21 additions & 45 deletions

File tree

cmd/clawwork/main.go

Lines changed: 21 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -663,23 +663,6 @@ func runStatus(cmd *cobra.Command, _ []string) error {
663663
if ticket, _ := cmd.Flags().GetString("ticket"); ticket != "" {
664664
return runTicketBalance(strings.ToUpper(ticket))
665665
}
666-
// Show service status if platform supports it.
667-
if mgr, err := daemon.New(); err == nil {
668-
st, _ := mgr.Status()
669-
if st != nil {
670-
switch {
671-
case !st.Installed:
672-
fmt.Println(tr("Service: not installed", "服务状态: 未安装"))
673-
case st.Running:
674-
fmt.Printf(tr("Service: running (PID %d)\n", "服务状态: 运行中(PID %d)\n"), st.PID)
675-
default:
676-
fmt.Println(tr("Service: stopped", "服务状态: 已停止"))
677-
}
678-
fmt.Printf(tr("Log file: %s\n", "日志文件: %s\n"), st.LogPath)
679-
fmt.Println()
680-
}
681-
}
682-
683666
cfg, err := config.Load()
684667
if err != nil {
685668
return err
@@ -692,26 +675,14 @@ func runStatus(cmd *cobra.Command, _ []string) error {
692675
return fmt.Errorf(tr("failed to fetch status: %w", "获取状态失败:%w"), err)
693676
}
694677

695-
fmt.Printf(tr("Agent: %s (%s)\n", "Agent: %s (%s)\n"), resp.Agent.Name, resp.Agent.ID)
696-
fmt.Printf(tr("Wallet: %s\n", "钱包: %s\n"), resp.Agent.WalletAddress)
697-
fmt.Printf(tr("Inscriptions: %d total, %d confirmed\n", "铭文: 共 %d,已确认 %d\n"), resp.Inscriptions.Total, resp.Inscriptions.Confirmed)
698-
fmt.Printf(tr("CW Earned: %d\n", "CW 收益: %d\n"), resp.Inscriptions.TotalCW)
699-
fmt.Printf(tr("NFT Hit: %v\n", "NFT 命中: %v\n"), resp.Inscriptions.Hit)
700-
fmt.Printf(tr("Platform: %s (%d NFTs remaining)\n", "平台: %s(剩余 NFT %d)\n"), resp.Activity.Status, resp.Activity.NFTsRemaining)
701-
if resp.GenesisNFT != nil {
702-
fmt.Printf(tr("Genesis NFT: #%d\n", "创世 NFT: #%d\n"), resp.GenesisNFT.TokenID)
703-
}
704-
705-
// Also show local state
706-
state := miner.LoadState()
707-
if state.TotalInscriptions > 0 {
708-
fmt.Print(tr("\n--- Local Stats ---\n", "\n--- 本地统计 ---\n"))
709-
fmt.Printf(tr("Session inscriptions: %d\n", "本次会话铭文: %d\n"), state.TotalInscriptions)
710-
fmt.Printf(tr("Session CW earned: %d\n", "本次会话 CW 收益: %d\n"), state.TotalCWEarned)
711-
fmt.Printf(tr("Session NFT hits: %d\n", "本次会话 NFT 命中: %d\n"), state.TotalHits)
712-
}
678+
// ── Agent info table ──
679+
fmt.Println()
680+
printRow(tr("Agent", "智能体"), fmt.Sprintf("%s (%s)", resp.Agent.Name, resp.Agent.ID))
681+
printRow(tr("Trust Score", "信任分"), fmt.Sprintf("%d", resp.Inscriptions.TotalCW)) // trust via CW proxy
682+
printRow(tr("CW Earned", "CW 收益"), fmt.Sprintf("%d", resp.Inscriptions.TotalCW))
683+
printRow(tr("Inscriptions", "铭文"), fmt.Sprintf("%d", resp.Inscriptions.Total))
713684

714-
// Show on-chain token holdings (ClawChain)
685+
// ── On-chain token holdings ──
715686
pubKey := cfg.Agent.PublicKey
716687
if pubKey == "" {
717688
if keys, _ := auth.LoadKeys(); keys != nil {
@@ -721,29 +692,34 @@ func runStatus(cmd *cobra.Command, _ []string) error {
721692
if pubKey != "" {
722693
mc := market.New("")
723694
chainAcc, err := mc.GetChainAccount(context.Background(), pubKey)
724-
if err == nil && chainAcc != nil && len(chainAcc.TokenBalances) > 0 {
725-
fmt.Print(tr("\n--- Token Holdings (ClawChain) ---\n", "\n--- 代币持仓 (ClawChain) ---\n"))
695+
if err == nil && chainAcc != nil {
696+
fmt.Println()
697+
printRow(tr("CW (on-chain)", "CW(链上)"), chainAcc.CWBalance+" CW")
726698
for tokenID, balance := range chainAcc.TokenBalances {
727699
if balance == "0" {
728700
continue
729701
}
730702
ticker, _ := mc.GetChainTokenName(context.Background(), tokenID)
731-
if ticker != "" {
732-
fmt.Printf(" %s: %s\n", ticker, balance)
733-
} else {
734-
short := tokenID
735-
if len(short) > 12 {
736-
short = short[:8] + "..."
703+
if ticker == "" {
704+
if len(tokenID) > 8 {
705+
ticker = tokenID[:8] + "..."
706+
} else {
707+
ticker = tokenID
737708
}
738-
fmt.Printf(" %s: %s\n", short, balance)
739709
}
710+
printRow(ticker, balance)
740711
}
741712
}
742713
}
714+
fmt.Println()
743715

744716
return nil
745717
}
746718

719+
func printRow(label, value string) {
720+
fmt.Printf(" %-20s %s\n", label, value)
721+
}
722+
747723
// runTicketBalance queries on-chain balance for a specific ticket by ticker.
748724
func runTicketBalance(ticker string) error {
749725
cfg, err := config.Load()

0 commit comments

Comments
 (0)