@tencentcloud/sdk-mcp 1.6.0 → 1.6.1

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.
@@ -1,3 +1,4 @@
1
+ import { downgradeToProductType } from './product-scope-intent.js';
1
2
  /**
2
3
  * MCP framework enum → index 中对应的 framework 值列表。
3
4
  * path-meta.ts 已通过 normalizeFrameworkDir 把目录名归一到标准 framework,
@@ -12,14 +13,31 @@ function expandFrameworks(framework) {
12
13
  return ['react', 'vue', 'web'];
13
14
  return FRAMEWORK_SEARCH_ALIASES[framework] ?? [framework];
14
15
  }
16
+ /**
17
+ * 类型别名:UIKit「组件(component)」与「feature」是同一批文档的两种叫法
18
+ * (chat preset 双标签,roomkit/live/call 仅打 feature),互相放行避免 types 硬过滤误杀。
19
+ */
20
+ const TYPE_ALIASES = {
21
+ component: ['component', 'feature'],
22
+ feature: ['feature', 'component'],
23
+ };
24
+ function expandTypeAliases(types) {
25
+ const expanded = new Set();
26
+ for (const t of types) {
27
+ for (const alias of TYPE_ALIASES[t] ?? [t])
28
+ expanded.add(alias);
29
+ }
30
+ return [...expanded];
31
+ }
15
32
  /** Chat 无独立 faq.md;types 含 faq 时退化到全语料检索(feature/component/urls 等均命中) */
