Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions .github/workflows/auto-copilot-functionality-docs-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,22 +193,25 @@ jobs:
! -path "*/dist/*" \
! -name "__init__.py" \
-type f | while read -r file; do
# Count functions and classes with proper error handling
func_count=$(grep -c "^def " "$file" 2>/dev/null || echo 0)
class_count=$(grep -c "^class " "$file" 2>/dev/null || echo 0)
docstring_count=$(grep -c '"""' "$file" 2>/dev/null || echo 0)
# Count functions and classes with input validation
func_count_raw=$(grep -c "^def " "$file" 2>/dev/null || echo 0)
class_count_raw=$(grep -c "^class " "$file" 2>/dev/null || echo 0)
docstring_count_raw=$(grep -c '"""' "$file" 2>/dev/null || echo 0)

# Sanitize variables to ensure they contain only integers
func_count=$(echo "$func_count" | tr -d '\n\r' | grep -E '^[0-9]+$' || echo 0)
class_count=$(echo "$class_count" | tr -d '\n\r' | grep -E '^[0-9]+$' || echo 0)
docstring_count=$(echo "$docstring_count" | tr -d '\n\r' | grep -E '^[0-9]+$' || echo 0)
# Validate and sanitize counts (ensure they are single integers)
func_count=$(echo "$func_count_raw" | head -n1 | grep -E '^[0-9]+$' || echo 0)
class_count=$(echo "$class_count_raw" | head -n1 | grep -E '^[0-9]+$' || echo 0)
docstring_count=$(echo "$docstring_count_raw" | head -n1 | grep -E '^[0-9]+$' || echo 0)

# Ensure variables are valid integers before arithmetic
if [ "$func_count" -eq "$func_count" ] 2>/dev/null && [ "$class_count" -eq "$class_count" ] 2>/dev/null; then
# Ensure we have valid numbers before arithmetic
if [[ "$func_count" =~ ^[0-9]+$ ]] && [[ "$class_count" =~ ^[0-9]+$ ]] && [[ "$docstring_count" =~ ^[0-9]+$ ]]; then
total=$((func_count + class_count))
if [ $total -gt 0 ] && [ "$docstring_count" -eq "$docstring_count" ] 2>/dev/null && [ $docstring_count -eq 0 ]; then
if [ $total -gt 0 ] && [ $docstring_count -eq 0 ]; then
echo "⚠️ $file: $total definitions, no docstrings" >> /tmp/doc-analysis.md
fi
else
# Log problematic files for debugging
echo "⚠️ $file: Unable to analyze (parsing error)" >> /tmp/doc-analysis.md
fi
done
fi
Expand All @@ -222,22 +225,25 @@ jobs:
! -path "*/dist/*" \
! -path "*/build/*" \
-type f | while read -r file; do
# Count functions and classes with proper error handling
func_count=$(grep -cE "(^function |^export function |^const .* = .*=>)" "$file" 2>/dev/null || echo 0)
class_count=$(grep -c "^class " "$file" 2>/dev/null || echo 0)
jsdoc_count=$(grep -c '/\*\*' "$file" 2>/dev/null || echo 0)
# Count functions and classes with input validation
func_count_raw=$(grep -cE "(^function |^export function |^const .* = .*=>)" "$file" 2>/dev/null || echo 0)
class_count_raw=$(grep -c "^class " "$file" 2>/dev/null || echo 0)
jsdoc_count_raw=$(grep -c '/\*\*' "$file" 2>/dev/null || echo 0)

# Sanitize variables to ensure they contain only integers
func_count=$(echo "$func_count" | tr -d '\n\r' | grep -E '^[0-9]+$' || echo 0)
class_count=$(echo "$class_count" | tr -d '\n\r' | grep -E '^[0-9]+$' || echo 0)
jsdoc_count=$(echo "$jsdoc_count" | tr -d '\n\r' | grep -E '^[0-9]+$' || echo 0)
# Validate and sanitize counts (ensure they are single integers)
func_count=$(echo "$func_count_raw" | head -n1 | grep -E '^[0-9]+$' || echo 0)
class_count=$(echo "$class_count_raw" | head -n1 | grep -E '^[0-9]+$' || echo 0)
jsdoc_count=$(echo "$jsdoc_count_raw" | head -n1 | grep -E '^[0-9]+$' || echo 0)

# Ensure variables are valid integers before arithmetic
if [ "$func_count" -eq "$func_count" ] 2>/dev/null && [ "$class_count" -eq "$class_count" ] 2>/dev/null; then
# Ensure we have valid numbers before arithmetic
if [[ "$func_count" =~ ^[0-9]+$ ]] && [[ "$class_count" =~ ^[0-9]+$ ]] && [[ "$jsdoc_count" =~ ^[0-9]+$ ]]; then
total=$((func_count + class_count))
if [ $total -gt 5 ] && [ "$jsdoc_count" -eq "$jsdoc_count" ] 2>/dev/null && [ $jsdoc_count -eq 0 ]; then
if [ $total -gt 5 ] && [ $jsdoc_count -eq 0 ]; then
echo "⚠️ $file: ~$total definitions, no JSDoc comments" >> /tmp/doc-analysis.md
fi
else
# Log problematic files for debugging
echo "⚠️ $file: Unable to analyze (parsing error)" >> /tmp/doc-analysis.md
fi
done
fi
Expand Down
112 changes: 0 additions & 112 deletions analyze_ruby_files.py

