mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-10 17:47:24 +01:00
Python 3.14 stdlib package wiring git to the todo MCP server: - closer (post-commit): runs the done_check of each Todo: trailer task and close_task's it only on exit 0. It FAILS OPEN: the commit already happened, so a down server, bad token or no gh prints one warning and exits 0 instead of failing the hook. - sweep: nightly drift report (systemd units shipped, not enabled). - import-pr: a merged PR's '## Todo:' items become tasks, deduped. - A done_check runs only if its sha256 is in ~/.config/todo-hooks/trusted-checks; 'Check: manual' notes are never auto-closed. - Hooks exposed in .pre-commit-hooks.yaml (post-commit, post-merge, post-rewrite). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.4 KiB
Python
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,
|
|
)
|