Part of #119.
Problem
A lab is a directory — agentlab.yaml, certs/, state/ — and every command reads it from the current directory: config.Load reads config.File relative to it, caCertPath/tlsCertPath (certs.go), labKubeconfig() (kubeconfig.go) and some thirty other sites are cwd-relative. The binary does not know which labs exist on the machine, so list (#121) has nothing to list, and open, pods or logs from anywhere else fail with "no agentlab.yaml found". With one lab — the common case — the person still has to cd into it first.
Proposed solution
- A registry under
os.UserConfigDir()/agentlab/ (~/.config/agentlab/ on Linux, ~/Library/Application Support/agentlab/ on macOS; the sibling of the update check's cache directory): one entry per cluster name → the absolute lab directory. configure and up write or refresh the entry for their lab; reading prunes entries whose directory or agentlab.yaml is gone. down leaves the entry — the lab still exists as a directory, and list shows its cluster as not created.
- One resolution order, in one place (
loadConfig in main.go, so every command gets it): --lab <name> (a persistent flag on the root) → an agentlab.yaml in the current directory → the single registered lab → on a terminal a huh select among the registered labs (the form's accessible mode applies: ACCESSIBLE, --accessible) → off a terminal a refusal that names the labs and --lab. A --lab that is not registered is refused naming the registered ones. Commands that touch no lab (self-update, completion, help, and list itself) never resolve one.
- The command then runs against that lab's directory. The smallest change that keeps the cwd-relative sites correct is to change into the lab directory before anything touches a path; a lab-directory root threaded through the package is the cleaner shape and can follow. Either way nothing moves and nothing is written outside the lab directory and the registry.
- A name collision is refused.
configure in a directory whose clusterName is registered to a different directory stops, naming both directories and asking for another clusterName — a second lab of that name would collide on the cluster and its ports anyway (today the discovery then treats the other lab's published ports as its own).
agentlab.yaml's clusterName is the lab's name everywhere: the registry, --lab, list, the picker.
Acceptance criteria
Part of #119.
Problem
A lab is a directory —
agentlab.yaml,certs/,state/— and every command reads it from the current directory:config.Loadreadsconfig.Filerelative to it,caCertPath/tlsCertPath(certs.go),labKubeconfig()(kubeconfig.go) and some thirty other sites are cwd-relative. The binary does not know which labs exist on the machine, solist(#121) has nothing to list, andopen,podsorlogsfrom anywhere else fail with "no agentlab.yaml found". With one lab — the common case — the person still has tocdinto it first.Proposed solution
os.UserConfigDir()/agentlab/(~/.config/agentlab/on Linux,~/Library/Application Support/agentlab/on macOS; the sibling of the update check's cache directory): one entry per cluster name → the absolute lab directory.configureandupwrite or refresh the entry for their lab; reading prunes entries whose directory oragentlab.yamlis gone.downleaves the entry — the lab still exists as a directory, andlistshows its cluster as not created.loadConfigin main.go, so every command gets it):--lab <name>(a persistent flag on the root) → anagentlab.yamlin the current directory → the single registered lab → on a terminal a huh select among the registered labs (the form's accessible mode applies:ACCESSIBLE,--accessible) → off a terminal a refusal that names the labs and--lab. A--labthat is not registered is refused naming the registered ones. Commands that touch no lab (self-update,completion,help, andlistitself) never resolve one.configurein a directory whoseclusterNameis registered to a different directory stops, naming both directories and asking for anotherclusterName— a second lab of that name would collide on the cluster and its ports anyway (today the discovery then treats the other lab's published ports as its own).agentlab.yaml'sclusterNameis the lab's name everywhere: the registry,--lab,list, the picker.Acceptance criteria
agentlab podsandagentlab logs musterfrom an unrelated directory use it. With two, a terminal gets a picker and< /dev/nullgets a refusal naming both labs and--lab;--lab <name>skips the picker.agentlab.yamlis used without a question, whatever the registry says.configurewith aclusterNameregistered to another directory is refused naming both directories.internal/forms, scripted keystrokes).agentlab.yaml…") describes the order above and--lab.