regen.mde 0.2.2
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.
- package/LICENSE +16 -0
- package/README.md +295 -0
- package/bin/build-corpus-editor.js +81 -0
- package/bin/build-corpus.js +41 -0
- package/bin/postinstall.js +187 -0
- package/bin/regen-mdeditor-install.js +27 -0
- package/bin/regen-mdeditor-uninstall.js +19 -0
- package/bin/validate-katex.js +93 -0
- package/desktop/BuildCorpusEditor/BuildCorpusBridge.cs +270 -0
- package/desktop/BuildCorpusEditor/BuildCorpusEditor.csproj +22 -0
- package/desktop/BuildCorpusEditor/EditorForm.cs +540 -0
- package/desktop/BuildCorpusEditor/Program.cs +81 -0
- package/desktop/BuildCorpusEditor/app.manifest +16 -0
- package/dist/release/regen.mde-0.2.2-win-x64-setup.exe +0 -0
- package/dist/release/regen.mde-0.2.2-win-x64.zip +0 -0
- package/dist/windows-editor/BuildCorpusEditor.deps.json +83 -0
- package/dist/windows-editor/BuildCorpusEditor.dll +0 -0
- package/dist/windows-editor/BuildCorpusEditor.exe +0 -0
- package/dist/windows-editor/BuildCorpusEditor.pdb +0 -0
- package/dist/windows-editor/BuildCorpusEditor.runtimeconfig.json +19 -0
- package/dist/windows-editor/Microsoft.Web.WebView2.Core.dll +0 -0
- package/dist/windows-editor/Microsoft.Web.WebView2.Core.xml +6817 -0
- package/dist/windows-editor/Microsoft.Web.WebView2.WinForms.dll +0 -0
- package/dist/windows-editor/Microsoft.Web.WebView2.WinForms.xml +510 -0
- package/dist/windows-editor/Microsoft.Web.WebView2.Wpf.dll +0 -0
- package/dist/windows-editor/Microsoft.Web.WebView2.Wpf.xml +1902 -0
- package/dist/windows-editor/WebView2Loader.dll +0 -0
- package/dist/windows-editor/runtimes/win-x64/native/WebView2Loader.dll +0 -0
- package/dist/windows-editor/wwwroot/assets/index-DjJ6xmhy.js +326 -0
- package/dist/windows-editor/wwwroot/assets/index-_dwMNNsm.css +1 -0
- package/dist/windows-editor/wwwroot/index.html +22 -0
- package/editor-web/index.html +21 -0
- package/editor-web/src/main.jsx +399 -0
- package/editor-web/src/styles.css +602 -0
- package/editor-web/vite.config.js +13 -0
- package/examples/build-corpus.config.example.json +21 -0
- package/installer/install-regen-mde.ps1 +175 -0
- package/installer/regen-mde.nsi +81 -0
- package/package.json +86 -0
- package/pyproject.toml +33 -0
- package/requirements.txt +4 -0
- package/scripts/build-windows-editor.ps1 +47 -0
- package/scripts/package-windows-editor.ps1 +90 -0
- package/scripts/run-corpus.ps1 +28 -0
- package/scripts/run-editor-implementation-plane.ps1 +203 -0
- package/scripts/run-required-tests.ps1 +98 -0
- package/scripts/run-smoke.ps1 +28 -0
- package/src/build_corpus/__init__.py +3 -0
- package/src/build_corpus/docx_exporter.py +798 -0
- package/src/build_corpus/exporter.py +1195 -0
- package/src/build_corpus/ppt_exporter.py +532 -0
- package/src/build_corpus/templates/__init__.py +1 -0
- package/src/build_corpus/templates/md-to-word-template.dotx +0 -0
- package/src/build_corpus/validate_assets.py +46 -0
- package/tools/audit_corpus.py +203 -0
- package/tools/collect_microsoft_word_templates.py +228 -0
- package/tools/collect_online_docx_corpus.py +272 -0
- package/tools/collect_online_pptx_corpus.py +252 -0
- package/tools/compare_pptx_inputs_outputs.py +87 -0
- package/tools/roundtrip_docx_corpus.py +171 -0
|
@@ -0,0 +1,203 @@
|
|
|
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
|
|
@@ -0,0 +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
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
param(
|
|
2
|
+
[Parameter(Mandatory=$true)]
|
|
3
|
+
[string]$Docx,
|
|
4
|
+
|
|
5
|
+
[string]$Out = ".tmp\smoke",
|
|
6
|
+
|
|
7
|
+
[ValidateSet("assets", "base64", "s3")]
|
|
8
|
+
[string]$Images = "assets",
|
|
9
|
+
|
|
10
|
+
[string]$Config = ""
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
$ErrorActionPreference = "Stop"
|
|
14
|
+
$root = Split-Path -Parent $PSScriptRoot
|
|
15
|
+
$buildCorpus = Join-Path $root "bin\build-corpus.js"
|
|
16
|
+
$katex = Join-Path $root "bin\validate-katex.js"
|
|
17
|
+
$assetValidator = Join-Path $root "src\build_corpus\validate_assets.py"
|
|
18
|
+
|
|
19
|
+
$args = @($buildCorpus, $Docx, "--out", $Out, "--images", $Images)
|
|
20
|
+
if ($Config) {
|
|
21
|
+
$args += @("--config", $Config)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
node @args
|
|
25
|
+
node $katex $Out | Set-Content -Path (Join-Path $Out "katex-report.json") -Encoding UTF8
|
|
26
|
+
py -3 $assetValidator $Out | Set-Content -Path (Join-Path $Out "asset-report.json") -Encoding UTF8
|
|
27
|
+
|
|
28
|
+
Write-Host "Smoke test passed: $Out"
|