From 4a9b76be12ade166dd5dbf1f3e0cc2a3ecdd5a19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 13 Aug 2026 08:53:12 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20chore:=20kb-sync=20post=20hook=20gr?= =?UTF-8?q?eps=20only=20the=20edited=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Domain edits: 227 README greps -> 1 (0.392s -> 0.003s); route sweep only for src/web + lib.rs edits; session sweep unchanged. --- .claude/kb-sync.sh | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/.claude/kb-sync.sh b/.claude/kb-sync.sh index 69c62f8..57763ca 100755 --- a/.claude/kb-sync.sh +++ b/.claude/kb-sync.sh @@ -19,23 +19,32 @@ ingest() { } check() { + # $2 = the single edited src file (post); empty = full sweep (session) # corner-cut: substring match on ".rs" anywhere in README — a module # mentioned outside ## Layout also counts; tighten to the section if it lies + mods="${2:-src/domain/*.rs src/web/*.rs}" + # only domain/web files are ## Layout modules (lib.rs, config.rs, ... are not) + case "$mods" in *src/domain/*.rs|*src/web/*.rs) ;; *) mods="" ;; esac missing="" - for f in src/domain/*.rs src/web/*.rs; do + for f in $mods; do b=$(basename "$f" .rs) [ "$b" = mod ] && continue grep -q "$b\.rs" README.md || missing="$missing $b" done # Route drift: every utoipa path under a lib.rs nest prefix must appear - # backticked in the README ## Endpoints table. + # backticked in the README ## Endpoints table. Only web/ and lib.rs edits can + # introduce drift, so a domain-file edit skips this sweep. routes="" - while read -r prefix mod; do - while read -r p; do - full="$prefix$p"; full="${full%/}" - grep -qF "\`$full\`" README.md || routes="$routes $full" - done < <(grep -oP 'path = "\K[^"]*' "src/web/$mod.rs" 2>/dev/null) - done < <(grep -oP '\.nest\("\K[^"]+", web::\w+' src/lib.rs | sed 's/", web::/ /') + case "${2:-src/lib.rs}" in + *src/web/*.rs|*src/lib.rs) + while read -r prefix mod; do + while read -r p; do + full="$prefix$p"; full="${full%/}" + grep -qF "\`$full\`" README.md || routes="$routes $full" + done < <(grep -oP 'path = "\K[^"]*' "src/web/$mod.rs" 2>/dev/null) + done < <(grep -oP '\.nest\("\K[^"]+", web::\w+' src/lib.rs | sed 's/", web::/ /') + ;; + esac msg="" [ -n "$missing" ] && msg="README.md ## Layout is missing src modules:$missing." [ -n "$routes" ] && msg="$msg README.md ## Endpoints is missing routes:$routes." @@ -53,7 +62,7 @@ case "$1" in fp=$(jq -r '.tool_input.file_path // empty' 2>/dev/null) case "$fp" in */README.md) ingest ;; - */src/*.rs) check PostToolUse ;; + */src/*.rs) check PostToolUse "$fp" ;; esac ;; esac