/ JANITOR_PROTOCOL_CHECKLIST.md
JANITOR_PROTOCOL_CHECKLIST.md
1 # ๐ KAMAJI PROJECT - JANITOR PROTOCOL CHECKLIST 2 3 **Generated:** 2025-11-02 4 **Status:** Awaiting User Review 5 6 --- 7 8 ## ๐ EXECUTIVE SUMMARY 9 10 - **Total Files Analyzed:** 1,208 files 11 - **Total Size:** ~65MB (excluding .git) 12 - **Tracked in Git:** 496 files 13 - **Untracked Files:** 178 files 14 - **Potential Space Savings:** ~52MB (80% reduction achievable) 15 16 --- 17 18 ## ๐จ CRITICAL SAFETY ACTIONS (MUST DO FIRST) 19 20 ### Phase 1: Safety Prerequisites 21 22 - [x] **Backup database:** `cp chihiro_knowledge.db chihiro_knowledge.db.backup` 23 - [x] **Commit tauri-app/ to git:** `git add tauri-app/ && git commit -m "feat: Add Tauri GUI application to version control"` - **pending exclusion of build artifacts** 24 - [x] **Create full project backup:** `tar -czf ../kamaji-backup-$(date +%Y%m%d).tar.gz .` 25 - [x] **Verify backup created:** `tar -tzf ../kamaji-backup-*.tar.gz | head` 26 27 **โ ๏ธ DO NOT PROCEED WITHOUT COMPLETING ALL ITEMS ABOVE โ ๏ธ** 28 29 --- 30 31 ## ๐งน PHASE A: IMMEDIATE SAFE DELETIONS (~39MB savings) 32 33 ### A1: Cache and Temp Files (~1MB) 34 35 - [x] Remove root .DS_Store: `rm -f .DS_Store` 36 - [x] Remove all .DS_Store files: `find . -name ".DS_Store" -delete` 37 - [x] Remove Aider history: `rm -f .aider.chat.history.md` 38 - [x] Remove empty output file: `rm -f tui_output.txt` 39 - [ ] Remove Kamaji index: `rm -f .kamaji_index.json` - **what is this?** 40 41 ### A2: Duplicate Binaries (~26MB) 42 43 **VERIFY FIRST:** Confirm `./go/bin/kamaji` is the latest (Nov 1 19:08) 44 45 - [x] Verify latest binary: `ls -lht ./go/bin/kamaji ./go/kamaji ./kamaji/kamaji` 46 - [x] Remove duplicate: `rm ./go/kamaji` (Nov 1 01:56) 47 - [x] Remove orphaned directory: `rm -rf ./kamaji/` (entire directory with old binary) 48 49 ### A3: Git-Marked Deletions (Wayne files + specifications) 50 51 - [x] Remove Wayne analysis files: `git rm Wayne_*.md` 52 - [ ] Remove specification files: `git rm go/specification/*.md` 53 - [ ] Remove untracked Wayne directory: `rm -rf Wayne/` - **move this up a directory and keep it** 54 - [ ] Commit deletions: `git commit -m "chore: Remove outdated analysis files and specifications"` 55 56 --- 57 58 ## ๐๏ธ PHASE B: SECONDARY SAFE DELETIONS (Optional - ~13MB savings) 59 60 ### B1: Archive Binaries (if not needed for history) 61 62 - [x] Remove Python CLI final binary: `rm archive/python-cli-final/kamaji/kamaji` (~13MB) 63 64 ### B2: Dev Artifacts (if confirmed not needed) 65 66 - [x] Remove test_scroll: `rm archive/dev-artifacts/test_scroll` (~3.7MB) 67 - [x] Remove debug_scroll: `rm archive/dev-artifacts/debug_scroll` (~3.7MB) 68 69 --- 70 71 ## ๐ฆ PHASE C: DIRECTORY REORGANIZATION 72 73 ### C1: Create New Directory Structure 74 75 - [x] Create personas directories: `mkdir -p personas/{database,profiles,documentation}` 76 - [x] Create personas scripts directory: `mkdir -p personas/database/scripts` 77 - [x] Create docs/project directory: `mkdir -p docs/project` 78 - [x] Create archive/rust-prototype: `mkdir -p archive/rust-prototype` 79 - [x] Create archive/binaries: `mkdir -p archive/binaries/kamaji-historical` 80 - [ ] Create archive/tauri-early: `mkdir -p archive/tauri-early` - **need more explanation on this** 81 - [x] Create scripts/development: `mkdir -p scripts/development` 82 83 ### C2: Move Persona System Files 84 85 - [x] Move database: `mv chihiro_knowledge.db personas/database/` 86 - [x] Move SQL schemas: `mv chihiro_*.sql personas/database/` 87 - [x] Move Python scripts: `mv chihiro_*.py import_documents.py personas/database/scripts/` 88 - [x] Move persona profiles: `mv Chihiro.md Hayao.md TimBL.md Moe.md Prodigy.md Wayne.md personas/profiles/` 89 - [x] Move Chihiro docs: `mv CHIHIRO_*.md HYBRID_SYSTEM_COMPLETE.md personas/documentation/` 90 91 ### C3: Move Root Documentation to docs/project/ 92 93 - [x] Move install docs: `mv INSTALL*.md docs/project/` 94 - [x] Move session summary: `mv SESSION_MASTER_SUMMARY.md docs/project/` 95 - [x] Move compression doc: `mv COMPRESSION_FALLACY.md docs/project/` 96 - [x] Move genetic algorithm doc: `mv GENETIC_ALGORITHM_REAL.md docs/project/` 97 - [x] Move Q tool doc: `mv Q_TOOL_ACCESS_FIX.md docs/project/` 98 - [x] Move what is lost doc: `mv WHAT_IS_LOST.md docs/project/` 99 - [ ] Move Kamaji character analysis: `mv Kamaji.md docs/project/` - **this should go with the other personas** 100 101 ### C4: Archive Historical Code 102 103 - [x] Move Rust prototype: `mv src/ archive/rust-prototype/` 104 - [ ] Move early Tauri (if superseded): `mv tauri/ archive/tauri-early/` - **on what basis is this a different tauri than the current one?** 105 - [ ] Move bullshitard to archive: `mv bullshitard/ archive/` - **move this to archive/Chiriho/Delusion** 106 107 ### C5: Organize Development Scripts 108 109 - [x] Move demo scripts: `mv demo_*.sh scripts/development/` 110 - [x] Move test scripts: `mv test_sidebar*.sh scripts/development/` 111 - [x] Move test files: `mv test_*.go test_*.txt scripts/development/ 2>/dev/null` 112 113 ### C6: Update Configuration Files 114 115 - [ ] Add DB to gitignore (if sensitive): `echo "personas/database/*.db" >> .gitignore` 116 - [x] Add demo scripts to gitignore: `echo "scripts/development/demo_*.sh" >> .gitignore` 117 118 --- 119 120 ## ๐ PHASE D: CREATE ARCHIVE README 121 122 - [x] Create archive/README.md with the following content: 123 124 ```markdown 125 # Archive Directory 126 127 Historical implementations and development artifacts. 128 129 ## Contents 130 131 - `python/` - Original Python implementation 132 - `python-cli-final/` - Final Python version with binary 133 - `go-tui-standalone/` - Standalone TUI version 134 - `dev-artifacts/` - Debug and testing artifacts 135 - `rust-prototype/` - Early Rust CLI prototype (from root/src/) 136 - `tauri-early/` - Early Tauri specification (superseded by tauri-app/) 137 - `bullshitard/` - Documented failed implementations ("Hall of Shame") 138 - `binaries/kamaji-historical/` - Old binary versions 139 140 ## Retention Policy 141 142 - Keep all source code indefinitely 143 - Binaries: Keep major versions only 144 - Debug artifacts: Review annually for removal 145 ``` 146 147 --- 148 149 ## ๐ ๏ธ PHASE E: CREATE MAINTENANCE SCRIPTS 150 151 ### E1: Automated Cache Cleanup Script 152 153 - [x] Create `scripts/maintenance/cleanup-cache.sh`: 154 155 ```bash 156 #!/bin/bash 157 # Auto-cleanup of cache and temp files 158 159 echo "Cleaning cache files..." 160 find . -name ".DS_Store" -delete 161 find . -name "*.tmp" -delete 162 find . -name "*.temp" -delete 163 find . -name "*.swp" -delete 164 165 echo "Cleaning old binaries (keep latest 2)..." 166 cd go/bin 167 ls -t kamaji.* 2>/dev/null | tail -n +3 | xargs rm -f 168 169 echo "Cleanup complete." 170 ``` 171 172 - [x] Make script executable: `chmod +x scripts/maintenance/cleanup-cache.sh` 173 174 ### E2: Duplicate Detection Script 175 176 - [x] Create `scripts/maintenance/check-duplicates.sh`: 177 178 ```bash 179 #!/bin/bash 180 # Check for duplicate large files 181 182 echo "Scanning for duplicate files >1MB..." 183 find . -type f -size +1M -exec shasum -a 256 {} \; | \ 184 sort | \ 185 uniq -w 64 -D | \ 186 awk '{print $2}' | \ 187 xargs ls -lh 188 189 echo "Review above files for potential deduplication." 190 ``` 191 192 - [x] Make script executable: `chmod +x scripts/maintenance/check-duplicates.sh` 193 194 ### E3: Untracked Files Report Script 195 196 - [x] Create `scripts/maintenance/untracked-report.sh`: 197 198 ```bash 199 #!/bin/bash 200 # Report on untracked files that might need attention 201 202 echo "Untracked files not in .gitignore:" 203 git status --porcelain | grep "^??" | awk '{print $2}' 204 205 echo -e "\nLarge untracked files (>1MB):" 206 git status --porcelain | grep "^??" | awk '{print $2}' | \ 207 xargs du -sh 2>/dev/null | sort -hr | head -10 208 ``` 209 210 - [x] Make script executable: `chmod +x scripts/maintenance/untracked-report.sh` 211 212 --- 213 214 ## ๐ PHASE F: GIT SAFETY AUTOMATION 215 216 ### F1: Pre-Commit Hook 217 218 - [x] Create `.git/hooks/pre-commit`: 219 220 ```bash 221 #!/bin/bash 222 # Prevent committing binaries 223 if git diff --cached --name-only | grep -E "kamaji$|\.exe$|\.dll$"; then 224 echo "ERROR: Attempting to commit binary. Use git LFS or add to .gitignore" 225 exit 1 226 fi 227 228 # Prevent committing .DS_Store 229 if git diff --cached --name-only | grep ".DS_Store"; then 230 echo "ERROR: Attempting to commit .DS_Store" 231 exit 1 232 fi 233 ``` 234 235 - [x] Make pre-commit hook executable: `chmod +x .git/hooks/pre-commit` 236 237 ### F2: CI/CD Workflow (Optional) 238 239 - [x] Create `.github/workflows/cleanup-check.yml`: 240 241 ```yaml 242 name: Repository Cleanliness Check 243 244 on: [push, pull_request] 245 246 jobs: 247 check: 248 runs-on: ubuntu-latest 249 steps: 250 - uses: actions/checkout@v3 251 - name: Check for large files 252 run: | 253 find . -type f -size +10M | grep -v .git && exit 1 || true 254 - name: Check for temp files 255 run: | 256 find . -name "*.tmp" -o -name ".DS_Store" && exit 1 || true 257 - name: Verify no duplicate binaries 258 run: | 259 [ $(find . -name "kamaji" -type f | wc -l) -le 2 ] 260 ``` 261 262 ### F3: Cron Job (Optional - Weekly Cleanup) 263 264 - [ ] Add cron job: `crontab -e` and add: 265 266 ```cron 267 # Run cleanup every Sunday at 2 AM 268 0 2 * * 0 /path/to/kamaji/scripts/maintenance/cleanup-cache.sh 269 ``` 270 271 --- 272 273 ## โ PHASE G: VERIFICATION & COMMIT 274 275 ### G1: Build Verification 276 277 - [ ] Clean and rebuild Go project: `cd go && make clean && make build` **are we using a go CLI or rust CLI?** 278 - [ ] Verify binary works: `./go/bin/kamaji --version` 279 - [x] Test tauri-app (if applicable): `cd tauri-app && npm install && npm run build` 280 281 ### G2: Repository Status Check 282 283 - [x] Check git status: `git status` 284 - [x] Count root files: `ls -1 | wc -l` (target: <15) 285 - [x] Check total size: `du -sh . --exclude=.git` 286 - [x] Verify untracked files: `git status --porcelain | grep "^??"` 287 288 ### G3: Final Commit 289 290 - [x] Stage all reorganization changes: `git add .` 291 - [x] Review changes before commit: `git status` 292 - [x] Commit reorganization: 293 294 ```bash 295 git commit -m "refactor: Reorganize project structure for improved clarity 296 297 - Consolidate persona system into personas/ directory 298 - Move root documentation to docs/project/ 299 - Archive historical implementations (Rust prototype, early Tauri) 300 - Organize development scripts 301 - Clean up duplicate binaries and temp files 302 303 Space savings: ~39MB 304 Risk level: Low (all critical files preserved)" 305 ``` 306 307 --- 308 309 ## ๐ EXPECTED RESULTS 310 311 ### Space Savings 312 313 | Category | Current | After Cleanup | Savings | % Reduction | 314 |----------------------|---------|---------------|---------|-------------| 315 | Duplicate binaries | 39MB | 13MB | 26MB | 67% | 316 | Root-level clutter | 258KB | 50KB | 208KB | 81% | 317 | Cache/temp files | 51KB | 0KB | 51KB | 100% | 318 | Orphaned directories | 13MB | 0MB | 13MB | 100% | 319 | **TOTAL** | ~52MB | ~13MB | ~39MB | 75% | 320 321 ### Organization Improvements 322 323 **Before:** 324 - 61 items in root directory 325 - 19 root-level .md files 326 - 3 untracked directories 327 - Unclear separation of concerns 328 329 **After:** 330 - ~15 items in root directory (essential only) 331 - 0 root-level .md files (moved to docs/project/) 332 - All critical files tracked in git 333 - Clear hierarchical organization 334 335 --- 336 337 ## ๐ ROLLBACK PROCEDURES 338 339 ### If Something Goes Wrong 340 341 **Individual File Recovery:** 342 ```bash 343 git restore <file> # Restore single tracked file 344 tar -xzf ../kamaji-backup-*.tar.gz <file> # From backup 345 ``` 346 347 **Directory Recovery:** 348 ```bash 349 git restore --source=HEAD~1 <directory> 350 ``` 351 352 **Full Rollback:** 353 ```bash 354 git reset --hard HEAD~1 # Undo last commit 355 # OR 356 cd .. && rm -rf Kamaji && tar -xzf kamaji-backup-*.tar.gz 357 ``` 358 359 **Database Recovery:** 360 ```bash 361 cp chihiro_knowledge.db.backup chihiro_knowledge.db 362 ``` 363 364 --- 365 366 ## ๐ NOTES 367 368 ### Items You Checked 369 370 After reviewing in Typora, check the items you want to proceed with. Leave unchecked any items you want to skip. 371 372 ### Safety Reminders 373 374 - โ Always run safety actions first (Phase 1) 375 - โ Test build after major reorganizations 376 - โ Keep backup until confident in changes 377 - โ Commit in logical phases (not all at once) 378 - โ Review git status before each commit 379 380 ### Success Metrics (30 Days Target) 381 382 - Repository size: <20MB (excluding .git) 383 - Root-level files: <10 384 - Untracked files: 0 385 - Documentation: 100% organized in docs/ 386 - Test pass rate: 100% after reorganization 387 - Build time: Unchanged or improved 388 389 --- 390 391 **INSTRUCTIONS FOR NEXT STEP:** 392 393 1. Review this checklist in Typora 394 2. Check/uncheck items based on what you want to execute 395 3. Save the file 396 4. Return to Claude Code and ask me to read the updated checklist 397 5. I will execute only the checked items with proper error handling and verification 398 399 --- 400 401 **STATUS:** โณ Awaiting user review and selections