diff --git a/bin/commands/mail.py b/bin/commands/mail.py index ad9bcbf..5ca6911 100644 --- a/bin/commands/mail.py +++ b/bin/commands/mail.py @@ -15,15 +15,30 @@ import click from bin.utils import handle_errors -CONFIG_PATH = Path.home() / ".myclaude" / "mail.json" +OLD_CONFIG_PATH = Path.home() / ".myclaude" / "mail.json" +CONFIG_PATH = Path.home() / ".config" / "mytoolkit" / "mail.json" + + +def _resolve_config_path() -> Path: + """Return active config path, migrating from old location if needed.""" + if CONFIG_PATH.exists(): + return CONFIG_PATH + if OLD_CONFIG_PATH.exists(): + CONFIG_PATH.parent.mkdir(parents=True, exist_ok=True) + import shutil + shutil.copy2(OLD_CONFIG_PATH, CONFIG_PATH) + click.echo(f"Migrated config: {OLD_CONFIG_PATH} -> {CONFIG_PATH}") + return CONFIG_PATH + return CONFIG_PATH def load_config(): """Load mail config.""" - if not CONFIG_PATH.exists(): + path = _resolve_config_path() + if not path.exists(): click.echo("Mail not configured. Run: mytoolkit mail config", err=True) raise click.Abort() - with open(CONFIG_PATH, encoding="utf-8") as f: + with open(path, encoding="utf-8") as f: return json.load(f)