Skip to content

abc_mine.cli

WARNING

This documentation is almost entirely "vibe coded"; while a helpful resource for humans and agents to understand this codebase, it should not be considered a source of ground truth in the way documentation normally is, and the user is responsible for verifying that all instructions given here are safe.

abc_mine.cli

The abc-mine command-line interface.

Subcommands, in the order a run uses them::

init        create a run and lock its configuration
preflight   prove the container can build and test the codebase
screen      score every selected commit against the rubric   (parallel)
rank        collapse viable summaries into a ranked shortlist (one agent)
build       turn each shortlisted commit into a task         (parallel)
status      report where a run stands
usage       report model usage, spend, and wall time per stage
export      copy emitted tasks into a abc-runner checkout
prompts     inspect, scaffold, and render prompt customization

Every stage command loads the config, loads the prompt pack, resolves the model from the environment, and checks the invocation against the run's locked configuration before doing any work. That ordering is deliberate: all of it is cheap, and all of it fails in seconds rather than after provisioning containers.

CliError

Bases: RuntimeError

A user-facing error. Reported without a traceback.

Source code in abc_mine/cli.py
class CliError(RuntimeError):
    """A user-facing error. Reported without a traceback."""

cmd_init

cmd_init(args: Namespace) -> int

Create a run directory and lock its configuration.

Source code in abc_mine/cli.py
def cmd_init(args: argparse.Namespace) -> int:
    """Create a run directory and lock its configuration."""
    cfg, pack = _load(args)
    _announce_pack(pack)

    problems = config_mod.validate_paths(cfg)
    if problems:
        raise CliError("configuration problems:\n  - " + "\n  - ".join(problems))

    try:
        model = config_mod.llm_env()
    except ConfigError as exc:
        # init is allowed without credentials so a run can be prepared on a
        # machine that will never execute it; the lock then records no model, and
        # the first stage to run will supply and lock one via drift.
        if not args.allow_missing_model:
            raise CliError(
                str(exc) + "\n\n(Pass --allow-missing-model to initialize anyway, "
                "e.g. when preparing a run on a submission host.)"
            ) from exc
        print(f"WARNING: {exc}", file=sys.stderr)
        print(file=sys.stderr)
        model = {"base_url": "", "model": "", "api": ""}

    cfg.run_dir.mkdir(parents=True, exist_ok=True)

    manifest_path = cfg.run_dir / manifest_mod.MANIFEST_NAME
    if args.reinit and manifest_path.is_file():
        # Re-lock an existing run to the current settings. Outputs are untouched;
        # only the lock is rewritten, and the previous one is kept beside it so the
        # change remains auditable.
        backup = manifest_path.with_suffix(".json.superseded")
        shutil.copy2(manifest_path, backup)
        manifest_path.unlink()
        print(f"Re-initializing: previous manifest saved as {backup.name}")

    try:
        run_manifest = manifest_mod.create(cfg, pack, model, notes=args.notes or "")
    except ManifestError as exc:
        raise CliError(str(exc)) from exc

    toolchain_problems = preflight_mod.check_config(cfg)

    print(f"Initialized run '{cfg.run_id}' at {cfg.run_dir}")
    print()
    git = run_manifest.data.get("codebase", {}).get("git", {})
    print(f"  codebase:   {cfg.codebase.name}")
    print(f"    HEAD:     {git.get('head', '?')[:12]}  {git.get('head_subject', '')[:48]}")
    print(f"    commits:  {git.get('commit_count', '?')}")
    print(f"  container:  {cfg.container.image}")
    print(f"  model:      {model.get('model') or '(not configured)'}")
    print(f"  prompts:    {cfg.prompts.pack or '(generic, no pack)'}")
    if pack.slots:
        print(f"    slots:    {', '.join(sorted(pack.slots))}")
    print(f"  manifest:   {run_manifest.path}")
    print()

    if toolchain_problems:
        print("Toolchain review:", file=sys.stderr)
        for problem in toolchain_problems:
            print(f"  - {problem}", file=sys.stderr)
        print(file=sys.stderr)

    print("Next:  abc-mine preflight --config <config>")
    print("       (proves the container can actually build and test this codebase)")
    return 0

