diff --git a/LESSONS.md b/LESSONS.md index 49e4601..2596cd8 100644 --- a/LESSONS.md +++ b/LESSONS.md @@ -6,3 +6,5 @@ Recurring problems and what worked. Read before starting; add an entry when a mi (`git remote add`) must run outside the sandbox. - `~/.cache/uv` is read-only inside the sandbox: export `UV_CACHE_DIR=$TMPDIR/uv-cache` before any `uv` command. +- The sandbox mounts char-device placeholders (`.claude/`, `.mcp.json`, dotfiles) in the + working dir; they are gitignored, never `git add` them. diff --git a/src/vnpipe/cli.py b/src/vnpipe/cli.py new file mode 100644 index 0000000..a247a12 --- /dev/null +++ b/src/vnpipe/cli.py @@ -0,0 +1,36 @@ +"""Command-line entry point. + +Each pipeline stage lives in its own module exposing ``register(subparsers)``, +which adds a subcommand whose handler takes the parsed ``argparse.Namespace``. +""" + +import argparse +import importlib +from pathlib import Path + +STAGE_MODULES = ["text", "annotate", "assets", "renpy_gen"] + + +def main(argv: list[str] | None = None) -> int: + parser = argparse.ArgumentParser(prog="vnpipe", description=__doc__) + parser.add_argument( + "--work", + type=Path, + default=Path("works/faust"), + help="Work directory containing work.toml (default: works/faust)", + ) + sub = parser.add_subparsers(dest="command", required=True) + for name in STAGE_MODULES: + try: + module = importlib.import_module(f"vnpipe.{name}") + except ModuleNotFoundError as exc: + if exc.name != f"vnpipe.{name}": + raise + continue + module.register(sub) + args = parser.parse_args(argv) + return args.handler(args) or 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/src/vnpipe/config.py b/src/vnpipe/config.py new file mode 100644 index 0000000..3e818cb --- /dev/null +++ b/src/vnpipe/config.py @@ -0,0 +1,37 @@ +"""Load a work's configuration (works//work.toml).""" + +import tomllib +from dataclasses import dataclass +from pathlib import Path +from typing import Any + + +@dataclass(frozen=True) +class Work: + root: Path + data: dict[str, Any] + + @property + def id(self) -> str: + return self.data["work"]["id"] + + @property + def cast(self) -> dict[str, dict[str, Any]]: + return self.data["cast"] + + @property + def speakers(self) -> dict[str, str]: + return self.data["speakers"] + + @property + def scenes(self) -> list[dict[str, Any]]: + return self.data["scenes"] + + def path(self, relative: str) -> Path: + return self.root / relative + + +def load_work(root: Path) -> Work: + root = Path(root) + with (root / "work.toml").open("rb") as fh: + return Work(root=root, data=tomllib.load(fh))