park.go: Replace ReadHook with pinned bead query (gt-rgd9x.1)

This commit is contained in:
Steve Yegge
2025-12-26 16:20:26 -08:00
parent 188fc88a83
commit 42f4f0555f

View File

@@ -5,12 +5,13 @@ import (
"fmt" "fmt"
"os" "os"
"os/exec" "os/exec"
"path/filepath"
"strings" "strings"
"time" "time"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/steveyegge/gastown/internal/beads"
"github.com/steveyegge/gastown/internal/style" "github.com/steveyegge/gastown/internal/style"
"github.com/steveyegge/gastown/internal/wisp"
) )
// Park command parks work on a gate, allowing agent to exit safely. // Park command parks work on a gate, allowing agent to exit safely.
@@ -109,12 +110,25 @@ func runPark(cmd *cobra.Command, args []string) error {
return fmt.Errorf("detecting agent identity: %w", err) return fmt.Errorf("detecting agent identity: %w", err)
} }
// Read current hook state (if any) // Read current pinned bead (if any)
var beadID, formula, hookContext string var beadID, formula, hookContext string
if hook, err := wisp.ReadHook(cloneRoot, agentID); err == nil { workDir, err := findLocalBeadsDir()
beadID = hook.BeadID if err == nil {
formula = hook.Formula b := beads.New(workDir)
hookContext = hook.Context pinnedBeads, err := b.List(beads.ListOptions{
Status: beads.StatusPinned,
Assignee: agentID,
Priority: -1,
})
if err == nil && len(pinnedBeads) > 0 {
beadID = pinnedBeads[0].ID
// Extract molecule from attachment fields
if attachment := beads.ParseAttachmentFields(pinnedBeads[0]); attachment != nil {
formula = attachment.AttachedMolecule
}
// Context is part of the bead description, not stored separately
hookContext = pinnedBeads[0].Description
}
} }
// Build context combining hook context and new message // Build context combining hook context and new message
@@ -190,7 +204,7 @@ func runPark(cmd *cobra.Command, args []string) error {
// parkedWorkPath returns the file path for an agent's parked work state. // parkedWorkPath returns the file path for an agent's parked work state.
func parkedWorkPath(cloneRoot, agentID string) string { func parkedWorkPath(cloneRoot, agentID string) string {
return wisp.WispPath(cloneRoot, fmt.Sprintf("parked-%s.json", strings.ReplaceAll(agentID, "/", "_"))) return filepath.Join(cloneRoot, ".beads", fmt.Sprintf("parked-%s.json", strings.ReplaceAll(agentID, "/", "_")))
} }
// readParkedWork reads the parked work state for an agent. // readParkedWork reads the parked work state for an agent.