From 2e8c32828acd20649ab990ecc8c54ff509db473a Mon Sep 17 00:00:00 2001 From: banteg <4562643+banteg@users.noreply.github.com> Date: Mon, 29 Dec 2025 18:06:54 +0400 Subject: [PATCH] fix: correct local config path --- readme.md | 4 ++-- src/takopi/config.py | 21 +++++++++++++++++++-- src/takopi/constants.py | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index 5fcb491..2e7e74b 100644 --- a/readme.md +++ b/readme.md @@ -32,7 +32,7 @@ uv run takopi --help ### Configuration -Create `~/.codex/takopi.toml` (or `./codex/takopi.toml` for a repo-local config): +Create `~/.codex/takopi.toml` (or `./.codex/takopi.toml` for a repo-local config): ```toml bot_token = "123456789:ABCdefGHIjklMNOpqrsTUVwxyz" @@ -46,7 +46,7 @@ chat_id = 123456789 The bridge only accepts messages where the chat ID equals the sender ID and both match `chat_id` (i.e., private chat with that user). -When you pass `--cd`, Takopi looks for `codex/takopi.toml` under that directory first. +When you pass `--cd`, Takopi looks for `.codex/takopi.toml` under that directory first. ### Codex Profile (Optional) diff --git a/src/takopi/config.py b/src/takopi/config.py index f09d965..8568fd0 100644 --- a/src/takopi/config.py +++ b/src/takopi/config.py @@ -10,6 +10,12 @@ class ConfigError(RuntimeError): pass +_EXAMPLE_CONFIG = ( + 'bot_token = "123456789:ABCdefGHIjklMNOpqrsTUVwxyz"\n' + "chat_id = 123456789\n" +) + + def _display_path(path: Path) -> str: try: cwd = Path.cwd() @@ -24,9 +30,20 @@ def _display_path(path: Path) -> str: def _missing_config_message(primary: Path, alternate: Path | None = None) -> str: + example = "Example config:\n```\n" + _EXAMPLE_CONFIG + "```\n" if alternate is None: - return f"Missing config file `{_display_path(primary)}`." - return "Missing takopi config. See readme.md for setup." + return ( + f"Missing config file `{_display_path(primary)}`.\n" + f"{example}" + ) + return ( + "Missing takopi config.\n" + "Create one of these files:\n" + f" {_display_path(alternate)}\n" + f" {_display_path(primary)}\n" + "\n" + f"{example}" + ) def _config_candidates(base_dir: Path | None) -> list[Path]: diff --git a/src/takopi/constants.py b/src/takopi/constants.py index 04475b1..d1cdc5d 100644 --- a/src/takopi/constants.py +++ b/src/takopi/constants.py @@ -3,5 +3,5 @@ from __future__ import annotations from pathlib import Path TELEGRAM_HARD_LIMIT = 4096 -LOCAL_CONFIG_NAME = Path("codex") / "takopi.toml" +LOCAL_CONFIG_NAME = Path(".codex") / "takopi.toml" HOME_CONFIG_PATH = Path.home() / ".codex" / "takopi.toml"