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
- Get Google Gemini API Key: AccessGoogle API StudioGet the API key.
- Install askrepo: Install askrepo by running the following command in a terminal:
cargo install askrepo
- Setting the API key: Set environment variables in the terminal to use the API key:
export GOOGLE_API_KEY="YOUR_API_KEY"
Usage
- Basic use: Run the following command in the terminal to analyze the source code in the specified directory and generate comments:
askrepo --prompt "Interpret the code in the provided file" --model "gemini-1.5-flash" . /src
- Customized tips: Can be done through
--prompt
Parameter customization issues, for example:
askrepo --prompt "What is the purpose of this code?" ---model "gemini-1.5-flash" . /src
- Specify the model: Can be done through
---model
The parameter specifies the Google AI model used, for example:
askrepo --model "gemini-1.5-flash" . /src
- Finding Code Errors: Use the following command to find potential errors in the code:
askrepo --prompt "Find errors in this code" --model "gemini-1.5-flash" . /src
Detailed function operation flow
- 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.
- Build Tips: Construct hints based on document information, questions and extracted source code content.
- Send Request: Send the prompt to the Google Gemini API for analysis.
- parse the response: Parses the JSON response returned by the API and extracts the generated text.
- output result: Output the generated text to the terminal to help developers understand the code or find errors.