Open farhoud opened 1 month ago
@rekino do we agree on the input for index?
@amrhssn are we on the same page on the provided response?
@farhoud This is neat! I like it 🙌🏻
@amrhssn Does user need to provide a project as an optional input?
do we need to change the Response to:
{
"status": "success",
"results": [
{
"project": "path or name?"
"file": "utils.py",
"line": 10,
"code": "def factorial(n):"
},
{
"project": "path or name?"
"file": "math_helpers.py",
"line": 5,
"code": "def compute_factorial(number):"
}
]
}
@rekino do we agree on the input for index?
@farhoud According to ast module standards, we need to keep the column number and end line as well as the start line number to uniquely specify a piece of code in a pyhton file.
Stories
user can index a project by providing a project path and main function to lattice user can search for code in human language
Lattice HTTP API Documentation
Base URL
we can also use http over linux socket
Endpoints
1. Index Project
Index a project by providing the project path and main function.
Endpoint
Request Body
Example Request
Response
2. Search Code
Search for code in human language.
Endpoint
Query Parameters
query
(required): The search query in human language.Example Request
Response
Detailed Endpoint Descriptions
Index Project Endpoint
Description: This endpoint allows you to index a project, making it searchable by the Lattice system.
HTTP Method:
POST
URL:
/index
Request Body:
path
(string, required): The path to the project directory you want to index.main
(string, required): The main function or entry point of your project.Example Request:
Example Response:
Search Code Endpoint
Description: This endpoint allows you to search your indexed codebase using human language.
HTTP Method:
GET
URL:
/search
Query Parameters:
query
(string, required): The search query in human language describing what you are looking for.Example Request:
Example Response:
Error Handling
Common Errors
400 Bad Request
404 Not Found
500 Internal Server Error
Conclusion
This HTTP API allows you to index projects and search for code using human language, facilitating easy navigation and management of your codebase. Follow the endpoint guidelines and examples to integrate these capabilities into your applications.
Lattice CLI Documentation
Overview
The Lattice CLI allows you to index your projects and search for code using human language. This makes it easier to manage and navigate through your codebase, especially for larger projects.
Commands
1.
index
Index a project by providing the project path and main function to Lattice.
Usage
Arguments
--path
(required): The path to the project directory you want to index.--main
(required): The main function or entry point of your project.Example
2.
search
Search for code in human language.
Usage
Arguments
--query
(required): The search query in human language describing what you are looking for.Example
Detailed Command Descriptions
Index Command
The
index
command allows you to index your project, making it searchable by the Lattice system. This is useful for setting up your project in Lattice so that you can leverage advanced search capabilities.Steps to Use
index
command with the appropriate arguments.Example Explained
/home/user/projects/my_project
.app.py
as the main function or entry point for the project.Search Command
The
search
command enables you to search your indexed codebase using human language. This makes it easier to find specific functions, classes, or code snippets without having to remember exact code syntax or file locations.Steps to Use
index
command.search
command with your query.Example Explained
Troubleshooting
Common Issues
Project Not Indexed
index
command before attempting to use thesearch
command.No Results Found
Getting Help
For additional help, use the
--help
flag with any command to display usage information.Conclusion
The Lattice CLI simplifies the process of navigating and managing your codebase by enabling human language search and efficient project indexing. Follow the usage guidelines and examples to make the most out of these powerful features.