utils/todo_hooks/paths.py
Krzysztof kuhy Rudnicki 1fb04ce59d
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
file length / file-length (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run
todo_hooks: session-start, canonical token path
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 12:24:29 +01:00

44 lines
1.4 KiB
Python

"""Every on-disk location the hooks use, overridable for tests."""
from __future__ import annotations
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from collections.abc import Mapping
@dataclass
class Paths:
"""Config, state and lookup locations used by the todo hooks."""
token_file: Path
trust_file: Path
report_file: Path
src_root: Path
capped: Path | None
@classmethod
def default(cls, env: Mapping[str, str], home: Path | None = None) -> Paths:
"""Resolve defaults under `home`; ``TODO_*`` env vars override each."""
base = home if home is not None else Path.home()
capped = base / ".claude" / "scripts" / "capped.sh"
return cls(
token_file=Path(
env.get("TODO_MCP_TOKEN_FILE")
or base / ".config" / "todo-mcp-client" / "token"
),
trust_file=Path(
env.get("TODO_HOOKS_TRUST_FILE")
or base / ".config" / "todo-hooks" / "trusted-checks"
),
report_file=Path(
env.get("TODO_HOOKS_REPORT")
or base / ".local" / "state" / "todo-drift" / "report.txt"
),
src_root=Path(env.get("TODO_HOOKS_SRC_ROOT") or base / "src"),
capped=capped if capped.is_file() else None,
)