Tasks
AIGuardian Documentation
Loading update info...
View on GitHubTask 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. Organized by project type - Common tasks apply to all projects, while language-specific tasks are only available for relevant project types
- 2. Independently executable - Each task can be run individually or as part of a batch
- 3. Self-contained - Tasks handle their own dependencies and operations
- 4. Consistently structured - All tasks follow the same interface pattern
- 1. Maintains a catalog of all available tasks
- 2. Maps tasks to project types
- 3. Handles task retrieval and execution
- 4. Manages task dependencies and execution order
- 1. Project Detection - The project type is detected based on files and directory structure
- 2. Task Selection - Available tasks for the detected project type are identified
- 3. Dependency Resolution - Task dependencies are resolved and ordered
- 4. Execution - Tasks are executed in the correct order
- 5. Reporting - Results are reported back to the user
- 1. Creating a new task module in the appropriate directory
- 2. Implementing the task interface
- 3. Registering the task with the task registry
- 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
Task Registry
The task registry is the central system that:
Available Task Categories
Common Tasks
These tasks apply to all project types:
Task ID | Description | |||
---|---|---|---|---|
clean-temp | Removes temporary files and directories | |||
normalize-line-endings | Ensures consistent line endings across all files | |||
optimize-gitignore | Improves .gitignore files with best practices | |||
format-code | Formats code according to best practices | JavaScript/TypeScript Tasks | Task ID | Description |
--------- | ------------- | |||
js-to-ts | Converts JavaScript files to TypeScript | |||
optimize-npm-deps | Analyzes and optimizes npm dependencies | |||
clean-node-modules | Safely cleans node_modules directory | Python Tasks | Task ID | Description |
--------- | ------------- | |||
clean-pycache | Removes __pycache__ directories | |||
optimize-requirements | Optimizes requirements.txt files | |||
format-python | Formats Python code using Black | Java Tasks | Task ID | Description |
--------- | ------------- | |||
clean-build | Cleans build artifacts | |||
optimize-maven-deps | Optimizes Maven dependencies |
format-java
| Formats Java code |Task Execution Flow
When AIGuardian runs, the task execution follows this flow:
Creating Custom Tasks
Advanced users can create custom tasks by:
See the Custom Tasks guide for detailed instructions.
Best Practices
Was this page helpful?