a6f05ab2d5
- Phase 0: AGENTS.md cleanup (dedup quotes, renumber sections, merge qmd) - Phase 1: typed relations (manage-relations.py, graph-search.py, check-staleness.py, detect-conflicts.py) - Phase 2: frontmatter validator, weekly lint, knowledge promotion, git hooks - Fix .gitignore to track tools/ and .githooks/ - Fix git remote URL (remove plaintext token) - New wiki pages: 504 pages, 34 raw sources
41 lines
1.4 KiB
PowerShell
41 lines
1.4 KiB
PowerShell
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
$wiki = 'D:\Applications\app\kepano-obsidian-main\wiki'
|
|
$vault = 'D:\Applications\app\kepano-obsidian-main'
|
|
|
|
# Get all available pages in vault
|
|
$allMd = Get-ChildItem -Path $vault -Filter '*.md' -File -Recurse
|
|
$availablePages = @{}
|
|
foreach ($f in $allMd) {
|
|
$bn = $f.BaseName
|
|
$availablePages[$bn] = $true
|
|
# Also register with Chinese characters variations
|
|
}
|
|
|
|
# Scan wiki files for broken links
|
|
$brokenLinks = @()
|
|
$wikiFiles = Get-ChildItem -Path $wiki -Filter '*.md' -File
|
|
|
|
foreach ($f in $wikiFiles) {
|
|
$content = [System.IO.File]::ReadAllText($f.FullName)
|
|
# Match [[Link]] or [[Link|Display]]
|
|
$matches = [regex]::Matches($content, '\[\[([^\]|]+)(?:\|[^\]]+)?\]\]')
|
|
foreach ($m in $matches) {
|
|
$linkTarget = $m.Groups[1].Value.Trim()
|
|
# Skip anchors and external links
|
|
if ($linkTarget -match '^http' -or $linkTarget -match '^#') { continue }
|
|
|
|
if (-not $availablePages.ContainsKey($linkTarget)) {
|
|
$brokenLinks += [PSCustomObject]@{
|
|
File = $f.Name
|
|
BrokenLink = $linkTarget
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($brokenLinks.Count -eq 0) {
|
|
Write-Output "BROKEN_LINKS: 0"
|
|
} else {
|
|
Write-Output "BROKEN_LINKS: $($brokenLinks.Count)"
|
|
$brokenLinks | ForEach-Object { Write-Output "$($_.File) -> [[$($_.BrokenLink)]]" }
|
|
} |