AI Personal Learning
and practical guidance
豆包Marscode1

askrepo: source code reading tool, using LLM to analyze the code, provide detailed code explanations, support for a variety of programming languages

General Introduction

askrepo is a source code reading tool based on the LLM (Large Language Model). It can read the contents of a Git-managed text file in a specified directory and send it to a Google Gemini API that provides answers to questions based on specified prompts. The tool is designed to help developers better understand and analyze source code and supports multiple programming languages.

 

Function List

  • Source code reading: Reads the contents of a Git-managed text file.
  • code analysis: Code analysis using the Google Gemini API.
  • Problem solving: Provide answers to questions based on specified prompts.
  • Multi-language support: Multiple programming languages are supported.
  • command-line tool: Provides command line tools for developers to use.
  • Detailed Code Explanation: Provide detailed code explanations to help developers better understand the code.

 

Using Help

Installation process

  1. Get Google Gemini API Key: AccessGoogle API StudioGet the API key.
  2. Install askrepo: Install askrepo by running the following command in a terminal:
复制复制复制复制复制复制复制
复制
   cargo install askrepo
  1. Setting the API key: Set environment variables in the terminal to use the API key:
复制复制复制复制复制复制
复制
   export GOOGLE_API_KEY="YOUR_API_KEY"

Usage

  1. Basic use: Run the following command in the terminal to analyze the source code in the specified directory and generate comments:
复制复制复制复制复制
复制
   askrepo --prompt "解释提供的文件中的代码" --model "gemini-1.5-flash" ./src
  1. Customized tips: Can be done through--promptParameter customization issues, for example:
复制复制复制复制
复制
   askrepo --prompt "这段代码的目的是什么?" --model "gemini-1.5-flash" ./src
  1. Specify the model: Can be done through--modelThe parameter specifies the Google AI model used, for example:
复制复制复制
复制
   askrepo --model "gemini-1.5-flash" ./src
  1. Finding Code Errors: Use the following command to find potential errors in the code:
复制复制
复制
   askrepo --prompt "查找这段代码中的错误" --model "gemini-1.5-flash" ./src

Detailed function operation flow

  1. Read the contents of the file: askrepo reads all Git-managed text files in the specified directory and formats their contents into a form suitable for querying.
  2. Build Tips: Construct hints based on document information, questions and extracted source code content.
  3. Send Request: Send the prompt to the Google Gemini API for analysis.
  4. parse the response: Parses the JSON response returned by the API and extracts the generated text.
  5. output result: Output the generated text to the terminal to help developers understand the code or find errors.

May not be reproduced without permission:Chief AI Sharing Circle " askrepo: source code reading tool, using LLM to analyze the code, provide detailed code explanations, support for a variety of programming languages
en_USEnglish