Add command documentation and improve daemon UX

- Added human-readable uptime formatting (51m 59s vs 3119.4 seconds)
- Fixed daemon stop race condition with SIGKILL
- Added markdown docs for 19 commands: blocked, comments, compact, daemon,
  delete, dep, epic, export, import, label, list, quickstart, rename-prefix,
  renumber, reopen, repos, restore, stale, sync
- Closed: bd-159, bd-152, bd-168
- Deleted test issues: bd-144, bd-145

Amp-Thread-ID: https://ampcode.com/threads/T-9f7c3fed-62de-4bcd-a059-8c1b77cdb841
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-10-19 22:24:14 -07:00
parent 581ea11a7c
commit 7658c4a8e8
21 changed files with 560 additions and 6 deletions

View File

@@ -268,6 +268,25 @@ func isDaemonRunning(pidFile string) (bool, int) {
return true, pid
}
func formatUptime(seconds float64) string {
if seconds < 60 {
return fmt.Sprintf("%.1f seconds", seconds)
}
if seconds < 3600 {
minutes := int(seconds / 60)
secs := int(seconds) % 60
return fmt.Sprintf("%dm %ds", minutes, secs)
}
if seconds < 86400 {
hours := int(seconds / 3600)
minutes := int(seconds/60) % 60
return fmt.Sprintf("%dh %dm", hours, minutes)
}
days := int(seconds / 86400)
hours := int(seconds/3600) % 24
return fmt.Sprintf("%dd %dh", days, hours)
}
func showDaemonStatus(pidFile string, global bool) {
if isRunning, pid := isDaemonRunning(pidFile); isRunning {
scope := "local"
@@ -342,7 +361,7 @@ func showDaemonHealth(global bool) {
fmt.Printf("%s Daemon Health: %s\n", statusIcon, health.Status)
fmt.Printf(" Version: %s\n", health.Version)
fmt.Printf(" Uptime: %.1f seconds\n", health.Uptime)
fmt.Printf(" Uptime: %s\n", formatUptime(health.Uptime))
fmt.Printf(" Cache Size: %d databases\n", health.CacheSize)
fmt.Printf(" Cache Hits: %d\n", health.CacheHits)
fmt.Printf(" Cache Misses: %d\n", health.CacheMisses)
@@ -551,8 +570,18 @@ func stopDaemon(pidFile string) {
}
fmt.Fprintf(os.Stderr, "Warning: daemon did not stop after 5 seconds, sending SIGKILL\n")
// Check one more time before SIGKILL to avoid race condition
if isRunning, _ := isDaemonRunning(pidFile); !isRunning {
fmt.Println("✓ Daemon stopped")
return
}
if err := process.Kill(); err != nil {
fmt.Fprintf(os.Stderr, "Error killing process: %v\n", err)
// Ignore "process already finished" errors
if !strings.Contains(err.Error(), "process already finished") {
fmt.Fprintf(os.Stderr, "Error killing process: %v\n", err)
}
}
os.Remove(pidFile)
fmt.Println("✓ Daemon killed")