ToonDex creates semantic folder indexes for LLM codebase navigation. It generates an index.toon file with concise summaries of each folder, ordered by importance.
93
Quality
93%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
$ErrorActionPreference = "Stop"
$IndexFile = "index.toon" $StateFile = ".toondex-state" $CooldownHours = 24 $ScoreThreshold = 3
if (Test-Path $StateFile) { try { $State = Get-Content $StateFile | ConvertFrom-Json if ($State.last_proposal) { $LastProposal = [DateTime]::Parse($State.last_proposal) $HoursSince = ((Get-Date) - $LastProposal).TotalHours if ($HoursSince -lt $CooldownHours) { exit 0 # Still in cooldown, skip all git operations } } } catch { # Ignore state file errors } }
if (-not (Test-Path $IndexFile)) { Write-Output "NO_index.toon" exit 0 }
try { $LastRef = git log -1 --format="%H" -- $IndexFile 2>$null } catch { $LastRef = "" }
if ([string]::IsNullOrEmpty($LastRef)) { Write-Output "NO_index.toon" exit 0 }
$Score = 0 $ChangedFiles = @()
try { $ChangedFiles = git diff --name-only "$LastRef..HEAD" 2>$null } catch { exit 0 }
if ($ChangedFiles.Count -eq 0) { exit 0 }
$IndexedFolders = Get-Content $IndexFile | Where-Object { $_ -notmatch "^#" -and $_ -match "," } | ForEach-Object { ($_ -split ",")[0].Trim() }
$NewFolders = @() $ChangedFolderPaths = $ChangedFiles | ForEach-Object { ($_ -split "/")[0..1] -join "/" } | Sort-Object -Unique | Where-Object { $_ -notmatch "^." }
foreach ($folder in $ChangedFolderPaths) { if ((Test-Path $folder -PathType Container) -and ($IndexedFolders -notcontains $folder)) { $NewFolders += $folder $Score += 3 } }
$DeletedFolders = @() foreach ($folder in $IndexedFolders) { if (-not (Test-Path $folder -PathType Container)) { $DeletedFolders += $folder $Score += 3 } }
$ChangedIndexed = @() foreach ($folder in $IndexedFolders) { $FolderChanges = ($ChangedFiles | Where-Object { $_ -match "^$([regex]::Escape($folder))/" }).Count if ($FolderChanges -gt 0) { $ChangedIndexed += "$folder($FolderChanges)" if ($FolderChanges -gt 10) { $Score += 2 } elseif ($FolderChanges -gt 5) { $Score += 1 } } }
try { $IndexDate = git log -1 --format="%ci" -- $IndexFile 2>$null $DaysSince = ((Get-Date) - [DateTime]::Parse($IndexDate)).Days if ($DaysSince -gt 7) { $Score += 1 } } catch { $DaysSince = "unknown" }
if ($Score -ge $ScoreThreshold) { Write-Output "PROPOSE_REDEX" Write-Output "score:$Score" Write-Output "last_indexed:$DaysSince days ago" Write-Output "total_changes:$($ChangedFiles.Count) files" if ($NewFolders.Count -gt 0) { Write-Output "new_folders:$($NewFolders -join ' ')" } if ($DeletedFolders.Count -gt 0) { Write-Output "deleted_folders:$($DeletedFolders -join ' ')" } if ($ChangedIndexed.Count -gt 0) { Write-Output "changed_indexed:$($ChangedIndexed -join ' ')" } }
Install with Tessl CLI
npx tessl i cpoepke/toon-dex@0.3.0