50a67c04bd
test / integration-docker (pull_request) Successful in 18s
tracker-policy-pr / check-pr (pull_request) Successful in 17s
test / unit (pull_request) Failing after 41s
lint / lint (push) Failing after 57s
test / integration-firecracker (pull_request) Successful in 3m26s
test / coverage (pull_request) Has been skipped
test / publish-infra (pull_request) Has been skipped
Move the eleven per-command modules (backend, cleanup, commit, edit, info, init, list, login, resume, start, supervise) into a new bot_bottle/cli/commands/ package, leaving the dispatcher (__init__), entrypoint (__main__), and shared helpers (_common, tui) at the cli root. Makes the command surface obvious at a glance and separates handlers from the plumbing that registers them. Updated the dispatcher's COMMANDS imports to .commands.*, bumped the moved files' relative-import depths (.._common, .. import tui, sibling .start unchanged), and repointed test references to bot_bottle.cli.commands.*. Full unit suite green (2243); CLI dispatch verified via `python -m bot_bottle.cli --help`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
60 lines
1.9 KiB
Python
60 lines
1.9 KiB
Python
"""resume: re-launch a bottle by its identity.
|
|
|
|
Reads ~/.bot-bottle/state/<identity>/metadata.json to recover the
|
|
(agent_name, cwd, copy_cwd) the bottle was originally started with,
|
|
then runs the same launch core as `start` — but pinned to the
|
|
recorded identity so the new bottle picks up any per-bottle Dockerfile
|
|
override and transcript snapshot under the same state dir.
|
|
|
|
Use case: an interrupted or preserved bottle needs to be relaunched;
|
|
the operator runs
|
|
./cli.py resume <identity>
|
|
to bring up the replacement from the recorded state.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
|
|
from ...backend import BottleSpec
|
|
from ...bottle_state import read_metadata
|
|
from ...log import die
|
|
from ...manifest import ManifestIndex
|
|
from .._common import PROG, USER_CWD
|
|
from .start import _launch_bottle
|
|
|
|
|
|
def cmd_resume(argv: list[str]) -> int:
|
|
parser = argparse.ArgumentParser(prog=f"{PROG} resume", add_help=True)
|
|
parser.add_argument("--dry-run", action="store_true")
|
|
parser.add_argument(
|
|
"identity",
|
|
help="bottle identity from a prior `start` (see its session-end output)",
|
|
)
|
|
args = parser.parse_args(argv)
|
|
|
|
metadata = read_metadata(args.identity)
|
|
if metadata is None:
|
|
die(
|
|
f"no state recorded for identity {args.identity!r}; "
|
|
f"check ~/.bot-bottle/state/ or run `cli.py start` to create a new bottle"
|
|
)
|
|
|
|
manifest = ManifestIndex.resolve(USER_CWD)
|
|
manifest.require_agent(metadata.agent_name)
|
|
|
|
spec = BottleSpec(
|
|
manifest=manifest,
|
|
agent_name=metadata.agent_name,
|
|
copy_cwd=metadata.copy_cwd,
|
|
user_cwd=metadata.cwd or USER_CWD,
|
|
identity=metadata.identity,
|
|
bottle_names=tuple(metadata.bottle_names),
|
|
)
|
|
backend_name = metadata.backend or None
|
|
return _launch_bottle(
|
|
spec,
|
|
dry_run=args.dry_run,
|
|
backend_name=backend_name,
|
|
)
|