16
- function resolveTypes(products, types) {
33
+ function resolveTypes(products, types, prompt, framework) {
17
34
  if (!types?.length)
18
35
  return undefined;
19
36
  if (products?.includes('chat') && types.includes('faq')) {
20
37
  return undefined;
21
38
  }
22
- return types;
39
+ const downgraded = downgradeToProductType(products, types, prompt, framework);
40
+ return expandTypeAliases(downgraded);
23
41
  }
24
42
  /** 单平台产品的隐式 framework 推断:避免对显然唯一的平台再发起询问 */
25
43
  function inferImplicitFramework(products, framework) {
@@ -33,7 +51,7 @@ export function normalizeParams(params) {
33
51
  const limit = Math.min(Math.max(params.limit ?? 8, 1), 16);
34
52
  const effectiveFramework = inferImplicitFramework(params.product, params.framework);
35
53
  const frameworks = expandFrameworks(effectiveFramework);
36
- const types = resolveTypes(params.product, params.types);
54
+ const types = resolveTypes(params.product, params.types, params.prompt, effectiveFramework);
37
55
  return {
38
56
  prompt: params.prompt,
39
57
  product: params.product,
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Product-scope intent (routes to chat/urls/product.md, type=product).
3
+ *
4
+ * These questions are about the PRODUCT / account scope — billing, packages, console settings,
5
+ * account & data capabilities configured in the console, storage/retention, usage limits.
6
+ * They are cross-platform and must NOT require a framework.
7
+ *
8
+ * Detection keys on *intent* words (console / billing / limit / product-setting), NOT on
9
+ * capability nouns alone (e.g. "relationship chain", "group management"): those nouns are
10
+ * ambiguous and can also be client-SDK feature questions on a specific platform.
11
+ * A platform / SDK / "how to implement" signal disqualifies the product-scope interpretation.
12
+ */
13
+ const PRODUCT_SCOPE_INTENT = /控制台|计费|套餐|价格|退费|续费|配额|使用限制|数量限制|存储时长|漫游.{0,4}时长|多端登录|登录策略|console|dashboard|billing|pricing|package\s*(plan|feature|difference)|quota|usage\s*limit|multi[\s-]?device\s*login|login\s*(policy|strategy)|(message\s*)?storage\s*(duration|period)|retention/i;
14
+ const CLIENT_IMPL_SIGNAL = /\b(android|ios|flutter|harmonyos|react[\s-]?native|unity|unreal(\s*engine)?|donut|uni[\s-]?app)\b|\bSDK\b|\bAPI\b|怎么(实现|调用|集成|接入|写)|如何(实现|调用|集成|接入|写)|\b(implement|integrate)\b/i;
15
+ export function isProductScopePrompt(prompt) {
16
+ if (!PRODUCT_SCOPE_INTENT.test(prompt))
17
+ return false;
18
+ if (CLIENT_IMPL_SIGNAL.test(prompt))
19
+ return false;
20
+ return true;
21
+ }
22
+ /**
23
+ * When the Agent mislabels a product-scope question as `feature` (no framework given),
24
+ * rewrite the type to `product` so filterPool can hit chat/urls/product.md.
25
+ * If a framework is present, the Agent genuinely wants a client feature — do not downgrade.
26
+ */
27
+ export function downgradeToProductType(products, types, prompt, framework) {
28
+ if (framework)
29
+ return types;
30
+ if (!types.includes('feature'))
31
+ return types;
32
+ if (!products?.includes('chat'))
33
+ return types;
34
+ if (!isProductScopePrompt(prompt))
35
+ return types;
36
+ const downgraded = types.filter((t) => t !== 'feature');
37
+ if (!downgraded.includes('product'))
38
+ downgraded.push('product');
39
+ return downgraded;
40
+ }
@@ -1,3 +1,4 @@
1
+ import { isProductScopePrompt } from './product-scope-intent.js';
1
2
  const PLATFORM_TYPES = new Set([
2
3
  'api',
3
4
  'component',
@@ -25,6 +26,12 @@ const PUSH_OVERVIEW_PROMPT = /开通|创建\s*Push|创建应用|SDKAppID|控制
25
26
  function hasProduct(norm, p) {
26
27
  return !!(norm.product?.includes(p));
27
28
  }
29
+ /** chat/urls/product.md:产品/账号级配置,非客户端 SDK feature */
30
+ function isChatProductScopeQuery(norm) {
31
+ if (!hasProduct(norm, 'chat'))
32
+ return false;
33
+ return isProductScopePrompt(norm.prompt);
34
+ }
28
35
  /** chat error-code URL 同时列了「服务端 / Web / Native」三类入口,必须先问平台才能定位 */
29
36
  function isChatErrorCodeAmbiguous(norm) {
30
37
  if (!hasProduct(norm, 'chat'))
@@ -58,6 +65,8 @@ export function requiresFramework(norm) {
58
65
  return true;
59
66
  if (CROSS_PLATFORM_PROMPT.test(norm.prompt))
60
67
  return false;
68
+ if (isChatProductScopeQuery(norm))
69
+ return false;
61
70
  if (norm.searchIntent?.length) {
62
71
  if (norm.searchIntent.some((t) => PLATFORM_TYPES.has(t)))
63
72
  return true;
@@ -188,7 +188,11 @@ export function searchKnowledge(params) {
188
188
  }
189
189
  const manifest = loadManifest();
190
190
  const allChunks = manifest.chunks;
191
- const pool = filterPool(allChunks, norm);
191
+ let pool = filterPool(allChunks, norm);
192
+ // 自愈:types 过滤导致 0 命中时,丢掉 types 再过滤一次,避免误传类型标签直接返回 empty
193
+ if (pool.length === 0 && norm.types?.length) {
194
+ pool = filterPool(allChunks, { ...norm, types: undefined });
195
+ }
192
196
  const { boosts, exactHits } = runExactLookup(norm.prompt, pool, norm);
193
197
  // P0-4:用 product 级缓存的 BM25 索引对子集打分(首次构建,后续命中缓存)
194
198
  // 索引基于该 product 全量 chunks(含 integration corpus);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tencentcloud/sdk-mcp",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Tencent Cloud MCP Server for SDK",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1 +1 @@
1
- {"chat-setting":["chat-setting","chatsetting","chat_setting"],"contact-list":["contact-list","contactlist","contact_list"],"conversation-actions":["conversation-actions","conversationactions","conversation_actions"],"conversation-list":["conversation-list","conversationlist","conversation_list"],"conversation-preview":["conversation-preview","conversationpreview","conversation_preview"],"conversation-search":["conversation-search","conversationsearch","conversation_search"],"message-input":["message-input","messageinput","message_input"],"message-list":["message-list","messagelist","message_list"],"search":["search","search","search"],"theme":["theme","theme","theme"],"chat-header":["chat-header","chatheader","chat_header"]}
1
+ {}