Generative AI Conversations
There are two ways to access the Pieces Copilot.
You can select a portion of code, right-click, and select Start Conversation About The Current Selection
, which will open up a new window.
Alternatively, you can use the command palette to enter the Pieces: Ask About The Current File
or Pieces: Ask About The Current Project
commands, which give you much greater context windows.
Pieces: Start Conversation About The Current Selection
One of the simplest ways to ask the Pieces Copilot a question about a specific class, method, function, or script is to use the in-menu Start Conversation About The Current Selection
option.
This feature makes it incredibly convenient for users to get quick insights or answers to specific questions about their code.
Once selected, you can enter your prompt in the text input field at the bottom of the Sublime editor's view and press enter:
Pieces: Ask About The Current File
The Pieces: Ask About The Current File
feature focuses on providing insights and assistance with the specific file you're working on.
To use this feature, open up the command palette using ⌘+shift+p
(macOS) or ctrl+shift+p
(Windows/Linux) and enter Pieces: Ask About The Current File
, then enter your question into the input field.
After running the initial command, you can then query the LLM, which will use the file as context to generate accurate and useful responses.
This is ideal for developers who need a comprehensive understanding of a file, such as its dependencies, functions, and classes.
It allows the LLM to thoroughly examine the file, identifying areas for potential improvement and detecting errors.
Try leveraging this feature to get documentation references and explanations for the file's content. This is especially helpful for onboarding new team members or working with unfamiliar code.
Pieces: Ask About The Current Project
Similar to the file-level command, the Pieces: Ask About The Current Project
command lets developers understand every corner of an entire project.
Open the command palette with ⌘+shift+p
(macOS) or ctrl+shift+p
(Windows/Linux) and enter Pieces: Ask About The Current Project
, then type in your question.
This feature can also highlight errors and suggest improvements on a wider scale, but its main benefit and use case is to help developers navigate their codebase by utilizing the Pieces context-awareness engine to provide relevant and accurate information with even the most specific of prompts.
Identifying Inconsistencies
When it comes to large-scale product development, especially when several developers are concerned, there are often small inconsistencies and oversights that make it difficult for new team members to effectively collaborate.
In this example, the naming conventions for functions in userController.js and productController.js are inconsistent (getUser
vs. fetchProduct
).
The Pieces: Ask About the Current Project
feature can highlight this inconsistency and suggest a uniform naming convention:
// userController.js
const getUser = (req, res) => {
// code to get user
};
// productController.js
const fetchProduct = (req, res) => {
// code to fetch product
};
Inconsistent Error Handling
Here, apiService.js uses a try-catch block for error handling, while authService.js does not.
// apiService.js
export const fetchData = async (url) => {
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error('Network response was not ok');
}
return await response.json();
} catch (error) {
console.error('Fetch error:', error);
throw error;
}
};
// authService.js
export const login = async (credentials) => {
const response = await fetch('/login', {
method: 'POST',
body: JSON.stringify(credentials),
});
if (response.status !== 200) {
throw new Error('Login failed');
}
return await response.json();
};
You can utilize this feature to locate these inconsistencies and let the generative AI suggest standardizing error handling across your entire project.