Скелет проекта
This commit is contained in:
35
scripts/post-commit
Normal file
35
scripts/post-commit
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env sh
|
||||
# Git post-commit hook: index changed files into RAG vector DB for the current story.
|
||||
# Install: cp scripts/post-commit .git/hooks/post-commit && chmod +x .git/hooks/post-commit
|
||||
# Requires: RAG_REPO_PATH, RAG_DB_DSN, RAG_EMBEDDINGS_DIM; story from RAG_STORY or .rag-story or current branch name.
|
||||
|
||||
set -e
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
|
||||
# Resolve story: env RAG_STORY > file .rag-story > current branch name
|
||||
if [ -n "${RAG_STORY}" ]; then
|
||||
STORY="${RAG_STORY}"
|
||||
elif [ -f .rag-story ]; then
|
||||
STORY=$(head -n1 .rag-story | tr -d '\n\r')
|
||||
else
|
||||
STORY=$(git branch --show-current)
|
||||
fi
|
||||
|
||||
if [ -z "$STORY" ]; then
|
||||
echo "post-commit: RAG_STORY or .rag-story or branch name required for indexing."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Run index (changed files only: previous commit -> HEAD)
|
||||
if command -v rag-agent >/dev/null 2>&1; then
|
||||
rag-agent index --changed --base-ref HEAD~1 --head-ref HEAD --story "$STORY"
|
||||
elif [ -n "${VIRTUAL_ENV}" ]; then
|
||||
rag-agent index --changed --base-ref HEAD~1 --head-ref HEAD --story "$STORY"
|
||||
else
|
||||
# Try repo venv or python -m
|
||||
if [ -f "venv/bin/rag-agent" ]; then
|
||||
venv/bin/rag-agent index --changed --base-ref HEAD~1 --head-ref HEAD --story "$STORY"
|
||||
else
|
||||
PYTHONPATH=src python -m rag_agent.cli index --changed --base-ref HEAD~1 --head-ref HEAD --story "$STORY" 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user