Skip to content

Commit 9729e05

Browse files
steveyeggeclaude
andcommitted
feat(rig): add operational state to gt rig status
Add Status line showing operational state (OPERATIONAL/PARKED/DOCKED) with source indication (local/global - synced/default). The state is looked up using the property layer system: 1. Wisp layer (local/ephemeral): .beads-wisp/config/<rig>.json 2. Rig bead labels (global/synced): status:parked or status:docked 3. Default: OPERATIONAL Example output: gastown Status: PARKED (local) Path: /Users/stevey/gt/gastown ... Closes: gt-5l7h4 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3f92004 commit 9729e05

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

internal/cmd/rig.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/steveyegge/gastown/internal/session"
2121
"github.com/steveyegge/gastown/internal/style"
2222
"github.com/steveyegge/gastown/internal/tmux"
23+
"github.com/steveyegge/gastown/internal/wisp"
2324
"github.com/steveyegge/gastown/internal/witness"
2425
"github.com/steveyegge/gastown/internal/workspace"
2526
)
@@ -1047,6 +1048,17 @@ func runRigStatus(cmd *cobra.Command, args []string) error {
10471048

10481049
// Header
10491050
fmt.Printf("%s\n", style.Bold.Render(rigName))
1051+
1052+
// Operational state
1053+
opState, opSource := getRigOperationalState(townRoot, rigName)
1054+
if opState == "OPERATIONAL" {
1055+
fmt.Printf(" Status: %s\n", style.Success.Render(opState))
1056+
} else if opState == "PARKED" {
1057+
fmt.Printf(" Status: %s (%s)\n", style.Warning.Render(opState), opSource)
1058+
} else if opState == "DOCKED" {
1059+
fmt.Printf(" Status: %s (%s)\n", style.Dim.Render(opState), opSource)
1060+
}
1061+
10501062
fmt.Printf(" Path: %s\n", r.Path)
10511063
if r.Config != nil && r.Config.Prefix != "" {
10521064
fmt.Printf(" Beads prefix: %s-\n", r.Config.Prefix)
@@ -1472,3 +1484,48 @@ func runRigRestart(cmd *cobra.Command, args []string) error {
14721484

14731485
return nil
14741486
}
1487+
1488+
// getRigOperationalState returns the operational state and source for a rig.
1489+
// It checks the wisp layer first (local/ephemeral), then rig bead labels (global).
1490+
// Returns state ("OPERATIONAL", "PARKED", or "DOCKED") and source ("local", "global - synced", or "default").
1491+
func getRigOperationalState(townRoot, rigName string) (state string, source string) {
1492+
// Check wisp layer first (local/ephemeral overrides)
1493+
wispConfig := wisp.NewConfig(townRoot, rigName)
1494+
if status := wispConfig.GetString("status"); status != "" {
1495+
switch strings.ToLower(status) {
1496+
case "parked":
1497+
return "PARKED", "local"
1498+
case "docked":
1499+
return "DOCKED", "local"
1500+
}
1501+
}
1502+
1503+
// Check rig bead labels (global/synced)
1504+
// Rig identity bead ID: <prefix>-rig-<name>
1505+
// Look for status:docked or status:parked labels
1506+
rigPath := filepath.Join(townRoot, rigName)
1507+
rigBeadsDir := beads.ResolveBeadsDir(rigPath)
1508+
bd := beads.NewWithBeadsDir(rigPath, rigBeadsDir)
1509+
1510+
// Try to find the rig identity bead
1511+
// Convention: <prefix>-rig-<rigName>
1512+
if rigCfg, err := rig.LoadRigConfig(rigPath); err == nil && rigCfg.Beads != nil {
1513+
rigBeadID := fmt.Sprintf("%s-rig-%s", rigCfg.Beads.Prefix, rigName)
1514+
if issue, err := bd.Show(rigBeadID); err == nil {
1515+
for _, label := range issue.Labels {
1516+
if strings.HasPrefix(label, "status:") {
1517+
statusValue := strings.TrimPrefix(label, "status:")
1518+
switch strings.ToLower(statusValue) {
1519+
case "docked":
1520+
return "DOCKED", "global - synced"
1521+
case "parked":
1522+
return "PARKED", "global - synced"
1523+
}
1524+
}
1525+
}
1526+
}
1527+
}
1528+
1529+
// Default: operational
1530+
return "OPERATIONAL", "default"
1531+
}

0 commit comments

Comments
 (0)