femo-plugin 1.0.0 → 1.0.2

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 (218) hide show
  1. package/FEMO_logo.svg +55 -0
  2. package/FEMO_logo_slogan.svg +29 -0
  3. package/README.md +10 -2
  4. package/_tmp/fallback/driver2.py +176 -0
  5. package/_tmp/fallback/events.jsonl +108 -0
  6. package/_tmp/fallback/gateway_ui.py +325 -0
  7. package/_tmp/fallback/outbox/j1553_human_[/347/234/213/347/211/214]_1.done +1 -0
  8. package/_tmp/fallback/outbox/r1.done +1 -0
  9. package/_tmp/fallback/outbox/r2.done +1 -0
  10. package/_tmp/fallback/outbox/r3.done +1 -0
  11. package/_tmp/fallback/outbox/r4.done +1 -0
  12. package/_tmp/fallback/outbox/r5.done +1 -0
  13. package/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225//350/260/201/346/230/257/345/215/247/345/272/225.femo +3 -2
  14. package/hostAdapter/dshAdapter/client/client-ui/composer.tsx +112 -9
  15. package/hostAdapter/dshAdapter/client/client-ui/styles.ts +17 -0
  16. package/hostAdapter/dshAdapter/client/fa-icons.tsx +3 -0
  17. package/hostAdapter/dshAdapter/host/engine-events.ts +4 -1
  18. package/hostAdapter/dshAdapter/host/index.ts +5 -0
  19. package/hostAdapter/dshAdapter/host/preset-install.ts +59 -0
  20. package/hostAdapter/dshAdapter/host/projection-input.ts +14 -6
  21. package/hostAdapter/dshAdapter/lib/client.js +124 -5
  22. package/hostAdapter/dshAdapter/lib/client.js.map +3 -3
  23. package/hostAdapter/dshAdapter/lib/index.js +58 -18
  24. package/hostAdapter/dshAdapter/lib/index.js.map +4 -4
  25. package/hostAdapter/dshAdapter/package.json +1 -5
  26. package/hostAdapter/dshAdapter/preset/agent.cordis.yml +220 -0
  27. package/hostAdapter/dshAdapter/preset/preset.yml +3 -0
  28. package/hostAdapter/zcodeAdapter/.tmp/femo/host-history/gateway.port +1 -0
  29. package/hostAdapter/zcodeAdapter/.tmp/femo/host-history/proj-mirror/femo-main-a-_40_52a9_624b.jsonl +3 -0
  30. package/hostAdapter/zcodeAdapter/.tmp/femo/host-history/proj-mirror/femo-main-a-_40_6211.jsonl +10 -0
  31. package/hostAdapter/zcodeAdapter/.tmp/femo/host-history/proj-mirror/femo-main-god.jsonl +11 -0
  32. package/hostAdapter/zcodeAdapter/.tmp/femo/host-history/proj-mirror/femo-main-stage.jsonl +11 -0
  33. package/hostAdapter/zcodeAdapter/.zcode-plugin/plugin.json +23 -0
  34. package/hostAdapter/zcodeAdapter/README.md +61 -0
  35. package/hostAdapter/zcodeAdapter/commands/femo.md +9 -0
  36. package/hostAdapter/zcodeAdapter/femo-zcode-dist/.zcode-plugin/plugin.json +23 -0
  37. package/hostAdapter/zcodeAdapter/femo-zcode-dist/LICENSE +201 -0
  38. package/hostAdapter/zcodeAdapter/femo-zcode-dist/README.md +635 -0
  39. package/hostAdapter/zcodeAdapter/femo-zcode-dist/commands/femo.md +9 -0
  40. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femo2host/__init__.py +4 -0
  41. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femo2host/femoToolcall/chronica.py +156 -0
  42. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femo2host/femoToolcall/femo-chat.mjs +69 -0
  43. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femo2host/femoToolcall/femo_debugger.py +1515 -0
  44. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femo2host/femo_api.py +437 -0
  45. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femo2host/femo_gen_api.jsx +77 -0
  46. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoBridges/ContextExample.py +555 -0
  47. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoBridges/MemoryExample.py +163 -0
  48. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoBridges/__init__.py +1 -0
  49. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoBridges/getDir/get_dir.py +56 -0
  50. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoBridges/getDir//344/275/240/345/217/257/344/273/245/350/256/276/345/256/232/344/273/273/346/204/217/346/226/207/344/273/266/345/244/271/344/270/272/347/224/250/346/210/267/346/225/260/346/215/256/346/226/207/344/273/266/345/244/271.txt +10 -0
  51. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoBridges/llmBridge.py +247 -0
  52. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoBridges/llmProviders.py +308 -0
  53. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/FEMO_CLIrenderer.py +198 -0
  54. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/FEMO_config.py +35 -0
  55. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/FEMO_errors.py +278 -0
  56. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/FEMO_interpreter.py +163 -0
  57. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/FEMO_normalizer.py +396 -0
  58. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/FEMO_parser.py +2468 -0
  59. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/FEMO_runtime.py +3630 -0
  60. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/FEMO_scope_resolver.py +209 -0
  61. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/__init__.py +1 -0
  62. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/actor_resolver.py +86 -0
  63. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/block_collector.py +441 -0
  64. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/db_utils.py +485 -0
  65. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/femoAsync.py +401 -0
  66. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/host_manifest.py +68 -0
  67. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/job_manager.py +767 -0
  68. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/protocol.py +126 -0
  69. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/save_dialog.py +402 -0
  70. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/task_world.py +544 -0
  71. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/vars/__init__.py +19 -0
  72. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/vars/checkpoint.py +113 -0
  73. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/vars/env.py +686 -0
  74. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/vars/evaluator.py +567 -0
  75. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/vars/join.py +303 -0
  76. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/vars/merge.py +157 -0
  77. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoCompiler/vars/model.py +245 -0
  78. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples/AI/345/211/252/350/247/206/351/242/221/AI/345/211/252/350/247/206/351/242/221.femo +192 -0
  79. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples/AI/350/201/212/345/244/251/345/256/244/group-chat.femo +42 -0
  80. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples/AI/350/201/212/345/244/251/345/256/244/random_wait_time.py +10 -0
  81. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples/LuxFiat/luxfiat.femo +38 -0
  82. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples/LuxFiat/wait.py +29 -0
  83. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples/debug/347/245/236/345/231/250/debug/347/245/236/345/231/250.femo +222 -0
  84. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples/discussion.femo +70 -0
  85. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples/goal-mode.femo +23 -0
  86. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples//345/270/270/347/224/250/345/267/245/345/205/267python/wait.py +29 -0
  87. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples//347/213/274/344/272/272/346/235/200/werewolf_utils.py +205 -0
  88. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples//347/213/274/344/272/272/346/235/200/werewolf_utils2.py +324 -0
  89. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples//347/213/274/344/272/272/346/235/200//347/213/274/344/272/272/346/235/200-/350/255/246/351/225/277/347/211/210.femo +544 -0
  90. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples//347/213/274/344/272/272/346/235/200//347/213/274/344/272/272/346/235/200.femo +331 -0
  91. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225/undercover_utils.py +683 -0
  92. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225//350/260/201/346/230/257/345/215/247/345/272/225-/350/217/234/345/270/202/345/234/272/345/261/200.femo +348 -0
  93. package/hostAdapter/zcodeAdapter/femo-zcode-dist/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225//350/260/201/346/230/257/345/215/247/345/272/225.femo +393 -0
  94. package/hostAdapter/zcodeAdapter/femo-zcode-dist/hooks/after-tool.mjs +3 -0
  95. package/hostAdapter/zcodeAdapter/femo-zcode-dist/hooks/hooks.json +16 -0
  96. package/hostAdapter/zcodeAdapter/femo-zcode-dist/hooks/lib.mjs +59 -0
  97. package/hostAdapter/zcodeAdapter/femo-zcode-dist/hooks/prompt-state.mjs +3 -0
  98. package/hostAdapter/zcodeAdapter/femo-zcode-dist/hooks/session-start.mjs +3 -0
  99. package/hostAdapter/zcodeAdapter/femo-zcode-dist/hooks/stop-intent.mjs +3 -0
  100. package/hostAdapter/zcodeAdapter/femo-zcode-dist/hostAdapter/dshAdapter/python/dev-bridge-test.py +43 -0
  101. package/hostAdapter/zcodeAdapter/femo-zcode-dist/hostAdapter/dshAdapter/python/femo_bridge.py +533 -0
  102. package/hostAdapter/zcodeAdapter/femo-zcode-dist/mcp/bridge-manager.mjs +192 -0
  103. package/hostAdapter/zcodeAdapter/femo-zcode-dist/mcp/event-router.mjs +258 -0
  104. package/hostAdapter/zcodeAdapter/femo-zcode-dist/mcp/femo-server.mjs +429 -0
  105. package/hostAdapter/zcodeAdapter/femo-zcode-dist/mcp/gateway.mjs +163 -0
  106. package/hostAdapter/zcodeAdapter/femo-zcode-dist/mcp/projection-writer.mjs +294 -0
  107. package/hostAdapter/zcodeAdapter/femo-zcode-dist/skills/femo/SKILL.md +93 -0
  108. package/hostAdapter/zcodeAdapter/femo-zcode-dist/tests/bridge-smoke.mjs +26 -0
  109. package/hostAdapter/zcodeAdapter/femo-zcode-dist/tests/event-router.test.mjs +157 -0
  110. package/hostAdapter/zcodeAdapter/femo-zcode-dist/tests/gateway-smoke.mjs +107 -0
  111. package/hostAdapter/zcodeAdapter/femo-zcode-dist/tests/integration-human.mjs +111 -0
  112. package/hostAdapter/zcodeAdapter/femo-zcode-dist/tests/main-actor.mjs +107 -0
  113. package/hostAdapter/zcodeAdapter/femo-zcode-dist/tests/mcp-smoke.mjs +130 -0
  114. package/hostAdapter/zcodeAdapter/femo-zcode-dist/tests/projection-writer.test.mjs +144 -0
  115. package/hostAdapter/zcodeAdapter/femo-zcode-dist/zcode.host.manifest.json +5 -0
  116. package/hostAdapter/zcodeAdapter/femo-zcode-dist//346/212/225/345/275/261/347/252/227/351/207/215/350/256/276/350/256/241-/350/256/250/350/256/272/347/250/277.md +113 -0
  117. package/hostAdapter/zcodeAdapter/femo-zcode-dist//350/257/255/346/263/225/346/226/207/346/241/243.md +1136 -0
  118. package/hostAdapter/zcodeAdapter/hooks/after-tool.mjs +3 -0
  119. package/hostAdapter/zcodeAdapter/hooks/hooks.json +16 -0
  120. package/hostAdapter/zcodeAdapter/hooks/lib.mjs +59 -0
  121. package/hostAdapter/zcodeAdapter/hooks/prompt-state.mjs +3 -0
  122. package/hostAdapter/zcodeAdapter/hooks/session-start.mjs +3 -0
  123. package/hostAdapter/zcodeAdapter/hooks/stop-intent.mjs +3 -0
  124. package/hostAdapter/zcodeAdapter/mcp/bridge-manager.mjs +192 -0
  125. package/hostAdapter/zcodeAdapter/mcp/event-router.mjs +258 -0
  126. package/hostAdapter/zcodeAdapter/mcp/femo-server.mjs +429 -0
  127. package/hostAdapter/zcodeAdapter/mcp/gateway.mjs +163 -0
  128. package/hostAdapter/zcodeAdapter/mcp/projection-writer.mjs +294 -0
  129. package/hostAdapter/zcodeAdapter/skills/femo/SKILL.md +93 -0
  130. package/hostAdapter/zcodeAdapter/tests/bridge-smoke.mjs +26 -0
  131. package/hostAdapter/zcodeAdapter/tests/event-router.test.mjs +157 -0
  132. package/hostAdapter/zcodeAdapter/tests/gateway-smoke.mjs +107 -0
  133. package/hostAdapter/zcodeAdapter/tests/integration-human.mjs +111 -0
  134. package/hostAdapter/zcodeAdapter/tests/main-actor.mjs +107 -0
  135. package/hostAdapter/zcodeAdapter/tests/mcp-smoke.mjs +130 -0
  136. package/hostAdapter/zcodeAdapter/tests/projection-writer.test.mjs +144 -0
  137. package/hostAdapter/zcodeAdapter/zcode.host.manifest.json +5 -0
  138. package/hostAdapter/zcodeAdapter//346/212/225/345/275/261/347/252/227/351/207/215/350/256/276/350/256/241-/350/256/250/350/256/272/347/250/277.md +113 -0
  139. package/package.json +1 -1
  140. package/scripts/diag-find-redblue.mjs +38 -0
  141. package/scripts/diag-god-log.mjs +31 -0
  142. package/scripts/diag-god-log2.mjs +39 -0
  143. package/scripts/diag-god-log3.mjs +35 -0
  144. package/scripts/diag-god-log4.mjs +59 -0
  145. package/scripts/diag-god-log4b.mjs +39 -0
  146. package/scripts/diag-redblue-god.mjs +39 -0
  147. package/scripts/diag-redblue-log.mjs +37 -0
  148. package/scripts/diag-redblue-span.mjs +41 -0
  149. package/scripts/diag-stage-1017.mjs +63 -0
  150. package/scripts/dump_session.py +36 -0
  151. package/scripts/link-workspace.ps1 +51 -0
  152. package/scripts/list_souls.py +18 -0
  153. package/scripts/probe-composer-refresh.mjs +197 -0
  154. package/scripts/seed_story_souls.py +86 -0
  155. package/scripts/sync-zcode-dist.ps1 +55 -0
  156. package/scripts/theme-tokenize/color-extract.txt +288 -0
  157. package/scripts/theme-tokenize/round1-quoted.ps1 +149 -0
  158. package/scripts/theme-tokenize/round2-bare.ps1 +138 -0
  159. package/scripts/theme-tokenize/round3-shape.ps1 +110 -0
  160. package/tests/_diag_r4_join.femo +32 -0
  161. package/tests/conftest.py +95 -0
  162. package/tests/diag-subagent-dir-3081.mjs +101 -0
  163. package/tests/femoGenerator.test.mjs +3909 -0
  164. package/tests/femoParser.test.mjs +4813 -0
  165. package/tests/femogen_notice.test.mjs +109 -0
  166. package/tests/femoparser_validation.test.mjs +84 -0
  167. package/tests/main-delivery-queue.test.mjs +329 -0
  168. package/tests/pre-step-gate.test.mjs +282 -0
  169. package/tests/read-subagent-model.mjs +24 -0
  170. package/tests/run-script-tests.py +97 -0
  171. package/tests/safe-steer.test.mjs +59 -0
  172. package/tests/strip_comments.test.mjs +164 -0
  173. package/tests/test_actor_failed.py +92 -0
  174. package/tests/test_compile_warnings.py +99 -0
  175. package/tests/test_debug_log_bus.py +108 -0
  176. package/tests/test_debugger_module_mode.py +141 -0
  177. package/tests/test_error_buckets.py +117 -0
  178. package/tests/test_error_dispatcher.py +261 -0
  179. package/tests/test_exec_ai_retry.py +155 -0
  180. package/tests/test_exec_human_retry.py +159 -0
  181. package/tests/test_file_resolve.py +104 -0
  182. package/tests/test_flow_events.py +311 -0
  183. package/tests/test_flow_ref_validation.py +92 -0
  184. package/tests/test_func_dict_fallback.py +39 -0
  185. package/tests/test_job_lifecycle.py +236 -0
  186. package/tests/test_job_manager.py +424 -0
  187. package/tests/test_mind.py +99 -0
  188. package/tests/test_module_call_args.py +258 -0
  189. package/tests/test_module_visibility.py +238 -0
  190. package/tests/test_notice.py +143 -0
  191. package/tests/test_out_whitelist.py +83 -0
  192. package/tests/test_par_if_dispatch.py +64 -0
  193. package/tests/test_par_nested_for.py +78 -0
  194. package/tests/test_parser.py +494 -0
  195. package/tests/test_pause.py +102 -0
  196. package/tests/test_pause_contract.py +135 -0
  197. package/tests/test_protocol_transcript.py +158 -0
  198. package/tests/test_scope_self.py +202 -0
  199. package/tests/test_source_validate.py +113 -0
  200. package/tests/test_task_world.py +447 -0
  201. package/tests/test_town_structure.py +70 -0
  202. package/tests/test_v2_checkpoint.py +115 -0
  203. package/tests/test_v2_env.py +383 -0
  204. package/tests/test_v2_evaluator.py +227 -0
  205. package/tests/test_v2_join.py +315 -0
  206. package/tests/test_v2_join_wiring.py +429 -0
  207. package/tests/test_v2_merge.py +167 -0
  208. package/tests/test_v2_model.py +143 -0
  209. package/tests/test_v2_resume_e2e.py +472 -0
  210. package/tests/test_var_decls.py +271 -0
  211. package/tests/verify-model-functions.mjs +90 -0
  212. package/tests/verify-subagent-model-3081.mjs +153 -0
  213. package//346/226/275/345/267/245/346/270/205/345/215/225/node-notice-/346/226/275/345/267/245/346/270/205/345/215/225.md +395 -0
  214. package//346/226/275/345/267/245/346/270/205/345/215/225//344/270/244/344/270/252/345/276/205/350/247/243/345/206/263/347/232/204/351/227/256/351/242/230.MD +66 -0
  215. package//346/226/275/345/267/245/346/270/205/345/215/225//345/201/234/346/255/242/351/223/276/344/277/256/345/244/215-/346/226/275/345/267/245/346/270/205/345/215/225.md +475 -0
  216. package//346/226/275/345/267/245/346/270/205/345/215/225//345/217/230/351/207/217/344/270/216task/347/263/273/347/273/237/351/207/215/346/236/204-/346/226/275/345/267/245/346/270/205/345/215/225-v2.md +847 -0
  217. package//346/226/275/345/267/245/346/270/205/345/215/225//350/277/220/350/241/214/347/212/266/346/200/201/351/223/276/350/267/257/351/207/215/346/236/204-/346/226/275/345/267/245/346/270/205/345/215/225v4.md +654 -0
  218. package//346/226/275/345/267/245/346/270/205/345/215/225//351/224/231/350/257/257/346/263/250/345/205/245/347/273/255/350/201/212-/346/226/275/345/267/245/346/270/205/345/215/225.md +471 -0
