@cratis/pi 7.102.0 → 7.103.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 (140) hide show
  1. package/package/corpus/harnesses/copilot/instructions/profiles.instructions.md +10 -1
  2. package/package/corpus/harnesses/copilot/instructions/pull-requests.instructions.md +2 -0
  3. package/package/corpus/harnesses/copilot/instructions/secrets.instructions.md +4 -0
  4. package/package/corpus/hooks/README.md +11 -1
  5. package/package/corpus/hooks/scripts/cratis-check-pr.mjs +12 -1
  6. package/package/corpus/hooks/scripts/cratis-guard-secrets.sh +79 -23
  7. package/package/corpus/hooks/scripts/cratis-guard-writes.sh +145 -40
  8. package/package/corpus/rules/profiles.md +10 -1
  9. package/package/corpus/rules/pull-requests.md +2 -0
  10. package/package/corpus/rules/secrets.md +4 -0
  11. package/package/corpus/skills/analyzing-dotnet-performance/LICENSE +23 -0
  12. package/package/corpus/skills/analyzing-dotnet-performance/NOTICE +36 -0
  13. package/package/corpus/skills/analyzing-dotnet-performance/SKILL.md +214 -0
  14. package/package/corpus/skills/analyzing-dotnet-performance/references/async-patterns.md +122 -0
  15. package/package/corpus/skills/analyzing-dotnet-performance/references/collections-and-linq.md +220 -0
  16. package/package/corpus/skills/analyzing-dotnet-performance/references/critical-patterns.md +291 -0
  17. package/package/corpus/skills/analyzing-dotnet-performance/references/io-and-serialization.md +135 -0
  18. package/package/corpus/skills/analyzing-dotnet-performance/references/memory-and-strings.md +219 -0
  19. package/package/corpus/skills/analyzing-dotnet-performance/references/regex-patterns.md +95 -0
  20. package/package/corpus/skills/analyzing-dotnet-performance/references/structural-patterns.md +38 -0
  21. package/package/corpus/skills/binlog-generation/LICENSE +23 -0
  22. package/package/corpus/skills/binlog-generation/NOTICE +22 -0
  23. package/package/corpus/skills/binlog-generation/SKILL.md +129 -0
  24. package/package/corpus/skills/check-bin-obj-clash/LICENSE +23 -0
  25. package/package/corpus/skills/check-bin-obj-clash/NOTICE +27 -0
  26. package/package/corpus/skills/check-bin-obj-clash/SKILL.md +127 -0
  27. package/package/corpus/skills/check-bin-obj-clash/references/common-causes-and-fixes.md +206 -0
  28. package/package/corpus/skills/coverage-analysis/LICENSE +23 -0
  29. package/package/corpus/skills/coverage-analysis/NOTICE +32 -0
  30. package/package/corpus/skills/coverage-analysis/SKILL.md +198 -0
  31. package/package/corpus/skills/coverage-analysis/references/guidelines.md +68 -0
  32. package/package/corpus/skills/coverage-analysis/references/output-format.md +91 -0
  33. package/package/corpus/skills/coverage-analysis/references/report-generation.md +58 -0
  34. package/package/corpus/skills/coverage-analysis/references/setup-discovery.md +307 -0
  35. package/package/corpus/skills/coverage-analysis/scripts/Compute-CrapScores.ps1 +80 -0
  36. package/package/corpus/skills/coverage-analysis/scripts/CoverageData.ps1 +272 -0
  37. package/package/corpus/skills/coverage-analysis/scripts/Extract-MethodCoverage.ps1 +65 -0
  38. package/package/corpus/skills/csharp-refactoring/LICENSE +23 -0
  39. package/package/corpus/skills/csharp-refactoring/NOTICE +22 -0
  40. package/package/corpus/skills/csharp-refactoring/SKILL.md +175 -0
  41. package/package/corpus/skills/csharp-refactoring/references/operation-catalog.md +37 -0
  42. package/package/corpus/skills/directory-build-organization/LICENSE +23 -0
  43. package/package/corpus/skills/directory-build-organization/NOTICE +21 -0
  44. package/package/corpus/skills/directory-build-organization/SKILL.md +205 -0
  45. package/package/corpus/skills/directory-build-organization/references/common-patterns.md +56 -0
  46. package/package/corpus/skills/directory-build-organization/references/multi-level-examples.md +167 -0
  47. package/package/corpus/skills/directory-build-organization/references/targetframework-props-pitfall.md +54 -0
  48. package/package/corpus/skills/dotnet-aot-compat/LICENSE +23 -0
  49. package/package/corpus/skills/dotnet-aot-compat/NOTICE +18 -0
  50. package/package/corpus/skills/dotnet-aot-compat/SKILL.md +265 -0
  51. package/package/corpus/skills/dotnet-aot-compat/references/polyfills.md +43 -0
  52. package/package/corpus/skills/dotnet-trace-collect/LICENSE +23 -0
  53. package/package/corpus/skills/dotnet-trace-collect/NOTICE +65 -0
  54. package/package/corpus/skills/dotnet-trace-collect/SKILL.md +116 -0
  55. package/package/corpus/skills/dotnet-trace-collect/references/dotnet-monitor.md +97 -0
  56. package/package/corpus/skills/dotnet-trace-collect/references/dotnet-trace-collect-linux.md +84 -0
  57. package/package/corpus/skills/dotnet-trace-collect/references/dotnet-trace-collect.md +91 -0
  58. package/package/corpus/skills/dotnet-trace-collect/references/perfcollect.md +200 -0
  59. package/package/corpus/skills/dotnet-trace-collect/references/perfview.md +141 -0
  60. package/package/corpus/skills/dotnet-trace-collect/references/tool-selection.md +160 -0
  61. package/package/corpus/skills/dump-collect/LICENSE +23 -0
  62. package/package/corpus/skills/dump-collect/NOTICE +40 -0
  63. package/package/corpus/skills/dump-collect/SKILL.md +97 -0
  64. package/package/corpus/skills/dump-collect/references/container-dumps.md +412 -0
  65. package/package/corpus/skills/dump-collect/references/coreclr-dumps.md +108 -0
  66. package/package/corpus/skills/dump-collect/references/nativeaot-dumps.md +280 -0
  67. package/package/corpus/skills/eliminate-redundant-restores/LICENSE +23 -0
  68. package/package/corpus/skills/eliminate-redundant-restores/NOTICE +19 -0
  69. package/package/corpus/skills/eliminate-redundant-restores/SKILL.md +112 -0
  70. package/package/corpus/skills/extension-points/LICENSE +23 -0
  71. package/package/corpus/skills/extension-points/NOTICE +18 -0
  72. package/package/corpus/skills/extension-points/SKILL.md +248 -0
  73. package/package/corpus/skills/filter-syntax/LICENSE +23 -0
  74. package/package/corpus/skills/filter-syntax/NOTICE +17 -0
  75. package/package/corpus/skills/filter-syntax/SKILL.md +179 -0
  76. package/package/corpus/skills/including-generated-files/LICENSE +23 -0
  77. package/package/corpus/skills/including-generated-files/NOTICE +17 -0
  78. package/package/corpus/skills/including-generated-files/SKILL.md +139 -0
  79. package/package/corpus/skills/microbenchmarking/LICENSE +23 -0
  80. package/package/corpus/skills/microbenchmarking/NOTICE +36 -0
  81. package/package/corpus/skills/microbenchmarking/SKILL.md +131 -0
  82. package/package/corpus/skills/microbenchmarking/references/bdn-internals-and-tuning.md +143 -0
  83. package/package/corpus/skills/microbenchmarking/references/comparison-strategies.md +200 -0
  84. package/package/corpus/skills/microbenchmarking/references/diagnosers-and-exporters.md +150 -0
  85. package/package/corpus/skills/microbenchmarking/references/project-setup-and-running.md +189 -0
  86. package/package/corpus/skills/microbenchmarking/references/writing-benchmarks.md +310 -0
  87. package/package/corpus/skills/msbuild/LICENSE +23 -0
  88. package/package/corpus/skills/msbuild/NOTICE +55 -0
  89. package/package/corpus/skills/msbuild/SKILL.md +117 -0
  90. package/package/corpus/skills/msbuild/references/antipatterns/additional-antipatterns.md +291 -0
  91. package/package/corpus/skills/msbuild/references/antipatterns/incremental-build-inputs-outputs.md +57 -0
  92. package/package/corpus/skills/msbuild/references/antipatterns/private-assets.md +29 -0
  93. package/package/corpus/skills/msbuild/references/binlog-failure-analysis.md +85 -0
  94. package/package/corpus/skills/msbuild/references/binlog-generation.md +69 -0
  95. package/package/corpus/skills/msbuild/references/build-perf-baseline.md +493 -0
  96. package/package/corpus/skills/msbuild/references/build-perf-diagnostics.md +268 -0
  97. package/package/corpus/skills/msbuild/references/copy-to-output-directory.md +183 -0
  98. package/package/corpus/skills/msbuild/references/eval-performance.md +190 -0
  99. package/package/corpus/skills/msbuild/references/extension-points.md +281 -0
  100. package/package/corpus/skills/msbuild/references/incremental-build.md +365 -0
  101. package/package/corpus/skills/msbuild/references/msbuild-antipatterns.md +401 -0
  102. package/package/corpus/skills/orleans/LICENSE +21 -0
  103. package/package/corpus/skills/orleans/NOTICE +64 -0
  104. package/package/corpus/skills/orleans/SKILL.md +140 -0
  105. package/package/corpus/skills/orleans/references/anti-patterns.md +660 -0
  106. package/package/corpus/skills/orleans/references/configuration-api.md +933 -0
  107. package/package/corpus/skills/orleans/references/examples.md +66 -0
  108. package/package/corpus/skills/orleans/references/grain-api.md +784 -0
  109. package/package/corpus/skills/orleans/references/grains.md +75 -0
  110. package/package/corpus/skills/orleans/references/hosting.md +71 -0
  111. package/package/corpus/skills/orleans/references/implementation.md +591 -0
  112. package/package/corpus/skills/orleans/references/official-docs-index.md +250 -0
  113. package/package/corpus/skills/orleans/references/patterns.md +811 -0
  114. package/package/corpus/skills/orleans/references/persistence-api.md +495 -0
  115. package/package/corpus/skills/orleans/references/primitive-selection.md +35 -0
  116. package/package/corpus/skills/orleans/references/scheduling-and-services.md +295 -0
  117. package/package/corpus/skills/orleans/references/serialization-api.md +299 -0
  118. package/package/corpus/skills/orleans/references/streaming-api.md +396 -0
  119. package/package/corpus/skills/orleans/references/testing-patterns.md +210 -0
  120. package/package/corpus/skills/platform-detection/LICENSE +23 -0
  121. package/package/corpus/skills/platform-detection/NOTICE +17 -0
  122. package/package/corpus/skills/platform-detection/SKILL.md +230 -0
  123. package/package/corpus/skills/platform-detection/references/command-mode.md +27 -0
  124. package/package/corpus/skills/profiling/LICENSE +21 -0
  125. package/package/corpus/skills/profiling/NOTICE +50 -0
  126. package/package/corpus/skills/profiling/SKILL.md +144 -0
  127. package/package/corpus/skills/profiling/references/commands.md +439 -0
  128. package/package/corpus/skills/profiling/references/patterns.md +586 -0
  129. package/package/corpus/skills/profiling/references/profiling.md +190 -0
  130. package/package/corpus/skills/run-tests/LICENSE +23 -0
  131. package/package/corpus/skills/run-tests/NOTICE +19 -0
  132. package/package/corpus/skills/run-tests/SKILL.md +305 -0
  133. package/package/corpus/skills/target-authoring/LICENSE +23 -0
  134. package/package/corpus/skills/target-authoring/NOTICE +17 -0
  135. package/package/corpus/skills/target-authoring/SKILL.md +165 -0
  136. package/package/corpus/skills/vectorization/LICENSE +23 -0
  137. package/package/corpus/skills/vectorization/NOTICE +17 -0
  138. package/package/corpus/skills/vectorization/SKILL.md +189 -0
  139. package/package/profile-catalog.json +85 -1
  140. package/package.json +1 -1
