fix(kilo-docs): normalize source link extraction on Windows

This commit is contained in:
Alex Alecu
2026-04-29 14:14:32 +03:00
parent 02adfec4ad
commit 3e3ec93991
+12 -3
View File
@@ -98,12 +98,18 @@ function shouldSkipFile(filepath: string): boolean {
if (/\.test\.[jt]sx?$/.test(filepath)) return true
if (/\.spec\.[jt]sx?$/.test(filepath)) return true
if (/\.stories\.[jt]sx?$/.test(filepath)) return true
if (/\/i18n\//.test(filepath) && !filepath.endsWith("en.ts")) return true
if (parts.includes("i18n") && path.basename(filepath) !== "en.ts") return true // kilocode_change
const basename = path.basename(filepath)
if (SKIP_FILES.includes(basename)) return true
return false
}
// kilocode_change start
function source(filepath: string): string {
return path.relative(ROOT, filepath).replaceAll(path.sep, "/")
}
// kilocode_change end
function clean(url: string): string {
return url.replace(/[.),:;]+$/, "").replace(/<\/?\w+>$/, "")
}
@@ -115,16 +121,19 @@ async function extract(): Promise<Map<string, Set<string>>> {
for (const ext of EXTENSIONS) {
const glob = new Glob(`**/*.${ext}`)
for await (const entry of glob.scan({ cwd: dir, absolute: true })) {
if (shouldSkipFile(entry)) continue
// kilocode_change start
const file = source(entry)
if (shouldSkipFile(file)) continue
const content = await Bun.file(entry).text()
for (const line of content.split("\n")) {
for (const match of line.matchAll(URL_RE)) {
const url = clean(match[0])
if (shouldExclude(url)) continue
if (!links.has(url)) links.set(url, new Set())
links.get(url)!.add(path.relative(ROOT, entry))
links.get(url)!.add(file)
}
}
// kilocode_change end
}
}
}