refactor: centralize KB_ROOT import across 39 scripts#6
Merged
Conversation
Each script previously declared its own `const KB_ROOT = join(__dirname, "../knowledge-base")`
(or a project-root variant). With `scripts/lib/kb-root.ts` already on main
(landed in the gate PR), each of these scripts can simply
`import { KB_ROOT } from "./lib/kb-root"` — one source of truth, and the
ZUHN_KB_ROOT env override now applies to every entry point uniformly.
Purely mechanical: 39 files × ±2 lines, no behavior change. The full test
suite has been passing with these imports applied in the working tree all
session (the imports were ALREADY being exercised — this just commits them).
Excluded from this PR (will land separately as ingest-improvements):
- scripts/ingest.ts (also wires the paste handler)
- scripts/lib/ingest/audio.ts (Whisper env-config / Korean-audio fix)
- scripts/lib/ingest/detect.ts + detect.test.ts (paste-type detection)
These four have substantive non-refactor changes belonging in a separate PR.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
gorajing
added a commit
that referenced
this pull request
May 28, 2026
Three coherent, long-pending ingest improvements that grew from the original session work, plus the matching tests. - lib/ingest/paste.ts (+ paste.test.ts) — ingest a local plain-text/markdown file as a "paste" source. Mirrors the pdf.ts pattern: copy the raw, derive the title from the first H1 or filename, write a "paste" source file via generateSourceId/slugify. No `url` field (paste sources have no scrapeable origin; gray-matter can't serialize undefined). - lib/ingest/detect.ts (+ detect.test.ts) — detect local text/markdown files as type "paste" so `npm run ingest <file.txt>` routes through the new paste handler instead of erroring out. - ingest.ts — wire the paste handler into the dispatch. - lib/ingest/audio.ts — Whisper invocation is now ENV-CONFIGURABLE (ZUHN_WHISPER_MODEL, ZUHN_WHISPER_TASK, ZUHN_WHISPER_LANGUAGE) and auto-detects language by default. Fixes a real bug: the previous hardcoded `--model base --language en` confabulated on non-English audio (forcing English on the weakest model produced fluent hallucination + repetition loops on Korean audio). Carries the KB_ROOT-import refactor for these 4 files; the same refactor across the OTHER 39 scripts is in PR #6 — splitting because these 4 also have substantive non-refactor changes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Each script used to declare its own
const KB_ROOT = join(__dirname, ...). Now they allimport { KB_ROOT } from "./lib/kb-root"— the single source of truth that landed on main with the gate PR. Side benefit: theZUHN_KB_ROOTenv override now applies uniformly to every entry point.Purely mechanical: 39 files × ±2 lines, no behavior change. The full suite has been green with these imports applied in the working tree all session — this PR just commits them.
Scope
scripts/ingest.ts(+ paste handler wiring)scripts/lib/ingest/audio.ts(Whisper env-config; fixes the Korean-audio hallucination bug)scripts/lib/ingest/detect.ts+detect.test.ts(paste-type detection)These 4 have substantive non-refactor changes and belong with the untracked
paste.ts/paste.test.tsas their own coherent unit.Test plan
🤖 Generated with Claude Code