@tencent-rtc/trtc-agent-skills 0.1.3 → 0.1.5

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.
Files changed (432) hide show
  1. package/.cursor/rules/main.mdc +12 -0
  2. package/AGENTS.md +14 -104
  3. package/CLAUDE.md +15 -127
  4. package/CODEBUDDY.md +15 -125
  5. package/README.md +7 -5
  6. package/README.zh.md +7 -5
  7. package/bin/cli.js +151 -46
  8. package/hooks/__pycache__/cursor-adapter.cpython-313.pyc +0 -0
  9. package/hooks/cursor-adapter.py +45 -18
  10. package/hooks/hooks-cursor.json +5 -18
  11. package/hooks/hooks.json +6 -31
  12. package/knowledge-base/chat/web/index.yaml +168 -0
  13. package/knowledge-base/chat/web/path-d-signals.yaml +4 -0
  14. package/knowledge-base/conference/web/index.yaml +143 -0
  15. package/knowledge-base/docs/chat/debug/GenerateTestUserSig.js +23 -0
  16. package/knowledge-base/docs/chat/debug/lib-generate-test-usersig.min.js +1 -0
  17. package/knowledge-base/docs/chat/gen-usersig.md +129 -0
  18. package/knowledge-base/docs/chat/product.md +61 -0
  19. package/knowledge-base/docs/chat/restapi.md +227 -0
  20. package/knowledge-base/docs/chat/sdk/android/faq.md +7 -0
  21. package/knowledge-base/docs/chat/sdk/android/index.md +94 -0
  22. package/knowledge-base/docs/chat/sdk/flutter/faq.md +7 -0
  23. package/knowledge-base/docs/chat/sdk/flutter/index.md +83 -0
  24. package/knowledge-base/docs/chat/sdk/ios/faq.md +7 -0
  25. package/knowledge-base/docs/chat/sdk/ios/index.md +94 -0
  26. package/knowledge-base/docs/chat/sdk/web/faq.md +8 -0
  27. package/knowledge-base/docs/chat/sdk/web/index.md +97 -0
  28. package/knowledge-base/docs/chat/uikit/android/index.md +28 -0
  29. package/knowledge-base/docs/chat/uikit/flutter/index.md +17 -0
  30. package/knowledge-base/docs/chat/uikit/ios/index.md +28 -0
  31. package/knowledge-base/docs/chat/uikit/react/index.md +6 -0
  32. package/knowledge-base/docs/chat/uikit/uniapp/index.md +6 -0
  33. package/knowledge-base/docs/chat/uikit/vue3/index.md +6 -0
  34. package/knowledge-base/docs/chat/webhook.md +73 -0
  35. package/knowledge-base/platform-slice-template.md +1041 -133
  36. package/knowledge-base/products.yaml +76 -0
  37. package/knowledge-base/scenario-spec.md +1316 -115
  38. package/knowledge-base/scenarios/conference/base/general-conference.md +22 -2
  39. package/knowledge-base/scenarios/conference/base/webinar-conference.md +14 -0
  40. package/knowledge-base/scenarios/conference/medical/1v1-video-consultation.md +19 -0
  41. package/knowledge-base/scenarios/conference/medical/medical-multidoctor-consultation.md +13 -0
  42. package/knowledge-base/scenarios/live/entertainment-live-room.md +12 -0
  43. package/knowledge-base/slice-spec.md +2377 -299
  44. package/knowledge-base/slices/chat/web/at-mention.md +417 -0
  45. package/knowledge-base/slices/chat/web/conversation-actions.md +178 -0
  46. package/knowledge-base/slices/chat/web/conversation-list.md +368 -0
  47. package/knowledge-base/slices/chat/web/detect-integration.md +36 -0
  48. package/knowledge-base/slices/chat/web/detect-style.md +88 -0
  49. package/knowledge-base/slices/chat/web/direct-chat-entry.md +210 -0
  50. package/knowledge-base/slices/chat/web/login-auth.md +244 -0
  51. package/knowledge-base/slices/chat/web/message-base-actions.md +273 -0
  52. package/knowledge-base/slices/chat/web/message-input.md +209 -0
  53. package/knowledge-base/slices/chat/web/message-list.md +532 -0
  54. package/knowledge-base/slices/chat/web/send-custom-message.md +189 -0
  55. package/knowledge-base/slices/chat/web/send-media.md +214 -0
  56. package/knowledge-base/slices/chat/web/state-api-skeleton.md +60 -0
  57. package/knowledge-base/slices/chat/web/style-guide.md +210 -0
  58. package/knowledge-base/slices/conference/web/integration-audit.md +1 -1
  59. package/knowledge-base/slices/conference/web/login-auth.md +14 -1
  60. package/knowledge-base/tooling/aliases.yaml +92 -0
  61. package/knowledge-base/tooling/intent-signals.yaml +181 -0
  62. package/knowledge-base/tooling/symptom-keywords.yaml +21 -0
  63. package/package.json +4 -1
  64. package/skills/trtc/SKILL.md +249 -258
  65. package/skills/trtc/hooks/__pycache__/report_prompt.cpython-313.pyc +0 -0
  66. package/skills/{trtc-topic/guardrails → trtc/hooks}/gate_slice_read.py +12 -8
  67. package/skills/{trtc-topic/guardrails → trtc/hooks}/gate_slice_write.py +16 -12
  68. package/skills/{trtc-topic/guardrails → trtc/hooks}/stop_require_apply_evidence.py +22 -14
  69. package/skills/trtc/hooks/topic_phase_gate.py +166 -0
  70. package/skills/{trtc-topic → trtc}/runtime/README.md +2 -2
  71. package/skills/{trtc-onboarding/reference/reporting-protocol.md → trtc/runtime/REPORTING.md} +5 -5
  72. package/skills/{trtc-topic → trtc}/runtime/RUNTIME.md +5 -5
  73. package/skills/trtc/runtime/lib/__init__.py +0 -0
  74. package/skills/{trtc-topic → trtc}/runtime/package-lock.json +2 -2
  75. package/skills/{trtc-topic → trtc}/runtime/package.json +2 -2
  76. package/skills/{trtc-topic → trtc}/runtime/telemetry-bridge.mjs +1 -1
  77. package/skills/{trtc-topic/scripts → trtc/tools}/STATE-MACHINE-GUIDE.md +23 -23
  78. package/skills/trtc/tools/__init__.py +2 -0
  79. package/skills/trtc/tools/__pycache__/__init__.cpython-313.pyc +0 -0
  80. package/skills/trtc/tools/__pycache__/query_classifier.cpython-313.pyc +0 -0
  81. package/skills/trtc/tools/__pycache__/reporting.cpython-313.pyc +0 -0
  82. package/skills/trtc/tools/__pycache__/search.cpython-313.pyc +0 -0
  83. package/skills/trtc/tools/__pycache__/session.cpython-313.pyc +0 -0
  84. package/skills/trtc/tools/apply.py +540 -0
  85. package/skills/trtc/tools/docs.py +712 -0
  86. package/skills/trtc/tools/docsbot.py +182 -0
  87. package/skills/trtc/tools/entry/render_ai_instructions.py +92 -0
  88. package/skills/trtc/tools/flow.py +1089 -0
  89. package/skills/{trtc-topic/scripts → trtc/tools}/init_slice_queue.py +5 -4
  90. package/skills/trtc/tools/kb.py +130 -0
  91. package/skills/{trtc-topic/scripts → trtc/tools}/next_slice.py +5 -4
  92. package/skills/trtc/tools/query_classifier.py +301 -0
  93. package/skills/trtc/tools/reporting.py +468 -0
  94. package/skills/trtc/tools/reporting_v2.py +263 -0
  95. package/skills/trtc/tools/search.py +817 -0
  96. package/skills/trtc/tools/session.py +1261 -0
  97. package/skills/trtc/tools/state_machine.py +690 -0
  98. package/skills/trtc-ai-service/README.ja.md +199 -0
  99. package/skills/trtc-ai-service/README.md +199 -0
  100. package/skills/trtc-ai-service/README.zh-CN.md +197 -0
  101. package/skills/trtc-ai-service/SKILL.md +945 -0
  102. package/skills/trtc-ai-service/auto_adapters/README.md +40 -0
  103. package/skills/trtc-ai-service/auto_adapters/frontend-spa/README.md +27 -0
  104. package/skills/trtc-ai-service/auto_adapters/frontend-spa/angular/voice-agent.component.ts.tpl +131 -0
  105. package/skills/trtc-ai-service/auto_adapters/frontend-spa/manifest.yaml +57 -0
  106. package/skills/trtc-ai-service/auto_adapters/frontend-spa/react/VoiceAgent.tsx.tpl +142 -0
  107. package/skills/trtc-ai-service/auto_adapters/frontend-spa/vue/VoiceAgent.vue.tpl +121 -0
  108. package/skills/trtc-ai-service/auto_adapters/integration_templates/generic-backend.md +45 -0
  109. package/skills/trtc-ai-service/auto_adapters/integration_templates/generic-frontend.md +51 -0
  110. package/skills/trtc-ai-service/auto_adapters/integration_templates/generic-rest-api.md +93 -0
  111. package/skills/trtc-ai-service/auto_adapters/java-backend/README.md +25 -0
  112. package/skills/trtc-ai-service/auto_adapters/java-backend/manifest.yaml +30 -0
  113. package/skills/trtc-ai-service/auto_adapters/java-backend/quarkus/VoiceAgentFilter.java.tpl +64 -0
  114. package/skills/trtc-ai-service/auto_adapters/java-backend/springboot/VoiceAgentFilter.java.tpl +91 -0
  115. package/skills/trtc-ai-service/auto_adapters/manifest.yaml +43 -0
  116. package/skills/trtc-ai-service/auto_adapters/node-backend/README.md +25 -0
  117. package/skills/trtc-ai-service/auto_adapters/node-backend/express.js.tpl +40 -0
  118. package/skills/trtc-ai-service/auto_adapters/node-backend/fastify.js.tpl +27 -0
  119. package/skills/trtc-ai-service/auto_adapters/node-backend/koa.js.tpl +31 -0
  120. package/skills/trtc-ai-service/auto_adapters/node-backend/manifest.yaml +47 -0
  121. package/skills/trtc-ai-service/auto_adapters/python-backend/README.md +22 -0
  122. package/skills/trtc-ai-service/auto_adapters/python-backend/django.py.tpl +32 -0
  123. package/skills/trtc-ai-service/auto_adapters/python-backend/fastapi.py.tpl +35 -0
  124. package/skills/trtc-ai-service/auto_adapters/python-backend/flask.py.tpl +31 -0
  125. package/skills/trtc-ai-service/auto_adapters/python-backend/manifest.yaml +45 -0
  126. package/skills/trtc-ai-service/capabilities/__init__.py +43 -0
  127. package/skills/trtc-ai-service/capabilities/conversation-core/.env.example +29 -0
  128. package/skills/trtc-ai-service/capabilities/conversation-core/INTEGRATION.md +134 -0
  129. package/skills/trtc-ai-service/capabilities/conversation-core/INTERFACE_ADAPT.md +111 -0
  130. package/skills/trtc-ai-service/capabilities/conversation-core/QUICK_START.md +62 -0
  131. package/skills/trtc-ai-service/capabilities/conversation-core/manifest.yaml +250 -0
  132. package/skills/trtc-ai-service/capabilities/conversation-core/requirements.txt +6 -0
  133. package/skills/trtc-ai-service/capabilities/conversation-core/src/__init__.py +10 -0
  134. package/skills/trtc-ai-service/capabilities/conversation-core/src/_capability_loader.py +218 -0
  135. package/skills/trtc-ai-service/capabilities/conversation-core/src/agent.py +231 -0
  136. package/skills/trtc-ai-service/capabilities/conversation-core/src/credentials.py +132 -0
  137. package/skills/trtc-ai-service/capabilities/conversation-core/src/health.py +355 -0
  138. package/skills/trtc-ai-service/capabilities/conversation-core/src/log_filter.py +76 -0
  139. package/skills/trtc-ai-service/capabilities/conversation-core/src/modality.py +109 -0
  140. package/skills/trtc-ai-service/capabilities/conversation-core/src/server.py +312 -0
  141. package/skills/trtc-ai-service/capabilities/conversation-core/src/trtc_client.py +315 -0
  142. package/skills/trtc-ai-service/capabilities/conversation-core/src/usersig.py +90 -0
  143. package/skills/trtc-ai-service/capabilities/conversation-core/tests/test_skeleton.py +216 -0
  144. package/skills/trtc-ai-service/capabilities/conversation-core/web-demo/README.md +48 -0
  145. package/skills/trtc-ai-service/capabilities/conversation-core/web-demo/app.js +415 -0
  146. package/skills/trtc-ai-service/capabilities/conversation-core/web-demo/index.html +68 -0
  147. package/skills/trtc-ai-service/capabilities/conversation-core/web-demo/styles.css +136 -0
  148. package/skills/trtc-ai-service/capabilities/digital-human/README.md +31 -0
  149. package/skills/trtc-ai-service/capabilities/digital-human/manifest.yaml +64 -0
  150. package/skills/trtc-ai-service/capabilities/digital-human/src/__init__.py +2 -0
  151. package/skills/trtc-ai-service/capabilities/digital-human/src/router.py +43 -0
  152. package/skills/trtc-ai-service/capabilities/human-handoff/INTERFACE_ADAPT.md +353 -0
  153. package/skills/trtc-ai-service/capabilities/human-handoff/README.md +44 -0
  154. package/skills/trtc-ai-service/capabilities/human-handoff/manifest.yaml +227 -0
  155. package/skills/trtc-ai-service/capabilities/human-handoff/src/__init__.py +2 -0
  156. package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/__init__.py +9 -0
  157. package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/default_rest.py +242 -0
  158. package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/factory.py +89 -0
  159. package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/local_queue.py +258 -0
  160. package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/mock.py +132 -0
  161. package/skills/trtc-ai-service/capabilities/human-handoff/src/core/__init__.py +25 -0
  162. package/skills/trtc-ai-service/capabilities/human-handoff/src/core/intent_detector.py +75 -0
  163. package/skills/trtc-ai-service/capabilities/human-handoff/src/core/models.py +163 -0
  164. package/skills/trtc-ai-service/capabilities/human-handoff/src/core/service.py +192 -0
  165. package/skills/trtc-ai-service/capabilities/human-handoff/src/feedback_store.py +54 -0
  166. package/skills/trtc-ai-service/capabilities/human-handoff/src/ports/__init__.py +4 -0
  167. package/skills/trtc-ai-service/capabilities/human-handoff/src/ports/handoff_client.py +86 -0
  168. package/skills/trtc-ai-service/capabilities/human-handoff/src/queue.py +62 -0
  169. package/skills/trtc-ai-service/capabilities/human-handoff/src/router.py +201 -0
  170. package/skills/trtc-ai-service/capabilities/human-handoff/src/summary_link.py +77 -0
  171. package/skills/trtc-ai-service/capabilities/human-handoff/src/trigger.py +25 -0
  172. package/skills/trtc-ai-service/capabilities/knowledge-base/INTERFACE_ADAPT.md +297 -0
  173. package/skills/trtc-ai-service/capabilities/knowledge-base/README.md +51 -0
  174. package/skills/trtc-ai-service/capabilities/knowledge-base/data/faq.json +20 -0
  175. package/skills/trtc-ai-service/capabilities/knowledge-base/manifest.yaml +211 -0
  176. package/skills/trtc-ai-service/capabilities/knowledge-base/src/__init__.py +8 -0
  177. package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/__init__.py +9 -0
  178. package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/default_rest.py +209 -0
  179. package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/factory.py +86 -0
  180. package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/local_json.py +172 -0
  181. package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/mock.py +91 -0
  182. package/skills/trtc-ai-service/capabilities/knowledge-base/src/core/__init__.py +12 -0
  183. package/skills/trtc-ai-service/capabilities/knowledge-base/src/core/models.py +77 -0
  184. package/skills/trtc-ai-service/capabilities/knowledge-base/src/core/scoring.py +73 -0
  185. package/skills/trtc-ai-service/capabilities/knowledge-base/src/core/service.py +78 -0
  186. package/skills/trtc-ai-service/capabilities/knowledge-base/src/ports/__init__.py +4 -0
  187. package/skills/trtc-ai-service/capabilities/knowledge-base/src/ports/kb_client.py +61 -0
  188. package/skills/trtc-ai-service/capabilities/knowledge-base/src/retriever.py +56 -0
  189. package/skills/trtc-ai-service/capabilities/knowledge-base/src/router.py +85 -0
  190. package/skills/trtc-ai-service/capabilities/session-summary/INTERFACE_ADAPT.md +99 -0
  191. package/skills/trtc-ai-service/capabilities/session-summary/README.md +47 -0
  192. package/skills/trtc-ai-service/capabilities/session-summary/data/test_session.json +18 -0
  193. package/skills/trtc-ai-service/capabilities/session-summary/manifest.yaml +165 -0
  194. package/skills/trtc-ai-service/capabilities/session-summary/src/__init__.py +2 -0
  195. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/__init__.py +5 -0
  196. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/base.py +31 -0
  197. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/default_rest.py +67 -0
  198. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/factory.py +51 -0
  199. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/local_json.py +42 -0
  200. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/mock.py +22 -0
  201. package/skills/trtc-ai-service/capabilities/session-summary/src/recorder.py +210 -0
  202. package/skills/trtc-ai-service/capabilities/session-summary/src/router.py +93 -0
  203. package/skills/trtc-ai-service/capabilities/session-summary/src/summarizer.py +163 -0
  204. package/skills/trtc-ai-service/capabilities/tool-calling/INTERFACE_ADAPT.md +158 -0
  205. package/skills/trtc-ai-service/capabilities/tool-calling/README.md +50 -0
  206. package/skills/trtc-ai-service/capabilities/tool-calling/data/tools.yaml +58 -0
  207. package/skills/trtc-ai-service/capabilities/tool-calling/examples/__init__.py +1 -0
  208. package/skills/trtc-ai-service/capabilities/tool-calling/examples/local_tools.py +101 -0
  209. package/skills/trtc-ai-service/capabilities/tool-calling/manifest.yaml +146 -0
  210. package/skills/trtc-ai-service/capabilities/tool-calling/src/__init__.py +8 -0
  211. package/skills/trtc-ai-service/capabilities/tool-calling/src/dispatcher.py +54 -0
  212. package/skills/trtc-ai-service/capabilities/tool-calling/src/registry.py +219 -0
  213. package/skills/trtc-ai-service/capabilities/tool-calling/src/router.py +50 -0
  214. package/skills/trtc-ai-service/references/business-contract-spec.md +263 -0
  215. package/skills/trtc-ai-service/scenarios/custom-builder/README.md +86 -0
  216. package/skills/trtc-ai-service/scenarios/custom-builder/output-templates/recipe.yaml.j2 +194 -0
  217. package/skills/trtc-ai-service/scenarios/custom-builder/prompts/q1-business-scenario.md +43 -0
  218. package/skills/trtc-ai-service/scenarios/custom-builder/prompts/q2-io-modality.md +57 -0
  219. package/skills/trtc-ai-service/scenarios/custom-builder/prompts/q3-ui-form.md +55 -0
  220. package/skills/trtc-ai-service/scenarios/custom-builder/prompts/q4-capabilities.md +78 -0
  221. package/skills/trtc-ai-service/scenarios/customer-service/README.md +114 -0
  222. package/skills/trtc-ai-service/scenarios/customer-service/recipe.yaml +154 -0
  223. package/skills/trtc-ai-service/scenarios/customer-service/sample-data/README.md +32 -0
  224. package/skills/trtc-ai-service/scenarios/customer-service/sample-data/faq-sample.json +37 -0
  225. package/skills/trtc-ai-service/scenarios/customer-service/system-prompt.template.md +94 -0
  226. package/skills/trtc-ai-service/scenarios/customer-service/ui/admin-board/app.js +347 -0
  227. package/skills/trtc-ai-service/scenarios/customer-service/ui/admin-board/index.html +125 -0
  228. package/skills/trtc-ai-service/scenarios/customer-service/ui/admin-board/styles.css +487 -0
  229. package/skills/trtc-ai-service/scenarios/customer-service/ui/admin-board/tokens.css +71 -0
  230. package/skills/trtc-ai-service/scenarios/customer-service/ui/design-system/DESIGN_GUIDELINES.md +370 -0
  231. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/README.md +68 -0
  232. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/app.js +1307 -0
  233. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/data.js +40 -0
  234. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/index.html +233 -0
  235. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/mock-shop.json +21 -0
  236. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/styles.css +603 -0
  237. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/tokens.css +71 -0
  238. package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/agent-link.js +323 -0
  239. package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/app.js +458 -0
  240. package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/index.html +109 -0
  241. package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/styles.css +489 -0
  242. package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/tokens.css +59 -0
  243. package/skills/trtc-ai-service/scripts/add-capability.py +364 -0
  244. package/skills/trtc-ai-service/scripts/contract-adapt.py +334 -0
  245. package/skills/trtc-ai-service/scripts/detect-stack.py +40 -0
  246. package/skills/trtc-ai-service/scripts/lib/__init__.py +20 -0
  247. package/skills/trtc-ai-service/scripts/lib/adapter_codegen.py +509 -0
  248. package/skills/trtc-ai-service/scripts/lib/arbitrator.py +152 -0
  249. package/skills/trtc-ai-service/scripts/lib/contract_resolver.py +519 -0
  250. package/skills/trtc-ai-service/scripts/lib/credential_validators.py +253 -0
  251. package/skills/trtc-ai-service/scripts/lib/curl_parser.py +303 -0
  252. package/skills/trtc-ai-service/scripts/lib/degrader.py +140 -0
  253. package/skills/trtc-ai-service/scripts/lib/injector.py +347 -0
  254. package/skills/trtc-ai-service/scripts/lib/manifest_resolver.py +288 -0
  255. package/skills/trtc-ai-service/scripts/lib/openapi_parser.py +289 -0
  256. package/skills/trtc-ai-service/scripts/lib/stack_detector.py +159 -0
  257. package/skills/trtc-ai-service/scripts/lib/tokens_compile.py +204 -0
  258. package/skills/trtc-ai-service/scripts/post-install-patch.py +225 -0
  259. package/skills/trtc-ai-service/scripts/setup-credentials.py +393 -0
  260. package/skills/trtc-ai-service/scripts/verify-credentials.py +108 -0
  261. package/skills/trtc-ai-service/start.sh +111 -0
  262. package/skills/trtc-ai-service/tests/__init__.py +1 -0
  263. package/skills/trtc-ai-service/tests/test_arbitrator.py +64 -0
  264. package/skills/trtc-ai-service/tests/test_capability_overlay.py +85 -0
  265. package/skills/trtc-ai-service/tests/test_contract_resolver.py +190 -0
  266. package/skills/trtc-ai-service/tests/test_handoff_ports.py +195 -0
  267. package/skills/trtc-ai-service/tests/test_kb_ports.py +195 -0
  268. package/skills/trtc-ai-service/tests/test_manifest_resolver.py +95 -0
  269. package/skills/trtc-ai-service/tests/test_recipe_assembly.py +175 -0
  270. package/skills/trtc-ai-service/tests/test_stack_and_degrader.py +101 -0
  271. package/skills/trtc-ai-service/tests/test_verify_credentials.py +285 -0
  272. package/skills/trtc-ai-service/triggers.yaml +29 -0
  273. package/skills/trtc-chat/.docs-query.yaml +8 -0
  274. package/skills/trtc-chat/SKILL.md +186 -0
  275. package/skills/trtc-chat/docs/SKILL.md +31 -0
  276. package/skills/trtc-chat/flows/maintenance.md +19 -0
  277. package/skills/trtc-chat/flows/onboarding.md +79 -0
  278. package/skills/trtc-chat/references/01-detect-project.md +136 -0
  279. package/skills/trtc-chat/references/02-path-a-questions.md +182 -0
  280. package/skills/trtc-chat/references/02-path-a-scaffold-template.md +59 -0
  281. package/skills/trtc-chat/references/02-path-a-script.md +266 -0
  282. package/skills/trtc-chat/references/02-path-a-templates.md +159 -0
  283. package/skills/trtc-chat/references/03-path-b-script.md +226 -0
  284. package/skills/trtc-chat/references/04-path-c-script.md +95 -0
  285. package/skills/trtc-chat/references/04-uikit-redirect.md +32 -0
  286. package/skills/trtc-chat/references/05-path-d-script.md +647 -0
  287. package/skills/trtc-chat/references/05-slice-loading.md +139 -0
  288. package/skills/trtc-chat/references/06-a-defensive-coding.md +139 -0
  289. package/skills/trtc-chat/references/06-hard-rules.md +190 -0
  290. package/skills/trtc-chat/references/08-state-config.md +229 -0
  291. package/skills/trtc-chat/references/09-troubleshoot.md +91 -0
  292. package/skills/trtc-chat/references/10-references-index.md +63 -0
  293. package/skills/trtc-chat/references/11-what-to-do-next-template.md +338 -0
  294. package/skills/trtc-chat/references/12-page-composition.md +73 -0
  295. package/skills/trtc-chat/references/13-reporting.md +128 -0
  296. package/skills/trtc-chat/references/14-official-docs.md +169 -0
  297. package/skills/trtc-chat/references/execution-units.yaml +27 -0
  298. package/skills/trtc-chat/references/vue3.md +104 -0
  299. package/skills/trtc-chat/tests/test_chat_bundle_contract.py +293 -0
  300. package/skills/trtc-chat/tools/__init__.py +5 -0
  301. package/skills/trtc-chat/tools/_delegate.py +32 -0
  302. package/skills/trtc-chat/tools/flow.py +8 -0
  303. package/skills/trtc-chat/tools/kb.py +8 -0
  304. package/skills/trtc-chat/tools/reporting_v2.py +8 -0
  305. package/skills/trtc-chat/tools/session.py +8 -0
  306. package/skills/trtc-conference/SKILL.md +324 -0
  307. package/skills/trtc-conference/flows/onboarding.md +205 -0
  308. package/skills/trtc-conference/flows/topic.md +474 -0
  309. package/skills/trtc-conference/flows/troubleshoot.md +85 -0
  310. package/skills/trtc-conference/hooks/pretooluse_require_business_decisions.py +213 -0
  311. package/skills/trtc-conference/playbooks/medical-quickstart.md +84 -0
  312. package/skills/trtc-conference/playbooks/official-roomkit.md +97 -0
  313. package/skills/trtc-conference/references/local-usersig/basic-info-config.ts +39 -0
  314. package/skills/trtc-conference/references/usersig-handling.md +134 -0
  315. package/skills/trtc-conference/templates/medical-consultation/src/config/lib-generate-test-usersig-es.min.d.ts +4 -0
  316. package/skills/trtc-conference/templates/medical-consultation/src/config/lib-generate-test-usersig-es.min.js +2 -0
  317. package/skills/trtc-conference/tests/__pycache__/test_conference_onboarding_contract.cpython-313-pytest-9.0.2.pyc +0 -0
  318. package/skills/trtc-conference/tests/__pycache__/test_conference_topic_flow_contract.cpython-313-pytest-9.0.2.pyc +0 -0
  319. package/skills/trtc-conference/tests/test_conference_index_contract.py +43 -0
  320. package/skills/trtc-conference/tests/test_conference_onboarding_contract.py +103 -0
  321. package/skills/trtc-conference/tests/test_conference_template_contract.py +25 -0
  322. package/skills/trtc-conference/tests/test_conference_topic_flow_contract.py +132 -0
  323. package/skills/trtc-conference/tools/apply_checks.py +328 -0
  324. package/skills/trtc-conference/verify_lib/__init__.py +0 -0
  325. package/skills/{trtc-apply/guardrails/apply_lib → trtc-conference/verify_lib}/rule_parser.py +1 -1
  326. package/skills/trtc-docs/SKILL.md +91 -119
  327. package/.cursor/rules/ui-mode.mdc +0 -99
  328. package/ai-instructions/base.md +0 -13
  329. package/ai-instructions/ui-mode.md +0 -93
  330. package/knowledge-base/index.yaml +0 -462
  331. package/skills/trtc/room-builder/SKILL.md +0 -133
  332. package/skills/trtc/room-builder/templates/scenarios/medical-consultation/README.md +0 -108
  333. package/skills/trtc/room-builder/tools/render_ai_instructions.py +0 -226
  334. package/skills/trtc-apply/SKILL.md +0 -97
  335. package/skills/trtc-onboarding/SKILL.md +0 -841
  336. package/skills/trtc-onboarding/reference/path-a1-demo.md +0 -103
  337. package/skills/trtc-onboarding/reference/path-a2-integrate.md +0 -737
  338. package/skills/trtc-onboarding/reference/path-b-troubleshoot.md +0 -186
  339. package/skills/trtc-onboarding/reference/path-c-expand.md +0 -43
  340. package/skills/trtc-onboarding/reference/supported-matrix.md +0 -100
  341. package/skills/trtc-search/SKILL.md +0 -228
  342. package/skills/trtc-topic/SKILL.md +0 -622
  343. package/skills/trtc-topic/scripts/apply.py +0 -581
  344. package/skills/trtc-topic/scripts/lib/state_machine.py +0 -328
  345. package/skills/trtc-topic/tests/README.md +0 -70
  346. package/skills/trtc-topic/tests/conftest.py +0 -72
  347. package/skills/trtc-topic/tests/test_apply_cli.py +0 -480
  348. package/skills/trtc-topic/tests/test_end_to_end.py +0 -305
  349. package/skills/trtc-topic/tests/test_finalize_session.py +0 -51
  350. package/skills/trtc-topic/tests/test_gates.py +0 -316
  351. package/skills/trtc-topic/tests/test_session_resolver.py +0 -260
  352. package/skills/trtc-topic/tests/test_state_machine.py +0 -414
  353. package/skills/trtc-topic/tests/test_stop_require_apply.py +0 -99
  354. package/skills/trtc-topic/tests/test_topic_skill_invariants.py +0 -130
  355. /package/skills/{trtc-topic → trtc}/runtime/lib/platforms.py +0 -0
  356. /package/skills/{trtc-topic → trtc}/runtime/telemetry_collector.py +0 -0
  357. /package/skills/{trtc-onboarding/reference → trtc/runtime}/usersig-handling.md +0 -0
  358. /package/skills/{trtc-topic/scripts → trtc/tools}/finalize_session.py +0 -0
  359. /package/skills/{trtc-apply/guardrails/apply_lib → trtc-ai-service/capabilities/conversation-core/tests}/__init__.py +0 -0
  360. /package/skills/{trtc-topic → trtc-conference}/references/execution-units.yaml +0 -0
  361. /package/skills/{trtc/room-builder/templates/scenarios/medical-consultation/src/config → trtc-conference/references/local-usersig}/lib-generate-test-usersig-es.min.d.ts +0 -0
  362. /package/skills/{trtc/room-builder/templates/scenarios/medical-consultation/src/config → trtc-conference/references/local-usersig}/lib-generate-test-usersig-es.min.js +0 -0
  363. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/docs/backend-contract.zh-CN.md +0 -0
  364. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/docs/integration.zh-CN.md +0 -0
  365. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/docs/theme.zh-CN.md +0 -0
  366. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/index.html +0 -0
  367. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/package.json +0 -0
  368. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/postcss.config.js +0 -0
  369. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/App.vue +0 -0
  370. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/ConsultationManagePanel.vue +0 -0
  371. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/LanguageSwitch.vue +0 -0
  372. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/LoadingSpinner.vue +0 -0
  373. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalAlert.vue +0 -0
  374. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalBusinessPanel.vue +0 -0
  375. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalButton.vue +0 -0
  376. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalConfirmDialog.vue +0 -0
  377. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalDataPanel.vue +0 -0
  378. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalRecordPanel.vue +0 -0
  379. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/PrescriptionPanel.vue +0 -0
  380. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/config/basic-info-config.ts +0 -0
  381. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/config/runtime-config.ts +0 -0
  382. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/env.d.ts +0 -0
  383. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/ConsultationChatPanel.vue +0 -0
  384. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/ConsultationMembersPanel.vue +0 -0
  385. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/ConsultationTranscriptionPanel.vue +0 -0
  386. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/ConsultationVideoStage.vue +0 -0
  387. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/InviteDoctorDialog.vue +0 -0
  388. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/KickMemberConfirmDialog.vue +0 -0
  389. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/types.ts +0 -0
  390. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/useConsultationChat.ts +0 -0
  391. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/useConsultationDevices.ts +0 -0
  392. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/useConsultationParticipants.ts +0 -0
  393. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/useConsultationPermissions.ts +0 -0
  394. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/utils.ts +0 -0
  395. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/en-US/index.ts +0 -0
  396. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/index.ts +0 -0
  397. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/medicalTranslate.ts +0 -0
  398. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/state.ts +0 -0
  399. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/zh-CN/index.ts +0 -0
  400. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/main.ts +0 -0
  401. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/mock/appointments.ts +0 -0
  402. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/mock/users.ts +0 -0
  403. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/router/index.ts +0 -0
  404. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/index.ts +0 -0
  405. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/integration/appointmentService.ts +0 -0
  406. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/integration/authService.ts +0 -0
  407. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/integration/launchContext.ts +0 -0
  408. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/integration/userService.ts +0 -0
  409. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/mock/appointmentService.ts +0 -0
  410. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/mock/authService.ts +0 -0
  411. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/mock/userService.ts +0 -0
  412. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/types.ts +0 -0
  413. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/shared/icons.ts +0 -0
  414. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/styles/index.css +0 -0
  415. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/styles/tailwind.css +0 -0
  416. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/styles/theme.css +0 -0
  417. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/utils/auth.ts +0 -0
  418. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/utils/format.ts +0 -0
  419. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/utils/navigation.ts +0 -0
  420. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/utils/session.ts +0 -0
  421. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/DoctorConsultationView.vue +0 -0
  422. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/DoctorDashboardView.vue +0 -0
  423. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/LoginView.vue +0 -0
  424. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/PatientConsultationFinishedView.vue +0 -0
  425. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/PatientConsultationView.vue +0 -0
  426. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/PatientSelectDoctorView.vue +0 -0
  427. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/PatientWaitingView.vue +0 -0
  428. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/tsconfig.json +0 -0
  429. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/tsconfig.node.json +0 -0
  430. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/vite.config.ts +0 -0
  431. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation//346/216/245/345/205/245/350/257/264/346/230/216.md" +0 -0
  432. /package/skills/{trtc-topic/runtime/lib → trtc-conference/tools}/__init__.py +0 -0
