diff --git a/Makefile b/Makefile index 9759979..f87baa2 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # ============================================================================= -# Knowledge Genome - Makefile v. 1.6.2 +# Knowledge Genome - Makefile v. 1.6.3 # Orchestrates the setup and management of the knowledge base. # ============================================================================= diff --git a/deploy/vm101/n8n-pi-wrap b/deploy/vm101/n8n-pi-wrap index 1b9f629..7fc5484 100755 --- a/deploy/vm101/n8n-pi-wrap +++ b/deploy/vm101/n8n-pi-wrap @@ -58,6 +58,32 @@ case "$cmd" in # MECHANICAL step: validate manifest -> index/log/scoped-lint/commit/PR -> 1 JSON line exec "${HOME}/.pi/agent/skills/ingest/scripts/run-ingest.sh" "${genome}" ;; + "pi changed-raw "*) + # List raw/ files changed between two commits, one per line (the webhook payload + # does NOT include file lists, so vm101's checkout computes the diff itself). + rest="${cmd#pi changed-raw }" + genome="${rest%% *}" + range="${rest#* }" + before="${range%% *}" + after="${range#* }" + case "$genome" in ""|*[!a-z0-9-]*) echo '{"status":"error","reason":"invalid genome name"}'; exit 1;; esac + case "$before$after" in *[!a-f0-9]*|"") echo '{"status":"error","reason":"invalid commit range"}'; exit 1;; esac + logger -t n8n-pi-wrap "ok: pi changed-raw ${genome} ${before}..${after}" + set -a; . "${HOME}/.config/knowledge-genome.env"; set +a + cd "${GENOMES_ROOT}/${genome}" 2>/dev/null || { echo '{"status":"error","reason":"unknown genome"}'; exit 1; } + git fetch -q origin + # changed/added raw files (exclude deletions: nothing to ingest), only under raw/, skip Syncthing infra + files="$(git diff --name-only --diff-filter=d "${before}" "${after}" -- raw/ 2>/dev/null \ + | grep -vE '(^|/)\.st(folder|ignore)' || true)" + # emit a JSON array via jq (safe escaping) + printf '%s\n' "$files" | grep -c . >/dev/null 2>&1 || files="" + if [ -z "$files" ]; then + echo '{"status":"ok","genome":"'"$genome"'","count":0,"files":[]}' + else + printf '%s\n' "$files" | jq -R . | jq -s \ + --arg g "$genome" '{status:"ok", genome:$g, count:length, files:.}' + fi + ;; "ollama list") logger -t n8n-pi-wrap "ok: ollama list" exec /usr/local/bin/ollama list