Code Search
The Code Search Action in Glean allows users to search through their deployment’s GitHub or GitLab code repositories directly from Glean’s interface. This functionality is designed to assist with various code-related tasks, such as:
- Finding and Understanding Code: Helps users locate specific code snippets, understand code changes, and navigate through code repositories.
- Creating Code Snippets: Allows users to generate code snippets based on their queries.
- Debugging: Assists in identifying recent changes that may be causing errors by searching through recent pull requests and commits.
- Feature Status Checks: Provides information on whether certain features have been implemented and how they can be enabled by searching related code files and documentation.
Usage Examples
-
Debugging Errors: A user can search for recent code changes that might have introduced errors into a specific component. The tool will look through recent commits and pull requests to identify potential causes and summarize them.
Example: “What recent changes could have caused errors in runtime configs?” The tool might identify PRs that addressed configuration errors and suggest reviewing those changes.
-
Feature Implementation Status: A user can inquire about the implementation status of a specific feature. The tool can identify if the feature has been implemented, locate the documentation, and even provide instructions on enabling it.
Example: “Is indexing of code content from GitHub files enabled?” The agent would confirm if the feature is active and outline the steps to enable it.
-
Code Implementation Guidance: A user, unsure where to start with implementing a new feature, can get guidance on which files to modify based on past similar changes.
Example: “Where can I add a new endpoint in QE?” The tool would search for similar past implementations and provide sample code snippets and file locations to get started.
Configuration
Prerequisites
- Ensure GitHub or GitLab is enabled as a datasource in the deployment configuration. This can be configured in the Glean admin portal under deployment settings.
Configure the code search connector by entering search queries in one of two ways:
-
Define Fixed Queries Manually
- Use this method to provide your exact queries to the code search agent. Create detailed search templates to specify the queries.
-
Write a Plain Text Prompt for Glean to Generate Queries From
- Glean uses this plain text field to generate queries, which it passes to the code search connector.
Test the setup in a controlled environment to ensure that the Code Search Action performs as expected. After successful testing, deploy it for use by all intended users.