fix: show [merge] mode in agent sub-items for status and doctor

Agents always use merge mode (symlink-per-file). Add [merge] prefix to
agent sub-item detail in status and doctor for consistency with skills.

Also refactor doctor displayTargetStatus to use sub-item format
(target name as header, skills/agents as indented sub-items).
This commit is contained in:
Willie
2026-04-08 22:19:20 +08:00
parent fa08916e3f
commit 1dbfc84e5f
4 changed files with 23 additions and 20 deletions
+12 -9
View File
@@ -411,13 +411,16 @@ func checkTargets(cfg *config.Config, result *doctorResult, isProject bool) map[
targetIssues := checkTargetIssues(target, cfg.Source)
// Target name header
fmt.Printf("%s%s%s\n", ui.Bold, name, ui.Reset)
if len(targetIssues) > 0 {
ui.Error("%s [%s]: %s", name, mode, strings.Join(targetIssues, ", "))
fmt.Printf(" skills %s[%s] %s%s\n", ui.Red, mode, strings.Join(targetIssues, ", "), ui.Reset)
result.addError()
details = append(details, fmt.Sprintf("%s: %s", name, strings.Join(targetIssues, ", ")))
hasError = true
} else {
cached := displayTargetStatus(name, target, cfg.Source, mode)
cached := displayTargetStatus(target, cfg.Source, mode)
cache[name] = cached
}
@@ -480,7 +483,7 @@ func checkTargetIssues(target config.TargetConfig, source string) []string {
return targetIssues
}
func displayTargetStatus(name string, target config.TargetConfig, source, mode string) cachedTargetStatus {
func displayTargetStatus(target config.TargetConfig, source, mode string) cachedTargetStatus {
sc := target.SkillsConfig()
var statusStr string
var cached cachedTargetStatus
@@ -496,7 +499,7 @@ func displayTargetStatus(name string, target config.TargetConfig, source, mode s
case sync.StatusMerged:
statusStr = fmt.Sprintf("merged (%d shared, %d local)", linkedCount, localCount)
case sync.StatusLinked:
statusStr = "linked (needs sync to apply merge mode)"
statusStr = "linked (needs sync)"
needsSync = true
default:
statusStr = status.String()
@@ -509,7 +512,7 @@ func displayTargetStatus(name string, target config.TargetConfig, source, mode s
case sync.StatusCopied:
statusStr = fmt.Sprintf("copied (%d managed, %d local)", managedCount, localCount)
case sync.StatusLinked:
statusStr = "linked (needs sync to apply copy mode)"
statusStr = "linked (needs sync)"
needsSync = true
default:
statusStr = status.String()
@@ -519,16 +522,16 @@ func displayTargetStatus(name string, target config.TargetConfig, source, mode s
cached.status = status
statusStr = status.String()
if status == sync.StatusMerged {
statusStr = "merged (needs sync to apply symlink mode)"
statusStr = "merged (needs sync)"
needsSync = true
}
}
statusColor := ui.Green
if needsSync {
ui.Warning("%s [%s]: %s", name, mode, statusStr)
} else {
ui.Success("%s [%s]: %s", name, mode, statusStr)
statusColor = ui.Yellow
}
fmt.Printf(" skills %s[%s] %s%s\n", statusColor, mode, statusStr, ui.Reset)
return cached
}
+9 -9
View File
@@ -21,12 +21,12 @@ func checkAgentTargetInline(name string, target config.TargetConfig, builtinAgen
info, err := os.Stat(agentPath)
if err != nil {
if os.IsNotExist(err) {
fmt.Printf(" agents %s%-12s%s %s\n", ui.Gray, "not created", ui.Reset, ui.Dim+agentPath+ui.Reset)
fmt.Printf(" agents %s[merge] not created%s\n", ui.Gray, ui.Reset)
result.addCheck("agent_target_"+name, checkPass,
fmt.Sprintf("Agent target %s: not created yet", name), nil)
return
}
fmt.Printf(" agents %s%-12s%s %s\n", ui.Red, "error", ui.Reset, ui.Dim+err.Error()+ui.Reset)
fmt.Printf(" agents %s[merge] error: %s%s\n", ui.Red, err.Error(), ui.Reset)
result.addError()
result.addCheck("agent_target_"+name, checkError,
fmt.Sprintf("Agent target %s: %v", name, err), nil)
@@ -34,7 +34,7 @@ func checkAgentTargetInline(name string, target config.TargetConfig, builtinAgen
}
if !info.IsDir() {
fmt.Printf(" agents %s%-12s%s %s\n", ui.Red, "error", ui.Reset, ui.Dim+"not a directory"+ui.Reset)
fmt.Printf(" agents %s[merge] error: not a directory%s\n", ui.Red, ui.Reset)
result.addError()
result.addCheck("agent_target_"+name, checkError,
fmt.Sprintf("Agent target %s: path is not a directory", name), nil)
@@ -43,8 +43,8 @@ func checkAgentTargetInline(name string, target config.TargetConfig, builtinAgen
linked, broken := countAgentLinksAndBroken(agentPath)
if broken > 0 {
msg := fmt.Sprintf("%d linked, %d broken", linked, broken)
fmt.Printf(" agents %s%-12s%s %s\n", ui.Yellow, "broken", ui.Reset, ui.Dim+msg+ui.Reset)
msg := fmt.Sprintf("[merge] %d linked, %d broken", linked, broken)
fmt.Printf(" agents %s%s%s\n", ui.Yellow, msg, ui.Reset)
result.addWarning()
result.addCheck("agent_target_"+name, checkWarning,
fmt.Sprintf("Agent target %s: %s", name, msg), nil)
@@ -52,16 +52,16 @@ func checkAgentTargetInline(name string, target config.TargetConfig, builtinAgen
}
if linked != agentCount && agentCount > 0 {
msg := fmt.Sprintf("%d/%d linked (drift)", linked, agentCount)
fmt.Printf(" agents %s%-12s%s %s\n", ui.Yellow, "drift", ui.Reset, ui.Dim+msg+ui.Reset)
msg := fmt.Sprintf("[merge] drift (%d/%d linked)", linked, agentCount)
fmt.Printf(" agents %s%s%s\n", ui.Yellow, msg, ui.Reset)
result.addWarning()
result.addCheck("agent_target_"+name, checkWarning,
fmt.Sprintf("Agent target %s: drift (%d/%d agents linked)", name, linked, agentCount), nil)
return
}
msg := fmt.Sprintf("%d/%d linked", linked, agentCount)
fmt.Printf(" agents %s%-12s%s %s\n", ui.Green, "synced", ui.Reset, ui.Dim+msg+ui.Reset)
msg := fmt.Sprintf("[merge] synced (%d/%d linked)", linked, agentCount)
fmt.Printf(" agents %s%s%s\n", ui.Green, msg, ui.Reset)
result.addCheck("agent_target_"+name, checkPass,
fmt.Sprintf("Agent target %s: %d agents synced", name, linked), nil)
}
+1 -1
View File
@@ -420,7 +420,7 @@ func printTargetsStatus(cfg *config.Config, discovered []sync.DiscoveredSkill) e
agentStatus = "drift"
driftLabel = ui.Yellow + " (drift)" + ui.Reset
}
printTargetSubItem("agents", agentStatus, fmt.Sprintf("%d/%d linked%s", linked, agentCount, driftLabel))
printTargetSubItem("agents", agentStatus, fmt.Sprintf("[merge] %d/%d linked%s", linked, agentCount, driftLabel))
}
}
}
+1 -1
View File
@@ -277,7 +277,7 @@ func printProjectTargetsStatus(runtime *projectRuntime, discovered []sync.Discov
agentStatus = "drift"
driftLabel = ui.Yellow + " (drift)" + ui.Reset
}
printTargetSubItem("agents", agentStatus, fmt.Sprintf("%d/%d linked%s", linked, agentCount, driftLabel))
printTargetSubItem("agents", agentStatus, fmt.Sprintf("[merge] %d/%d linked%s", linked, agentCount, driftLabel))
}
}
}