fix: Improve config path resolution and error messages (fixes #262)

Three critical UX improvements for custom config handling:

1. User config directory support:
   - Added ~/.config/skill-seekers/configs/ to search path
   - Users can now place custom configs in their home directory
   - Path resolution order: exact path → ./configs/ → user config dir → API

2. Better error messages:
   - Show all searched absolute paths when config not found
   - Added get_last_searched_paths() function to track locations
   - Clear guidance on where to place custom configs

3. Auto-create config.json:
   - ConfigManager now creates config.json on first initialization
   - Creates configs/ subdirectory for user custom configs
   - Display shows custom configs directory path

Fixes reported by @melamers in issue #262 where:
- Config path shown by `skill-seekers config` didn't exist
- Unclear where to save custom configs
- Error messages didn't show exact paths searched

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
yusyus
2026-01-27 22:01:04 +03:00
parent 746e335fae
commit cf3da6dff3
3 changed files with 78 additions and 11 deletions

View File

@@ -43,15 +43,28 @@ class ConfigManager:
self.config_file = self.CONFIG_FILE
self.progress_dir = self.PROGRESS_DIR
self._ensure_directories()
# Check if config file exists before loading
config_exists = self.config_file.exists()
self.config = self._load_config()
# Save config file if it was just created with defaults
if not config_exists:
self.save_config()
def _ensure_directories(self):
"""Ensure configuration and progress directories exist with secure permissions."""
# Create main config and progress directories
for directory in [self.config_dir, self.progress_dir]:
directory.mkdir(parents=True, exist_ok=True)
# Set directory permissions to 700 (rwx------)
directory.chmod(stat.S_IRWXU)
# Also create configs subdirectory for user custom configs
configs_dir = self.config_dir / "configs"
configs_dir.mkdir(exist_ok=True)
configs_dir.chmod(stat.S_IRWXU)
def _load_config(self) -> dict[str, Any]:
"""Load configuration from file or create default."""
if not self.config_file.exists():
@@ -391,6 +404,7 @@ class ConfigManager:
"""Display current configuration summary."""
print("\n📋 Skill Seekers Configuration\n")
print(f"Config file: {self.config_file}")
print(f"Custom configs dir: {self.config_dir / 'configs'}")
print(f"Progress dir: {self.progress_dir}\n")
# GitHub profiles