From 907eba71948e140bf963427972cc412fe05fbacd Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Tue, 30 Dec 2025 10:40:54 -0800 Subject: [PATCH] Instrument gt commands to emit events to activity feed (gt-7aw1m) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add events.LogFeed calls to the following gt commands: - nudge.go: Log TypeNudge events when nudging agents - unsling.go: Log TypeUnhook events when removing work from hooks - up.go: Log TypeBoot events when starting Gas Town services - down.go: Log TypeHalt events when stopping Gas Town services - stop.go: Log TypeKill events when stopping polecat sessions - polecat_spawn.go: Log TypeSpawn events when spawning polecats Also add helper functions to events package: - UnhookPayload: Creates payload for unhook events - KillPayload: Creates payload for kill events - HaltPayload: Creates payload for halt events 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/cmd/down.go | 10 ++++++++++ internal/cmd/nudge.go | 4 ++++ internal/cmd/polecat_spawn.go | 4 ++++ internal/cmd/stop.go | 4 ++++ internal/cmd/unsling.go | 4 ++++ internal/cmd/up.go | 8 ++++++++ internal/events/events.go | 23 +++++++++++++++++++++++ 7 files changed, 57 insertions(+) diff --git a/internal/cmd/down.go b/internal/cmd/down.go index 426b59f0..16504ce0 100644 --- a/internal/cmd/down.go +++ b/internal/cmd/down.go @@ -6,6 +6,7 @@ import ( "github.com/spf13/cobra" "github.com/steveyegge/gastown/internal/daemon" + "github.com/steveyegge/gastown/internal/events" "github.com/steveyegge/gastown/internal/style" "github.com/steveyegge/gastown/internal/tmux" "github.com/steveyegge/gastown/internal/workspace" @@ -112,6 +113,15 @@ func runDown(cmd *cobra.Command, args []string) error { fmt.Println() if allOK { fmt.Printf("%s All services stopped\n", style.Bold.Render("✓")) + // Log halt event with stopped services + stoppedServices := []string{"daemon", "deacon", "mayor"} + for _, rigName := range rigs { + stoppedServices = append(stoppedServices, fmt.Sprintf("%s/witness", rigName)) + } + if downAll { + stoppedServices = append(stoppedServices, "tmux-server") + } + _ = events.LogFeed(events.TypeHalt, "gt", events.HaltPayload(stoppedServices)) } else { fmt.Printf("%s Some services failed to stop\n", style.Bold.Render("✗")) return fmt.Errorf("not all services stopped") diff --git a/internal/cmd/nudge.go b/internal/cmd/nudge.go index 99e45ec3..561b9cd6 100644 --- a/internal/cmd/nudge.go +++ b/internal/cmd/nudge.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/spf13/cobra" + "github.com/steveyegge/gastown/internal/events" "github.com/steveyegge/gastown/internal/style" "github.com/steveyegge/gastown/internal/tmux" "github.com/steveyegge/gastown/internal/workspace" @@ -92,6 +93,7 @@ func runNudge(cmd *cobra.Command, args []string) error { if townRoot, err := workspace.FindFromCwd(); err == nil && townRoot != "" { LogNudge(townRoot, "deacon", message) } + _ = events.LogFeed(events.TypeNudge, sender, events.NudgePayload("", "deacon", message)) return nil } @@ -130,6 +132,7 @@ func runNudge(cmd *cobra.Command, args []string) error { if townRoot, err := workspace.FindFromCwd(); err == nil && townRoot != "" { LogNudge(townRoot, target, message) } + _ = events.LogFeed(events.TypeNudge, sender, events.NudgePayload(rigName, target, message)) } else { // Raw session name (legacy) exists, err := t.HasSession(target) @@ -150,6 +153,7 @@ func runNudge(cmd *cobra.Command, args []string) error { if townRoot, err := workspace.FindFromCwd(); err == nil && townRoot != "" { LogNudge(townRoot, target, message) } + _ = events.LogFeed(events.TypeNudge, sender, events.NudgePayload("", target, message)) } return nil diff --git a/internal/cmd/polecat_spawn.go b/internal/cmd/polecat_spawn.go index fc25b7a4..2cba58a3 100644 --- a/internal/cmd/polecat_spawn.go +++ b/internal/cmd/polecat_spawn.go @@ -8,6 +8,7 @@ import ( "github.com/steveyegge/gastown/internal/config" "github.com/steveyegge/gastown/internal/constants" + "github.com/steveyegge/gastown/internal/events" "github.com/steveyegge/gastown/internal/git" "github.com/steveyegge/gastown/internal/polecat" "github.com/steveyegge/gastown/internal/rig" @@ -161,6 +162,9 @@ func SpawnPolecatForSling(rigName string, opts SlingSpawnOptions) (*SpawnedPolec fmt.Printf("%s Polecat %s spawned\n", style.Bold.Render("✓"), polecatName) + // Log spawn event to activity feed + _ = events.LogFeed(events.TypeSpawn, "gt", events.SpawnPayload(rigName, polecatName)) + return &SpawnedPolecatInfo{ RigName: rigName, PolecatName: polecatName, diff --git a/internal/cmd/stop.go b/internal/cmd/stop.go index 2fc3322f..0d9ff85c 100644 --- a/internal/cmd/stop.go +++ b/internal/cmd/stop.go @@ -6,6 +6,7 @@ import ( "github.com/spf13/cobra" "github.com/steveyegge/gastown/internal/config" + "github.com/steveyegge/gastown/internal/events" "github.com/steveyegge/gastown/internal/git" "github.com/steveyegge/gastown/internal/rig" "github.com/steveyegge/gastown/internal/session" @@ -147,6 +148,9 @@ func runStop(cmd *cobra.Command, args []string) error { logger := townlog.NewLogger(townRoot) logger.Log(townlog.EventKill, agent, "gt stop") + // Log kill event to activity feed + _ = events.LogFeed(events.TypeKill, "gt", events.KillPayload(r.Name, info.Polecat, "gt stop")) + // Log captured output (truncated) if len(output) > 200 { output = output[len(output)-200:] diff --git a/internal/cmd/unsling.go b/internal/cmd/unsling.go index 9ddd72da..a786fdd1 100644 --- a/internal/cmd/unsling.go +++ b/internal/cmd/unsling.go @@ -5,6 +5,7 @@ import ( "github.com/spf13/cobra" "github.com/steveyegge/gastown/internal/beads" + "github.com/steveyegge/gastown/internal/events" "github.com/steveyegge/gastown/internal/style" ) @@ -141,6 +142,9 @@ func runUnsling(cmd *cobra.Command, args []string) error { return fmt.Errorf("unpinning bead %s: %w", pinned.ID, err) } + // Log unhook event + _ = events.LogFeed(events.TypeUnhook, agentID, events.UnhookPayload(pinned.ID)) + fmt.Printf("%s Work removed from hook\n", style.Bold.Render("✓")) fmt.Printf(" Bead %s is now status=open\n", pinned.ID) diff --git a/internal/cmd/up.go b/internal/cmd/up.go index 04ed4ed8..4553f7ef 100644 --- a/internal/cmd/up.go +++ b/internal/cmd/up.go @@ -12,6 +12,7 @@ import ( "github.com/steveyegge/gastown/internal/beads" "github.com/steveyegge/gastown/internal/config" "github.com/steveyegge/gastown/internal/daemon" + "github.com/steveyegge/gastown/internal/events" "github.com/steveyegge/gastown/internal/refinery" "github.com/steveyegge/gastown/internal/style" "github.com/steveyegge/gastown/internal/tmux" @@ -159,6 +160,13 @@ func runUp(cmd *cobra.Command, args []string) error { fmt.Println() if allOK { fmt.Printf("%s All services running\n", style.Bold.Render("✓")) + // Log boot event with started services + startedServices := []string{"daemon", "deacon", "mayor"} + for _, rigName := range rigs { + startedServices = append(startedServices, fmt.Sprintf("%s/witness", rigName)) + startedServices = append(startedServices, fmt.Sprintf("%s/refinery", rigName)) + } + _ = events.LogFeed(events.TypeBoot, "gt", events.BootPayload("town", startedServices)) } else { fmt.Printf("%s Some services failed to start\n", style.Bold.Render("✗")) return fmt.Errorf("not all services started") diff --git a/internal/events/events.go b/internal/events/events.go index 060e6791..a3b402d3 100644 --- a/internal/events/events.go +++ b/internal/events/events.go @@ -246,3 +246,26 @@ func EscalationPayload(rig, target, to, reason string) map[string]interface{} { "reason": reason, } } + +// UnhookPayload creates a payload for unhook events. +func UnhookPayload(beadID string) map[string]interface{} { + return map[string]interface{}{ + "bead": beadID, + } +} + +// KillPayload creates a payload for kill events. +func KillPayload(rig, target, reason string) map[string]interface{} { + return map[string]interface{}{ + "rig": rig, + "target": target, + "reason": reason, + } +} + +// HaltPayload creates a payload for halt events. +func HaltPayload(services []string) map[string]interface{} { + return map[string]interface{}{ + "services": services, + } +}