04d7ca2e6a
test / unit (pull_request) Successful in 32s
test / integration (pull_request) Successful in 43s
lint / lint (push) Successful in 1m32s
prd-number / assign-numbers (push) Successful in 17s
test / unit (push) Successful in 29s
Update Quality Badges / update-badges (push) Successful in 1m18s
test / integration (push) Successful in 45s
Chunk 1 (schema + storage): BottleSpec, ActiveAgent, and BottleMetadata gain label and color fields. Both docker and smolmachines backends persist them to metadata.json on prepare and surface them in enumerate_active_agents(). AgentProvider.provision_plan() passes label/color through to the Claude provider, which injects them into claude.json so claude-code displays the session name and color in its header. Codex provider accepts and ignores the knobs. Chunk 2 (curses modal + display): cmd_start presents a two-step curses modal — first edit the label (first keystroke replaces the pre-fill), then optionally pick a color. cli list active renders label with ANSI escape codes when the terminal supports it, falling back to agent_name when no label is set. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
73 lines
2.1 KiB
Python
73 lines
2.1 KiB
Python
"""list: list available agents or active bottles."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import os
|
|
import sys
|
|
|
|
from ..backend import enumerate_active_agents
|
|
from ..manifest import Manifest
|
|
from ._common import PROG, USER_CWD
|
|
|
|
_ANSI_COLOR_CODES: dict[str, str] = {
|
|
"black": "\033[30m",
|
|
"red": "\033[31m",
|
|
"green": "\033[32m",
|
|
"yellow": "\033[33m",
|
|
"blue": "\033[34m",
|
|
"magenta": "\033[35m",
|
|
"cyan": "\033[36m",
|
|
"white": "\033[37m",
|
|
"bright-black": "\033[90m",
|
|
"bright-red": "\033[91m",
|
|
"bright-green": "\033[92m",
|
|
"bright-yellow": "\033[93m",
|
|
"bright-blue": "\033[94m",
|
|
"bright-magenta": "\033[95m",
|
|
"bright-cyan": "\033[96m",
|
|
"bright-white": "\033[97m",
|
|
}
|
|
_ANSI_RESET = "\033[0m"
|
|
|
|
|
|
def _ansi_label(text: str, color: str) -> str:
|
|
if not color:
|
|
return text
|
|
if not sys.stdout.isatty():
|
|
return text
|
|
term = os.environ.get("TERM", "")
|
|
if term in ("dumb", ""):
|
|
return text
|
|
code = _ANSI_COLOR_CODES.get(color)
|
|
if not code:
|
|
return text
|
|
return f"{code}{text}{_ANSI_RESET}"
|
|
|
|
|
|
def cmd_list(argv: list[str]) -> int:
|
|
parser = argparse.ArgumentParser(prog=f"{PROG} list", add_help=True)
|
|
parser.add_argument("scope", choices=["available", "active"])
|
|
args = parser.parse_args(argv)
|
|
|
|
if args.scope == "available":
|
|
manifest = Manifest.resolve(USER_CWD)
|
|
for name in manifest.agents.keys():
|
|
print(name)
|
|
return 0
|
|
|
|
# `active` enumerates every backend (docker + smolmachines)
|
|
# so smolmachines bottles aren't hidden behind the env var.
|
|
active = enumerate_active_agents()
|
|
if not active:
|
|
print("no active bot-bottle bottles", file=sys.stderr)
|
|
return 0
|
|
# One line per bottle: `<backend>\t<slug>\t<label>\t<services>`.
|
|
# Tab-separated keeps the format stable for shell pipelines.
|
|
for b in active:
|
|
services = ",".join(b.services) if b.services else "-"
|
|
display_name = b.label if b.label else b.agent_name
|
|
colored_name = _ansi_label(display_name, b.color)
|
|
print(f"{b.backend_name}\t{b.slug}\t{colored_name}\t{services}")
|
|
return 0
|