Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e1f21e0
The code snippet provided is a PowerShell script designed to audit a …
aj1126 Jun 30, 2026
ae3e822
fix: Updated drive audit toolkit to support any storage drive and imp…
aj1126 Jun 30, 2026
e93235f
fix: Update RunspacePool initialization in asynchronous engine
aj1126 Jun 30, 2026
b518760
fix(DriveTools.psm1): Add missing function `Clear-DriveToolsStatus`
aj1126 Jun 30, 2026
6a2f507
Invoke-DriveAuditFast | Out-Null # =================================…
aj1126 Jun 30, 2026
120d6f9
fix: Enhance thread safety and logging in Update-DriveHashCache and I…
aj1126 Jun 30, 2026
808a2c8
fix: Update DriveHashCache and Invoke-DriveAuditFast functions to han…
aj1126 Jun 30, 2026
1b9174a
add: System.Data.SQLite.dll
aj1126 Jun 30, 2026
139d0e7
refactor: Remove System.Data.SQLite and SQLite.Interop assemblies
aj1126 Jun 30, 2026
dc3558a
fix: add `AuditEngine` class for processing files
aj1126 Jun 30, 2026
dbcea4c
This commit introduces a new window called `MainWindow.xaml` in the D…
aj1126 Jun 30, 2026
6ea1031
It looks like you have a large PowerShell script that manages various…
aj1126 Jun 30, 2026
97e282c
fix: Update DriveTools.GUI.ps1 to include a cancel button for stoppin…
aj1126 Jun 30, 2026
57c6caf
fix: Update Invoke-AsyncGuiTask to use explicit [Action] block conver…
aj1126 Jun 30, 2026
88edb08
fix: Update asynchronous pipeline handler to use native threading and…
aj1126 Jun 30, 2026
e72ddde
fix: Update Invoke-AsyncGuiTask function to ensure flawless argument …
aj1126 Jun 30, 2026
76020e5
The provided code snippet is an example of a PowerShell script design…
aj1126 Jun 30, 2026
59ad455
The provided script is a PowerShell module named `DriveTools` designe…
aj1126 Jun 30, 2026
8feed08
The provided PowerShell script is a complex application designed for …
aj1126 Jun 30, 2026
88f8871
feat(DriveTools.GUI.ps1): Added advanced details checkbox and output …
aj1126 Jun 30, 2026
230915f
fix: Update DriveTools Core Architecture Test Suite to support mock f…
aj1126 Jun 30, 2026
41a35dd
fix(test): optimize DriveTools.Tests.ps1 for Pester v5+ and Windows P…
aj1126 Jun 30, 2026
3ae1813
fix(tests): update DriveTools.Tests.ps1 for Pester v5.7+ compatibilit…
aj1126 Jun 30, 2026
e653116
feat: Implement dry run functionality in DriveTools.psm1 to enhance s…
aj1126 Jun 30, 2026
71762e6
fix(directive): Converted public fields to auto-properties for seamle…
aj1126 Jun 30, 2026
11611db
Refactor: improve code style and naming
aj1126 Jul 8, 2026
896b4fa
fix: resolve C# compilation failure in PS 5.1 and refactor Pester tes…
aj1126 Jul 8, 2026
0fb2542
docs: update AGENTS.md with C# inline compilation and Pester collecti…
aj1126 Jul 8, 2026
7654a65
fix review feedback from copilot review
Copilot Jul 8, 2026
4157de8
Migrate DriveTools.Tests.ps1 to Pester 5 assertion syntax
Copilot Jul 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .agents/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Negation: use `Should Not BeNullOrEmpty`, `Should Not Throw`, `Should Not Be $null`
- Boolean: use `Should Be $true` or `Should Be $false`
- Comparison: use `Should BeGreaterThan 0`
- Collection Null Checks: Avoid piping empty collections (like `BlockingCollection` or arrays) directly to `Should Not Be $null`. PowerShell unpacks the empty collection to nothing, causing the check to fail. Instead, check using a parenthesized boolean assertion: `($null -ne $Engine.FileQueue) | Should Be $true`.

## 4. Re-Saving UTF-8 with BOM Safely
- **Avoiding Encoding Corruption**: When converting/saving a file to UTF-8 with BOM via PowerShell, ensure you read the file using `-Encoding UTF8` before writing it back. Reading it as ANSI will corrupt existing Unicode glyphs:
Expand Down Expand Up @@ -52,3 +53,14 @@
## 8. Artifact and Workspace File Operations
- **Artifact Directory Bounds**: Always write user-facing reports, plan documents, and walk-throughs in the designated conversation brain directory `C:\Users\ajjuk\.gemini\antigravity\brain\<conversation-id>/` and provide `ArtifactMetadata`.
- **Workspace Files**: Never provide `ArtifactMetadata` when creating or modifying files inside the user's workspace directory (e.g. source files, `.vscode/settings.json`, `.cursorrules`).

