@team-agent/installer 0.5.128 → 0.6.0

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 (436) hide show
  1. package/README.md +4 -4
  2. package/README.zh.md +1 -1
  3. package/package.json +4 -8
  4. package/skills/team-agent/SKILL.md +37 -20
  5. package/skills/team-agent/command-coverage.json +169 -183
  6. package/skills/team-agent/docs/reference/team-agent-operator.md +64 -30
  7. package/skills/team-agent/references/recovery-runbook.md +1 -1
  8. package/skills/team-agent/references/team-agent-operator.md +64 -30
  9. package/templates/team_state.md +1 -1
  10. package/Cargo.lock +0 -1063
  11. package/Cargo.toml +0 -36
  12. package/crates/team-agent/Cargo.toml +0 -69
  13. package/crates/team-agent/src/app_server_test_support.rs +0 -258
  14. package/crates/team-agent/src/cli/adapters.rs +0 -1288
  15. package/crates/team-agent/src/cli/arguments.rs +0 -405
  16. package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
  17. package/crates/team-agent/src/cli/diagnose.rs +0 -1721
  18. package/crates/team-agent/src/cli/emit.rs +0 -2930
  19. package/crates/team-agent/src/cli/grok_slot.rs +0 -384
  20. package/crates/team-agent/src/cli/helpers.rs +0 -91
  21. package/crates/team-agent/src/cli/intent/runtime.rs +0 -1216
  22. package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -912
  23. package/crates/team-agent/src/cli/intent/tests.rs +0 -689
  24. package/crates/team-agent/src/cli/intent.rs +0 -664
  25. package/crates/team-agent/src/cli/leader.rs +0 -300
  26. package/crates/team-agent/src/cli/leader_prompt.rs +0 -261
  27. package/crates/team-agent/src/cli/leaders.rs +0 -418
  28. package/crates/team-agent/src/cli/mod.rs +0 -6545
  29. package/crates/team-agent/src/cli/models.rs +0 -1206
  30. package/crates/team-agent/src/cli/named_address.rs +0 -1651
  31. package/crates/team-agent/src/cli/profile.rs +0 -342
  32. package/crates/team-agent/src/cli/route.rs +0 -212
  33. package/crates/team-agent/src/cli/schedule.rs +0 -175
  34. package/crates/team-agent/src/cli/send/coordinator.rs +0 -164
  35. package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
  36. package/crates/team-agent/src/cli/send/persist.rs +0 -156
  37. package/crates/team-agent/src/cli/send/presentation.rs +0 -370
  38. package/crates/team-agent/src/cli/send/resolve.rs +0 -573
  39. package/crates/team-agent/src/cli/send.rs +0 -199
  40. package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
  41. package/crates/team-agent/src/cli/spec.rs +0 -165
  42. package/crates/team-agent/src/cli/status.rs +0 -280
  43. package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
  44. package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
  45. package/crates/team-agent/src/cli/status_port/brief.rs +0 -1981
  46. package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
  47. package/crates/team-agent/src/cli/status_port/format.rs +0 -146
  48. package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
  49. package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
  50. package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
  51. package/crates/team-agent/src/cli/status_port/store.rs +0 -416
  52. package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
  53. package/crates/team-agent/src/cli/status_port.rs +0 -92
  54. package/crates/team-agent/src/cli/tests/base.rs +0 -885
  55. package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
  56. package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
  57. package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -322
  58. package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
  59. package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
  60. package/crates/team-agent/src/cli/tests/mod.rs +0 -137
  61. package/crates/team-agent/src/cli/tests/named_address.rs +0 -761
  62. package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
  63. package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -484
  64. package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
  65. package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
  66. package/crates/team-agent/src/cli/tests/status_send.rs +0 -888
  67. package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
  68. package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
  69. package/crates/team-agent/src/cli/triage.rs +0 -234
  70. package/crates/team-agent/src/cli/types.rs +0 -591
  71. package/crates/team-agent/src/codex_app_server.rs +0 -546
  72. package/crates/team-agent/src/communication_mode/mod.rs +0 -56
  73. package/crates/team-agent/src/compiler/tests.rs +0 -827
  74. package/crates/team-agent/src/compiler.rs +0 -890
  75. package/crates/team-agent/src/conpty/backend.rs +0 -829
  76. package/crates/team-agent/src/conpty/mod.rs +0 -33
  77. package/crates/team-agent/src/contract_runtime/backend.rs +0 -1744
  78. package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
  79. package/crates/team-agent/src/contract_runtime/config.rs +0 -364
  80. package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -76
  81. package/crates/team-agent/src/contract_runtime/discovery.rs +0 -449
  82. package/crates/team-agent/src/contract_runtime/fork.rs +0 -361
  83. package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
  84. package/crates/team-agent/src/contract_runtime/framework.rs +0 -367
  85. package/crates/team-agent/src/contract_runtime/mcp.rs +0 -394
  86. package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
  87. package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
  88. package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
  89. package/crates/team-agent/src/contract_runtime/registry.rs +0 -553
  90. package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
  91. package/crates/team-agent/src/coordinator/backoff.rs +0 -741
  92. package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
  93. package/crates/team-agent/src/coordinator/health.rs +0 -1185
  94. package/crates/team-agent/src/coordinator/mod.rs +0 -119
  95. package/crates/team-agent/src/coordinator/orphan.rs +0 -110
  96. package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
  97. package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
  98. package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
  99. package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
  100. package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
  101. package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
  102. package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
  103. package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
  104. package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
  105. package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
  106. package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
  107. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -300
  108. package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
  109. package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
  110. package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
  111. package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -503
  112. package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
  113. package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
  114. package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
  115. package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
  116. package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
  117. package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
  118. package/crates/team-agent/src/coordinator/tick.rs +0 -3024
  119. package/crates/team-agent/src/coordinator/types.rs +0 -540
  120. package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
  121. package/crates/team-agent/src/db/message_store.rs +0 -1527
  122. package/crates/team-agent/src/db/migration.rs +0 -984
  123. package/crates/team-agent/src/db/mod.rs +0 -26
  124. package/crates/team-agent/src/db/schema.rs +0 -663
  125. package/crates/team-agent/src/diagnose/comms.rs +0 -242
  126. package/crates/team-agent/src/diagnose/mod.rs +0 -44
  127. package/crates/team-agent/src/diagnose/orphans.rs +0 -889
  128. package/crates/team-agent/src/direct_delivery.rs +0 -368
  129. package/crates/team-agent/src/event_log.rs +0 -502
  130. package/crates/team-agent/src/fake_worker.rs +0 -303
  131. package/crates/team-agent/src/inbox_store.rs +0 -169
  132. package/crates/team-agent/src/kill_audit.rs +0 -106
  133. package/crates/team-agent/src/layout/manager.rs +0 -248
  134. package/crates/team-agent/src/layout/mod.rs +0 -36
  135. package/crates/team-agent/src/layout/overlay.rs +0 -134
  136. package/crates/team-agent/src/layout/placement.rs +0 -52
  137. package/crates/team-agent/src/layout/recovery.rs +0 -106
  138. package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
  139. package/crates/team-agent/src/layout/sessions.rs +0 -294
  140. package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
  141. package/crates/team-agent/src/layout/worker_env.rs +0 -721
  142. package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
  143. package/crates/team-agent/src/leader/helpers.rs +0 -178
  144. package/crates/team-agent/src/leader/incident.rs +0 -6
  145. package/crates/team-agent/src/leader/lease.rs +0 -3356
  146. package/crates/team-agent/src/leader/mod.rs +0 -104
  147. package/crates/team-agent/src/leader/owner_bind.rs +0 -400
  148. package/crates/team-agent/src/leader/prompt.rs +0 -905
  149. package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
  150. package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
  151. package/crates/team-agent/src/leader/rediscover.rs +0 -1192
  152. package/crates/team-agent/src/leader/registry.rs +0 -888
  153. package/crates/team-agent/src/leader/start.rs +0 -4501
  154. package/crates/team-agent/src/leader/takeover.rs +0 -65
  155. package/crates/team-agent/src/leader/tests/basics.rs +0 -337
  156. package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
  157. package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
  158. package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
  159. package/crates/team-agent/src/leader/tests/identity.rs +0 -465
  160. package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
  161. package/crates/team-agent/src/leader/tests/idle.rs +0 -113
  162. package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
  163. package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
  164. package/crates/team-agent/src/leader/tests/mod.rs +0 -106
  165. package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -268
  166. package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
  167. package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
  168. package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
  169. package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
  170. package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
  171. package/crates/team-agent/src/leader/types.rs +0 -534
  172. package/crates/team-agent/src/lib.rs +0 -147
  173. package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
  174. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -881
  175. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -598
  176. package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
  177. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -204
  178. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -107
  179. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -144
  180. package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
  181. package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
  182. package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
  183. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -160
  184. package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
  185. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -899
  186. package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -225
  187. package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
  188. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5200
  189. package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
  190. package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
  191. package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
  192. package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -473
  193. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
  194. package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
  195. package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
  196. package/crates/team-agent/src/lifecycle/launch.rs +0 -557
  197. package/crates/team-agent/src/lifecycle/lock.rs +0 -350
  198. package/crates/team-agent/src/lifecycle/mod.rs +0 -79
  199. package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
  200. package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -1067
  201. package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
  202. package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2199
  203. package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1798
  204. package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +0 -163
  205. package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2362
  206. package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
  207. package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
  208. package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
  209. package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
  210. package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
  211. package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
  212. package/crates/team-agent/src/lifecycle/restart.rs +0 -227
  213. package/crates/team-agent/src/lifecycle/role_config.rs +0 -1230
  214. package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
  215. package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
  216. package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
  217. package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
  218. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
  219. package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
  220. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -447
  221. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1638
  222. package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
  223. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -770
  224. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -419
  225. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2035
  226. package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1327
  227. package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
  228. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
  229. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
  230. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -72
  231. package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
  232. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
  233. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -512
  234. package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
  235. package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
  236. package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
  237. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3983
  238. package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
  239. package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
  240. package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
  241. package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
  242. package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
  243. package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
  244. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -164
  245. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -200
  246. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
  247. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -527
  248. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -1062
  249. package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1419
  250. package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -98
  251. package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -550
  252. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -226
  253. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -332
  254. package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
  255. package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
  256. package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
  257. package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
  258. package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
  259. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
  260. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
  261. package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
  262. package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
  263. package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
  264. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
  265. package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
  266. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -342
  267. package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
  268. package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
  269. package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
  270. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
  271. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
  272. package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
  273. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
  274. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -995
  275. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -836
  276. package/crates/team-agent/src/lifecycle/tests.rs +0 -105
  277. package/crates/team-agent/src/lifecycle/types.rs +0 -877
  278. package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -363
  279. package/crates/team-agent/src/main.rs +0 -52
  280. package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
  281. package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
  282. package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
  283. package/crates/team-agent/src/mcp_server/mod.rs +0 -119
  284. package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
  285. package/crates/team-agent/src/mcp_server/readiness.rs +0 -527
  286. package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -348
  287. package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
  288. package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
  289. package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -158
  290. package/crates/team-agent/src/mcp_server/tests/send.rs +0 -353
  291. package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -341
  292. package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
  293. package/crates/team-agent/src/mcp_server/tests.rs +0 -43
  294. package/crates/team-agent/src/mcp_server/tools.rs +0 -889
  295. package/crates/team-agent/src/mcp_server/types.rs +0 -396
  296. package/crates/team-agent/src/mcp_server/wire.rs +0 -867
  297. package/crates/team-agent/src/messaging/activity.rs +0 -461
  298. package/crates/team-agent/src/messaging/address.rs +0 -87
  299. package/crates/team-agent/src/messaging/delivery.rs +0 -3727
  300. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
  301. package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
  302. package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
  303. package/crates/team-agent/src/messaging/helpers.rs +0 -336
  304. package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
  305. package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
  306. package/crates/team-agent/src/messaging/mod.rs +0 -167
  307. package/crates/team-agent/src/messaging/persist.rs +0 -377
  308. package/crates/team-agent/src/messaging/presentation.rs +0 -417
  309. package/crates/team-agent/src/messaging/reminders.rs +0 -316
  310. package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
  311. package/crates/team-agent/src/messaging/results.rs +0 -1415
  312. package/crates/team-agent/src/messaging/scheduler.rs +0 -223
  313. package/crates/team-agent/src/messaging/selftest.rs +0 -315
  314. package/crates/team-agent/src/messaging/send.rs +0 -981
  315. package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
  316. package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -657
  317. package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
  318. package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
  319. package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
  320. package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
  321. package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
  322. package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3549
  323. package/crates/team-agent/src/messaging/tests/spine.rs +0 -853
  324. package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
  325. package/crates/team-agent/src/messaging/trust.rs +0 -215
  326. package/crates/team-agent/src/messaging/types.rs +0 -472
  327. package/crates/team-agent/src/messaging/wait.rs +0 -366
  328. package/crates/team-agent/src/messaging/watchers.rs +0 -916
  329. package/crates/team-agent/src/model/enums.rs +0 -356
  330. package/crates/team-agent/src/model/errors.rs +0 -18
  331. package/crates/team-agent/src/model/ids.rs +0 -165
  332. package/crates/team-agent/src/model/mod.rs +0 -29
  333. package/crates/team-agent/src/model/name_similarity.rs +0 -252
  334. package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
  335. package/crates/team-agent/src/model/paths.rs +0 -257
  336. package/crates/team-agent/src/model/routing.rs +0 -387
  337. package/crates/team-agent/src/model/spec.rs +0 -1184
  338. package/crates/team-agent/src/model/task_graph.rs +0 -321
  339. package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
  340. package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
  341. package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
  342. package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
  343. package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
  344. package/crates/team-agent/src/model/yaml/tests.rs +0 -188
  345. package/crates/team-agent/src/model/yaml.rs +0 -802
  346. package/crates/team-agent/src/os_probe.rs +0 -280
  347. package/crates/team-agent/src/packaging/install.rs +0 -219
  348. package/crates/team-agent/src/packaging/migrate.rs +0 -38
  349. package/crates/team-agent/src/packaging/mod.rs +0 -91
  350. package/crates/team-agent/src/packaging/repair.rs +0 -33
  351. package/crates/team-agent/src/packaging/tests.rs +0 -822
  352. package/crates/team-agent/src/packaging/types.rs +0 -417
  353. package/crates/team-agent/src/platform/argv.rs +0 -331
  354. package/crates/team-agent/src/platform/errors.rs +0 -104
  355. package/crates/team-agent/src/platform/file_lock.rs +0 -279
  356. package/crates/team-agent/src/platform/mod.rs +0 -5
  357. package/crates/team-agent/src/platform/process.rs +0 -545
  358. package/crates/team-agent/src/provider/adapter.rs +0 -1150
  359. package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
  360. package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
  361. package/crates/team-agent/src/provider/adapters/copilot.rs +0 -75
  362. package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
  363. package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
  364. package/crates/team-agent/src/provider/adapters/mod.rs +0 -30
  365. package/crates/team-agent/src/provider/adapters/pi.rs +0 -106
  366. package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
  367. package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
  368. package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
  369. package/crates/team-agent/src/provider/argv_route.rs +0 -405
  370. package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
  371. package/crates/team-agent/src/provider/classify.rs +0 -708
  372. package/crates/team-agent/src/provider/command_helpers.rs +0 -45
  373. package/crates/team-agent/src/provider/faults.rs +0 -165
  374. package/crates/team-agent/src/provider/helpers.rs +0 -52
  375. package/crates/team-agent/src/provider/mod.rs +0 -78
  376. package/crates/team-agent/src/provider/model_catalog.rs +0 -910
  377. package/crates/team-agent/src/provider/session/capture.rs +0 -2731
  378. package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
  379. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -172
  380. package/crates/team-agent/src/provider/session/context_fork.rs +0 -396
  381. package/crates/team-agent/src/provider/session/mod.rs +0 -36
  382. package/crates/team-agent/src/provider/session/resume.rs +0 -269
  383. package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
  384. package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
  385. package/crates/team-agent/src/provider/session_scan/common.rs +0 -654
  386. package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
  387. package/crates/team-agent/src/provider/session_scan/pi.rs +0 -185
  388. package/crates/team-agent/src/provider/session_scan.rs +0 -71
  389. package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
  390. package/crates/team-agent/src/provider/submit_now.rs +0 -71
  391. package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
  392. package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
  393. package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
  394. package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
  395. package/crates/team-agent/src/provider/tests/adapter.rs +0 -441
  396. package/crates/team-agent/src/provider/tests/classify.rs +0 -148
  397. package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -35
  398. package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
  399. package/crates/team-agent/src/provider/tests/faults.rs +0 -200
  400. package/crates/team-agent/src/provider/tests/idle.rs +0 -177
  401. package/crates/team-agent/src/provider/tests/wire.rs +0 -213
  402. package/crates/team-agent/src/provider/tests.rs +0 -32
  403. package/crates/team-agent/src/provider/types.rs +0 -529
  404. package/crates/team-agent/src/provider/wire.rs +0 -394
  405. package/crates/team-agent/src/redaction.rs +0 -259
  406. package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
  407. package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
  408. package/crates/team-agent/src/state/identity.rs +0 -914
  409. package/crates/team-agent/src/state/identity_keys.rs +0 -132
  410. package/crates/team-agent/src/state/mod.rs +0 -74
  411. package/crates/team-agent/src/state/owner_gate.rs +0 -482
  412. package/crates/team-agent/src/state/ownership.rs +0 -563
  413. package/crates/team-agent/src/state/paths.rs +0 -395
  414. package/crates/team-agent/src/state/persist.rs +0 -3811
  415. package/crates/team-agent/src/state/projection.rs +0 -1508
  416. package/crates/team-agent/src/state/repository/intent.rs +0 -14
  417. package/crates/team-agent/src/state/repository/tests.rs +0 -184
  418. package/crates/team-agent/src/state/repository.rs +0 -866
  419. package/crates/team-agent/src/state/selector.rs +0 -160
  420. package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
  421. package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
  422. package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
  423. package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
  424. package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
  425. package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
  426. package/crates/team-agent/src/tmux_backend/tests.rs +0 -4103
  427. package/crates/team-agent/src/tmux_backend.rs +0 -4492
  428. package/crates/team-agent/src/topology.rs +0 -537
  429. package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
  430. package/crates/team-agent/src/transport/native_input.rs +0 -491
  431. package/crates/team-agent/src/transport/test_support.rs +0 -743
  432. package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
  433. package/crates/team-agent/src/transport/tests/mod.rs +0 -194
  434. package/crates/team-agent/src/transport/tests/wire.rs +0 -574
  435. package/crates/team-agent/src/transport.rs +0 -1655
  436. package/crates/team-agent/src/transport_factory.rs +0 -819