cmd_preflight

cmd_preflight(args: Namespace) -> int

Prove the container can build and test the codebase.

Source code in abc_mine/cli.py
def cmd_preflight(args: argparse.Namespace) -> int:
    """Prove the container can build and test the codebase."""
    cfg, pack = _load(args)
    _header(cfg, "preflight")

    problems = config_mod.validate_paths(cfg)
    if problems:
        raise CliError("configuration problems:\n  - " + "\n  - ".join(problems))

    static = preflight_mod.check_config(cfg)
    if static:
        print("Toolchain review:")
        for problem in static:
            print(f"  - {problem}")
        print()

    result = preflight_mod.run(
        cfg,
        dry_run=args.dry_run,
        include_full_test=args.full_test,
    )
    print(result.describe())
    print()

    report = preflight_mod.save_report(cfg, result) if cfg.run_dir.exists() else None
    if report:
        print(f"Report: {report}")

    if result.ok and args.write_config:
        if result.full_build_seconds is None and result.targeted_test_seconds is None:
            print("Nothing measured to write back.")
        else:
            backup = preflight_mod.write_measurements(cfg, result)
            print(f"Wrote measured timings into {cfg.source_path}")
            print(f"  (previous version saved as {backup.name})")
            print(
                "  Every stage now quotes these measured figures in its prompts, "
                "so cost\n  judgements are based on fact rather than assumption."
            )
    elif result.ok and not args.dry_run:
        print(
            "Tip: re-run with --write-config to record the measured build and test\n"
            "     costs in your config. Agents reason about verification cost, and\n"
            "     a measured number is far better than an assumed one."
        )

    if not result.ok:
        print()
        print(
            "Preflight FAILED. The mining stages depend on these commands working\n"
            "inside the container: screening agents use them to check candidates,\n"
            "and every emitted benchmark's verifier must call them at grading time.\n"
            "Running the workflow now would burn agent budget producing tasks that\n"
            "cannot be verified.",
            file=sys.stderr,
        )
        return 1

    print()
    print("Next:  abc-mine screen --config <config>")
    return 0

cmd_screen

cmd_screen(args: Namespace) -> int

Score every selected commit against the rubric.

Source code in abc_mine/cli.py
def cmd_screen(args: argparse.Namespace) -> int:
    """Score every selected commit against the rubric."""
    cfg, pack, model = _prepare_stage(args, "screen")
    _header(cfg, "screen")

    if args.plan:
        work_plan = screen_stage.plan(cfg, only=args.only)
        print(work_plan.describe(cfg.execution.max_attempts))
        return 0

    _warn_if_no_preflight(cfg)

    outcome = screen_stage.run(
        cfg, pack, model, dry_run=args.dry_run, only=args.only
    )
    if not outcome.is_primary:
        return 0

    print()
    print(outcome.describe())
    stats = screen_stage.summarize(cfg)
    print()
    print(f"Run totals: {stats['screened']} screened, {stats['viable']} viable, "
          f"{stats['disqualified']} disqualified")
    if stats.get("viable"):
        print(f"  best score {stats['score_max']}, mean {stats['score_mean']}")
    usage = stats.get("usage") or {}
    if usage.get("requests"):
        print(f"  model usage: {telemetry_mod.describe(usage)}")

    failed = outcome.counts.get("failed", 0)
    if failed:
        print()
        print(
            f"{failed} item(s) failed. They are recorded in "
            f"{screen_stage.attempts_path(cfg)}\n"
            f"and will be retried on the next run, up to "
            f"execution.max_attempts ({cfg.execution.max_attempts}).",
            file=sys.stderr,
        )
    print()
    print("Next:  abc-mine rank --config <config>")
    return 0

cmd_rank

cmd_rank(args: Namespace) -> int

Collapse viable summaries into a ranked shortlist.

