Files
donlucasandClaude Opus 5 c9a019eb88 The name finally reaches the parts that were left alone
xscapes was decided on 09-01 with the repo, and the rename stopped at the
module path because going further meant touching live state: the env vars,
~/.config/asciiscapes/, and the marker on twelve hooks already installed in
his settings.json. This finishes it.

The marker was the whole risk. It is uninstall's only handle on its own
work, so changing the constant alone would have left twelve hooks that
nothing could see -- uninstall reporting zero, install adding a second copy
beside each, and a person editing JSON by hand to remove a tool that said
it had gone. install.go now WRITES `# xscapes:v1` and RECOGNISES
`# asciiscapes:v1`, and the existing stale-path branch migrates them. The
plan says "migrated from asciiscapes:v1" rather than "re-pointed", because
the two are different amounts of risk and the reviewer should be told which.
Proven by emptying legacyMarkers: the tests go red, and the failure shows
the orphan exactly -- Stop ends up with two hooks, one of them invisible.

Settings were renamed with a fallback rather than a hard cut, because a
rename is the cheapest way there is to build a knob nothing reads: the
value looks applied, the picture does not change, and the measurement is
wrong with nothing saying so. These are variables typed by hand while
judging a frame, so muscle memory is the expected input. internal/envx
keeps ASCIISCAPES_* working and names it on stderr once, from the top of
main -- the last moment certainly safe to write, since -live, claude and
inside take the alternate screen shortly after. hook and statusline are
exempt: one runs on every tool call into /dev/null, the other owns a line
of the agent's chrome. Writing the test for the warning found it firing on
a variable exported empty, which is inert, and a warning that cries wolf on
a clean environment is one nobody reads.

Left saying asciiscapes on purpose, and these are not leftovers: the
legacyMarkers entry, envx's legacyPrefix, the verbatim quotes in
_FEEDBACK.md, origin-chat.md's decision pass, and the superseded bullets in
RESUME.md. Rewriting a record of what was true then would only make it lie.

Live state moved with it: ~/.config/asciiscapes -> ~/.config/xscapes (53
spools, 17 backups), and the twelve hooks migrated with a diff of exactly
24 lines, all marker, nothing else touched. Two spools written into the old
path by the still-old binary during the swap were merged back in timestamp
order rather than appended.

Also drops a duplicated `xscapes tune` line in the help, which predates
this and was only visible once the name was read twice.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R1u8vp8AgrTuaCCcLv6HVi
2026-09-03 12:17:14 -07:00

108 lines
3.6 KiB
Go

package main
import (
"fmt"
"strings"
"github.com/donlucasx/xscapes/internal/canvas"
"github.com/donlucasx/xscapes/internal/companion"
"github.com/donlucasx/xscapes/internal/scape"
)
// animPage renders each state as a real frame sequence and cycles it in the
// browser. A still cannot show breathing, and breathing is the whole point.
func animPage(seed int64, frames int, fps float64) string {
cat := companion.NewCat()
cw, ch := cat.Size()
states := []struct {
st companion.State
note string
say string
}{
{companion.Resting, "slow breath, tail barely moves, eyes half shut", ""},
{companion.Working, "faster breath, tail sweeping, eyes open, occasional blink", ""},
{companion.NeedsYou, "quick breath, tail flicking, wide eyes, ask balloon", "allow Bash?"},
{companion.Done, "slow breath, tail held high and still, content eyes, soft knock", "tests passed"},
}
var b strings.Builder
b.WriteString(`<style>` +
`.stage{position:relative}.fr{display:none}.fr:first-child{display:block}` +
`.row{display:flex;gap:26px;align-items:center}` +
`</style>`)
b.WriteString(`<h1>xscapes &mdash; companion, animated</h1>`)
for _, s := range states {
var st strings.Builder
for i := 0; i < frames; i++ {
t := float64(i) / fps
c := canvas.New(72, 24, canvas.AlphaFar, canvas.AlphaMid, canvas.AlphaNear)
act := scape.Activity{}
if s.st != companion.Resting {
act = scape.Activity{Working: true, Level: 0.65}
}
scape.NewShore(seed, false).Update(c, t, act)
top := c.H - 2 - ch
cat.Draw(c.Near(), 6, top, t, s.st)
if s.say != "" {
rows, col := companion.Bubble(s.say), bubbleAskCol
if s.st == companion.Done {
rows, col = companion.DoneBubble(s.say), bubbleCol
}
(&companion.Sprite{Rows: rows, Body: col, Opaque: true}).
Draw(c.Near(), 6+cw-2, top-len(rows))
}
fmt.Fprintf(&st, `<div class="fr">%s</div>`, c.HTMLFragment(13))
}
fmt.Fprintf(&b,
`<div class="card"><div class="meta"><div class="nm">%s</div>`+
`<div class="rg">%d frames &middot; %.0f fps</div><div class="nt">%s</div></div>`+
`<div class="stage">%s</div></div>`,
s.st, frames, fps, s.note, st.String())
}
// Walking: there and back, so the loop is seamless and both facings show.
{
ww, wh := cat.WalkSize()
const steps = 48
x0, x1 := 4, 72-ww-4
var st strings.Builder
for i := 0; i < steps; i++ {
half := steps / 2
var px int
var dir int
if i < half {
px, dir = x0+(x1-x0)*i/half, 1
} else {
px, dir = x1-(x1-x0)*(i-half)/half, -1
}
c := canvas.New(72, 24, canvas.AlphaFar, canvas.AlphaMid, canvas.AlphaNear)
scape.NewShore(seed, false).Update(c, float64(i)/fps,
scape.Activity{Working: true, Level: 0.5})
// Phase tracks distance walked, not the clock, so the feet do not skate.
cat.DrawWalk(c.Near(), px, c.H-2-wh, float64(px)*0.8*float64(dir), dir)
fmt.Fprintf(&st, `<div class="fr">%s</div>`, c.HTMLFragment(13))
}
fmt.Fprintf(&b,
`<div class="card"><div class="meta"><div class="nm">walking</div>`+
`<div class="rg">%d frames &middot; %.0f fps</div>`+
`<div class="nt">side view, four legs on diagonal pairs, body bobs at mid-stride; `+
`turns around at each end</div></div>`+
`<div class="stage">%s</div></div>`, steps, fps, st.String())
}
fmt.Fprintf(&b, `<script>
document.querySelectorAll('.stage').forEach(function(st){
var fr = Array.prototype.slice.call(st.children), i = 0;
setInterval(function(){
fr[i].style.display = 'none';
i = (i + 1) %% fr.length;
fr[i].style.display = 'block';
}, %d);
});
</script>`, int(1000/fps))
return canvas.HTMLPage("xscapes — companion animated", b.String())
}