Skip to content

Commit 90a7e69

Browse files
committed
Fix compliance scripts for src layout compatibility
1 parent 9914d85 commit 90a7e69

7 files changed

Lines changed: 227 additions & 57 deletions

tools/compliance/Check-UiCoreAdapterContracts.ps1

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,31 @@ function Add-Finding {
1717
Rule = $Rule
1818
File = $File
1919
Message = $Message
20-
})
20+
})
21+
}
22+
23+
function Resolve-RepoPath {
24+
param([string]$RelativePath)
25+
26+
$candidates = [System.Collections.Generic.List[string]]::new()
27+
$candidates.Add($RelativePath)
28+
29+
if ($RelativePath -match '^src[\\/](.+)$') {
30+
$candidates.Add("lib/McpServer/src/$($matches[1])")
31+
}
32+
33+
if ($RelativePath -match '^lib[\\/]McpServer[\\/]src[\\/](.+)$') {
34+
$candidates.Add("src/$($matches[1])")
35+
}
36+
37+
foreach ($candidate in $candidates | Select-Object -Unique) {
38+
$path = Join-Path $RepoRoot $candidate
39+
if (Test-Path -LiteralPath $path) {
40+
return $path
41+
}
42+
}
43+
44+
return Join-Path $RepoRoot $RelativePath
2145
}
2246

2347
function Assert-ContainsPattern {
@@ -28,7 +52,7 @@ function Assert-ContainsPattern {
2852
[string]$MissingMessage
2953
)
3054

31-
$fullPath = Join-Path $RepoRoot $RelativePath
55+
$fullPath = Resolve-RepoPath $RelativePath
3256
if (-not (Test-Path -LiteralPath $fullPath)) {
3357
Add-Finding -Rule $Rule -File $RelativePath -Message "Required file not found."
3458
return
@@ -43,37 +67,37 @@ function Assert-ContainsPattern {
4367
$adapterContracts = @(
4468
@{
4569
Rule = "ADP001"
46-
File = "lib/McpServer/src/McpServer.Director/TodoApiClientAdapter.cs"
70+
File = "src/McpServer.Director/TodoApiClientAdapter.cs"
4771
Pattern = "class\s+TodoApiClientAdapter\s*:\s*ITodoApiClient\b"
4872
Message = "Director TODO adapter must implement ITodoApiClient."
4973
},
5074
@{
5175
Rule = "ADP002"
52-
File = "lib/McpServer/src/McpServer.Director/WorkspaceApiClientAdapter.cs"
76+
File = "src/McpServer.Director/WorkspaceApiClientAdapter.cs"
5377
Pattern = "class\s+WorkspaceApiClientAdapter\s*:\s*IWorkspaceApiClient\b"
5478
Message = "Director workspace adapter must implement IWorkspaceApiClient."
5579
},
5680
@{
5781
Rule = "ADP003"
58-
File = "lib/McpServer/src/McpServer.Director/SessionLogApiClientAdapter.cs"
82+
File = "src/McpServer.Director/SessionLogApiClientAdapter.cs"
5983
Pattern = "class\s+SessionLogApiClientAdapter\s*:\s*ISessionLogApiClient\b"
6084
Message = "Director session log adapter must implement ISessionLogApiClient."
6185
},
6286
@{
6387
Rule = "ADP004"
64-
File = "lib/McpServer/src/McpServer.Web/Adapters/TodoApiClientAdapter.cs"
88+
File = "src/McpServer.Web/Adapters/TodoApiClientAdapter.cs"
6589
Pattern = "class\s+TodoApiClientAdapter\s*:\s*ITodoApiClient\b"
6690
Message = "Web TODO adapter must implement ITodoApiClient."
6791
},
6892
@{
6993
Rule = "ADP005"
70-
File = "lib/McpServer/src/McpServer.Web/Adapters/WorkspaceApiClientAdapter.cs"
94+
File = "src/McpServer.Web/Adapters/WorkspaceApiClientAdapter.cs"
7195
Pattern = "class\s+WorkspaceApiClientAdapter\s*:\s*IWorkspaceApiClient\b"
7296
Message = "Web workspace adapter must implement IWorkspaceApiClient."
7397
},
7498
@{
7599
Rule = "ADP006"
76-
File = "lib/McpServer/src/McpServer.Web/Adapters/SessionLogApiClientAdapter.cs"
100+
File = "src/McpServer.Web/Adapters/SessionLogApiClientAdapter.cs"
77101
Pattern = "class\s+SessionLogApiClientAdapter\s*:\s*ISessionLogApiClient\b"
78102
Message = "Web session log adapter must implement ISessionLogApiClient."
79103
}
@@ -90,37 +114,37 @@ foreach ($contract in $adapterContracts) {
90114
$registrationChecks = @(
91115
@{
92116
Rule = "ADP101"
93-
File = "lib/McpServer/src/McpServer.Director/DirectorServiceRegistration.cs"
117+
File = "src/McpServer.Director/DirectorServiceRegistration.cs"
94118
Pattern = "AddSingleton<ITodoApiClient>\s*\(_\s*=>\s*new\s+TodoApiClientAdapter\("
95119
Message = "Director service registration must wire ITodoApiClient to TodoApiClientAdapter."
96120
},
97121
@{
98122
Rule = "ADP102"
99-
File = "lib/McpServer/src/McpServer.Director/DirectorServiceRegistration.cs"
123+
File = "src/McpServer.Director/DirectorServiceRegistration.cs"
100124
Pattern = "AddSingleton<IWorkspaceApiClient>\s*\(_\s*=>\s*new\s+WorkspaceApiClientAdapter\("
101125
Message = "Director service registration must wire IWorkspaceApiClient to WorkspaceApiClientAdapter."
102126
},
103127
@{
104128
Rule = "ADP103"
105-
File = "lib/McpServer/src/McpServer.Director/DirectorServiceRegistration.cs"
129+
File = "src/McpServer.Director/DirectorServiceRegistration.cs"
106130
Pattern = "AddSingleton<ISessionLogApiClient>\s*\(_\s*=>\s*new\s+SessionLogApiClientAdapter\("
107131
Message = "Director service registration must wire ISessionLogApiClient to SessionLogApiClientAdapter."
108132
},
109133
@{
110134
Rule = "ADP104"
111-
File = "lib/McpServer/src/McpServer.Web/WebServiceRegistration.cs"
135+
File = "src/McpServer.Web/WebServiceRegistration.cs"
112136
Pattern = "AddScoped<ITodoApiClient,\s*TodoApiClientAdapter>\s*\(\s*\)"
113137
Message = "Web service registration must wire ITodoApiClient to TodoApiClientAdapter."
114138
},
115139
@{
116140
Rule = "ADP105"
117-
File = "lib/McpServer/src/McpServer.Web/WebServiceRegistration.cs"
141+
File = "src/McpServer.Web/WebServiceRegistration.cs"
118142
Pattern = "AddScoped<IWorkspaceApiClient,\s*WorkspaceApiClientAdapter>\s*\(\s*\)"
119143
Message = "Web service registration must wire IWorkspaceApiClient to WorkspaceApiClientAdapter."
120144
},
121145
@{
122146
Rule = "ADP106"
123-
File = "lib/McpServer/src/McpServer.Web/WebServiceRegistration.cs"
147+
File = "src/McpServer.Web/WebServiceRegistration.cs"
124148
Pattern = "AddScoped<ISessionLogApiClient,\s*SessionLogApiClientAdapter>\s*\(\s*\)"
125149
Message = "Web service registration must wire ISessionLogApiClient to SessionLogApiClientAdapter."
126150
}

tools/compliance/Check-UiCoreCompatibilityShims.ps1

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,31 @@ function Add-Finding {
1717
Rule = $Rule
1818
File = $File
1919
Message = $Message
20-
})
20+
})
21+
}
22+
23+
function Resolve-RepoPath {
24+
param([string]$RelativePath)
25+
26+
$candidates = [System.Collections.Generic.List[string]]::new()
27+
$candidates.Add($RelativePath)
28+
29+
if ($RelativePath -match '^src[\\/](.+)$') {
30+
$candidates.Add("lib/McpServer/src/$($matches[1])")
31+
}
32+
33+
if ($RelativePath -match '^lib[\\/]McpServer[\\/]src[\\/](.+)$') {
34+
$candidates.Add("src/$($matches[1])")
35+
}
36+
37+
foreach ($candidate in $candidates | Select-Object -Unique) {
38+
$path = Join-Path $RepoRoot $candidate
39+
if (Test-Path -LiteralPath $path) {
40+
return $path
41+
}
42+
}
43+
44+
return Join-Path $RepoRoot $RelativePath
2145
}
2246

2347
function Assert-ContainsPattern {
@@ -28,7 +52,7 @@ function Assert-ContainsPattern {
2852
[string]$MissingMessage
2953
)
3054

31-
$fullPath = Join-Path $RepoRoot $RelativePath
55+
$fullPath = Resolve-RepoPath $RelativePath
3256
if (-not (Test-Path -LiteralPath $fullPath)) {
3357
Add-Finding -Rule $Rule -File $RelativePath -Message "Required file not found."
3458
return
@@ -42,13 +66,13 @@ function Assert-ContainsPattern {
4266

4367
Assert-ContainsPattern `
4468
-Rule "SHM001" `
45-
-RelativePath "lib/McpServer/src/McpServer.UI.Core/Commands/CqrsRelayFactory.cs" `
69+
-RelativePath "src/McpServer.UI.Core/Commands/CqrsRelayFactory.cs" `
4670
-Pattern "Create<T>\(Dispatcher\s+dispatcher,\s*Action<T\?>\s+action,\s*Func<T\?,\s*bool>\?\s+canExecute\)" `
4771
-MissingMessage "UI.Core relay factory must expose a parameter-aware Action<T?> canExecute overload for legacy host call patterns."
4872

4973
Assert-ContainsPattern `
5074
-Rule "SHM002" `
51-
-RelativePath "lib/McpServer/src/McpServer.UI.Core/Commands/CqrsRelayFactory.cs" `
75+
-RelativePath "src/McpServer.UI.Core/Commands/CqrsRelayFactory.cs" `
5276
-Pattern "Create<T>\(Dispatcher\s+dispatcher,\s*Func<T\?,\s*Task>\s+action,\s*Func<T\?,\s*bool>\?\s+canExecute\)" `
5377
-MissingMessage "UI.Core relay factory must expose a parameter-aware Func<T?, Task> canExecute overload for compatibility."
5478

tools/compliance/Check-UiCoreHostIntegration.ps1

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,31 @@ function Add-Finding {
1717
Rule = $Rule
1818
File = $File
1919
Message = $Message
20-
})
20+
})
21+
}
22+
23+
function Resolve-RepoPath {
24+
param([string]$RelativePath)
25+
26+
$candidates = [System.Collections.Generic.List[string]]::new()
27+
$candidates.Add($RelativePath)
28+
29+
if ($RelativePath -match '^src[\\/](.+)$') {
30+
$candidates.Add("lib/McpServer/src/$($matches[1])")
31+
}
32+
33+
if ($RelativePath -match '^lib[\\/]McpServer[\\/]src[\\/](.+)$') {
34+
$candidates.Add("src/$($matches[1])")
35+
}
36+
37+
foreach ($candidate in $candidates | Select-Object -Unique) {
38+
$path = Join-Path $RepoRoot $candidate
39+
if (Test-Path -LiteralPath $path) {
40+
return $path
41+
}
42+
}
43+
44+
return Join-Path $RepoRoot $RelativePath
2145
}
2246

2347
function Assert-ContainsPattern {
@@ -28,7 +52,7 @@ function Assert-ContainsPattern {
2852
[string]$MissingMessage
2953
)
3054

31-
$fullPath = Join-Path $RepoRoot $RelativePath
55+
$fullPath = Resolve-RepoPath $RelativePath
3256
if (-not (Test-Path -LiteralPath $fullPath)) {
3357
Add-Finding -Rule $Rule -File $RelativePath -Message "Required file not found."
3458
return
@@ -43,56 +67,56 @@ function Assert-ContainsPattern {
4367
# Web composition root invariants
4468
Assert-ContainsPattern `
4569
-Rule "HIN001" `
46-
-RelativePath "lib/McpServer/src/McpServer.Web/WebServiceRegistration.cs" `
70+
-RelativePath "src/McpServer.Web/WebServiceRegistration.cs" `
4771
-Pattern "AddUiCore\(typeof\(WebServiceRegistration\)\.Assembly\)" `
4872
-MissingMessage "Web service registration must call AddUiCore(typeof(WebServiceRegistration).Assembly) for shared ViewModel/handler wiring."
4973

5074
Assert-ContainsPattern `
5175
-Rule "HIN002" `
52-
-RelativePath "lib/McpServer/src/McpServer.Web/WebServiceRegistration.cs" `
76+
-RelativePath "src/McpServer.Web/WebServiceRegistration.cs" `
5377
-Pattern "AddScoped<ITodoApiClient,\s*TodoApiClientAdapter>\s*\(\s*\)" `
5478
-MissingMessage "Web service registration must wire ITodoApiClient to TodoApiClientAdapter."
5579

5680
Assert-ContainsPattern `
5781
-Rule "HIN003" `
58-
-RelativePath "lib/McpServer/src/McpServer.Web/WebServiceRegistration.cs" `
82+
-RelativePath "src/McpServer.Web/WebServiceRegistration.cs" `
5983
-Pattern "AddScoped<IWorkspaceApiClient,\s*WorkspaceApiClientAdapter>\s*\(\s*\)" `
6084
-MissingMessage "Web service registration must wire IWorkspaceApiClient to WorkspaceApiClientAdapter."
6185

6286
Assert-ContainsPattern `
6387
-Rule "HIN004" `
64-
-RelativePath "lib/McpServer/src/McpServer.Web/WebServiceRegistration.cs" `
88+
-RelativePath "src/McpServer.Web/WebServiceRegistration.cs" `
6589
-Pattern "AddScoped<ISessionLogApiClient,\s*SessionLogApiClientAdapter>\s*\(\s*\)" `
6690
-MissingMessage "Web service registration must wire ISessionLogApiClient to SessionLogApiClientAdapter."
6791

6892
# Director composition root invariants
6993
Assert-ContainsPattern `
7094
-Rule "HIN101" `
71-
-RelativePath "lib/McpServer/src/McpServer.Director/DirectorServiceRegistration.cs" `
95+
-RelativePath "src/McpServer.Director/DirectorServiceRegistration.cs" `
7296
-Pattern "AddCqrs\(typeof\(Program\)\.Assembly\)" `
7397
-MissingMessage "Director DI registration must initialize CQRS pipeline from Program assembly."
7498

7599
Assert-ContainsPattern `
76100
-Rule "HIN102" `
77-
-RelativePath "lib/McpServer/src/McpServer.Director/DirectorServiceRegistration.cs" `
101+
-RelativePath "src/McpServer.Director/DirectorServiceRegistration.cs" `
78102
-Pattern "AddUiCore\(\)" `
79103
-MissingMessage "Director DI registration must wire shared UI.Core services."
80104

81105
Assert-ContainsPattern `
82106
-Rule "HIN103" `
83-
-RelativePath "lib/McpServer/src/McpServer.Director/DirectorServiceRegistration.cs" `
107+
-RelativePath "src/McpServer.Director/DirectorServiceRegistration.cs" `
84108
-Pattern "AddSingleton<ITodoApiClient>\s*\(_\s*=>\s*new\s+TodoApiClientAdapter\(" `
85109
-MissingMessage "Director DI registration must wire ITodoApiClient to TodoApiClientAdapter."
86110

87111
Assert-ContainsPattern `
88112
-Rule "HIN104" `
89-
-RelativePath "lib/McpServer/src/McpServer.Director/DirectorServiceRegistration.cs" `
113+
-RelativePath "src/McpServer.Director/DirectorServiceRegistration.cs" `
90114
-Pattern "AddSingleton<IWorkspaceApiClient>\s*\(_\s*=>\s*new\s+WorkspaceApiClientAdapter\(" `
91115
-MissingMessage "Director DI registration must wire IWorkspaceApiClient to WorkspaceApiClientAdapter."
92116

93117
Assert-ContainsPattern `
94118
-Rule "HIN105" `
95-
-RelativePath "lib/McpServer/src/McpServer.Director/DirectorServiceRegistration.cs" `
119+
-RelativePath "src/McpServer.Director/DirectorServiceRegistration.cs" `
96120
-Pattern "AddSingleton<ISessionLogApiClient>\s*\(_\s*=>\s*new\s+SessionLogApiClientAdapter\(" `
97121
-MissingMessage "Director DI registration must wire ISessionLogApiClient to SessionLogApiClientAdapter."
98122

tools/compliance/Check-UiCoreMigration.ps1

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,30 @@ function To-RelativePath {
2929
return [IO.Path]::GetRelativePath($RepoRoot, $Path).Replace("\", "/")
3030
}
3131

32+
function Resolve-RepoPath {
33+
param([string]$RelativePath)
34+
35+
$candidates = [System.Collections.Generic.List[string]]::new()
36+
$candidates.Add($RelativePath)
37+
38+
if ($RelativePath -match '^src[\\/](.+)$') {
39+
$candidates.Add("lib/McpServer/src/$($matches[1])")
40+
}
41+
42+
if ($RelativePath -match '^lib[\\/]McpServer[\\/]src[\\/](.+)$') {
43+
$candidates.Add("src/$($matches[1])")
44+
}
45+
46+
foreach ($candidate in $candidates | Select-Object -Unique) {
47+
$path = Join-Path $RepoRoot $candidate
48+
if (Test-Path -LiteralPath $path) {
49+
return $path
50+
}
51+
}
52+
53+
return Join-Path $RepoRoot $RelativePath
54+
}
55+
3256
function Assert-ProjectReference {
3357
param(
3458
[string]$Rule,
@@ -37,7 +61,7 @@ function Assert-ProjectReference {
3761
[string]$ProjectReferencePattern
3862
)
3963

40-
$projectPath = Join-Path $RepoRoot $ProjectRelativePath
64+
$projectPath = Resolve-RepoPath $ProjectRelativePath
4165
if (-not (Test-Path -LiteralPath $projectPath)) {
4266
Add-Finding -Rule $Rule -Description $Description -File $ProjectRelativePath -Line 1 -Text "Project file not found."
4367
return
@@ -54,19 +78,19 @@ $projectReferenceChecks = @(
5478
Rule = "UIM001"
5579
Description = "McpServerManager.Core must reference McpServer.UI.Core."
5680
ProjectRelativePath = "src/McpServerManager.Core/McpServerManager.Core.csproj"
57-
ProjectReferencePattern = "<ProjectReference\s+Include=""\.\.\\\.\.\\lib\\McpServer\\src\\McpServer\.UI\.Core\\McpServer\.UI\.Core\.csproj""\s*/?>"
81+
ProjectReferencePattern = "<ProjectReference\s+Include=""(?:\.\.\\){1,2}(?:lib\\McpServer\\src\\)?McpServer\.UI\.Core\\McpServer\.UI\.Core\.csproj""\s*/?>"
5882
},
5983
@{
6084
Rule = "UIM002"
6185
Description = "McpServer.Web must reference McpServer.UI.Core."
62-
ProjectRelativePath = "lib/McpServer/src/McpServer.Web/McpServer.Web.csproj"
63-
ProjectReferencePattern = "<ProjectReference\s+Include=""\.\.\\McpServer\.UI\.Core\\McpServer\.UI\.Core\.csproj""\s*/?>"
86+
ProjectRelativePath = "src/McpServer.Web/McpServer.Web.csproj"
87+
ProjectReferencePattern = "<ProjectReference\s+Include=""(?:\.\.\\){1,2}(?:lib\\McpServer\\src\\)?McpServer\.UI\.Core\\McpServer\.UI\.Core\.csproj""\s*/?>"
6488
},
6589
@{
6690
Rule = "UIM003"
6791
Description = "McpServer.Director must reference McpServer.UI.Core."
68-
ProjectRelativePath = "lib/McpServer/src/McpServer.Director/McpServer.Director.csproj"
69-
ProjectReferencePattern = "<ProjectReference\s+Include=""\.\.\\McpServer\.UI\.Core\\McpServer\.UI\.Core\.csproj""\s*/?>"
92+
ProjectRelativePath = "src/McpServer.Director/McpServer.Director.csproj"
93+
ProjectReferencePattern = "<ProjectReference\s+Include=""(?:\.\.\\){1,2}(?:lib\\McpServer\\src\\)?McpServer\.UI\.Core\\McpServer\.UI\.Core\.csproj""\s*/?>"
7094
}
7195
)
7296

@@ -145,17 +169,17 @@ $noViewModelZones = @(
145169
@{
146170
Rule = "UIM201"
147171
Description = "McpServer.Director must not declare local *ViewModel classes."
148-
RelativePath = "lib/McpServer/src/McpServer.Director"
172+
RelativePath = "src/McpServer.Director"
149173
},
150174
@{
151175
Rule = "UIM202"
152176
Description = "McpServer.Web must not declare local *ViewModel classes."
153-
RelativePath = "lib/McpServer/src/McpServer.Web"
177+
RelativePath = "src/McpServer.Web"
154178
}
155179
)
156180

157181
foreach ($zone in $noViewModelZones) {
158-
$zonePath = Join-Path $RepoRoot $zone.RelativePath
182+
$zonePath = Resolve-RepoPath $zone.RelativePath
159183
if (-not (Test-Path -LiteralPath $zonePath)) {
160184
Add-Finding -Rule $zone.Rule -Description $zone.Description -File $zone.RelativePath -Line 1 -Text "Directory not found."
161185
continue

0 commit comments

Comments
 (0)