fix: correct local config path

This commit is contained in:
banteg
2025-12-29 18:06:54 +04:00
parent bbb7bcbc39
commit 2e8c32828a
3 changed files with 22 additions and 5 deletions
+2 -2
View File
@@ -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)
+19 -2
View File
@@ -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]:
+1 -1
View File
@@ -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"