cvkg-render-native 0.1.3

Cyberpunk Viking Knowledge Graph (CVKG) - High-fidelity agentic UI framework
Documentation
//! # CVKG Agentic Development Guidelines (v1.2)
//!
//! All AI agents contributing to this crate MUST follow ALL seven rules:
//!
//! ── Karpathy Guidelines (1–4) ────────────────────────────────────────────
//! 1. THINK FIRST     — State assumptions. Surface ambiguity. Push back on complexity.
//! 2. STAY SIMPLE     — Minimum code. No speculative features. No unasked-for abstractions.
//! 3. BE SURGICAL     — Touch only what's required. Own your orphans. Don't improve neighbors.
//! 4. VERIFY GOALS    — Turn tasks into checkable criteria. Loop until they pass. Never commit broken.
//!
//! ── CVKG Extended Protocols (5–7) ────────────────────────────────────────
//! 5. TRIPLE-PASS     — Read the target, its surrounding context, and its full call graph
//                      at least THREE TIMES before making any edit or revision.
//! 6. COMMENT ALL     — Every major pub fn, unsafe block, and non-trivial algorithm in
//                      every .rs/.ts/.h/.wgsl file MUST have a descriptive doc comment.
//                      Comments describe WHY and WHAT CONTRACT, not HOW mechanically.
//! 7. MONITOR LOOPS   — Check every tool call / command for progress every 30 seconds.
//                      After 3 consecutive identical failures, stop, write BLOCKED.md,
//                      and move to unblocked work. Never silently accept a broken state.
//!
//! Sources:
//   Karpathy: https://github.com/multica-ai/andrej-karpathy-skills
//   CVKG Extended: Section 2 of the CVKG Design Specification

//! Platform-native widget delegation using winit and AccessKit
//!
//! This crate provides platform-specific rendering backends for native desktop targets
//  using winit for window/event handling and AccessKit for accessibility tree integration.

use cvkg_core::Rect;
use winit::event_loop::EventLoop;

/// Native renderer backend implementing the CvkgRenderer trait
pub struct NativeRenderer {
    window: Option<winit::window::Window>,
    event_loop: Option<EventLoop<()>>,
    accesskit_tree: Option<accesskit::Tree>,
}

impl NativeRenderer {
    #[doc(hidden)]
    pub fn new() -> Self {
        Self {
            window: None,
            event_loop: None,
            accesskit_tree: None,
        }
    }
}

/// Abstract trait that all renderer backends must implement
pub trait CvkgRenderer: Send + Sync {
    fn begin_frame(&mut self, size: winit::dpi::PhysicalSize<u32>, scale: f32);
    fn end_frame(&mut self);

    fn fill_rect(&mut self, rect: Rect, color: [f32; 4]);
    fn stroke_rect(&mut self, rect: Rect, color: [f32; 4], stroke_width: f32);
    fn fill_rounded_rect(&mut self, rect: Rect, radius: f32, color: [f32; 4]);
    fn draw_text(&mut self, text: &str, x: f32, y: f32, color: [f32; 4]);
}

// TODO: Implement actual native rendering with winit and AccessKit integration
// TODO: Platform-specific implementations for macOS, Windows, and Linux