fix(mayor): match handoff priming for gt may at startup (hq-osbot)

When starting Mayor via 'gt may at', the session now:
1. Works from townRoot (~/gt) instead of mayorDir (~/gt/mayor)
2. Includes startup beacon with explicit instructions in initial prompt
3. Removes redundant post-start nudges (beacon has instructions)

This matches the 'gt handoff' behavior where the agent immediately
knows to check hook and mail on startup.

Fixes: hq-h3449 (P0 escalation - horrendous starting UX)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
mayor
2026-01-13 03:22:56 -08:00
committed by beads/crew/emma
parent 791b388a93
commit 278b2f2d4d
3 changed files with 21 additions and 21 deletions

View File

@@ -68,7 +68,7 @@ func (m *Manager) Start(agentOverride string) error {
}
}
// Ensure mayor directory exists
// Ensure mayor directory exists (for Claude settings)
mayorDir := m.mayorDir()
if err := os.MkdirAll(mayorDir, 0755); err != nil {
return fmt.Errorf("creating mayor directory: %w", err)
@@ -79,18 +79,25 @@ func (m *Manager) Start(agentOverride string) error {
return fmt.Errorf("ensuring Claude settings: %w", err)
}
// Build startup command first - the startup hook handles 'gt prime' automatically
// Build startup beacon with explicit instructions (matches gt handoff behavior)
// This ensures the agent has clear context immediately, not after nudges arrive
beacon := session.FormatStartupNudge(session.StartupNudgeConfig{
Recipient: "mayor",
Sender: "human",
Topic: "cold-start",
})
// Build startup command WITH the beacon prompt - the startup hook handles 'gt prime' automatically
// Export GT_ROLE and BD_ACTOR in the command since tmux SetEnvironment only affects new panes
startupCmd, err := config.BuildAgentStartupCommandWithAgentOverride("mayor", "mayor", "", "", agentOverride)
startupCmd, err := config.BuildAgentStartupCommandWithAgentOverride("mayor", "mayor", "", beacon, agentOverride)
if err != nil {
return fmt.Errorf("building startup command: %w", err)
}
// Create session with command directly to avoid send-keys race condition.
// This runs the command as the pane's initial process, avoiding the shell
// readiness timing issues that cause "bad pattern" and command-not-found errors.
// Create session in townRoot (not mayorDir) to match gt handoff behavior
// This ensures Mayor works from the town root where all tools work correctly
// See: https://github.com/anthropics/gastown/issues/280
if err := t.NewSessionWithCommand(sessionID, mayorDir, startupCmd); err != nil {
if err := t.NewSessionWithCommand(sessionID, m.townRoot, startupCmd); err != nil {
return fmt.Errorf("creating tmux session: %w", err)
}
@@ -119,18 +126,8 @@ func (m *Manager) Start(agentOverride string) error {
time.Sleep(constants.ShutdownNotifyDelay)
// Inject startup nudge for predecessor discovery via /resume
_ = session.StartupNudge(t, sessionID, session.StartupNudgeConfig{
Recipient: "mayor",
Sender: "human",
Topic: "cold-start",
}) // Non-fatal
// GUPP: Gas Town Universal Propulsion Principle
// Send the propulsion nudge to trigger autonomous coordination.
// Wait for beacon to be fully processed (needs to be separate prompt)
time.Sleep(2 * time.Second)
_ = t.NudgeSession(sessionID, session.PropulsionNudgeForRole("mayor", mayorDir)) // Non-fatal
// Startup beacon with instructions is now included in the initial command,
// so no separate nudge needed. The agent starts with full context immediately.
return nil
}