@wix/mcp 1.0.74 → 1.0.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bin-standalone.js +83500 -12272
- package/build/cjs/index.cjs +41 -14
- package/build/cjs/toolkit.cjs +41 -14
- package/build/dts/docs/searchFormatting.d.ts +1 -0
- package/build/dts/docs/searchFormatting.js +49 -14
- package/build/dts/index.d.ts +1 -0
- package/build/dts/index.js +0 -1
- package/build/dts/infra/tool-bi.d.ts +4 -4
- package/build/dts/infra/tool-bi.js +1 -1
- package/build/dts/toolkit-entry.d.cts +410 -0
- package/build/dts/toolkit-entry.d.ts +409 -19
- package/build/dts/toolkit-entry.js +0 -1
- package/build/dts/toolkit-types.d.ts +31 -0
- package/build/dts/toolkit-types.js +12 -0
- package/build/dts/toolkit.d.ts +5 -5
- package/build/esm/index.js +41 -14
- package/build/esm/toolkit.js +41 -14
- package/package.json +26 -19
- package/build/bin-standalone.js.map +0 -7
- package/build/cjs/index.cjs.map +0 -7
- package/build/cjs/toolkit.cjs.map +0 -7
- package/build/dts/api-call/index.d.ts.map +0 -1
- package/build/dts/api-call/index.js.map +0 -1
- package/build/dts/api-call/upload-image-tool.d.ts.map +0 -1
- package/build/dts/api-call/upload-image-tool.js.map +0 -1
- package/build/dts/api-call/upload-image-tool.test.d.ts +0 -2
- package/build/dts/api-call/upload-image-tool.test.d.ts.map +0 -1
- package/build/dts/api-call/upload-image-tool.test.js +0 -217
- package/build/dts/api-call/upload-image-tool.test.js.map +0 -1
- package/build/dts/api-call/upload-image-utils.d.ts.map +0 -1
- package/build/dts/api-call/upload-image-utils.js.map +0 -1
- package/build/dts/api-call/upload-image-utils.test.d.ts +0 -2
- package/build/dts/api-call/upload-image-utils.test.d.ts.map +0 -1
- package/build/dts/api-call/upload-image-utils.test.js +0 -121
- package/build/dts/api-call/upload-image-utils.test.js.map +0 -1
- package/build/dts/api-call/validation.d.ts.map +0 -1
- package/build/dts/api-call/validation.js.map +0 -1
- package/build/dts/api-call/validation.test.d.ts +0 -2
- package/build/dts/api-call/validation.test.d.ts.map +0 -1
- package/build/dts/api-call/validation.test.js +0 -42
- package/build/dts/api-call/validation.test.js.map +0 -1
- package/build/dts/auth/auth-error-handling.test.d.ts +0 -2
- package/build/dts/auth/auth-error-handling.test.d.ts.map +0 -1
- package/build/dts/auth/auth-error-handling.test.js +0 -347
- package/build/dts/auth/auth-error-handling.test.js.map +0 -1
- package/build/dts/auth/index.d.ts.map +0 -1
- package/build/dts/auth/index.js.map +0 -1
- package/build/dts/bin.d.ts.map +0 -1
- package/build/dts/bin.js.map +0 -1
- package/build/dts/cli-tools/account-auth-strategy.d.ts.map +0 -1
- package/build/dts/cli-tools/account-auth-strategy.js.map +0 -1
- package/build/dts/cli-tools/account-token-store.d.ts.map +0 -1
- package/build/dts/cli-tools/account-token-store.js.map +0 -1
- package/build/dts/cli-tools/cli.d.ts.map +0 -1
- package/build/dts/cli-tools/cli.js.map +0 -1
- package/build/dts/cli-tools/utils.d.ts.map +0 -1
- package/build/dts/cli-tools/utils.js.map +0 -1
- package/build/dts/code-mode/index.d.ts.map +0 -1
- package/build/dts/code-mode/index.js.map +0 -1
- package/build/dts/code-mode/index.test.d.ts +0 -2
- package/build/dts/code-mode/index.test.d.ts.map +0 -1
- package/build/dts/code-mode/index.test.js +0 -342
- package/build/dts/code-mode/index.test.js.map +0 -1
- package/build/dts/code-mode/truncate-response.d.ts.map +0 -1
- package/build/dts/code-mode/truncate-response.js.map +0 -1
- package/build/dts/code-mode/truncate-response.test.d.ts +0 -2
- package/build/dts/code-mode/truncate-response.test.d.ts.map +0 -1
- package/build/dts/code-mode/truncate-response.test.js +0 -32
- package/build/dts/code-mode/truncate-response.test.js.map +0 -1
- package/build/dts/code-mode/validation.d.ts.map +0 -1
- package/build/dts/code-mode/validation.js.map +0 -1
- package/build/dts/code-mode/validation.test.d.ts +0 -2
- package/build/dts/code-mode/validation.test.d.ts.map +0 -1
- package/build/dts/code-mode/validation.test.js +0 -72
- package/build/dts/code-mode/validation.test.js.map +0 -1
- package/build/dts/config/default-config.bulk-preference.test.d.ts +0 -2
- package/build/dts/config/default-config.bulk-preference.test.d.ts.map +0 -1
- package/build/dts/config/default-config.bulk-preference.test.js +0 -42
- package/build/dts/config/default-config.bulk-preference.test.js.map +0 -1
- package/build/dts/config/default-config.d.ts.map +0 -1
- package/build/dts/config/default-config.execute-orchestration.test.d.ts +0 -2
- package/build/dts/config/default-config.execute-orchestration.test.d.ts.map +0 -1
- package/build/dts/config/default-config.execute-orchestration.test.js +0 -40
- package/build/dts/config/default-config.execute-orchestration.test.js.map +0 -1
- package/build/dts/config/default-config.js.map +0 -1
- package/build/dts/config/default-config.readme.test.d.ts +0 -2
- package/build/dts/config/default-config.readme.test.d.ts.map +0 -1
- package/build/dts/config/default-config.readme.test.js +0 -84
- package/build/dts/config/default-config.readme.test.js.map +0 -1
- package/build/dts/config/default-config.searchspec-goal.test.d.ts +0 -2
- package/build/dts/config/default-config.searchspec-goal.test.d.ts.map +0 -1
- package/build/dts/config/default-config.searchspec-goal.test.js +0 -30
- package/build/dts/config/default-config.searchspec-goal.test.js.map +0 -1
- package/build/dts/config/param-descriptions.d.ts.map +0 -1
- package/build/dts/config/param-descriptions.js.map +0 -1
- package/build/dts/constants.d.ts.map +0 -1
- package/build/dts/constants.js.map +0 -1
- package/build/dts/docs/browse-menu.d.ts.map +0 -1
- package/build/dts/docs/browse-menu.js.map +0 -1
- package/build/dts/docs/browse-menu.test.d.ts +0 -2
- package/build/dts/docs/browse-menu.test.d.ts.map +0 -1
- package/build/dts/docs/browse-menu.test.js +0 -66
- package/build/dts/docs/browse-menu.test.js.map +0 -1
- package/build/dts/docs/browse-tool.test.d.ts +0 -2
- package/build/dts/docs/browse-tool.test.d.ts.map +0 -1
- package/build/dts/docs/browse-tool.test.js +0 -77
- package/build/dts/docs/browse-tool.test.js.map +0 -1
- package/build/dts/docs/create-site-guide.d.ts.map +0 -1
- package/build/dts/docs/create-site-guide.js.map +0 -1
- package/build/dts/docs/docs.d.ts.map +0 -1
- package/build/dts/docs/docs.js.map +0 -1
- package/build/dts/docs/fetch-article.d.ts.map +0 -1
- package/build/dts/docs/fetch-article.js.map +0 -1
- package/build/dts/docs/fetch-article.test.d.ts +0 -2
- package/build/dts/docs/fetch-article.test.d.ts.map +0 -1
- package/build/dts/docs/fetch-article.test.js +0 -93
- package/build/dts/docs/fetch-article.test.js.map +0 -1
- package/build/dts/docs/fetch-skills.d.ts.map +0 -1
- package/build/dts/docs/fetch-skills.js.map +0 -1
- package/build/dts/docs/fetch-skills.test.d.ts +0 -2
- package/build/dts/docs/fetch-skills.test.d.ts.map +0 -1
- package/build/dts/docs/fetch-skills.test.js +0 -140
- package/build/dts/docs/fetch-skills.test.js.map +0 -1
- package/build/dts/docs/get-to-know.d.ts.map +0 -1
- package/build/dts/docs/get-to-know.js.map +0 -1
- package/build/dts/docs/get-to-know.test.d.ts +0 -2
- package/build/dts/docs/get-to-know.test.d.ts.map +0 -1
- package/build/dts/docs/get-to-know.test.js +0 -152
- package/build/dts/docs/get-to-know.test.js.map +0 -1
- package/build/dts/docs/long-content.d.ts.map +0 -1
- package/build/dts/docs/long-content.js.map +0 -1
- package/build/dts/docs/normalize-menu-content.d.ts.map +0 -1
- package/build/dts/docs/normalize-menu-content.js.map +0 -1
- package/build/dts/docs/searchFormatting.d.ts.map +0 -1
- package/build/dts/docs/searchFormatting.js.map +0 -1
- package/build/dts/docs/searchFormatting.test.d.ts +0 -2
- package/build/dts/docs/searchFormatting.test.d.ts.map +0 -1
- package/build/dts/docs/searchFormatting.test.js +0 -39
- package/build/dts/docs/searchFormatting.test.js.map +0 -1
- package/build/dts/docs/semanticSearch.d.ts.map +0 -1
- package/build/dts/docs/semanticSearch.js.map +0 -1
- package/build/dts/docs/semanticSearch.test.d.ts +0 -2
- package/build/dts/docs/semanticSearch.test.d.ts.map +0 -1
- package/build/dts/docs/semanticSearch.test.js +0 -923
- package/build/dts/docs/semanticSearch.test.js.map +0 -1
- package/build/dts/docs/velo-readme.d.ts.map +0 -1
- package/build/dts/docs/velo-readme.js.map +0 -1
- package/build/dts/import-claude-design-tool/banner.d.ts.map +0 -1
- package/build/dts/import-claude-design-tool/banner.js.map +0 -1
- package/build/dts/import-claude-design-tool/constants.d.ts.map +0 -1
- package/build/dts/import-claude-design-tool/constants.js.map +0 -1
- package/build/dts/import-claude-design-tool/index.d.ts.map +0 -1
- package/build/dts/import-claude-design-tool/index.js.map +0 -1
- package/build/dts/import-claude-design-tool/index.test.d.ts +0 -2
- package/build/dts/import-claude-design-tool/index.test.d.ts.map +0 -1
- package/build/dts/import-claude-design-tool/index.test.js +0 -329
- package/build/dts/import-claude-design-tool/index.test.js.map +0 -1
- package/build/dts/import-claude-design-tool/sanitize.d.ts.map +0 -1
- package/build/dts/import-claude-design-tool/sanitize.js.map +0 -1
- package/build/dts/import-claude-design-tool/wixstro-client.d.ts.map +0 -1
- package/build/dts/import-claude-design-tool/wixstro-client.js.map +0 -1
- package/build/dts/index.d.ts.map +0 -1
- package/build/dts/index.js.map +0 -1
- package/build/dts/infra/bi-logger.d.ts.map +0 -1
- package/build/dts/infra/bi-logger.js.map +0 -1
- package/build/dts/infra/environment.d.ts.map +0 -1
- package/build/dts/infra/environment.js.map +0 -1
- package/build/dts/infra/file-logger.d.ts.map +0 -1
- package/build/dts/infra/file-logger.js.map +0 -1
- package/build/dts/infra/logger.d.ts.map +0 -1
- package/build/dts/infra/logger.js.map +0 -1
- package/build/dts/infra/panorama.d.ts.map +0 -1
- package/build/dts/infra/panorama.js.map +0 -1
- package/build/dts/infra/response-size-limits.d.ts.map +0 -1
- package/build/dts/infra/response-size-limits.js.map +0 -1
- package/build/dts/infra/sentry.d.ts.map +0 -1
- package/build/dts/infra/sentry.js.map +0 -1
- package/build/dts/infra/tool-bi.d.ts.map +0 -1
- package/build/dts/infra/tool-bi.js.map +0 -1
- package/build/dts/infra/widget-payload.d.ts.map +0 -1
- package/build/dts/infra/widget-payload.js.map +0 -1
- package/build/dts/resources/docs.d.ts.map +0 -1
- package/build/dts/resources/docs.js.map +0 -1
- package/build/dts/site-widget-tools/claim-site-tool/index.d.ts.map +0 -1
- package/build/dts/site-widget-tools/claim-site-tool/index.js.map +0 -1
- package/build/dts/site-widget-tools/constants.d.ts.map +0 -1
- package/build/dts/site-widget-tools/constants.js.map +0 -1
- package/build/dts/site-widget-tools/create-site-from-template-tool/index.d.ts.map +0 -1
- package/build/dts/site-widget-tools/create-site-from-template-tool/index.js.map +0 -1
- package/build/dts/site-widget-tools/edit-site-tool/index.d.ts.map +0 -1
- package/build/dts/site-widget-tools/edit-site-tool/index.js.map +0 -1
- package/build/dts/site-widget-tools/index.d.ts.map +0 -1
- package/build/dts/site-widget-tools/index.js.map +0 -1
- package/build/dts/site-widget-tools/pull-site-creation-job-tool/index.d.ts.map +0 -1
- package/build/dts/site-widget-tools/pull-site-creation-job-tool/index.js.map +0 -1
- package/build/dts/site-widget-tools/search-site-templates-tool/index.d.ts.map +0 -1
- package/build/dts/site-widget-tools/search-site-templates-tool/index.js.map +0 -1
- package/build/dts/site-widget-tools/site-builder-tool/index.d.ts.map +0 -1
- package/build/dts/site-widget-tools/site-builder-tool/index.js.map +0 -1
- package/build/dts/site-widget-tools/site-builder-tool/index.test.d.ts +0 -2
- package/build/dts/site-widget-tools/site-builder-tool/index.test.d.ts.map +0 -1
- package/build/dts/site-widget-tools/site-builder-tool/index.test.js +0 -46
- package/build/dts/site-widget-tools/site-builder-tool/index.test.js.map +0 -1
- package/build/dts/site-widget-tools/site-creation-tool/index.d.ts.map +0 -1
- package/build/dts/site-widget-tools/site-creation-tool/index.js.map +0 -1
- package/build/dts/site-widget-tools/site-creation-tool/index.test.d.ts +0 -2
- package/build/dts/site-widget-tools/site-creation-tool/index.test.d.ts.map +0 -1
- package/build/dts/site-widget-tools/site-creation-tool/index.test.js +0 -57
- package/build/dts/site-widget-tools/site-creation-tool/index.test.js.map +0 -1
- package/build/dts/site-widget-tools/suggested-domain-tool/index.d.ts.map +0 -1
- package/build/dts/site-widget-tools/suggested-domain-tool/index.js.map +0 -1
- package/build/dts/site-widget-tools/types.d.ts.map +0 -1
- package/build/dts/site-widget-tools/types.js.map +0 -1
- package/build/dts/site-widget-tools/utils.d.ts.map +0 -1
- package/build/dts/site-widget-tools/utils.js.map +0 -1
- package/build/dts/support/index.d.ts.map +0 -1
- package/build/dts/support/index.js.map +0 -1
- package/build/dts/tool-bi-reporting.test.d.ts +0 -2
- package/build/dts/tool-bi-reporting.test.d.ts.map +0 -1
- package/build/dts/tool-bi-reporting.test.js +0 -219
- package/build/dts/tool-bi-reporting.test.js.map +0 -1
- package/build/dts/tool-utils.d.ts.map +0 -1
- package/build/dts/tool-utils.js.map +0 -1
- package/build/dts/tool-utils.spec.d.ts +0 -2
- package/build/dts/tool-utils.spec.d.ts.map +0 -1
- package/build/dts/tool-utils.spec.js +0 -98
- package/build/dts/tool-utils.spec.js.map +0 -1
- package/build/dts/toolkit-entry.d.ts.map +0 -1
- package/build/dts/toolkit-entry.js.map +0 -1
- package/build/dts/toolkit-json-schema.test.d.ts +0 -2
- package/build/dts/toolkit-json-schema.test.d.ts.map +0 -1
- package/build/dts/toolkit-json-schema.test.js +0 -36
- package/build/dts/toolkit-json-schema.test.js.map +0 -1
- package/build/dts/toolkit.d.ts.map +0 -1
- package/build/dts/toolkit.js.map +0 -1
- package/build/dts/toolkit.test.d.ts +0 -2
- package/build/dts/toolkit.test.d.ts.map +0 -1
- package/build/dts/toolkit.test.js +0 -691
- package/build/dts/toolkit.test.js.map +0 -1
- package/build/dts/widget-manifest.d.ts.map +0 -1
- package/build/dts/widget-manifest.js.map +0 -1
- package/build/dts/wix-fetch-error.d.ts.map +0 -1
- package/build/dts/wix-fetch-error.js.map +0 -1
- package/build/dts/wix-mcp-server.d.ts.map +0 -1
- package/build/dts/wix-mcp-server.js.map +0 -1
- package/build/dts/wixel/api.d.ts.map +0 -1
- package/build/dts/wixel/api.js.map +0 -1
- package/build/dts/wixel/constants.d.ts.map +0 -1
- package/build/dts/wixel/constants.js.map +0 -1
- package/build/dts/wixel/external-agent-api.d.ts.map +0 -1
- package/build/dts/wixel/external-agent-api.js.map +0 -1
- package/build/dts/wixel/get-wixel-asset-tool.d.ts.map +0 -1
- package/build/dts/wixel/get-wixel-asset-tool.js.map +0 -1
- package/build/dts/wixel/get-wixel-job-status-tool.d.ts.map +0 -1
- package/build/dts/wixel/get-wixel-job-status-tool.js.map +0 -1
- package/build/dts/wixel/get-wixel-project-assets-tool.d.ts.map +0 -1
- package/build/dts/wixel/get-wixel-project-assets-tool.js.map +0 -1
- package/build/dts/wixel/index.d.ts.map +0 -1
- package/build/dts/wixel/index.js.map +0 -1
- package/build/dts/wixel/mark-wixel-job-as-fulfilled-tool.d.ts.map +0 -1
- package/build/dts/wixel/mark-wixel-job-as-fulfilled-tool.js.map +0 -1
- package/build/dts/wixel/open-headless-wixel-project-tool.d.ts.map +0 -1
- package/build/dts/wixel/open-headless-wixel-project-tool.js.map +0 -1
- package/build/dts/wixel/pull-headless-wixel-job-tool.d.ts.map +0 -1
- package/build/dts/wixel/pull-headless-wixel-job-tool.js.map +0 -1
- package/build/dts/wixel/update-headless-wixel-job-tool.d.ts.map +0 -1
- package/build/dts/wixel/update-headless-wixel-job-tool.js.map +0 -1
- package/build/dts/wixel/utils.d.ts.map +0 -1
- package/build/dts/wixel/utils.js.map +0 -1
- package/build/dts/wixel/wixel-bi.d.ts.map +0 -1
- package/build/dts/wixel/wixel-bi.js.map +0 -1
- package/build/dts/wixel/wixel-bi.test.d.ts +0 -2
- package/build/dts/wixel/wixel-bi.test.d.ts.map +0 -1
- package/build/dts/wixel/wixel-bi.test.js +0 -35
- package/build/dts/wixel/wixel-bi.test.js.map +0 -1
- package/build/dts/wixel/wixel-session-tools.d.ts.map +0 -1
- package/build/dts/wixel/wixel-session-tools.js.map +0 -1
- package/build/dts/wixel/wixel-session-tools.test.d.ts +0 -2
- package/build/dts/wixel/wixel-session-tools.test.d.ts.map +0 -1
- package/build/dts/wixel/wixel-session-tools.test.js +0 -143
- package/build/dts/wixel/wixel-session-tools.test.js.map +0 -1
- package/build/esm/index.js.map +0 -7
- package/build/esm/toolkit.js.map +0 -7
|
@@ -1,923 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, beforeEach, vi, afterAll } from 'vitest';
|
|
2
|
-
import { DEFAULT_MAX_RESULTS, runSemanticSearchAndFormat } from './semanticSearch.js';
|
|
3
|
-
import { LONG_KB_CONTENT } from './long-content.js';
|
|
4
|
-
const sampleSearchResponse = {
|
|
5
|
-
results: {
|
|
6
|
-
SDK_DOCS_KB_ID: {
|
|
7
|
-
results: [
|
|
8
|
-
{
|
|
9
|
-
entry: {
|
|
10
|
-
content: 'SDK Documentation content 1\nline 2\nline 3',
|
|
11
|
-
url: 'https://dev.wix.com/docs/sdk/example'
|
|
12
|
-
},
|
|
13
|
-
scoresInfo: {
|
|
14
|
-
overallMatchScore: 0.95
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
entry: {
|
|
19
|
-
content: 'SDK Documentation content 2'
|
|
20
|
-
},
|
|
21
|
-
scoresInfo: {
|
|
22
|
-
overallMatchScore: 0.85
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
entry: {
|
|
27
|
-
content: LONG_KB_CONTENT,
|
|
28
|
-
chunkedContent: ['some-chunked-content']
|
|
29
|
-
},
|
|
30
|
-
scoresInfo: {
|
|
31
|
-
overallMatchScore: 0.83
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
SDK_SCHEMAS_KB_ID: {
|
|
37
|
-
results: [
|
|
38
|
-
{
|
|
39
|
-
entry: {
|
|
40
|
-
content: 'SDK Schema content 1'
|
|
41
|
-
},
|
|
42
|
-
scoresInfo: {
|
|
43
|
-
overallMatchScore: 0.9
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
},
|
|
48
|
-
BUILD_APPS_KB_ID: {
|
|
49
|
-
results: [
|
|
50
|
-
{
|
|
51
|
-
entry: {
|
|
52
|
-
content: 'Build Apps content 1'
|
|
53
|
-
},
|
|
54
|
-
scoresInfo: {
|
|
55
|
-
overallMatchScore: 0.88
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
// MCP_REST_RECIPES_KB_ID removed - recipes migrated to Picasso docs
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const originalProcessEnv = process.env;
|
|
64
|
-
describe('Semantic Search', () => {
|
|
65
|
-
let fetchMock;
|
|
66
|
-
global.fetch = vi.fn();
|
|
67
|
-
beforeEach(() => {
|
|
68
|
-
vi.clearAllMocks();
|
|
69
|
-
process.env = { ...originalProcessEnv };
|
|
70
|
-
fetchMock = global.fetch;
|
|
71
|
-
fetchMock.mockReset();
|
|
72
|
-
fetchMock.mockResolvedValue({
|
|
73
|
-
ok: true,
|
|
74
|
-
status: 200,
|
|
75
|
-
statusText: 'OK',
|
|
76
|
-
json: async () => sampleSearchResponse
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
afterAll(() => {
|
|
80
|
-
process.env = originalProcessEnv;
|
|
81
|
-
});
|
|
82
|
-
test('performs SDK semantic search successfully', async () => {
|
|
83
|
-
const sdkResponse = {
|
|
84
|
-
results: {
|
|
85
|
-
SDK_DOCS_KB_ID: {
|
|
86
|
-
results: [
|
|
87
|
-
{
|
|
88
|
-
entry: {
|
|
89
|
-
content: 'SDK Documentation content 1'
|
|
90
|
-
},
|
|
91
|
-
scoresInfo: {
|
|
92
|
-
overallMatchScore: 0.95
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
entry: {
|
|
97
|
-
content: 'SDK Documentation content 2'
|
|
98
|
-
},
|
|
99
|
-
scoresInfo: {
|
|
100
|
-
overallMatchScore: 0.85
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
]
|
|
104
|
-
},
|
|
105
|
-
SDK_SCHEMAS_KB_ID: {
|
|
106
|
-
results: [
|
|
107
|
-
{
|
|
108
|
-
entry: {
|
|
109
|
-
content: 'SDK Schema content 1'
|
|
110
|
-
},
|
|
111
|
-
scoresInfo: {
|
|
112
|
-
overallMatchScore: 0.9
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
]
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
fetchMock.mockResolvedValueOnce({
|
|
120
|
-
ok: true,
|
|
121
|
-
status: 200,
|
|
122
|
-
json: async () => sdkResponse
|
|
123
|
-
});
|
|
124
|
-
const result = await runSemanticSearchAndFormat({
|
|
125
|
-
toolName: 'SDK',
|
|
126
|
-
toolParams: {
|
|
127
|
-
searchTerm: 'wix-data query'
|
|
128
|
-
},
|
|
129
|
-
usePlatformizedSearch: false
|
|
130
|
-
});
|
|
131
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
132
|
-
const [url] = fetchMock.mock.calls[0];
|
|
133
|
-
expect(url).toContain('mcp-docs-search/v1/search');
|
|
134
|
-
expect(url).toContain(`maxResults=${DEFAULT_MAX_RESULTS}`);
|
|
135
|
-
expect(url).toContain('rerank=false');
|
|
136
|
-
expect(url).toContain('kbName=SDK_DOCS_KB_ID');
|
|
137
|
-
expect(url).toContain('kbName=SDK_METHODS_KB_ID');
|
|
138
|
-
expect(url).toContain('kbName=API_REFERENCE_SDK_KB_ID');
|
|
139
|
-
expect(url).toContain('kbName=REST_DOCS_KB_ID');
|
|
140
|
-
expect(url).toContain('searchTerm=wix-data+query');
|
|
141
|
-
// Results should be sorted by score and limited to 10
|
|
142
|
-
expect(result).toBe('SDK Documentation content 1\n\n========================================\n\nSDK Schema content 1\n\n========================================\n\nSDK Documentation content 2');
|
|
143
|
-
});
|
|
144
|
-
test('performs REST semantic search successfully', async () => {
|
|
145
|
-
const restResponse = {
|
|
146
|
-
results: {
|
|
147
|
-
REST_METHODS_KB_ID: {
|
|
148
|
-
results: [
|
|
149
|
-
{
|
|
150
|
-
entry: {
|
|
151
|
-
content: 'REST Methods content'
|
|
152
|
-
},
|
|
153
|
-
scoresInfo: {
|
|
154
|
-
overallMatchScore: 0.98
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
]
|
|
158
|
-
},
|
|
159
|
-
REST_DOCS_KB_ID: {
|
|
160
|
-
results: [
|
|
161
|
-
{
|
|
162
|
-
entry: {
|
|
163
|
-
content: 'REST Documentation content'
|
|
164
|
-
},
|
|
165
|
-
scoresInfo: {
|
|
166
|
-
overallMatchScore: 0.95
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
]
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
fetchMock.mockResolvedValueOnce({
|
|
174
|
-
ok: true,
|
|
175
|
-
status: 200,
|
|
176
|
-
json: async () => restResponse
|
|
177
|
-
});
|
|
178
|
-
const result = await runSemanticSearchAndFormat({
|
|
179
|
-
toolName: 'REST',
|
|
180
|
-
toolParams: {
|
|
181
|
-
searchTerm: 'create collection'
|
|
182
|
-
},
|
|
183
|
-
usePlatformizedSearch: false
|
|
184
|
-
});
|
|
185
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
186
|
-
const [url] = fetchMock.mock.calls[0];
|
|
187
|
-
expect(url).toContain('kbName=REST_METHODS_KB_ID');
|
|
188
|
-
expect(url).toContain('kbName=REST_DOCS_KB_ID');
|
|
189
|
-
// MCP_REST_RECIPES_KB_ID disabled - recipes migrated to Picasso docs
|
|
190
|
-
expect(url).not.toContain('kbName=MCP_REST_RECIPES_KB_ID');
|
|
191
|
-
expect(result).toBe('REST Methods content\n\n========================================\n\nREST Documentation content');
|
|
192
|
-
});
|
|
193
|
-
test('interleaves REST methods and articles in score order within each bucket', async () => {
|
|
194
|
-
const restResponse = {
|
|
195
|
-
results: {
|
|
196
|
-
REST_DOCS_KB_ID: {
|
|
197
|
-
results: [
|
|
198
|
-
{
|
|
199
|
-
entry: {
|
|
200
|
-
content: 'Article 1'
|
|
201
|
-
},
|
|
202
|
-
scoresInfo: {
|
|
203
|
-
overallMatchScore: 0.99
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
entry: {
|
|
208
|
-
content: 'Article 2'
|
|
209
|
-
},
|
|
210
|
-
scoresInfo: {
|
|
211
|
-
overallMatchScore: 0.98
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
entry: {
|
|
216
|
-
content: 'Article 3'
|
|
217
|
-
},
|
|
218
|
-
scoresInfo: {
|
|
219
|
-
overallMatchScore: 0.97
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
entry: {
|
|
224
|
-
content: 'Article 4'
|
|
225
|
-
},
|
|
226
|
-
scoresInfo: {
|
|
227
|
-
overallMatchScore: 0.96
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
]
|
|
231
|
-
},
|
|
232
|
-
REST_METHODS_KB_ID: {
|
|
233
|
-
results: [
|
|
234
|
-
{
|
|
235
|
-
entry: {
|
|
236
|
-
content: 'Method 1'
|
|
237
|
-
},
|
|
238
|
-
scoresInfo: {
|
|
239
|
-
overallMatchScore: 0.75
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
entry: {
|
|
244
|
-
content: 'Method 2'
|
|
245
|
-
},
|
|
246
|
-
scoresInfo: {
|
|
247
|
-
overallMatchScore: 0.7
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
entry: {
|
|
252
|
-
content: 'Method 3'
|
|
253
|
-
},
|
|
254
|
-
scoresInfo: {
|
|
255
|
-
overallMatchScore: 0.65
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
]
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
fetchMock.mockResolvedValueOnce({
|
|
263
|
-
ok: true,
|
|
264
|
-
status: 200,
|
|
265
|
-
json: async () => restResponse
|
|
266
|
-
});
|
|
267
|
-
const result = await runSemanticSearchAndFormat({
|
|
268
|
-
toolName: 'REST',
|
|
269
|
-
toolParams: {
|
|
270
|
-
searchTerm: 'create product catalog v3'
|
|
271
|
-
},
|
|
272
|
-
maxResults: 6,
|
|
273
|
-
usePlatformizedSearch: false
|
|
274
|
-
});
|
|
275
|
-
expect(result).toBe([
|
|
276
|
-
'Method 1',
|
|
277
|
-
'Method 2',
|
|
278
|
-
'Article 1',
|
|
279
|
-
'Article 2',
|
|
280
|
-
'Method 3',
|
|
281
|
-
'Article 3'
|
|
282
|
-
].join('\n\n' + '='.repeat(40) + '\n\n'));
|
|
283
|
-
});
|
|
284
|
-
test('performs BUSINESS_SOLUTIONS semantic search successfully', async () => {
|
|
285
|
-
const restResponse = {
|
|
286
|
-
results: {
|
|
287
|
-
REST_DOCS_KB_ID: {
|
|
288
|
-
results: [
|
|
289
|
-
{
|
|
290
|
-
entry: {
|
|
291
|
-
content: 'REST Documentation content'
|
|
292
|
-
},
|
|
293
|
-
scoresInfo: {
|
|
294
|
-
overallMatchScore: 0.95
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
]
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
fetchMock.mockResolvedValueOnce({
|
|
302
|
-
ok: true,
|
|
303
|
-
status: 200,
|
|
304
|
-
json: async () => restResponse
|
|
305
|
-
});
|
|
306
|
-
const result = await runSemanticSearchAndFormat({
|
|
307
|
-
toolName: 'BUSINESS_SOLUTIONS',
|
|
308
|
-
toolParams: {
|
|
309
|
-
searchTerm: 'create collection'
|
|
310
|
-
},
|
|
311
|
-
usePlatformizedSearch: false
|
|
312
|
-
});
|
|
313
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
314
|
-
const [url] = fetchMock.mock.calls[0];
|
|
315
|
-
expect(url).not.toContain('kbName=REST_METHODS_KB_ID');
|
|
316
|
-
expect(url).toContain('kbName=REST_DOCS_KB_ID');
|
|
317
|
-
// MCP_REST_RECIPES_KB_ID disabled - recipes migrated to Picasso docs
|
|
318
|
-
expect(url).not.toContain('kbName=MCP_REST_RECIPES_KB_ID');
|
|
319
|
-
expect(result).toBe('REST Documentation content');
|
|
320
|
-
});
|
|
321
|
-
test('performs WDS semantic search successfully', async () => {
|
|
322
|
-
const wdsResponse = {
|
|
323
|
-
results: {
|
|
324
|
-
WDS_DOCS_KB_ID: {
|
|
325
|
-
results: [
|
|
326
|
-
{
|
|
327
|
-
entry: {
|
|
328
|
-
content: 'WDS Documentation content'
|
|
329
|
-
},
|
|
330
|
-
scoresInfo: {
|
|
331
|
-
overallMatchScore: 0.95
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
]
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
fetchMock.mockResolvedValueOnce({
|
|
339
|
-
ok: true,
|
|
340
|
-
status: 200,
|
|
341
|
-
json: async () => wdsResponse
|
|
342
|
-
});
|
|
343
|
-
const result = await runSemanticSearchAndFormat({
|
|
344
|
-
toolName: 'WDS',
|
|
345
|
-
toolParams: {
|
|
346
|
-
searchTerm: 'Button component'
|
|
347
|
-
},
|
|
348
|
-
usePlatformizedSearch: false
|
|
349
|
-
});
|
|
350
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
351
|
-
const [url] = fetchMock.mock.calls[0];
|
|
352
|
-
expect(url).toContain('kbName=WDS_DOCS_KB_ID');
|
|
353
|
-
expect(result).toBe('WDS Documentation content');
|
|
354
|
-
});
|
|
355
|
-
test('performs BUILD_APPS semantic search successfully', async () => {
|
|
356
|
-
const buildAppsResponse = {
|
|
357
|
-
results: {
|
|
358
|
-
BUILD_APPS_KB_ID: {
|
|
359
|
-
results: [
|
|
360
|
-
{
|
|
361
|
-
entry: {
|
|
362
|
-
content: 'Build Apps content 1'
|
|
363
|
-
},
|
|
364
|
-
scoresInfo: {
|
|
365
|
-
overallMatchScore: 0.88
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
]
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
fetchMock.mockResolvedValueOnce({
|
|
373
|
-
ok: true,
|
|
374
|
-
status: 200,
|
|
375
|
-
json: async () => buildAppsResponse
|
|
376
|
-
});
|
|
377
|
-
const result = await runSemanticSearchAndFormat({
|
|
378
|
-
toolName: 'BUILD_APPS',
|
|
379
|
-
toolParams: {
|
|
380
|
-
searchTerm: 'deploy app'
|
|
381
|
-
},
|
|
382
|
-
usePlatformizedSearch: false
|
|
383
|
-
});
|
|
384
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
385
|
-
const [url] = fetchMock.mock.calls[0];
|
|
386
|
-
expect(url).toContain('kbName=BUILD_APPS_KB_ID');
|
|
387
|
-
expect(result).toBe('Build Apps content 1');
|
|
388
|
-
});
|
|
389
|
-
test('performs OVERVIEW semantic search successfully', async () => {
|
|
390
|
-
const overviewResponse = {
|
|
391
|
-
results: {
|
|
392
|
-
OVERVIEW_KB_ID: {
|
|
393
|
-
results: [
|
|
394
|
-
{
|
|
395
|
-
entry: {
|
|
396
|
-
content: 'Overview content 1'
|
|
397
|
-
},
|
|
398
|
-
scoresInfo: {
|
|
399
|
-
overallMatchScore: 0.88
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
]
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
};
|
|
406
|
-
fetchMock.mockResolvedValueOnce({
|
|
407
|
-
ok: true,
|
|
408
|
-
status: 200,
|
|
409
|
-
json: async () => overviewResponse
|
|
410
|
-
});
|
|
411
|
-
const result = await runSemanticSearchAndFormat({
|
|
412
|
-
toolName: 'OVERVIEW',
|
|
413
|
-
toolParams: {
|
|
414
|
-
searchTerm: 'business overview'
|
|
415
|
-
},
|
|
416
|
-
usePlatformizedSearch: false
|
|
417
|
-
});
|
|
418
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
419
|
-
const [url] = fetchMock.mock.calls[0];
|
|
420
|
-
expect(url).toContain('kbName=OVERVIEW_KB_ID');
|
|
421
|
-
expect(result).toBe('Overview content 1');
|
|
422
|
-
});
|
|
423
|
-
test('performs WIX_HEADLESS semantic search successfully', async () => {
|
|
424
|
-
const wixHeadlessResponse = {
|
|
425
|
-
results: {
|
|
426
|
-
WIX_HEADLESS_KB_ID: {
|
|
427
|
-
results: [
|
|
428
|
-
{
|
|
429
|
-
entry: {
|
|
430
|
-
content: 'Wix Headless content 1'
|
|
431
|
-
},
|
|
432
|
-
scoresInfo: {
|
|
433
|
-
overallMatchScore: 0.92
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
]
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
fetchMock.mockResolvedValueOnce({
|
|
441
|
-
ok: true,
|
|
442
|
-
status: 200,
|
|
443
|
-
json: async () => wixHeadlessResponse
|
|
444
|
-
});
|
|
445
|
-
const result = await runSemanticSearchAndFormat({
|
|
446
|
-
toolName: 'WIX_HEADLESS',
|
|
447
|
-
toolParams: {
|
|
448
|
-
searchTerm: 'query'
|
|
449
|
-
},
|
|
450
|
-
usePlatformizedSearch: false
|
|
451
|
-
});
|
|
452
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
453
|
-
const [url] = fetchMock.mock.calls[0];
|
|
454
|
-
expect(url).toContain('kbName=HEADLESS_KB_ID');
|
|
455
|
-
expect(result).toBe('Wix Headless content 1');
|
|
456
|
-
});
|
|
457
|
-
test('performs CLI semantic search successfully', async () => {
|
|
458
|
-
const cliResponse = {
|
|
459
|
-
results: {
|
|
460
|
-
CLI_KB_ID: {
|
|
461
|
-
results: [
|
|
462
|
-
{
|
|
463
|
-
entry: {
|
|
464
|
-
content: 'Wix CLI documentation content'
|
|
465
|
-
},
|
|
466
|
-
scoresInfo: {
|
|
467
|
-
overallMatchScore: 0.91
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
]
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
fetchMock.mockResolvedValueOnce({
|
|
475
|
-
ok: true,
|
|
476
|
-
status: 200,
|
|
477
|
-
json: async () => cliResponse
|
|
478
|
-
});
|
|
479
|
-
const result = await runSemanticSearchAndFormat({
|
|
480
|
-
toolName: 'CLI',
|
|
481
|
-
toolParams: {
|
|
482
|
-
searchTerm: 'wix cli commands'
|
|
483
|
-
},
|
|
484
|
-
usePlatformizedSearch: false
|
|
485
|
-
});
|
|
486
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
487
|
-
const [url] = fetchMock.mock.calls[0];
|
|
488
|
-
expect(url).toContain('kbName=CLI_KB_ID');
|
|
489
|
-
expect(result).toBe('Wix CLI documentation content');
|
|
490
|
-
});
|
|
491
|
-
test('handles API error response', async () => {
|
|
492
|
-
fetchMock.mockResolvedValueOnce({
|
|
493
|
-
ok: false,
|
|
494
|
-
status: 500,
|
|
495
|
-
statusText: 'Internal Server Error'
|
|
496
|
-
});
|
|
497
|
-
await expect(runSemanticSearchAndFormat({
|
|
498
|
-
toolName: 'SDK',
|
|
499
|
-
toolParams: {
|
|
500
|
-
searchTerm: 'query'
|
|
501
|
-
},
|
|
502
|
-
usePlatformizedSearch: false
|
|
503
|
-
})).rejects.toThrow('Failed to run rag search: Internal Server Error');
|
|
504
|
-
});
|
|
505
|
-
test('handles empty results', async () => {
|
|
506
|
-
fetchMock.mockResolvedValueOnce({
|
|
507
|
-
ok: true,
|
|
508
|
-
status: 200,
|
|
509
|
-
json: async () => ({ results: {} })
|
|
510
|
-
});
|
|
511
|
-
await expect(runSemanticSearchAndFormat({
|
|
512
|
-
toolName: 'SDK',
|
|
513
|
-
toolParams: {
|
|
514
|
-
searchTerm: 'query'
|
|
515
|
-
},
|
|
516
|
-
usePlatformizedSearch: false
|
|
517
|
-
})).rejects.toThrow('No result from search');
|
|
518
|
-
});
|
|
519
|
-
test('respects maxResults parameter', async () => {
|
|
520
|
-
const maxResults = 5;
|
|
521
|
-
await runSemanticSearchAndFormat({
|
|
522
|
-
toolName: 'SDK',
|
|
523
|
-
toolParams: {
|
|
524
|
-
searchTerm: 'query'
|
|
525
|
-
},
|
|
526
|
-
maxResults,
|
|
527
|
-
usePlatformizedSearch: false
|
|
528
|
-
});
|
|
529
|
-
const [url] = fetchMock.mock.calls[0];
|
|
530
|
-
expect(url).toContain('maxResults=5');
|
|
531
|
-
});
|
|
532
|
-
test('respects rerank parameter', async () => {
|
|
533
|
-
await runSemanticSearchAndFormat({
|
|
534
|
-
toolName: 'SDK',
|
|
535
|
-
toolParams: {
|
|
536
|
-
searchTerm: 'query'
|
|
537
|
-
},
|
|
538
|
-
maxResults: 5,
|
|
539
|
-
rerank: true,
|
|
540
|
-
usePlatformizedSearch: false
|
|
541
|
-
});
|
|
542
|
-
const [url] = fetchMock.mock.calls[0];
|
|
543
|
-
expect(url).toContain('rerank=true');
|
|
544
|
-
});
|
|
545
|
-
describe('usePlatformizedSearch: true', () => {
|
|
546
|
-
const markdownResponse = (content) => ({ content });
|
|
547
|
-
test('makes POST request to /markdown endpoint with correct body', async () => {
|
|
548
|
-
fetchMock.mockResolvedValueOnce({
|
|
549
|
-
ok: true,
|
|
550
|
-
status: 200,
|
|
551
|
-
json: async () => markdownResponse('some result')
|
|
552
|
-
});
|
|
553
|
-
await runSemanticSearchAndFormat({
|
|
554
|
-
toolName: 'REST',
|
|
555
|
-
toolParams: { searchTerm: 'create collection' },
|
|
556
|
-
usePlatformizedSearch: true
|
|
557
|
-
});
|
|
558
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
559
|
-
const [url, init] = fetchMock.mock.calls[0];
|
|
560
|
-
expect(url).toBe('https://www.wixapis.com/mcp-docs-search/v1/docs/search/markdown');
|
|
561
|
-
expect(init.method).toBe('POST');
|
|
562
|
-
const body = JSON.parse(init.body);
|
|
563
|
-
expect(body).toEqual({
|
|
564
|
-
search_term: 'create collection',
|
|
565
|
-
document_type: 'REST',
|
|
566
|
-
maximum_results: DEFAULT_MAX_RESULTS
|
|
567
|
-
});
|
|
568
|
-
});
|
|
569
|
-
test.each([
|
|
570
|
-
'SDK',
|
|
571
|
-
'REST',
|
|
572
|
-
'WDS',
|
|
573
|
-
'BUILD_APPS',
|
|
574
|
-
'WIX_HEADLESS',
|
|
575
|
-
'VELO',
|
|
576
|
-
'CLI',
|
|
577
|
-
'BUSINESS_SOLUTIONS',
|
|
578
|
-
'OVERVIEW'
|
|
579
|
-
])('sends correct document_type for %s', async (toolName) => {
|
|
580
|
-
fetchMock.mockResolvedValueOnce({
|
|
581
|
-
ok: true,
|
|
582
|
-
status: 200,
|
|
583
|
-
json: async () => markdownResponse('result')
|
|
584
|
-
});
|
|
585
|
-
await runSemanticSearchAndFormat({
|
|
586
|
-
toolName,
|
|
587
|
-
toolParams: { searchTerm: 'test' },
|
|
588
|
-
usePlatformizedSearch: true
|
|
589
|
-
});
|
|
590
|
-
const body = JSON.parse(fetchMock.mock.calls[0][1].body);
|
|
591
|
-
expect(body.document_type).toBe(toolName);
|
|
592
|
-
});
|
|
593
|
-
test('respects maxResults parameter in request body', async () => {
|
|
594
|
-
fetchMock.mockResolvedValueOnce({
|
|
595
|
-
ok: true,
|
|
596
|
-
status: 200,
|
|
597
|
-
json: async () => markdownResponse('result')
|
|
598
|
-
});
|
|
599
|
-
await runSemanticSearchAndFormat({
|
|
600
|
-
toolName: 'SDK',
|
|
601
|
-
toolParams: { searchTerm: 'query' },
|
|
602
|
-
maxResults: 5,
|
|
603
|
-
usePlatformizedSearch: true
|
|
604
|
-
});
|
|
605
|
-
const body = JSON.parse(fetchMock.mock.calls[0][1].body);
|
|
606
|
-
expect(body.maximum_results).toBe(5);
|
|
607
|
-
});
|
|
608
|
-
test('passes linesInEachResult to server in request body', async () => {
|
|
609
|
-
fetchMock.mockResolvedValueOnce({
|
|
610
|
-
ok: true,
|
|
611
|
-
status: 200,
|
|
612
|
-
json: async () => markdownResponse('result')
|
|
613
|
-
});
|
|
614
|
-
await runSemanticSearchAndFormat({
|
|
615
|
-
toolName: 'SDK',
|
|
616
|
-
toolParams: { searchTerm: 'query' },
|
|
617
|
-
linesInEachResult: 20,
|
|
618
|
-
usePlatformizedSearch: true
|
|
619
|
-
});
|
|
620
|
-
const body = JSON.parse(fetchMock.mock.calls[0][1].body);
|
|
621
|
-
expect(body.lines_in_each_result).toBe(20);
|
|
622
|
-
});
|
|
623
|
-
test('handles API error response', async () => {
|
|
624
|
-
fetchMock.mockResolvedValueOnce({
|
|
625
|
-
ok: false,
|
|
626
|
-
status: 500,
|
|
627
|
-
statusText: 'Internal Server Error'
|
|
628
|
-
});
|
|
629
|
-
await expect(runSemanticSearchAndFormat({
|
|
630
|
-
toolName: 'SDK',
|
|
631
|
-
toolParams: { searchTerm: 'query' },
|
|
632
|
-
usePlatformizedSearch: true
|
|
633
|
-
})).rejects.toThrow('Failed to run rag search: Internal Server Error');
|
|
634
|
-
});
|
|
635
|
-
test('throws when server returns empty content', async () => {
|
|
636
|
-
fetchMock.mockResolvedValueOnce({
|
|
637
|
-
ok: true,
|
|
638
|
-
status: 200,
|
|
639
|
-
json: async () => markdownResponse('')
|
|
640
|
-
});
|
|
641
|
-
await expect(runSemanticSearchAndFormat({
|
|
642
|
-
toolName: 'SDK',
|
|
643
|
-
toolParams: { searchTerm: 'query' },
|
|
644
|
-
usePlatformizedSearch: true
|
|
645
|
-
})).rejects.toThrow('No result from search');
|
|
646
|
-
});
|
|
647
|
-
});
|
|
648
|
-
describe('light mode and long content', () => {
|
|
649
|
-
test('respects no linesInEachResult parameter - default behavior', async () => {
|
|
650
|
-
const result = await runSemanticSearchAndFormat({
|
|
651
|
-
toolName: 'SDK',
|
|
652
|
-
toolParams: {
|
|
653
|
-
searchTerm: 'query'
|
|
654
|
-
},
|
|
655
|
-
maxResults: 5,
|
|
656
|
-
rerank: false,
|
|
657
|
-
usePlatformizedSearch: false
|
|
658
|
-
});
|
|
659
|
-
expect(result).toContain('line 3');
|
|
660
|
-
});
|
|
661
|
-
test('respects linesInEachResult parameter', async () => {
|
|
662
|
-
const result = await runSemanticSearchAndFormat({
|
|
663
|
-
toolName: 'SDK',
|
|
664
|
-
toolParams: {
|
|
665
|
-
searchTerm: 'query'
|
|
666
|
-
},
|
|
667
|
-
maxResults: 5,
|
|
668
|
-
rerank: false,
|
|
669
|
-
linesInEachResult: 2,
|
|
670
|
-
usePlatformizedSearch: false
|
|
671
|
-
});
|
|
672
|
-
expect(result).toContain('line 2');
|
|
673
|
-
expect(result).toContain('... 1 more lines ...');
|
|
674
|
-
expect(result).toContain('> Next: read the full article at https://dev.wix.com/docs/sdk/example using the suitable read tool.');
|
|
675
|
-
});
|
|
676
|
-
test('uses method-specific read guidance for truncated method results', async () => {
|
|
677
|
-
fetchMock.mockResolvedValueOnce({
|
|
678
|
-
ok: true,
|
|
679
|
-
status: 200,
|
|
680
|
-
json: async () => ({
|
|
681
|
-
results: {
|
|
682
|
-
REST_METHODS_KB_ID: {
|
|
683
|
-
results: [
|
|
684
|
-
{
|
|
685
|
-
entry: {
|
|
686
|
-
content: 'Method header\ncode example\nschema details',
|
|
687
|
-
url: 'https://dev.wix.com/docs/api-reference/example-method'
|
|
688
|
-
},
|
|
689
|
-
scoresInfo: {
|
|
690
|
-
overallMatchScore: 0.95
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
]
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
})
|
|
697
|
-
});
|
|
698
|
-
const result = await runSemanticSearchAndFormat({
|
|
699
|
-
toolName: 'REST',
|
|
700
|
-
toolParams: {
|
|
701
|
-
searchTerm: 'query'
|
|
702
|
-
},
|
|
703
|
-
maxResults: 5,
|
|
704
|
-
rerank: false,
|
|
705
|
-
linesInEachResult: 1,
|
|
706
|
-
usePlatformizedSearch: false
|
|
707
|
-
});
|
|
708
|
-
expect(result).toContain('... 2 more lines ...');
|
|
709
|
-
expect(result).toContain('> Next: read the full method article at https://dev.wix.com/docs/api-reference/example-method using the suitable read tool to get the complete code examples and method description.\n> If you need more detail about the request or response shape, read the full method schema using the suitable tool.');
|
|
710
|
-
expect(result).not.toContain('> Next: read the full article at ');
|
|
711
|
-
// Not a query/search method — the capability marker must stay off.
|
|
712
|
-
expect(result).not.toContain('closed, endpoint-specific list');
|
|
713
|
-
});
|
|
714
|
-
test('marks query/search methods with the capability hint', async () => {
|
|
715
|
-
fetchMock.mockResolvedValueOnce({
|
|
716
|
-
ok: true,
|
|
717
|
-
status: 200,
|
|
718
|
-
json: async () => ({
|
|
719
|
-
results: {
|
|
720
|
-
REST_METHODS_KB_ID: {
|
|
721
|
-
results: [
|
|
722
|
-
{
|
|
723
|
-
entry: {
|
|
724
|
-
content: '# Method: Query Draft Posts\n# Method API Endpoint: POST https://www.wixapis.com/blog/v3/draft-posts/query\ncode example\nschema details',
|
|
725
|
-
url: 'https://dev.wix.com/docs/api-reference/business-solutions/blog/draft-posts/query-draft-posts'
|
|
726
|
-
},
|
|
727
|
-
scoresInfo: { overallMatchScore: 0.95 }
|
|
728
|
-
}
|
|
729
|
-
]
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
})
|
|
733
|
-
});
|
|
734
|
-
const result = await runSemanticSearchAndFormat({
|
|
735
|
-
toolName: 'REST',
|
|
736
|
-
toolParams: { searchTerm: 'query draft posts' },
|
|
737
|
-
maxResults: 5,
|
|
738
|
-
rerank: false,
|
|
739
|
-
linesInEachResult: 1,
|
|
740
|
-
usePlatformizedSearch: false
|
|
741
|
-
});
|
|
742
|
-
expect(result).toContain('> Query/search: this endpoint declares which fields it can filter and sort by');
|
|
743
|
-
expect(result).toContain('closed and covers this endpoint only');
|
|
744
|
-
});
|
|
745
|
-
test('uses method-specific read guidance for method-shaped content outside method KBs', async () => {
|
|
746
|
-
fetchMock.mockResolvedValueOnce({
|
|
747
|
-
ok: true,
|
|
748
|
-
status: 200,
|
|
749
|
-
json: async () => ({
|
|
750
|
-
results: {
|
|
751
|
-
REST_DOCS_KB_ID: {
|
|
752
|
-
results: [
|
|
753
|
-
{
|
|
754
|
-
entry: {
|
|
755
|
-
content: [
|
|
756
|
-
'# Package: collectionManagement',
|
|
757
|
-
'# Namespace: dataCollections',
|
|
758
|
-
'# Method: List Data Collections',
|
|
759
|
-
'## Method link: https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-collections/list-data-collections',
|
|
760
|
-
'Method details'
|
|
761
|
-
].join('\n')
|
|
762
|
-
},
|
|
763
|
-
scoresInfo: {
|
|
764
|
-
overallMatchScore: 0.95
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
]
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
})
|
|
771
|
-
});
|
|
772
|
-
const result = await runSemanticSearchAndFormat({
|
|
773
|
-
toolName: 'REST',
|
|
774
|
-
toolParams: {
|
|
775
|
-
searchTerm: 'list data collections'
|
|
776
|
-
},
|
|
777
|
-
maxResults: 5,
|
|
778
|
-
rerank: false,
|
|
779
|
-
linesInEachResult: 4,
|
|
780
|
-
usePlatformizedSearch: false
|
|
781
|
-
});
|
|
782
|
-
expect(result).toContain('... 1 more lines ...');
|
|
783
|
-
expect(result).toContain('> Next: read the full method article at https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-collections/list-data-collections using the suitable read tool to get the complete code examples and method description.\n> If you need more detail about the request or response shape, read the full method schema using the suitable tool.');
|
|
784
|
-
});
|
|
785
|
-
test('extracts read hint URL from single-hash method link content', async () => {
|
|
786
|
-
fetchMock.mockResolvedValueOnce({
|
|
787
|
-
ok: true,
|
|
788
|
-
status: 200,
|
|
789
|
-
json: async () => ({
|
|
790
|
-
results: {
|
|
791
|
-
REST_METHODS_KB_ID: {
|
|
792
|
-
results: [
|
|
793
|
-
{
|
|
794
|
-
entry: {
|
|
795
|
-
content: [
|
|
796
|
-
'# Package: catalogV3',
|
|
797
|
-
'# Namespace: productsV3',
|
|
798
|
-
'# Method: Create Product',
|
|
799
|
-
'# Method link: https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/products-v3/create-product',
|
|
800
|
-
'# Method API Endpoint: POST https://www.wixapis.com/stores/v3/products',
|
|
801
|
-
'Method details'
|
|
802
|
-
].join('\n')
|
|
803
|
-
},
|
|
804
|
-
scoresInfo: {
|
|
805
|
-
overallMatchScore: 0.95
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
]
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
})
|
|
812
|
-
});
|
|
813
|
-
const result = await runSemanticSearchAndFormat({
|
|
814
|
-
toolName: 'REST',
|
|
815
|
-
toolParams: {
|
|
816
|
-
searchTerm: 'create product'
|
|
817
|
-
},
|
|
818
|
-
maxResults: 5,
|
|
819
|
-
rerank: false,
|
|
820
|
-
linesInEachResult: 5,
|
|
821
|
-
usePlatformizedSearch: false
|
|
822
|
-
});
|
|
823
|
-
expect(result).toContain('... 1 more lines ...');
|
|
824
|
-
expect(result).toContain('> Next: read the full method article at https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/products-v3/create-product using the suitable read tool to get the complete code examples and method description.\n> If you need more detail about the request or response shape, read the full method schema using the suitable tool.');
|
|
825
|
-
});
|
|
826
|
-
test('extracts read hint URL from article link content when entry URL is missing', async () => {
|
|
827
|
-
fetchMock.mockResolvedValueOnce({
|
|
828
|
-
ok: true,
|
|
829
|
-
status: 200,
|
|
830
|
-
json: async () => ({
|
|
831
|
-
results: {
|
|
832
|
-
REST_DOCS_KB_ID: {
|
|
833
|
-
results: [
|
|
834
|
-
{
|
|
835
|
-
entry: {
|
|
836
|
-
content: [
|
|
837
|
-
'## Article: Catalog Setup',
|
|
838
|
-
'## Article Link: https://dev.wix.com/docs/api-reference/example-article',
|
|
839
|
-
'# Catalog Setup',
|
|
840
|
-
'Body line'
|
|
841
|
-
].join('\n')
|
|
842
|
-
},
|
|
843
|
-
scoresInfo: {
|
|
844
|
-
overallMatchScore: 0.95
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
]
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
})
|
|
851
|
-
});
|
|
852
|
-
const result = await runSemanticSearchAndFormat({
|
|
853
|
-
toolName: 'REST',
|
|
854
|
-
toolParams: {
|
|
855
|
-
searchTerm: 'query'
|
|
856
|
-
},
|
|
857
|
-
maxResults: 5,
|
|
858
|
-
rerank: false,
|
|
859
|
-
linesInEachResult: 2,
|
|
860
|
-
usePlatformizedSearch: false
|
|
861
|
-
});
|
|
862
|
-
expect(result).toContain('... 2 more lines ...');
|
|
863
|
-
expect(result).toContain('> Next: read the full article at https://dev.wix.com/docs/api-reference/example-article using the suitable read tool.');
|
|
864
|
-
});
|
|
865
|
-
test('respects linesInEachResult parameter', async () => {
|
|
866
|
-
const result = await runSemanticSearchAndFormat({
|
|
867
|
-
toolName: 'SDK',
|
|
868
|
-
toolParams: {
|
|
869
|
-
searchTerm: 'query'
|
|
870
|
-
},
|
|
871
|
-
maxResults: 5,
|
|
872
|
-
rerank: false,
|
|
873
|
-
linesInEachResult: 1,
|
|
874
|
-
usePlatformizedSearch: false
|
|
875
|
-
});
|
|
876
|
-
expect(result).not.toContain('line 2');
|
|
877
|
-
});
|
|
878
|
-
test('respects linesInEachResult even if content is too long', async () => {
|
|
879
|
-
const longContentLines = LONG_KB_CONTENT.split('\n');
|
|
880
|
-
const longContentLine1 = longContentLines[0];
|
|
881
|
-
const longContentLine16 = longContentLines[16];
|
|
882
|
-
const result = await runSemanticSearchAndFormat({
|
|
883
|
-
toolName: 'SDK',
|
|
884
|
-
toolParams: {
|
|
885
|
-
searchTerm: 'query'
|
|
886
|
-
},
|
|
887
|
-
maxResults: 10,
|
|
888
|
-
rerank: false,
|
|
889
|
-
linesInEachResult: 15,
|
|
890
|
-
usePlatformizedSearch: false
|
|
891
|
-
});
|
|
892
|
-
expect(result).toContain(longContentLine1);
|
|
893
|
-
expect(result).not.toContain('some-chunked-content');
|
|
894
|
-
expect(result).not.toContain(longContentLine16);
|
|
895
|
-
});
|
|
896
|
-
test('uses chunked content if content is too long and linesInEachResult is not set', async () => {
|
|
897
|
-
const result = await runSemanticSearchAndFormat({
|
|
898
|
-
toolName: 'SDK',
|
|
899
|
-
toolParams: {
|
|
900
|
-
searchTerm: 'query'
|
|
901
|
-
},
|
|
902
|
-
maxResults: 10,
|
|
903
|
-
rerank: false,
|
|
904
|
-
usePlatformizedSearch: false
|
|
905
|
-
});
|
|
906
|
-
expect(result).toContain('some-chunked-content');
|
|
907
|
-
});
|
|
908
|
-
test('uses chunked content if content is too long and linesInEachResult is set', async () => {
|
|
909
|
-
const result = await runSemanticSearchAndFormat({
|
|
910
|
-
toolName: 'SDK',
|
|
911
|
-
toolParams: {
|
|
912
|
-
searchTerm: 'query'
|
|
913
|
-
},
|
|
914
|
-
maxResults: 10,
|
|
915
|
-
rerank: false,
|
|
916
|
-
linesInEachResult: 1500,
|
|
917
|
-
usePlatformizedSearch: false
|
|
918
|
-
});
|
|
919
|
-
expect(result).toContain('some-chunked-content');
|
|
920
|
-
});
|
|
921
|
-
});
|
|
922
|
-
});
|
|
923
|
-
//# sourceMappingURL=semanticSearch.test.js.map
|