## 9. C# Inline Compilation Compatibility (PowerShell 5.1+)
- **C# 5 Syntax Limits**: When defining inline C# class definitions via `Add-Type` in module files, restrict the code syntax to C# 5 or lower. Windows PowerShell 5.1 compiles code using the .NET 4.0 C# compiler, which does not support C# 6+ features (e.g., expression-bodied properties `=>`, string interpolation `$""`, null-conditional operator `?.`).
- **Property Getters**: Use standard explicit getters instead of `=>`:
```csharp
// Correct (C# 5):
public int ProcessedCount { get { return _processedCount; } }

// Incorrect (C# 6):
public int ProcessedCount => _processedCount;
```
90 changes: 90 additions & 0 deletions public/Start-DTAuditGui.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
function Start-DTAuditGui {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)] [string]$ScanPath,
[Parameter(Mandatory = $true)] [string]$CsvLogPath,
[int]$QueueLimit = 10000
)
Comment on lines +1 to +7

# 1. Instantiate the WPF window from file
Add-Type -AssemblyName PresentationFramework, PresentationCore, WindowsBase
$XamlPath = Join-Path $PSScriptRoot "..\src\UI\MainWindow.xaml"
[xml]$XamlContent = Get-Content -Raw -Path $XamlPath
$Reader = [System.Xml.XmlNodeReader]::new($XamlContent)
$Window = [System.Windows.Markup.XamlReader]::Load($Reader)

# 2. Extract UI control references
$StartButton = $Window.FindName("StartButton")
$ProgressBar = $Window.FindName("AuditProgressBar")
$StatusLabel = $Window.FindName("StatusText")
$PathLabel = $Window.FindName("PathText")

$PathLabel.Text = "Target Path: $ScanPath"

# 3. Handle click event via asynchronous worker threads
$StartButton.Add_Click({
$StartButton.IsEnabled = $false

# Instantiate the shared state context using our precompiled C# engine
$Engine = [DriveTools.Core.AuditEngine]::new($QueueLimit, $CsvLogPath)
$LogicalCores = [System.Environment]::ProcessorCount

# Spawn consumer workers to compute hashes in parallel
[System.Threading.Tasks.Task]::Run({
$RunspacePool = [System.Management.Automation.Runspaces.RunspaceFactory]::CreateRunspacePool(1, $LogicalCores + 1)
$RunspacePool.Open()
$ActiveTasks = [System.Collections.Generic.List[object]]::new()

$WorkerBlock = { param([DriveTools.Core.AuditEngine]$EngineInstance) $EngineInstance.StartConsumerWorker() }

for ($i = 0; $i -lt $LogicalCores; $i++) {
$PS = [System.Management.Automation.PowerShell]::Create().AddScript($WorkerBlock).AddArgument($Engine)
$PS.RunspacePool = $RunspacePool
$AsyncResult = $PS.BeginInvoke()
$ActiveTasks.Add([PSCustomObject]@{ Pipeline = $PS; Result = $AsyncResult })
}

# File System Traversal (Producer Loop)
[System.Threading.Tasks.Task]::Run({
try {
$Files = [System.IO.Directory]::EnumerateFiles($ScanPath, "*", [System.IO.SearchOption]::AllDirectories)
foreach ($File in $Files) {
if ([System.IO.File]::GetAttributes($File).HasFlag([System.IO.FileAttributes]::ReparsePoint)) { continue }
$Engine.FileQueue.Add($File)
}
}
finally { $Engine.FileQueue.CompleteAdding() }
})

# 4. Decoupled UI Progress Monitor Loop (Marshals to the UI Thread)
while (-not $Engine.FileQueue.IsCompleted) {
[System.Threading.Thread]::Sleep(250) # Throttles context switches to protect CPU frames

$Processed = $Engine.ProcessedCount
$CurrentPath = $Engine.ActiveFile
$DisplayPath = if ($CurrentPath.Length -gt 55) { "..." + $CurrentPath.Substring($CurrentPath.Length - 52) } else { $CurrentPath }

# Safe cross-thread invocation to avoid Thread Access Exceptions
[System.Windows.Application]::Current.Dispatcher.Invoke([Action]{
$StatusLabel.Text = "Processing Data: $Processed files hashed..."
$PathLabel.Text = "Current Node: $DisplayPath"
})
}

# Clean tear-down of pipeline contexts
foreach ($Task in $ActiveTasks) {
$null = $Task.Pipeline.EndInvoke($Task.Result)
$Task.Pipeline.Dispose()
}
$RunspacePool.Close(); $RunspacePool.Dispose()

[System.Windows.Application]::Current.Dispatcher.Invoke([Action]{
$StatusLabel.Text = "Audit Completed Successfully!"
$ProgressBar.Value = 100
})
})
})

# Render window frame model safely
$null = $Window.ShowDialog()
}
Loading
Loading