mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-19 18:54:32 +01:00
feedback_inbox and app_errors guessed kuhyx/<folder> for a task's repo, which filed cleanup-plate under kuhyx/cleanup-plate (real: Sepci0/cleanup-plate) and showed phantom repos on the board. Both now read the GitHub owner/name from ~/src/<folder>'s origin remote (https or ssh forms) and fall back to the guess only when there is no checkout or its origin is not on GitHub. app-errors 0.1.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWZfgt44aEKxvGBJkwP
56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
# Copyright (c) 2026 Krzysztof Rudnicki
|
|
"""Every on-disk and network location, resolved in one place.
|
|
|
|
Tests redirect :func:`resolve_paths` once; nothing else names a real path.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from pathlib import Path
|
|
|
|
MCP_URL = "http://127.0.0.1:8735/mcp"
|
|
# Port 9 (discard) refuses connections: a test that forgets to inject a client
|
|
# fails closed instead of reaching the live todo server.
|
|
DEAD_URL = "http://127.0.0.1:9/mcp"
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Paths:
|
|
"""Where the inbox reads games, its token, its lock and its units."""
|
|
|
|
data_root: Path
|
|
token_file: Path
|
|
lock_file: Path
|
|
unit_dir: Path
|
|
mcp_url: str
|
|
# Game checkouts: ``<src_root>/<repo>``'s origin names the GitHub repo.
|
|
src_root: Path
|
|
|
|
@classmethod
|
|
def under(cls, root: Path) -> Paths:
|
|
"""A throwaway layout below ``root`` that can never reach the live app."""
|
|
return cls(
|
|
data_root=root / "data",
|
|
token_file=root / "token",
|
|
lock_file=root / "state" / "lock",
|
|
unit_dir=root / "units",
|
|
mcp_url=DEAD_URL,
|
|
src_root=root / "src",
|
|
)
|
|
|
|
|
|
def resolve_paths(given: Paths | None = None) -> Paths:
|
|
"""Return ``given`` or the real layout under the user's home."""
|
|
if given is not None:
|
|
return given
|
|
home = Path.home()
|
|
return Paths(
|
|
data_root=home / "data",
|
|
token_file=home / ".config" / "feedback-inbox" / "token",
|
|
lock_file=home / ".local" / "share" / "feedback-inbox" / "lock",
|
|
unit_dir=home / ".config" / "systemd" / "user",
|
|
mcp_url=MCP_URL,
|
|
src_root=home / "src",
|
|
)
|