Official Codebase of 3DCodeVerse
Python
flywheel: standalone c3d-flywheel package with its own CLI
gaoypenga843db834b2c
diff --git a/flywheel/README.md b/flywheel/README.mdnew file mode 100644index 00000000..699801c9--- /dev/null+++ b/flywheel/README.md@@ -0,0 +1,42 @@+# c3d-flywheel++The legacy reader of **3dcodeverse v0.0.x runs**. Those releases ran a harness-side pipeline+(plan → vendor coding agent → build → gates → render → VLM judge → refine) and recorded every+run as a directory: `spec.json`, `record.json`, `src/` (a git repo, one commit per round),+`artifacts/`, `telemetry/cost.jsonl`, `events.jsonl`, optionally `deliverable/`. The plugin+(v0.1+) writes none of that; this package reads what exists and turns it into a dataset, a+gallery, a cost audit or a hand-over folder. It makes no model calls and needs no API key:+captioning, re-judging and judge calibration stayed in the v0.0.x releases.++Every record is read leniently (`c3d_flywheel.legacy`): fields later versions dropped+(`budget`, `backends`, the settings snapshot) are kept as data, the plan as a dict.++## Install++```+pip install -e harness # the plugin package: contracts, conventions, workspace, proc+pip install -e flywheel # this package; `pip install -e 'flywheel[parquet]'` for metadata.parquet / --pack+```++## Commands++A run is named by its directory, or by its slug under `--runs-dir` (default `./runs`).++```+c3d-flywheel show <run> [--section all|status|deliverable|evidence|cost] [--events N] [--runs-dir DIR]+c3d-flywheel status <run> [--events N] [--runs-dir DIR] # = show --section status (works without record.json)+c3d-flywheel pick <run> [--round N] [--runs-dir DIR] # choose a round (best judged, or N) → deliverable/ + selection.json+c3d-flywheel cost <run|root>... [--md FILE] [--recheck] [--limit N] [--per-run/--no-per-run] [--runs-dir DIR]+c3d-flywheel cost --runs-dir <root> [--recheck] [--md FILE] # a whole battery+c3d-flywheel cost prices [--provider P] [--stale] [--unverified] [--days N]+c3d-flywheel gallery serve [ROOTS...] [--port N] [--host H] [--open/--no-open] [--reload] [--title T] [--runtime-js DIR]+c3d-flywheel gallery build [ROOTS...] [--out gallery.html] [--embed] [--title T] [--thumb-px N]+c3d-flywheel export <runs_root> <out_dir> [--min-score X] [--only-passed] [--include-unbuilt] [--captions-dir DIR] [--drop-duplicates] [--pack] [--tar-prefix P]+c3d-flywheel pairs <runs_root> <out.jsonl> [--min-delta X]+c3d-flywheel refine <runs_root> <out.jsonl> [--with-code]+```++A root is any tree of run directories (`runs/`, `eval/bench/out/<battery>/...`); nested battery+layouts (`cells/<prompt>/<arm>/run`) are found and named by their meaningful path segments.+`gallery serve` binds to loopback unless a host is typed; the GLB viewer uses the three.js+vendored in the plugin's `runtime_js/node_modules` when it is installed (no CDN).diff --git a/flywheel/c3d_flywheel/__init__.py b/flywheel/c3d_flywheel/__init__.pyindex a1451a6b..e2ebe081 100644--- a/flywheel/c3d_flywheel/__init__.py+++ b/flywheel/c3d_flywheel/__init__.py@@ -1 +1,3 @@-"""Optional tools that READ finished runs — nothing a run needs in order to happen."""+"""c3d-flywheel: the legacy reader of 3dcodeverse v0.0.x runs — records, cost, gallery, dataset, pick."""++__version__ = "0.1.0"diff --git a/flywheel/c3d_flywheel/cli/__init__.py b/flywheel/c3d_flywheel/cli/__init__.pynew file mode 100644index 00000000..db2ac5ff--- /dev/null+++ b/flywheel/c3d_flywheel/cli/__init__.py@@ -0,0 +1 @@+"""The ``c3d-flywheel`` command line (``main.app``)."""diff --git a/flywheel/c3d_flywheel/cli/_common.py b/flywheel/c3d_flywheel/cli/_common.pynew file mode 100644index 00000000..f49690f4--- /dev/null+++ b/flywheel/c3d_flywheel/cli/_common.py@@ -0,0 +1,125 @@+"""Shared CLI plumbing: Rich formatting, errors, and opening a recorded run by slug or path."""++from __future__ import annotations++from pathlib import Path+from typing import Annotated, Any++import typer+from codeverse3d.workspace import Workspace+from rich.console import Console+from rich.panel import Panel+from rich.table import Table++from c3d_flywheel.legacy import LegacySpec, RunRecord++console = Console(emoji=False)+err_console = Console(stderr=True, style="bold red", emoji=False)++#: where a bare slug is looked up when no ``--runs-dir`` is given+DEFAULT_RUNS_DIR = Path("runs")++RunsDirOpt = Annotated[Path | None, typer.Option("--runs-dir", help=f"runs root a bare slug is resolved against (default: {DEFAULT_RUNS_DIR})")]+++def err(msg: str) -> None:+ err_console.print(f"error: {msg}")+++def ok(msg: str) -> None:+ console.print(f"[green]{msg}[/green]")+++def warn(msg: str) -> None:+ console.print(f"[yellow]{msg}[/yellow]")+++def fmt_score(s: float | None) -> str:+ return "-" if s is None else f"{s:.3f}"+++def fmt_usd(v: float) -> str:+ return f"${v:.4f}"+++class CliError(typer.Exit):++ def __init__(self, message: str, code: int = 1):+ err(message)+ super().__init__(code=code)+++def runs_root(runs_dir: Path | None) -> Path:+ return Path(runs_dir) if runs_dir is not None else DEFAULT_RUNS_DIR+++def open_workspace(slug: str, runs_dir: Path | None = None) -> Workspace:+ """A run named by its directory, or by its slug under the runs root."""+ p = Path(slug)+ if p.is_dir() and (p / "spec.json").is_file():+ return Workspace(p)+ ws = Workspace(runs_root(runs_dir) / slug)+ if not ws.exists():+ raise CliError(f"run not found: {ws.root} (no spec.json)")+ return ws+++def load_spec(ws: Workspace) -> LegacySpec:+ try:+ return LegacySpec.model_validate_json(ws.spec_path.read_text())+ except Exception as e:+ raise CliError(f"invalid spec.json in {ws.root}: {e}") from e+++def kv_table(title: str, rows: dict[str, Any]) -> Table:+ t = Table(title=title, show_header=False)+ t.add_column("key", style="bold")+ t.add_column("value")+ for k, v in rows.items():+ t.add_row(str(k), str(v))+ return t+++def rounds_table(rows: list[Any], picked: int | None) -> Table:+ """``select.RoundRow`` rows; ``*`` marks the picked round."""+ t = Table(title="rounds (* = picked)", show_lines=False)+ for col in ("#", "kind", "build", "gate err", "score", "passed", "cost", "min", "commit"):+ t.add_column(col, justify="right" if col in ("#", "gate err", "score", "cost", "min") else "left")+ for r in rows:+ build = "-" if r.build_ok is None else ("ok" if r.build_ok else "[red]FAIL[/red]")+ passed = "-" if r.passed is None else ("[green]yes[/green]" if r.passed else "no")+ t.add_row(f"{r.index}{'*' if r.index == picked else ''}", r.kind, build, str(r.gate_errors), fmt_score(r.score),+ passed, fmt_usd(r.cost_usd), f"{r.minutes:.1f}", r.commit[:8])+ return t+++def print_record_summary(record: RunRecord, ws_root: Path | None = None) -> None:+ from c3d_flywheel import select++ spec = record.spec+ root = Path(ws_root or record.workspace)+ s = select.summarise(root, record=record)+ status_col = {"failed": "red", "budget": "yellow", "agent_quota": "yellow"}.get(record.status.value, "cyan")+ lines = [+ f"[bold]{spec.prompt}[/bold]",+ f"track={spec.track.value} language={spec.language.value} generator={spec.backends.generator} "+ f"judge={spec.backends.judge}",+ f"stop=[{status_col}]{s.stop_reason}[/{status_col}] baseline={fmt_score(s.baseline_score)} "+ f"picked={fmt_score(s.picked_score)} (round {s.round}, "+ f"{f'by {s.method}' if s.picked_round is not None else 'nothing judged: the latest built round with renders'}) rounds={s.rounds} "+ f"cost={fmt_usd(record.total_usage.cost_usd)}",+ ]+ if record.error:+ lines.append(f"[red]error: {record.error}[/red]")+ if ws_root is not None:+ ws = Workspace(ws_root)+ lines.append(f"workspace: {ws_root}")+ picked = next((r for r in record.rounds if r.index == s.round), None)+ if picked is not None and picked.renders is not None and picked.renders.contact_sheet:+ # record.json stores absolute paths of the producing host; rebase onto this root+ lines.append(f"sheet: {ws.rebase(picked.renders.contact_sheet)}")+ if ws.deliverable_manifest_path.is_file():+ lines.append(f"deliverable: {ws.deliverable}")+ console.print(Panel("\n".join(lines), title="run", expand=False))+ if record.rounds:+ console.print(rounds_table(select.round_rows(root, record=record), s.round))diff --git a/flywheel/c3d_flywheel/cli/cost_cmd.py b/flywheel/c3d_flywheel/cli/cost_cmd.pyindex 5b684da6..e94215ae 100644--- a/flywheel/c3d_flywheel/cli/cost_cmd.py+++ b/flywheel/c3d_flywheel/cli/cost_cmd.py@@ -1,12 +1,12 @@-"""``3dcodeverse cost`` — what the runs cost and where the money went, from each run's+"""``c3d-flywheel cost`` — what the runs cost and where the money went, from each run's``telemetry/cost.jsonl`` ledger.- 3dcodeverse cost <slug> # one run, from its own ledger- 3dcodeverse cost --runs-dir eval/bench/out/x # a whole battery, aggregated- 3dcodeverse cost runs/ eval/bench/out/* # any mix of run dirs / trees- 3dcodeverse cost show runs/ --md report.md # the same, explicit + full markdown- 3dcodeverse cost runs/ --recheck # re-price with today's table (drift vs what was billed)- 3dcodeverse cost prices [--stale] [--unverified]+ c3d-flywheel cost <slug> # one run, from its own ledger+ c3d-flywheel cost --runs-dir eval/bench/out/x # a whole battery, aggregated+ c3d-flywheel cost runs/ eval/bench/out/* # any mix of run dirs / trees+ c3d-flywheel cost show runs/ --md report.md # the same, explicit + full markdown+ c3d-flywheel cost runs/ --recheck # re-price with today's table (drift vs what was billed)+ c3d-flywheel cost prices [--stale] [--unverified]"""from __future__ import annotations@@ -19,7 +19,7 @@ import clickimport typerfrom typer.core import TyperGroup-from codeverse3d.cli._common import console, ok, runs_root, warn+from c3d_flywheel.cli._common import console, ok, runs_root, warn#: a price row older than this needs re-checking against the provider's pageSTALE_AFTER_DAYS = 90@@ -106,7 +106,7 @@ def prices(days: Annotated[int, typer.Option("--days", help="staleness threshold in days")] = STALE_AFTER_DAYS,) -> None:"""The USD price table with its provenance; flags stale, approximate or unverified rows."""- from c3d_flywheel.models.pricing import PRICES, price_provenance+ from c3d_flywheel.cost.pricing import PRICES, price_provenancerows, flagged = [], 0for (prov, model) in sorted(PRICES):diff --git a/flywheel/c3d_flywheel/cli/flywheel_cmd.py b/flywheel/c3d_flywheel/cli/flywheel_cmd.pyindex 2115f460..b6fabbf8 100644--- a/flywheel/c3d_flywheel/cli/flywheel_cmd.py+++ b/flywheel/c3d_flywheel/cli/flywheel_cmd.py@@ -1,23 +1,18 @@-"""``3dcodeverse flywheel export | pairs | refine | caption``."""+"""``c3d-flywheel export | pairs | refine``: recorded runs → dataset rows."""from __future__ import annotations-from contextlib import nullcontextfrom pathlib import Pathfrom typing import Annotatedimport typerfrom rich.markup import escape+from c3d_flywheel.cli import _common as C+from c3d_flywheel.cli._common import console, kv_table, ok, warnfrom c3d_flywheel.dataset.pairs import MIN_PREFERENCE_DELTA, build_pairs-from codeverse3d.cli import _common as C-from codeverse3d.cli._common import console, kv_table, ok, warn-from codeverse3d.config import get_settings-flywheel_app = typer.Typer(no_args_is_help=True)--@flywheel_app.command("export")def export_cmd(runs_dir: Annotated[Path, typer.Argument(help="runs root")],out_dir: Annotated[Path, typer.Argument(help="dataset folder")],@@ -26,7 +21,7 @@ def export_cmd(pack: Annotated[bool, typer.Option("--pack", help="also pack samples-NNN.tar + byte-range locators")] = False,tar_prefix: Annotated[str, typer.Option("--tar-prefix", help="repo-root-relative prefix for the tar column")] = "",include_unbuilt: Annotated[bool, typer.Option("--include-unbuilt", help="also export runs whose exported round never built")] = False,- captions_dir: Annotated[Path | None, typer.Option("--captions-dir", help="side-car captions written by `caption --out`")] = None,+ captions_dir: Annotated[Path | None, typer.Option("--captions-dir", help="side-car captions (<dir>/<slug>.json) written by the v0.0.x captioner")] = None,drop_duplicates: Annotated[bool, typer.Option("--drop-duplicates", help="leave byte-identical duplicates (raw code sha256 + prompt) out of the index, manifest and tars (recorded under the manifest's dropped); normalised ones are only marked near_duplicate_of")] = False,) -> None:"""Export runs → sample folders + dataset_manifest.json + metadata.jsonl/.parquet (+ tars)."""@@ -37,9 +32,8 @@ def export_cmd(try:import pyarrow # noqa: F401except ImportError:- # escaped: rich reads "[flywheel]" as markup- raise C.CliError(escape("--pack needs the flywheel extra: "- "pip install -e 'harness[flywheel]'")) from None+ # escaped: rich reads "[parquet]" as markup+ raise C.CliError(escape("--pack needs the parquet extra: pip install 'c3d-flywheel[parquet]'")) from Nonerep = export_samples(runs_dir, out_dir, min_score=min_score, only_passed=only_passed, include_unbuilt=include_unbuilt,captions_dir=captions_dir, drop_duplicates=drop_duplicates)@@ -63,7 +57,6 @@ def export_cmd(ok(f"packed {prep.n_samples} samples into {prep.tars}; verified {n} locators")-@flywheel_app.command("pairs")def pairs_cmd(runs_dir: Annotated[Path, typer.Argument()],out_jsonl: Annotated[Path, typer.Argument()],@@ -74,7 +67,6 @@ def pairs_cmd(ok(f"{n} pairs → {out_jsonl}")-@flywheel_app.command("refine")def refine_cmd(runs_dir: Annotated[Path, typer.Argument()],out_jsonl: Annotated[Path, typer.Argument()],@@ -86,48 +78,3 @@ def refine_cmd(n, drops = build_refine(runs_dir, out_jsonl, with_code=with_code)ok(f"{n} transitions → {out_jsonl}" + (f"; not exported: {dict(drops)}" if drops else ""))---@flywheel_app.command("caption")-def caption_cmd(- target: Annotated[str, typer.Argument(help="run slug/dir, or a runs root with --all")],- model: Annotated[str | None, typer.Option("--model", help="default: Settings.default_captioner")] = None,- all_runs: Annotated[bool, typer.Option("--all", help="caption every un-captioned run under target")] = False,- force: Annotated[bool, typer.Option("--force", help="re-caption even if captions exist")] = False,- runs_dir: Annotated[Path | None, typer.Option("--runs-dir")] = None,- out: Annotated[Path | None, typer.Option("--out", help="write side-car <out>/<slug>.json instead of touching the run (read-only runs)")] = None,-) -> None:- """Caption run(s): {detailed, instruction, factory} via a chat model."""- from c3d_flywheel.dataset.captions import CaptionError, caption_sample- from c3d_flywheel.dataset.export import load_captions- from c3d_flywheel.cost.instrument import run_ledger- from codeverse3d.proc import RunLocked, exclusive- from c3d_flywheel.record.record import iter_runs, load_record-- model = model or get_settings().default_captioner- if all_runs:- targets = [(fr.ws, fr.record, fr.run_id.slug)- for fr in iter_runs(target, on_error=lambda d, e: warn(f"skip {d.name}: {e}"))]- else:- ws = C.open_workspace(target, runs_dir)- targets = [(ws, load_record(ws), None)] # no scan root → basename identity- done = skipped = failed = 0- for ws, rec, slug in targets:- if not force and load_captions(ws, rec, out, slug=slug).get("detailed"):- skipped += 1- continue- # per run: captioning rewrites record.json (--out writes a side-car instead); a locked- # run is skipped so one live run does not abort an --all batch- lock = nullcontext() if out else exclusive(ws.root, what=f"3dcodeverse flywheel caption {ws.root.name}")- try:- with lock, run_ledger(ws.root, run=ws.root.name, create=False):- caps = caption_sample(ws, rec, model, out_dir=out, slug=slug)- except (CaptionError, RunLocked) as e:- failed += 1- warn(str(e))- continue- done += 1- console.print(f"[bold]{slug or ws.root.name}[/bold]: {caps.instruction}")- ok(f"captioned {done}, skipped {skipped} (already), failed {failed}")- if failed and not done:- raise typer.Exit(code=1)diff --git a/flywheel/c3d_flywheel/cli/layout_cmd.py b/flywheel/c3d_flywheel/cli/layout_cmd.pyindex 1b323cf1..2d69e1d2 100644--- a/flywheel/c3d_flywheel/cli/layout_cmd.py+++ b/flywheel/c3d_flywheel/cli/layout_cmd.py@@ -1,5 +1,5 @@-"""``3dcodeverse show`` — the single-run view: STATUS (works mid-run, without record.json;-``3dcodeverse status`` is ``show --section status``), DELIVERABLE, QUALITY EVIDENCE and+"""``c3d-flywheel show`` — the single-run view: STATUS (works without record.json;+``c3d-flywheel status`` is ``show --section status``), DELIVERABLE, QUALITY EVIDENCE andCOST & SETTINGS."""from __future__ import annotations@@ -8,10 +8,11 @@ import jsonfrom typing import Annotated, Anyimport typer+from codeverse3d.workspace import Workspacefrom rich.table import Table-from codeverse3d.cli import _common as C-from codeverse3d.cli._common import (+from c3d_flywheel.cli import _common as C+from c3d_flywheel.cli._common import (RunsDirOpt,console,fmt_score,@@ -20,14 +21,13 @@ from codeverse3d.cli._common import (print_record_summary,warn,)-from codeverse3d.contracts.run import (+from c3d_flywheel.legacy import (CostSummary,DeliverableFile,RunDeliverable,RunRecord,SettingsSnapshot,)-from codeverse3d.workspace import Workspacedef _human_bytes(n: int) -> str:@@ -45,26 +45,21 @@ def _section(title: str) -> None:# --------------------------------------------------------------------------- statusdef print_status(ws: Workspace, record: RunRecord | None, n_events: int) -> None:- from codeverse3d.proc import EventLog, holder_of, read_json_or_none+ from codeverse3d.proc import read_json_or_none, read_jsonl_lenient_section("STATUS — where the run stands")if record is not None:print_record_summary(record, ws.root)else:spec = C.load_spec(ws)- console.print(kv_table("run (no record.json yet)", {+ console.print(kv_table("run (no record.json)", {"prompt": spec.prompt, "track": spec.track.value, "language": spec.language.value,"generator": spec.backends.generator, "judge": spec.backends.judge, "workspace": ws.root}))- state: dict[str, Any] = {}- if (held := holder_of(ws.root)) is not None:- state["RUNNING NOW"] = f"pid {held.get('pid', '?')} ({held.get('what') or '3dcodeverse'})"if ws.state_path.is_file():raw = read_json_or_none(ws.state_path)- state["run_state"] = "(unreadable)" if raw is None else ", ".join(- f"{k}={v}" for k, v in raw.items() if not isinstance(v, (dict, list)))[:300]- if state:- console.print(kv_table("state", state))- evs = EventLog(ws.events_path).read()+ console.print(kv_table("state", {"run_state": "(unreadable)" if raw is None else ", ".join(+ f"{k}={v}" for k, v in raw.items() if not isinstance(v, (dict, list)))[:300]}))+ evs = read_jsonl_lenient(ws.events_path, dicts_only=True) if ws.events_path.is_file() else []if evs:console.print(f"[dim]last {min(n_events, len(evs))} of {len(evs)} events:[/dim]")for ev in evs[-n_events:]:@@ -129,7 +124,7 @@ def print_deliverable(ws: Workspace, record: RunRecord) -> None:if d is not None:console.print(_deliverable_table(d))else:- console.print(kv_table("artifacts (no deliverable/ yet — `3dcodeverse pick` packages a round)",+ console.print(kv_table("artifacts (no deliverable/ yet — `c3d-flywheel pick` packages a round)",_unpackaged_artifact_rows(ws)))@@ -252,7 +247,7 @@ def show(record: RunRecord | None = load_record(ws)except RecordError as e:if section not in ("all", "status"):- raise C.CliError(f"{e} (`3dcodeverse status {slug}` shows where the run stands)") from e+ raise C.CliError(f"{e} (`c3d-flywheel status {slug}` shows where the run stands)") from erecord, missing = None, str(e)if section in ("all", "status"):print_status(ws, record, events)@@ -269,5 +264,5 @@ def show(def status(slug: str, runs_dir: RunsDirOpt = None, events: EventsOpt = 8) -> None:- """Where a run stands, mid-run too: `3dcodeverse show <slug> --section status`."""+ """Where a run stands: `c3d-flywheel show <slug> --section status`."""show(slug, runs_dir, section="status", events=events)diff --git a/flywheel/c3d_flywheel/cli/main.py b/flywheel/c3d_flywheel/cli/main.pynew file mode 100644index 00000000..9a0a3723--- /dev/null+++ b/flywheel/c3d_flywheel/cli/main.py@@ -0,0 +1,155 @@+"""``c3d-flywheel`` — the command line over recorded v0.0.x runs: ``show`` / ``status`` / ``pick``,+``cost``, ``gallery serve|build``, ``export`` / ``pairs`` / ``refine``. Heavy modules import lazily+so ``--help`` stays fast."""++from __future__ import annotations++from pathlib import Path+from typing import Annotated++import typer++from c3d_flywheel import __version__+from c3d_flywheel.cli import _common as C+from c3d_flywheel.cli._common import RunsDirOpt, console, kv_table, ok, warn+from c3d_flywheel.cli.cost_cmd import cost_app+from c3d_flywheel.cli.flywheel_cmd import export_cmd, pairs_cmd, refine_cmd+from c3d_flywheel.cli.layout_cmd import show, status++# ===================================================================== gallery+gallery_app = typer.Typer(no_args_is_help=True)++RootsArg = Annotated[list[Path] | None, typer.Argument(+ help="run roots (default: ./runs and every ./eval/bench/out/*/runs that exists)")]+RuntimeJsOpt = Annotated[Path | None, typer.Option(+ "--runtime-js", help="the plugin's runtime_js/ (vendored three.js for the GLB viewer; default: next to the "+ "installed codeverse3d package)")]+++def resolve_roots(roots: list[Path] | None) -> list[Path]:+ """Explicit roots (validated) or the defaults; a clear error when there are none."""+ from c3d_flywheel.gallery.index import default_roots++ if roots:+ missing = [r for r in roots if not Path(r).is_dir()]+ if missing:+ raise C.CliError("not a directory: " + ", ".join(str(m) for m in missing))+ return [Path(r) for r in roots]+ found = default_roots(Path.cwd())+ if not found:+ raise C.CliError(f"no run roots found (looked for runs/ and eval/bench/out/*/runs under {Path.cwd()}); "+ f"pass one explicitly: `c3d-flywheel gallery serve path/to/runs`")+ return found+++@gallery_app.command("serve")+def serve_cmd(+ roots: RootsArg = None,+ port: Annotated[int, typer.Option("--port", min=0, max=65535, help="0 = pick a free port")] = 8765,+ host: Annotated[str | None, typer.Option("--host", help="default 127.0.0.1; any non-loopback address must be "+ "typed here explicitly")] = None,+ open_browser: Annotated[bool, typer.Option("--open/--no-open", help="open the page in a browser")] = True,+ reload: Annotated[bool, typer.Option("--reload", help="re-scan the roots on every page load "+ "(cheap: records only, images stay lazy)")] = False,+ title: Annotated[str, typer.Option("--title")] = "3dcodeverse gallery",+ runtime_js: RuntimeJsOpt = None,+) -> None:+ """Serve the gallery (and the run directories) on localhost."""+ from c3d_flywheel.gallery.server import GalleryError, serve++ root_paths = resolve_roots(roots)++ def announce(app, url: str) -> None:+ ix = app.index+ console.print(kv_table("gallery", {+ "url": url, "runs": len(ix.entries()), "roots": len(ix.sections),+ "index built in": f"{ix.build_ms} ms", "reload": reload,+ "sections": ", ".join(f"{s.label}({len(s.entries)})" for s in ix.sections)}))+ console.print("[dim]Ctrl-C to stop[/dim]")++ try:+ serve(root_paths, host=host, port=port, reload=reload, open_browser=open_browser, title=title,+ runtime_js=runtime_js, on_start=announce)+ except GalleryError as e:+ raise C.CliError(str(e)) from e+ ok("gallery stopped")+++@gallery_app.command("build")+def build_cmd(+ roots: RootsArg = None,+ out: Annotated[Path, typer.Option("--out", help="output .html")] = Path("gallery.html"),+ embed: Annotated[bool, typer.Option("--embed", help="inline the contact sheets as data: URIs so the page can "+ "be shared (much bigger; links still point here)")] = False,+ title: Annotated[str | None, typer.Option("--title")] = None,+ thumb_px: Annotated[int, typer.Option("--thumb-px", min=128, help="embedded thumbnail long edge")] = 720,+) -> None:+ """Write the gallery as one self-contained HTML file."""+ from c3d_flywheel.gallery.page import build_static++ path, n, index = build_static(resolve_roots(roots), out, title=title, embed=embed, thumb_px=thumb_px)+ broken = sum(1 for e in index.entries() if e.state != "ok")+ if broken:+ warn(f"{broken} run(s) have no usable record.json (shown as broken cards)")+ ok(f"gallery of {n} runs → {path} ({path.stat().st_size // 1024} KB)")+ if not embed:+ console.print("[dim]file:// links; `--embed` inlines the images, `c3d-flywheel gallery serve` makes them clickable[/dim]")+++# ===================================================================== pick+def pick(+ slug: str,+ round_index: Annotated[int | None, typer.Option("--round", min=0, help="hand over this round instead")] = None,+ runs_dir: RunsDirOpt = None,+) -> None:+ """Choose the round of a finished run to hand over and package it: deliverable/ + selection.json."""+ from c3d_flywheel import select+ from c3d_flywheel.record.record import RecordError++ ws = C.open_workspace(slug, runs_dir)+ try:+ idx = round_index if round_index is not None else select.pick(ws.root)+ if idx is None:+ warn("no round was judged, so none was picked: name one with `c3d-flywheel pick <slug> --round N`")+ raise typer.Exit(code=1)+ select.package(ws.root, idx, method="round" if round_index is not None else "score")+ rows = select.round_rows(ws.root)+ except RecordError as e:+ raise C.CliError(str(e), code=2) from e+ except ValueError as e:+ raise C.CliError(str(e), code=2) from e+ ok(f"picked round {idx} ({'named' if round_index is not None else 'by score'}) → {ws.deliverable}")+ console.print(C.rounds_table(rows, idx))+++# ===================================================================== the app+app = typer.Typer(+ name="c3d-flywheel",+ help="c3d-flywheel: read the runs 3dcodeverse v0.0.x recorded — show, pick, cost, gallery, dataset export.",+ pretty_exceptions_enable=False,+)+app.command()(show)+app.command()(status)+app.command()(pick)+app.add_typer(cost_app, name="cost", help="Cost audit: per stage/role/model, waste, $ per run.")+app.add_typer(gallery_app, name="gallery",+ help="Look at runs locally: `serve` on localhost, `build` one shareable HTML file.")+app.command("export")(export_cmd)+app.command("pairs")(pairs_cmd)+app.command("refine")(refine_cmd)++[email protected](invoke_without_command=True)+def _root(+ ctx: typer.Context, version: Annotated[bool, typer.Option("--version", is_eager=True)] = False+) -> None:+ if version:+ console.print(f"c3d-flywheel {__version__}")+ raise typer.Exit()+ if ctx.invoked_subcommand is None:+ console.print(ctx.get_help())+ raise typer.Exit()+++if __name__ == "__main__": # pragma: no cover+ app()diff --git a/flywheel/c3d_flywheel/costreport/__init__.py b/flywheel/c3d_flywheel/costreport/__init__.pyindex 654ccd05..81984d54 100644--- a/flywheel/c3d_flywheel/costreport/__init__.py+++ b/flywheel/c3d_flywheel/costreport/__init__.py@@ -1,4 +1,4 @@-"""The cost of finished runs, read back: ``3dcodeverse cost`` and its markdown report.+"""The cost of finished runs, read back: ``c3d-flywheel cost`` and its markdown report.* ``audit`` ``audit_runs(paths)`` → ``Audit`` (every run's ledger under the paths, aggregated, + waste)* ``report`` ``console(audit)`` · ``markdown(audit)``diff --git a/flywheel/c3d_flywheel/costreport/audit.py b/flywheel/c3d_flywheel/costreport/audit.pyindex 6eb1afe2..5889acb3 100644--- a/flywheel/c3d_flywheel/costreport/audit.py+++ b/flywheel/c3d_flywheel/costreport/audit.py@@ -7,10 +7,11 @@ from dataclasses import dataclass, fieldfrom pathlib import Pathfrom codeverse3d.contracts.common import Usage-from codeverse3d.contracts.run import RunId+from codeverse3d.proc import read_json_or_none+from c3d_flywheel.cost.ledger import load_ledger, price_call, summarisefrom c3d_flywheel.cost.types import CallCost, Stage, Summary-from codeverse3d.proc import read_json_or_none+from c3d_flywheel.legacy import RunIdfrom c3d_flywheel.record.record import (RecordError,find_run_dirs,diff --git a/flywheel/c3d_flywheel/costreport/report.py b/flywheel/c3d_flywheel/costreport/report.pyindex 00899600..18f3b44b 100644--- a/flywheel/c3d_flywheel/costreport/report.py+++ b/flywheel/c3d_flywheel/costreport/report.py@@ -10,6 +10,7 @@ from __future__ import annotationsfrom collections.abc import Sequencefrom c3d_flywheel import select+from c3d_flywheel.cost.types import STAGE_ORDER, CostBucketfrom c3d_flywheel.costreport.audit import (Audit,RunLedger,@@ -18,7 +19,6 @@ from c3d_flywheel.costreport.audit import (stage_latency,uncached_if_no_cache,)-from c3d_flywheel.cost.types import STAGE_ORDER, CostBucketdef _usd(x: float) -> str:@@ -145,7 +145,7 @@ def markdown(audit: Audit, *, title: str = "Cost audit") -> str:def console(audit: Audit) -> str:- """Compact plain-text version for ``3dcodeverse cost``."""+ """Compact plain-text version for ``c3d-flywheel cost``."""lines = [line.replace("**", "") for line in summary_lines(audit)]lines += ["", "stage:"]for b in audit.summary.ranked("stage"):diff --git a/flywheel/c3d_flywheel/dataset/__init__.py b/flywheel/c3d_flywheel/dataset/__init__.pyindex b514d82b..566edddc 100644--- a/flywheel/c3d_flywheel/dataset/__init__.py+++ b/flywheel/c3d_flywheel/dataset/__init__.py@@ -1,10 +1,9 @@-"""Run records → a dataset: what ``3dcodeverse flywheel …`` does AFTER the runs exist.+"""Run records → a dataset: ``c3d-flywheel export | pairs | refine``.* ``export`` ``export_samples(runs_dir, out_dir, min_score=..)`` → ``ExportReport``* ``pack`` ``pack_samples(out_dir)`` (plain tars + byte-range locators, optional)* ``pairs`` ``build_pairs(runs_dir, out_jsonl, min_delta=..)`` → n* ``refine`` the refine-transition rows (``RefineTransition``)-* ``captions`` ``caption_sample(ws, record, model_id)`` → ``Captions``* ``sample`` one run → one dataset sample (the code files of its picked round)* ``quality`` ``quality_tier`` (A/B/C/D) · ``prompt_id`` · code fingerprints, duplicate groups"""diff --git a/flywheel/c3d_flywheel/dataset/export.py b/flywheel/c3d_flywheel/dataset/export.pyindex 0b80a3e8..8fd09360 100644--- a/flywheel/c3d_flywheel/dataset/export.py+++ b/flywheel/c3d_flywheel/dataset/export.py@@ -9,16 +9,16 @@ from datetime import UTC, datetimefrom pathlib import Pathfrom typing import Any, NamedTuple+from codeverse3d.contracts.common import ENTRY_FILE, Language+from codeverse3d.proc import read_json_or_none, sha256_file, write_json_atomic, write_text_atomic+from codeverse3d.workspace import Workspacefrom pydantic import BaseModel, Fieldfrom c3d_flywheel.dataset import sample as Sfrom c3d_flywheel.dataset.quality import DuplicateGroup, code_sha256, mark_duplicates-from codeverse3d.contracts.common import ENTRY_FILE, Language-from codeverse3d.contracts.run import RunId, RunRecord-from codeverse3d.proc import read_json_or_none, sha256_file, write_json_atomic, write_text_atomic+from c3d_flywheel.legacy import RunId, RunRecordfrom c3d_flywheel.record.git_history import CODE_ROOTSfrom c3d_flywheel.record.record import FoundRun, iter_runs-from codeverse3d.workspace import Workspacelog = logging.getLogger(__name__)@@ -370,7 +370,7 @@ def load_manifest(out_dir: Path | str) -> DatasetGenerationManifest:path = Path(out_dir) / MANIFEST_NAMEif not path.is_file():raise ManifestError(- f"{path} not found — run export first (3dcodeverse flywheel export writes it): "+ f"{path} not found — run export first (c3d-flywheel export writes it): "f"pack no longer rescans directories")try:return DatasetGenerationManifest.model_validate_json(path.read_text())diff --git a/flywheel/c3d_flywheel/dataset/pairs.py b/flywheel/c3d_flywheel/dataset/pairs.pyindex 82b76407..acf30d37 100644--- a/flywheel/c3d_flywheel/dataset/pairs.py+++ b/flywheel/c3d_flywheel/dataset/pairs.py@@ -7,13 +7,14 @@ from collections import defaultdictfrom pathlib import Pathfrom typing import Any+from codeverse3d.proc import read_jsonl_lenient+from codeverse3d.workspace import Workspace+from c3d_flywheel import selectfrom c3d_flywheel.dataset.quality import prompt_id-from codeverse3d.contracts.run import RoundRecord, RunRecord-from codeverse3d.proc import read_jsonl_lenient+from c3d_flywheel.legacy import RoundRecord, RunRecordfrom c3d_flywheel.record import git_historyfrom c3d_flywheel.record.record import effective_judgment, iter_runs, skip_unreadable-from codeverse3d.workspace import Workspace__all__ = ["build_pairs", "preference_pairs", "repair_pairs", "in_round_repair_pairs","cross_backend_pairs"]diff --git a/flywheel/c3d_flywheel/dataset/refine.py b/flywheel/c3d_flywheel/dataset/refine.pyindex 2c0079db..2e0bc0ec 100644--- a/flywheel/c3d_flywheel/dataset/refine.py+++ b/flywheel/c3d_flywheel/dataset/refine.py@@ -7,11 +7,12 @@ from collections.abc import Iteratorfrom pathlib import Pathfrom typing import Any+from codeverse3d.contracts.artifacts import Severity+from codeverse3d.workspace import Workspacefrom pydantic import BaseModel, Fieldfrom c3d_flywheel.dataset.pairs import MIN_PREFERENCE_DELTA-from codeverse3d.contracts.artifacts import Severity-from codeverse3d.contracts.run import RoundRecord, RunRecord+from c3d_flywheel.legacy import RoundRecord, RunRecordfrom c3d_flywheel.record.git_history import (GitReadError,changed_files_between,@@ -19,7 +20,6 @@ from c3d_flywheel.record.git_history import (read_tree_at,)from c3d_flywheel.record.record import effective_judgment, effective_score, iter_runs-from codeverse3d.workspace import WorkspaceREFINE_KINDS: tuple[str, ...] = ("refine", "rewrite", "detail")MAX_DIFF_BYTES = 200_000diff --git a/flywheel/c3d_flywheel/dataset/sample.py b/flywheel/c3d_flywheel/dataset/sample.pyindex aa1ffaff..54a5508d 100644--- a/flywheel/c3d_flywheel/dataset/sample.py+++ b/flywheel/c3d_flywheel/dataset/sample.py@@ -7,9 +7,16 @@ from datetime import datetimefrom pathlib import Pathfrom typing import Any+from codeverse3d.contracts.common import (+ ENTRY_FILE,+ LANGUAGE_LABEL,+ TRACK_INFO,+ Language,+ code_file,+)+from codeverse3d.workspace import Workspacefrom pydantic import BaseModel, Field-from codeverse3d import __version__from c3d_flywheel import selectfrom c3d_flywheel.dataset.quality import (QualityTier,@@ -17,18 +24,10 @@ from c3d_flywheel.dataset.quality import (prompt_id,quality_tier,)-from codeverse3d.contracts.common import (- ENTRY_FILE,- LANGUAGE_LABEL,- TRACK_INFO,- Language,- code_file,-)-from codeverse3d.contracts.run import RoundRecord, RunRecord+from c3d_flywheel.legacy import RoundRecord, RunRecordfrom c3d_flywheel.record import git_historyfrom c3d_flywheel.record.deliverable import load_deliverable, round_outputsfrom c3d_flywheel.record.record import effective_judgment, round_summary, stop_reason-from codeverse3d.workspace import WorkspaceMAX_GLB_BYTES = 20 * 1024 * 1024SOURCE_NAME = "3dcodeverse"@@ -65,7 +64,7 @@ class SampleMeta(BaseModel):source: str = SOURCE_NAMEsource_run: str = ""license: str = SAMPLE_LICENSE- harness_version: str = __version__+ harness_version: str = Field(default="", description="the codeverse3d version that produced the run (record.environment)")prompt: strconstraints: dict[str, Any] = Field(default_factory=dict)tags: list[str] = Field(default_factory=list)@@ -261,6 +260,7 @@ def build_meta(files=sorted(files),renders=sorted(renders),environment=dict(record.environment),+ harness_version=str(record.environment.get("codeverse3d", "")),source_run=str(ws.root),prompt=spec.prompt,constraints=spec.constraints.model_dump(mode="json", exclude_none=True),diff --git a/flywheel/c3d_flywheel/gallery/__init__.py b/flywheel/c3d_flywheel/gallery/__init__.pyindex 241576a0..2ca0f9cb 100644--- a/flywheel/c3d_flywheel/gallery/__init__.py+++ b/flywheel/c3d_flywheel/gallery/__init__.py@@ -1,4 +1,4 @@-"""The local run gallery: ``3dcodeverse gallery serve`` (localhost) and ``3dcodeverse gallery build`` (one file).+"""The local run gallery: ``c3d-flywheel gallery serve`` (localhost) and ``c3d-flywheel gallery build`` (one file).* ``index`` ``build_index(roots)`` · ``default_roots()`` — record.json → typed entries* ``model`` ``RunEntry`` / ``RootSection`` / ``GalleryIndex`` / ``summarize`` / ``match``,diff --git a/flywheel/c3d_flywheel/gallery/detail.py b/flywheel/c3d_flywheel/gallery/detail.pyindex 7898273b..c45d0f77 100644--- a/flywheel/c3d_flywheel/gallery/detail.py+++ b/flywheel/c3d_flywheel/gallery/detail.py@@ -5,16 +5,17 @@ from __future__ import annotationsfrom pathlib import Pathfrom urllib.parse import quote+from codeverse3d.contracts.common import ENTRY_FILE+from codeverse3d.workspace import Workspace+from c3d_flywheel.gallery.cards import fmt, gallery_figure, tier_tag, verdict_tagfrom c3d_flywheel.gallery.code import CODE_CSS, numbered, read_text, src_filesfrom c3d_flywheel.gallery.index import run_relfrom c3d_flywheel.gallery.model import RunEntryfrom c3d_flywheel.gallery.theme import esc, footer, page_shell, top_barfrom c3d_flywheel.gallery.urls import UrlMaker-from codeverse3d.contracts.common import ENTRY_FILE-from codeverse3d.contracts.run import RoundRecord, RunRecord+from c3d_flywheel.legacy import RoundRecord, RunRecordfrom c3d_flywheel.record.record import effective_judgment-from codeverse3d.workspace import WorkspaceDETAIL_CSS = CODE_CSS + """.hero{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.05fr);gap:var(--s-4);align-items:start}diff --git a/flywheel/c3d_flywheel/gallery/index.py b/flywheel/c3d_flywheel/gallery/index.pyindex 3fa1fdc9..0765a2e0 100644--- a/flywheel/c3d_flywheel/gallery/index.py+++ b/flywheel/c3d_flywheel/gallery/index.py@@ -5,6 +5,10 @@ from __future__ import annotationsimport timefrom pathlib import Path+from codeverse3d.conventions import views_by_preference+from codeverse3d.proc import read_json_or_none+from codeverse3d.workspace import Workspace+from c3d_flywheel import selectfrom c3d_flywheel.dataset.quality import quality_tierfrom c3d_flywheel.dataset.sample import gate_error_summary@@ -16,9 +20,7 @@ from c3d_flywheel.gallery.model import (RunLink,humanize_view,)-from codeverse3d.contracts.run import RunId, RunRecord-from codeverse3d.conventions import views_by_preference-from codeverse3d.proc import read_json_or_none+from c3d_flywheel.legacy import RunId, RunRecordfrom c3d_flywheel.record.deliverable import round_outputsfrom c3d_flywheel.record.record import (RecordError,@@ -28,7 +30,6 @@ from c3d_flywheel.record.record import (is_run_dir,load_record,)-from codeverse3d.workspace import WorkspaceDEFAULT_RUNS = "runs"DEFAULT_BENCH_GLOB = "eval/bench/out/*/runs"diff --git a/flywheel/c3d_flywheel/gallery/page.py b/flywheel/c3d_flywheel/gallery/page.pyindex 53fcc802..e032c6bd 100644--- a/flywheel/c3d_flywheel/gallery/page.py+++ b/flywheel/c3d_flywheel/gallery/page.py@@ -5,6 +5,8 @@ from __future__ import annotationsimport jsonfrom pathlib import Path+from codeverse3d.proc import write_text_atomic+from c3d_flywheel.gallery.cards import TABLE_HEAD, fmt, render_card, render_rowfrom c3d_flywheel.gallery.index import build_indexfrom c3d_flywheel.gallery.model import (@@ -19,7 +21,6 @@ from c3d_flywheel.gallery.model import ()from c3d_flywheel.gallery.theme import INDEX_CSS, INDEX_JS, esc, footer, page_shell, top_barfrom c3d_flywheel.gallery.urls import THUMB_PX, StaticUrls, UrlMaker-from codeverse3d.proc import write_text_atomic# --------------------------------------------------------------------------- summary@@ -160,7 +161,7 @@ def render_static(index: GalleryIndex, *, title: str = "3dcodeverse gallery", emextra_html: str = "") -> str:note = ("images are inlined; the links open the original run directories on this machine"if embed else "images and links point at the run directories with file:// — "- "use `3dcodeverse gallery serve` for a page that works anywhere")+ "use `c3d-flywheel gallery serve` for a page that works anywhere")return render_index(index, StaticUrls(embed=embed, thumb_px=thumb_px),title=title, sort=sort, view=view, note=note, extra_html=extra_html)diff --git a/flywheel/c3d_flywheel/gallery/server.py b/flywheel/c3d_flywheel/gallery/server.pyindex d7f912a2..7b662509 100644--- a/flywheel/c3d_flywheel/gallery/server.py+++ b/flywheel/c3d_flywheel/gallery/server.py@@ -1,4 +1,4 @@-"""The local gallery server: ``3dcodeverse gallery serve``."""+"""The local gallery server: ``c3d-flywheel gallery serve``."""from __future__ import annotations@@ -184,9 +184,10 @@ class GalleryApp:return Response(content_type=ctype, path=target, headers=headers)def _detail(self, entry: RunEntry) -> Response:- from c3d_flywheel.record.record import RecordError, load_recordfrom codeverse3d.workspace import Workspace+ from c3d_flywheel.record.record import RecordError, load_record+ws = Workspace(entry.path)try:rec = load_record(ws)@@ -290,9 +291,10 @@ def make_server(app: GalleryApp, host: str = DEFAULT_HOST, port: int = DEFAULT_Pdef serve(roots: list[Path] | list[str], *, host: str | None = None,port: int = DEFAULT_PORT, reload: bool = False, open_browser: bool = False,- title: str = "3dcodeverse gallery", on_start: Any = None) -> None:+ title: str = "3dcodeverse gallery", runtime_js: Path | str | None = None,+ on_start: Any = None) -> None:bind = host or DEFAULT_HOST- app = GalleryApp(roots, reload=reload, title=title)+ app = GalleryApp(roots, reload=reload, title=title, runtime_js=runtime_js)httpd = make_server(app, bind, port)url = f"http://{'127.0.0.1' if bind == '0.0.0.0' else bind}:{httpd.server_address[1]}/" # noqa: S104if on_start is not None:diff --git a/flywheel/c3d_flywheel/gallery/viewer.py b/flywheel/c3d_flywheel/gallery/viewer.pyindex 11ff12fa..68a670d8 100644--- a/flywheel/c3d_flywheel/gallery/viewer.py+++ b/flywheel/c3d_flywheel/gallery/viewer.py@@ -11,10 +11,11 @@ from __future__ import annotationsimport jsonfrom pathlib import Path+import codeverse3d+from c3d_flywheel.gallery.model import RunEntryfrom c3d_flywheel.gallery.theme import esc, footer, page_shell, top_barfrom c3d_flywheel.gallery.urls import PathError, UrlMaker, safe_join-from codeverse3d.config import get_settings#: URL prefix → path under node_modules/threeVENDOR_MAP = {"three/build/": "build/", "three/examples/jsm/": "examples/jsm/"}@@ -86,11 +87,14 @@ addEventListener('resize', () => {"""+def default_runtime_js() -> Path:+ """The plugin's ``runtime_js/`` as an editable install lays it out: next to the ``codeverse3d`` package."""+ return Path(codeverse3d.__file__).resolve().parent.parent / "runtime_js"++def three_root(runtime_js: Path | str | None = None) -> Path | None:"""``runtime_js/node_modules/three`` when the vendored copy is installed."""- if runtime_js is None:- runtime_js = get_settings().runtime_js_dir()- p = Path(runtime_js) / "node_modules" / "three"+ p = Path(runtime_js or default_runtime_js()) / "node_modules" / "three"return p if (p / "build" / "three.module.js").is_file() else Nonediff --git a/flywheel/c3d_flywheel/record/__init__.py b/flywheel/c3d_flywheel/record/__init__.pyindex 8a18324b..b30c6b93 100644--- a/flywheel/c3d_flywheel/record/__init__.py+++ b/flywheel/c3d_flywheel/record/__init__.py@@ -1,9 +1,9 @@-"""What every run WRITES so it can be read later: ``record.json`` and what travels with it.+"""What every v0.0.x run wrote so it can be read later: ``record.json`` and what travels with it.-* ``record`` ``finalize_record(ws, record)`` · ``load_record(ws)`` · ``iter_runs(runs_dir)`` ·+* ``record`` ``load_record(ws)`` · ``iter_runs(runs_dir)`` ·``effective_judgment`` · ``unique_files``* ``deliverable`` every round's kept build (``artifacts/rNN/``) and ``deliverable/`` for one round-* ``telemetry`` the settings / environment a record carries+* ``telemetry`` the cost summary of a run, from its ledger* ``git_history`` reading the workspace's own git history (files at a round's commit)Turning a tree of finished runs into a dataset, a gallery or a cost report is ``c3d_flywheel``.diff --git a/flywheel/c3d_flywheel/record/deliverable.py b/flywheel/c3d_flywheel/record/deliverable.pyindex b3e6dae2..37e04e53 100644--- a/flywheel/c3d_flywheel/record/deliverable.py+++ b/flywheel/c3d_flywheel/record/deliverable.py@@ -13,11 +13,12 @@ import shutilfrom pathlib import Pathfrom codeverse3d.contracts.common import ENTRY_FILE, Language, Track-from codeverse3d.contracts.run import DeliverableFile, RoundRecord, RunDeliverable, RunRecordfrom codeverse3d.proc import write_json_atomic-from c3d_flywheel.record import git_historyfrom codeverse3d.workspace import Workspace+from c3d_flywheel.legacy import DeliverableFile, RoundRecord, RunDeliverable, RunRecord+from c3d_flywheel.record import git_history+log = logging.getLogger(__name__)#: a round's build output → its role in the hand-over (these and ``meshes/`` are what a round keeps)diff --git a/flywheel/c3d_flywheel/select.py b/flywheel/c3d_flywheel/select.pyindex 0136e63c..472ddedb 100644--- a/flywheel/c3d_flywheel/select.py+++ b/flywheel/c3d_flywheel/select.py@@ -1,4 +1,4 @@-"""Which round of a finished run to hand over — and the hand-over itself (``3dcodeverse pick``)."""+"""Which round of a finished run to hand over — and the hand-over itself (``c3d-flywheel pick``)."""from __future__ import annotations@@ -8,20 +8,19 @@ from datetime import UTC, datetimefrom pathlib import Pathfrom typing import Literal+from codeverse3d.contracts.spec import FIXED_PARTS_GATE, PROJECT_GATE_PREFIX+from codeverse3d.proc import read_json_or_none+from codeverse3d.workspace import Workspacefrom pydantic import BaseModel, Field-from codeverse3d.contracts.run import RoundRecord, RunRecord-from codeverse3d.contracts.spec import FIXED_PARTS_GATE, PROJECT_GATE_PREFIX-from codeverse3d.proc import EventLog, read_json_or_none+from c3d_flywheel.legacy import RoundRecord, RunRecordfrom c3d_flywheel.record.deliverable import build_deliverable, round_outputsfrom c3d_flywheel.record.record import (effective_judgment,load_record,- repackage,round_complexity,stop_reason,)-from codeverse3d.workspace import Workspacelog = logging.getLogger(__name__)@@ -149,10 +148,7 @@ def package(run_dir: Path | str, round_index: int, *, method: Method = "round")rec = load_record(ws)if not any(r.index == round_index for r in rec.rounds):raise ValueError(f"no round {round_index} in {ws.root} (rounds: {[r.index for r in rec.rounds]})")- rec = repackage(ws) or load_record(ws)- manifest = build_deliverable(ws, rec, round_index)+ build_deliverable(ws, rec, round_index)sel = Selection(round=round_index, method=method, scores={r.index: r.score for r in round_rows(ws.root, record=rec)})ws.write_json(ws.root / SELECTION_NAME, sel)- EventLog(ws.events_path).emit("pick.packaged", round=round_index, method=method,- files=len(manifest.files))return ws.deliverablediff --git a/flywheel/pyproject.toml b/flywheel/pyproject.tomlnew file mode 100644index 00000000..394721e0--- /dev/null+++ b/flywheel/pyproject.toml@@ -0,0 +1,42 @@+[build-system]+requires = ["setuptools>=69", "wheel"]+build-backend = "setuptools.build_meta"++[project]+name = "c3d-flywheel"+version = "0.1.0"+description = "Reads the runs 3dcodeverse v0.0.x recorded: show / pick / cost / gallery / dataset export."+readme = "README.md"+requires-python = ">=3.13"+license = { text = "Apache-2.0" }+dependencies = [+ "3dcodeverse", # the plugin package: contracts, conventions, workspace, proc (pip install -e harness)+ "pydantic>=2.12",+ "typer>=0.12",+ "click>=8.1", # cli/cost_cmd.py subclasses TyperGroup with a click.Context+ "rich>=13",+ "pillow>=10", # gallery --embed thumbnails+]++[project.optional-dependencies]+parquet = ["pyarrow>=15"] # `c3d-flywheel export --pack` and metadata.parquet++[project.scripts]+c3d-flywheel = "c3d_flywheel.cli.main:app"++[tool.setuptools.packages.find]+include = ["c3d_flywheel*"]++[tool.setuptools.exclude-package-data]+c3d_flywheel = ["**/__pycache__/*"]++[tool.ruff]+line-length = 100+target-version = "py313"++[tool.ruff.lint]+select = ["E", "W", "F", "I", "B", "UP", "SIM"]+ignore = ["E501"]++[tool.ruff.lint.isort]+known-first-party = ["c3d_flywheel"]