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

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 (360) 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 +32 -118
  5. package/README.md +7 -5
  6. package/README.zh.md +7 -5
  7. package/bin/cli.js +133 -41
  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/conference/web/index.yaml +143 -0
  13. package/knowledge-base/platform-slice-template.md +1041 -133
  14. package/knowledge-base/products.yaml +76 -0
  15. package/knowledge-base/scenario-spec.md +1316 -115
  16. package/knowledge-base/scenarios/conference/base/general-conference.md +22 -2
  17. package/knowledge-base/scenarios/conference/base/webinar-conference.md +14 -0
  18. package/knowledge-base/scenarios/conference/medical/1v1-video-consultation.md +19 -0
  19. package/knowledge-base/scenarios/conference/medical/medical-multidoctor-consultation.md +13 -0
  20. package/knowledge-base/scenarios/live/entertainment-live-room.md +12 -0
  21. package/knowledge-base/slice-spec.md +2377 -299
  22. package/knowledge-base/slices/conference/web/integration-audit.md +1 -1
  23. package/knowledge-base/slices/conference/web/login-auth.md +14 -1
  24. package/knowledge-base/tooling/aliases.yaml +92 -0
  25. package/knowledge-base/tooling/intent-signals.yaml +181 -0
  26. package/knowledge-base/tooling/symptom-keywords.yaml +21 -0
  27. package/package.json +1 -1
  28. package/skills/trtc/SKILL.md +202 -245
  29. package/skills/trtc/hooks/__pycache__/report_prompt.cpython-313.pyc +0 -0
  30. package/skills/{trtc-topic/guardrails → trtc/hooks}/gate_slice_read.py +12 -8
  31. package/skills/{trtc-topic/guardrails → trtc/hooks}/gate_slice_write.py +16 -12
  32. package/skills/{trtc-topic/guardrails → trtc/hooks}/stop_require_apply_evidence.py +22 -14
  33. package/skills/trtc/hooks/topic_phase_gate.py +161 -0
  34. package/skills/{trtc-topic → trtc}/runtime/README.md +2 -2
  35. package/skills/{trtc-onboarding/reference/reporting-protocol.md → trtc/runtime/REPORTING.md} +5 -5
  36. package/skills/{trtc-topic → trtc}/runtime/RUNTIME.md +5 -5
  37. package/skills/trtc/runtime/lib/__init__.py +0 -0
  38. package/skills/{trtc-topic → trtc}/runtime/package-lock.json +2 -2
  39. package/skills/{trtc-topic → trtc}/runtime/package.json +2 -2
  40. package/skills/{trtc-topic → trtc}/runtime/telemetry-bridge.mjs +1 -1
  41. package/skills/{trtc-topic/scripts → trtc/tools}/STATE-MACHINE-GUIDE.md +23 -23
  42. package/skills/trtc/tools/__init__.py +2 -0
  43. package/skills/trtc/tools/__pycache__/__init__.cpython-313.pyc +0 -0
  44. package/skills/trtc/tools/__pycache__/query_classifier.cpython-313.pyc +0 -0
  45. package/skills/trtc/tools/__pycache__/reporting.cpython-313.pyc +0 -0
  46. package/skills/trtc/tools/__pycache__/search.cpython-313.pyc +0 -0
  47. package/skills/trtc/tools/__pycache__/session.cpython-313.pyc +0 -0
  48. package/skills/trtc/tools/apply.py +540 -0
  49. package/skills/trtc/tools/docs.py +712 -0
  50. package/skills/trtc/tools/docsbot.py +182 -0
  51. package/skills/trtc/tools/entry/render_ai_instructions.py +92 -0
  52. package/skills/trtc/tools/flow.py +1089 -0
  53. package/skills/{trtc-topic/scripts → trtc/tools}/init_slice_queue.py +5 -4
  54. package/skills/{trtc-topic/scripts → trtc/tools}/next_slice.py +5 -4
  55. package/skills/trtc/tools/query_classifier.py +301 -0
  56. package/skills/trtc/tools/reporting.py +447 -0
  57. package/skills/trtc/tools/search.py +817 -0
  58. package/skills/trtc/tools/session.py +1261 -0
  59. package/skills/trtc/tools/state_machine.py +690 -0
  60. package/skills/trtc-ai-service/README.md +195 -0
  61. package/skills/trtc-ai-service/README.zh-CN.md +193 -0
  62. package/skills/trtc-ai-service/SKILL.md +945 -0
  63. package/skills/trtc-ai-service/auto_adapters/README.md +40 -0
  64. package/skills/trtc-ai-service/auto_adapters/frontend-spa/README.md +27 -0
  65. package/skills/trtc-ai-service/auto_adapters/frontend-spa/angular/voice-agent.component.ts.tpl +131 -0
  66. package/skills/trtc-ai-service/auto_adapters/frontend-spa/manifest.yaml +57 -0
  67. package/skills/trtc-ai-service/auto_adapters/frontend-spa/react/VoiceAgent.tsx.tpl +142 -0
  68. package/skills/trtc-ai-service/auto_adapters/frontend-spa/vue/VoiceAgent.vue.tpl +121 -0
  69. package/skills/trtc-ai-service/auto_adapters/integration_templates/generic-backend.md +45 -0
  70. package/skills/trtc-ai-service/auto_adapters/integration_templates/generic-frontend.md +51 -0
  71. package/skills/trtc-ai-service/auto_adapters/integration_templates/generic-rest-api.md +93 -0
  72. package/skills/trtc-ai-service/auto_adapters/java-backend/README.md +25 -0
  73. package/skills/trtc-ai-service/auto_adapters/java-backend/manifest.yaml +30 -0
  74. package/skills/trtc-ai-service/auto_adapters/java-backend/quarkus/VoiceAgentFilter.java.tpl +64 -0
  75. package/skills/trtc-ai-service/auto_adapters/java-backend/springboot/VoiceAgentFilter.java.tpl +91 -0
  76. package/skills/trtc-ai-service/auto_adapters/manifest.yaml +43 -0
  77. package/skills/trtc-ai-service/auto_adapters/node-backend/README.md +25 -0
  78. package/skills/trtc-ai-service/auto_adapters/node-backend/express.js.tpl +40 -0
  79. package/skills/trtc-ai-service/auto_adapters/node-backend/fastify.js.tpl +27 -0
  80. package/skills/trtc-ai-service/auto_adapters/node-backend/koa.js.tpl +31 -0
  81. package/skills/trtc-ai-service/auto_adapters/node-backend/manifest.yaml +47 -0
  82. package/skills/trtc-ai-service/auto_adapters/python-backend/README.md +22 -0
  83. package/skills/trtc-ai-service/auto_adapters/python-backend/django.py.tpl +32 -0
  84. package/skills/trtc-ai-service/auto_adapters/python-backend/fastapi.py.tpl +35 -0
  85. package/skills/trtc-ai-service/auto_adapters/python-backend/flask.py.tpl +31 -0
  86. package/skills/trtc-ai-service/auto_adapters/python-backend/manifest.yaml +45 -0
  87. package/skills/trtc-ai-service/capabilities/__init__.py +43 -0
  88. package/skills/trtc-ai-service/capabilities/conversation-core/.env.example +29 -0
  89. package/skills/trtc-ai-service/capabilities/conversation-core/INTEGRATION.md +134 -0
  90. package/skills/trtc-ai-service/capabilities/conversation-core/INTERFACE_ADAPT.md +111 -0
  91. package/skills/trtc-ai-service/capabilities/conversation-core/QUICK_START.md +62 -0
  92. package/skills/trtc-ai-service/capabilities/conversation-core/manifest.yaml +250 -0
  93. package/skills/trtc-ai-service/capabilities/conversation-core/requirements.txt +6 -0
  94. package/skills/trtc-ai-service/capabilities/conversation-core/src/__init__.py +10 -0
  95. package/skills/trtc-ai-service/capabilities/conversation-core/src/_capability_loader.py +218 -0
  96. package/skills/trtc-ai-service/capabilities/conversation-core/src/agent.py +231 -0
  97. package/skills/trtc-ai-service/capabilities/conversation-core/src/credentials.py +132 -0
  98. package/skills/trtc-ai-service/capabilities/conversation-core/src/health.py +355 -0
  99. package/skills/trtc-ai-service/capabilities/conversation-core/src/log_filter.py +76 -0
  100. package/skills/trtc-ai-service/capabilities/conversation-core/src/modality.py +109 -0
  101. package/skills/trtc-ai-service/capabilities/conversation-core/src/server.py +312 -0
  102. package/skills/trtc-ai-service/capabilities/conversation-core/src/trtc_client.py +315 -0
  103. package/skills/trtc-ai-service/capabilities/conversation-core/src/usersig.py +90 -0
  104. package/skills/trtc-ai-service/capabilities/conversation-core/tests/test_skeleton.py +216 -0
  105. package/skills/trtc-ai-service/capabilities/conversation-core/web-demo/README.md +48 -0
  106. package/skills/trtc-ai-service/capabilities/conversation-core/web-demo/app.js +415 -0
  107. package/skills/trtc-ai-service/capabilities/conversation-core/web-demo/index.html +68 -0
  108. package/skills/trtc-ai-service/capabilities/conversation-core/web-demo/styles.css +136 -0
  109. package/skills/trtc-ai-service/capabilities/digital-human/README.md +31 -0
  110. package/skills/trtc-ai-service/capabilities/digital-human/manifest.yaml +64 -0
  111. package/skills/trtc-ai-service/capabilities/digital-human/src/__init__.py +2 -0
  112. package/skills/trtc-ai-service/capabilities/digital-human/src/router.py +43 -0
  113. package/skills/trtc-ai-service/capabilities/human-handoff/INTERFACE_ADAPT.md +353 -0
  114. package/skills/trtc-ai-service/capabilities/human-handoff/README.md +44 -0
  115. package/skills/trtc-ai-service/capabilities/human-handoff/manifest.yaml +227 -0
  116. package/skills/trtc-ai-service/capabilities/human-handoff/src/__init__.py +2 -0
  117. package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/__init__.py +9 -0
  118. package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/default_rest.py +242 -0
  119. package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/factory.py +89 -0
  120. package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/local_queue.py +258 -0
  121. package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/mock.py +132 -0
  122. package/skills/trtc-ai-service/capabilities/human-handoff/src/core/__init__.py +25 -0
  123. package/skills/trtc-ai-service/capabilities/human-handoff/src/core/intent_detector.py +75 -0
  124. package/skills/trtc-ai-service/capabilities/human-handoff/src/core/models.py +163 -0
  125. package/skills/trtc-ai-service/capabilities/human-handoff/src/core/service.py +192 -0
  126. package/skills/trtc-ai-service/capabilities/human-handoff/src/feedback_store.py +54 -0
  127. package/skills/trtc-ai-service/capabilities/human-handoff/src/ports/__init__.py +4 -0
  128. package/skills/trtc-ai-service/capabilities/human-handoff/src/ports/handoff_client.py +86 -0
  129. package/skills/trtc-ai-service/capabilities/human-handoff/src/queue.py +62 -0
  130. package/skills/trtc-ai-service/capabilities/human-handoff/src/router.py +201 -0
  131. package/skills/trtc-ai-service/capabilities/human-handoff/src/summary_link.py +77 -0
  132. package/skills/trtc-ai-service/capabilities/human-handoff/src/trigger.py +25 -0
  133. package/skills/trtc-ai-service/capabilities/knowledge-base/INTERFACE_ADAPT.md +297 -0
  134. package/skills/trtc-ai-service/capabilities/knowledge-base/README.md +51 -0
  135. package/skills/trtc-ai-service/capabilities/knowledge-base/data/faq.json +20 -0
  136. package/skills/trtc-ai-service/capabilities/knowledge-base/manifest.yaml +211 -0
  137. package/skills/trtc-ai-service/capabilities/knowledge-base/src/__init__.py +8 -0
  138. package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/__init__.py +9 -0
  139. package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/default_rest.py +209 -0
  140. package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/factory.py +86 -0
  141. package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/local_json.py +172 -0
  142. package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/mock.py +91 -0
  143. package/skills/trtc-ai-service/capabilities/knowledge-base/src/core/__init__.py +12 -0
  144. package/skills/trtc-ai-service/capabilities/knowledge-base/src/core/models.py +77 -0
  145. package/skills/trtc-ai-service/capabilities/knowledge-base/src/core/scoring.py +73 -0
  146. package/skills/trtc-ai-service/capabilities/knowledge-base/src/core/service.py +78 -0
  147. package/skills/trtc-ai-service/capabilities/knowledge-base/src/ports/__init__.py +4 -0
  148. package/skills/trtc-ai-service/capabilities/knowledge-base/src/ports/kb_client.py +61 -0
  149. package/skills/trtc-ai-service/capabilities/knowledge-base/src/retriever.py +56 -0
  150. package/skills/trtc-ai-service/capabilities/knowledge-base/src/router.py +85 -0
  151. package/skills/trtc-ai-service/capabilities/session-summary/INTERFACE_ADAPT.md +99 -0
  152. package/skills/trtc-ai-service/capabilities/session-summary/README.md +47 -0
  153. package/skills/trtc-ai-service/capabilities/session-summary/data/test_session.json +18 -0
  154. package/skills/trtc-ai-service/capabilities/session-summary/manifest.yaml +165 -0
  155. package/skills/trtc-ai-service/capabilities/session-summary/src/__init__.py +2 -0
  156. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/__init__.py +5 -0
  157. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/base.py +31 -0
  158. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/default_rest.py +67 -0
  159. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/factory.py +51 -0
  160. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/local_json.py +42 -0
  161. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/mock.py +22 -0
  162. package/skills/trtc-ai-service/capabilities/session-summary/src/recorder.py +210 -0
  163. package/skills/trtc-ai-service/capabilities/session-summary/src/router.py +93 -0
  164. package/skills/trtc-ai-service/capabilities/session-summary/src/summarizer.py +163 -0
  165. package/skills/trtc-ai-service/capabilities/tool-calling/INTERFACE_ADAPT.md +158 -0
  166. package/skills/trtc-ai-service/capabilities/tool-calling/README.md +50 -0
  167. package/skills/trtc-ai-service/capabilities/tool-calling/data/tools.yaml +58 -0
  168. package/skills/trtc-ai-service/capabilities/tool-calling/examples/__init__.py +1 -0
  169. package/skills/trtc-ai-service/capabilities/tool-calling/examples/local_tools.py +101 -0
  170. package/skills/trtc-ai-service/capabilities/tool-calling/manifest.yaml +146 -0
  171. package/skills/trtc-ai-service/capabilities/tool-calling/src/__init__.py +8 -0
  172. package/skills/trtc-ai-service/capabilities/tool-calling/src/dispatcher.py +54 -0
  173. package/skills/trtc-ai-service/capabilities/tool-calling/src/registry.py +219 -0
  174. package/skills/trtc-ai-service/capabilities/tool-calling/src/router.py +50 -0
  175. package/skills/trtc-ai-service/references/business-contract-spec.md +263 -0
  176. package/skills/trtc-ai-service/scenarios/custom-builder/README.md +86 -0
  177. package/skills/trtc-ai-service/scenarios/custom-builder/output-templates/recipe.yaml.j2 +194 -0
  178. package/skills/trtc-ai-service/scenarios/custom-builder/prompts/q1-business-scenario.md +43 -0
  179. package/skills/trtc-ai-service/scenarios/custom-builder/prompts/q2-io-modality.md +57 -0
  180. package/skills/trtc-ai-service/scenarios/custom-builder/prompts/q3-ui-form.md +55 -0
  181. package/skills/trtc-ai-service/scenarios/custom-builder/prompts/q4-capabilities.md +78 -0
  182. package/skills/trtc-ai-service/scenarios/customer-service/README.md +114 -0
  183. package/skills/trtc-ai-service/scenarios/customer-service/recipe.yaml +154 -0
  184. package/skills/trtc-ai-service/scenarios/customer-service/sample-data/README.md +32 -0
  185. package/skills/trtc-ai-service/scenarios/customer-service/sample-data/faq-sample.json +37 -0
  186. package/skills/trtc-ai-service/scenarios/customer-service/system-prompt.template.md +94 -0
  187. package/skills/trtc-ai-service/scenarios/customer-service/ui/admin-board/app.js +347 -0
  188. package/skills/trtc-ai-service/scenarios/customer-service/ui/admin-board/index.html +125 -0
  189. package/skills/trtc-ai-service/scenarios/customer-service/ui/admin-board/styles.css +487 -0
  190. package/skills/trtc-ai-service/scenarios/customer-service/ui/admin-board/tokens.css +71 -0
  191. package/skills/trtc-ai-service/scenarios/customer-service/ui/design-system/DESIGN_GUIDELINES.md +370 -0
  192. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/README.md +68 -0
  193. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/app.js +1307 -0
  194. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/data.js +40 -0
  195. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/index.html +233 -0
  196. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/mock-shop.json +21 -0
  197. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/styles.css +603 -0
  198. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/tokens.css +71 -0
  199. package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/agent-link.js +323 -0
  200. package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/app.js +458 -0
  201. package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/index.html +109 -0
  202. package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/styles.css +489 -0
  203. package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/tokens.css +59 -0
  204. package/skills/trtc-ai-service/scripts/add-capability.py +364 -0
  205. package/skills/trtc-ai-service/scripts/contract-adapt.py +334 -0
  206. package/skills/trtc-ai-service/scripts/detect-stack.py +40 -0
  207. package/skills/trtc-ai-service/scripts/lib/__init__.py +20 -0
  208. package/skills/trtc-ai-service/scripts/lib/adapter_codegen.py +509 -0
  209. package/skills/trtc-ai-service/scripts/lib/arbitrator.py +152 -0
  210. package/skills/trtc-ai-service/scripts/lib/contract_resolver.py +519 -0
  211. package/skills/trtc-ai-service/scripts/lib/credential_validators.py +253 -0
  212. package/skills/trtc-ai-service/scripts/lib/curl_parser.py +303 -0
  213. package/skills/trtc-ai-service/scripts/lib/degrader.py +140 -0
  214. package/skills/trtc-ai-service/scripts/lib/injector.py +347 -0
  215. package/skills/trtc-ai-service/scripts/lib/manifest_resolver.py +288 -0
  216. package/skills/trtc-ai-service/scripts/lib/openapi_parser.py +289 -0
  217. package/skills/trtc-ai-service/scripts/lib/stack_detector.py +159 -0
  218. package/skills/trtc-ai-service/scripts/lib/tokens_compile.py +204 -0
  219. package/skills/trtc-ai-service/scripts/post-install-patch.py +225 -0
  220. package/skills/trtc-ai-service/scripts/setup-credentials.py +393 -0
  221. package/skills/trtc-ai-service/scripts/verify-credentials.py +108 -0
  222. package/skills/trtc-ai-service/start.sh +111 -0
  223. package/skills/trtc-ai-service/tests/__init__.py +1 -0
  224. package/skills/trtc-ai-service/tests/test_arbitrator.py +64 -0
  225. package/skills/trtc-ai-service/tests/test_capability_overlay.py +85 -0
  226. package/skills/trtc-ai-service/tests/test_contract_resolver.py +190 -0
  227. package/skills/trtc-ai-service/tests/test_handoff_ports.py +195 -0
  228. package/skills/trtc-ai-service/tests/test_kb_ports.py +195 -0
  229. package/skills/trtc-ai-service/tests/test_manifest_resolver.py +95 -0
  230. package/skills/trtc-ai-service/tests/test_recipe_assembly.py +175 -0
  231. package/skills/trtc-ai-service/tests/test_stack_and_degrader.py +101 -0
  232. package/skills/trtc-ai-service/tests/test_verify_credentials.py +285 -0
  233. package/skills/trtc-ai-service/triggers.yaml +29 -0
  234. package/skills/trtc-conference/SKILL.md +324 -0
  235. package/skills/trtc-conference/flows/onboarding.md +205 -0
  236. package/skills/trtc-conference/flows/topic.md +474 -0
  237. package/skills/trtc-conference/flows/troubleshoot.md +85 -0
  238. package/skills/trtc-conference/hooks/pretooluse_require_business_decisions.py +213 -0
  239. package/skills/trtc-conference/playbooks/medical-quickstart.md +84 -0
  240. package/skills/trtc-conference/playbooks/official-roomkit.md +97 -0
  241. package/skills/trtc-conference/references/local-usersig/basic-info-config.ts +39 -0
  242. package/skills/trtc-conference/references/usersig-handling.md +134 -0
  243. package/skills/trtc-conference/templates/medical-consultation/src/config/lib-generate-test-usersig-es.min.d.ts +4 -0
  244. package/skills/trtc-conference/templates/medical-consultation/src/config/lib-generate-test-usersig-es.min.js +2 -0
  245. package/skills/trtc-conference/tests/__pycache__/test_conference_onboarding_contract.cpython-313-pytest-9.0.2.pyc +0 -0
  246. package/skills/trtc-conference/tests/__pycache__/test_conference_topic_flow_contract.cpython-313-pytest-9.0.2.pyc +0 -0
  247. package/skills/trtc-conference/tests/test_conference_index_contract.py +43 -0
  248. package/skills/trtc-conference/tests/test_conference_onboarding_contract.py +103 -0
  249. package/skills/trtc-conference/tests/test_conference_template_contract.py +25 -0
  250. package/skills/trtc-conference/tests/test_conference_topic_flow_contract.py +132 -0
  251. package/skills/trtc-conference/tools/apply_checks.py +328 -0
  252. package/skills/trtc-conference/verify_lib/__init__.py +0 -0
  253. package/skills/{trtc-apply/guardrails/apply_lib → trtc-conference/verify_lib}/rule_parser.py +1 -1
  254. package/skills/trtc-docs/SKILL.md +91 -119
  255. package/.cursor/rules/ui-mode.mdc +0 -99
  256. package/ai-instructions/base.md +0 -13
  257. package/ai-instructions/ui-mode.md +0 -93
  258. package/knowledge-base/index.yaml +0 -462
  259. package/skills/trtc/room-builder/SKILL.md +0 -133
  260. package/skills/trtc/room-builder/templates/scenarios/medical-consultation/README.md +0 -108
  261. package/skills/trtc/room-builder/tools/render_ai_instructions.py +0 -226
  262. package/skills/trtc-apply/SKILL.md +0 -97
  263. package/skills/trtc-onboarding/SKILL.md +0 -841
  264. package/skills/trtc-onboarding/reference/path-a1-demo.md +0 -103
  265. package/skills/trtc-onboarding/reference/path-a2-integrate.md +0 -737
  266. package/skills/trtc-onboarding/reference/path-b-troubleshoot.md +0 -186
  267. package/skills/trtc-onboarding/reference/path-c-expand.md +0 -43
  268. package/skills/trtc-onboarding/reference/supported-matrix.md +0 -100
  269. package/skills/trtc-search/SKILL.md +0 -228
  270. package/skills/trtc-topic/SKILL.md +0 -622
  271. package/skills/trtc-topic/scripts/apply.py +0 -581
  272. package/skills/trtc-topic/scripts/lib/state_machine.py +0 -328
  273. package/skills/trtc-topic/tests/README.md +0 -70
  274. package/skills/trtc-topic/tests/conftest.py +0 -72
  275. package/skills/trtc-topic/tests/test_apply_cli.py +0 -480
  276. package/skills/trtc-topic/tests/test_end_to_end.py +0 -305
  277. package/skills/trtc-topic/tests/test_finalize_session.py +0 -51
  278. package/skills/trtc-topic/tests/test_gates.py +0 -316
  279. package/skills/trtc-topic/tests/test_session_resolver.py +0 -260
  280. package/skills/trtc-topic/tests/test_state_machine.py +0 -414
  281. package/skills/trtc-topic/tests/test_stop_require_apply.py +0 -99
  282. package/skills/trtc-topic/tests/test_topic_skill_invariants.py +0 -130
  283. /package/skills/{trtc-topic → trtc}/runtime/lib/platforms.py +0 -0
  284. /package/skills/{trtc-topic → trtc}/runtime/telemetry_collector.py +0 -0
  285. /package/skills/{trtc-onboarding/reference → trtc/runtime}/usersig-handling.md +0 -0
  286. /package/skills/{trtc-topic/scripts → trtc/tools}/finalize_session.py +0 -0
  287. /package/skills/{trtc-apply/guardrails/apply_lib → trtc-ai-service/capabilities/conversation-core/tests}/__init__.py +0 -0
  288. /package/skills/{trtc-topic → trtc-conference}/references/execution-units.yaml +0 -0
  289. /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
  290. /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
  291. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/docs/backend-contract.zh-CN.md +0 -0
  292. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/docs/integration.zh-CN.md +0 -0
  293. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/docs/theme.zh-CN.md +0 -0
  294. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/index.html +0 -0
  295. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/package.json +0 -0
  296. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/postcss.config.js +0 -0
  297. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/App.vue +0 -0
  298. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/ConsultationManagePanel.vue +0 -0
  299. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/LanguageSwitch.vue +0 -0
  300. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/LoadingSpinner.vue +0 -0
  301. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalAlert.vue +0 -0
  302. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalBusinessPanel.vue +0 -0
  303. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalButton.vue +0 -0
  304. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalConfirmDialog.vue +0 -0
  305. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalDataPanel.vue +0 -0
  306. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalRecordPanel.vue +0 -0
  307. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/PrescriptionPanel.vue +0 -0
  308. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/config/basic-info-config.ts +0 -0
  309. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/config/runtime-config.ts +0 -0
  310. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/env.d.ts +0 -0
  311. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/ConsultationChatPanel.vue +0 -0
  312. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/ConsultationMembersPanel.vue +0 -0
  313. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/ConsultationTranscriptionPanel.vue +0 -0
  314. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/ConsultationVideoStage.vue +0 -0
  315. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/InviteDoctorDialog.vue +0 -0
  316. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/KickMemberConfirmDialog.vue +0 -0
  317. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/types.ts +0 -0
  318. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/useConsultationChat.ts +0 -0
  319. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/useConsultationDevices.ts +0 -0
  320. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/useConsultationParticipants.ts +0 -0
  321. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/useConsultationPermissions.ts +0 -0
  322. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/utils.ts +0 -0
  323. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/en-US/index.ts +0 -0
  324. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/index.ts +0 -0
  325. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/medicalTranslate.ts +0 -0
  326. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/state.ts +0 -0
  327. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/zh-CN/index.ts +0 -0
  328. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/main.ts +0 -0
  329. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/mock/appointments.ts +0 -0
  330. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/mock/users.ts +0 -0
  331. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/router/index.ts +0 -0
  332. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/index.ts +0 -0
  333. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/integration/appointmentService.ts +0 -0
  334. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/integration/authService.ts +0 -0
  335. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/integration/launchContext.ts +0 -0
  336. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/integration/userService.ts +0 -0
  337. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/mock/appointmentService.ts +0 -0
  338. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/mock/authService.ts +0 -0
  339. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/mock/userService.ts +0 -0
  340. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/types.ts +0 -0
  341. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/shared/icons.ts +0 -0
  342. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/styles/index.css +0 -0
  343. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/styles/tailwind.css +0 -0
  344. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/styles/theme.css +0 -0
  345. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/utils/auth.ts +0 -0
  346. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/utils/format.ts +0 -0
  347. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/utils/navigation.ts +0 -0
  348. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/utils/session.ts +0 -0
  349. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/DoctorConsultationView.vue +0 -0
  350. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/DoctorDashboardView.vue +0 -0
  351. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/LoginView.vue +0 -0
  352. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/PatientConsultationFinishedView.vue +0 -0
  353. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/PatientConsultationView.vue +0 -0
  354. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/PatientSelectDoctorView.vue +0 -0
  355. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/PatientWaitingView.vue +0 -0
  356. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/tsconfig.json +0 -0
  357. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/tsconfig.node.json +0 -0
  358. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/vite.config.ts +0 -0
  359. /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
  360. /package/skills/{trtc-topic/runtime/lib → trtc-conference/tools}/__init__.py +0 -0
