feat: add _Template and New-Engine.ps1 for starting new engines

Each engine-building run started from a hand-copied scaffold (Qwen's),
which carried that engine's name and stale notes. _Template holds the
generic scaffold with a __NAME__ placeholder, and New-Engine.ps1 stamps
out a named copy. The template's starter tests go through the
benchmark's NestValidator, so a model gets a real pass/fail target
instead of a plumbing-only check; they were verified to pass against
Opus55.

Directory.Build.props now also detects when it sits in an Engines/
folder inside an OpenNest checkout, so an engine stamped there with
-IncludeBuildFiles builds without passing OpenNestRoot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
aj
2026-09-24 10:10:24 -04:00
co-authored by Claude Opus 5.5
parent cfce484952
commit 70ae0cc155
8 changed files with 352 additions and 3 deletions
+49
View File
@@ -0,0 +1,49 @@
<#
.SYNOPSIS
Creates a new engine project from _Template/.
.DESCRIPTION
Copies _Template/ to <Destination>/OpenNest.Engine.<Name>/ and replaces the __NAME__
placeholder in file names and contents. The new engine builds against OpenNest via
Directory.Build.props, which must sit in <Destination> or a parent folder.
With -IncludeBuildFiles, Directory.Build.props/.targets are copied into <Destination>
too, so the engine can live outside this repo, e.g. in an Engines/ folder inside an
OpenNest checkout (the props detect that layout on their own).
.EXAMPLE
./New-Engine.ps1 -Name Nova
./New-Engine.ps1 -Name Nova -Destination C:/bench/run1/OpenNest/Engines -IncludeBuildFiles
#>
param(
[Parameter(Mandatory)]
[ValidatePattern('^[A-Z][A-Za-z0-9]*$')]
[string]$Name,
[string]$Destination = $PSScriptRoot,
[switch]$IncludeBuildFiles
)
$ErrorActionPreference = 'Stop'
$template = Join-Path $PSScriptRoot '_Template'
$target = Join-Path $Destination "OpenNest.Engine.$Name"
if (Test-Path $target) { throw "'$target' already exists." }
New-Item -ItemType Directory -Force $Destination | Out-Null
Copy-Item $template $target -Recurse
Get-ChildItem $target -Recurse -File | ForEach-Object {
$text = [IO.File]::ReadAllText($_.FullName)
[IO.File]::WriteAllText($_.FullName, $text.Replace('__NAME__', $Name))
}
# Deepest paths first so renaming a folder never invalidates a pending child path.
Get-ChildItem $target -Recurse | Where-Object Name -like '*__NAME__*' |
Sort-Object { $_.FullName.Length } -Descending |
ForEach-Object { Rename-Item $_.FullName $_.Name.Replace('__NAME__', $Name) }
if ($IncludeBuildFiles) {
foreach ($file in 'Directory.Build.props', 'Directory.Build.targets') {
Copy-Item (Join-Path $PSScriptRoot $file) $Destination -Force
}
}
Write-Host "Created $target"