regen.mde 0.2.2 → 0.8.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 (56) hide show
  1. package/LICENSE +16 -16
  2. package/README.md +409 -295
  3. package/bin/build-corpus-editor.js +83 -81
  4. package/bin/build-corpus.js +41 -41
  5. package/bin/postinstall.js +259 -187
  6. package/bin/regen-mdeditor-install.js +27 -27
  7. package/bin/regen-mdeditor-uninstall.js +19 -19
  8. package/bin/validate-katex.js +93 -93
  9. package/desktop/BuildCorpusEditor/BuildCorpusBridge.cs +493 -270
  10. package/desktop/BuildCorpusEditor/BuildCorpusEditor.csproj +22 -22
  11. package/desktop/BuildCorpusEditor/EditorForm.cs +853 -540
  12. package/desktop/BuildCorpusEditor/Program.cs +85 -81
  13. package/desktop/BuildCorpusEditor/app.manifest +16 -16
  14. package/dist/release/regen-mde-0.8.0-win-x64.zip +0 -0
  15. package/dist/windows-editor/BuildCorpusEditor.dll +0 -0
  16. package/dist/windows-editor/BuildCorpusEditor.exe +0 -0
  17. package/dist/windows-editor/BuildCorpusEditor.pdb +0 -0
  18. package/dist/windows-editor/BuildCorpusEditor.runtimeconfig.json +1 -1
  19. package/dist/windows-editor/wwwroot/assets/index-C_VxJk4k.js +375 -0
  20. package/dist/windows-editor/wwwroot/assets/index-Wt9zSjIw.css +1 -0
  21. package/dist/windows-editor/wwwroot/index.html +22 -22
  22. package/editor-web/index.html +21 -21
  23. package/editor-web/src/main.jsx +1044 -399
  24. package/editor-web/src/styles.css +846 -602
  25. package/editor-web/vite.config.js +13 -13
  26. package/examples/build-corpus.config.example.json +21 -21
  27. package/installer/install-regen-mde.ps1 +214 -175
  28. package/installer/regen-mde.nsi +81 -81
  29. package/package.json +10 -6
  30. package/pyproject.toml +4 -3
  31. package/requirements.txt +5 -4
  32. package/scripts/build-windows-editor.ps1 +47 -47
  33. package/scripts/package-windows-editor.ps1 +90 -90
  34. package/scripts/release-dual.mjs +105 -0
  35. package/scripts/run-corpus.ps1 +28 -28
  36. package/scripts/run-editor-implementation-plane.ps1 +226 -203
  37. package/scripts/run-required-tests.ps1 +98 -98
  38. package/scripts/run-smoke.ps1 +28 -28
  39. package/src/build_corpus/__init__.py +1 -1
  40. package/src/build_corpus/docx_exporter.py +1055 -798
  41. package/src/build_corpus/equations.py +1345 -0
  42. package/src/build_corpus/exporter.py +1488 -1195
  43. package/src/build_corpus/frontmatter.py +302 -0
  44. package/src/build_corpus/ppt_exporter.py +543 -532
  45. package/src/build_corpus/templates/__init__.py +1 -1
  46. package/src/build_corpus/validate_assets.py +46 -46
  47. package/tools/audit_corpus.py +203 -203
  48. package/tools/collect_microsoft_word_templates.py +228 -228
  49. package/tools/collect_online_docx_corpus.py +272 -272
  50. package/tools/collect_online_pptx_corpus.py +252 -252
  51. package/tools/compare_pptx_inputs_outputs.py +87 -87
  52. package/tools/roundtrip_docx_corpus.py +171 -171
  53. package/dist/release/regen.mde-0.2.2-win-x64-setup.exe +0 -0
  54. package/dist/release/regen.mde-0.2.2-win-x64.zip +0 -0
  55. package/dist/windows-editor/wwwroot/assets/index-DjJ6xmhy.js +0 -326
  56. package/dist/windows-editor/wwwroot/assets/index-_dwMNNsm.css +0 -1
