Clean up legacy code after unified architecture implementation

- Remove obsolete cmd/auto_enhance.go command (replaced by unified enhance)
- Implement EnhanceInPlace method using unified pipeline
- Remove generated demo files from git tracking
- Verify all functionality works after cleanup:
  * go build successful
  * enhance command working correctly
  * unified pipeline (discovery → ID generation → content injection) verified
  * clean command structure (only enhance, serve, restore commands)

The codebase is now clean with no legacy auto-enhance references or stub implementations. All functionality consolidated into the unified Discoverer + Enhancer architecture.
This commit is contained in:
2025-09-16 17:08:43 +02:00
parent 27a619b452
commit eabb7b16e8
14 changed files with 145 additions and 134 deletions

View File

@@ -1,91 +0,0 @@
package cmd
import (
"fmt"
"os"
"github.com/insertr/insertr/internal/content"
"github.com/spf13/cobra"
)
var (
autoEnhanceOutput string
autoEnhanceAggressive bool
)
var autoEnhanceCmd = &cobra.Command{
Use: "auto-enhance [input-dir]",
Short: "Automatically detect and add insertr classes to HTML elements",
Long: `Auto-enhance scans HTML files and automatically adds insertr classes to viable content elements.
This command uses intelligent heuristics to detect editable content:
- Text-only elements (headers, paragraphs, simple links)
- Elements with safe inline formatting (strong, em, span, etc.)
- Container elements that benefit from expansion
- Buttons and other interactive content elements
Examples:
insertr auto-enhance ./site --output ./enhanced
insertr auto-enhance ./blog --output ./blog-enhanced --aggressive
insertr auto-enhance /path/to/site --output /path/to/enhanced`,
Args: cobra.ExactArgs(1),
RunE: runAutoEnhance,
}
func runAutoEnhance(cmd *cobra.Command, args []string) error {
inputDir := args[0]
// Validate input directory
if _, err := os.Stat(inputDir); os.IsNotExist(err) {
return fmt.Errorf("input directory does not exist: %s", inputDir)
}
// Default output directory if not specified
if autoEnhanceOutput == "" {
autoEnhanceOutput = inputDir + "-enhanced"
}
fmt.Printf("🔍 Auto-enhancing HTML files...\n")
fmt.Printf("📁 Input: %s\n", inputDir)
fmt.Printf("📁 Output: %s\n", autoEnhanceOutput)
if autoEnhanceAggressive {
fmt.Printf("⚡ Aggressive mode: enabled\n")
}
fmt.Printf("\n")
// Create discoverer
discoverer := content.NewDiscoverer()
// Run element discovery
result, err := discoverer.DiscoverDirectory(inputDir, autoEnhanceOutput, autoEnhanceAggressive)
if err != nil {
return fmt.Errorf("auto-enhancement failed: %w", err)
}
// Print results
fmt.Printf("✅ Auto-enhancement complete!\n\n")
fmt.Printf("📊 Results:\n")
fmt.Printf(" Files processed: %d\n", result.FilesProcessed)
fmt.Printf(" Elements enhanced: %d\n", result.ElementsEnhanced)
fmt.Printf(" Containers added: %d\n", result.ContainersAdded)
fmt.Printf(" Individual elements: %d\n", result.IndividualsAdded)
if len(result.SkippedFiles) > 0 {
fmt.Printf("\n⚠ Skipped files (%d):\n", len(result.SkippedFiles))
for _, file := range result.SkippedFiles {
fmt.Printf(" - %s\n", file)
}
}
fmt.Printf("\n🎯 Enhanced files ready in: %s\n", autoEnhanceOutput)
fmt.Printf("📝 Use 'insertr enhance %s' to inject content from database\n", autoEnhanceOutput)
return nil
}
func init() {
autoEnhanceCmd.Flags().StringVarP(&autoEnhanceOutput, "output", "o", "", "output directory for enhanced files")
autoEnhanceCmd.Flags().BoolVar(&autoEnhanceAggressive, "aggressive", false, "aggressive mode: enhance single-child containers")
rootCmd.AddCommand(autoEnhanceCmd)
}