Skip to content

Commit 9d4fed5

Browse files
committed
refactor(@angular/cli): update algolia config for documentation search tool
The Algolia search configuration has been updated to support querying multiple major versions of the documentation. Error handling was also improved to support fallback to known indexes correctly.
1 parent 0ae9c99 commit 9d4fed5

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

packages/angular/cli/src/commands/mcp/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
export const k1 = '@angular/cli';
10-
export const at = 'QBHBbOdEO4CmBOC2d7jNmg==';
10+
export const at = 'gv2tkIHTOiWtI6Su96LXLQ==';
1111
export const iv = Buffer.from([
1212
0x97, 0xf4, 0x62, 0x95, 0x3e, 0x12, 0x76, 0x84, 0x8a, 0x09, 0x4a, 0xc9, 0xeb, 0xa2, 0x84, 0x69,
1313
]);

packages/angular/cli/src/commands/mcp/tools/doc-search.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const ALGOLIA_APP_ID = 'L1XWT2UJ7F';
1717
// https://www.algolia.com/doc/guides/security/api-keys/#search-only-api-key
1818
// This is a search only, rate limited key. It is sent within the URL of the query request.
1919
// This is not the actual key.
20-
const ALGOLIA_API_E = '322d89dab5f2080fe09b795c93413c6a89222b13a447cdf3e6486d692717bc0c';
20+
const ALGOLIA_API_E = '34738e8ae1a45e58bbce7b0f9810633d8b727b44a6479cf5e14b6a337148bd50';
2121

2222
/**
2323
* The minimum major version of Angular for which a version-specific documentation index is known to exist.
@@ -45,7 +45,7 @@ const docSearchInputSchema = z.object({
4545
includeTopContent: z
4646
.boolean()
4747
.optional()
48-
.default(true)
48+
.default(false)
4949
.describe(
5050
'When true, the content of the top result is fetched and included. ' +
5151
'Set to false to get a list of results without fetching content, which is faster.',
@@ -145,22 +145,22 @@ function createDocSearchHandler({ logger }: McpToolContext) {
145145
version ?? LATEST_KNOWN_DOCS_VERSION,
146146
MIN_SUPPORTED_DOCS_VERSION,
147147
);
148-
let searchResults = await client.search(createSearchArguments(query, finalSearchedVersion));
148+
let searchResults;
149+
try {
150+
searchResults = await client.search(createSearchArguments(query, finalSearchedVersion));
151+
} catch {}
149152

150153
// If the initial search for a newer-than-stable version returns no results, it may be because
151154
// the index for that version doesn't exist yet. In this case, fall back to the latest known
152155
// stable version.
153-
if (
154-
searchResults.results.every((result) => !('hits' in result) || result.hits.length === 0) &&
155-
finalSearchedVersion > LATEST_KNOWN_DOCS_VERSION
156-
) {
156+
if (!searchResults && finalSearchedVersion > LATEST_KNOWN_DOCS_VERSION) {
157157
finalSearchedVersion = LATEST_KNOWN_DOCS_VERSION;
158158
searchResults = await client.search(createSearchArguments(query, finalSearchedVersion));
159159
}
160160

161-
const allHits = searchResults.results.flatMap((result) => (result as SearchResponse).hits);
161+
const allHits = searchResults?.results.flatMap((result) => (result as SearchResponse).hits);
162162

163-
if (allHits.length === 0) {
163+
if (!allHits?.length) {
164164
return {
165165
content: [
166166
{

0 commit comments

Comments
 (0)