cd /Users/rbutare/websites/apps/aiwizard

# 1. Stage ALL remaining deletions (admin, data/build, etc)
git add -A
git status --short | tail -20

git commit -m "v1.6 final - remove admin data/build docs-review frontend includes - 11/11 PASS"
git tag -a v1.6 -m "v1.6 clean 11/11 PASS rbutareOld .github prompts kept 7277 deletions"
git log --oneline -3

# 2. Create v1.7 branch
git checkout -b v1.7-autocode
git branch

# 3. v1.7 - autocode true scan
cat > php/code.scanner.php <<'PHP'
<?php
// v1.7 - true scan, no glob every load, per-section
function v17_scan($base) {
  $counts = ['php'=>0,'css'=>0,'html'=>0,'sql'=>0,'sh'=>0,'json'=>0];
  $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($base, FilesystemIterator::SKIP_DOTS));
  foreach ($it as $f) {
    if ($f->isDir()) continue;
    $p = $f->getPathname();
    if (strpos($p,'/.git/')!==false) continue;
    if (strpos($p,'/data/build/')!==false) continue;
    $ext = strtolower($f->getExtension());
    if (isset($counts[$ext])) $counts[$ext]++;
  }
  return $counts;
}
PHP

cat > tools/code.count.sh <<'SH'
#!/bin/bash
BASE="/Users/rbutare/websites/apps/aiwizard"; cd $BASE
echo "=== v1.7 TRUE COUNTS ==="
for e in php css html sql sh json; do printf "%-4s : %3d\n" $e $(find . -type f -name "*.$e" ! -path "*/.git/*" ! -path "*/data/build/*" | wc -l); done
echo "total : $(find . -type f \( -name "*.php" -o -name "*.css" -o -name "*.html" -o -name "*.sql" -o -name "*.sh" -o -name "*.json" \) ! -path "*/.git/*" ! -path "*/data/build/*" | wc -l)"
SH
chmod +x tools/code.count.sh
./tools/code.count.sh

git add php/code.scanner.php tools/code.count.sh
git commit -m "v1.7 autocode - true scan php css html sql sh json per-section no glob"

git log --oneline -4
echo "=== v1.7 READY ==="