@@ -1,203 +1,226 @@
1
- [CmdletBinding()]
2
- param(
3
- [ValidateSet("Plan", "Verify", "Install", "Smoke")]
4
- [string]$Mode = "Verify",
5
- [string]$Root = ""
6
- )
7
-
8
- $ErrorActionPreference = "Stop"
9
-
10
- if ([string]::IsNullOrWhiteSpace($Root)) {
11
- $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
12
- $Root = (Resolve-Path (Join-Path $scriptDir "..")).Path
13
- }
14
-
15
- function Write-Step {
16
- param([string]$Message)
17
- Write-Host ""
18
- Write-Host "==> $Message" -ForegroundColor Cyan
19
- }
20
-
21
- function Invoke-Checked {
22
- param(
23
- [string]$FilePath,
24
- [string[]]$Arguments,
25
- [string]$WorkingDirectory = $Root
26
- )
27
- Write-Host "+ $FilePath $($Arguments -join ' ')" -ForegroundColor DarkGray
28
- Push-Location $WorkingDirectory
29
- try {
30
- & $FilePath @Arguments
31
- $exitCode = if ($LASTEXITCODE -is [int]) { $LASTEXITCODE } else { 0 }
32
- } finally {
33
- Pop-Location
34
- }
35
- if ($exitCode -ne 0) {
36
- throw "Command failed with exit code ${exitCode}: $FilePath $($Arguments -join ' ')"
37
- }
38
- }
39
-
40
- function Invoke-HiddenNode {
41
- param([string[]]$Arguments)
42
- Write-Host "+ node $($Arguments -join ' ')" -ForegroundColor DarkGray
43
- Push-Location $Root
44
- try {
45
- & node @Arguments
46
- $exitCode = if ($LASTEXITCODE -is [int]) { $LASTEXITCODE } else { 0 }
47
- } finally {
48
- Pop-Location
49
- }
50
- if ($exitCode -ne 0) {
51
- throw "Command failed with exit code ${exitCode}: node $($Arguments -join ' ')"
52
- }
53
- }
54
-
55
- function Test-CommandExists {
56
- param([string]$Name)
57
- if (-not (Get-Command $Name -ErrorAction SilentlyContinue)) {
58
- throw "Required command not found on PATH: $Name"
59
- }
60
- }
61
-
62
- function Read-WorkItems {
63
- $path = Join-Path $Root "work-items\build-corpus-editor-work-items.json"
64
- if (-not (Test-Path -LiteralPath $path)) {
65
- throw "Missing work-item file: $path"
66
- }
67
- return Get-Content -LiteralPath $path -Raw | ConvertFrom-Json
68
- }
69
-
70
- function Show-Plan {
71
- $items = Read-WorkItems
72
- Write-Host "# $($items.epic.id): $($items.epic.title)"
73
- Write-Host $items.epic.goal
74
- Write-Host ""
75
- $items.work_items | Format-Table id,title,status -AutoSize
76
- }
77
-
78
- function Test-ImplementationShape {
79
- $required = @(
80
- "work-items\build-corpus-editor-work-items.json",
81
- "work-items\build-corpus-editor-implementation-plane.md",
82
- "scripts\run-editor-implementation-plane.ps1",
83
- "build-corpus-editor-plane.cmd"
84
- )
85
- foreach ($rel in $required) {
86
- $path = Join-Path $Root $rel
87
- if (-not (Test-Path -LiteralPath $path)) {
88
- throw "Missing required implementation-plane artifact: $rel"
89
- }
90
- }
91
-
92
- $regenEditor = "C:\Dev\regen-root\packages\editor\src\components\MarkdownEditor.tsx"
93
- if (-not (Test-Path -LiteralPath $regenEditor)) {
94
- throw "Existing source editor not found: $regenEditor"
95
- }
96
-
97
- $package = Get-Content -LiteralPath (Join-Path $Root "package.json") -Raw | ConvertFrom-Json
98
- if (-not $package.bin."build-corpus") {
99
- throw "package.json no longer exposes build-corpus CLI"
100
- }
101
- }
102
-
103
- function Invoke-BaseVerification {
104
- Write-Step "Checking toolchain"
105
- Test-CommandExists "node"
106
- Test-CommandExists "npm"
107
- Test-CommandExists "py"
108
- Invoke-Checked "node" @("--version")
109
- Invoke-Checked "npm" @("--version")
110
- Invoke-Checked "py" @("-3", "--version")
111
-
112
- Write-Step "Checking implementation-plane artifacts"
113
- Test-ImplementationShape
114
-
115
- Write-Step "Running existing CLI smoke"
116
- Invoke-Checked "node" @("bin\build-corpus.js", "--help")
117
- Invoke-Checked "node" @("bin\validate-katex.js", "README.md")
118
-
119
- Write-Step "Running Python unit tests"
120
- $env:PYTHONPATH = Join-Path $Root "src"
121
- Invoke-Checked "py" @("-3", "-m", "unittest", "discover", "-s", "tests", "-p", "test_exporter.py")
122
- }
123
-
124
- function Invoke-InstallVerification {
125
- Invoke-BaseVerification
126
-
127
- Write-Step "Installing current package globally"
128
- Invoke-Checked "npm" @("install", "-g", ".")
129
-
130
- Write-Step "Checking installed command resolution"
131
- Invoke-Checked "where.exe" @("build-corpus")
132
- Invoke-Checked "build-corpus" @("--help")
133
-
134
- Write-Step "Checking existing conversion Explorer verbs"
135
- Invoke-Checked "reg.exe" @("query", "HKCU\Software\Classes\SystemFileAssociations\.docx\shell\BuildCorpusToMarkdown")
136
- Invoke-Checked "reg.exe" @("query", "HKCU\Software\Classes\SystemFileAssociations\.md\shell\BuildCorpusToWord")
137
-
138
- $editorVerb = "HKCU\Software\Classes\SystemFileAssociations\.md\shell\BuildCorpusOpenEditor"
139
- $result = Start-Process -FilePath "reg.exe" -ArgumentList @("query", $editorVerb) -NoNewWindow -Wait -PassThru
140
- if ($result.ExitCode -ne 0) {
141
- throw "Editor open verb is not installed yet. Complete BC-EDITOR-04, then rerun Install mode."
142
- }
143
- }
144
-
145
- function Invoke-SmokeVerification {
146
- Invoke-BaseVerification
147
-
148
- $smokeRoot = Join-Path $Root ".tmp\editor-plane-smoke"
149
- if (Test-Path -LiteralPath $smokeRoot) {
150
- Remove-Item -LiteralPath $smokeRoot -Recurse -Force
151
- }
152
- New-Item -ItemType Directory -Path $smokeRoot | Out-Null
153
-
154
- Write-Step "Creating Markdown fixture"
155
- $md = Join-Path $smokeRoot "sample.md"
156
- Set-Content -LiteralPath $md -Encoding UTF8 -Value @"
157
- # Build Corpus Editor Smoke
158
-
159
- Paragraph with **bold**, *italic*, a [link](https://example.com), and a table.
160
-
161
- | Name | Value |
162
- | --- | --- |
163
- | Alpha | One |
164
- "@
165
-
166
- Write-Step "Exporting Markdown fixture to Word"
167
- Invoke-Checked "node" @("bin\build-corpus.js", $md, "--to", "word", "--out-same-dir")
168
- $docx = Join-Path $smokeRoot "sample.docx"
169
- if (-not (Test-Path -LiteralPath $docx)) {
170
- throw "Expected DOCX output missing: $docx"
171
- }
172
-
173
- Write-Step "Converting generated Word fixture back to Markdown"
174
- $roundTrip = Join-Path $smokeRoot "roundtrip"
175
- Invoke-Checked "node" @("bin\build-corpus.js", $docx, "--out", $roundTrip)
176
- $roundTripMarkdown = Get-ChildItem -LiteralPath $roundTrip -Recurse -Filter "*.md" | Select-Object -First 1
177
- if (-not $roundTripMarkdown) {
178
- throw "Expected reconverted Markdown output missing under $roundTrip"
179
- }
180
-
181
- Write-Step "Checking editor launcher is implemented"
182
- $editorBin = Join-Path $Root "bin\build-corpus-editor.js"
183
- if (-not (Test-Path -LiteralPath $editorBin)) {
184
- throw "Editor launcher is not implemented yet. Complete BC-EDITOR-02, then rerun Smoke mode."
185
- }
186
-
187
- Invoke-HiddenNode @("bin\build-corpus-editor.js", $md, "--no-open", "--self-test")
188
- Invoke-HiddenNode @("bin\build-corpus-editor.js", $docx, "--no-open", "--self-test")
189
- Invoke-HiddenNode @("bin\build-corpus-editor.js", $md, "--document-self-test", "--out", (Join-Path $smokeRoot "md-functional"))
190
- Invoke-HiddenNode @("bin\build-corpus-editor.js", $docx, "--document-self-test", "--out", (Join-Path $smokeRoot "docx-functional"))
191
- Invoke-HiddenNode @("bin\build-corpus-editor.js", $md, "--smoke-ui", "--background")
192
- Invoke-HiddenNode @("bin\build-corpus-editor.js", $docx, "--smoke-ui", "--background")
193
- }
194
-
195
- switch ($Mode) {
196
- "Plan" { Show-Plan }
197
- "Verify" { Invoke-BaseVerification }
198
- "Install" { Invoke-InstallVerification }
199
- "Smoke" { Invoke-SmokeVerification }
200
- }
201
-
202
- Write-Host ""
203
- Write-Host "Build Corpus editor plane $Mode completed." -ForegroundColor Green
1
+ [CmdletBinding()]
2
+ param(
3
+ [ValidateSet("Plan", "Verify", "Install", "Smoke")]
4
+ [string]$Mode = "Verify",
5
+ [string]$Root = ""
6
+ )
7
+
8
+ $ErrorActionPreference = "Stop"
9
+
10
+ if ([string]::IsNullOrWhiteSpace($Root)) {
11
+ $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
12
+ $Root = (Resolve-Path (Join-Path $scriptDir "..")).Path
13
+ }
14
+
15
+ function Write-Step {
16
+ param([string]$Message)
17
+ Write-Host ""
18
+ Write-Host "==> $Message" -ForegroundColor Cyan
19
+ }
20
+
21
+ function Invoke-Checked {
22
+ param(
23
+ [string]$FilePath,
24
+ [string[]]$Arguments,
25
+ [string]$WorkingDirectory = $Root
26
+ )
27
+ Write-Host "+ $FilePath $($Arguments -join ' ')" -ForegroundColor DarkGray
28
+ Push-Location $WorkingDirectory
29
+ try {
30
+ & $FilePath @Arguments
31
+ $exitCode = if ($LASTEXITCODE -is [int]) { $LASTEXITCODE } else { 0 }
32
+ } finally {
33
+ Pop-Location
34
+ }
35
+ if ($exitCode -ne 0) {
36
+ throw "Command failed with exit code ${exitCode}: $FilePath $($Arguments -join ' ')"
37
+ }
38
+ }
39
+
40
+ function Invoke-HiddenNode {
41
+ param([string[]]$Arguments)
42
+ $effectiveArguments = @($Arguments)
43
+ if ($effectiveArguments.Count -gt 0 -and $effectiveArguments[0] -eq "bin\build-corpus-editor.js" -and -not ($effectiveArguments -contains "--background")) {
44
+ $effectiveArguments += "--background"
45
+ }
46
+
47
+ Write-Host "+ node $($effectiveArguments -join ' ')" -ForegroundColor DarkGray
48
+
49
+ $outFile = Join-Path ([System.IO.Path]::GetTempPath()) "regen-mde-hidden-node-out-$([System.Guid]::NewGuid().ToString('N')).log"
50
+ $errFile = Join-Path ([System.IO.Path]::GetTempPath()) "regen-mde-hidden-node-err-$([System.Guid]::NewGuid().ToString('N')).log"
51
+ try {
52
+ $result = Start-Process -FilePath "node" `
53
+ -ArgumentList $effectiveArguments `
54
+ -WorkingDirectory $Root `
55
+ -WindowStyle Hidden `
56
+ -Wait `
57
+ -PassThru `
58
+ -RedirectStandardOutput $outFile `
59
+ -RedirectStandardError $errFile
60
+
61
+ if (Test-Path -LiteralPath $outFile) {
62
+ $stdout = Get-Content -LiteralPath $outFile -Raw
63
+ if (-not [string]::IsNullOrWhiteSpace($stdout)) { Write-Host $stdout.TrimEnd() }
64
+ }
65
+ if (Test-Path -LiteralPath $errFile) {
66
+ $stderr = Get-Content -LiteralPath $errFile -Raw
67
+ if (-not [string]::IsNullOrWhiteSpace($stderr)) { Write-Host $stderr.TrimEnd() -ForegroundColor DarkGray }
68
+ }
69
+ $exitCode = $result.ExitCode
70
+ } finally {
71
+ Remove-Item -LiteralPath $outFile, $errFile -Force -ErrorAction SilentlyContinue
72
+ }
73
+ if ($exitCode -ne 0) {
74
+ throw "Command failed with exit code ${exitCode}: node $($effectiveArguments -join ' ')"
75
+ }
76
+ }
77
+
78
+ function Test-CommandExists {
79
+ param([string]$Name)
80
+ if (-not (Get-Command $Name -ErrorAction SilentlyContinue)) {
81
+ throw "Required command not found on PATH: $Name"
82
+ }
83
+ }
84
+
85
+ function Read-WorkItems {
86
+ $path = Join-Path $Root "work-items\build-corpus-editor-work-items.json"
87
+ if (-not (Test-Path -LiteralPath $path)) {
88
+ throw "Missing work-item file: $path"
89
+ }
90
+ return Get-Content -LiteralPath $path -Raw | ConvertFrom-Json
91
+ }
92
+
93
+ function Show-Plan {
94
+ $items = Read-WorkItems
95
+ Write-Host "# $($items.epic.id): $($items.epic.title)"
96
+ Write-Host $items.epic.goal
97
+ Write-Host ""
98
+ $items.work_items | Format-Table id,title,status -AutoSize
99
+ }
100
+
101
+ function Test-ImplementationShape {
102
+ $required = @(
103
+ "work-items\build-corpus-editor-work-items.json",
104
+ "work-items\build-corpus-editor-implementation-plane.md",
105
+ "scripts\run-editor-implementation-plane.ps1",
106
+ "build-corpus-editor-plane.cmd"
107
+ )
108
+ foreach ($rel in $required) {
109
+ $path = Join-Path $Root $rel
110
+ if (-not (Test-Path -LiteralPath $path)) {
111
+ throw "Missing required implementation-plane artifact: $rel"
112
+ }
113
+ }
114
+
115
+ $regenEditor = "C:\Dev\regen-root\packages\editor\src\components\MarkdownEditor.tsx"
116
+ if (-not (Test-Path -LiteralPath $regenEditor)) {
117
+ throw "Existing source editor not found: $regenEditor"
118
+ }
119
+
120
+ $package = Get-Content -LiteralPath (Join-Path $Root "package.json") -Raw | ConvertFrom-Json
121
+ if (-not $package.bin."build-corpus") {
122
+ throw "package.json no longer exposes build-corpus CLI"
123
+ }
124
+ }
125
+
126
+ function Invoke-BaseVerification {
127
+ Write-Step "Checking toolchain"
128
+ Test-CommandExists "node"
129
+ Test-CommandExists "npm"
130
+ Test-CommandExists "py"
131
+ Invoke-Checked "node" @("--version")
132
+ Invoke-Checked "npm" @("--version")
133
+ Invoke-Checked "py" @("-3", "--version")
134
+
135
+ Write-Step "Checking implementation-plane artifacts"
136
+ Test-ImplementationShape
137
+
138
+ Write-Step "Running existing CLI smoke"
139
+ Invoke-Checked "node" @("bin\build-corpus.js", "--help")
140
+ Invoke-Checked "node" @("bin\validate-katex.js", "README.md")
141
+
142
+ Write-Step "Running Python unit tests"
143
+ $env:PYTHONPATH = Join-Path $Root "src"
144
+ Invoke-Checked "py" @("-3", "-m", "unittest", "discover", "-s", "tests", "-p", "test_exporter.py")
145
+ }
146
+
147
+ function Invoke-InstallVerification {
148
+ Invoke-BaseVerification
149
+
150
+ Write-Step "Installing current package globally"
151
+ Invoke-Checked "npm" @("install", "-g", ".")
152
+
153
+ Write-Step "Checking installed command resolution"
154
+ Invoke-Checked "where.exe" @("build-corpus")
155
+ Invoke-Checked "build-corpus" @("--help")
156
+
157
+ Write-Step "Checking existing conversion Explorer verbs"
158
+ Invoke-Checked "reg.exe" @("query", "HKCU\Software\Classes\SystemFileAssociations\.docx\shell\BuildCorpusToMarkdown")
159
+ Invoke-Checked "reg.exe" @("query", "HKCU\Software\Classes\SystemFileAssociations\.md\shell\BuildCorpusToWord")
160
+
161
+ $editorVerb = "HKCU\Software\Classes\SystemFileAssociations\.md\shell\BuildCorpusOpenEditor"
162
+ $result = Start-Process -FilePath "reg.exe" -ArgumentList @("query", $editorVerb) -NoNewWindow -Wait -PassThru
163
+ if ($result.ExitCode -ne 0) {
164
+ throw "Editor open verb is not installed yet. Complete BC-EDITOR-04, then rerun Install mode."
165
+ }
166
+ }
167
+
168
+ function Invoke-SmokeVerification {
169
+ Invoke-BaseVerification
170
+
171
+ $smokeRoot = Join-Path $Root ".tmp\editor-plane-smoke"
172
+ if (Test-Path -LiteralPath $smokeRoot) {
173
+ Remove-Item -LiteralPath $smokeRoot -Recurse -Force
174
+ }
175
+ New-Item -ItemType Directory -Path $smokeRoot | Out-Null
176
+
177
+ Write-Step "Creating Markdown fixture"
178
+ $md = Join-Path $smokeRoot "sample.md"
179
+ Set-Content -LiteralPath $md -Encoding UTF8 -Value @"
180
+ # Build Corpus Editor Smoke
181
+
182
+ Paragraph with **bold**, *italic*, a [link](https://example.com), and a table.
183
+
184
+ | Name | Value |
185
+ | --- | --- |
186
+ | Alpha | One |
187
+ "@
188
+
189
+ Write-Step "Exporting Markdown fixture to Word"
190
+ Invoke-Checked "node" @("bin\build-corpus.js", $md, "--to", "word", "--out-same-dir")
191
+ $docx = Join-Path $smokeRoot "sample.docx"
192
+ if (-not (Test-Path -LiteralPath $docx)) {
193
+ throw "Expected DOCX output missing: $docx"
194
+ }
195
+
196
+ Write-Step "Converting generated Word fixture back to Markdown"
197
+ $roundTrip = Join-Path $smokeRoot "roundtrip"
198
+ Invoke-Checked "node" @("bin\build-corpus.js", $docx, "--out", $roundTrip)
199
+ $roundTripMarkdown = Get-ChildItem -LiteralPath $roundTrip -Recurse -Filter "*.md" | Select-Object -First 1
200
+ if (-not $roundTripMarkdown) {
201
+ throw "Expected reconverted Markdown output missing under $roundTrip"
202
+ }
203
+
204
+ Write-Step "Checking editor launcher is implemented"
205
+ $editorBin = Join-Path $Root "bin\build-corpus-editor.js"
206
+ if (-not (Test-Path -LiteralPath $editorBin)) {
207
+ throw "Editor launcher is not implemented yet. Complete BC-EDITOR-02, then rerun Smoke mode."
208
+ }
209
+
210
+ Invoke-HiddenNode @("bin\build-corpus-editor.js", $md, "--no-open", "--self-test")
211
+ Invoke-HiddenNode @("bin\build-corpus-editor.js", $docx, "--no-open", "--self-test")
212
+ Invoke-HiddenNode @("bin\build-corpus-editor.js", $md, "--document-self-test", "--out", (Join-Path $smokeRoot "md-functional"))
213
+ Invoke-HiddenNode @("bin\build-corpus-editor.js", $docx, "--document-self-test", "--out", (Join-Path $smokeRoot "docx-functional"))
214
+ Invoke-HiddenNode @("bin\build-corpus-editor.js", $md, "--smoke-ui", "--background")
215
+ Invoke-HiddenNode @("bin\build-corpus-editor.js", $docx, "--smoke-ui", "--background")
216
+ }
217
+
218
+ switch ($Mode) {
219
+ "Plan" { Show-Plan }
220
+ "Verify" { Invoke-BaseVerification }
221
+ "Install" { Invoke-InstallVerification }
222
+ "Smoke" { Invoke-SmokeVerification }
223
+ }
224
+
225
+ Write-Host ""
226
+ Write-Host "Build Corpus editor plane $Mode completed." -ForegroundColor Green
@@ -1,98 +1,98 @@
1
- [CmdletBinding()]
2
- param(
3
- [ValidateSet("Auto", "Conversion", "Editor", "All")]
4
- [string]$Suite = "Auto",
5
- [string]$Root = "",
6
- [switch]$FromGitDiff
7
- )
8
-
9
- $ErrorActionPreference = "Stop"
10
-
11
- if ([string]::IsNullOrWhiteSpace($Root)) {
12
- $Root = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
13
- }
14
-
15
- function Write-Step {
16
- param([string]$Message)
17
- Write-Host ""
18
- Write-Host "==> $Message" -ForegroundColor Cyan
19
- }
20
-
21
- function Invoke-Checked {
22
- param([string]$FilePath, [string[]]$Arguments)
23
- Write-Host "+ $FilePath $($Arguments -join ' ')" -ForegroundColor DarkGray
24
- Push-Location $Root
25
- try {
26
- & $FilePath @Arguments
27
- $exitCode = if ($LASTEXITCODE -is [int]) { $LASTEXITCODE } else { 0 }
28
- } finally {
29
- Pop-Location
30
- }
31
- if ($exitCode -ne 0) {
32
- throw "Command failed with exit code ${exitCode}: $FilePath $($Arguments -join ' ')"
33
- }
34
- }
35
-
36
- function Get-TouchedFiles {
37
- Push-Location $Root
38
- try {
39
- $files = @()
40
- $files += git diff --name-only
41
- $files += git diff --name-only --cached
42
- $files += git ls-files --others --exclude-standard
43
- return $files | Where-Object { $_ } | Sort-Object -Unique
44
- } finally {
45
- Pop-Location
46
- }
47
- }
48
-
49
- function Resolve-Suites {
50
- if ($Suite -eq "All") { return @("Conversion", "Editor") }
51
- if ($Suite -eq "Conversion") { return @("Conversion") }
52
- if ($Suite -eq "Editor") { return @("Editor") }
53
-
54
- $files = Get-TouchedFiles
55
- $conversion = $false
56
- $editor = $false
57
- foreach ($file in $files) {
58
- if ($file -match '^(src/build_corpus/|tests/|tools/|bin/build-corpus\.js|bin/validate-katex\.js|requirements\.txt|pyproject\.toml)') {
59
- $conversion = $true
60
- }
61
- if ($file -match '^(editor-web/|desktop/|installer/|bin/build-corpus-editor\.js|bin/regen-mdeditor-|scripts/build-windows-editor\.ps1|scripts/package-windows-editor\.ps1|scripts/run-editor-implementation-plane\.ps1|package\.json|package-lock\.json)') {
62
- $editor = $true
63
- }
64
- }
65
- if (-not $conversion -and -not $editor) {
66
- $conversion = $true
67
- $editor = $true
68
- }
69
- $resolved = @()
70
- if ($conversion) { $resolved += "Conversion" }
71
- if ($editor) { $resolved += "Editor" }
72
- return $resolved
73
- }
74
-
75
- function Invoke-ConversionSuite {
76
- Write-Step "Conversion suite"
77
- $env:PYTHONPATH = Join-Path $Root "src"
78
- Invoke-Checked "node" @("bin\build-corpus.js", "--help")
79
- Invoke-Checked "node" @("bin\validate-katex.js", "README.md")
80
- Invoke-Checked "py" @("-3", "-m", "unittest", "discover", "-s", "tests", "-p", "test_exporter.py")
81
- Invoke-Checked "py" @("-3", "-m", "unittest", "discover", "-s", "tests", "-p", "test_ppt_exporter.py")
82
- }
83
-
84
- function Invoke-EditorSuite {
85
- Write-Step "Editor suite"
86
- Invoke-Checked "npm" @("run", "editor:windows")
87
- Invoke-Checked "powershell.exe" @("-NoProfile", "-ExecutionPolicy", "Bypass", "-File", "scripts\run-editor-implementation-plane.ps1", "-Mode", "Smoke")
88
- }
89
-
90
- $resolved = Resolve-Suites
91
- Write-Host "Required suites: $($resolved -join ', ')" -ForegroundColor Yellow
92
- foreach ($item in $resolved) {
93
- if ($item -eq "Conversion") { Invoke-ConversionSuite }
94
- if ($item -eq "Editor") { Invoke-EditorSuite }
95
- }
96
-
97
- Write-Host ""
98
- Write-Host "Required test suites passed: $($resolved -join ', ')" -ForegroundColor Green
1
+ [CmdletBinding()]
2
+ param(
3
+ [ValidateSet("Auto", "Conversion", "Editor", "All")]
4
+ [string]$Suite = "Auto",
5
+ [string]$Root = "",
6
+ [switch]$FromGitDiff
7
+ )
8
+
9
+ $ErrorActionPreference = "Stop"
10
+
11
+ if ([string]::IsNullOrWhiteSpace($Root)) {
12
+ $Root = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
13
+ }
14
+
15
+ function Write-Step {
16
+ param([string]$Message)
17
+ Write-Host ""
18
+ Write-Host "==> $Message" -ForegroundColor Cyan
19
+ }
20
+
21
+ function Invoke-Checked {
22
+ param([string]$FilePath, [string[]]$Arguments)
23
+ Write-Host "+ $FilePath $($Arguments -join ' ')" -ForegroundColor DarkGray
24
+ Push-Location $Root
25
+ try {
26
+ & $FilePath @Arguments
27
+ $exitCode = if ($LASTEXITCODE -is [int]) { $LASTEXITCODE } else { 0 }
28
+ } finally {
29
+ Pop-Location
30
+ }
31
+ if ($exitCode -ne 0) {
32
+ throw "Command failed with exit code ${exitCode}: $FilePath $($Arguments -join ' ')"
33
+ }
34
+ }
35
+
36
+ function Get-TouchedFiles {
37
+ Push-Location $Root
38
+ try {
39
+ $files = @()
40
+ $files += git diff --name-only
41
+ $files += git diff --name-only --cached
42
+ $files += git ls-files --others --exclude-standard
43
+ return $files | Where-Object { $_ } | Sort-Object -Unique
44
+ } finally {
45
+ Pop-Location
46
+ }
47
+ }
48
+
49
+ function Resolve-Suites {
50
+ if ($Suite -eq "All") { return @("Conversion", "Editor") }
51
+ if ($Suite -eq "Conversion") { return @("Conversion") }
52
+ if ($Suite -eq "Editor") { return @("Editor") }
53
+
54
+ $files = Get-TouchedFiles
55
+ $conversion = $false
56
+ $editor = $false
57
+ foreach ($file in $files) {
58
+ if ($file -match '^(src/build_corpus/|tests/|tools/|bin/build-corpus\.js|bin/validate-katex\.js|requirements\.txt|pyproject\.toml)') {
59
+ $conversion = $true
60
+ }
61
+ if ($file -match '^(editor-web/|desktop/|installer/|bin/build-corpus-editor\.js|bin/regen-mdeditor-|scripts/build-windows-editor\.ps1|scripts/package-windows-editor\.ps1|scripts/run-editor-implementation-plane\.ps1|package\.json|package-lock\.json)') {
62
+ $editor = $true
63
+ }
64
+ }
65
+ if (-not $conversion -and -not $editor) {
66
+ $conversion = $true
67
+ $editor = $true
68
+ }
69
+ $resolved = @()
70
+ if ($conversion) { $resolved += "Conversion" }
71
+ if ($editor) { $resolved += "Editor" }
72
+ return $resolved
73
+ }
74
+
75
+ function Invoke-ConversionSuite {
76
+ Write-Step "Conversion suite"
77
+ $env:PYTHONPATH = Join-Path $Root "src"
78
+ Invoke-Checked "node" @("bin\build-corpus.js", "--help")
79
+ Invoke-Checked "node" @("bin\validate-katex.js", "README.md")
80
+ Invoke-Checked "py" @("-3", "-m", "unittest", "discover", "-s", "tests", "-p", "test_exporter.py")
81
+ Invoke-Checked "py" @("-3", "-m", "unittest", "discover", "-s", "tests", "-p", "test_ppt_exporter.py")
82
+ }
83
+
84
+ function Invoke-EditorSuite {
85
+ Write-Step "Editor suite"
86
+ Invoke-Checked "npm" @("run", "editor:windows")
87
+ Invoke-Checked "powershell.exe" @("-NoProfile", "-ExecutionPolicy", "Bypass", "-File", "scripts\run-editor-implementation-plane.ps1", "-Mode", "Smoke")
88
+ }
89
+
90
+ $resolved = Resolve-Suites
91
+ Write-Host "Required suites: $($resolved -join ', ')" -ForegroundColor Yellow
92
+ foreach ($item in $resolved) {
93
+ if ($item -eq "Conversion") { Invoke-ConversionSuite }
94
+ if ($item -eq "Editor") { Invoke-EditorSuite }
95
+ }
96
+
97
+ Write-Host ""
98
+ Write-Host "Required test suites passed: $($resolved -join ', ')" -ForegroundColor Green