@@ -0,0 +1,393 @@
1
+ meta:
2
+ name = 谁是卧底2
3
+ version = 6.0
4
+ session = new
5
+ output_style = |
6
+ 这是一局「谁是卧底」游戏!3 人以上即可开局:平民们拿同一个词,卧底拿一个跟它相近的词(7 人及以下 1 名卧底、8 人及以上 2 名卧底,两名卧底同词),另外还有一个白板什么词都没有。
7
+ 每个人只知道自己的牌面,不知道自己的身份——平民、卧底还是白板,要靠听别人怎么描述、再回头核对自己的牌来推断。
8
+ 平民要尽早把卧底都投出去;卧底要装成平民、活到最后;白板手里没有词,要顺着别人的描述混过去、别被投出去(活到终局就算白板赢)。
9
+ 每轮每人说一句话描述自己的词:不能直接说出这个词,也不能描述得太直白独特——太独特会被卧底抄走。
10
+ 说话要像真人玩桌游那样自然、简短、口语化,一句到两句,不要写成分析报告,不要自报身份,也不要说"我不知道自己是什么身份"这类穿帮话。
11
+ 轮到你投票时,先给一句简短的怀疑理由,然后必须输出一行赋值语句。
12
+ 当你需要指定玩家时,必须 @他,且只能使用存活玩家名单里真实存在的名字。
13
+ 你没有调用任何工具的能力,严禁使用工具,直接根据你看到的聊天记录发言。
14
+
15
+ actors:
16
+ ai @小猫咪 = soul:littlecat, source:openrouter/openrouter/free
17
+ ai @Eve = soul:the1stlittlesoul, source:deepseek-official/deepseek-v4-flash
18
+ ai @小机 = soul:debugcoder1, source:openrouter/openrouter/free
19
+ ai @看图梗 = soul:vision_terrier, source:local/gemma-3-4b-it
20
+ ai @铲屎官 = source:main
21
+ human @猫猫 = soul:human, source:0
22
+
23
+ code:
24
+ u = file:"undercover_utils.py"
25
+
26
+ vars:
27
+ roles = {}
28
+ words = {}
29
+ words_text = {}
30
+ $alive = [@小猫咪, @Eve, @小机, @看图梗, @铲屎官, @猫猫]
31
+ @卧底 = ""
32
+ @白板 = ""
33
+ deck_word = []
34
+ round_no = 0
35
+ $vote_results = {}
36
+ is_pk = false
37
+ $pk_candidates = []
38
+ $pk_voters = []
39
+ $voters = []
40
+ eliminated = "无人"
41
+ game_over = false
42
+ winner = ""
43
+ @speaker = ""
44
+ @VOTE = ""
45
+ announce_text = ""
46
+ round_task = ""
47
+ verdict_text = ""
48
+
49
+ action 结束判定 @func(u.next_round_stage):
50
+ in:
51
+ alive_players = $alive
52
+ roles = roles
53
+ out:
54
+ game_over, winner
55
+
56
+ module 发牌:
57
+ action 发牌 @func(u.deal_cards):
58
+ in:
59
+ players = $alive
60
+ out:
61
+ roles, words, @卧底, @白板, deck_word
62
+
63
+ # 白板的牌面不能只显示"???"——演员会当成渲染故障。牌面文案由 Python 现算:
64
+ # 平民/卧底="你拿到的词是【X】",白板="你手里没有词(白板)…"。
65
+ action 牌面文案 @func(u.card_texts):
66
+ in:
67
+ words = words
68
+ out:
69
+ words_text
70
+
71
+ action 开局公告 @notice:
72
+ prompt: |
73
+ {u.board_notice(roles)}
74
+ 规则:每轮每人说一句描述自己的牌(不能直接说出来),然后全体投票,得票最多的人出局。
75
+ 如果投票出现平票,本轮无人出局:平票的几位当场申辩一句、其余人重投一次决出谁走;
76
+ 若重投再次平票,僵局不再空转——由平票的几人中随机送走一人。
77
+ 卧底全部被投出去=平民赢;卧底活到最后=卧底赢;白板只要没被投出去,就算白板自己赢。
78
+ scope: all
79
+
80
+ action 看牌 @mind(@speaker):
81
+ prompt: |
82
+ 【发牌】你是{@speaker}。
83
+ {words_text.@speaker}
84
+ 这张牌只有你自己看得见:不许把牌面直接念出来,也不要说自己是什么身份(你本来就不知道)。
85
+ 看清楚了就回一句「收到」,然后等轮到你描述。
86
+ showprompt: |
87
+ "【发牌】你的手机震了一下,看看你的词。"
88
+ scope: self
89
+
90
+ action 本轮顺序 @func(u.shuffle_order):
91
+ in:
92
+ players = $alive
93
+ out:
94
+ $alive
95
+
96
+ flow:
97
+ [发牌]: 发牌
98
+ [牌面文案]: 牌面文案
99
+ [开局公告]: 开局公告
100
+ [看牌]: 看牌
101
+ [本轮顺序]: 本轮顺序
102
+
103
+ [IN] -> [发牌]
104
+ [发牌] -> [牌面文案]
105
+ [牌面文案] -> [开局公告]
106
+ [开局公告] -> for @speaker in $alive:
107
+ -> [看牌] ->
108
+ -> [本轮顺序]
109
+ [本轮顺序] -> [OUT]
110
+
111
+ # sketch:
112
+ # [FOR] = 145, 201
113
+ # [OUT] = 600, 380
114
+ # [发牌] = 180, 120
115
+ # [开局公告] = 420, 120
116
+ # [看牌] = -4, 165
117
+ # [轮次推进] = 188, 261
118
+ # [本轮顺序] = 420, 260
119
+
120
+ module 发言:
121
+ # 轮次号必须在这里自增:发牌模块只跑一次,主循环回到 &发言 时不会再进发牌,
122
+ # 旧写法(自增放在发牌)导致公告永远显示"第 1 轮"(2026-09-12 实测)。
123
+ action 轮次推进 @assign:
124
+ out:
125
+ round_no += 1
126
+
127
+ action 生成轮次公告 @func(u.round_announcement):
128
+ in:
129
+ round_no = round_no
130
+ alive_players = $alive
131
+ out:
132
+ announce_text, round_task
133
+
134
+ action 回合公告 @notice:
135
+ prompt: |
136
+ "{announce_text}\n{round_task}"
137
+ scope: all
138
+
139
+ action 陈述 @mind(@speaker):
140
+ prompt: |
141
+ 【谁是卧底 · 第{round_no}轮陈述】你是{@speaker}。{words_text.@speaker}
142
+ 当前存活玩家:{u.names($alive)}。
143
+ 轮到你陈述了:用一句自然的话描述你的牌面。
144
+ · 不能直接把牌面念出来;
145
+ · 也不能描述得太直白独特——太独特会被人照抄;
146
+ · 说一句正常游戏里会说的话就够了,不要长篇分析,不要自报身份(你自己也不知道身份,别露怯);
147
+ · 本节点只输出这一句台词,不要写 SET VARIABLE,也不要写任何赋值语句。
148
+ scope: all
149
+
150
+ action 设定常规投票人 @assign:
151
+ out:
152
+ $voters = $alive
153
+
154
+ flow:
155
+ [轮次推进]: 轮次推进
156
+ [生成轮次公告]: 生成轮次公告
157
+ [回合公告]: 回合公告
158
+ [陈述]: 陈述
159
+ [设定常规投票人]: 设定常规投票人
160
+
161
+ [IN] -> [轮次推进]
162
+ [轮次推进] -> [生成轮次公告]
163
+ [生成轮次公告] -> [回合公告]
164
+ [回合公告] -> for @speaker in $alive:
165
+ -> [陈述] ->
166
+ -> [设定常规投票人]
167
+ [设定常规投票人] -> [OUT]
168
+
169
+ # sketch:
170
+ # [FOR] = 200, 200
171
+ # [OUT] = 600, 380
172
+ # [生成轮次公告] = 180, 120
173
+ # [回合公告] = 420, 120
174
+ # [陈述] = 393, 212
175
+ # [设定常规投票人] = 180, 260
176
+
177
+ module 投票:
178
+ action 票箱清空 @assign:
179
+ out:
180
+ $vote_results = {}
181
+
182
+ action 投票 @mind(@speaker):
183
+ prompt: |
184
+ 【谁是卧底 · 第{round_no}轮投票】你是{@speaker},现在轮到你投票。
185
+ 当前存活玩家:{u.names($alive)}。你不能投自己。
186
+ 回想这一轮大家的陈述:谁的话跟别人对不上?谁像在含糊其辞、没有正面描述?
187
+ 先给一句简短的怀疑理由,然后必须输出一行赋值:
188
+ SET VARIABLE: <<@VOTE = @你怀疑的人>>
189
+ 只能填存活玩家名单里真实存在的名字,不能弃票。
190
+ showprompt: |
191
+ "【投票】轮到你投票:先给一句怀疑理由,再在下面的选择器里选你要投的人。"
192
+ scope: self
193
+ out:
194
+ @VOTE
195
+
196
+ action 收票 @func(u.collect_vote):
197
+ in:
198
+ vote_results = $vote_results
199
+ voter_name = @speaker
200
+ target = @VOTE
201
+ out:
202
+ $vote_results
203
+
204
+ flow:
205
+ [票箱清空]: 票箱清空
206
+ [投票]: 投票
207
+ [收票]: 收票
208
+
209
+ [IN] -> [票箱清空]
210
+ [票箱清空] -> par @speaker in $voters:
211
+ -> [投票] -> [收票] ->
212
+ -> [OUT]
213
+
214
+ # sketch:
215
+ # [PAR] = 140, -5
216
+ # [PAR_出] = 145, 279
217
+ # [OUT] = 3, 200
218
+ # [票箱清空] = -5, 91
219
+ # [投票] = 141, 91
220
+ # [收票] = 143, 177
221
+
222
+ module 结算:
223
+ action 计票结算 @func(u.process_votes):
224
+ in:
225
+ vote_results = $vote_results
226
+ alive_players = $alive
227
+ roles = roles
228
+ round_no = round_no
229
+ out:
230
+ eliminated, $alive, is_pk, $pk_candidates, announce_text, game_over, winner
231
+
232
+ action 投票结果公告 @notice:
233
+ prompt: |
234
+ "{announce_text}"
235
+ scope: all
236
+
237
+ flow:
238
+ [计票结算]: 计票结算
239
+ [投票结果公告]: 投票结果公告
240
+
241
+ [IN] -> [计票结算]
242
+ [计票结算] -> [投票结果公告]
243
+ [投票结果公告] -> [OUT]
244
+
245
+ # sketch:
246
+ # [OUT] = 600, 280
247
+ # [计票结算] = 180, 120
248
+ # [投票结果公告] = 420, 120
249
+
250
+ module 平票PK:
251
+ action 生成PK提示 @func(u.pk_prompt):
252
+ in:
253
+ pk_candidates = $pk_candidates
254
+ alive_players = $alive
255
+ round_no = round_no
256
+ out:
257
+ announce_text, $pk_voters
258
+
259
+ action PK公告 @notice:
260
+ prompt: |
261
+ "{announce_text}"
262
+ scope: all
263
+
264
+ action PK申辩 @mind(@speaker):
265
+ prompt: |
266
+ 【平票 PK】你是{@speaker},你被投到平票了,现在轮到你申辩。
267
+ 平票的玩家:{u.names($pk_candidates)}。
268
+ 当前存活玩家:{u.names($alive)}。
269
+ 用一句话为自己申辩:说说为什么自己不像最可疑的那个,或者指出别人的破绽。
270
+ · 不要把你的词直接说出来,也不要自报身份;
271
+ · 一句话就够,不要长篇大论;
272
+ · 本节点只输出这一句申辩,不要写 SET VARIABLE,也不要写任何赋值语句。
273
+ scope: all
274
+
275
+ action 设定PK投票人 @assign:
276
+ out:
277
+ $voters = $pk_voters
278
+
279
+ action PK计票结算 @func(u.pk_decide):
280
+ in:
281
+ vote_results = $vote_results
282
+ pk_candidates = $pk_candidates
283
+ alive_players = $alive
284
+ roles = roles
285
+ round_no = round_no
286
+ out:
287
+ eliminated, $alive, $pk_candidates, announce_text, game_over, winner
288
+
289
+ action PK结果公告 @notice:
290
+ prompt: |
291
+ "{announce_text}"
292
+ scope: all
293
+
294
+ flow:
295
+ [生成PK提示]: 生成PK提示
296
+ [PK公告]: PK公告
297
+ [PK申辩]: PK申辩
298
+ [设定PK投票人]: 设定PK投票人
299
+ [PK重投]: &投票
300
+ [PK计票结算]: PK计票结算
301
+ [PK结果公告]: PK结果公告
302
+
303
+ [IN] -> [生成PK提示]
304
+ [生成PK提示] -> [PK公告]
305
+ [PK公告] -> for @speaker in $pk_candidates:
306
+ -> [PK申辩] ->
307
+ -> [设定PK投票人]
308
+ [设定PK投票人] -> [PK重投]
309
+ [PK重投] -> [PK计票结算]
310
+ [PK计票结算] -> [PK结果公告]
311
+ [PK结果公告] -> [OUT]
312
+
313
+ # sketch:
314
+ # [FOR] = 321, 101
315
+ # [OUT] = 131, 207
316
+ # [生成PK提示] = 155, -9
317
+ # [PK公告] = 317, -8
318
+ # [PK申辩] = 155, 80
319
+ # [设定PK投票人] = 464, -7
320
+ # [PK重投] = 459, 78
321
+ # [PK计票结算] = 464, 195
322
+ # [PK结果公告] = 297, 196
323
+
324
+ module 赛后讨论:
325
+ action 终局判决 @func(u.verdict):
326
+ in:
327
+ eliminated = eliminated
328
+ roles = roles
329
+ words = words
330
+ alive_players = $alive
331
+ winner = winner
332
+ deck_word = deck_word
333
+ out:
334
+ verdict_text, announce_text
335
+
336
+ action 终局公告 @notice:
337
+ prompt: |
338
+ "{announce_text}"
339
+ scope: all
340
+
341
+ action 散场闲聊 @ai(@Eve):
342
+ prompt: |
343
+ 游戏结束了,大家随便聊聊这局吧:你觉得谁演得最好,谁露了马脚。
344
+ 本节点只输出这段闲聊,不要写 SET VARIABLE,也不要写任何赋值语句。
345
+ scope: all
346
+
347
+ flow:
348
+ [终局判决]: 终局判决
349
+ [终局公告]: 终局公告
350
+ [散场闲聊]: 散场闲聊
351
+
352
+ [IN] -> [终局判决]
353
+ [终局判决] -> [终局公告]
354
+ [终局公告] -> [散场闲聊]
355
+ [散场闲聊] -> [OUT]
356
+
357
+ # sketch:
358
+ # [OUT] = 600, 280
359
+ # [终局判决] = 180, 120
360
+ # [终局公告] = 337, 120
361
+ # [散场闲聊] = 495, 120
362
+
363
+ mainflow:
364
+ [发牌]: &发牌
365
+ [发言]: &发言
366
+ [投票]: &投票
367
+ [结算]: &结算
368
+ [平票PK]: &平票PK
369
+ [赛后讨论]: &赛后讨论
370
+ [结束判定]: 结束判定
371
+
372
+ [START] -> [发牌]
373
+ [发牌] -> [发言]
374
+ [发言] -> [投票]
375
+ [投票] -> [结算]
376
+ [结算] -> fork:
377
+ -> if (is_pk == false) -> [结束判定]
378
+ -> if (is_pk == true) -> [平票PK]
379
+ [结束判定] -> fork:
380
+ -> if (game_over == false) -> [发言]
381
+ -> if (game_over == true) -> [赛后讨论]
382
+ [赛后讨论] -> [END]
383
+ [平票PK] -> [结束判定]
384
+
385
+ #sketch:
386
+ # [END] = -1, 174
387
+ # [发牌] = 153, -15
388
+ # [发言] = 313, -15
389
+ # [投票] = 490, -15
390
+ # [结算] = 491, 117
391
+ # [平票PK] = 491, 246
392
+ # [赛后讨论] = 149, 159
393
+ # [结束判定] = 317, 166
@@ -0,0 +1,3 @@
1
+ // after-tool.mjs — 薄 hook:经网关查询注入内容(语义见 gateway.mjs /hook/post-tool-use)
2
+ import { relay } from './lib.mjs';
3
+ relay('post-tool-use');
@@ -0,0 +1,16 @@
1
+ {
2
+ "hooks": {
3
+ "SessionStart": [
4
+ { "hooks": [{ "type": "process", "command": "node", "args": ["${ZCODE_PLUGIN_ROOT}/hooks/session-start.mjs"], "timeoutMs": 4000, "statusMessage": "femo: 检查剧本运行态" }] }
5
+ ],
6
+ "UserPromptSubmit": [
7
+ { "hooks": [{ "type": "process", "command": "node", "args": ["${ZCODE_PLUGIN_ROOT}/hooks/prompt-state.mjs"], "timeoutMs": 4000, "statusMessage": "femo: 运行态播报" }] }
8
+ ],
9
+ "Stop": [
10
+ { "hooks": [{ "type": "process", "command": "node", "args": ["${ZCODE_PLUGIN_ROOT}/hooks/stop-intent.mjs"], "timeoutMs": 4000, "statusMessage": "femo: 检查待演节点" }] }
11
+ ],
12
+ "PostToolUse": [
13
+ { "matcher": "femo_.*", "hooks": [{ "type": "process", "command": "node", "args": ["${ZCODE_PLUGIN_ROOT}/hooks/after-tool.mjs"], "timeoutMs": 4000, "statusMessage": "femo: 下一步提示" }] }
14
+ ]
15
+ }
16
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * lib.mjs — hook 薄客户端共享库。
3
+ * 铁律:2s 内必答,任何异常静默退出——hook 绝不卡会话。
4
+ * 端口发现顺序:FEMO_DATA_DIR → ZCODE_PLUGIN_DATA → femoRoot/user_data(自包含缺省布局)。
5
+ */
6
+ import { existsSync, readFileSync } from 'node:fs';
7
+ import { join, dirname } from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+
10
+ const PLUGIN_ROOT = process.env.ZCODE_PLUGIN_ROOT || process.env.CLAUDE_PLUGIN_ROOT || join(dirname(fileURLToPath(import.meta.url)), '..');
11
+
12
+ /** femoRoot(引擎根):从插件根向上找含 femo2host 的祖先——开发态解析到仓库根
13
+ * (插件根 = hostAdapter/zcodeAdapter);找不到 = 安装态平铺布局,落回插件根本身。
14
+ * 与 mcp/bridge-manager.mjs 的 resolveFemoRoot 同语义(hook 侧零依赖自备一份)。 */
15
+ export function findFemoRoot() {
16
+ let dir = PLUGIN_ROOT;
17
+ for (let i = 0; i < 6; i++) {
18
+ if (existsSync(join(dir, 'femo2host'))) return dir;
19
+ const parent = dirname(dir);
20
+ if (parent === dir) break;
21
+ dir = parent;
22
+ }
23
+ return PLUGIN_ROOT;
24
+ }
25
+
26
+ export function findGatewayPort() {
27
+ const roots = [];
28
+ if (process.env.FEMO_DATA_DIR) roots.push(join(process.env.FEMO_DATA_DIR, 'femo'));
29
+ if (process.env.ZCODE_PLUGIN_DATA) roots.push(join(process.env.ZCODE_PLUGIN_DATA, 'femo'));
30
+ roots.push(join(findFemoRoot(), 'user_data')); // 自包含缺省布局
31
+ for (const r of roots) {
32
+ const f = join(r, 'host-history', 'gateway.port');
33
+ if (existsSync(f)) {
34
+ const p = readFileSync(f, 'utf8').trim();
35
+ if (/^\d+$/.test(p)) return p;
36
+ }
37
+ }
38
+ return null;
39
+ }
40
+
41
+ /** 查询网关 hook 端点并原样输出其 JSON(空对象 = 不注入)。 */
42
+ export async function relay(endpoint) {
43
+ let stdin = '';
44
+ process.stdin.setEncoding('utf8');
45
+ process.stdin.on('data', d => { stdin += d; });
46
+ process.stdin.on('end', async () => {
47
+ try {
48
+ const port = findGatewayPort();
49
+ if (!port) process.exit(0); // 网关未起 = 插件未活动,静默
50
+ const ctl = new AbortController();
51
+ const timer = setTimeout(() => ctl.abort(), 2000);
52
+ const res = await fetch(`http://127.0.0.1:${port}/hook/${endpoint}`, { signal: ctl.signal });
53
+ clearTimeout(timer);
54
+ const out = await res.json();
55
+ if (out && Object.keys(out).length > 0) process.stdout.write(JSON.stringify(out));
56
+ } catch { /* 静默 */ }
57
+ process.exit(0);
58
+ });
59
+ }
@@ -0,0 +1,3 @@
1
+ // prompt-state.mjs — 薄 hook:经网关查询注入内容(语义见 gateway.mjs /hook/user-prompt-submit)
2
+ import { relay } from './lib.mjs';
3
+ relay('user-prompt-submit');
@@ -0,0 +1,3 @@
1
+ // session-start.mjs — 薄 hook:经网关查询注入内容(语义见 gateway.mjs /hook/session-start)
2
+ import { relay } from './lib.mjs';
3
+ relay('session-start');
@@ -0,0 +1,3 @@
1
+ // stop-intent.mjs — 薄 hook:经网关查询注入内容(语义见 gateway.mjs /hook/stop)
2
+ import { relay } from './lib.mjs';
3
+ relay('stop');
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env python3
2
+ """Local protocol test for femo_bridge.py (no dsh involved)."""
3
+ import subprocess
4
+ import sys
5
+ import json
6
+ import time
7
+
8
+ sys.stdout.reconfigure(encoding="utf-8", errors="replace")
9
+ sys.stderr.reconfigure(encoding="utf-8", errors="replace")
10
+
11
+ BRIDGE = r"D:\myFiles\fe4m\python\femo_bridge.py"
12
+ FE4M = r"D:\myFiles\fe4m"
13
+
14
+ p = subprocess.Popen(
15
+ [sys.executable, BRIDGE, "--fe4m", FE4M],
16
+ stdin=subprocess.PIPE,
17
+ stdout=subprocess.PIPE,
18
+ stderr=subprocess.PIPE,
19
+ text=True,
20
+ encoding="utf-8",
21
+ errors="replace",
22
+ bufsize=1,
23
+ )
24
+
25
+ def send(obj):
26
+ p.stdin.write(json.dumps(obj) + "\n")
27
+ p.stdin.flush()
28
+
29
+ send({"id": 1, "cmd": "ping", "args": {}})
30
+ send({"id": 2, "cmd": "list_scripts", "args": {}})
31
+ send({"id": 3, "cmd": "run", "args": {"femo": "not a real script"}})
32
+ time.sleep(2)
33
+ p.stdin.close()
34
+ try:
35
+ out, err = p.communicate(timeout=15)
36
+ except subprocess.TimeoutExpired:
37
+ p.kill()
38
+ out, err = p.communicate()
39
+ print("!! timed out; process killed")
40
+ print("=== bridge stdout ===")
41
+ print(out)
42
+ print("=== bridge stderr (first 2000 chars) ===")
43
+ print(err[:2000])