Update prompts

This commit is contained in:
vczh
2026-02-05 15:53:47 -08:00
parent b9ee2b3e22
commit fe2a56d5bf
40 changed files with 1125 additions and 1793 deletions

4
.github/Scripts/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
Build.log
Build.log.unfinished
Execute.log
Execute.log.unfinished

28
.github/Scripts/copilotBuild.ps1 vendored Normal file
View File

@@ -0,0 +1,28 @@
. $PSScriptRoot\copilotShared.ps1
# Remove log files
$logFile = "$PSScriptRoot\Build.log"
$logFileUnfinished = "$logFile.unfinished"
Remove-Item -Path $logFile, $logFileUnfinished -Force -ErrorAction SilentlyContinue
# Find the solution folder by looking for *.sln files
$solutionFolder = GetSolutionDir
$solutionFile = "$solutionFolder\$((Get-ChildItem -Path $solutionFolder -Filter "*.sln" -ErrorAction SilentlyContinue)[0])"
$vsdevcmd = $env:VLPP_VSDEVCMD_PATH
if ($vsdevcmd -eq $null) {
$MESSAGE_1 = "You have to add an environment variable named VLPP_VSDEVCMD_PATH and set its value to the path of VsDevCmd.bat, e.g.:"
$MESSAGE_2 = "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat"
throw "$MESSAGE_1\r\n$MESSAGE_2"
}
# Execute msbuild with output to both console and log file
$Configuration = "Debug"
$Platform = "x64"
$msbuild_arguments = "MSBUILD `"$solutionFile`" /m:8 $rebuildControl /p:Configuration=`"$Configuration`";Platform=`"$Platform`""
$cmd_arguments = "`"`"$vsdevcmd`" & $msbuild_arguments"
$commandLine = "/c $cmd_arguments"
& $env:ComSpec $commandLine 2>&1 | Tee-Object -FilePath $logFileUnfinished
Rename-Item -Path $logFileUnfinished -NewName $logFile -Force
exit $LASTEXITCODE

4
.github/Scripts/copilotDebug_Init.txt vendored Normal file
View File

@@ -0,0 +1,4 @@
.lines
l+s
l+t
.nvload "C:\Program Files\Microsoft Visual Studio\18\Community\Common7\Packages\Debugger\Visualizers\vlpp.natvis"

View File

@@ -0,0 +1,10 @@
param(
[Parameter(Mandatory=$true)]
[string]$Command
)
. $PSScriptRoot\copilotShared.ps1
$cdbpath = GetCDBPath
$commandLine = "echo .remote_exit | `"$($cdbpath)`" -remote npipe:server=.,pipe=VlppUnitTest -clines 0 -c `"$Command`""
echo $commandLine
cmd.exe /S /C $commandLine

27
.github/Scripts/copilotDebug_Start.ps1 vendored Normal file
View File

@@ -0,0 +1,27 @@
param(
[Parameter(Mandatory=$true)]
[string]$Executable
)
. $PSScriptRoot\copilotShared.ps1
# Ensure the executable name has .exe extension
if ($Executable.EndsWith(".exe")) {
throw "\$Executable parameter should not include the .exe extension: $Executable"
}
$executableName = $Executable + ".exe"
# Find the solution folder by looking for *.sln files
$solutionFolder = GetSolutionDir
# Find the file with the latest modification time
$latestFile = GetLatestModifiedExecutable $solutionFolder $executableName
Write-Host "Selected $executableName`: $($latestFile.Path) (Modified: $($latestFile.LastWriteTime))"
# Try to read debug arguments from the corresponding .vcxproj.user file
$debugArgs = GetDebugArgs $solutionFolder $latestFile $Executable
$cdbpath = GetCDBPath
$commandLine = "`"$($cdbpath)`" -server npipe:pipe=VlppUnitTest -cf `"$PSScriptRoot\copilotDebug_Init.txt`" -o `"$($latestFile.Path)`" $debugArgs"
echo $commandLine
cmd.exe /S /C $commandLine

5
.github/Scripts/copilotDebug_Stop.ps1 vendored Normal file
View File

