Utility Commands

VritraAI provides a collection of utility commands for file hashing, text encoding/decoding, file validation, code formatting, feedback submission, and session management. These tools help with common development and system administration tasks.

File Hashing

hash <file> [algorithm]

Calculate cryptographic hash of a file. Useful for file integrity verification, checksums, and security purposes.

Supported Algorithms:

  • md5 - MD5 hash (128-bit)
  • sha1 - SHA-1 hash (160-bit)
  • sha256 - SHA-256 hash (256-bit, default)

Features:

  • Efficient chunk-based reading for large files
  • Error recovery with helpful messages
  • SHA-256 as default (most secure)
  • Hexadecimal hash output

Parameters:

  • file - Path to the file to hash
  • algorithm - (Optional) Hash algorithm (md5, sha1, sha256). Defaults to sha256

Examples:

# Calculate SHA-256 hash (default)
hash file.txt

# Calculate MD5 hash
hash file.txt md5

# Calculate SHA-1 hash
hash file.txt sha1

# Hash a Python script
hash script.py sha256

Text Encoding & Decoding

encode <method> <text>

Encode text using various encoding methods. Useful for data transformation, URL encoding, and data obfuscation.

Supported Methods:

  • base64 - Base64 encoding
  • url - URL encoding (percent encoding)
  • hex - Hexadecimal encoding

Examples:

# Base64 encoding
encode base64 Hello World

# URL encoding
encode url https://example.com/page?q=hello world

# Hexadecimal encoding
encode hex Hello

decode <method> <text>

Decode text that was encoded using various methods. Reverses the encoding process.

Supported Methods:

  • base64 - Base64 decoding
  • url - URL decoding (percent decoding)
  • hex - Hexadecimal decoding

Examples:

# Base64 decoding
decode base64 SGVsbG8gV29ybGQ=

# URL decoding
decode url https%3A%2F%2Fexample.com%2Fpage

# Hexadecimal decoding
decode hex 48656c6c6f

File Validation

validate <file>

Validate file syntax or format. Currently supports Python and JSON files. For unsupported file types, uses AI to validate if available.

Supported File Types:

  • .py - Python syntax validation using AST parser
  • .json - JSON format validation
  • Other types: Uses AI validation if AI is enabled

Features:

  • Python AST parsing for syntax validation
  • JSON parsing for format validation
  • AI-powered validation for unsupported types
  • Clear success/error messages

Examples:

# Validate Python file
validate script.py

# Validate JSON file
validate config.json

# Validate other file types (uses AI)
validate data.xml

Note: For file types other than Python and JSON, AI validation is used if AI is enabled. This provides flexible validation for various file formats.

Code Formatting

format <python_file.py>

Format Python code files using black or autopep8. Creates a formatted output file with _formatted.py suffix. Only supports Python files.

Features:

  • Uses black if available (preferred)
  • Falls back to autopep8 if black is not available
  • Creates output file: <filename>_formatted.py
  • Preserves original file
  • Only supports Python (.py) files

Requirements:

  • black or autopep8 must be installed
  • File must be a Python (.py) file

Examples:

# Format Python file
format script.py
# Creates: script_formatted.py

# Format with black (if installed)
format app.py

# Format with autopep8 (if black not available)
format utils.py

Note: This command only supports Python (.py) files. The formatted output is saved to a new file with _formatted.py suffix, preserving your original file.

Session Management

session [subcommand]

Manage session data including command history, modified files, and session statistics. Useful for tracking your work and exporting session information.

Usage Modes:

  • session - Show current session information and statistics
  • session save [filename] - Save session data to JSON file
  • session clear - Clear current session data

Session Information Includes:

  • Session start time
  • Commands executed
  • Modified files
  • Session duration
  • Statistics and summaries

Examples:

# Show session information
session

# Save session to default filename
session save

# Save session to custom filename
session save my_session.json

# Clear session data
session clear

Command History

history [number]

Show command history with timestamps. Displays all commands or the last N commands. Supports piping to head and tail commands for filtering.

Usage Modes:

  • history - Show all command history with timestamps
  • history <number> - Show last N commands
  • history | head <n> - Show first N commands from history
  • history | tail <n> - Show last N commands from history

Features:

  • Automatic timestamp recording for every command
  • Duplicate prevention with file locking to ensure data integrity
  • Formatted timestamp display (YYYY-MM-DD HH:MM:SS.microseconds)
  • Accurate command counting (only counts actual commands, not timestamps)
  • Supports piping to head and tail for filtering
  • Colored output with Rich formatting for better readability
  • Persistent history across sessions

History Format:

Each command is recorded with a timestamp in the format:

  • # YYYY-MM-DD HH:MM:SS.microseconds - Timestamp line
  • +command - Command line (prefixed with +)

Examples:

# Show all command history
history

# Show last 10 commands
history 10

# Show first 5 commands using head
history | head 5

# Show last 3 commands using tail
history | tail 3

# Show last 5 commands
history 5

Note: Commands are automatically recorded with timestamps when executed. The history system uses file locking to prevent duplicate entries and ensure data integrity. Piped output (with head or tail) maintains the same colored formatting as the standard history display.

Feedback

feedback

Launch an interactive feedback form to send feedback, bug reports, or feature requests to the VritraAI team. Helps improve the tool based on user input.

Features:

  • Interactive feedback form
  • Automatic submission to configured worker endpoint
  • Supports bug reports, feature requests, and general feedback

Examples:

# Launch feedback form
feedback

Note: Feedback is sent to the configured feedback worker endpoint. Your feedback helps improve VritraAI!

Best Practices

  • File integrity: Use hash to verify file integrity and detect corruption
  • Data encoding: Use encode/decode for data transformation tasks
  • Code quality: Use validate before committing code to catch syntax errors
  • Code formatting: Use format to maintain consistent code style
  • Session tracking: Use session save to export your work session
  • Command recall: Use history to find previously executed commands
  • Contribute: Use feedback to report bugs or suggest features

💡 Pro Tip: Combine utilities for powerful workflows. For example, validate a file, format it, then hash it to verify the formatted version matches expected output!