fix(sling): resolve rig path for cross-rig bead hooking
gt sling failed when hooking rig-level beads from town root because bd update doesn't support cross-database routing like bd show does. The fix adds a ResolveHookDir helper that: 1. Extracts the prefix from bead ID (e.g., "ap-xxx" → "ap-") 2. Looks up the rig path from routes.jsonl 3. Falls back to townRoot if prefix not found Also removes the BEADS_DIR environment override which was preventing routing from working correctly. Fixes #148
This commit is contained in:
@@ -406,20 +406,10 @@ func runSling(cmd *cobra.Command, args []string) error {
|
||||
beadID = wispRootID
|
||||
}
|
||||
|
||||
// Hook the bead using bd update
|
||||
// For town-level beads (hq-*), set BEADS_DIR to town beads
|
||||
// For rig-level beads (gt-*, bd-*, etc.), use redirect-based routing from hookWorkDir
|
||||
// Hook the bead using bd update.
|
||||
// See: https://github.com/steveyegge/gastown/issues/148
|
||||
hookCmd := exec.Command("bd", "--no-daemon", "update", beadID, "--status=hooked", "--assignee="+targetAgent)
|
||||
if strings.HasPrefix(beadID, "hq-") {
|
||||
// Town-level bead: set BEADS_DIR explicitly
|
||||
hookCmd.Env = append(os.Environ(), "BEADS_DIR="+townBeadsDir)
|
||||
hookCmd.Dir = townRoot
|
||||
} else if hookWorkDir != "" {
|
||||
// Rig-level bead: use redirect from polecat's worktree
|
||||
hookCmd.Dir = hookWorkDir
|
||||
} else {
|
||||
hookCmd.Dir = townRoot
|
||||
}
|
||||
hookCmd.Dir = beads.ResolveHookDir(townRoot, beadID, hookWorkDir)
|
||||
hookCmd.Stderr = os.Stderr
|
||||
if err := hookCmd.Run(); err != nil {
|
||||
return fmt.Errorf("hooking bead: %w", err)
|
||||
@@ -939,11 +929,10 @@ func runSlingFormula(args []string) error {
|
||||
|
||||
fmt.Printf("%s Wisp created: %s\n", style.Bold.Render("✓"), wispResult.RootID)
|
||||
|
||||
// Step 3: Hook the wisp bead using bd update (discovery-based approach)
|
||||
// Set BEADS_DIR to town-level beads so hq-* beads are accessible
|
||||
// Step 3: Hook the wisp bead using bd update.
|
||||
// See: https://github.com/steveyegge/gastown/issues/148
|
||||
hookCmd := exec.Command("bd", "--no-daemon", "update", wispResult.RootID, "--status=hooked", "--assignee="+targetAgent)
|
||||
hookCmd.Env = append(os.Environ(), "BEADS_DIR="+townBeadsDir)
|
||||
hookCmd.Dir = townRoot
|
||||
hookCmd.Dir = beads.ResolveHookDir(townRoot, wispResult.RootID, "")
|
||||
hookCmd.Stderr = os.Stderr
|
||||
if err := hookCmd.Run(); err != nil {
|
||||
return fmt.Errorf("hooking wisp bead: %w", err)
|
||||
@@ -1432,17 +1421,10 @@ func runBatchSling(beadIDs []string, rigName string, townBeadsDir string) error
|
||||
}
|
||||
}
|
||||
|
||||
// Hook the bead
|
||||
// For town-level beads (hq-*), set BEADS_DIR; for rig-level beads use redirect
|
||||
// Hook the bead. See: https://github.com/steveyegge/gastown/issues/148
|
||||
townRoot := filepath.Dir(townBeadsDir)
|
||||
hookCmd := exec.Command("bd", "--no-daemon", "update", beadID, "--status=hooked", "--assignee="+targetAgent)
|
||||
if strings.HasPrefix(beadID, "hq-") {
|
||||
// Town-level bead: set BEADS_DIR and run from town root (parent of townBeadsDir)
|
||||
hookCmd.Env = append(os.Environ(), "BEADS_DIR="+townBeadsDir)
|
||||
hookCmd.Dir = filepath.Dir(townBeadsDir)
|
||||
} else if hookWorkDir != "" {
|
||||
// Rig-level bead: use redirect from polecat's worktree
|
||||
hookCmd.Dir = hookWorkDir
|
||||
}
|
||||
hookCmd.Dir = beads.ResolveHookDir(townRoot, beadID, hookWorkDir)
|
||||
hookCmd.Stderr = os.Stderr
|
||||
if err := hookCmd.Run(); err != nil {
|
||||
results = append(results, slingResult{beadID: beadID, polecat: spawnInfo.PolecatName, success: false, errMsg: "hook failed"})
|
||||
|
||||
Reference in New Issue
Block a user