@@ -0,0 +1,289 @@
1
+ """OpenAPI (Swagger 2 / OpenAPI 3) → ``ParsedApi`` parser.
2
+
3
+ Only implements the minimal subset needed for capability contract adaptation:
4
+ - ``info.servers[0].url`` → ``base_url``
5
+ - ``paths.<path>.<method>`` → a set of ``ParsedApi``
6
+ - ``$ref`` references resolved via ``components.schemas`` / ``definitions`` into type maps
7
+ - No OpenAPI validation (no heavy dependencies like jsonschema)
8
+
9
+ Supported file formats: ``.yaml`` / ``.yml`` / ``.json``.
10
+ """
11
+ from __future__ import annotations
12
+
13
+ import copy
14
+ import json
15
+ from pathlib import Path
16
+ from typing import Any, Dict, List, Optional
17
+
18
+ from .curl_parser import AuthSpec, ParsedApi, _normalize_schema
19
+
20
+
21
+ class OpenApiParseError(ValueError):
22
+ """OpenAPI 文件解析失败。"""
23
+
24
+
25
+ # ---------------------------------------------------------------------------
26
+ # 装载
27
+ # ---------------------------------------------------------------------------
28
+ def _load_file(path: Path) -> Dict[str, Any]:
29
+ if not path.exists():
30
+ raise OpenApiParseError(f"file not found: {path}")
31
+ text = path.read_text(encoding="utf-8")
32
+ if path.suffix.lower() in (".yaml", ".yml"):
33
+ try:
34
+ import yaml # type: ignore
35
+ except ImportError as exc:
36
+ raise OpenApiParseError("PyYAML required for .yaml input") from exc
37
+ try:
38
+ data = yaml.safe_load(text)
39
+ except yaml.YAMLError as exc:
40
+ raise OpenApiParseError(f"yaml parse failed: {exc}") from exc
41
+ else:
42
+ try:
43
+ data = json.loads(text)
44
+ except json.JSONDecodeError as exc:
45
+ raise OpenApiParseError(f"json parse failed: {exc}") from exc
46
+ if not isinstance(data, dict):
47
+ raise OpenApiParseError("OpenAPI root must be a mapping")
48
+ return data
49
+
50
+
51
+ # ---------------------------------------------------------------------------
52
+ # $ref 解析
53
+ # ---------------------------------------------------------------------------
54
+ class _RefResolver:
55
+ def __init__(self, doc: Dict[str, Any]) -> None:
56
+ self.doc = doc
57
+ self._cache: Dict[str, Any] = {}
58
+ # OpenAPI 3 用 components.schemas;Swagger 2 用 definitions
59
+ self.components = (
60
+ doc.get("components", {}).get("schemas", {})
61
+ if isinstance(doc.get("components"), dict)
62
+ else {}
63
+ )
64
+ self.definitions = (
65
+ doc.get("definitions", {}) if isinstance(doc.get("definitions"), dict) else {}
66
+ )
67
+
68
+ def resolve(self, node: Any, _depth: int = 0) -> Any:
69
+ if _depth > 10: # 防递归爆栈
70
+ return {"$ref_too_deep": True}
71
+ if isinstance(node, dict):
72
+ if "$ref" in node:
73
+ target = self._lookup(node["$ref"])
74
+ return self.resolve(target, _depth + 1)
75
+ return {k: self.resolve(v, _depth + 1) for k, v in node.items()}
76
+ if isinstance(node, list):
77
+ return [self.resolve(item, _depth + 1) for item in node]
78
+ return node
79
+
80
+ def _lookup(self, ref: str) -> Any:
81
+ if ref in self._cache:
82
+ return self._cache[ref]
83
+ # 仅支持本文档引用 #/...
84
+ if not ref.startswith("#/"):
85
+ return {"$ref_external": ref}
86
+ cur: Any = self.doc
87
+ for seg in ref[2:].split("/"):
88
+ if isinstance(cur, dict) and seg in cur:
89
+ cur = cur[seg]
90
+ else:
91
+ return {"$ref_unresolved": ref}
92
+ self._cache[ref] = cur
93
+ return cur
94
+
95
+
96
+ # ---------------------------------------------------------------------------
97
+ # Schema → 简化类型字典
98
+ # ---------------------------------------------------------------------------
99
+ _PRIMITIVES = {
100
+ "string": "string",
101
+ "integer": "int",
102
+ "number": "float",
103
+ "boolean": "bool",
104
+ }
105
+
106
+
107
+ def _schema_to_type(schema: Dict[str, Any], depth: int = 0) -> Any:
108
+ """把 OpenAPI schema 转成内部类型表达。"""
109
+ if depth > 10 or not isinstance(schema, dict):
110
+ return "any"
111
+ t = schema.get("type")
112
+ if t in _PRIMITIVES:
113
+ if "enum" in schema and isinstance(schema["enum"], list):
114
+ vals = ", ".join(str(v) for v in schema["enum"])
115
+ return f"enum[{vals}]"
116
+ return _PRIMITIVES[t]
117
+ if t == "array":
118
+ item_t = _schema_to_type(schema.get("items", {}) or {}, depth + 1)
119
+ return f"{item_t}[]" if isinstance(item_t, str) else [item_t]
120
+ if t == "object" or "properties" in schema:
121
+ out: Dict[str, Any] = {}
122
+ for k, v in (schema.get("properties") or {}).items():
123
+ out[k] = _schema_to_type(v or {}, depth + 1)
124
+ return out
125
+ # oneOf / anyOf / allOf 简化为 any
126
+ if any(k in schema for k in ("oneOf", "anyOf", "allOf")):
127
+ return "any"
128
+ return "any"
129
+
130
+
131
+ # ---------------------------------------------------------------------------
132
+ # 单 operation → ParsedApi
133
+ # ---------------------------------------------------------------------------
134
+ def _extract_request_schema(op: Dict[str, Any], resolver: _RefResolver) -> Dict[str, Any]:
135
+ schema: Dict[str, Any] = {}
136
+ # OpenAPI 3: requestBody.content["application/json"].schema
137
+ rb = op.get("requestBody")
138
+ if isinstance(rb, dict):
139
+ rb = resolver.resolve(rb)
140
+ content = rb.get("content", {}) if isinstance(rb, dict) else {}
141
+ for mime, mb in content.items():
142
+ if "json" in mime.lower():
143
+ s = mb.get("schema") if isinstance(mb, dict) else None
144
+ if s is not None:
145
+ schema = _schema_to_type(resolver.resolve(s)) or {}
146
+ if isinstance(schema, dict):
147
+ return schema
148
+ break
149
+ # Swagger 2: parameters[in=body].schema
150
+ for p in op.get("parameters", []) or []:
151
+ p = resolver.resolve(p) if isinstance(p, dict) else p
152
+ if isinstance(p, dict) and p.get("in") == "body":
153
+ s = p.get("schema")
154
+ if s is not None:
155
+ conv = _schema_to_type(resolver.resolve(s))
156
+ if isinstance(conv, dict):
157
+ return conv
158
+ # 兜底:把 query/path/header 参数也合并到 request_schema
159
+ out: Dict[str, Any] = {}
160
+ for p in op.get("parameters", []) or []:
161
+ p = resolver.resolve(p) if isinstance(p, dict) else p
162
+ if not isinstance(p, dict):
163
+ continue
164
+ if p.get("in") in ("query", "path", "header"):
165
+ name = p.get("name")
166
+ if name:
167
+ out[name] = _schema_to_type(p.get("schema") or {"type": p.get("type", "string")})
168
+ return out
169
+
170
+
171
+ def _extract_response_schema(op: Dict[str, Any], resolver: _RefResolver) -> Dict[str, Any]:
172
+ responses = op.get("responses") or {}
173
+ # 优先 200 / 201 / 2xx
174
+ for code in ("200", "201", "default"):
175
+ if code in responses:
176
+ r = resolver.resolve(responses[code])
177
+ if isinstance(r, dict):
178
+ # OpenAPI 3
179
+ content = r.get("content", {}) if isinstance(r.get("content"), dict) else {}
180
+ for mime, mb in content.items():
181
+ if "json" in mime.lower() and isinstance(mb, dict):
182
+ s = resolver.resolve(mb.get("schema") or {})
183
+ conv = _schema_to_type(s)
184
+ if isinstance(conv, dict):
185
+ return conv
186
+ # Swagger 2
187
+ if "schema" in r:
188
+ s = resolver.resolve(r["schema"])
189
+ conv = _schema_to_type(s)
190
+ if isinstance(conv, dict):
191
+ return conv
192
+ break
193
+ return {}
194
+
195
+
196
+ def _detect_auth_from_security(op: Dict[str, Any], doc: Dict[str, Any]) -> AuthSpec:
197
+ sec_defs = (
198
+ doc.get("components", {}).get("securitySchemes", {})
199
+ if isinstance(doc.get("components"), dict)
200
+ else doc.get("securityDefinitions", {})
201
+ ) or {}
202
+ sec = op.get("security") or doc.get("security") or []
203
+ for entry in sec:
204
+ if not isinstance(entry, dict):
205
+ continue
206
+ for name in entry.keys():
207
+ scheme = sec_defs.get(name) or {}
208
+ t = scheme.get("type", "").lower()
209
+ if t == "http" and scheme.get("scheme", "").lower() == "bearer":
210
+ return AuthSpec(type="bearer", location="header", name="Authorization")
211
+ if t == "apikey":
212
+ return AuthSpec(
213
+ type="api_key",
214
+ location=scheme.get("in", "header"),
215
+ name=scheme.get("name", "X-API-Key"),
216
+ )
217
+ if t == "http" and scheme.get("scheme", "").lower() == "basic":
218
+ return AuthSpec(type="basic", location="header", name="Authorization")
219
+ return AuthSpec()
220
+
221
+
222
+ def _base_url(doc: Dict[str, Any]) -> str:
223
+ servers = doc.get("servers") or []
224
+ if servers and isinstance(servers, list) and isinstance(servers[0], dict):
225
+ return str(servers[0].get("url", "")).rstrip("/")
226
+ # Swagger 2
227
+ host = doc.get("host", "")
228
+ schemes = doc.get("schemes") or ["https"]
229
+ base_path = doc.get("basePath", "")
230
+ if host:
231
+ return f"{schemes[0]}://{host}{base_path}".rstrip("/")
232
+ return ""
233
+
234
+
235
+ # ---------------------------------------------------------------------------
236
+ # 公共入口
237
+ # ---------------------------------------------------------------------------
238
+ _HTTP_METHODS = {"get", "post", "put", "delete", "patch", "head", "options"}
239
+
240
+
241
+ def parse_openapi(
242
+ file_path: Path,
243
+ *,
244
+ select_path: Optional[str] = None,
245
+ select_method: Optional[str] = None,
246
+ ) -> List[ParsedApi]:
247
+ """解析 OpenAPI 文件返回所有 operation 的 ParsedApi 列表。
248
+
249
+ 可用 ``select_path`` / ``select_method`` 过滤;为空时返回全部 operation。
250
+ """
251
+ doc = _load_file(Path(file_path))
252
+ resolver = _RefResolver(doc)
253
+ base = _base_url(doc)
254
+ paths = doc.get("paths") or {}
255
+ if not isinstance(paths, dict):
256
+ raise OpenApiParseError("OpenAPI 'paths' must be a mapping")
257
+
258
+ out: List[ParsedApi] = []
259
+ for path, item in paths.items():
260
+ if not isinstance(item, dict):
261
+ continue
262
+ if select_path and select_path != path:
263
+ continue
264
+ for method, op in item.items():
265
+ if method.lower() not in _HTTP_METHODS:
266
+ continue
267
+ if select_method and method.upper() != select_method.upper():
268
+ continue
269
+ if not isinstance(op, dict):
270
+ continue
271
+ api = ParsedApi(
272
+ method=method.upper(),
273
+ base_url=base,
274
+ path=path,
275
+ request_schema=_extract_request_schema(op, resolver),
276
+ response_schema=_extract_response_schema(op, resolver),
277
+ auth=_detect_auth_from_security(op, doc),
278
+ source="openapi",
279
+ body_format="json" if op.get("requestBody") or any(
280
+ p.get("in") == "body" for p in (op.get("parameters") or []) if isinstance(p, dict)
281
+ ) else "none",
282
+ raw=f"openapi://{path}#{method.upper()}",
283
+ )
284
+ out.append(api)
285
+ if select_path and not out:
286
+ raise OpenApiParseError(
287
+ f"no operation matched: path={select_path!r}, method={select_method!r}"
288
+ )
289
+ return out
@@ -0,0 +1,159 @@
1
+ """Tech stack detection.
2
+
3
+ Reads signal files from the target project root and outputs standardized tech_stack labels:
4
+ react / vue / angular / next /
5
+ express / koa / fastify /
6
+ spring-boot / quarkus /
7
+ flask / fastapi / django
8
+
9
+ On detection failure, primary is None; degrader decides fallback to L2 or L3.
10
+ """
11
+ from __future__ import annotations
12
+
13
+ import json
14
+ from dataclasses import dataclass
15
+ from pathlib import Path
16
+ from typing import Iterable, List, Optional
17
+
18
+
19
+ _PRIORITY = [
20
+ "next",
21
+ "react",
22
+ "vue",
23
+ "angular",
24
+ "express",
25
+ "koa",
26
+ "fastify",
27
+ "spring-boot",
28
+ "quarkus",
29
+ "fastapi",
30
+ "flask",
31
+ "django",
32
+ ]
33
+
34
+
35
+ @dataclass
36
+ class DetectResult:
37
+ primary: Optional[str]
38
+ candidates: List[str]
39
+ signals: List[str]
40
+
41
+ def to_dict(self) -> dict:
42
+ return {
43
+ "primary": self.primary,
44
+ "candidates": self.candidates,
45
+ "signals": self.signals,
46
+ }
47
+
48
+
49
+ def _safe_text(p: Path) -> str:
50
+ try:
51
+ return p.read_text(encoding="utf-8", errors="replace")
52
+ except OSError:
53
+ return ""
54
+
55
+
56
+ def _detect_node(project: Path, signals: List[str]) -> List[str]:
57
+ pkg = project / "package.json"
58
+ if not pkg.exists():
59
+ return []
60
+ try:
61
+ data = json.loads(_safe_text(pkg))
62
+ except json.JSONDecodeError:
63
+ return []
64
+ deps = {}
65
+ for k in ("dependencies", "devDependencies", "peerDependencies"):
66
+ deps.update(data.get(k) or {})
67
+ out: List[str] = []
68
+ mapping = {
69
+ "next": "next",
70
+ "react": "react",
71
+ "vue": "vue",
72
+ "@angular/core": "angular",
73
+ "express": "express",
74
+ "koa": "koa",
75
+ "fastify": "fastify",
76
+ }
77
+ for dep_key, label in mapping.items():
78
+ if dep_key in deps:
79
+ out.append(label)
80
+ signals.append(f"package.json:{dep_key}")
81
+ return out
82
+
83
+
84
+ def _detect_java(project: Path, signals: List[str]) -> List[str]:
85
+ out: List[str] = []
86
+ pom = project / "pom.xml"
87
+ gradle = project / "build.gradle"
88
+ gradle_kts = project / "build.gradle.kts"
89
+ text = ""
90
+ for p in (pom, gradle, gradle_kts):
91
+ if p.exists():
92
+ text += _safe_text(p)
93
+ signals.append(p.name)
94
+ if "spring-boot-starter" in text or "org.springframework.boot" in text:
95
+ out.append("spring-boot")
96
+ if "quarkus-core" in text or "io.quarkus" in text:
97
+ out.append("quarkus")
98
+ return out
99
+
100
+
101
+ def _detect_python(project: Path, signals: List[str]) -> List[str]:
102
+ out: List[str] = []
103
+ chunks: List[str] = []
104
+ for fname in ("requirements.txt", "pyproject.toml", "Pipfile", "setup.py"):
105
+ p = project / fname
106
+ if p.exists():
107
+ chunks.append(_safe_text(p).lower())
108
+ signals.append(fname)
109
+ blob = "\n".join(chunks)
110
+ if not blob:
111
+ return out
112
+ # Order: fastapi has higher priority than flask (some projects declare both)
113
+ if "fastapi" in blob:
114
+ out.append("fastapi")
115
+ if "django" in blob:
116
+ out.append("django")
117
+ if "flask" in blob:
118
+ out.append("flask")
119
+ return out
120
+
121
+
122
+ def _ordered_unique(items: Iterable[str]) -> List[str]:
123
+ seen, out = set(), []
124
+ for x in items:
125
+ if x not in seen:
126
+ seen.add(x)
127
+ out.append(x)
128
+ return out
129
+
130
+
131
+ def detect(project_root: Path) -> DetectResult:
132
+ """Run tech stack detection on the target project."""
133
+ project_root = Path(project_root).resolve()
134
+ signals: List[str] = []
135
+ cands: List[str] = []
136
+ cands += _detect_node(project_root, signals)
137
+ cands += _detect_java(project_root, signals)
138
+ cands += _detect_python(project_root, signals)
139
+ cands = _ordered_unique(cands)
140
+
141
+ # Select primary by _PRIORITY
142
+ primary: Optional[str] = None
143
+ for label in _PRIORITY:
144
+ if label in cands:
145
+ primary = label
146
+ break
147
+ return DetectResult(primary=primary, candidates=cands, signals=signals)
148
+
149
+
150
+ def match_adapter(tech_stack: str, auto_adapters: list) -> Optional[str]:
151
+ """Find the matching adapter name in manifest.integration.auto_adapters."""
152
+ if not tech_stack or not auto_adapters:
153
+ return None
154
+ for entry in auto_adapters:
155
+ if not isinstance(entry, dict):
156
+ continue
157
+ if tech_stack in (entry.get("tech_stack") or []):
158
+ return entry.get("adapter")
159
+ return None
@@ -0,0 +1,204 @@
1
+ """tokens_compile —— compile design_tokens.json into CSS variable files.
2
+
3
+ Design goals:
4
+ - Single source of truth: design_tokens.json
5
+ - Compiled output: scenarios/**/ui/**/tokens.css (DESIGN_GUIDELINES §9 declares these must not be hand-edited)
6
+ - Naming aligns with DESIGN_GUIDELINES.md §2.1 CSS variable names (compact, not full flatten)
7
+ - No third-party dependencies (no style-dictionary, etc.)
8
+
9
+ Invocation:
10
+ python3 -m scripts.lib.tokens_compile \\
11
+ --src design_tokens.json \\
12
+ --dest scenarios/customer-service/ui/widget-floating/tokens.css \\
13
+ --dest scenarios/customer-service/ui/admin-board/tokens.css
14
+ """
15
+ from __future__ import annotations
16
+
17
+ import argparse
18
+ import json
19
+ import sys
20
+ from pathlib import Path
21
+ from typing import Any, Dict, List, Tuple
22
+
23
+
24
+ _HEADER = (
25
+ "/*\n"
26
+ " * Auto-generated from design_tokens.json —— **DO NOT EDIT**\n"
27
+ " * Build command: python3 -m scripts.lib.tokens_compile\n"
28
+ " * Naming convention: see scenarios/customer-service/ui/design-system/DESIGN_GUIDELINES.md §2.1\n"
29
+ " */\n"
30
+ )
31
+
32
+
33
+ # ---------------------------------------------------------------------------
34
+ # 命名映射:(json 路径) → (CSS 变量名)
35
+ # 注:与 DESIGN_GUIDELINES.md §2.1 完全对齐
36
+ # ---------------------------------------------------------------------------
37
+ _MAP: List[Tuple[str, str]] = [
38
+ # color.background.* → --color-bg-*
39
+ ("color.background.gradient-start", "--color-bg-gradient-start"),
40
+ ("color.background.gradient-end", "--color-bg-gradient-end"),
41
+ ("color.background.gradient", "--color-bg-gradient"),
42
+ ("color.background.surface", "--color-bg-surface"),
43
+ ("color.background.surface-strong", "--color-bg-surface-strong"),
44
+ ("color.background.border", "--color-bg-border"),
45
+ # color.brand.* → --color-brand-*
46
+ ("color.brand.accent", "--color-brand-accent"),
47
+ # color.text.* → --color-text-*
48
+ ("color.text.primary", "--color-text-primary"),
49
+ ("color.text.secondary", "--color-text-secondary"),
50
+ ("color.text.tertiary", "--color-text-tertiary"),
51
+ ("color.text.disabled", "--color-text-disabled"),
52
+ ("color.text.placeholder", "--color-text-placeholder"),
53
+ # color.status.* → --color-status-*
54
+ ("color.status.success", "--color-status-success"),
55
+ ("color.status.info", "--color-status-info"),
56
+ ("color.status.warning", "--color-status-warning"),
57
+ ("color.status.error", "--color-status-error"),
58
+ # color.input.* → --color-input-*
59
+ ("color.input.background", "--color-input-bg"),
60
+ ("color.input.icon-send", "--color-input-icon-send"),
61
+ # typography.* → --font-family-* / --font-size-* / --font-weight-* / --line-height-*
62
+ ("typography.fontFamily.base", "--font-family-base"),
63
+ ("typography.title.fontSize", "--font-size-title"),
64
+ ("typography.title.fontWeight", "--font-weight-title"),
65
+ ("typography.title.lineHeight", "--line-height-title"),
66
+ ("typography.brandName.fontSize", "--font-size-brand"),
67
+ ("typography.brandName.fontWeight", "--font-weight-brand"),
68
+ ("typography.placeholder.fontSize", "--font-size-placeholder"),
69
+ ("typography.placeholder.fontWeight", "--font-weight-placeholder"),
70
+ # spacing.* → --space-*
71
+ ("spacing.card-padding", "--space-card-padding"),
72
+ ("spacing.input-padding-x", "--space-input-padding-x"),
73
+ ("spacing.input-padding-y", "--space-input-padding-y"),
74
+ ("spacing.gap-brand-title", "--space-gap-brand-title"),
75
+ # radius.* → --radius-*
76
+ ("radius.card", "--radius-card"),
77
+ ("radius.input", "--radius-input"),
78
+ ("radius.logo", "--radius-logo"),
79
+ ]
80
+
81
+
82
+ # ---------------------------------------------------------------------------
83
+ # 视觉分组(输出顺序 + 注释分隔)
84
+ # ---------------------------------------------------------------------------
85
+ _GROUPS: List[Tuple[str, List[str]]] = [
86
+ ("Background / surfaces", [
87
+ "--color-bg-gradient-start", "--color-bg-gradient-end", "--color-bg-gradient",
88
+ "--color-bg-surface", "--color-bg-surface-strong", "--color-bg-border",
89
+ ]),
90
+ ("Brand / accent", ["--color-brand-accent"]),
91
+ ("Text", [
92
+ "--color-text-primary", "--color-text-secondary", "--color-text-tertiary",
93
+ "--color-text-disabled", "--color-text-placeholder",
94
+ ]),
95
+ ("Status (success / info / warning / error)", [
96
+ "--color-status-success", "--color-status-info",
97
+ "--color-status-warning", "--color-status-error",
98
+ ]),
99
+ ("Input", ["--color-input-bg", "--color-input-icon-send"]),
100
+ ("Typography", [
101
+ "--font-family-base",
102
+ "--font-size-title", "--font-weight-title", "--line-height-title",
103
+ "--font-size-brand", "--font-weight-brand",
104
+ "--font-size-placeholder", "--font-weight-placeholder",
105
+ ]),
106
+ ("Spacing", [
107
+ "--space-card-padding", "--space-input-padding-x",
108
+ "--space-input-padding-y", "--space-gap-brand-title",
109
+ ]),
110
+ ("Radius", ["--radius-card", "--radius-input", "--radius-logo"]),
111
+ ("Effects", ["--effect-input-blur"]),
112
+ ]
113
+
114
+
115
+ def _walk_json(tokens: Dict[str, Any], path: str) -> Any:
116
+ """按 'a.b.c' 路径取出 token 节点;返回 None 表示找不到。"""
117
+ cur: Any = tokens
118
+ for seg in path.split("."):
119
+ if not isinstance(cur, dict) or seg not in cur:
120
+ return None
121
+ cur = cur[seg]
122
+ return cur
123
+
124
+
125
+ def _format_value(node: Dict[str, Any]) -> str:
126
+ """把 token 叶子节点转成 CSS 值字面量。"""
127
+ val = node.get("value")
128
+ typ = node.get("type")
129
+ if typ == "blur" and isinstance(val, dict) and "radius" in val:
130
+ return f"blur({val['radius']})"
131
+ return str(val)
132
+
133
+
134
+ def compile_tokens(src: Path) -> str:
135
+ raw = json.loads(src.read_text(encoding="utf-8"))
136
+
137
+ # 第一遍:把 _MAP 中每个 token 的最终 CSS 值算出来
138
+ resolved: Dict[str, str] = {}
139
+ missing: List[str] = []
140
+ for json_path, css_name in _MAP:
141
+ node = _walk_json(raw, json_path)
142
+ if not isinstance(node, dict) or "value" not in node:
143
+ missing.append(json_path)
144
+ continue
145
+ resolved[css_name] = _format_value(node)
146
+
147
+ # 单独补 effect.input-blur(_format_value 已能处理 dict→blur(...) )
148
+ eff_node = _walk_json(raw, "effect.input-blur")
149
+ if isinstance(eff_node, dict):
150
+ resolved["--effect-input-blur"] = _format_value(eff_node)
151
+
152
+ if missing:
153
+ raise SystemExit(
154
+ "design_tokens.json is missing the following tokens. Please add them and re-run:\n - "
155
+ + "\n - ".join(missing)
156
+ )
157
+
158
+ # 第二遍:按 _GROUPS 顺序输出
159
+ lines = [_HEADER, ":root {"]
160
+ first = True
161
+ for group_label, names in _GROUPS:
162
+ if not first:
163
+ lines.append("")
164
+ first = False
165
+ lines.append(f" /* {group_label} */")
166
+ for n in names:
167
+ v = resolved.get(n)
168
+ if v is None:
169
+ continue
170
+ lines.append(f" {n}: {v};")
171
+ lines.append("}")
172
+ lines.append("") # 末尾换行
173
+ return "\n".join(lines)
174
+
175
+
176
+ def _argparser() -> argparse.ArgumentParser:
177
+ p = argparse.ArgumentParser(description="design_tokens.json → CSS 变量")
178
+ p.add_argument("--src", default="design_tokens.json")
179
+ p.add_argument(
180
+ "--dest",
181
+ action="append",
182
+ required=True,
183
+ help="可重复,每次写一份产物",
184
+ )
185
+ return p
186
+
187
+
188
+ def main() -> int:
189
+ args = _argparser().parse_args()
190
+ src = Path(args.src)
191
+ if not src.exists():
192
+ print(f"src not found: {src}", file=sys.stderr)
193
+ return 2
194
+ css = compile_tokens(src)
195
+ for dest_str in args.dest:
196
+ dest = Path(dest_str)
197
+ dest.parent.mkdir(parents=True, exist_ok=True)
198
+ dest.write_text(css, encoding="utf-8")
199
+ print(f"wrote {dest} ({len(css)} bytes)")
200
+ return 0
201
+
202
+
203
+ if __name__ == "__main__":
204
+ sys.exit(main())