From 9db9fc2af8f9d02b0d1a5f55d70e9c00a4fd8c88 Mon Sep 17 00:00:00 2001 From: aleiby Date: Sat, 24 Jan 2026 21:47:04 -0800 Subject: [PATCH] fix(doctor): implement Fix for misclassified-wisps check (#878) The misclassified-wisps check could detect issues that should be wisps but couldn't fix them because bd update lacked an --ephemeral flag. Now that beads supports `bd update --ephemeral` (steveyegge/beads#1263), implement the actual fix to mark detected issues as ephemeral. Closes #852 Co-authored-by: Claude Opus 4.5 --- internal/doctor/misclassified_wisp_check.go | 35 +++++++++++++++------ 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/internal/doctor/misclassified_wisp_check.go b/internal/doctor/misclassified_wisp_check.go index a4963c82..8d0075bc 100644 --- a/internal/doctor/misclassified_wisp_check.go +++ b/internal/doctor/misclassified_wisp_check.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "os" + "os/exec" "path/filepath" "strings" @@ -193,14 +194,30 @@ func (c *CheckMisclassifiedWisps) shouldBeWisp(id, title, issueType string, labe return "" } -// Fix marks misclassified issues as wisps using bd update. +// Fix marks misclassified issues as wisps using bd update --ephemeral. func (c *CheckMisclassifiedWisps) Fix(ctx *CheckContext) error { - // Note: bd doesn't have a direct flag to set wisp:true on existing issues. - // The proper fix is to ensure issues are created with --ephemeral flag. - // For now, we just report the issues - they'll be cleaned up by wisp-gc - // if they become abandoned, or manually closed. - // - // A true fix would require bd to support: bd update --ephemeral - // Until then, this check serves as a diagnostic. - return nil + if len(c.misclassified) == 0 { + return nil + } + + var lastErr error + + for _, wisp := range c.misclassified { + // Determine working directory: town-level or rig-level + var workDir string + if wisp.rigName == "town" { + workDir = ctx.TownRoot + } else { + workDir = filepath.Join(ctx.TownRoot, wisp.rigName) + } + + // Run bd update --ephemeral + cmd := exec.Command("bd", "update", wisp.id, "--ephemeral") + cmd.Dir = workDir + if output, err := cmd.CombinedOutput(); err != nil { + lastErr = fmt.Errorf("%s/%s: %v (%s)", wisp.rigName, wisp.id, err, string(output)) + } + } + + return lastErr }