CCNotify
CCNotify copied to clipboard
Refactor replacements.json structure to eliminate duplication
Description
The current replacements.json file has a confusing dual structure where project information is stored in both _auto_discovered.projects and project_names.replacements. This creates redundancy and makes the configuration harder to understand and maintain.
Context
- Project Area: Configuration system / Text-to-Speech replacements
- Complexity: 4/10 (Moderate - involves refactoring and migration)
- User Impact: Improves configuration clarity and maintainability
Current Problem
- Projects are stored in two places:
_auto_discovered.projects(with rich metadata: folder, display_name, pronunciation)project_names.replacements(simple key-value pairs)
- The TTS system prioritizes
_auto_discoveredwhich is why user replacements work - Auto-discovery adds entries to BOTH locations, creating duplication
- README documentation doesn't match the actual structure being used
Technical Details
Affected Files:
src/ccnotify/notify.py- Core replacement logic (5 functions to update)load_replacements()(line 430)auto_add_project_to_replacements()(line 287)apply_project_name_replacement()(line 445)get_project_pronunciation()(line 457)apply_command_replacement()(line 474)
README.md- Documentation update for "Pronunciation Customization" section- User config files - Will need automatic migration
Requirements
- Consolidate project storage to a single
projectssection - Maintain rich metadata structure (folder, display_name, pronunciation)
- Provide automatic migration for existing configurations
- Add comprehensive examples for commands and patterns
- Update documentation to reflect the new structure
Proposed Structure
{
"projects": {
"ccnotify": {
"folder": "-Users-helmi-code-ccnotify",
"display_name": "CCNotify",
"pronunciation": "CC notify"
},
"agent-zero": {
"folder": "-Users-helmi-code-agent-zero",
"display_name": "Agent Zero",
"pronunciation": "agent zero"
}
},
"commands": {
"ls": "list",
"cd": "change directory",
"rm": "remove",
"mkdir": "make directory",
"npm": "N P M",
"uvx": "U V X"
},
"patterns": [
{
"pattern": "npm run (\\\\w+)",
"replacement": "N P M run {1}"
},
{
"pattern": "git (push|pull|commit)",
"replacement": "git {1}"
},
{
"pattern": "(.+)\\\\.py",
"replacement": "{1} python file"
}
]
}
Implementation Steps
- [ ] Update
load_replacements()to use new default structure - [ ] Modify
auto_add_project_to_replacements()to write toprojectssection - [ ] Update
get_project_pronunciation()to read fromprojects[name].pronunciation - [ ] Update
apply_project_name_replacement()to useprojects[name].display_name - [ ] Add migration logic to convert old format to new on first load
- [ ] Add comprehensive command and pattern examples
- [ ] Update README documentation
- [ ] Test migration with existing configurations
Acceptance Criteria
- [ ] No duplicate project data in configuration
- [ ] Existing user configurations are automatically migrated
- [ ] TTS pronunciations continue to work correctly
- [ ] README accurately documents the new structure
- [ ] Rich metadata (folder, display_name, pronunciation) is preserved