Source code in abc_mine/cli.py
def cmd_rank(args: argparse.Namespace) -> int:
    """Collapse viable summaries into a ranked shortlist."""
    cfg, pack, model = _prepare_stage(args, "rank")
    _header(cfg, "rank")

    try:
        if args.plan:
            if cfg.rank.method == "interleaving":
                from .stages import rank_interleaving

                il_plan = rank_interleaving.plan(cfg, pack, model)
                print(il_plan.describe())
                over = il_plan.over_budget
            else:
                single = rank_stage.plan(cfg, pack, model)
                print(single.describe())
                over = [single] if single.over_budget else []
            for group_plan in over:
                print()
                print(rank_stage._budget_error(group_plan))
            return 1 if over else 0

        shortlist = rank_stage.run(
            cfg, pack, model, dry_run=args.dry_run, force=args.force
        )
    except rank_stage.RankError as exc:
        raise CliError(str(exc)) from exc

    # Non-primary MPI ranks have done their share; rank 0 reports.
    if shortlist.get("dry_run") or shortlist.get("is_primary") is False:
        return 0

    print()
    print("Next:  abc-mine build --config <config>")
    return 0

cmd_build

cmd_build(args: Namespace) -> int

Turn each shortlisted commit into a abc-runner task.

Source code in abc_mine/cli.py
def cmd_build(args: argparse.Namespace) -> int:
    """Turn each shortlisted commit into a abc-runner task."""
    cfg, pack, model = _prepare_stage(args, "build")
    _header(cfg, "build")

    try:
        if args.plan:
            print(build_stage.plan(
                cfg, only=args.only, force=args.force, limit=args.limit
            ).describe())
            return 0

        _warn_if_no_preflight(cfg)
        outcome = build_stage.run(
            cfg, pack, model,
            dry_run=args.dry_run, only=args.only, force=args.force,
            limit=args.limit,
        )
    except rank_stage.RankError as exc:
        raise CliError(str(exc)) from exc

    if not outcome.is_primary:
        return 0

    print()
    print(outcome.describe())
    stats = build_stage.summarize(cfg)
    print()
    emitted = f"Emitted tasks: {stats['ok']} ok, {stats['failed']} failed"
    if stats["saved"]:
        emitted += (
            f", {stats['unfinished']} unfinished-saved, "
            f"{stats['awaiting_check']} awaiting-check"
        )
    print(emitted)
    print(f"  group: {stats['group_dir']}")
    if (stats.get("usage") or {}).get("requests"):
        print(f"  model usage: {telemetry_mod.describe(stats['usage'])}")
    if stats["saved"]:
        print(
            f"  {stats['saved']} task(s) were interrupted and saved; re-run build "
            "to resume them."
        )

    if stats["failures"]:
        print()
        print("Failures:", file=sys.stderr)
        for failure in stats["failures"]:
            detail = (failure["detail"] or "").splitlines()
            print(f"  {failure['task_id']}: {detail[0] if detail else ''}", file=sys.stderr)

    if stats["ok"]:
        print()
        print("Next:  abc-mine export --config <config> --dest <abc-runner-checkout>")
    return 0 if not stats["failed"] else 1

cmd_status

cmd_status(args: Namespace) -> int

Report where a run stands.

