buddy

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package buddy implements the companion (tamagotchi) system.

Mirrors src/buddy/ from the Claude Code TS source:

  • Mulberry32 PRNG seeded from FNV-1a hash of user ID
  • 18 species with 5 rarity tiers
  • 5 stats (DEBUGGING, PATIENCE, CHAOS, WISDOM, SNARK)
  • ASCII sprite frames with eye/hat substitution
  • /buddy command for display

Index

Constants

This section is empty.

Variables

View Source
var AllSpecies = []string{
	"duck", "goose", "blob", "cat", "dragon", "octopus",
	"owl", "penguin", "turtle", "snail", "ghost", "axolotl",
	"capybara", "cactus", "robot", "rabbit", "mushroom", "chonk",
}

AllSpecies is the complete list of 18 companion species (mirrors buddy/types.ts).

Functions

func IntroPrompt

func IntroPrompt() string

IntroPrompt returns the system-prompt block injected when a companion is active. Mirrors src/buddy/prompt.ts companionIntroText: tells the model that a small named buddy sits beside the input box, and what to do when the user addresses the buddy by name. Empty string when no companion is configured.

Read at startup by cmd/conduit/main.go to fold into the system blocks alongside CLAUDE.md and MCP instructions.

func RenderFace

func RenderFace(b Bones) string

RenderFace returns a compact inline representation of the companion.

func RenderSprite

func RenderSprite(b Bones, frame int) string

RenderSprite renders one animation frame of the companion. frame is taken modulo the frame count. Eye placeholder {E} is substituted.

func Save

func Save(sc *StoredCompanion) error

Save persists the companion soul.

func SpriteFrameCount

func SpriteFrameCount(species string) int

SpriteFrameCount returns the number of animation frames for a species.

func Summary

func Summary(b Bones, name string) string

Types

type Bones

type Bones struct {
	Species string
	Rarity  string
	Eye     string
	Hat     string
	Shiny   bool
	Stats   map[string]int // 1-100 per stat
}

Bones are the deterministically generated companion attributes.

func GenerateBones

func GenerateBones(userID string, forcedRarity ...string) Bones

GenerateBones generates deterministic companion bones for the given userID. Mirrors companion.ts generateBones().

forcedRarity overrides the weighted rarity roll (use "" for normal roll). The env var CLAUDE_BUDDY_FORCE_RARITY takes precedence over forcedRarity.

type StoredCompanion

type StoredCompanion struct {
	Name         string `json:"name"`
	UserID       string `json:"userId"`
	HatchedAt    string `json:"hatchedAt,omitempty"`
	ForcedRarity string `json:"forcedRarity,omitempty"` // persisted rarity override
}

StoredCompanion is the persisted companion soul (bones are regenerated).

func Load

func Load() (*StoredCompanion, error)

Load reads the stored companion. Returns nil if none exists yet.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL