Files
skills-win/tools-sync/tests/test_sync_mcp_registrations.ps1
Myfro9andClaude Opus 5 f665448376 sync: BOWEI 2026-09-07 tools-sync 改为 junction 模型(registry 双向 ingest + 修复)
- sync_repos.ps1: 每个 skill 只在 ~\.claude\skills 有一份物理副本,其余 registry
  一律 junction;新增 registry-only skill 的自动 ingest、MISDIRECTED 链接修复、
  同名内容分叉的 CONFLICT 报告,以及只对 -MirrorRegistry 做全量镜像。
- SKILL.md: 重写阶段 1/2,补 Codex MCP 存储模型(config.toml 惰性,
  codex mcp list --json 是唯一权威口径)与 CLI 升级会清空注册表的事实。
- sync_mcp_registrations.ps1 + references/codex_mcp_wanted_keys.json:
  报告 codex-cli 无接口可设的键(tool_timeout_sec / env_vars)为
  "registered, but incomplete" 而非失败。
- tests/test_sync_repos_registries.ps1: registry 对账的回归测试。
- .gitignore: orchestration(Orca 自带的发现桩,同 orca-cli)列为 local-only。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01438Zbcx49e4o46uSA71mFF
2026-09-07 16:22:09 +08:00

59 lines
2.6 KiB
PowerShell

$ErrorActionPreference = "Stop"
$scriptUnderTest = Join-Path (Split-Path $PSScriptRoot -Parent) "scripts\sync_mcp_registrations.ps1"
$testDir = Join-Path ([IO.Path]::GetTempPath()) ("tools-sync-mcp-test-" + [guid]::NewGuid().ToString("N"))
New-Item -ItemType Directory -Path $testDir | Out-Null
$claudeConfig = Join-Path $testDir "claude.json"
$codexConfig = Join-Path $testDir "config.toml"
try {
$claudeText = @'
{
"mcpServers": {
"claude-only": {"type":"stdio","command":"python","args":["a.py"],"env":{"A":"1"}},
"same": {"type":"stdio","command":"python","args":["same.py"],"env":{}},
"drifted": {"type":"stdio","command":"python","args":["claude.py"],"env":{}}
}
}
'@
[IO.File]::WriteAllText($claudeConfig, $claudeText, [Text.UTF8Encoding]::new($false))
$codexText = @'
[mcp_servers.codex-only]
command = "python"
args = ["b.py"]
[mcp_servers.same]
command = "python"
args = ["same.py"]
env = { PYTHONIOENCODING = "utf-8", PYTHONUTF8 = "1" }
[mcp_servers.drifted]
command = "python"
args = ["codex.py"]
[mcp_servers.node_repl]
command = "C:\\Users\\tester\\.codex\\runtimes\\node_repl.exe"
'@
[IO.File]::WriteAllText($codexConfig, $codexText, [Text.UTF8Encoding]::new($false))
$oldErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = "Continue"
# -CodexSource Toml pins the read to the fixture; the default Auto path would query the
# real `codex mcp list` and make this test measure the machine instead of the fixtures.
$output = & powershell -NoProfile -ExecutionPolicy Bypass -File $scriptUnderTest `
-ClaudeConfig $claudeConfig -CodexConfig $codexConfig -CodexSource Toml -Verbose 2>&1 | Out-String
$code = $LASTEXITCODE
$ErrorActionPreference = $oldErrorActionPreference
if ($code -ne 2) { throw "expected audit exit 2, got $code`n$output" }
if ($output -notmatch 'Claude only\s*:\s*claude-only') { throw "Claude-only difference not detected`n$output" }
if ($output -notmatch 'Codex only\s*:\s*codex-only') { throw "Codex-only difference not detected`n$output" }
if ($output -notmatch 'Drift\s*:\s*drifted') { throw "drift not detected`n$output" }
if ($output -notmatch 'Matched\s*:\s*same') { throw "Codex-only UTF-8 env should not cause drift`n$output" }
if ($output -match 'Codex only\s*:.*node_repl') { throw "managed Codex MCP was not excluded`n$output" }
Write-Host "PASS: bidirectional MCP audit fixtures"
} finally {
Remove-Item -LiteralPath $claudeConfig -Force -ErrorAction SilentlyContinue
Remove-Item -LiteralPath $codexConfig -Force -ErrorAction SilentlyContinue
Remove-Item -LiteralPath $testDir -Force -ErrorAction SilentlyContinue
}