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

76 lines
2.5 KiB
Go

// Package envx reads xscapes settings from the environment, and keeps the
// pre-rename ASCIISCAPES_* names working.
//
// The project was called asciiscapes until 2026-09-03. Every setting it reads
// was renamed with it, and a rename is the cheapest way there is to build a
// knob that nothing reads: the value looks applied, the picture does not
// change, and a measurement taken from it is wrong with nothing saying so.
// Most of these variables exist precisely to be typed by hand while judging a
// frame, so muscle memory is the expected input, not a mistake to punish.
//
// The two halves are deliberately separate. Lookup makes an old name still
// WORK, silently, because it is called from render paths that must not write
// to a terminal mid-frame. WarnLegacy makes it LOUD, once, from a place where
// printing is safe.
package envx
import (
"fmt"
"io"
"os"
"sort"
"strings"
)
// prefix is the current name. legacyPrefix is what it used to be.
const (
prefix = "XSCAPES_"
legacyPrefix = "ASCIISCAPES_"
)
// Lookup returns the value of XSCAPES_<name>, falling back to the pre-rename
// ASCIISCAPES_<name>. The new name wins when both are set. Silent by design --
// see WarnLegacy for the announcement.
func Lookup(name string) string {
if v := os.Getenv(prefix + name); v != "" {
return v
}
return os.Getenv(legacyPrefix + name)
}
// Legacy lists the ASCIISCAPES_* variables actually present in the
// environment, sorted, each rendered as "OLD (use NEW)".
func Legacy() []string {
var out []string
for _, kv := range os.Environ() {
k, v, ok := strings.Cut(kv, "=")
if !ok || !strings.HasPrefix(k, legacyPrefix) || v == "" {
// An empty value is inert -- Lookup returns "" for it either way --
// so warning about it is a false alarm, and a warning that cries
// wolf on a clean environment is one nobody reads.
continue
}
name := strings.TrimPrefix(k, legacyPrefix)
if os.Getenv(prefix+name) != "" {
out = append(out, fmt.Sprintf("%s (ignored; %s%s is set)", k, prefix, name))
continue
}
out = append(out, fmt.Sprintf("%s (use %s%s)", k, prefix, name))
}
sort.Strings(out)
return out
}
// WarnLegacy names every old-style variable on w. Call it once, early, from
// somewhere that is not painting a frame.
func WarnLegacy(w io.Writer) {
old := Legacy()
if len(old) == 0 {
return
}
fmt.Fprintf(w, "xscapes: %s is the old name; these still work but will not forever:\n", strings.TrimSuffix(legacyPrefix, "_"))
for _, s := range old {
fmt.Fprintf(w, " %s\n", s)
}
}