@@ -0,0 +1,272 @@
1
+ # Shared, report-identity-scoped Cobertura normalization. This does not attest
2
+ # that a report was collected from the current checkout.
3
+
4
+ function New-CoverageMap {
5
+ return [System.Collections.Generic.Dictionary[string, object]]::new([StringComparer]::Ordinal)
6
+ }
7
+
8
+ function Add-CoverageDiagnostic($Diagnostics, [string]$Code, [string]$Message, [string]$Path) {
9
+ $Diagnostics.Add([pscustomobject]@{ code = $Code; severity = 'warning'; message = $Message; path = $Path })
10
+ }
11
+
12
+ function Read-CoverageInteger([string]$Text, [string]$Name, [long]$Minimum = 0) {
13
+ $value = 0L
14
+ if (-not [long]::TryParse($Text, [Globalization.NumberStyles]::Integer,
15
+ [Globalization.CultureInfo]::InvariantCulture, [ref]$value) -or $value -lt $Minimum) {
16
+ throw [FormatException]::new("Invalid $Name value '$Text'.")
17
+ }
18
+ return $value
19
+ }
20
+
21
+ function Add-CoverageLine($Map, $Node, [string]$Key, [string]$ReportId) {
22
+ $number = Read-CoverageInteger $Node.GetAttribute('number') 'line number' 1
23
+ $hits = Read-CoverageInteger $Node.GetAttribute('hits') 'line hits'
24
+ $lineKey = "$Key`n$number"
25
+ if (-not $Map.ContainsKey($lineKey)) {
26
+ $Map[$lineKey] = @{
27
+ Covered = $false
28
+ NonBranch = $false
29
+ ConflictingBranches = $false
30
+ Branches = [System.Collections.Generic.List[object]]::new()
31
+ Observations = [System.Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal)
32
+ }
33
+ }
34
+ $entry = $Map[$lineKey]
35
+ $entry.Covered = $entry.Covered -or $hits -gt 0
36
+ if (-not $entry.Observations.Add($ReportId)) { return }
37
+ $branch = $Node.GetAttribute('branch')
38
+ if ($branch -and $branch -notin @('true', 'false')) {
39
+ throw [FormatException]::new("Invalid branch flag '$branch'.")
40
+ }
41
+ if ($branch -ne 'true') {
42
+ $entry.NonBranch = $true
43
+ if ($entry.Branches.Count) { $entry.ConflictingBranches = $true }
44
+ return
45
+ }
46
+ if ($entry.NonBranch) { $entry.ConflictingBranches = $true }
47
+ $raw = $Node.GetAttribute('condition-coverage')
48
+ if ($raw -notmatch '^\s*[\d.]+%\s*\((\d+)/(\d+)\)\s*$') {
49
+ $entry.Branches.Add(@{ Total = $null; Covered = $null; Conditions = $null })
50
+ return
51
+ }
52
+ $covered = Read-CoverageInteger $Matches[1] 'covered branches'
53
+ $total = Read-CoverageInteger $Matches[2] 'total branches' 1
54
+ if ($covered -gt $total) { throw [FormatException]::new('Covered branches exceed total branches.') }
55
+
56
+ # Cobertura jump conditions describe two outcomes, not which outcome a
57
+ # 50% observation took. Keep that ambiguity even when condition ids match.
58
+ $conditions = New-CoverageMap
59
+ $nodes = @($Node.SelectNodes('conditions/condition'))
60
+ $conditionSum = 0
61
+ $usable = $nodes.Count -gt 0 -and $total -eq 2 * $nodes.Count
62
+ foreach ($condition in $nodes) {
63
+ $id = $condition.GetAttribute('number')
64
+ $coverage = $condition.GetAttribute('coverage')
65
+ if ($condition.GetAttribute('type') -ne 'jump' -or -not $id -or
66
+ $conditions.ContainsKey($id) -or $coverage -notmatch '^(0|50|100)(?:\.0+)?%$') {
67
+ $usable = $false
68
+ continue
69
+ }
70
+ $count = [int]$Matches[1] / 50
71
+ $conditions[$id] = $count
72
+ $conditionSum += $count
73
+ }
74
+ if (-not $usable -or $conditionSum -ne $covered) { $conditions = $null }
75
+ $entry.Branches.Add(@{ Total = $total; Covered = $covered; Conditions = $conditions })
76
+ }
77
+
78
+ function Get-CoverageMeasure($Lines) {
79
+ $coveredLines = @($Lines.Values | Where-Object Covered).Count
80
+ $linePercent = if ($Lines.Count) { [math]::Round(100.0 * $coveredLines / $Lines.Count, 1) } else { $null }
81
+ $lower = 0L
82
+ $upper = 0L
83
+ $total = 0L
84
+ $unknown = $Lines.Count -eq 0
85
+ foreach ($line in $Lines.Values) {
86
+ $observations = @($line.Branches)
87
+ if (-not $observations.Count) { continue }
88
+ if ($line.ConflictingBranches -or @($observations | Where-Object { $null -eq $_.Total }).Count) {
89
+ $unknown = $true
90
+ continue
91
+ }
92
+ $totals = @($observations | ForEach-Object { $_.Total } | Sort-Object -Unique)
93
+ if ($totals.Count -ne 1 -or $null -eq $totals[0]) { $unknown = $true; continue }
94
+ $capacity = $totals[0]
95
+ $total += $capacity
96
+ $useConditions = $true
97
+ $conditionIds = $null
98
+ foreach ($observation in $observations) {
99
+ if ($null -eq $observation.Conditions) { $useConditions = $false; break }
100
+ $ids = @($observation.Conditions.Keys | Sort-Object -CaseSensitive)
101
+ $identity = ConvertTo-Json -InputObject $ids -Compress
102
+ if ($null -ne $conditionIds -and $conditionIds -cne $identity) { $useConditions = $false; break }
103
+ $conditionIds = $identity
104
+ }
105
+ if ($useConditions) {
106
+ foreach ($id in $observations[0].Conditions.Keys) {
107
+ $counts = @($observations | ForEach-Object { $_.Conditions[$id] })
108
+ $lower += ($counts | Measure-Object -Maximum).Maximum
109
+ $upper += [math]::Min(2, ($counts | Measure-Object -Sum).Sum)
110
+ }
111
+ } else {
112
+ $counts = @($observations | ForEach-Object { $_.Covered })
113
+ $lower += ($counts | Measure-Object -Maximum).Maximum
114
+ $upper += [math]::Min($capacity, ($counts | Measure-Object -Sum).Sum)
115
+ }
116
+ }
117
+ $branchStatus = if ($unknown) { 'unknown' } elseif (-not $total) { 'not-applicable' } elseif ($lower -eq $upper) { 'exact' } else { 'bounded' }
118
+ return [pscustomobject]@{
119
+ TotalLines = $Lines.Count
120
+ CoveredLines = $coveredLines
121
+ LineCoverage = $linePercent
122
+ LineCoverageStatus = $(if ($Lines.Count) { 'exact' } else { 'unknown' })
123
+ TotalBranches = $(if ($unknown) { $null } else { $total })
124
+ CoveredBranches = $(if ($branchStatus -in @('exact', 'not-applicable')) { [long]$lower } else { $null })
125
+ BranchCoverage = $(if ($branchStatus -eq 'exact') { [math]::Round(100.0 * $lower / $total, 1) } else { $null })
126
+ BranchCoverageStatus = $branchStatus
127
+ CoveredBranchesLower = $(if (-not $unknown) { [long]$lower } else { $null })
128
+ CoveredBranchesUpper = $(if (-not $unknown) { [long]$upper } else { $null })
129
+ BranchCoverageLower = $(if (-not $unknown -and $total) { [math]::Round(100.0 * $lower / $total, 1) } else { $null })
130
+ BranchCoverageUpper = $(if (-not $unknown -and $total) { [math]::Round(100.0 * $upper / $total, 1) } else { $null })
131
+ }
132
+ }
133
+
134
+ function Get-CoverageData([string[]]$Paths) {
135
+ if (-not $Paths.Count) { throw [ArgumentException]::new('At least one Cobertura report is required.') }
136
+ $methods = New-CoverageMap
137
+ $classLines = New-CoverageMap
138
+ $methodLines = New-CoverageMap
139
+ $inputs = [System.Collections.Generic.List[object]]::new()
140
+ $reports = [System.Collections.Generic.List[object]]::new()
141
+ $diagnostics = [System.Collections.Generic.List[object]]::new()
142
+ $seen = [System.Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal)
143
+ $allClassesHaveLines = $true
144
+ foreach ($path in ($Paths | Sort-Object -Unique -CaseSensitive)) {
145
+ $resolved = (Get-Item -LiteralPath $path -ErrorAction Stop).FullName
146
+ $bytes = [IO.File]::ReadAllBytes($resolved)
147
+ $hash = [Convert]::ToHexString([Security.Cryptography.SHA256]::HashData($bytes)).ToLowerInvariant()
148
+ $inputs.Add([pscustomobject]@{ path = $resolved; sha256 = $hash })
149
+ if (-not $seen.Add($hash)) { continue }
150
+ $xml = [xml]::new()
151
+ $xml.XmlResolver = $null
152
+ $stream = [IO.MemoryStream]::new($bytes, $false)
153
+ try { $xml.Load($stream) } finally { $stream.Dispose() }
154
+ if ($xml.DocumentElement.Name -ne 'coverage') { throw [FormatException]::new("Not a Cobertura report: $path") }
155
+ $coverageRoot = $xml.DocumentElement
156
+ $report = @{ line = $null; branch = $null }
157
+ foreach ($metric in @('line', 'branch')) {
158
+ $prefix = if ($metric -eq 'line') { 'lines' } else { 'branches' }
159
+ $valid = $coverageRoot.GetAttribute("$prefix-valid")
160
+ $covered = $coverageRoot.GetAttribute("$prefix-covered")
161
+ if ($valid -or $covered) {
162
+ $denominator = Read-CoverageInteger $valid "$prefix-valid"
163
+ $numerator = Read-CoverageInteger $covered "$prefix-covered"
164
+ if ($numerator -gt $denominator) { throw [FormatException]::new("$prefix-covered exceeds $prefix-valid.") }
165
+ $report[$metric] = @{ Total = $denominator; Covered = $numerator }
166
+ }
167
+ }
168
+ $reports.Add($report)
169
+ $reportMethods = [System.Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal)
170
+ foreach ($class in $xml.SelectNodes('/coverage/packages/package/classes/class')) {
171
+ $filename = $class.GetAttribute('filename').Replace('\', '/')
172
+ $className = $class.GetAttribute('name')
173
+ $module = $class.ParentNode.ParentNode.GetAttribute('name')
174
+ if (-not $filename -or -not $className) { throw [FormatException]::new('Class name and filename are required.') }
175
+ $sourceKey = ConvertTo-Json -InputObject @($module, $filename) -Compress
176
+ $classNodes = @($class.SelectNodes('lines/line'))
177
+ if (-not $classNodes.Count) { $allClassesHaveLines = $false }
178
+ foreach ($line in $classNodes) { Add-CoverageLine $classLines $line $sourceKey $hash }
179
+ foreach ($method in $class.SelectNodes('methods/method')) {
180
+ $name = $method.GetAttribute('name')
181
+ if (-not $name) { throw [FormatException]::new('Method name is required.') }
182
+ $signature = $method.GetAttribute('signature')
183
+ $key = ConvertTo-Json -InputObject @($module, $filename, $className, $name, $signature) -Compress
184
+ if (-not $reportMethods.Add($key)) {
185
+ throw [FormatException]::new("Duplicate method identity for $className.$name; signatures or source mapping are ambiguous.")
186
+ }
187
+ if (-not $methods.ContainsKey($key)) {
188
+ $methods[$key] = @{
189
+ Module = $module; Class = $className; Method = $name; Signature = $signature; File = $filename
190
+ Lines = (New-CoverageMap)
191
+ Complexities = [System.Collections.Generic.HashSet[long]]::new()
192
+ }
193
+ }
194
+ $entry = $methods[$key]
195
+ $complexity = $method.GetAttribute('complexity')
196
+ if ($complexity) { [void]$entry.Complexities.Add((Read-CoverageInteger $complexity 'complexity' 1)) }
197
+ foreach ($line in $method.SelectNodes('lines/line')) {
198
+ Add-CoverageLine $entry.Lines $line '' $hash
199
+ Add-CoverageLine $methodLines $line $sourceKey $hash
200
+ }
201
+ }
202
+ }
203
+ }
204
+ $result = [System.Collections.Generic.List[object]]::new()
205
+ foreach ($entry in $methods.Values) {
206
+ $measure = Get-CoverageMeasure $entry.Lines
207
+ $complexity = if ($entry.Complexities.Count -eq 1) { @($entry.Complexities)[0] } else { $null }
208
+ $item = [ordered]@{
209
+ Class = $entry.Class; Method = $entry.Method; Signature = $entry.Signature; File = $entry.File
210
+ Module = $entry.Module; Complexity = $complexity
211
+ ComplexityStatus = $(if ($null -ne $complexity) { 'exact' } else { 'unknown' })
212
+ }
213
+ foreach ($property in $measure.PSObject.Properties) { $item[$property.Name] = $property.Value }
214
+ $item.UncoveredLines = $measure.TotalLines - $measure.CoveredLines
215
+ if ($null -eq $complexity) {
216
+ Add-CoverageDiagnostic $diagnostics 'COMPLEXITY_UNKNOWN' "Missing or conflicting complexity for $($entry.Class).$($entry.Method)." $entry.File
217
+ }
218
+ if ($measure.LineCoverageStatus -eq 'unknown') {
219
+ Add-CoverageDiagnostic $diagnostics 'METHOD_LINES_UNKNOWN' "No executable-line evidence for $($entry.Class).$($entry.Method)." $entry.File
220
+ }
221
+ if ($measure.BranchCoverageStatus -in @('unknown', 'bounded')) {
222
+ Add-CoverageDiagnostic $diagnostics 'BRANCH_UNION_UNCERTAIN' "Branch outcomes cannot be uniquely merged for $($entry.Class).$($entry.Method)." $entry.File
223
+ }
224
+ $result.Add([pscustomobject]$item)
225
+ }
226
+ $aggregate = Get-CoverageMeasure $classLines
227
+ $aggregateScope = 'class-lines'
228
+ if (-not $allClassesHaveLines -or -not $classLines.Count) {
229
+ $aggregateScope = if ($reports.Count -eq 1) { 'report' } else { 'method-lines-only' }
230
+ $aggregate = [pscustomobject]@{ LineCoverage = $null; LineCoverageStatus = 'unknown'; BranchCoverage = $null; BranchCoverageStatus = 'unknown' }
231
+ if ($reports.Count -eq 1) {
232
+ foreach ($metric in @('line', 'branch')) {
233
+ $counter = $reports[0][$metric]
234
+ $name = if ($metric -eq 'line') { 'LineCoverage' } else { 'BranchCoverage' }
235
+ if ($null -ne $counter) {
236
+ $aggregate.$name = if ($counter.Total) { [math]::Round(100.0 * $counter.Covered / $counter.Total, 1) } else { $null }
237
+ $aggregate."${name}Status" = if ($counter.Total) { 'exact' } else { 'not-applicable' }
238
+ }
239
+ }
240
+ }
241
+ }
242
+ if (-not $result.Count) {
243
+ Add-CoverageDiagnostic $diagnostics 'METHODS_UNAVAILABLE' 'The report has no method-level coverage evidence.' ''
244
+ }
245
+ return [pscustomobject]@{
246
+ Methods = @($result | Sort-Object -CaseSensitive Module, File, Class, Method, Signature)
247
+ Inputs = @($inputs)
248
+ Diagnostics = $diagnostics
249
+ Summary = [ordered]@{
250
+ overall_line_coverage = $aggregate.LineCoverage
251
+ overall_line_coverage_status = $aggregate.LineCoverageStatus
252
+ overall_branch_coverage = $aggregate.BranchCoverage
253
+ overall_branch_coverage_status = $aggregate.BranchCoverageStatus
254
+ coverage_scope = $aggregateScope
255
+ method_line_coverage = (Get-CoverageMeasure $methodLines).LineCoverage
256
+ total_methods = $result.Count
257
+ }
258
+ }
259
+ }
260
+
261
+ function Write-CoverageJson([string]$Tool, [string]$Status, $Scope, $Inputs, $Diagnostics, $Data) {
262
+ [ordered]@{
263
+ schema_version = '1'; tool = $Tool; tool_version = '1.0'; status = $Status
264
+ scope = $Scope; inputs = @($Inputs); diagnostics = @($Diagnostics); data = $Data
265
+ } | ConvertTo-Json -Depth 30
266
+ }
267
+
268
+ function Write-CoverageDiagnostics($Diagnostics) {
269
+ foreach ($diagnostic in $Diagnostics) {
270
+ [Console]::Error.WriteLine("$($diagnostic.code): $($diagnostic.message)")
271
+ }
272
+ }
@@ -0,0 +1,65 @@
1
+ <#
2
+ .SYNOPSIS
3
+ Extract Cobertura method coverage without inventing missing measurements.
4
+ .DESCRIPTION
5
+ Legacy output is a JSON array; diagnostics and summaries go to stderr.
6
+ Use -OutputFormat json-v1 for provenance, null/unknown metrics and branch bounds.
7
+ Merging is scoped to reported module/file/class/signature identities, not an
8
+ attestation of source revision. Duplicate report bytes are idempotent.
9
+ Exit codes: 0 complete, 2 invalid input, 3 incomplete/unrepresentable evidence.
10
+ #>
11
+ param(
12
+ [Parameter(Mandatory=$true)][string[]]$CoberturaPath,
13
+ [ValidateRange(0,100)][int]$CoverageThreshold = 80,
14
+ [ValidateRange(0,100)][int]$BranchThreshold = 70,
15
+ [ValidateSet('uncovered', 'below-threshold', 'all')][string]$Filter = 'all',
16
+ [ValidateSet('legacy', 'json-v1')][string]$OutputFormat = 'legacy'
17
+ )
18
+
19
+ try {
20
+ . "$PSScriptRoot\CoverageData.ps1"
21
+ } catch {
22
+ $diagnostic = @{ code = 'DEPENDENCY_UNAVAILABLE'; severity = 'error'; message = $_.Exception.Message; path = "$PSScriptRoot\CoverageData.ps1" }
23
+ [Console]::Error.WriteLine("$($diagnostic.code): $($diagnostic.message)")
24
+ if ($OutputFormat -eq 'json-v1') {
25
+ @{
26
+ schema_version = '1'; tool = 'Extract-MethodCoverage'; tool_version = '1.0'; status = 'error'
27
+ scope = @{}; inputs = @(); diagnostics = @($diagnostic); data = @{}
28
+ } | ConvertTo-Json -Depth 5
29
+ }
30
+ exit 2
31
+ }
32
+ $scope = @{ identity = 'reported-module-file-class-signature'; source_revision = $null; filter = $Filter }
33
+ try {
34
+ $coverage = Get-CoverageData $CoberturaPath
35
+ } catch {
36
+ $diagnostics = @([pscustomobject]@{ code = 'INVALID_INPUT'; severity = 'error'; message = $_.Exception.Message })
37
+ Write-CoverageDiagnostics $diagnostics
38
+ if ($OutputFormat -eq 'json-v1') { Write-CoverageJson 'Extract-MethodCoverage' 'error' $scope @() $diagnostics @{} }
39
+ exit 2
40
+ }
41
+ $partial = -not $coverage.Methods.Count -or @($coverage.Methods | Where-Object {
42
+ $_.LineCoverageStatus -eq 'unknown' -or $_.BranchCoverageStatus -in @('unknown', 'bounded') -or $_.ComplexityStatus -eq 'unknown'
43
+ }).Count -gt 0
44
+ $methods = @($coverage.Methods | Where-Object {
45
+ if ($Filter -eq 'all') { return $true }
46
+ if ($_.LineCoverageStatus -eq 'unknown' -or $_.BranchCoverageStatus -in @('unknown', 'bounded')) { return $true }
47
+ if ($Filter -eq 'uncovered') { return $_.LineCoverage -eq 0 }
48
+ return (100.0 * $_.CoveredLines / $_.TotalLines) -lt $CoverageThreshold -or
49
+ ($_.TotalBranches -gt 0 -and (100.0 * $_.CoveredBranches / $_.TotalBranches) -lt $BranchThreshold)
50
+ } | Sort-Object -Property @{Expression='UncoveredLines';Descending=$true}, @{Expression='LineCoverage';Descending=$false}, Class, Method, File, Signature)
51
+ Write-CoverageDiagnostics $coverage.Diagnostics
52
+ if ($OutputFormat -eq 'json-v1') {
53
+ Write-CoverageJson 'Extract-MethodCoverage' $(if ($partial) { 'partial' } else { 'complete' }) $scope $coverage.Inputs $coverage.Diagnostics @{
54
+ methods = $methods; summary = $coverage.Summary
55
+ }
56
+ } elseif (-not $partial) {
57
+ $legacy = @($methods | Select-Object Class, Method, Signature, File, Complexity, LineCoverage,
58
+ @{Name='BranchCoverage';Expression={if ($_.BranchCoverageStatus -eq 'not-applicable') { 0 } else { $_.BranchCoverage }}},
59
+ CoveredLines, TotalLines, UncoveredLines, CoveredBranches, TotalBranches)
60
+ ConvertTo-Json -InputObject $legacy -Depth 5
61
+ [Console]::Error.WriteLine("METHODS_FILTERED:$($methods.Count)")
62
+ [Console]::Error.WriteLine("UNCOVERED_METHODS:$(@($methods | Where-Object { $_.LineCoverageStatus -eq 'exact' -and $_.LineCoverage -eq 0 }).Count)")
63
+ }
64
+ if ($partial) { exit 3 }
65
+ exit 0
@@ -0,0 +1,23 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) .NET Foundation and Contributors
4
+
5
+ All rights reserved.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
@@ -0,0 +1,22 @@
1
+ C# Refactoring (behavior-preserving)
2
+ Copyright (c) .NET Foundation and Contributors
3
+ Licensed under the MIT License. See LICENSE.
4
+
5
+ Upstream source: https://github.com/dotnet/skills/blob/a6bf43ab61967c30919334986515163ab24d7635/plugins/dotnet/skills/csharp-refactoring/SKILL.md
6
+
7
+ Changes made by Cratis:
8
+
9
+ LICENSE:
10
+ - Copy upstream MIT license and copyright verbatim.
11
+
12
+ SKILL.md:
13
+ - Normalize frontmatter serialization, add MIT license where absent; preserve name and description.
14
+ - Add marked modification/source comment and applicability/Cratis precedence line.
15
+ - Add the requested Cratis persisted-event, proxy, Orleans identity and framework-public-API contract section.
16
+ - Rewrite the description to the Cratis shape (what it does, Use when, Not for) and drop references to skills that are not part of this corpus.
17
+ - Remove references to the dotnet-upgrade skill; point to the repository's own upgrade workflow.
18
+
19
+ references/operation-catalog.md:
20
+ - Replace the upstream issue reference with a plain statement of the behavior.
21
+
22
+ NOTICE: Add this attribution, change list, and any download/execution disclosure.
@@ -0,0 +1,175 @@
1
+ ---
2
+ name: csharp-refactoring
3
+ description: 'Safely refactors C#/.NET code without changing behavior: rename, move, extract, inline, merge, consolidate, deduplicate, split, or modernize, including partial or generated declarations, public APIs, serialization and reflection names, friend assemblies, conditional compilation, and multi-targeted projects. Use when a request asks for a refactor, or calls a feature, bug fix, upgrade, or public nullability change a refactor and the behavior-changing part must be separated or declined. Not for ordinary feature or bug fixes, standalone framework or package upgrades, adding tests, or formatting-only work.'
4
+ license: MIT
5
+ ---
6
+
7
+ <!-- Modified by Cratis from dotnet's original (MIT): frontmatter, applicability, navigation and the changes listed in NOTICE. Upstream: https://github.com/dotnet/skills (plugins/dotnet/skills/csharp-refactoring/SKILL.md; see NOTICE) -->
8
+
9
+ # C# Refactoring (behavior-preserving)
10
+
11
+ Cratis rules in `.cratis/ai/rules/` (including `csharp.md`, `specs.csharp.md`, and `orleans.md`) and the `cratis-*` skills win where they differ.
12
+
13
+ A refactor changes **structure**, never observable **behavior**. Do the edit with binding-aware tools,
14
+ then confirm behavior held with a build + the relevant tests. Keep the effort proportional to the change:
15
+ a one-line local rename does not need the ceremony a public multi-targeted change does.
16
+
17
+ ## Mandatory gate: classify before validation or editing
18
+
19
+ Read only enough repository context to classify **each requested operation**. Do this before restoring,
20
+ building, or making an edit. Classification precedence is:
21
+
22
+ - If the request explicitly asks for at least one separable behavior-preserving operation, complete
23
+ that structural work and defer only the behavior-changing or contract-changing operations. Do not
24
+ invent or infer structural work to avoid the stop response.
25
+ - If the structural and behavior-changing parts cannot be separated, use the whole-request stop
26
+ response and state why they are inseparable.
27
+ - Otherwise, use the whole-request stop response only when **every** requested operation is outside
28
+ behavior-preserving refactoring.
29
+
30
+ For a whole request that is outside behavior-preserving refactoring:
31
+
32
+ 1. State: `Not a behavior-preserving refactor: <specific reason>.`
33
+ 2. State: `No files changed.`
34
+ 3. State: `Next workflow: <workflow>.` Then stop. Do not add manual implementation steps, alternatives,
35
+ an offer to proceed without the workflow, or a follow-up question — even when that workflow is unavailable.
36
+
37
+ | Requested as a "refactor" | Classification and action |
38
+ |---|---|
39
+ | Framework or NuGet version change | **Upgrade.** Do not edit or validate the upgrade here; hand off to the repository's upgrade workflow. |
40
+ | New capability, flag, endpoint, tier, or behavior | **Feature.** Do not implement it here; hand off to the repository's feature workflow. |
41
+ | Threshold, rate, output, or bug-result change | **Behavior change.** Defer it and hand off to the repository's bug-fix or behavior-change workflow; still complete any clearly separable structural operation. |
42
+ | Tighten or loosen a shipped/public nullable annotation | **Source-contract change.** Leave the declaration and API record unchanged; hand off to the repository's API-contract workflow. |
43
+
44
+ For a mixed request, never stop after classification. Perform the separable structural operation,
45
+ explicitly defer the behavior/contract change, and never state `No files changed.` after completing
46
+ structural work. Never modify tests to make an unauthorized behavior change appear preserved.
47
+
48
+ ## Work only in the current workspace
49
+
50
+ Use the current agent workspace as the boundary. If it is a Git checkout, resolve its repository root
51
+ (`git rev-parse --show-toplevel`) and stay inside it. If Git metadata is absent, treat the current working
52
+ directory and its subdirectories as the boundary, and use a solution or project named in the request
53
+ inside it; Git is not a prerequisite for a refactor. Resolve prompt-provided relative paths inside that
54
+ boundary.
55
+
56
+ Search and edit only that workspace. Never use filesystem-wide search or select a similarly named clone,
57
+ another worktree, build output, or unrelated temporary directory because a file also exists there. If a
58
+ named path is absent, stop and report the mismatch instead of guessing another workspace. If a tool rejects
59
+ an in-workspace path for a mechanical reason such as path form or unsupported tool root, retry through
60
+ another in-workspace mechanism. If the rejection is a permission or policy denial, report it instead of
61
+ working around it. Never search outside the boundary.
62
+
63
+ ## Rename / move by bindings, not text
64
+
65
+ The #1 way a "rename" silently corrupts code is editing textual matches (comments, strings, unrelated
66
+ overloads) instead of real **bindings**. Find every binding reference first, then edit semantically. Use
67
+ the strongest tool available: an IDE/Roslyn workspace refactoring, then the C# LSP the
68
+ [`dotnet` plugin declares](https://github.com/dotnet/skills/blob/main/plugins/dotnet/lsp.json)
69
+ (`findReferences`, `goToDefinition`, `incomingCalls`, `rename` code action), then analyzer code-fixes /
70
+ Roslynator, then compiler-validated edits (edit the true bindings, rebuild, let the compiler flag misses).
71
+ Plain find/replace only when scope is provably tiny and every hit is verified. Include **every** `partial`
72
+ declaration, and edit the generator input, never generated (`*.g.cs`) output.
73
+
74
+ For the operation → Roslyn-provider mapping and representative PRs, see
75
+ [references/operation-catalog.md](references/operation-catalog.md).
76
+
77
+ ## Consolidate toward the existing source of truth
78
+
79
+ When de-duplicating, preserve the ownership direction stated by the code or request. If `B` duplicates
80
+ an implementation already owned by `A`, keep `A` canonical and make `B` delegate to it; do not invert
81
+ the dependency merely because either direction compiles. Preserve public compatibility wrappers when
82
+ the duplicate surface is shipped, and migrate only in-repo callers that are safe to move.
83
+
84
+ ## Decisions that change the edit
85
+
86
+ Use the first matching row instead of applying the requested operation mechanically:
87
+
88
+ | Situation | Do | Never |
89
+ |---|---|---|
90
+ | Inline an internal, unshipped pass-through wrapper | Migrate every binding reference to the target, remove the wrapper, then compile to catch misses. | Keep dead indirection "for compatibility" when no compatibility boundary exists. |
91
+ | Inline or remove a shipped/public wrapper | Migrate ordinary in-repo callers, but retain an `[Obsolete]` forwarding entry point unless the request explicitly authorizes a breaking change. | Delete a shipped API merely because all current source callers were migrated. |
92
+ | Rename a member reached by a string, reflection, DI, or configuration | Rename binding-based callers; preserve the observed external name with a forwarding shim or metadata, and exercise the old-name path. | Rewrite an external/configured name just to make the new source name consistent. |
93
+ | Extract duplicated logic whose callers pass different values | Extract the algorithm and pass each caller's existing inputs through unchanged. | Collapse distinct inputs, evaluation order, rounding, or side effects into one caller's version. |
94
+ | Rename code compiled under `#if` or multiple TFMs | Update every source branch and validate each target framework explicitly. | Treat a green default-target build as evidence for unbuilt branches. |
95
+ | Merge near-identical types | Parameterize only the values that differ, migrate every construction site, and preserve each old value exactly. If the old types are internal/unshipped and the request says to merge into one type, delete their declarations. | Retain unnecessary aliases, static holders, factories, or wrapper types that leave the requested merge incomplete; introduce a new hierarchy or behavior. |
96
+
97
+ ## Preserve contracts beyond C# call sites
98
+
99
+ Compilation proves binding compatibility, not every external contract. Before renaming or moving a
100
+ type/member, check whether its name or metadata is observed by serialization, reflection, dependency
101
+ injection, configuration binding, source generators, P/Invoke, or `dynamic`.
102
+
103
+ | Boundary | Required decision |
104
+ |---|---|
105
+ | Serialized/configuration name | Preserve the external name with the repository's existing mechanism (for example, `JsonPropertyName`) while migrating C# callers; run a focused round-trip or payload test. |
106
+ | Public nullable annotation | The mandatory classification gate applies: leave it unchanged and hand off as a source-contract change. |
107
+ | Uncovered reflection or runtime lookup | Do not guess that a compile-clean rename is safe. Preserve the observed name or stop and report the unverified runtime boundary. |
108
+
109
+ ## Verify proportionally
110
+
111
+ Confirm behavior is preserved after the edit — scaled to blast radius, not a fixed ceremony:
112
+
113
+ - **Local / private** (method-local or `private` member, one file, single target framework, no public
114
+ surface, no `partial`/generated/`#if`): skip a separate baseline unless the tree is already suspect.
115
+ Make the edit, then run the narrowest build and relevant tests once. Let the compiler catch missed
116
+ references.
117
+ - **Cross-boundary** (public/shipped symbol, multi-targeted project, `#if`/platform branches, or
118
+ `partial`/generated code): establish a baseline, then run an explicit build and the relevant tests for
119
+ **each** target framework after the edit (a test command's implicit build is not separate build evidence;
120
+ a green default build can hide a break on another TFM), and run the hazards check below.
121
+
122
+ Use the repo's own build/test workflow when it documents one (`README`/`CONTRIBUTING`, `build.*`, `eng/`,
123
+ `global.json`, `.github/workflows`); its instructions win over any generic command.
124
+
125
+ ### Typical workflow (one operation)
126
+ 1. Choose one named refactoring operation and keep the step focused on that operation only.
127
+ 2. Find true binding references (`findReferences`/`goToDefinition`/rename) and include all `partial` declarations.
128
+ 3. Establish a baseline first only for a cross-boundary change or a tree not already known green.
129
+ 4. Apply the change via the most semantics-aware tool available; avoid blind find/replace when possible.
130
+ 5. Rebuild and run the relevant tests. If the gate goes red, report the failure and repair or reassess only
131
+ your edit; never discard unrelated worktree changes.
132
+
133
+ Otherwise:
134
+ ```bash
135
+ dotnet build # 0 errors
136
+ dotnet test # stays green; same pass count as before
137
+ ```
138
+
139
+ One operation per step; never mix a refactor and a behavior change in the same step. On red, stop and report the failure; repair only your edit without discarding unrelated worktree changes.
140
+
141
+ ## Final response contract
142
+
143
+ Keep the handoff concise and evidence-based:
144
+
145
+ - **Refactor:** name the structural operation and the symbols/files changed.
146
+ - **Preserved:** name the behavior or compatibility boundary and the mechanism that preserved it.
147
+ - **Validation:** report the exact commands and observed result; never claim success after a failed restore,
148
+ build, target framework, or test run.
149
+ - **Deferred:** for a mixed request, name the behavior/contract change intentionally left undone and its
150
+ correct next workflow. Omit this line when nothing was deferred.
151
+
152
+ ## Cross-boundary hazards (only when it touches a boundary)
153
+
154
+ If — and only if — the change touches a **public** symbol, a **multi-targeted** project, or
155
+ `partial`/generated code, some breaks won't show up as a failing test. Search the repo for the surface
156
+ that governs the symbol (don't assume): the public-API gate (`PublicAPI.Shipped/Unshipped.txt` for
157
+ PublicApiAnalyzers, and/or `ApiCompat`/`<EnablePackageValidation>` — not interchangeable),
158
+ `<TargetFrameworks>`/`#if` branches, and `InternalsVisibleTo`. Moving a public type to another assembly
159
+ needs `[TypeForwardedTo]` in the original assembly; a move within one assembly does not. A public
160
+ *rename* needs an `[Obsolete]` shim, not a forwarder. For a provably local/private change, skip these
161
+ checks.
162
+
163
+ ## Stop an in-scope refactor when
164
+
165
+ - The baseline is already red (you can't prove you preserved behavior).
166
+ - The requested structural change would alter a public/shipped API and no compatibility shim or forwarder
167
+ can preserve it. Report the boundary. Use the gate's handoff format when no structural work was completed;
168
+ after separable work, put the incompatible operation on the `Deferred:` line instead. Do not ask to make
169
+ the breaking change.
170
+ - Equivalence depends on runtime behavior tests don't cover (reflection, DI, serialization, `dynamic`,
171
+ P/Invoke) — report the unverified boundary instead of claiming behavior was preserved.
172
+
173
+ ## Contracts the compiler cannot see in Cratis code
174
+
175
+ Preserve `[EventType]` identifiers and type names of persisted events, generated TypeScript proxies of Arc commands/queries, `[Alias]`/serializer ids in Orleans, and public API of framework packages (semver).
@@ -0,0 +1,37 @@
1
+ # C# refactoring operation catalog (detail)
2
+
3
+ Load this when you need the full operation taxonomy or the Roslyn provider each maps to.
4
+ The core SKILL.md keeps only the short operation list; this file is the depth.
5
+
6
+ ## Contents
7
+
8
+ - Operation catalog (provider, recurrence, representative PR)
9
+ - "Modernize" is defined by the repo's analyzer config
10
+
11
+ ## Operation catalog
12
+
13
+ Canonical operations, aligned with Roslyn's own IDE refactoring providers
14
+ (`src/Features/CSharp/Portable/CodeRefactorings`). The provider column is informational — a
15
+ headless CLI agent usually cannot invoke these IDE code actions directly, so apply them via the fallback
16
+ ladder in SKILL.md.
17
+
18
+ | Operation | Roslyn provider / tool | Recurrence | Representative real PR |
19
+ |-----------|------------------------|-----------:|------------------------|
20
+ | **Rename** symbol / type / file | rename engine (`Renamer`) | high | _runtime_ "Rename `DISABLE_CROSSGEN`"; _sdk_ "Rename `dnup` to `dotnetup`" |
21
+ | **Move** type / member / file | `MoveType`, `MoveStaticMembers` | high | _runtime_ "Move DSA tests into System.Security.Cryptography"; _sdk_ "Move SDK task unit test projects from src/ to test/" |
22
+ | **Consolidate / de-duplicate** | analyzer-assisted | high | _runtime_ "Consolidate ComWrappers implementation across platforms" |
23
+ | **Modernize / simplify** idioms | `UseExplicitOrImplicitType`, `UseRecursivePatterns`, `ConvertLocalFunctionToMethod`, `AddAwait` | high | _roslyn_ "Simplify lots of redundant code in code fix providers" |
24
+ | **Split** large class / file / assembly | extract + move | medium | _roslyn_ "Split `FeatureSwitchManager`"; _runtime_ "Move RPC contracts to a separate assembly" |
25
+ | **Extract** method / class / interface | `ExtractClass`, extract-method, extract-interface | medium | _runtime_ "Extract `ManifestBuilder` and `EventListener`" |
26
+ | **Inline** method / local / constant | `InlineMethod`, `InlineTemporary` | lower | _runtime_ "Refactor `UInt128` division" |
27
+ | **Pull up / push down** member | `PullMemberUp` | tail | move members between a type and its base/interface |
28
+ | **Sync namespace** to folder | `SyncNamespace` | tail | align `namespace` with folder layout after a move |
29
+
30
+ ## "Modernize" is defined by the repo's analyzer config, not personal taste
31
+
32
+ These repos drive idiom rules through `.editorconfig` + `EnforceOnBuild` (which enforces
33
+ code-style analyzers during build). Apply the fixes the repo's own analyzers request
34
+ (IDE00xx / CAxxxx) via `dotnet format` / code-fixes; don't impose a style it hasn't opted into, and don't
35
+ blanket-suppress diagnostics to make an edit "pass." For _adopting_ nullable annotations specifically, see
36
+ the repository's nullable migration workflow; enabling nullable across a project or changing public API
37
+ annotations is a migration or contract change, not a canonical behavior-preserving refactoring operation.
@@ -0,0 +1,23 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) .NET Foundation and Contributors
4
+
5
+ All rights reserved.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ Organizing Build Infrastructure with Directory.Build Files
2
+ Copyright (c) .NET Foundation and Contributors
3
+ Licensed under the MIT License. See LICENSE.
4
+
5
+ Upstream source: https://github.com/dotnet/skills/blob/a6bf43ab61967c30919334986515163ab24d7635/plugins/dotnet-msbuild/skills/directory-build-organization/SKILL.md
6
+
7
+ Changes made by Cratis:
8
+
9
+ LICENSE:
10
+ - Copy upstream MIT license and copyright verbatim.
11
+
12
+ SKILL.md:
13
+ - Lead the description trigger with an explicit "Use when" clause.
14
+ - Normalize frontmatter serialization, add MIT license where absent; preserve name and description.
15
+ - Add marked modification/source comment and applicability/Cratis precedence line.
16
+ - Rewrite the description to the Cratis shape (what it does, Use when, Not for) and drop references to skills that are not part of this corpus.
17
+
18
+ references/multi-level-examples.md:
19
+ - Add or normalize the top Contents list from existing headings; preserve section content.
20
+
21
+ NOTICE: Add this attribution, change list, and any download/execution disclosure.