Source code in abc_mine/cli.py
def cmd_status(args: argparse.Namespace) -> int:
    """Report where a run stands."""
    cfg, pack = _load(args)

    try:
        run_manifest = manifest_mod.load(cfg)
    except ManifestError as exc:
        raise CliError(str(exc)) from exc

    print("=" * 72)
    print(f"Run: {cfg.run_id}")
    print("=" * 72)
    print(f"  created:    {run_manifest.created_at} by "
          f"{run_manifest.data.get('run', {}).get('created_by', '?')}")
    print(f"  codebase:   {cfg.codebase.name}")
    git = run_manifest.data.get("codebase", {}).get("git", {})
    print(f"    HEAD:     {git.get('head', '?')[:12]} ({git.get('commit_count', '?')} commits)")
    print(f"  container:  {cfg.container.image}")
    locked_model = run_manifest.fingerprint.get("model.id") or "(none)"
    print(f"  model:      {locked_model}")
    overrides = run_manifest.data.get("prompt_overrides_active") or []
    print(f"  prompts:    {cfg.prompts.pack or '(generic)'}"
          + (f"  OVERRIDES: {', '.join(overrides)}" if overrides else ""))
    if run_manifest.data.get("accepted_drift"):
        print(f"  NOTE: this run has accepted configuration drift "
              f"({len(run_manifest.data['accepted_drift'])} time(s)); its outputs "
              f"are a mixture")
    print()

    report = preflight_mod.load_report(cfg)
    if report is None:
        print("  preflight:  not run")
    else:
        mark = "passed" if report.get("ok") else "FAILED"
        detail = []
        if report.get("full_build_seconds"):
            detail.append(f"build {config_mod._humanize_seconds(report['full_build_seconds'])}")
        if report.get("targeted_test_seconds"):
            detail.append(
                f"targeted test {config_mod._humanize_seconds(report['targeted_test_seconds'])}"
            )
        print(f"  preflight:  {mark}" + (f"  ({', '.join(detail)})" if detail else ""))

    screen_stats = screen_stage.summarize(cfg)
    if screen_stats["screened"]:
        print(
            f"  screen:     {screen_stats['screened']} screened, "
            f"{screen_stats['viable']} viable, "
            f"{screen_stats['disqualified']} disqualified"
        )
        failures = manifest_mod.attempt_counts(
            screen_stage.attempts_path(cfg), status="failed"
        )
        if failures:
            spent = manifest_mod.exhausted_items(
                screen_stage.attempts_path(cfg), cfg.execution.max_attempts
            )
            print(f"                {len(failures)} with failures, "
                  f"{len(spent)} out of attempts")
    else:
        print("  screen:     not run")

    try:
        shortlist = rank_stage.load_shortlist(cfg)
        method = shortlist.get("method", {})
        print(
            f"  rank:       {shortlist.get('n_selected', 0)} "
            f"{'ranked' if shortlist.get('complete') else 'selected'} of "
            f"{shortlist.get('n_candidates', 0)} candidates"
            + ("  (single-context)" if method.get("single_context") else "")
            + (f"  (interleaving, {method.get('groups')} groups)"
               if method.get("name") == "interleaving" else "")
        )
    except rank_stage.RankError:
        print("  rank:       not run")

    build_stats = build_stage.summarize(cfg)
    if build_stats["tasks"]:
        line = f"  build:      {build_stats['ok']} ok, {build_stats['failed']} failed"
        if build_stats["saved"]:
            line += (
                f", {build_stats['unfinished']} unfinished-saved, "
                f"{build_stats['awaiting_check']} awaiting-check"
            )
        print(line)
        if build_stats["saved"]:
            print("                (saved states will be resumed on the next build run)")
    else:
        print("  build:      not run")

    spend = _stage_usages(cfg)
    if any(s["usage"].get("requests") for s in spend.values()):
        print()
        for stage, info in spend.items():
            if info["usage"].get("requests"):
                print(f"  {stage + ' usage:':<12}{telemetry_mod.describe(info['usage'])}")
        print("                (details: abc-mine usage --config <config>)")

    print()
    if args.verbose:
        print("Stage history:")
        for record in run_manifest.data.get("stages", []):
            job = f" job {record['slurm_job_id']}" if record.get("slurm_job_id") else ""
            print(f"  {record.get('at', '?')}  {record.get('stage', '?'):<10}"
                  f" on {record.get('host', '?')}{job}")
            # Resources are provenance, not configuration: they explain a measured
            # timing rather than constraining a resume. Shown so a run assembled
            # from differently-sized allocations can be interpreted.
            res = record.get("resources") or {}
            parts = [
                f"{k.replace('SLURM_', '').lower()}={v}"
                for k, v in res.items()
                if k not in ("SLURM_JOB_ID", "SLURM_JOB_NODELIST")
            ]
            if parts:
                print(f"    {' '.join(parts)}")
            model = record.get("model_id")
            if model:
                print(f"    model={model} parallel={record.get('parallel', '?')}"
                      f" workers={record.get('workers', '?')}")
    return 0

