You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The search_code handler will enable querying for code across Azure DevOps repositories using the Azure DevOps Search REST API. This feature will allow users to search for specific code snippets, files, or patterns across all accessible repositories.
Implementation Details
The Azure DevOps Search API is separate from the core Azure DevOps API and requires a different endpoint structure:
Base URL: https://almsearch.dev.azure.com/{organization}/{project}/_apis/search/codesearchresults
Method: POST
Authentication: Same as other Azure DevOps API endpoints
API Version: 7.1
Note: The azure-devops-node-api library does not directly support the Search API, so we'll need to implement custom HTTP requests.
Important Addition: Even though the Search API doesn't directly return full code content, our implementation should fetch and return the actual code for each search result to avoid requiring additional API calls. This will require making additional GitAPI calls to fetch file content after receiving search results.
Subtasks
Schema Definition
Create SearchCodeSchema in a new file under src/features/search/schemas.ts
Include parameters:
searchText (required): The text to search for
projectId (required): The project to search in
filters (optional): Repository, path, branch, and code element filters
top (optional): Number of results to return (default: 100)
skip (optional): Number of results to skip (pagination)
includeSnippet (optional): Whether to include code snippets in results (default: true)
includeContent (optional): Whether to include full file content in results (default: true)
Types Definition
Create types for the request and response objects
Define interfaces for code search results, matches, and filters
Add content property to result objects to hold full file content
Implement
search_code
Handler with TestsThe
search_code
handler will enable querying for code across Azure DevOps repositories using the Azure DevOps Search REST API. This feature will allow users to search for specific code snippets, files, or patterns across all accessible repositories.Implementation Details
The Azure DevOps Search API is separate from the core Azure DevOps API and requires a different endpoint structure:
https://almsearch.dev.azure.com/{organization}/{project}/_apis/search/codesearchresults
Note: The
azure-devops-node-api
library does not directly support the Search API, so we'll need to implement custom HTTP requests.Important Addition: Even though the Search API doesn't directly return full code content, our implementation should fetch and return the actual code for each search result to avoid requiring additional API calls. This will require making additional GitAPI calls to fetch file content after receiving search results.
Subtasks
Schema Definition
SearchCodeSchema
in a new file undersrc/features/search/schemas.ts
searchText
(required): The text to search forprojectId
(required): The project to search infilters
(optional): Repository, path, branch, and code element filterstop
(optional): Number of results to return (default: 100)skip
(optional): Number of results to skip (pagination)includeSnippet
(optional): Whether to include code snippets in results (default: true)includeContent
(optional): Whether to include full file content in results (default: true)Types Definition
src/features/search/types.ts
Feature Implementation
src/features/search/search-code/
feature.ts
with the mainsearchCode
functionIntegration with Server
server.ts
ListToolsRequestSchema
responseUnit Tests
feature.spec.unit.ts
with mock API responsesIntegration Tests
feature.spec.int.ts
to test against a real Azure DevOps instanceDocumentation
docs/tools/search.md
API Sample Request
API Sample Response Structure
Notes
The text was updated successfully, but these errors were encountered: