feat(prime): Add session metadata output for seance discovery

New outputSessionMetadata() function prints a structured line at prime start:
[GAS TOWN] role:mayor pid:12345 session:abc-uuid-123

This enables gt seance to discover sessions from Claude transcripts,
complementing the existing event emission to .events.jsonl.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
mayor
2026-01-02 00:10:55 -08:00
committed by beads/crew/dave
parent c328730a00
commit 302e14cf27

View File

@@ -118,6 +118,9 @@ func runPrime(cmd *cobra.Command, args []string) error {
// Emit session_start event for seance discovery
emitSessionEvent(ctx)
// Output session metadata for seance discovery
outputSessionMetadata(ctx)
// Output context
if err := outputPrimeContext(ctx); err != nil {
return err
@@ -1523,3 +1526,28 @@ func emitSessionEvent(ctx RoleContext) {
payload := events.SessionPayload(sessionID, actor, topic, ctx.WorkDir)
events.LogFeed(events.TypeSessionStart, actor, payload)
}
// outputSessionMetadata prints a structured metadata line for seance discovery.
// Format: [GAS TOWN] role:<role> pid:<pid> session:<session_id>
// This enables gt seance to discover sessions from gt prime output.
func outputSessionMetadata(ctx RoleContext) {
if ctx.Role == RoleUnknown {
return
}
// Get agent identity for the role field
actor := getAgentIdentity(ctx)
if actor == "" {
return
}
// Get session ID from environment (set by Claude Code hooks)
sessionID := os.Getenv("CLAUDE_SESSION_ID")
if sessionID == "" {
// Fall back to a generated identifier
sessionID = fmt.Sprintf("%s-%d", actor, os.Getpid())
}
// Output structured metadata line
fmt.Printf("[GAS TOWN] role:%s pid:%d session:%s\n", actor, os.Getpid(), sessionID)
}