|
| 1 | +#!/bin/bash |
| 2 | +# Cortex Linux - Repo Cleanup Script |
| 3 | +# Run this once to organize the repo for public launch |
| 4 | +# Usage: cd ~/cortex && bash cortex-cleanup.sh |
| 5 | + |
| 6 | +set -e |
| 7 | + |
| 8 | +echo "🧹 CORTEX LINUX REPO CLEANUP" |
| 9 | +echo "============================" |
| 10 | +echo "" |
| 11 | + |
| 12 | +cd ~/cortex || { echo "❌ ~/cortex not found"; exit 1; } |
| 13 | + |
| 14 | +# Confirm we're in the right place |
| 15 | +if [ ! -f "README.md" ] || [ ! -d ".git" ]; then |
| 16 | + echo "❌ Not in cortex repo root. Run from ~/cortex" |
| 17 | + exit 1 |
| 18 | +fi |
| 19 | + |
| 20 | +echo "📁 Current root files: $(ls *.py *.sh *.json *.csv *.md 2>/dev/null | wc -l | tr -d ' ')" |
| 21 | +echo "" |
| 22 | + |
| 23 | +# Step 1: Create directories if they don't exist |
| 24 | +echo "1️⃣ Creating directory structure..." |
| 25 | +mkdir -p cortex/modules |
| 26 | +mkdir -p tests |
| 27 | +mkdir -p scripts |
| 28 | +mkdir -p docs |
| 29 | +mkdir -p internal |
| 30 | + |
| 31 | +# Step 2: Move Python modules into cortex/ |
| 32 | +echo "2️⃣ Moving Python modules to cortex/..." |
| 33 | +for file in context_memory.py dependency_resolver.py error_parser.py \ |
| 34 | + installation_history.py installation_verifier.py llm_router.py \ |
| 35 | + logging_system.py; do |
| 36 | + if [ -f "$file" ]; then |
| 37 | + mv "$file" cortex/ 2>/dev/null && echo " ✓ $file → cortex/" |
| 38 | + fi |
| 39 | +done |
| 40 | + |
| 41 | +# Step 3: Move test files into tests/ |
| 42 | +echo "3️⃣ Moving test files to tests/..." |
| 43 | +for file in test_*.py; do |
| 44 | + if [ -f "$file" ]; then |
| 45 | + mv "$file" tests/ 2>/dev/null && echo " ✓ $file → tests/" |
| 46 | + fi |
| 47 | +done |
| 48 | + |
| 49 | +# Step 4: Move shell scripts into scripts/ |
| 50 | +echo "4️⃣ Moving shell scripts to scripts/..." |
| 51 | +for file in *.sh; do |
| 52 | + # Keep this cleanup script in root temporarily |
| 53 | + if [ "$file" != "cortex-cleanup.sh" ] && [ -f "$file" ]; then |
| 54 | + mv "$file" scripts/ 2>/dev/null && echo " ✓ $file → scripts/" |
| 55 | + fi |
| 56 | +done |
| 57 | + |
| 58 | +# Step 5: Move markdown docs to docs/ (except key root files) |
| 59 | +echo "5️⃣ Moving documentation to docs/..." |
| 60 | +for file in *.md; do |
| 61 | + case "$file" in |
| 62 | + README.md|CHANGELOG.md|LICENSE|Contributing.md) |
| 63 | + echo " ⊘ $file (keeping in root)" |
| 64 | + ;; |
| 65 | + *) |
| 66 | + if [ -f "$file" ]; then |
| 67 | + mv "$file" docs/ 2>/dev/null && echo " ✓ $file → docs/" |
| 68 | + fi |
| 69 | + ;; |
| 70 | + esac |
| 71 | +done |
| 72 | + |
| 73 | +# Step 6: Move internal/admin files and gitignore them |
| 74 | +echo "6️⃣ Moving internal files to internal/..." |
| 75 | +for file in bounties_owed.csv bounties_pending.json contributors.json \ |
| 76 | + issue_status.json payments_history.json pr_status.json; do |
| 77 | + if [ -f "$file" ]; then |
| 78 | + mv "$file" internal/ 2>/dev/null && echo " ✓ $file → internal/" |
| 79 | + fi |
| 80 | +done |
| 81 | + |
| 82 | +# Step 7: Delete duplicate/junk files |
| 83 | +echo "7️⃣ Removing duplicate files..." |
| 84 | +rm -f "README_DEPENDENCIES (1).md" 2>/dev/null && echo " ✓ Removed README_DEPENDENCIES (1).md" |
| 85 | +rm -f "deploy_jesse_system (1).sh" 2>/dev/null && echo " ✓ Removed deploy_jesse_system (1).sh" |
| 86 | + |
| 87 | +# Step 8: Update .gitignore |
| 88 | +echo "8️⃣ Updating .gitignore..." |
| 89 | +if ! grep -q "internal/" .gitignore 2>/dev/null; then |
| 90 | + echo "" >> .gitignore |
| 91 | + echo "# Internal admin files (bounties, payments, etc.)" >> .gitignore |
| 92 | + echo "internal/" >> .gitignore |
| 93 | + echo " ✓ Added internal/ to .gitignore" |
| 94 | +else |
| 95 | + echo " ⊘ internal/ already in .gitignore" |
| 96 | +fi |
| 97 | + |
| 98 | +# Step 9: Create __init__.py files if missing |
| 99 | +echo "9️⃣ Ensuring Python packages are importable..." |
| 100 | +touch cortex/__init__.py 2>/dev/null |
| 101 | +touch tests/__init__.py 2>/dev/null |
| 102 | +echo " ✓ __init__.py files created" |
| 103 | + |
| 104 | +# Step 10: Show results |
| 105 | +echo "" |
| 106 | +echo "📊 CLEANUP COMPLETE" |
| 107 | +echo "===================" |
| 108 | +echo "Root files now: $(ls *.py *.sh *.json *.csv 2>/dev/null | wc -l | tr -d ' ') (should be ~0)" |
| 109 | +echo "" |
| 110 | +echo "Directory structure:" |
| 111 | +echo " cortex/ - $(ls cortex/*.py 2>/dev/null | wc -l | tr -d ' ') Python modules" |
| 112 | +echo " tests/ - $(ls tests/*.py 2>/dev/null | wc -l | tr -d ' ') test files" |
| 113 | +echo " scripts/ - $(ls scripts/*.sh 2>/dev/null | wc -l | tr -d ' ') shell scripts" |
| 114 | +echo " docs/ - $(ls docs/*.md 2>/dev/null | wc -l | tr -d ' ') markdown files" |
| 115 | +echo " internal/ - $(ls internal/ 2>/dev/null | wc -l | tr -d ' ') admin files (gitignored)" |
| 116 | +echo "" |
| 117 | + |
| 118 | +# Step 11: Git commit |
| 119 | +echo "🔟 Committing changes..." |
| 120 | +git add -A |
| 121 | +git status --short |
| 122 | +echo "" |
| 123 | +read -p "Commit and push these changes? (y/n): " -n 1 -r |
| 124 | +echo |
| 125 | +if [[ $REPLY =~ ^[Yy]$ ]]; then |
| 126 | + git commit -m "Reorganize repo structure for public launch |
| 127 | +
|
| 128 | +- Move Python modules to cortex/ |
| 129 | +- Move tests to tests/ |
| 130 | +- Move scripts to scripts/ |
| 131 | +- Move docs to docs/ |
| 132 | +- Move internal admin files to internal/ (gitignored) |
| 133 | +- Remove duplicate files |
| 134 | +- Clean root directory for professional appearance" |
| 135 | + |
| 136 | + git push origin main |
| 137 | + echo "" |
| 138 | + echo "✅ DONE! Repo is now clean and pushed." |
| 139 | +else |
| 140 | + echo "" |
| 141 | + echo "⚠️ Changes staged but NOT committed. Run 'git commit' when ready." |
| 142 | +fi |
| 143 | + |
| 144 | +echo "" |
| 145 | +echo "🧪 NEXT STEP: Test the CLI" |
| 146 | +echo " cd ~/cortex && source venv/bin/activate && cortex install nginx --dry-run" |
| 147 | +echo "" |
0 commit comments