AIGuardian
Back to Home

Tasks

AIGuardian Documentation

Loading update info...
View on GitHub

Task System

AIGuardian uses a task-based architecture to organize and execute code optimization operations. This document explains how the task system works and how to use it effectively.

Task Architecture

Each optimization operation in AIGuardian is implemented as a standalone task with a consistent interface. Tasks are:

  1. 1. Organized by project type - Common tasks apply to all projects, while language-specific tasks are only available for relevant project types
  1. 2. Independently executable - Each task can be run individually or as part of a batch
  1. 3. Self-contained - Tasks handle their own dependencies and operations
  1. 4. Consistently structured - All tasks follow the same interface pattern
  2. Task Registry

    The task registry is the central system that:

    1. 1. Maintains a catalog of all available tasks
    1. 2. Maps tasks to project types
    1. 3. Handles task retrieval and execution
    1. 4. Manages task dependencies and execution order
    2. Available Task Categories

      Common Tasks

      These tasks apply to all project types:

      Task IDDescription
      clean-tempRemoves temporary files and directories
      normalize-line-endingsEnsures consistent line endings across all files
      optimize-gitignoreImproves .gitignore files with best practices
      format-codeFormats code according to best practices

      JavaScript/TypeScript Tasks

      Task IDDescription
      ----------------------
      js-to-tsConverts JavaScript files to TypeScript
      optimize-npm-depsAnalyzes and optimizes npm dependencies
      clean-node-modulesSafely cleans node_modules directory

      Python Tasks

      Task IDDescription
      ----------------------
      clean-pycacheRemoves __pycache__ directories
      optimize-requirementsOptimizes requirements.txt files
      format-pythonFormats Python code using Black

      Java Tasks

      Task IDDescription
      ----------------------
      clean-buildCleans build artifacts
      optimize-maven-depsOptimizes Maven dependencies
      | format-java | Formats Java code |

      Task Execution Flow

      When AIGuardian runs, the task execution follows this flow:

      1. 1. Project Detection - The project type is detected based on files and directory structure
      1. 2. Task Selection - Available tasks for the detected project type are identified
      1. 3. Dependency Resolution - Task dependencies are resolved and ordered
      1. 4. Execution - Tasks are executed in the correct order
      1. 5. Reporting - Results are reported back to the user
      2. Creating Custom Tasks

        Advanced users can create custom tasks by:

        1. 1. Creating a new task module in the appropriate directory
        1. 2. Implementing the task interface
        1. 3. Registering the task with the task registry
        2. See the Custom Tasks guide for detailed instructions.

          Best Practices

          • Run tasks in a logical order (cleaning tasks before optimization tasks)
          • Use --dry-run to preview changes before applying them
          • Create backups before running destructive tasks
          • Use task-specific options to customize behavior

Was this page helpful?