feat(cli): добавлен батч-режим и конфигурационный файл (шаги 8–12)

- Зачем:
  - обработка нескольких файлов за один вызов с загрузкой модели один раз.
  - хранение дефолтов (модель, язык, устройство) в .transcriber.toml.
- Что:
  - добавлен config.py: поиск .transcriber.toml (CWD → ~/.config), парсинг, валидация, приоритет CLI > конфиг > хардкод.
  - рефакторинг transcriber.py: выделены load_model() и _transcribe_file() с TranscribeFileResult для переиспользования модели в батче.
  - добавлены expand_globs() с дедупликацией и has_existing_transcript() в utils.py.
  - CLI: files: list[Path], --force/-f, prescan-first батч с итоговой статистикой и временем, Status-спиннер для прогресса.
  - README: секции батч-режим, конфигурационный файл, --force в таблице опций.
  - ADR-002: зафиксированы архитектурные решения (prescan-first, TranscribeFileResult, конфиг без мержа).
- Проверка:
  - uv run pytest -q — 94 passed, 1 skipped.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-18 20:57:19 +03:00
co-authored by Claude Opus 4.6
parent b46827a283
commit e28232ef50
13 changed files with 1227 additions and 103 deletions
+22
View File
@@ -1,3 +1,4 @@
import glob
import shutil
import subprocess
import sys
@@ -68,3 +69,24 @@ def build_output_path(input_path: Path, output: Path | None = None) -> Path:
if output is not None:
return output
return input_path.with_stem(input_path.stem + "-transcript").with_suffix(".md")
def expand_globs(paths: list[Path]) -> list[Path]:
seen: set[Path] = set()
result: list[Path] = []
for p in paths:
s = str(p)
if any(c in s for c in ("*", "?", "[")):
candidates = [Path(m) for m in sorted(glob.glob(s))]
else:
candidates = [p]
for c in candidates:
resolved = c.resolve()
if resolved not in seen:
seen.add(resolved)
result.append(c)
return result
def has_existing_transcript(input_path: Path) -> bool:
return build_output_path(input_path).exists()