cmd_usage

cmd_usage(args: Namespace) -> int

Report model usage, spend, and wall time per stage.

Source code in abc_mine/cli.py
def cmd_usage(args: argparse.Namespace) -> int:
    """Report model usage, spend, and wall time per stage."""
    cfg, _ = _load(args)
    pricing = None
    if args.reprice:
        try:
            pricing = config_mod.llm_pricing()
        except ConfigError as exc:
            raise CliError(str(exc)) from exc
    spend = _stage_usages(cfg, pricing, reprice=args.reprice)
    total = telemetry_mod.merge(info["usage"] for info in spend.values())
    if args.json:
        print(json.dumps({"run": cfg.run_id, "stages": spend, "total": total},
                         indent=2, sort_keys=True))
        return 0

    print("=" * 72)
    print(f"Usage: {cfg.run_id}" + ("  (repriced at current LLM_PRICE_*)" if args.reprice else ""))
    print("=" * 72)
    for stage, info in list(spend.items()) + [("total", {"usage": total, "source": ""})]:
        u = info["usage"]
        print()
        head = f"{stage}:"
        if stage != "total":
            head += f"  {info.get('items', 0)} item(s), {info.get('runs', 0)} run(s)"
            head += f"  [source: {info.get('source') or 'none'}]"
        print(head)
        print(f"  requests:            {u.get('requests', 0):,}")
        if u.get("requests_tokens_unknown"):
            print(f"    of which {u['requests_tokens_unknown']:,} have no token counts "
                  "(recorded before token logging was fixed)")
        print(f"  input (standard):    {u.get('input_tokens_standard', 0):,}")
        print(f"  input (cache read):  {u.get('input_tokens_cache_read', 0):,}")
        print(f"  input (cache write): {u.get('input_tokens_cache_write', 0):,}")
        print(f"  output:              {u.get('output_tokens', 0):,}")
        print(f"  cost:                {telemetry_mod.format_cost(u.get('cost'))}")
        print(f"  request seconds:     {float(u.get('request_seconds') or 0):,.1f}")
        agent = u.get("agent_seconds")
        print(f"  agent wall seconds:  "
              + ("unknown" if agent is None else f"{float(agent):,.1f}"))
        tools = telemetry_mod.top_tools(u, args.top)
        if tools:
            print("  top tools by seconds:")
            for name, slot in tools:
                print(f"    {name:<16} {float(slot.get('seconds') or 0):>10,.1f}s  "
                      f"{slot.get('count', 0)} call(s)"
                      + (f", {slot['errors']} error(s)" if slot.get("errors") else ""))
    return 0

cmd_export

cmd_export(args: Namespace) -> int

Copy emitted tasks into a abc-runner checkout.

