466f4ee13a
tracker-policy-pr / check-pr (pull_request) Successful in 13s
test / integration-docker (pull_request) Successful in 34s
test / unit (pull_request) Successful in 49s
lint / lint (push) Successful in 57s
test / integration-firecracker (pull_request) Successful in 3m29s
test / coverage (pull_request) Successful in 20s
test / publish-infra (pull_request) Has been skipped
Brings in the two commits main gained: #472 (CLI cleanup — remove `info`, split `list active` into a top-level `active`, simplify `list`) and the terminology glossary. #472 was written against the old flat cli/ layout, so its semantics are reconciled into the reorg'd cli/commands/ structure: * new `active` command lives at cli/commands/active.py, registered in the lazy registry and listed in `help` (not left at the flat path). * `info` removed: deleted cli/commands/info.py, dropped from the registry and `help`. * `list` simplified to list-available-only, using the reorg's os.getcwd()/constants.PROG conventions. * the `list active` -> `active` doc wording applied to the backend docstrings that our split moved into base.py / selection.py. Our reorg wins for the fully-rewritten dispatcher (cli/__init__ shim, backend facade). pyright: 0 errors. Full unit suite green (2243). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
"""commit: freeze a running bottle's state to a resumable artifact.
|
|
|
|
Docker bottles are committed to a local Docker image. Macos-container
|
|
bottles are exported and rebuilt as a local Apple Container image.
|
|
Firecracker bottles stream the guest rootfs out over SSH and rebuild a
|
|
local Docker image. The resulting reference is stored in per-bottle
|
|
state so the next `./cli.py resume <slug>` boots from the snapshot
|
|
instead of rebuilding from the Dockerfile.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
|
|
from ...backend import enumerate_active_agents
|
|
from ...backend.freeze import CommitCancelled, get_freezer
|
|
from ...bottle_state import read_metadata
|
|
from ...log import die
|
|
from ..constants import PROG
|
|
from .. import tui
|
|
|
|
|
|
def cmd_commit(argv: list[str]) -> int:
|
|
parser = argparse.ArgumentParser(prog=f"{PROG} commit", add_help=True)
|
|
parser.add_argument(
|
|
"slug",
|
|
nargs="?",
|
|
default=None,
|
|
help=(
|
|
"bottle slug from `cli.py active` "
|
|
"(omit to pick interactively)"
|
|
),
|
|
)
|
|
args = parser.parse_args(argv)
|
|
|
|
slug = args.slug
|
|
if slug is None:
|
|
active = enumerate_active_agents()
|
|
if not active:
|
|
die("no active bottles; start one with `./cli.py start`")
|
|
choices = [a.slug for a in active]
|
|
slug = tui.filter_select(choices, title="Select bottle to commit")
|
|
if slug is None:
|
|
return 0
|
|
|
|
metadata = read_metadata(slug)
|
|
backend = metadata.backend if metadata else ""
|
|
|
|
try:
|
|
get_freezer(backend).commit_slug(slug)
|
|
except CommitCancelled:
|
|
return 0
|
|
return 0
|