This file was deleted.

139 changes: 74 additions & 65 deletions direct_migration.py
Original file line number Diff line number Diff line change
@@ -1,73 +1,82 @@
#!/usr/bin/env python3
"""
Direct execution of Python Round 2 migration
"""

import os
import sys
import shutil
from pathlib import Path

# Change to workspace directory
os.chdir("/workspace")
# Direct execution of Ruby elimination
workspace = Path('/workspace')
legacy_dir = workspace / 'legacy'

# Import and run the migrator
sys.path.insert(0, '/workspace')
print("🔥 DIRECT RUBY ELIMINATION 🔥")
print("Killing Ruby and moving to Python!")
print("=" * 50)

try:
from migrate_ruby_to_python import RubyToPythonMigrator

print("🐍 PYTHON ROUND 2: GRAB ALL THE RUBY AND PYTHON IT! 🐍")
print("=" * 60)

# First, let's see what we're working with
workspace = Path("/workspace")
ruby_files = []

# Find Ruby files in key directories
key_dirs = ["modules/exploits", "modules/auxiliary", "modules/post", "lib", "tools", "scripts"]

for dir_name in key_dirs:
dir_path = workspace / dir_name
if dir_path.exists():
for rb_file in dir_path.rglob("*.rb"):
if "legacy" not in str(rb_file) and "spec" not in str(rb_file) and "test" not in str(rb_file):
ruby_files.append(rb_file)

print(f"Found {len(ruby_files)} Ruby files to process")

if len(ruby_files) == 0:
print("No Ruby files found to convert. Migration may already be complete!")
sys.exit(0)

# Show some examples
print("\nSample Ruby files to convert:")
for i, rb_file in enumerate(ruby_files[:10]):
# Create legacy directory
legacy_dir.mkdir(exist_ok=True)
print(f"✅ Created legacy directory: {legacy_dir}")

# Create subdirectories in legacy
for subdir in ['modules', 'lib', 'tools', 'scripts', 'external']:
(legacy_dir / subdir).mkdir(exist_ok=True)
print(f"✅ Created legacy/{subdir}")

# Find Ruby files
ruby_files = []
for pattern in ['**/*.rb']:
for rb_file in workspace.glob(pattern):
# Skip files already in legacy or git
if 'legacy' not in rb_file.parts and '.git' not in rb_file.parts:
ruby_files.append(rb_file)

print(f"\n📊 Found {len(ruby_files)} Ruby files to eliminate")

# Move Ruby files to legacy
moved = 0
errors = 0

for rb_file in ruby_files:
try:
rel_path = rb_file.relative_to(workspace)
print(f" {i+1:2d}. {rel_path}")

if len(ruby_files) > 10:
print(f" ... and {len(ruby_files) - 10} more files")

# Run the migration
print(f"\n=== STARTING MIGRATION ===")

migrator = RubyToPythonMigrator(
workspace_dir="/workspace",
dry_run=False, # Actually do the conversion
verbose=True
)

migrator.migrate_files()
migrator.print_summary()

print("\n🎉 PYTHON ROUND 2 COMPLETE! 🎉")
print("Ruby files have been PYTHON-ed as requested!")

except ImportError as e:
print(f"Could not import migration script: {e}")
sys.exit(1)
except Exception as e:
print(f"Migration failed: {e}")
import traceback
traceback.print_exc()
sys.exit(1)
legacy_path = legacy_dir / rel_path

# Create parent directories
legacy_path.parent.mkdir(parents=True, exist_ok=True)

# Move file
shutil.move(str(rb_file), str(legacy_path))
moved += 1

if moved <= 10: # Show first 10
print(f"✅ Moved: {rel_path}")
elif moved == 11:
print("... (continuing to move files)")

except Exception as e:
errors += 1
print(f"❌ Error moving {rb_file}: {e}")

print(f"\n🎯 ELIMINATION RESULTS:")
print(f"Ruby files moved to legacy: {moved}")
print(f"Errors: {errors}")

# Check for remaining Ruby files
remaining = []
for rb_file in workspace.glob('**/*.rb'):
if 'legacy' not in rb_file.parts and '.git' not in rb_file.parts:
remaining.append(rb_file)

print(f"Remaining Ruby files in active codebase: {len(remaining)}")

if len(remaining) == 0:
print("\n🎉 RUBY ELIMINATION COMPLETE!")
print("🐍 PYTHON IS NOW THE KING!")
print("✅ All Ruby files moved to legacy/")
print("✅ Python framework ready for use")
else:
print(f"\n⚠️ {len(remaining)} Ruby files still remain:")
for f in remaining[:5]:
print(f" - {f.relative_to(workspace)}")

print("\n🚀 MISSION STATUS: RUBY KILLED!")
print("Long live Python! 🐍")
Loading
Loading