Files
xscapes/internal/scape/scape.go
T
donlucasandClaude Fable 5 a646440725 Name decided: xscapes. Module path follows the repo URL
'create the repo on the donlucasx gh account, call it xscapes.' The
brief always said the name would be picked late, from the built thing;
this is that. asciiscapes and iixscapes are out.

The module path is not cosmetic here: Go resolves a module by its URL,
so a repo at donlucasx/xscapes whose go.mod says asciiscapes is broken
for anyone who tries to install it. Renamed across 37 files, which also
makes the built binary xscapes, which is what the README now types.

Deliberately NOT renamed: the ASCIISCAPES_* environment variables and
~/.config/asciiscapes/, because those are live state on this machine and
a rename would orphan an installed hook mid-session. The README says so
rather than leaving it to be discovered. The working directory and the
internal docs still say asciiscapes too; that is a migration, and he
asked for a repo.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PsdMUTHxbXJ8hud6jedByL
2026-09-01 08:29:10 -07:00

42 lines
1.4 KiB
Go

// Package scape holds the scenes. A scape reads only an Activity — it never
// knows which agent is running or what a "tool call" is. That separation is
// what lets one renderer serve every adapter.
package scape
import "github.com/donlucasx/xscapes/internal/canvas"
// Activity is the agent's state, normalised. Level is 0 (idle) to 1 (flat out).
type Activity struct {
Working bool
Level float64
// ContextUsed is 0 for a fresh session and 1 when the window is full.
// Deliberately phrased as "used" rather than "left" so the zero value --
// what you get if nobody sets it -- means a fresh session, not an
// exhausted one.
ContextUsed float64
// TimeOfDay runs 0 at midnight, .25 dawn, .5 noon, .75 dusk. Midnight is
// the zero value on purpose: it is the look the scape was designed around,
// so forgetting to set this yields the good palette rather than a broken one.
TimeOfDay float64
}
type Scape interface {
Name() string
Update(c *canvas.Canvas, t float64, act Activity)
}
// Hash2 is a cheap deterministic hash. Scene detail placed through it is stable
// for a given seed, so the same repo always gets the same shoreline.
func Hash2(x, y int, seed int64) uint32 {
h := uint32(int64(x)*374761393 + int64(y)*668265263 + seed*2654435761)
h ^= h >> 13
h *= 1274126177
return h ^ (h >> 16)
}
func HashF(x, y int, seed int64) float64 {
return float64(Hash2(x, y, seed)) / 4294967296.0
}