👋 ¡Hola! Soy tu asistente de desarrollo.Estoy aquí para ayudarte con:🔎 Explicar la arquitectura de tu proyecto📝 Analizar commits y cambios recientes🌿 Resolver dudas sobre Git🤖 Ejecutar operaciones del asistente Chapi
The AI analyzes your code changes and generates professional commit messages:
How It Works
Prompt Engineering
Example Output
public class GenerateCommitMessageUseCase{ private readonly IChatClient _chatClient; public async Task<Result<string>> ExecuteAsync(string diffContent) { // Build prompt with diff content var prompt = GetPrompt.GitCommit(diffContent); // Call Gemini API var messages = new List<ChatMessage> { new ChatMessage(ChatRole.User, prompt) }; var response = await _chatClient.CompleteAsync(messages); return Result<string>.Success(response.Message.Text); }}
Chapi uses a carefully crafted prompt for Conventional Commits:
public static string GitCommit(string diffContent){ return $@" Analiza el siguiente 'diff' y genera un mensaje de commit profesional en español según el estándar Conventional Commits. Reglas: - Retorna SÓLO un objeto JSON válido - Estructura: {{ "summary": "...", "description": "..." }} - Summary: Una línea, 72 caracteres máximo - Description: 1-2 frases + lista de cambios importantes Tipos: - 'feat': Nuevas funciones - 'fix': Corrección de errores - 'refactor': Limpieza de código - 'chore': Mantenimiento Diff: {diffContent} ";}
Input diff:
+ public async Task<Result> AuthenticateAsync()+ {+ var authUrl = BuildAuthUrl();+ Process.Start(authUrl);+ var code = await ListenForCallback();+ return await ExchangeToken(code);+ }
public string BuildConversationHistory(ConversationContext context){ var history = new StringBuilder(); history.AppendLine("=== CONVERSATION HISTORY ==="); foreach (var msg in context.ConversationHistory.TakeLast(5)) { var author = msg.Author == MessageAuthor.User ? "Usuario" : "Asistente"; history.AppendLine($"{author}: {msg.Text}"); } return history.ToString();}
3
Capability Awareness
The AI knows what actions it can perform:
public string BuildCapabilitiesInfo(){ var capabilities = new StringBuilder(); capabilities.AppendLine("=== YOUR CAPABILITIES ==="); foreach (var cap in _capabilityRegistry.GetAllCapabilities()) { capabilities.AppendLine( $"- ID: {cap.Id} | Description: {cap.Description}" ); } return capabilities.ToString();}
# Commit changes"Commit all changes with a professional message""Create a commit and push to remote"# Branch management"Create a new branch called feature/auth""Switch to the develop branch"# Status queries"What files did I change?""Show me my recent commits""Am I behind the remote?"
# Create projects"Create a new API called UserService in C:\\Projects"# Clone repositories"Clone https://github.com/user/repo.git to C:\\Projects"# List projects"Show me all my projects""What projects do I have?"
# Architecture questions"Explain the architecture of this project""What's the folder structure?"# Code understanding"What does this commit change?""Explain the recent modifications"# Guidance"How do I add a new module?""Best practices for this codebase?"
public async Task<Result<ChatMessage>> ProcessUserMessageAsync( string userMessage, Action<string>? onTokenReceived = null){ // Get AI response with streaming var result = await _geminiChatService.SendMessageAsync( userMessage, context, onTokenReceived ); // Parse action from response // Format: [[ACTION:{"type":"git.commit","params":{...}}]] var action = ExtractActionFromResponse(result.Data); if (action != null) { // Create actionable message with button return new ChatMessage { Text = result.Data, Author = MessageAuthor.Assistant, Action = new UserIntent { CapabilityId = action.Type, Parameters = action.Params } }; } return new ChatMessage { Text = result.Data };}
Example interaction:
User: "Commit my changes with a good message"Assistant: "I'll create a professional commit for your changes.You modified:- src/Services/AuthService.cs- src/Controllers/AuthController.csProposed message:feat(auth): implement OAuth2 authentication flowAdd OAuth2 authentication with GitHub provider:- Create AuthService with token exchange- Add login endpoint to AuthController- Implement secure credential storageWould you like me to commit these changes?[Execute Commit]"
public async Task<Result<string>> SendMessageAsync( string userMessage, ConversationContext context, Action<string>? onTokenReceived = null){ var fullPrompt = GetPrompt.ChatAssistant( contextInfo, conversationHistory, capabilitiesInfo, userMessage ); var messages = new List<ChatMessage> { new ChatMessage(ChatRole.User, fullPrompt) }; var fullResponseBuilder = new StringBuilder(); // Stream tokens as they arrive await foreach (var update in chatClient.GetStreamingResponseAsync(messages)) { if (update.Contents[0] is TextContent textContent) { var token = textContent.Text; fullResponseBuilder.Append(token); onTokenReceived?.Invoke(token); // Update UI in real-time } } return Result<string>.Success(fullResponseBuilder.ToString());}
This provides a ChatGPT-like typing effect in the UI.
Chapi can analyze stored procedures and generate code:
public static string AnalyzeEmail( string moduleName, string methodName, string emailContent, string database, string methodType){ return $@" Analiza el siguiente correo técnico y extrae información del Stored Procedure. CONTEXTO: - Módulo: {moduleName} - Método: {methodName} - Base de datos: {database} CORREO TÉCNICO: {emailContent} INSTRUCCIONES: Retorna JSON con: - StoredProcedureName: Nombre del SP - RequestParameters: Parámetros de entrada (C# DTOs) - DtoFields: Campos de respuesta - ResponseMapper: Mapeo de campos Usa convenciones: - Campos CODE terminan con 'Code' - Campos NAME terminan con 'Name' - Campos FLAG inician con 'fla' - Todo en camelCase ";}
You can modify prompts in GetPrompt.cs for different behavior:
public static string ChatAssistant( string contextInfo, string conversationHistory, string capabilitiesInfo, string userMessage){ return $@" Eres un asistente de desarrollo integrado en Chapi Assistant. TU PERSONALIDAD: - Hablas en español de forma natural y amigable - Eres experto en desarrollo de software, Git, y arquitectura TUS CAPACIDADES: {capabilitiesInfo} {contextInfo} {conversationHistory} MENSAJE DEL USUARIO: {userMessage} ";}