Related Code Files:
sync_tools_to_desktop.py- Main synchronization script.sync_log.json- Sync history tracking (created in destination)
The sync_tools_to_desktop.py script provides intelligent synchronization between your main code-intelligence-toolkit repository and a separate copy on your Desktop. This is useful when you have two separate git repositories and want to keep the tools synchronized without manual copying.
- Smart Detection: Only syncs files that have actually changed (using MD5 hashing)
- Git Awareness: Warns about uncommitted changes in the destination repository
- Selective Sync: Syncs Python tools, shell scripts, config files, and documentation
- Safe Operation: Creates backups of modified files before overwriting
- History Tracking: Maintains a log of all sync operations
- Dry Run Mode: Preview changes before applying them
- Force Mode: Override safety checks when needed
- The script is already created in your main repository
- Make it executable:
chmod +x sync_tools_to_desktop.py
From your main repository directory:
./sync_tools_to_desktop.py./sync_tools_to_desktop.py --dry-run./sync_tools_to_desktop.py --force./sync_tools_to_desktop.py --source /path/to/source --dest /path/to/destination- All Python files (
*.py) - Shell scripts (
*.sh, includingrun_any_python_tool.sh) - Configuration files (
.pytoolsrc*) - Documentation (
*.md)
- Git directories (
.git) - Python cache (
__pycache__,*.pyc) - macOS files (
.DS_Store) - The sync script itself
- Sync history (
.sync_log.json)
-
Make changes in main repository:
cd ~/DemoStrategies/Strategies/code-intelligence-toolkit # Edit tools, fix bugs, add features git add . git commit -m "Enhanced tool features"
-
Sync to desktop:
./sync_tools_to_desktop.py
-
Review and commit in desktop repo:
cd ~/Desktop/code-intelligence-toolkit git status git add -u # Modified files git add . # New files git commit -m "Sync tools from main repository"
The script checks for uncommitted changes in the destination repository and warns you:
⚠️ WARNING: Desktop repository has local modifications:
Modified files:
- tool1.py
- tool2.py
Proceed with sync? (y/N/force):
Modified files are backed up before overwriting:
- Original:
tool.py - Backup:
tool.py.backup
A .sync_log.json file tracks all sync operations:
{
"syncs": [
{
"timestamp": "2025-07-25T10:30:45",
"files_synced": 15,
"total_files": 15
}
],
"file_hashes": {
"tool1.py": "abc123...",
"tool2.py": "def456..."
}
}Create a shell script for regular syncing:
#\!/bin/bash
# sync_and_commit.sh
# Sync tools
./sync_tools_to_desktop.py --force
# Auto-commit in desktop repo
cd ~/Desktop/code-intelligence-toolkit
if [[ $(git status --porcelain) ]]; then
git add .
git commit -m "Auto-sync from main repository $(date +%Y-%m-%d)"
echo "✅ Synced and committed"
else
echo "✅ No changes to sync"
fiAdd to .git/hooks/post-commit in main repo:
#\!/bin/bash
echo "🔄 Syncing to desktop repository..."
./sync_tools_to_desktop.py --dry-runCreate the desktop repository first:
mkdir -p ~/Desktop/code-intelligence-toolkit
cd ~/Desktop/code-intelligence-toolkit
git initEnsure the sync script is executable:
chmod +x sync_tools_to_desktop.pyClear the sync history to force re-sync:
rm ~/Desktop/code-intelligence-toolkit/.sync_log.json
./sync_tools_to_desktop.py- Commit Before Syncing: Always commit changes in both repositories before syncing
- Review Changes: Use
--dry-runto preview what will be synced - Regular Syncs: Sync frequently to avoid large divergences
- Document Changes: Keep commit messages descriptive in both repositories
- Test After Sync: Run key tools after syncing to ensure everything works
- Primary development in main repository
- Test thoroughly
- Commit changes
- Sync to desktop
- Test in desktop environment
- Commit in desktop repository
- Make urgent fix in desktop repository
- Commit the fix
- Manually port important changes back to main repository
- Resume normal sync flow
Potential improvements for the sync tool:
- Bidirectional sync support
- Exclude list configuration file
- Sync specific file patterns only
- Integration with git operations
- Conflict resolution strategies