API Reference

Complete guide to the PhantomDev core library.

Overview

PhantomDev provides a modular architecture. While most users will interface through the CLI, developers can integrate the specific underlying engines into their own Rust projects.

Crate Structure

  • phantomdev-core: Core types and traits.
  • phantomdev-detector: AI stylometry detection engine.
  • phantomdev-humanizer: Code humanization tools.
  • phantomdev-undercover: Adversarial rewrite tools.
  • phantomdev-jitter: Temporal obfuscation features.
  • phantomdev-tui: The terminal UI dashboard implementation.

Detector API

Use the detection engine to analyze code for AI-generated patterns.

use phantomdev_detector::PhantomDetector; use phantomdev_core::{CodeBlock, Language}; fn main() -> anyhow::Result<()> { let detector = PhantomDetector::new()?; let code = CodeBlock { path: "src/main.rs".into(), language: Language::Rust, content: "fn main() { println!(\"Hello World\"); }".into(), line_range: (1, 1), }; let result = detector.detect(&code)?; println!("AI Probability: {:.2}%", result.score.ai_probability * 100.0); Ok(()) }

Humanizer API

Transform code to match your personal style.

use phantomdev_humanizer::PhantomHumanizer; fn main() -> anyhow::Result<()> { let humanizer = PhantomHumanizer::new(); let repo_path = std::env::current_dir()?; // Learn style profile from git history let profile = humanizer.learn_style(&repo_path)?; // Use it to humanize code // let humanized_code = humanizer.humanize(&code_block, &profile)?; Ok(()) }

Undercover API

Apply adversarial stylometry transformations.

use phantomdev_undercover::UndercoverTransformer; fn main() -> anyhow::Result<()> { let transformer = UndercoverTransformer::new(); // Transform commit message let original = "feat: Implement comprehensive user authentication"; let transformed = transformer.transform_message(original)?; println!("Original: {}", original); println!("Transformed: {}", transformed); Ok(()) }

Jitter API

Add temporal obfuscation to simulate organic development pace.

use phantomdev_jitter::JitterEngine; fn main() -> anyhow::Result<()> { let jitter = JitterEngine::new(60, 300); // min 60s, max 300s // Get a random delay let delay = jitter.random_delay(); println!("Waiting {} seconds...", delay.as_secs()); std::thread::sleep(delay); Ok(()) }

Core Types

Common types used across all PhantomDev crates.

CodeBlock

Represents a block of code with metadata including path, language, content, and line range.

Language

Enum representing supported programming languages (Rust, Python, JavaScript, TypeScript, Go, C++).

DetectionResult

Result of AI detection including probability score, detected patterns, and confidence level.

StyleProfile

Learned coding style profile including naming conventions, comment patterns, and formatting preferences.

Full Documentation

For extensive API documentation with examples, run:

cargo doc --open

This will generate and open the Rust documentation in your browser.