@@ -0,0 +1,5 @@
. $PSScriptRoot\copilotShared.ps1
$cdbpath = GetCDBPath
$commandLine = "`"$($cdbpath)`" -remote npipe:server=.,pipe=VlppUnitTest -clines 0 -c `"qq`""
echo $commandLine
cmd.exe /S /C $commandLine

33
.github/Scripts/copilotExecute.ps1 vendored Normal file
View File

@@ -0,0 +1,33 @@
param(
[Parameter(Mandatory=$true)]
[string]$Executable
)
. $PSScriptRoot\copilotShared.ps1
# Remove log files
$logFile = "$PSScriptRoot\Execute.log"
$logFileUnfinished = "$logFile.unfinished"
Remove-Item -Path $logFile, $logFileUnfinished -Force -ErrorAction SilentlyContinue
# Ensure the executable name has .exe extension
if ($Executable.EndsWith(".exe")) {
throw "\$Executable parameter should not include the .exe extension: $Executable"
}
$executableName = $Executable + ".exe"
# Find the solution folder by looking for *.sln files
$solutionFolder = GetSolutionDir
# Find the file with the latest modification time
$latestFile = GetLatestModifiedExecutable $solutionFolder $executableName
Write-Host "Selected $executableName`: $($latestFile.Path) (Modified: $($latestFile.LastWriteTime))"
# Try to read debug arguments from the corresponding .vcxproj.user file
$debugArgs = GetDebugArgs $solutionFolder $latestFile $Executable
# Execute the selected executable with debug arguments and save output to log file
$commandLine = "`"$($latestFile.Path)`" /C $debugArgs"
& { $commandLine; & cmd.exe /S /C $commandLine 2>&1 } | Tee-Object -FilePath $logFileUnfinished
Rename-Item -Path $logFileUnfinished -NewName $logFile -Force
exit $LASTEXITCODE

87
.github/Scripts/copilotPrepare.ps1 vendored Normal file
View File

@@ -0,0 +1,87 @@
# Prepare Copilot workspace files
param(
[switch]$Backup
)
# Create or override the markdown files with the specified content
$filesToOverride = @{
"Copilot_Planning.md" = "# !!!PLANNING!!!"
"Copilot_Execution.md" = "# !!!EXECUTION!!!"
"Copilot_Task.md" = "# !!!TASK!!!"
}
# Create or override the markdown files with the specified content
$filesToCreate = @{
"Copilot_Scrum.md" = "# !!!SCRUM!!!"
"Copilot_KB.md" = "# !!!KNOWLEDGE BASE!!!"
}
# Backup each markdown file for learning
$filesToBackup = @()
foreach ($file in $filesToOverride.GetEnumerator()) {
$filePath = "$PSScriptRoot\..\TaskLogs\$($file.Key)"
if (Test-Path $filePath) {
$filesToBackup += $filePath
}
}
{
$filePath = "$PSScriptRoot\..\TaskLogs\Copilot_Execution_Finding.md"
if (Test-Path $filePath) {
$filesToBackup += $filePath
}
}
if ($filesToBackup.Count -gt 0) {
$timestamp = Get-Date -Format "yyyy-MM-dd-HH-mm-ss"
$backupFolder = "$PSScriptRoot\..\Learning\$timestamp"
Write-Host "Creating backup folder: $backupFolder"
New-Item -ItemType Directory -Path $backupFolder -Force | Out-Null
foreach ($filePath in $filesToBackup) {
$fileName = Split-Path $filePath -Leaf
$destinationPath = Join-Path $backupFolder $fileName
Write-Host "Backing up $fileName to Learning folder..."
Copy-Item -Path $filePath -Destination $destinationPath -Force
}
}
{
$filePath = "$PSScriptRoot\..\TaskLogs\Copilot_Execution_Finding.md"
if (Test-Path $filePath) {
Write-Host "Deleting Copilot_Execution_Finding.md..."
Remove-Item -Path $filePath -Force
}
}
if ($Backup) {
# Delete all files in $filesToOverride
foreach ($file in $filesToOverride.GetEnumerator()) {
$filePath = "$PSScriptRoot\..\TaskLogs\$($file.Key)"
if (Test-Path $filePath) {
Write-Host "Deleting $($file.Key)..."
Remove-Item -Path $filePath -Force
}
}
} else {
# Create each markdown file with the specified content
foreach ($file in $filesToOverride.GetEnumerator()) {
$filePath = "$PSScriptRoot\..\TaskLogs\$($file.Key)"
Write-Host "Creating/overriding $($file.Key)..."
$file.Value | Out-File -FilePath $filePath -Encoding UTF8
}
# Create files only if they don't exist
foreach ($file in $filesToCreate.GetEnumerator()) {
$filePath = "$PSScriptRoot\..\TaskLogs\$($file.Key)"
if (-not (Test-Path $filePath)) {
Write-Host "Creating $($file.Key)..."
$file.Value | Out-File -FilePath $filePath -Encoding UTF8
} else {
Write-Host "Skipping $($file.Key) (already exists)..."
}
}
}
Write-Host "Copilot preparation completed."

88
.github/Scripts/copilotShared.ps1 vendored Normal file
View File

@@ -0,0 +1,88 @@
function GetCDBPath {
if ($env:CDBPATH -eq $null) {
$MESSAGE_1 = "You have to add an environment variable named CDBPATH and set its value to the path of cdb.exe, e.g.:"
$MESSAGE_2 = "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\cdb.exe"
$MESSAGE_3 = "To get cdb.exe, you need to install WDK via VS Installer (Individual Components page) followed by Windows WDK."
throw "$MESSAGE_1\r\n$MESSAGE_2\r\n$MESSAGE_3"
}
return $env:CDBPATH
}
function GetSolutionDir {
$currentDir = Get-Location
$solutionFolder = $null
while ($currentDir -ne $null) {
$solutionFiles = Get-ChildItem -Path $currentDir.Path -Filter "*.sln" -ErrorAction SilentlyContinue
if ($solutionFiles.Count -gt 0) {
$solutionFolder = $currentDir.Path
Write-Host "Found solution folder: $solutionFolder"
break
}
$currentDir = $currentDir.Parent
}
if ($solutionFolder -eq $null) {
throw "Could not find a solution folder (*.sln file) in current directory or any parent directories."
}
return $solutionFolder
}
function GetLatestModifiedExecutable($solutionFolder, $executableName) {
# Define configuration to path mappings
$configToPathMap = @{
"Debug|Win32" = "$solutionFolder\Debug\$executableName"
"Release|Win32" = "$solutionFolder\Release\$executableName"
"Debug|x64" = "$solutionFolder\x64\Debug\$executableName"
"Release|x64" = "$solutionFolder\x64\Release\$executableName"
}
# Find existing files and get their modification times with configuration info
$existingFiles = @()
foreach ($config in $configToPathMap.Keys) {
$path = $configToPathMap[$config]
if (Test-Path $path) {
$fileInfo = Get-Item $path
$existingFiles += [PSCustomObject]@{
Path = $path
Configuration = $config
LastWriteTime = $fileInfo.LastWriteTime
}
}
}
if ($existingFiles.Count -eq 0) {
throw "No $executableName files found in any of the expected locations."
}
return $existingFiles | Sort-Object LastWriteTime -Descending | Select-Object -First 1
}
function GetDebugArgs($solutionFolder, $latestFile, $executable) {
$userProjectFile = "$solutionFolder\$executable\$executable.vcxproj.user"
if (Test-Path $userProjectFile) {
try {
[xml]$userProjectXml = Get-Content $userProjectFile
$configPlatform = $latestFile.Configuration
if ($configPlatform) {
# Find the PropertyGroup with the matching Condition
$propertyGroup = $userProjectXml.Project.PropertyGroup | Where-Object {
$_.Condition -eq "'`$(Configuration)|`$(Platform)'=='$configPlatform'"
}
if ($propertyGroup -and $propertyGroup.LocalDebuggerCommandArguments) {
$debugArgs = $propertyGroup.LocalDebuggerCommandArguments
Write-Host "Found debug arguments: $debugArgs"
return $debugArgs
}
}
}
catch {
Write-Host "Warning: Could not read debug arguments from $userProjectFile"
}
} else {
Write-Host "Failed to find $userProjectFile"
}
return ""
}