Genkit Setup & Configuration
Relevant source files
The following files were used as context for generating this wiki page:
Genkit Setup & Configuration defines the integration of Google's AI framework within the KernelForge application to provide automated log analysis. The system enables the AI Troubleshooting Assistant, which scans kernel build logs for errors related to GKI/KMI compatibility and patch failures. Because the application exports as a static Android APK, the current implementation uses a mock service to simulate AI responses when a remote backend is unavailable.
Sources: README.md, src/ai/flows/ai-build-troubleshooting-assistant.ts:4-6
Core AI Initialization
The application initializes the Genkit instance using the Google AI plugin. The configuration targets the gemini-2.5-flash model for processing AI requests.
import {genkit} from 'genkit';
import {googleAI} from '@genkit-ai/google-genai';
export const ai = genkit({
plugins: [googleAI()],
model: 'googleai/gemini-2.5-flash',
});
Sources: src/ai/genkit.ts:1-7
AI Troubleshooting Flow
The troubleshooting system follows a defined schema for inputs and outputs. It accepts kernel build logs and device metadata, then produces a summary with identified errors and suggested fixes.
Data Structures
The system uses specific schemas to validate the data passed to the AI model.
| Field | Type | Description |
|---|---|---|
buildLog | String | The raw text output from the kernel compilation process. |
deviceInfo | Object | Metadata including model, codename, GKI version, and KMI version. |
summary | String | A high-level overview of the build status or errors found. |
identifiedErrors | Array | A list of specific strings representing detected build failures. |
suggestedSolutions | Array | A list of actionable steps to resolve the identified errors. |
Sources: src/ai/flows/ai-build-troubleshooting-assistant.ts:8-28
Workflow Logic
The application triggers the analysis through the user interface. The AITroubleshooter component handles the execution state and displays results.
The diagram shows the logic flow from user interaction to result rendering in the AI dashboard.
Sources: src/components/dashboard/AITroubleshooter.tsx:20-33
Development and CLI Integration
KernelForge includes specific scripts to manage the Genkit environment during development. These scripts utilize the genkit-cli and tsx to run the AI flows.
- genkit:dev: Starts the Genkit development server using
src/ai/dev.ts. - genkit:watch: Starts the server in watch mode for live code changes.
Sources: package.json:7-8, src/ai/dev.ts:1-4
Static Export Limitations
Since KernelForge is packaged as a static Android APK via Capacitor, the aiBuildTroubleshootingAssistant function currently operates in a mock mode. It returns a simulated response after a 2000ms delay to account for the lack of a local Node.js backend in the mobile environment.
The sequence diagram illustrates the communication between the UI and the mock flow during a static deployment.
Sources: src/ai/flows/ai-build-troubleshooting-assistant.ts:30-48, README.md
Dashboard Integration
The AI features are accessed via the "ai" tab in the main dashboard. The KernelcrafterDashboard component passes the accumulated logsText to the AITroubleshooter to ensure the AI has the most recent compilation data.
- File Path:
src/app/page.tsx - Logic: The
logsstate is mapped to a string format:[timestamp] message. - Interaction: Users switch to the AI tab to view the analysis of the logs generated in the "compilation" or "dashboard" tabs.
Sources: src/app/page.tsx:162-164, src/app/page.tsx:438-442
Genkit Setup & Configuration provides the framework for intelligent debugging in KernelForge. While currently limited by static deployment constraints, the architecture is prepared for full Google AI integration via defined flows and model configurations.