@@ -1,822 +0,0 @@
1
- //!
2
- #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
3
- #![allow(non_snake_case)]
4
- use super::*;
5
- use std::path::{Path, PathBuf};
6
-
7
- // ───────────────────────────────────────────────────────────────────────
8
- // §19 散字符串 → enum:SkillTarget→Provider 关联 (skeleton:112 codex→Codex,
9
- // claude→ClaudeCode;all→None)。Python _skill_dest_dir 据 target 选 dir。
10
- // ───────────────────────────────────────────────────────────────────────
11
-
12
- #[test]
13
- fn skill_target_codex_maps_to_provider_codex() {
14
- // skeleton line 112: codex→Codex.
15
- assert_eq!(SkillTarget::Codex.provider(), Some(Provider::Codex));
16
- }
17
-
18
- #[test]
19
- fn skill_target_claude_maps_to_provider_claude_code() {
20
- // skeleton line 112: claude→ClaudeCode (NOT bare Claude — §3 claude vs claude_code 不能漏归一).
21
- assert_eq!(SkillTarget::Claude.provider(), Some(Provider::ClaudeCode));
22
- }
23
-
24
- #[test]
25
- fn skill_target_all_has_no_single_provider() {
26
- // `All` fan-out 两者 → 无单一 provider.
27
- assert_eq!(SkillTarget::All.provider(), None);
28
- }
29
-
30
- // ───────────────────────────────────────────────────────────────────────
31
- // _skill_dest_dir (commands.py:467-472):claude→~/.claude/skills/team-agent,
32
- // 其余(含 codex)→~/.codex/skills/team-agent;All→None(非单 dir,fan-out)。
33
- // ───────────────────────────────────────────────────────────────────────
34
-
35
- #[test]
36
- fn dest_dir_codex_resolves_to_dot_codex() {
37
- // commands.py:471 — codex (else branch) → ~/.codex/skills/team-agent.
38
- let home = Path::new("/home/testuser");
39
- let got = SkillTarget::Codex.dest_dir(home);
40
- assert_eq!(
41
- got,
42
- Some(SkillDestDir(PathBuf::from(
43
- "/home/testuser/.codex/skills/team-agent"
44
- )))
45
- );
46
- }
47
-
48
- #[test]
49
- fn dest_dir_claude_resolves_to_dot_claude() {
50
- // commands.py:469 — claude → ~/.claude/skills/team-agent.
51
- let home = Path::new("/home/testuser");
52
- let got = SkillTarget::Claude.dest_dir(home);
53
- assert_eq!(
54
- got,
55
- Some(SkillDestDir(PathBuf::from(
56
- "/home/testuser/.claude/skills/team-agent"
57
- )))
58
- );
59
- }
60
-
61
- #[test]
62
- fn skill_target_copilot_maps_to_provider_copilot() {
63
- // E9: copilot → Provider::Copilot (0.3.x 新增 provider,不归到 codex/claude).
64
- assert_eq!(SkillTarget::Copilot.provider(), Some(Provider::Copilot));
65
- }
66
-
67
- #[test]
68
- fn dest_dir_copilot_resolves_to_dot_copilot() {
69
- // E9 实证 (.team/artifacts/copilot-probe/):copilot skill 源 = ~/.copilot/skills,
70
- // configDir 默认 ~/.copilot → ~/.copilot/skills/team-agent.
71
- let home = Path::new("/home/testuser");
72
- let got = SkillTarget::Copilot.dest_dir(home);
73
- assert_eq!(
74
- got,
75
- Some(SkillDestDir(PathBuf::from(
76
- "/home/testuser/.copilot/skills/team-agent"
77
- )))
78
- );
79
- }
80
-
81
- #[test]
82
- fn dest_dir_three_providers_distinct_locations() {
83
- // E9: 三 provider 各自独立位置 (.codex / .claude / .copilot),互不踩.
84
- let home = Path::new("/home/testuser");
85
- let dirs: Vec<PathBuf> = SkillTarget::SINGLE_TARGETS
86
- .iter()
87
- .map(|t| t.dest_dir(home).expect("single target has dest").0)
88
- .collect();
89
- assert_eq!(
90
- dirs,
91
- vec![
92
- PathBuf::from("/home/testuser/.codex/skills/team-agent"),
93
- PathBuf::from("/home/testuser/.claude/skills/team-agent"),
94
- PathBuf::from("/home/testuser/.copilot/skills/team-agent"),
95
- ]
96
- );
97
- }
98
-
99
- #[test]
100
- fn dest_dir_all_is_none_not_single_dir() {
101
- // `All` 应 fan-out 到两者 → 非单 dir → None (skeleton:116).
102
- let home = Path::new("/home/testuser");
103
- assert_eq!(SkillTarget::All.dest_dir(home), None);
104
- }
105
-
106
- // ───────────────────────────────────────────────────────────────────────
107
- // Version 单一真相源:env!("CARGO_PKG_VERSION") — 修双源漂移
108
- // (pyproject 0.1.4 vs package.json 0.2.11)。current() == Cargo.toml 版本,
109
- // 禁手抄第二处。as_str() 即透传。
110
- // ───────────────────────────────────────────────────────────────────────
111
-
112
- #[test]
113
- fn version_current_equals_cargo_pkg_version() {
114
- // 单一真相源 — 禁手抄。current() 必须 == 编译期 CARGO_PKG_VERSION.
115
- assert_eq!(Version::current().as_str(), env!("CARGO_PKG_VERSION"));
116
- }
117
-
118
- #[test]
119
- fn version_current_is_not_a_hand_copied_python_drift_literal() {
120
- // STRENGTHENED (gate w59ds828k): the old test only asserted !is_empty() && != "dev",
121
- // which a buggy impl returning a hardcoded "0.2.11" copied from package.json would PASS —
122
- // exactly the double-source-drift bug the subsystem forbids. Now CONCRETE & falsifiable.
123
- //
124
- // CONCRETE golden: workspace Cargo.toml version == "0.0.0" (Phase 0; team-agent-rs
125
- // Cargo.toml:12). CARGO_PKG_VERSION therefore resolves to "0.0.0" — which differs from
126
- // BOTH Python drift sources (pyproject.toml 0.1.4 / package.json 0.2.11). So a porter who
127
- // hand-copies either Python literal instead of using env!("CARGO_PKG_VERSION") FAILS here.
128
- let v = Version::current();
129
- assert_eq!(
130
- v.as_str(),
131
- env!("CARGO_PKG_VERSION"),
132
- "single source of truth = CARGO_PKG_VERSION"
133
- );
134
- assert_ne!(
135
- v.as_str(),
136
- "0.1.4",
137
- "must not hand-copy pyproject.toml drift source"
138
- );
139
- assert_ne!(
140
- v.as_str(),
141
- "0.2.11",
142
- "must not hand-copy package.json drift source"
143
- );
144
- assert_ne!(
145
- v.as_str(),
146
- "dev",
147
- "must not be install.mjs:54 'dev' fallback"
148
- );
149
- }
150
-
151
- #[test]
152
- fn no_literal_version_string_hardcoded_in_packaging_code() {
153
- // STRENGTHENED (gate w59ds828k): grep-assert the production CODE (comments stripped)
154
- // contains no hand-copied semver literal — only env!("CARGO_PKG_VERSION") may supply the
155
- // version. Reads the file at test time via CARGO_MANIFEST_DIR. The Python drift literals
156
- // 0.1.4 / 0.2.11 legitimately appear in doc/line comments documenting the bug, so we strip
157
- // comment text first and scan only executable code. This is the one place where
158
- // "double-source-drift forbidden" is statically checked against the source itself.
159
- let src = std::fs::read_to_string(concat!(
160
- env!("CARGO_MANIFEST_DIR"),
161
- "/src/packaging/types.rs"
162
- ))
163
- .expect("read own source");
164
- // Production region only (the #[cfg(test)] mod uses these literals as golden anti-examples):
165
- let prod = match src.find("#[cfg(test)]") {
166
- Some(i) => &src[..i],
167
- None => &src[..],
168
- };
169
- // Strip everything from the first `//` on each line (covers `//!` doc + `//` line comments).
170
- let code: String = prod
171
- .lines()
172
- .map(|line| match line.find("//") {
173
- Some(i) => &line[..i],
174
- None => line,
175
- })
176
- .collect::<Vec<_>>()
177
- .join("\n");
178
- assert!(
179
- !code.contains("0.1.4"),
180
- "packaging.rs code must not hand-copy pyproject 0.1.4 (use env!(CARGO_PKG_VERSION))"
181
- );
182
- assert!(
183
- !code.contains("0.2.11"),
184
- "packaging.rs code must not hand-copy package.json 0.2.11 (use env!(CARGO_PKG_VERSION))"
185
- );
186
- // The ONLY version source allowed is env!("CARGO_PKG_VERSION") — assert it is the source.
187
- assert!(
188
- code.contains("CARGO_PKG_VERSION"),
189
- "Version::current() must derive from env!(\"CARGO_PKG_VERSION\")"
190
- );
191
- }
192
-
193
- #[test]
194
- fn version_serde_transparent_roundtrip() {
195
- // #[serde(transparent)] — 序列化为裸字符串,非 {"0":"..."}.
196
- let v = Version("1.2.3".to_string());
197
- let json = serde_json::to_string(&v).unwrap();
198
- assert_eq!(json, "\"1.2.3\"");
199
- let back: Version = serde_json::from_str(&json).unwrap();
200
- assert_eq!(back, v);
201
- }
202
-
203
- // ───────────────────────────────────────────────────────────────────────
204
- // platform_support (§8 如实声明):macOS/Linux 原生;Windows 原生一等
205
- // (WezTerm/ConPTY,见 transport-backend-design)。不假装兼容。
206
- // ───────────────────────────────────────────────────────────────────────
207
-
208
- #[test]
209
- fn macos_aarch64_is_native() {
210
- assert_eq!(
211
- platform_support(ReleaseTarget::MacosAarch64),
212
- PlatformSupport::Native
213
- );
214
- }
215
-
216
- #[test]
217
- fn macos_x8664_is_native() {
218
- assert_eq!(
219
- platform_support(ReleaseTarget::MacosX8664),
220
- PlatformSupport::Native
221
- );
222
- }
223
-
224
- #[test]
225
- fn linux_x8664_is_native() {
226
- assert_eq!(
227
- platform_support(ReleaseTarget::LinuxX8664),
228
- PlatformSupport::Native
229
- );
230
- }
231
-
232
- #[test]
233
- fn linux_aarch64_is_native() {
234
- assert_eq!(
235
- platform_support(ReleaseTarget::LinuxAarch64),
236
- PlatformSupport::Native
237
- );
238
- }
239
-
240
- #[test]
241
- fn windows_x8664_is_preview_compile_only_during_batch_0_to_5() {
242
- // 0.5.x Windows portability CR C-1 (P0):
243
- // Windows previously claimed `PlatformSupport::Native` but
244
- // `cargo check --target x86_64-pc-windows-msvc` was RED — the
245
- // Unix-only `std::os::unix` / `libc::pid_t` calls in
246
- // tmux_backend/coordinator/lifecycle/packaging never compiled on
247
- // Windows. Claiming Native was a MUST-NOT-13 假绿承诺 (user
248
- // installs and immediately hits build failures).
249
- //
250
- // This test locks the honest downgrade in place until Batch 6/7
251
- // real-machine gates pass. Promoting Windows back to `Native`
252
- // requires:
253
- // 1. Batch 6 fake-provider smoke on the SSH host (design §Batch 6)
254
- // 2. Batch 7 real-machine subscription serial (CR §C-5)
255
- // Both flip this test to `assert PlatformSupport::Native` in a
256
- // deliberate PR — no silent regen.
257
- //
258
- // Truth source: `.team/artifacts/0.5.x-windows-portability-cr-verdict.md` §C-1.
259
- match platform_support(ReleaseTarget::WindowsX8664) {
260
- PlatformSupport::PreviewCompileOnly { preview_gate, note } => {
261
- assert_eq!(preview_gate, "compile_gate");
262
- assert!(note.contains("compile_gate") || note.contains("cargo check"));
263
- }
264
- other => panic!(
265
- "Windows must stay `PreviewCompileOnly` while the compile gate is RED; \
266
- promoting back to `Native` requires Batch 6 + Batch 7 real-machine gates. \
267
- Got {other:?}"
268
- ),
269
- }
270
- }
271
-
272
- #[test]
273
- fn windows_x8664_is_not_native_yet_c1_hard_lock() {
274
- // Belt-and-braces companion for the above — a distinct assertion
275
- // that fires clearly if a future refactor of `PlatformSupport`
276
- // changes variant names.
277
- let support = platform_support(ReleaseTarget::WindowsX8664);
278
- assert_ne!(
279
- support,
280
- PlatformSupport::Native,
281
- "CR C-1: Windows must NOT be Native until Batch 6/7 gates pass"
282
- );
283
- }
284
-
285
- // ───────────────────────────────────────────────────────────────────────
286
- // doctor — typed DoctorStatus (commands.py:218-260)。
287
- // error 路径 + 精确消息:
288
- // - --fix 无 --gate → TeamAgentError("--fix requires --gate") (commands.py:221)
289
- // - unknown doctor gate → "unknown doctor gate: <g>" (commands.py:235)
290
- // - schema layout drift → HasBlockers{SchemaLayoutDrift} (commands.py:242-250)
291
- // ───────────────────────────────────────────────────────────────────────
292
-
293
- fn doctor_opts(workspace: &Path) -> DoctorOptions {
294
- DoctorOptions {
295
- workspace: workspace.to_path_buf(),
296
- gate: None,
297
- fix: false,
298
- cleanup_orphans: false,
299
- confirm: false,
300
- }
301
- }
302
-
303
- #[test]
304
- fn doctor_fix_without_gate_is_invalid_options() {
305
- // commands.py:220-221 — `--fix requires --gate`.
306
- let ws = PathBuf::from("/tmp/ws-doctor-fix");
307
- let mut opts = doctor_opts(&ws);
308
- opts.fix = true;
309
- opts.gate = None;
310
- let err = doctor(&opts).expect_err("fix without gate must error");
311
- match err {
312
- PackagingError::InvalidOptions(msg) => {
313
- assert!(
314
- msg.contains("--fix requires --gate"),
315
- "expected '--fix requires --gate', got: {msg}"
316
- );
317
- }
318
- other => panic!("expected InvalidOptions, got {other:?}"),
319
- }
320
- }
321
-
322
- /// TEST-SUPPORT seed helper (real impl — pure test scaffolding, uses rusqlite directly):
323
- /// build a workspace whose `.team/runtime/team.db` has the LEGACY drifted layout
324
- /// (owner_team_id appended as the last column on the 4 managed tables, user_version=1).
325
- /// This is the exact fixture migration.rs::build_legacy uses; schema_diagnosis on it yields
326
- /// non-empty layout_diffs → doctor() must surface SchemaLayoutDrift. Returns the workspace.
327
- fn seed_workspace_with_drifted_db(tag: &str) -> PathBuf {
328
- use rusqlite::Connection;
329
- let ws = std::env::temp_dir().join(format!("ta-doctor-drift-{}-{}", std::process::id(), tag));
330
- let db = ws.join(".team").join("runtime").join("team.db");
331
- std::fs::create_dir_all(db.parent().unwrap()).expect("seed runtime dir");
332
- let conn = Connection::open(&db).expect("open drifted db");
333
- // Legacy layout: owner_team_id is the LAST column → physical column-order drift vs canonical.
334
- conn.execute_batch(
335
- "create table messages (message_id text primary key, task_id text, sender text, recipient text, reply_to text, requires_ack integer, status text, content text, artifact_refs text, created_at text, updated_at text, delivered_at text, acknowledged_at text, error text, delivery_attempts integer not null default 0, owner_team_id text);
336
- create table results (result_id text primary key, task_id text not null, agent_id text not null, envelope text not null, status text not null, created_at text not null, owner_team_id text);
337
- create table scheduled_events (id integer primary key, due_at text not null, target text not null, kind text not null, payload_json text not null, status text not null, created_at text not null, fired_at text, result_json text, owner_team_id text);
338
- create table agent_health (agent_id text not null, status text not null, last_output_at text, context_usage_pct integer, current_task_id text, updated_at text not null, owner_team_id text);
339
- pragma user_version = 1;",
340
- )
341
- .expect("seed legacy schema");
342
- drop(conn);
343
- ws
344
- }
345
-
346
- #[test]
347
- fn doctor_on_clean_workspace_no_drift_is_ok() {
348
- // 无 schema layout drift (空/无 db) → DoctorStatus::Ok.
349
- // schema_diagnosis(missing db) → layout_diffs 空 → 非 HasBlockers(SchemaLayoutDrift).
350
- // NOTE (gate w59ds828k): clean→Ok cannot distinguish "gates ran & passed" from "gates not
351
- // wired" because step 11/12 gate entities live elsewhere. The positive drift test below
352
- // (doctor_drifted_db_emits_schema_layout_drift_blocker) is what proves doctor() actually
353
- // READS schema_diagnosis and emits the typed SchemaLayoutDrift blocker on real drift.
354
- let dir = std::env::temp_dir().join(format!("ta-doctor-clean-{}", std::process::id()));
355
- let _ = std::fs::create_dir_all(&dir);
356
- let opts = doctor_opts(&dir);
357
- let status = doctor(&opts).expect("clean workspace doctor should succeed");
358
- assert_eq!(status, DoctorStatus::Ok);
359
- }
360
-
361
- #[test]
362
- fn doctor_comms_gate_failure_maps_to_typed_blocker() {
363
- let dir = std::env::temp_dir().join(format!("ta-doctor-comms-{}", std::process::id()));
364
- let _ = std::fs::create_dir_all(&dir);
365
- let mut opts = doctor_opts(&dir);
366
- opts.gate = Some(DoctorGate::Comms);
367
- let status = doctor(&opts).expect("comms gate should return typed blockers");
368
- match status {
369
- DoctorStatus::HasBlockers { blockers } => {
370
- let blocker = blockers
371
- .iter()
372
- .find(|blocker| blocker.source == BlockerSource::CommsGate)
373
- .expect("must surface CommsGate blocker");
374
- assert!(
375
- blocker.detail.contains("receiver_binding"),
376
- "blocker detail must name failing check: {}",
377
- blocker.detail
378
- );
379
- }
380
- DoctorStatus::Ok => panic!("missing receiver binding must not report Ok"),
381
- }
382
- }
383
-
384
- #[test]
385
- fn doctor_drifted_db_emits_schema_layout_drift_blocker() {
386
- // STRENGTHENED (gate w59ds828k): the ONLY drift assertion previously
387
- // (doctor_status_has_blockers_carries_typed_source) was a pure serde test that hand-built
388
- // the Blocker — it never proved doctor() EMITS SchemaLayoutDrift from a real drifted db.
389
- // This drives real doctor() on a SEEDED drifted team.db and pins the CONCRETE golden:
390
- // commands.py:242-250 → schema layout drift → coordinator.schema_error ==
391
- // "team.db physical layout drift detected" (EXACT string, commands.py:248).
392
- let ws = seed_workspace_with_drifted_db("blocker");
393
- let opts = doctor_opts(&ws);
394
- let status =
395
- doctor(&opts).expect("doctor on drifted workspace should succeed (returns blockers)");
396
- match status {
397
- DoctorStatus::HasBlockers { blockers } => {
398
- let drift = blockers
399
- .iter()
400
- .find(|b| b.source == BlockerSource::SchemaLayoutDrift)
401
- .expect("must surface a SchemaLayoutDrift blocker");
402
- // EXACT golden string from commands.py:248.
403
- assert_eq!(
404
- drift.detail, "team.db physical layout drift detected",
405
- "schema_error golden must match commands.py:248 verbatim"
406
- );
407
- }
408
- DoctorStatus::Ok => panic!("drifted team.db must NOT report Ok — layout_diffs non-empty"),
409
- }
410
- }
411
-
412
- #[test]
413
- fn doctor_status_ok_serializes_with_status_tag() {
414
- // #[serde(tag = "status")] — Ok → {"status":"ok"}.
415
- let json = serde_json::to_string(&DoctorStatus::Ok).unwrap();
416
- assert_eq!(json, "{\"status\":\"ok\"}");
417
- }
418
-
419
- #[test]
420
- fn doctor_status_has_blockers_carries_typed_source() {
421
- // HasBlockers serde:tag status=has_blockers + blockers[].source snake_case.
422
- let status = DoctorStatus::HasBlockers {
423
- blockers: vec![Blocker {
424
- source: BlockerSource::SchemaLayoutDrift,
425
- detail: "team.db physical layout drift detected".to_string(),
426
- }],
427
- };
428
- let json = serde_json::to_string(&status).unwrap();
429
- assert!(json.contains("\"status\":\"has_blockers\""), "got: {json}");
430
- assert!(
431
- json.contains("\"source\":\"schema_layout_drift\""),
432
- "got: {json}"
433
- );
434
- // detail 精确 == commands.py:248 schema_error 文本.
435
- assert!(
436
- json.contains("team.db physical layout drift detected"),
437
- "got: {json}"
438
- );
439
- }
440
-
441
- #[test]
442
- fn blocker_source_serde_exact_snake_case_strings() {
443
- // §19 穷尽 enum 序列化 == Python 散字符串等价 (逐 variant 钉).
444
- let cases: &[(BlockerSource, &str)] = &[
445
- (BlockerSource::SchemaLayoutDrift, "\"schema_layout_drift\""),
446
- (BlockerSource::OrphanCoordinator, "\"orphan_coordinator\""),
447
- (BlockerSource::CommsGate, "\"comms_gate\""),
448
- (BlockerSource::PathNotConfigured, "\"path_not_configured\""),
449
- ];
450
- for (src, want) in cases {
451
- assert_eq!(&serde_json::to_string(src).unwrap(), want);
452
- }
453
- }
454
-
455
- // ───────────────────────────────────────────────────────────────────────
456
- // repair_schema — 转调 step 3 fix_schema_layout(workspace, SCHEMA_VERSION=3)。
457
- // (commands.py:239-240 doctor --fix-schema)。
458
- // 决策:
459
- // - db 不存在 → Missing → 无 drift → UpToDate (转调外壳)。
460
- // - 撞活跃锁 → Blocked{reason:"active_lock"} 且不写备份。
461
- // 破坏性 rebuild 真路径 #[ignore](需真 db fixture / 真机)。
462
- // ───────────────────────────────────────────────────────────────────────
463
-
464
- #[test]
465
- fn repair_schema_missing_db_is_up_to_date() {
466
- // db 不存在 (.team/runtime/team.db) → fix_schema_layout 返 Missing →
467
- // packaging 包成 UpToDate (无 drift 需迁移)。
468
- let dir = std::env::temp_dir().join(format!("ta-repair-missing-{}", std::process::id()));
469
- let _ = std::fs::create_dir_all(&dir);
470
- let outcome = repair_schema(&dir).expect("missing db repair should succeed");
471
- match outcome {
472
- MigrationOutcome::UpToDate { diagnosis } => {
473
- // schema_diagnosis(missing) → ok=true, layout_diffs 空.
474
- assert!(diagnosis.layout_diffs.is_empty(), "missing db has no drift");
475
- }
476
- other => panic!("expected UpToDate for missing db, got {other:?}"),
477
- }
478
- }
479
-
480
- #[test]
481
- #[ignore = "REAL-MACHINE-E2E: needs real drifted team.db fixture + destructive rebuild"]
482
- fn repair_schema_drifted_db_migrates() {
483
- // 真 drift fixture → Migrated{fix: FixResult::Fixed{rebuilds non-empty}}.
484
- let ws = PathBuf::from("/nonexistent-fixture");
485
- let outcome = repair_schema(&ws).expect("drift repair");
486
- assert!(matches!(outcome, MigrationOutcome::Migrated { .. }));
487
- }
488
-
489
- #[test]
490
- #[ignore = "REAL-MACHINE-E2E: needs a held active lock on team.db (concurrent BEGIN IMMEDIATE)"]
491
- fn repair_schema_active_lock_is_blocked_no_backup() {
492
- // 撞活跃锁 → Blocked{reason:"active_lock"};且不写备份 (db/migration.rs:db_lock_status).
493
- let ws = PathBuf::from("/nonexistent-locked-fixture");
494
- let outcome = repair_schema(&ws).expect("blocked repair returns Ok wrapper");
495
- match outcome {
496
- MigrationOutcome::Blocked { reason } => assert_eq!(reason, "active_lock"),
497
- other => panic!("expected Blocked, got {other:?}"),
498
- }
499
- }
500
-
501
- // ───────────────────────────────────────────────────────────────────────
502
- // diagnose_path — bincheck.mjs printMissingBinDiagnostic 等价 (typed PathDiagnostic)。
503
- // bin 在 PATH → OnPath;不在 → NotOnPath{diagnostic}。Rust 无 npm → npmrc_prefix=None。
504
- // 纯逻辑可单测 (真探 PATH 部分 #[ignore])。
505
- // ───────────────────────────────────────────────────────────────────────
506
-
507
- #[test]
508
- fn diagnose_path_when_bin_on_path_reports_on_path() {
509
- // bin_dir 在当前 PATH → install report 的 path_hint 是 OnPath{bin_dir}。
510
- let path_var = std::env::var("PATH").unwrap_or_default();
511
- let bin = path_var
512
- .split(':')
513
- .filter(|p| !p.is_empty())
514
- .map(PathBuf::from)
515
- .find(|p| p.ends_with("bin"))
516
- .expect("PATH has at least one .../bin entry");
517
- let mut opts = install_opts(SkillTarget::Codex);
518
- opts.prefix = Prefix(bin.parent().expect("bin dir has parent").to_path_buf());
519
- let hint = install(&opts)
520
- .expect("install reports on-path bin")
521
- .path_hint;
522
- match hint {
523
- PathHint::OnPath { bin_dir } => assert_eq!(bin_dir, bin),
524
- PathHint::NotOnPath { .. } => panic!("PATH entry should report OnPath"),
525
- }
526
- }
527
-
528
- #[test]
529
- fn diagnose_path_not_on_path_npmrc_prefix_is_none_no_npm() {
530
- // Rust 版无 npm 路径 → npmrc_prefix == None (skeleton:257).
531
- // 用一个绝不在 PATH 的安装前缀,经当前公开 install 路径取得诊断。
532
- let prefix = PathBuf::from("/zzz-definitely-not-on-path-9f3a");
533
- let bin = prefix.join("bin");
534
- let mut opts = install_opts(SkillTarget::Codex);
535
- opts.prefix = Prefix(prefix);
536
- let hint = install(&opts)
537
- .expect("install reports off-path bin")
538
- .path_hint;
539
- match hint {
540
- PathHint::NotOnPath {
541
- bin_dir,
542
- diagnostic,
543
- } => {
544
- assert_eq!(bin_dir, bin);
545
- // Rust 无 npm → 绝不重新引入 .npmrc 解析.
546
- assert_eq!(diagnostic.npmrc_prefix, None);
547
- // path_entries == 当前 PATH 条目数 (bincheck.mjs:43).
548
- let want = std::env::var("PATH")
549
- .unwrap_or_default()
550
- .split(':')
551
- .filter(|p| !p.is_empty())
552
- .count();
553
- assert_eq!(diagnostic.path_entries, want);
554
- }
555
- PathHint::OnPath { .. } => panic!("bogus dir must be NotOnPath"),
556
- }
557
- }
558
-
559
- #[test]
560
- fn path_hint_serde_tag_kind() {
561
- // #[serde(tag = "kind")] — OnPath → {"kind":"on_path",...}.
562
- let h = PathHint::OnPath {
563
- bin_dir: PathBuf::from("/home/u/.local/bin"),
564
- };
565
- let json = serde_json::to_string(&h).unwrap();
566
- assert!(json.contains("\"kind\":\"on_path\""), "got: {json}");
567
- }
568
-
569
- // ───────────────────────────────────────────────────────────────────────
570
- // install_skill — cmd_install_skill (commands.py:451-481)。
571
- // error 路径 + 精确消息:
572
- // - --dest + --target all → InvalidOptions("--dest cannot be combined with --target all")
573
- // (commands.py:453-454)
574
- // dry-run 决策 (无副作用,可单测):
575
- // - dry_run=true → SkillInstallOutcome{dry_run:true, removed_stale:[]} 不落地.
576
- // 真拷 / removed_stale #[ignore] (文件系统副作用)。
577
- // ───────────────────────────────────────────────────────────────────────
578
-
579
- fn skill_opts(target: SkillTarget, dest: Option<PathBuf>, dry_run: bool) -> SkillInstallOptions {
580
- SkillInstallOptions {
581
- target,
582
- dest,
583
- dry_run,
584
- source: PathBuf::from("/repo/skills/team-agent"),
585
- }
586
- }
587
-
588
- #[test]
589
- fn install_skill_dest_with_target_all_is_invalid() {
590
- // commands.py:453-454 — `--dest cannot be combined with --target all`.
591
- let opts = skill_opts(SkillTarget::All, Some(PathBuf::from("/custom/dest")), false);
592
- let err = install_skill(&opts).expect_err("dest + all must error");
593
- match err {
594
- PackagingError::InvalidOptions(msg) => assert!(
595
- msg.contains("--dest cannot be combined with --target all"),
596
- "got: {msg}"
597
- ),
598
- other => panic!("expected InvalidOptions, got {other:?}"),
599
- }
600
- }
601
-
602
- #[test]
603
- fn install_skill_dry_run_single_target_reports_plan_no_side_effects() {
604
- // commands.py:477-478 dry_run → {ok, source, dest, dry_run:true} 不落地.
605
- let opts = skill_opts(SkillTarget::Codex, None, true);
606
- let outcomes = install_skill(&opts).expect("dry-run install-skill");
607
- assert_eq!(outcomes.len(), 1, "single target → 1 outcome");
608
- let o = &outcomes[0];
609
- assert_eq!(o.target, SkillTarget::Codex);
610
- assert!(o.dry_run, "dry_run flag preserved");
611
- // dry-run 绝不清理残留 (无副作用).
612
- assert!(o.removed_stale.is_empty(), "dry-run touches nothing");
613
- // dest == codex skill dir (HOME 依赖,用 dirs 解析;只断后缀稳定部分).
614
- assert!(
615
- o.dest
616
- .0
617
- .ends_with(PathBuf::from(".codex/skills/team-agent")),
618
- "got: {:?}",
619
- o.dest
620
- );
621
- }
622
-
623
- #[test]
624
- fn install_skill_dry_run_target_all_fans_out_to_all_providers() {
625
- // E9: target all → 表驱动 fan-out 全 provider (codex + claude + copilot),顺序固定.
626
- let opts = skill_opts(SkillTarget::All, None, true);
627
- let outcomes = install_skill(&opts).expect("dry-run install-skill all");
628
- assert_eq!(outcomes.len(), 3, "all → fan-out codex+claude+copilot");
629
- // KEY ORDER:SINGLE_TARGETS 顺序 codex, claude, copilot.
630
- assert_eq!(outcomes[0].target, SkillTarget::Codex);
631
- assert_eq!(outcomes[1].target, SkillTarget::Claude);
632
- assert_eq!(outcomes[2].target, SkillTarget::Copilot);
633
- assert!(outcomes.iter().all(|o| o.dry_run));
634
- }
635
-
636
- #[test]
637
- fn install_skill_dry_run_explicit_dest_single_target() {
638
- // commands.py:455-457 — --dest 显式目录,覆盖 target 路径解析,单 outcome.
639
- let dest = PathBuf::from("/custom/skills/team-agent");
640
- let opts = skill_opts(SkillTarget::Codex, Some(dest.clone()), true);
641
- let outcomes = install_skill(&opts).expect("dry-run explicit dest");
642
- assert_eq!(outcomes.len(), 1);
643
- assert_eq!(outcomes[0].dest, SkillDestDir(dest));
644
- assert!(outcomes[0].dry_run);
645
- }
646
-
647
- #[test]
648
- #[ignore = "REAL-MACHINE-E2E: real copytree + stale diff removal (fixes dirs_exist_ok=True residue)"]
649
- fn install_skill_real_copy_removes_stale_files() {
650
- // 修 commands.py:480 dirs_exist_ok 残留:Rust 拷前清旧 SKILL,记录 removed_stale.
651
- let opts = skill_opts(
652
- SkillTarget::Codex,
653
- Some(PathBuf::from("/tmp/ta-skill-real")),
654
- false,
655
- );
656
- let outcomes = install_skill(&opts).expect("real install-skill");
657
- assert!(!outcomes[0].dry_run);
658
- // 真路径下若有旧残留,removed_stale 非空 (具体值依 fixture).
659
- }
660
-
661
- // ───────────────────────────────────────────────────────────────────────
662
- // install — install.mjs:48-95。
663
- // - install 首装:InstallReport.replace == None (无二进制替换).
664
- // - installer 默认 skill_target = All (install.mjs:74 `--target all`).
665
- // 全副作用 #[ignore] (写 bin / 拷 skill / 探 PATH / 跑 doctor) — clean-install E2E.
666
- // ───────────────────────────────────────────────────────────────────────
667
-
668
- fn install_opts(skill_target: SkillTarget) -> InstallOptions {
669
- InstallOptions {
670
- prefix: Prefix(PathBuf::from("/home/u/.local")),
671
- self_binary: PathBuf::from("/proc/self/exe"),
672
- skill_target,
673
- }
674
- }
675
-
676
- #[test]
677
- #[ignore = "REAL-MACHINE-E2E: clean-install writes bin + copies skill + runs doctor + probes PATH"]
678
- fn install_first_time_has_no_binary_replace() {
679
- // install.mjs:48 install 入口 — 首装无 replace.
680
- let opts = install_opts(SkillTarget::All);
681
- let report = install(&opts).expect("clean install");
682
- assert!(report.replace.is_none(), "first install must NOT replace");
683
- // installer 默认装两个 skill (--target all).
684
- assert_eq!(report.skills.len(), 2);
685
- // 版本 == 单一真相源.
686
- assert_eq!(report.version, Version::current());
687
- }
688
-
689
- #[test]
690
- fn atomic_replace_outcome_serde_tag_outcome() {
691
- // #[serde(tag = "outcome")] — RolledBack carries restored_from + error.
692
- let o = AtomicReplaceOutcome::RolledBack {
693
- restored_from: PathBuf::from("/home/u/.local/bin/.previous"),
694
- error: "EXDEV".to_string(),
695
- };
696
- let json = serde_json::to_string(&o).unwrap();
697
- assert!(json.contains("\"outcome\":\"rolled_back\""), "got: {json}");
698
- assert!(json.contains("\"error\":\"EXDEV\""), "got: {json}");
699
- }
700
-
701
- // ───────────────────────────────────────────────────────────────────────
702
- // §84 — packaging 绝不触发 provider client / prompt / token.
703
- // install_skill 只拷文件 (provider 调用计数 = 0)。此处以「无 provider 依赖」
704
- // 的结构性断言代替运行时计数:dry-run install-skill 不应需要任何 provider opts。
705
- // (真 mock-provider-call-count==0 断言归集成层,这里钉 dry-run 不读 provider.)
706
- // ───────────────────────────────────────────────────────────────────────
707
-
708
- #[test]
709
- #[serial_test::serial(env)]
710
- fn install_skill_dry_run_is_pure_no_provider_state() {
711
- // §84:install-skill 只拷文件;dry-run 连文件都不动 → 纯函数式可重复.
712
- //
713
- // 0.5.43 debt-sweep (§6.2): even dry-run reads ambient HOME to
714
- // build the target skill path. Parallel real-copy sibling tests
715
- // hold the same `ENV_LOCK_PKG` + `HomeGuard::set` guards; without
716
- // matching guards here, two dry-run runs can observe HOME after
717
- // a real-copy test swapped it, producing spurious diffs. Same
718
- // env critical section as the other HOME-mutating install tests.
719
- let _g = ENV_LOCK_PKG.lock().unwrap_or_else(|p| p.into_inner());
720
- let home = std::env::temp_dir().join(format!(
721
- "ta-0543-pkg-dry-{}-{}",
722
- std::process::id(),
723
- line!()
724
- ));
725
- let _ = std::fs::remove_dir_all(&home);
726
- std::fs::create_dir_all(&home).expect("create dry-run HOME");
727
- let _h = HomeGuard::set(&home);
728
- let opts = skill_opts(SkillTarget::Claude, None, true);
729
- let first = install_skill(&opts).expect("dry-run 1");
730
- let second = install_skill(&opts).expect("dry-run 2");
731
- assert_eq!(
732
- first, second,
733
- "dry-run install-skill must be deterministic & side-effect free"
734
- );
735
- let _ = std::fs::remove_dir_all(&home);
736
- }
737
-
738
- // ───────────────────────────────────────────────────────────────────────
739
- // CRLF / platform — wrapper 内容在 Python 是 sh wrapper (LF)。Rust 单二进制
740
- // 后无 sh wrapper;但 PATH 诊断的 path_entries 分隔在 Windows 用 ';'。
741
- // 此处钉 diagnose_path 在空 PATH 时 path_entries==0 (bincheck.mjs:43 三元)。
742
- // ───────────────────────────────────────────────────────────────────────
743
-
744
- #[test]
745
- #[ignore = "REAL-MACHINE-E2E: needs to override process PATH env to empty/Windows-delimited"]
746
- fn diagnose_path_empty_path_has_zero_entries() {
747
- // bincheck.mjs:43 — searchPath ? split.length : 0;空 PATH → 0 entries.
748
- // (真改 process env PATH 影响并行测试,故 ignore;实现层应支持注入 PATH.)
749
- let mut opts = install_opts(SkillTarget::Codex);
750
- opts.prefix = Prefix(PathBuf::from("/anything"));
751
- let hint = install(&opts)
752
- .expect("install reports empty PATH")
753
- .path_hint;
754
- if let PathHint::NotOnPath { diagnostic, .. } = hint {
755
- assert_eq!(diagnostic.path_entries, 0);
756
- } else {
757
- panic!("empty PATH → NotOnPath");
758
- }
759
- }
760
-
761
- // ═══════════════ P2 FIX-LOOP RED (复绿即对抗 cross-model findings) ═══════════════
762
-
763
- static ENV_LOCK_PKG: std::sync::Mutex<()> = std::sync::Mutex::new(());
764
- struct HomeGuard {
765
- prev: Option<String>,
766
- }
767
- impl HomeGuard {
768
- fn set(home: &Path) -> Self {
769
- let prev = std::env::var("HOME").ok();
770
- std::env::set_var("HOME", home);
771
- Self { prev }
772
- }
773
- }
774
- impl Drop for HomeGuard {
775
- fn drop(&mut self) {
776
- match &self.prev {
777
- Some(v) => std::env::set_var("HOME", v),
778
- None => std::env::remove_var("HOME"),
779
- }
780
- }
781
- }
782
-
783
- // E9 — install-skill --target all (real copy) must land team-agent SKILL.md in ALL THREE
784
- // provider locations (~/.codex|.claude|.copilot/skills/team-agent) and the copied bytes must
785
- // equal the source. This is the "三 provider 位置断言(install 后文件存在且=源)" gate.
786
- #[test]
787
- #[serial_test::serial(env)]
788
- fn install_skill_all_real_copies_to_three_provider_locations() {
789
- let _g = ENV_LOCK_PKG.lock().unwrap_or_else(|p| p.into_inner());
790
- let base = std::env::temp_dir().join(format!("ta-e9-skill-all-{}", std::process::id()));
791
- let home = base.join("home");
792
- std::fs::create_dir_all(&home).unwrap();
793
- // Build a real skill source tree with a recognizable SKILL.md.
794
- let source = base.join("src-skill");
795
- std::fs::create_dir_all(&source).unwrap();
796
- let body = b"---\nname: team-agent\n---\nE9 source marker\n";
797
- std::fs::write(source.join("SKILL.md"), body).unwrap();
798
- let _h = HomeGuard::set(&home);
799
-
800
- let opts = SkillInstallOptions {
801
- target: SkillTarget::All,
802
- dest: None,
803
- dry_run: false,
804
- source: source.clone(),
805
- };
806
- let outcomes = install_skill(&opts).expect("real install-skill all");
807
- assert_eq!(outcomes.len(), 3, "all → codex+claude+copilot");
808
-
809
- for sub in [".codex", ".claude", ".copilot"] {
810
- let dest = home
811
- .join(sub)
812
- .join("skills")
813
- .join("team-agent")
814
- .join("SKILL.md");
815
- assert!(dest.exists(), "{sub}: SKILL.md must exist after install");
816
- assert_eq!(
817
- std::fs::read(&dest).unwrap(),
818
- body,
819
- "{sub}: installed SKILL.md bytes must equal source"
820
- );
821
- }
822
- }