@@ -0,0 +1,139 @@
1
+ # 05 - Slice 命中机制 + 多候选选择 + 兜底
2
+
3
+ > dispatcher 在以下三个时机主动 `read_file` 本文件:
4
+ > - 路径 A 的 **A.1.5 被动解析**(命中扩展 slice / 收集 unsupported_intents)
5
+ > - 路径 A 的 A.5 引导菜单选中后
6
+ > - 路径 B 的 B.2 听需求阶段
7
+
8
+ ## 5.1 命中流程
9
+
10
+ ```
11
+ 1. Bash `python3 -m tools.kb resolve chat/web/index.yaml` → Read
12
+ (含所有 slice 的 frontmatter 摘要:id / description / trigger-keywords /
13
+ applies-to / sdk-version / prerequisites)
14
+
15
+ 2. 解析用户需求(动词 + 名词 + 业务术语)
16
+ - 动词:发送 / 加 / 实现 / 接 / 显示 / 接收 / 撤回 / 搜索 / ...
17
+ - 名词:消息 / 卡片 / 群 / 会话 / 已读 / ...
18
+ - 业务术语:订单 / 商品 / 优惠券 / 红包 / 投票 / 客服 / 评价 / ...
19
+
20
+ 3. 在 trigger-keywords 中找语义匹配的 slice
21
+ ⚠ 注意:trigger-keywords 是给 LLM 看的元数据,不是 grep 字段。
22
+ 用语义能力做模糊命中,不依赖精确字符串匹配。
23
+
24
+ 4. 多个候选时,按下面 §5.2 排序
25
+
26
+ 5. 命中 → read_file 读 slice 完整内容 → 进入写代码阶段
27
+
28
+ 6. 完全没命中 → §5.3 兜底
29
+ - 路径 A.1.5 场景:归入 unsupported_intents,A.4 口头收尾时一并提示,**不**进 §5.3 兜底实现
30
+ - 路径 B B.2 场景:进 §5.3 兜底实现 + 提 issue
31
+ ```
32
+
33
+ ## 5.2 多候选排序
34
+
35
+ 按以下优先级降序:
36
+
37
+ 1. `applies-to` 匹配当前项目集成方式(`tuikit-atomicx-vue3`)
38
+ 2. `sdk-version` 匹配项目实际 SDK 版本(`package.json` 里的 `tuikit-atomicx-vue3` 版本)
39
+ 3. `prerequisites` 链与 `session(session_context.chat)` 已完成项匹配的越多越优
40
+ - 路径 A.1.5 场景:`base_slices_applied` 视为已完成(4 件套基础 + 已入列的 extensionSlices)
41
+ - 路径 B 场景:`base_slices_applied` + `extension_slices_applied` 都视为已完成
42
+ 4. `trigger-keywords` 命中关键词数量
43
+
44
+ 最后仍并列时:
45
+
46
+ ```
47
+ > 我找到几个 slice 都对得上:
48
+ > 1. send-custom-message(自定义订单卡片)
49
+ > 2. send-image-advanced(图片消息)
50
+ >
51
+ > 你描述的 "我要发订单消息" 是哪种?
52
+ > 还是先做订单卡片,图片放它的字段里?
53
+ ```
54
+
55
+ 让用户做最后决策,不要替用户选。
56
+
57
+ ## 5.3 兜底分支(无 slice 命中)
58
+
59
+ ### 路径 A.1.5 场景(被动解析阶段)
60
+
61
+ ❌ **不**走 §5.3 自由实现。命中失败的意图归入 `unsupported_intents`:
62
+
63
+ ```jsonc
64
+ {
65
+ "raw": "把消息翻译成英文", // 用户原话
66
+ "intent": "message-translation", // dispatcher 抽取的意图标签
67
+ "askedAt": "2026-05-20T15:22:00Z"
68
+ }
69
+ ```
70
+
71
+ A.4 收尾时在 agent 回复里说一次(按意图类别给 fallback 建议,详见 `./02-path-a-script.md` § A.4),**不写额外文件**。
72
+
73
+ ### 路径 B B.2 场景(已集成项目的二次增量)
74
+
75
+ ❗ **未命中 slice 时,禁止自由实现**——不准基于训练数据猜测 SDK 用法、不准用 `chat.xxx` 旧 API 硬写代码。
76
+
77
+ 输出以下话术后**停止**,等待用户反馈:
78
+
79
+ ```
80
+ > 抱歉,我的知识库里暂时没有找到对应这个功能的实现指南,目前无法为您实现该功能。
81
+ >
82
+ > 您可以通过工单向 即时通信 IM 团队反馈,我们会评估是否将其加入 slice 库:
83
+ > https://console.cloud.tencent.com/workorder/category
84
+ >
85
+ > 如果您有其他功能需求,欢迎继续告诉我。
86
+ ```
87
+
88
+ ❌ **以下是典型违规输出,出现即视为执行错误**:
89
+
90
+ ```
91
+ // 违规:读骨架文件自由实现
92
+ const msg = await chat.createCustomMessage({ payload: { data: '...' } })
93
+ await chat.sendMessage({ to: targetID, message: msg })
94
+ // → 旧 API,与 State API 架构冲突,直接导致应用崩溃
95
+ ```
96
+
97
+ ```
98
+ // 违规:给"仅供参考"的示例代码
99
+ // 以下是基于 SDK 通用规则的参考实现,仅供参考:
100
+ const store = useMessageInputStore(conversationID)
101
+ await store.sendMessage({ type: 'customMessage', customData: '...' })
102
+ // → 用户会直接复制使用,没有 slice 规范约束,一定会出错,导致不可用
103
+ ```
104
+
105
+ ## 5.4 prerequisites 链解析(A.1.5 / B.2 共用)
106
+
107
+ 命中 slice 时必须递归校验 prerequisites:
108
+
109
+ ```
110
+ resolveDeps(sliceId):
111
+ slice = index[sliceId]
112
+ for prereq in slice.prerequisites:
113
+ if prereq in base_slices_applied + extension_slices_applied + currentBatch:
114
+ continue // 已满足
115
+ if prereq in index AND prereq not in base_slices_applied:
116
+ currentBatch.unshift(prereq) // 自动补齐前置
117
+ resolveDeps(prereq) // 递归
118
+ else:
119
+ throw 'unmet-prerequisite'
120
+
121
+ A.1.5 场景:
122
+ - 链长 ≤ 2(命中 1 个 slice + 自动补齐 1 个前置)→ 静默补齐
123
+ - 链长 ≥ 3 → 把整条链显式列给用户:"为了实现 X,需要同时装 Y / Z,确认吗?"
124
+ 用户拒绝 → 整个意图降级到 unsupported_intents
125
+
126
+ B.2 场景:
127
+ - 任意链长都显式列给用户确认(路径 B 是用户主动驱动,不容易因链长惊到)
128
+ ```
129
+
130
+ ## 5.5 命中失败的常见原因(自查清单)
131
+
132
+ dispatcher 自己使用,不是给用户看的:
133
+
134
+ - 关键词在 `trigger-keywords` 里漏列了 → 提 issue 补关键词
135
+ - 用户用的是别名(如把 "已读回执" 说成 "看过没") → 适当扩词
136
+ - 用户描述的是组合场景(如 "群里发订单") → 命中两个 slice,先后实现
137
+ - 场景超出当前 features 范围(如客服分配系统) → 走 §5.3 兜底
138
+ - A.1.5 阶段意图 confidence < 0.7 → 直接丢弃,不进 unsupported_intents(避免污染 session(session_context.chat))
139
+
@@ -0,0 +1,139 @@
1
+ # 06-a - 防御编程统一规范
2
+
3
+ > 所有 slice 的 API 调用必须遵循本文件规范。dispatcher 写代码前与 `06-hard-rules.md` 并行 `read_file`。
4
+
5
+ ---
6
+
7
+ ## 6a.1 异步 API 调用范式
8
+
9
+ 所有 SDK 异步调用必须遵循以下模板:
10
+
11
+ ```ts
12
+ import { formatError } from '@/im/error-map'
13
+
14
+ const loading = ref(false)
15
+
16
+ async function handleAction() {
17
+ loading.value = true
18
+ try {
19
+ await sdkApi(...)
20
+ // 成功处理
21
+ } catch (err: any) {
22
+ showFeedback(formatError(err)) // 见 § 6a.3,必须给用户可见反馈
23
+ } finally {
24
+ loading.value = false
25
+ }
26
+ }
27
+ ```
28
+
29
+ ❌ **禁止**:
30
+ - `try/finally` 无 `catch`(失败静默吞掉)
31
+ - `catch` 里只 `console.error` 不给 UI 反馈
32
+
33
+ ---
34
+
35
+ ## 6a.2 错误反馈形式
36
+
37
+ 根据操作类型选择不同的反馈形式:
38
+
39
+ | 操作类型 | 反馈形式 | 原因 |
40
+ |---|---|---|
41
+ | **发消息** | 输入框附近就近显示小字 | 不打断输入流,用户可直接重试 |
42
+ | **加载消息/会话列表** | 列表区域内空态提示 + 重试按钮 | 不遮挡已有内容 |
43
+ | **写操作**(撤回/删除/置顶/免打扰/清空) | Toast(2-3 秒自动消失) | 轻量提示,不需要用户主动关闭 |
44
+ | **登录失败** | 就地显示错误 | 需要引导用户操作 |
45
+
46
+ ❗ **有 UI 库时优先用 UI 库的 Toast/Message 组件;无 UI 库时自建最小 Toast(有 Tailwind/SCSS)或 `alert()`(空项目,标 TODO)**
47
+
48
+ ### Toast / 错误提示视觉规范
49
+
50
+ - **颜色**:使用项目 error 色(UI 库的 `type="error"` / `variant="destructive"` / 红色系),不准用默认灰色或 info 色
51
+ - **显示位置**:居中或偏上(`top-center`),不准显示在底部——底部容易被输入框或 toolbar 遮挡
52
+ - **z-index**:`9999`,确保不被页面其他层遮挡
53
+ - **最大宽度**:`max-width: 360px`(或项目 Toast 组件已有的最大宽度约束,跟随项目规范)
54
+ - **文字换行**:`word-break: break-word`,不准单行溢出截断(`text-overflow: ellipsis`)——错误信息必须完整可读,不能被截断
55
+ - **自建 Toast 无 UI 库时**:
56
+ ```css
57
+ .toast-error {
58
+ max-width: 360px;
59
+ word-break: break-word;
60
+ /* error 色跟随项目 CSS 变量或 Tailwind token */
61
+ }
62
+ ```
63
+
64
+ ---
65
+
66
+ ## 6a.3 错误信息内容
67
+
68
+ ❗ **禁止把 SDK 原始错误 JSON 直接暴露给用户**
69
+
70
+ ❗ **`ERROR_MAP` 和 `formatError` 必须提取为共用模块**,不准在每个组件里各自定义:
71
+
72
+ ```
73
+ src/im/error-map.ts ← 统一维护,各组件 import 使用
74
+ ```
75
+
76
+ 参考实现(`src/im/error-map.ts`):
77
+
78
+ ```ts
79
+ const ERROR_MAP: Record<number, string> = {
80
+ 20003: '对方账号不存在,请确认 userID 是否正确;可先用该 userID 登录一次,或在腾讯云 IM 控制台手动创建',
81
+ 70001: '登录凭证已过期,请重新生成 UserSig 后再登录',
82
+ 70003: '登录凭证解析失败,请使用官网提供的 API 重新生成 UserSig',
83
+ 70009: 'UserSig 验证失败,请检查请求的 SDKAppID 和生成 UserSig 的密钥或私钥是否一致',
84
+ 70013: '请求的 UserID 与生成 UserSig 时使用的 UserID 不一致,可使用 IM 控制台 UserSig 生成&校验工具校验',
85
+ 70014: '请求的 SDKAppID 与生成 UserSig 时使用的 SDKAppID 不一致,可使用 IM 控制台 UserSig 生成&校验工具校验',
86
+ 10015: '群组不存在或已经被解散,请确认群组 ID 是否正确',
87
+ 2501: '对方账号不存在,请确认 userID 是否正确;可先用该 userID 登录一次,或在腾讯云 IM 控制台手动创建',
88
+ 2801: '网络请求超时,请检查网络连接',
89
+ }
90
+
91
+ export function formatError(err: any): string {
92
+ const code = err?.code
93
+ return ERROR_MAP[code] ?? err?.errorMessage ?? '操作失败,请稍后重试'
94
+ }
95
+ ```
96
+
97
+ > `error.errorMessage` 是 SDK 返回的错误描述字段,比 `err.message`(JS 原生 Error)更准确。优先用映射表,映射表未覆盖时才降级显示 `errorMessage`。
98
+
99
+ 各组件使用方式:
100
+
101
+ ```ts
102
+ import { formatError } from '@/im/error-map'
103
+
104
+ } catch (err: any) {
105
+ showFeedback(formatError(err))
106
+ }
107
+ ```
108
+
109
+ ---
110
+
111
+ ## 6a.4 状态锁规则
112
+
113
+ 状态锁用于表达 loading 态(禁用按钮、显示加载中),必须在 `finally` 里复位:
114
+
115
+ | 操作类型 | 锁变量命名 |
116
+ |---|---|
117
+ | 发消息 | `sending` |
118
+ | 加载列表/消息 | `loading` / `loadingOlder` |
119
+ | 登录/登出 | `loggingIn` |
120
+ | 写操作(撤回/删除等) | `submitting` / `loading` |
121
+
122
+ ❗ 状态锁必须在 `finally` 里复位,不能在 `try` 里复位(catch 路径会跳过)
123
+
124
+ ---
125
+
126
+ ## 6a.5 入参校验规则
127
+
128
+ 以下情况必须做入参校验,不满足条件直接 `return`(不发请求):
129
+
130
+ | 参数 | 校验条件 |
131
+ |---|---|
132
+ | 文本消息内容 | `text.trim().length > 0` |
133
+ | userID | 非空字符串 |
134
+ | conversationID | 非空字符串 |
135
+ | 文件大小 | 图片 ≤ 20MB / 视频 ≤ 100MB / 文件 ≤ 100MB |
136
+
137
+ ❌ **禁止**:空 userID / 空文本直接发请求(会触发 SDK 报错,体验差且浪费请求)
138
+
139
+ > ❗ **调用顺序约束**(发消息前必须等 login resolve)见 `06-hard-rules.md § 6.1`。
@@ -0,0 +1,190 @@
1
+ # 06 - Hard rules 全量版(含反例)
2
+
3
+ > 主 SKILL.md 仅保留摘要。dispatcher 在写代码 / 自检前主动 `read_file` 本文件。首次加载后可缓存到当前会话上下文。
4
+
5
+ ## 两大绝对约束(违反任一必须返工,不可跳过)
6
+
7
+ > **SDK API 正确性** 和 **视觉规范** 是同级的绝对约束,不存在"功能先跑起来、UI 后期再改"的优先级。
8
+ > - SDK API 错误 → 运行时崩溃,交付物不可用
9
+ > - 视觉规范违反 → 交付物不达标,同样视为返工
10
+
11
+ ❗ **写每一个组件前**,先问自己两个问题:
12
+ 1. 这个组件调用的 SDK API 是否来自 slice §3,还是从训练数据猜的?
13
+ 2. 这个组件打开后视觉上是否达标?容器有没有从底色浮起?颜色是否超过 1 个主色?间距/圆角/字号是否命中锚点值?气泡圆角是否不对称?
14
+
15
+ ---
16
+
17
+ ## 6.1 SDK API 是绝对真理
18
+
19
+ ### ❗ 不准从训练数据猜 API 名称
20
+ LLM 训练数据里有大量过期 / 错版的腾讯云 IM SDK 调用方式(如 `tim.sendMsg` 之类的旧名),**所有 SDK 调用必须从 slice 的"§ 3 SDK API 必读"段落里复制**。
21
+
22
+ ❌ 反例:
23
+ ```ts
24
+ // 不准这样写
25
+ tim.sendMsg({ to: 'user1', body: 'hi' });
26
+ ```
27
+
28
+ ✅ 正例(来自 slice):
29
+ ```ts
30
+ import { useMessageInputStore } from 'tuikit-atomicx-vue3/chat'
31
+ const { sendMessage } = useMessageInputStore(conversationID)
32
+ await sendMessage({ type: 'textMessage', text: 'hi' })
33
+ ```
34
+
35
+ ### ❗ payload 必须 `JSON.stringify` 后传 SDK
36
+ 自定义消息的 `data` / `description` / `extension` 等字段,SDK 期望的是字符串。
37
+
38
+ ❌ 反例:
39
+ ```ts
40
+ chat.createCustomMessage({ payload: { data: { orderId: 1 } } }); // 直接传对象
41
+ ```
42
+
43
+ ✅ 正例:
44
+ ```ts
45
+ chat.createCustomMessage({
46
+ payload: {
47
+ data: JSON.stringify({ orderId: 1 }), // ✅ 字符串
48
+ description: '订单卡片',
49
+ extension: '',
50
+ },
51
+ });
52
+ ```
53
+
54
+ ### ❗ businessID 必须有可读语义
55
+ - 必须与卡片业务强相关(如 `order` / `product` / `coupon` / `red-packet` / `rating`)
56
+ - 团队若有命名空间约定(如 `trtc/*` / `biz/*` / `shop/*`)→ 跟随团队约定
57
+ - ❌ 不准写 `'1'` / `'123'` / `'custom'` / `'card'` / `'msg'` 等无语义裸值
58
+ - 评价卡片不再是默认 demo(v0.2 起已并入 `send-custom-message` slice,businessID 自定义如 `rating` / `customer-rating`)
59
+
60
+ ### ❗ 发送消息前必须 `await` login resolve
61
+ 未登录就调 send → SDK 会抛 60016 / 60005 等。
62
+
63
+ ✅ 正例:
64
+ ```ts
65
+ await chat.login({ userID, userSig }); // 必须等
66
+ await chat.sendMessage(message);
67
+ ```
68
+
69
+ ### ❗ 不准改用户已有组件内部实现
70
+ - 一律在用户业务代码层用 State API 直接调 SDK
71
+ - 不准 `document.querySelector('.tui-chat-input')` 这类 hack 已有组件 DOM
72
+ - 不准用 `:deep(...)` 强改用户既有组件样式
73
+ - 增量功能写在自己新建的业务组件里,与项目已有组件并存(含可能存在的 UIKit)
74
+
75
+ ---
76
+
77
+ ## 6.2 UI 是自由的,但守 3 条底线
78
+
79
+ > 样式由 AI 自由发挥,不预设审美规则。但必须遵循项目已有 CSS 方案和 UI 库。
80
+
81
+ ❗ **写任何 UI 组件代码前,必须先** Bash `python3 -m tools.kb resolve slices/chat/web/style-guide.md` → Read(用色 / 圆角 / 间距 / 视觉禁区 / 精细化手法全在里面),所有 starter / feature slice 的 UI 部分均适用。
82
+
83
+ ### ❗ 必须使用项目已有 CSS 方案和 UI 库
84
+ - 探测到 Tailwind → 用 Tailwind utility,不要再引一套 CSS
85
+ - 探测到 Element Plus → 用 `<el-card>` `<el-button>`,不要手撸 div
86
+ - 探测到 shadcn → 用 `<Card>` `<Dialog>`,不要再装新 UI 库
87
+ - 空项目(无已有体系)→ 路径 A 默认装 Tailwind,AI 自由写样式
88
+
89
+ ### ❗ 必须复用项目已存在的同类组件
90
+ - `src/components/ui/card.vue` 存在 → 卡片消息复用,不再新建
91
+ - `src/components/ui/dialog.vue` 存在 → 详情弹窗复用
92
+
93
+ ### ❗ 必须遵循项目现有命名约定
94
+ - 文件名:跟 `src/components/*` 现有大小写一致
95
+ - 组件名:跟现有 `<script setup>` / Options API 风格一致
96
+ - TS 类型:跟现有 interface / type 命名一致
97
+
98
+ ---
99
+
100
+ ## 6.3 增量改动安全
101
+
102
+ ### ❗ patch 文件前必须先 `read_file`
103
+ - 用户可能在你上次 read 之后改过文件
104
+ - 直接 patch 会覆盖未读到的最新改动
105
+
106
+ ### ❗ 不准改用户已有的 SDK 初始化 / 登录代码
107
+ - 路径 B 项目里 `src/im/init.ts` 里的 `chat.create` / `chat.login` 已经在跑
108
+ - 增量功能必须在用户已有的 chat 实例上调 API
109
+ - 如果发现 init 写法陈旧 / 有 bug → 先告知用户,不要默默改
110
+
111
+ ### ❗ Plan 阶段必须显式列出"不会改的东西"
112
+ - 这是给用户的承诺,也是 dispatcher 自己的红线
113
+ - 模板见 `03-path-b-script.md` B.4
114
+
115
+ ### ❗ 写文件前必须确认改动清单(用户可打断)
116
+ - 列出所有要新增 / 修改的文件路径
117
+ - 等用户回"开始" / "调整:xxx" 再动手
118
+ - 用户说"按你判断"等同于"开始"
119
+
120
+ ---
121
+
122
+ ## 6.4 逐 slice 闭环 + 禁止预读(long-context 退化对策)
123
+
124
+ > 这一节 hard rules 适用于**所有**多 slice 场景:路径 A 的 A.3 基础 4 件套 + A.3.x 扩展 N 件套(N ≤ 3),以及路径 B 一次需求命中多个 slice(如"群里发订单卡片"同时命中 `group-chat` + `send-custom-message`)的情况。
125
+
126
+ ### ❗ 禁止预读
127
+ - 写第 N 个 slice 时,**不准** `read_file` 第 N+1、N+2…个 slice 文件
128
+ - 不准在 Plan 阶段批量装载所有候选 slice 再回头一个个写
129
+ - 下一个 slice 必须在当前 slice 的 read → plan → write → self-check → 内部记账 5 步全部完成后再读
130
+
131
+ ### ❗ 每轮闭环
132
+ 每个 slice 的处理必须严格走 5 步:
133
+
134
+ ```
135
+ Step 1 read_file 当前 slice 完整内容
136
+ Step 2 Plan:1-3 句告诉用户本轮要写什么 / 不会改什么
137
+ Step 3 Write:按 slice § 3 SDK API + § 4 hard rules 实现
138
+ Step 4 Self-check:对照本 slice § 反例库
139
+ Step 5 内部记账(仅当前会话上下文,不写盘):
140
+ - 本轮已完成 slice 名
141
+ - 本轮新建 / 修改的文件清单
142
+ - 用了哪些项目已有组件(供后续轮复用)
143
+ ```
144
+
145
+ Self-check 不通过就在本轮内修,**不准**带着问题进入下一个 slice。
146
+
147
+ ### ❗ 跨轮命名一致性
148
+ - 第 2 个 slice 起,写代码前先回看上一轮 Step 5 的"已用组件清单"
149
+ - 命名必须延续上一轮,不准每个 slice 另起一套
150
+ - 如本轮发现上一轮命名有问题 → 在本轮 Plan 里显式提出"建议把上一轮的 X 改名为 Y",征求用户同意后改;不准默默改
151
+
152
+ ### ❗ 扩展轮结构前瞻(防止"新卡片塞进旧气泡容器")
153
+ - 扩展轮(如追加自定义卡片 Bubble / 新消息类型分支)写代码**前**,必须先 `read_file` 上一轮生成的模板文件,确认:
154
+ 1. 新组件要插入的位置——是在现有气泡容器**内部**还是**外部**?
155
+ 2. 如果自定义卡片不应套在气泡容器内,而上一轮模板没有为此预留分支出口 → 本轮 Plan 里**必须显式提出结构重构**(把新分支提到气泡容器外面),不准偷懒直接往已有容器里塞
156
+ 3. 重构范围写进 Plan 的"本轮要改的文件清单",让用户可打断
157
+ - ❌ 反例:上一轮 `message-list` 把所有 type 统一包在 `<div class="msg-bubble">` 里,扩展轮直接在 `msg-bubble` 内部加了 `<OrderCardBubble>` 组件 → 卡片被套在气泡背景/圆角/阴影里,违反"自定义卡片不套气泡"
158
+ - ✅ 正例:扩展轮发现上一轮没有为 `MessageType.Custom` 预留"跳出气泡"的结构分支 → Plan 里写"需重构 MessageList 模板:Custom 分支提到 msg-bubble 外层" → 用户确认后再写
159
+
160
+ ### 为什么这条规则存在(写给 dispatcher 自己看)
161
+
162
+ ❌ **典型故障模式**(一次性批量读取 5 份 slice → 一次性生成全部代码时观察到的):
163
+ - 写到第 4、5 个 slice 时,§ 4 hard rules 已"远离视野",幻觉 SDK API 名 / 漏 `JSON.stringify` payload / businessID 错写成无前缀
164
+ - 不同 slice 之间组件命名不一致(`MessageBubble` vs `MsgItem` vs `ChatBubble` 同一个东西取三个名)
165
+ - 后写的覆盖前写的命名约定,需要回头返工
166
+
167
+ ✅ **机制原理**:长上下文下 LLM 的 attention 对越早出现的内容衰减越严重(recency bias)。逐 slice 闭环让"当前 slice § 3 + § 4"始终是 ≤300 行内的最近上下文,attention 落在它身上;上一轮的输出通过 Step 5 的"已用组件 / token 清单"以**精炼摘要**而非"原文回滚"的方式带入下一轮,是 long-context attention dilution 的标准对策。
168
+
169
+ ---
170
+
171
+ ## 6.5 自检清单(写完后必走)
172
+
173
+ - [ ] 所有 `chat.createXxxMessage` / `chat.sendMessage` 调用与 slice 一致
174
+ - [ ] 所有 payload `data` 字段都 `JSON.stringify` 过
175
+ - [ ] businessID 都有可读业务语义(`order` / `coupon` / `rating` 等;团队有命名空间约定就跟随),无 `'1'` / `'custom'` / `'card'` 等裸值
176
+ - [ ] 没有引入新的 UI 库(除非 slice 明确要求)
177
+ - [ ] 没有改 `src/im/init.ts` 等已有初始化文件(除非用户明确同意)
178
+ - [ ] `.trtc-session.yaml`(经 `tools.session`) 已写入新 slice 名(写入字段:`extension_slices_applied` 追加 + `changes` append;详见 `08-state-config.md`);`<projectRoot>` 由 `08-state-config.md` § 8.1.1 找根算法决定
179
+
180
+ ---
181
+
182
+ ## 6.6 引导菜单内容来源
183
+
184
+ - ❗ 只列 knowledge-base 中实际存在的 slice(以 `tools.kb resolve chat/web/index.yaml` 与 `tools.kb resolve slices/chat/web/<name>.md` 为准)
185
+ - ❗ 未命中任何 slice 的功能不出现在推荐列表中
186
+ - ❌ 根据 SDK 通用能力推测"应该有"的 feature slice
187
+ - [ ] 没有把临时 mock 接口写成永久代码(标 `// TODO: replace with real API`)
188
+ - [ ] **本轮 slice 是 read → plan → write → self-check 单轮闭环完成的**(不是把 N 个 slice 一次读完再批量写;多 slice 场景见 § 6.4)
189
+ - [ ] 所有异步 SDK 调用都有 `try/catch/finally`,`catch` 里调 `showFeedback(formatError(err))`,无静默吞错
190
+ - [ ] 错误反馈形式符合 `06-a-defensive-coding.md § 6a.2`(发消息→就近小字 / 写操作→Toast / 加载→空态+重试)