Source code in abc_mine/cli.py
def cmd_export(args: argparse.Namespace) -> int:
    """Copy emitted tasks into a abc-runner checkout."""
    cfg, _ = _load(args)
    source = build_stage.group_dir(cfg)
    if not source.is_dir():
        raise CliError(
            f"no emitted task group at {source}\n"
            "Run the build stage first:  abc-mine build --config <config>"
        )

    ok_tasks = build_stage.completed_tasks(build_stage.manifest_path(cfg))
    if not ok_tasks:
        raise CliError(
            "no tasks have been built successfully, so there is nothing to export.\n"
            f"See {build_stage.manifest_path(cfg)} for what failed."
        )

    dest_root = Path(args.dest).expanduser().resolve()
    dest = dest_root / "tasks" / cfg.group_id if args.abc_runner_root else dest_root
    dest.mkdir(parents=True, exist_ok=True)

    # Only verified-ok tasks are exported. A failed task's directory may exist and
    # look complete, but its verifier is known not to discriminate — exporting it
    # would put a benchmark that cannot grade anything into a real suite.
    exported: list[str] = []
    for child in sorted(source.iterdir()):
        if child.is_file():
            shutil.copy2(child, dest / child.name)
            continue
        if child.name not in ok_tasks:
            continue
        target = dest / child.name
        if target.exists():
            if not args.force:
                print(f"  skip {child.name} (already present; --force to overwrite)")
                continue
            shutil.rmtree(target)
        shutil.copytree(child, target, symlinks=True)
        exported.append(child.name)

    print(f"Exported {len(exported)} task(s) to {dest}")
    for name in exported:
        print(f"  {name}")

    skipped = len(ok_tasks) - len(exported)
    if skipped > 0:
        print(f"  ({skipped} already present)")

    print()
    print("Remaining manual steps:")
    print(f"  1. Provide a container template for the group, e.g.")
    print(f"       containers/task_groups/{cfg.group_id}.Dockerfile.jinja2")
    print(f"     It must supply the same toolchain the verifiers call.")
    print(f"  2. Run:  abc-runner run {cfg.group_id}")
    return 0

cmd_prompts

cmd_prompts(args: Namespace) -> int

Inspect, scaffold, and render prompt customization.

Source code in abc_mine/cli.py
def cmd_prompts(args: argparse.Namespace) -> int:
    """Inspect, scaffold, and render prompt customization."""
    action = args.prompts_action

    if action == "slots":
        print("Prompt slots — optional per-codebase context.\n")
        print("Each is a markdown file under <pack>/slots/. Every one is optional:")
        print("an absent or empty file omits its section entirely.\n")
        for slot in prompts_mod.SLOTS:
            stages = ", ".join(sorted({t.split("_")[0] for t in slot.templates}))
            print(f"  {slot.key}")
            print(f"    used by:  {stages}")
            print(f"    heading:  {slot.heading.lstrip('# ')}")
            print(f"    purpose:  {slot.purpose}")
            print()
        print("Scaffold a pack:  abc-mine prompts scaffold <dir>")
        return 0

    if action == "scaffold":
        created = prompts_mod.scaffold(args.dest, with_overrides=args.with_overrides)
        dest = Path(args.dest)
        print(f"Scaffolded a prompt pack at {dest}")
        for path in created:
            print(f"  {path.relative_to(dest)}")
        print()
        print("Fill in the slots you need and delete the rest. Then point your")
        print("config at it:")
        print()
        print("    prompts:")
        print(f"      pack: {dest}")
        if args.with_overrides:
            print()
            print("An overrides/ directory was also created. Overrides REPLACE a")
            print("shipped template rather than adding to it, and require")
            print("prompts.allow_template_overrides: true. Prefer slots unless you")
            print("specifically need to rewrite a base template — see")
            print(f"{dest / 'overrides' / 'README.md'}.")
        return 0

    if action == "show":
        name = args.template
        if name not in prompts_mod.TEMPLATE_NAMES:
            raise CliError(
                f"unknown template {name!r}. Available: "
                + ", ".join(prompts_mod.TEMPLATE_NAMES)
            )
        sys.stdout.write(prompts_mod.load_template(name))
        return 0

    if action == "render":
        return _render_prompt(args)

    raise CliError(f"unknown prompts action: {action!r}")

build_parser

build_parser() -> ArgumentParser

Build the top-level argument parser.

Source code in abc_mine/cli.py
def build_parser() -> argparse.ArgumentParser:
    """Build the top-level argument parser."""
    parser = argparse.ArgumentParser(
        prog="abc-mine",
        description=(
            "Mine a git codebase for agentic-coding benchmarks and emit "
            "ABC Runner tasks, in three stages: screen, rank, build."
        ),
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog=(
            "Typical run:\n"
            "  abc-mine init      --config mine.yaml\n"
            "  abc-mine preflight --config mine.yaml --write-config\n"
            "  abc-mine screen    --config mine.yaml --parallel local --workers 8\n"
            "  abc-mine rank      --config mine.yaml\n"
            "  abc-mine build     --config mine.yaml --parallel local --workers 4\n"
            "  abc-mine export    --config mine.yaml --dest ../abc-runner\n"
            "\n"
            "The model is configured entirely by environment variables:\n"
            "  LLM_BASE_URL  LLM_MODEL  LLM_API  LLM_API_KEY\n"
            "Optional pricing (USD per 1M tokens; all four or none):\n"
            "  LLM_PRICE_INPUT_PER_1M  LLM_PRICE_CACHE_READ_PER_1M\n"
            "  LLM_PRICE_CACHE_WRITE_PER_1M  LLM_PRICE_OUTPUT_PER_1M\n"
        ),
    )
    parser.add_argument("--version", action="version", version=f"abc-mine {__version__}")
    subparsers = parser.add_subparsers(dest="command", metavar="<command>")

    p_init = subparsers.add_parser(
        "init", help="Create a run and lock its configuration."
    )
    _add_config(p_init)
    p_init.add_argument("--notes", help="Free-text note recorded in the manifest.")
    p_init.add_argument(
        "--allow-missing-model", action="store_true",
        help="Initialize without model credentials (e.g. on a submission host).",
    )
    p_init.add_argument(
        "--reinit", action="store_true",
        help="Re-lock an already-initialized run to the current settings. Existing "
             "outputs are left untouched and the previous manifest is kept as "
             "run.json.superseded. Use this to recover a run whose manifest was "
             "lost, or to deliberately adopt changed settings mid-run.",
    )
    p_init.set_defaults(func=cmd_init)

    p_pre = subparsers.add_parser(
        "preflight",
        help="Prove the container can build and test the codebase, and measure cost.",
    )
    _add_config(p_pre)
    p_pre.add_argument("--dry-run", action="store_true",
                       help="Print the container commands without running them.")
    p_pre.add_argument("--full-test", action="store_true",
                       help="Also time the full test suite (can be very slow).")
    p_pre.add_argument("--write-config", action="store_true",
                       help="Write measured timings back into the config file.")
    p_pre.set_defaults(func=cmd_preflight)

    p_screen = subparsers.add_parser(
        "screen", help="Score every selected commit against the rubric (parallel)."
    )
    _add_config(p_screen)
    _add_execution(p_screen)
    p_screen.add_argument("--only", nargs="+", default=(), metavar="SHA",
                          help="Screen only these commits (prefix match).")
    p_screen.add_argument("--plan", action="store_true",
                          help="Show what would be screened, then exit.")
    p_screen.set_defaults(func=cmd_screen)

    p_rank = subparsers.add_parser(
        "rank", help="Collapse viable summaries into a ranked shortlist (one agent)."
    )
    _add_config(p_rank)
    _add_execution(p_rank)
    p_rank.add_argument("--plan", action="store_true",
                        help="Show the candidate payload and token estimate, then exit.")
    p_rank.add_argument("--force", action="store_true",
                        help="Discard an existing shortlist (and any recorded "
                             "interleaving groups) and rank again.")
    p_rank.add_argument("--method", dest="rank_method",
                        choices=config_mod.RANK_METHODS,
                        help="Override rank.method.")
    p_rank.set_defaults(func=cmd_rank)

    p_build = subparsers.add_parser(
        "build", help="Turn each shortlisted commit into a abc-runner task (parallel)."
    )
    _add_config(p_build)
    _add_execution(p_build)
    p_build.add_argument("--only", nargs="+", default=(), metavar="SHA",
                         help="Build only these commits (prefix match).")
    p_build.add_argument("--plan", action="store_true",
                         help="Show what would be built, then exit.")
    p_build.add_argument("--force", action="store_true",
                         help="Rebuild tasks already recorded as complete.")
    p_build.add_argument("--limit", type=int, metavar="N",
                         help="Start at most N commits in this invocation, from the "
                              "top of the remaining rank order. A per-job stopping "
                              "point, not a run setting: rerun to continue down the "
                              "order.")
    p_build.set_defaults(func=cmd_build)

    p_status = subparsers.add_parser("status", help="Report where a run stands.")
    _add_config(p_status)
    p_status.add_argument("-v", "--verbose", action="store_true",
                          help="Also show the stage invocation history.")
    p_status.set_defaults(func=cmd_status)

    p_usage = subparsers.add_parser(
        "usage", help="Report model usage, spend, and wall time per stage."
    )
    _add_config(p_usage)
    p_usage.add_argument("--json", action="store_true", help="Print JSON.")
    p_usage.add_argument("--reprice", action="store_true",
                         help="Recompute costs from the current LLM_PRICE_* "
                              "variables instead of showing the recorded cost.")
    p_usage.add_argument("--top", type=int, default=5, metavar="N",
                         help="Tools to list per stage (default: 5).")
    p_usage.set_defaults(func=cmd_usage)

    p_export = subparsers.add_parser(
        "export", help="Copy successfully-built tasks into a abc-runner checkout."
    )
    _add_config(p_export)
    p_export.add_argument("--dest", required=True,
                          help="Destination: a abc-runner checkout, or any directory.")
    p_export.add_argument(
        "--abc-runner-root", action="store_true", default=True,
        help="Treat --dest as a abc-runner checkout and write to "
             "<dest>/tasks/<group>/ (default).",
    )
    p_export.add_argument(
        "--raw", dest="abc_runner_root", action="store_false",
        help="Treat --dest as a literal destination directory.",
    )
    p_export.add_argument("--force", action="store_true",
                          help="Overwrite tasks already present at the destination.")
    p_export.set_defaults(func=cmd_export)

    p_prompts = subparsers.add_parser(
        "prompts", help="Inspect, scaffold, and render prompt customization."
    )
    prompt_subs = p_prompts.add_subparsers(dest="prompts_action", metavar="<action>")

    p_slots = prompt_subs.add_parser("slots", help="List the available prompt slots.")
    p_slots.set_defaults(func=cmd_prompts)

    p_scaffold = prompt_subs.add_parser(
        "scaffold", help="Create an empty, commented prompt pack."
    )
    p_scaffold.add_argument("dest", help="Directory to create.")
    p_scaffold.add_argument(
        "--with-overrides", action="store_true",
        help="Also create overrides/ for full template replacement (advanced).",
    )
    p_scaffold.set_defaults(func=cmd_prompts)

    p_show = prompt_subs.add_parser(
        "show", help="Print a shipped base template (a good override starting point)."
    )
    p_show.add_argument("template", choices=prompts_mod.TEMPLATE_NAMES)
    p_show.set_defaults(func=cmd_prompts)

    p_render = prompt_subs.add_parser(
        "render",
        help="Render a fully-composed prompt exactly as an agent would receive it.",
    )
    _add_config(p_render)
    p_render.add_argument("stage", choices=("screen", "rank", "build"))
    p_render.add_argument("-o", "--output", help="Write to a file instead of stdout.")
    p_render.set_defaults(func=cmd_prompts)

    p_prompts.set_defaults(func=cmd_prompts, prompts_action="slots")
    return parser

main

main(argv: Sequence[str] | None = None) -> int

CLI entry point.

Source code in abc_mine/cli.py
def main(argv: Sequence[str] | None = None) -> int:
    """CLI entry point."""
    parser = build_parser()
    args = parser.parse_args(argv)

    if not getattr(args, "command", None):
        parser.print_help()
        return 1
    if args.command == "prompts" and not getattr(args, "prompts_action", None):
        args.prompts_action = "slots"

    try:
        return int(args.func(args) or 0)
    except CliError as exc:
        _report_error(str(exc))
        return 1
    except KeyboardInterrupt:
        if _launcher_rank() == 0:
            print("\ninterrupted", file=sys.stderr)
        return 130
    except (ConfigError, PromptError, ManifestError, repo_mod.GitError) as exc:
        _report_error(str(exc))
        return 1