claude-flow-novice 2.18.21 → 2.18.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/cfn-scripts/check-memory.sh +150 -0
- package/.claude/cfn-scripts/run-with-memory-limit.sh +91 -0
- package/.claude/hooks/README.md +148 -148
- package/.claude/hooks/{SessionStart:cfn-load-openai-key.sh → SessionStart-cfn-load-openai-key.sh} +35 -35
- package/.claude/hooks/SessionStart:cfn-build-ruvector.sh +28 -28
- package/.claude/hooks/cfn-bash-search-hook.sh +87 -0
- package/.claude/hooks/cfn-smart-search-hook.sh +127 -0
- package/.claude/hooks/post-commit-codebase-index +79 -45
- package/.claude/settings.json +14 -3
- package/.claude/skills/cfn-edit-safety/lib/hooks/security-scanner.sh +1 -0
- package/.claude/skills/cfn-local-ruvector-accelerator/cfn-integration.sh +47 -6
- package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/index.rs +6 -3
- package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/init.rs +3 -3
- package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/query.rs +1 -1
- package/.claude/skills/cfn-local-ruvector-accelerator/src/lib.rs +1 -0
- package/.claude/skills/cfn-local-ruvector-accelerator/src/paths.rs +4 -2
- package/.claude/skills/cfn-local-ruvector-accelerator/src/search_engine.rs +11 -0
- package/.claude/skills/cfn-local-ruvector-accelerator/test_query_api.sh +102 -102
- package/CLAUDE.md +32 -4
- package/package.json +9 -5
- package/scripts/organize-root-files.sh +340 -340
- package/scripts/postinstall.js +120 -3
- package/test-epic-creator-security.sh +202 -202
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
INPUT=$(timeout 1 cat || echo "{}")
|
|
5
|
+
CMD=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
|
|
6
|
+
|
|
7
|
+
log() { echo "[$(date '+%H:%M:%S')] $*" >> /tmp/ruvector-bash-hook.log; }
|
|
8
|
+
|
|
9
|
+
# Load API key from .env if not set
|
|
10
|
+
load_api_key() {
|
|
11
|
+
if [[ -n "${OPENAI_API_KEY:-}" ]] && [[ "${OPENAI_API_KEY:-}" != "your_"* ]]; then
|
|
12
|
+
return 0
|
|
13
|
+
fi
|
|
14
|
+
local env_file="${CLAUDE_PROJECT_DIR:-.}/.env"
|
|
15
|
+
if [[ -f "$env_file" ]]; then
|
|
16
|
+
local key=$(grep "^OPENAI_API_KEY=" "$env_file" 2>/dev/null | cut -d= -f2- | tr -d '"' | tr -d "'" || true)
|
|
17
|
+
if [[ -n "$key" ]] && [[ "$key" != "your_"* ]]; then
|
|
18
|
+
export OPENAI_API_KEY="$key"
|
|
19
|
+
return 0
|
|
20
|
+
fi
|
|
21
|
+
fi
|
|
22
|
+
return 1
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
log "Bash hook: $CMD"
|
|
26
|
+
|
|
27
|
+
if echo "$CMD" | grep -qE "find\s+/mnt/c"; then
|
|
28
|
+
echo "🔴 BLOCKED: find on /mnt/c forbidden (memory leak). Use Glob tool instead." >&2
|
|
29
|
+
exit 2
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
if ! echo "$CMD" | grep -qiE "^\s*(grep|rg|find)\s|[|&;]\s*(grep|rg|find)\s"; then
|
|
33
|
+
exit 0
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
PATTERN=""
|
|
37
|
+
|
|
38
|
+
PATTERN=$(echo "$CMD" | grep -oE '(grep|rg)\s+[^|]+' | grep -oE '"[^"]+"' | head -1 | tr -d '"' || true)
|
|
39
|
+
|
|
40
|
+
if [ -z "$PATTERN" ]; then
|
|
41
|
+
PATTERN=$(echo "$CMD" | grep -oE "(grep|rg)\s+(-[a-zA-Z]+\s+)*([a-zA-Z_][a-zA-Z0-9_]*)" | awk '{print $NF}' || true)
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
if [ -z "$PATTERN" ]; then
|
|
45
|
+
PATTERN=$(echo "$CMD" | grep -oE '\-name\s+"[^"]+"' | sed 's/-name\s*"//' | tr -d '"' || true)
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
if [ -z "$PATTERN" ] || [ ${#PATTERN} -lt 3 ] || [[ "$PATTERN" == -* ]]; then
|
|
49
|
+
exit 0
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
DB_PATH="$HOME/.local/share/ruvector/index_v2.db"
|
|
53
|
+
PROJECT_ROOT="${CLAUDE_PROJECT_DIR:-$(pwd)}"
|
|
54
|
+
|
|
55
|
+
CONTEXT=""
|
|
56
|
+
|
|
57
|
+
# Try SQL first (fast, no API key)
|
|
58
|
+
if [ -f "$DB_PATH" ]; then
|
|
59
|
+
SAFE_PATTERN=$(echo "$PATTERN" | sed "s/'/''/g")
|
|
60
|
+
SAFE_ROOT=$(echo "$PROJECT_ROOT" | sed "s/'/''/g")
|
|
61
|
+
|
|
62
|
+
RESULTS=$(timeout 3 sqlite3 -separator ':' "$DB_PATH" \
|
|
63
|
+
"SELECT REPLACE(file_path, '$SAFE_ROOT/', ''), line_number, name FROM entities WHERE project_root = '$SAFE_ROOT' AND (name LIKE '%${SAFE_PATTERN}%' OR file_path LIKE '%${SAFE_PATTERN}%') LIMIT 6" 2>/dev/null || true)
|
|
64
|
+
|
|
65
|
+
if [ -n "$RESULTS" ]; then
|
|
66
|
+
CONTEXT="RuVector indexed matches for '$PATTERN':\n$RESULTS"
|
|
67
|
+
log "SQL context injected for: $PATTERN"
|
|
68
|
+
fi
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
# Fallback to semantic search if SQL found nothing
|
|
72
|
+
if [ -z "$CONTEXT" ] && command -v local-ruvector >/dev/null 2>&1; then
|
|
73
|
+
if load_api_key; then
|
|
74
|
+
log "SQL returned nothing, trying semantic search for: $PATTERN"
|
|
75
|
+
SEMANTIC=$(timeout 5 local-ruvector query "$PATTERN" --max-results 5 --threshold 0.3 2>/dev/null | sed 's/\x1b\[[0-9;]*m//g' | grep -v "^$" | grep -v "INFO\|ERROR\|WARN" | head -6 || true)
|
|
76
|
+
if [ -n "$SEMANTIC" ]; then
|
|
77
|
+
CONTEXT="RuVector semantic matches for '$PATTERN':\n$SEMANTIC"
|
|
78
|
+
log "Semantic context injected for: $PATTERN"
|
|
79
|
+
fi
|
|
80
|
+
fi
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
if [ -n "$CONTEXT" ]; then
|
|
84
|
+
echo "{\"additionalContext\":\"$CONTEXT\"}"
|
|
85
|
+
fi
|
|
86
|
+
|
|
87
|
+
exit 0
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
exec 2>/tmp/ruvector-search-hook.log
|
|
4
|
+
|
|
5
|
+
INPUT=$(timeout 1 cat || echo "{}")
|
|
6
|
+
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // empty')
|
|
7
|
+
PATTERN=$(echo "$INPUT" | jq -r '.tool_input.pattern // empty')
|
|
8
|
+
|
|
9
|
+
log() {
|
|
10
|
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" >> /tmp/ruvector-search-hook.log
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
# Load API key from .env if not set
|
|
14
|
+
load_api_key() {
|
|
15
|
+
if [[ -n "${OPENAI_API_KEY:-}" ]] && [[ "${OPENAI_API_KEY:-}" != "your_"* ]]; then
|
|
16
|
+
return 0
|
|
17
|
+
fi
|
|
18
|
+
local env_file="${CLAUDE_PROJECT_DIR:-.}/.env"
|
|
19
|
+
if [[ -f "$env_file" ]]; then
|
|
20
|
+
local key=$(grep "^OPENAI_API_KEY=" "$env_file" 2>/dev/null | cut -d= -f2- | tr -d '"' | tr -d "'" || true)
|
|
21
|
+
if [[ -n "$key" ]] && [[ "$key" != "your_"* ]]; then
|
|
22
|
+
export OPENAI_API_KEY="$key"
|
|
23
|
+
log "Loaded OPENAI_API_KEY from .env"
|
|
24
|
+
return 0
|
|
25
|
+
fi
|
|
26
|
+
fi
|
|
27
|
+
return 1
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
log "Hook triggered: tool=$TOOL_NAME pattern='$PATTERN'"
|
|
31
|
+
|
|
32
|
+
# Skip if no pattern or tool not Grep/Glob
|
|
33
|
+
if [[ -z "$PATTERN" || -z "$TOOL_NAME" ]]; then
|
|
34
|
+
log "Missing pattern or tool name, exiting"
|
|
35
|
+
exit 0
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
# Skip conditions
|
|
39
|
+
if [[ ${#PATTERN} -lt 3 ]]; then
|
|
40
|
+
log "Pattern too short, skipping"
|
|
41
|
+
exit 0
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
# Skip glob patterns (file discovery, not semantic)
|
|
45
|
+
if [[ "$PATTERN" == *"*"* ]] || [[ "$PATTERN" == *"?"* ]] || [[ "$PATTERN" == *"["* ]]; then
|
|
46
|
+
log "Pattern looks like glob, skipping"
|
|
47
|
+
exit 0
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
# Skip exact paths (contains / and . extension)
|
|
51
|
+
if [[ "$PATTERN" == *"/"* ]] && [[ "$PATTERN" == *"."* ]]; then
|
|
52
|
+
log "Pattern looks like exact path, skipping"
|
|
53
|
+
exit 0
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
CONTEXT=""
|
|
57
|
+
UNCOMMITTED=""
|
|
58
|
+
|
|
59
|
+
# Check uncommitted files
|
|
60
|
+
if command -v git >/dev/null 2>&1; then
|
|
61
|
+
UNCOMMITTED=$(timeout 2 git diff --name-only HEAD 2>/dev/null | grep -i "$PATTERN" || true)
|
|
62
|
+
if [[ -n "$UNCOMMITTED" ]]; then
|
|
63
|
+
log "Found uncommitted matches"
|
|
64
|
+
CONTEXT="Uncommitted files matching pattern:
|
|
65
|
+
$UNCOMMITTED
|
|
66
|
+
|
|
67
|
+
"
|
|
68
|
+
fi
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
# Query RuVector V2 SQL first (no API key needed)
|
|
72
|
+
RUVECTOR_RESULTS=""
|
|
73
|
+
DB_PATH="$HOME/.local/share/ruvector/index_v2.db"
|
|
74
|
+
PROJECT_ROOT="${CLAUDE_PROJECT_DIR:-$(pwd)}"
|
|
75
|
+
if [[ -f "$DB_PATH" ]]; then
|
|
76
|
+
log "Querying RuVector SQL for: $PATTERN (project: $PROJECT_ROOT)"
|
|
77
|
+
# Escape pattern for SQL LIKE
|
|
78
|
+
SAFE_PATTERN=$(echo "$PATTERN" | sed "s/'/''/g")
|
|
79
|
+
SAFE_ROOT=$(echo "$PROJECT_ROOT" | sed "s/'/''/g")
|
|
80
|
+
RUVECTOR_RESULTS=$(timeout 3 sqlite3 -separator ':' "$DB_PATH" \
|
|
81
|
+
"SELECT REPLACE(file_path, '$SAFE_ROOT/', ''), line_number, name FROM entities WHERE project_root = '$SAFE_ROOT' AND (name LIKE '%${SAFE_PATTERN}%' OR file_path LIKE '%${SAFE_PATTERN}%') LIMIT 8" 2>/dev/null | head -10 || true)
|
|
82
|
+
if [[ -n "$RUVECTOR_RESULTS" ]]; then
|
|
83
|
+
log "RuVector SQL returned results"
|
|
84
|
+
CONTEXT="${CONTEXT}RuVector indexed matches for '$PATTERN':
|
|
85
|
+
$RUVECTOR_RESULTS
|
|
86
|
+
|
|
87
|
+
"
|
|
88
|
+
fi
|
|
89
|
+
else
|
|
90
|
+
log "RuVector index not found at $DB_PATH"
|
|
91
|
+
fi
|
|
92
|
+
|
|
93
|
+
# Fallback to semantic search if SQL found nothing and API key available
|
|
94
|
+
if [[ -z "$RUVECTOR_RESULTS" ]] && command -v local-ruvector >/dev/null 2>&1; then
|
|
95
|
+
if load_api_key; then
|
|
96
|
+
log "SQL returned nothing, trying semantic search for: $PATTERN"
|
|
97
|
+
# Strip ANSI codes from output
|
|
98
|
+
SEMANTIC_RESULTS=$(timeout 5 local-ruvector query "$PATTERN" --max-results 5 --threshold 0.3 2>/dev/null | sed 's/\x1b\[[0-9;]*m//g' | grep -v "^$" | grep -v "INFO\|ERROR\|WARN" | head -8 || true)
|
|
99
|
+
if [[ -n "$SEMANTIC_RESULTS" ]]; then
|
|
100
|
+
log "Semantic search returned results"
|
|
101
|
+
CONTEXT="${CONTEXT}RuVector semantic matches for '$PATTERN':
|
|
102
|
+
$SEMANTIC_RESULTS
|
|
103
|
+
|
|
104
|
+
"
|
|
105
|
+
else
|
|
106
|
+
log "Semantic search returned no results"
|
|
107
|
+
fi
|
|
108
|
+
else
|
|
109
|
+
log "No API key available for semantic search"
|
|
110
|
+
fi
|
|
111
|
+
fi
|
|
112
|
+
|
|
113
|
+
# Output context if we have any
|
|
114
|
+
if [[ -n "$CONTEXT" ]]; then
|
|
115
|
+
# Try JSON output first
|
|
116
|
+
if command -v jq >/dev/null 2>&1; then
|
|
117
|
+
echo "$INPUT" | jq --arg context "$CONTEXT" '. + {additionalContext: $context}'
|
|
118
|
+
else
|
|
119
|
+
# Fallback to plain text
|
|
120
|
+
echo "$CONTEXT"
|
|
121
|
+
fi
|
|
122
|
+
log "Context injected successfully"
|
|
123
|
+
else
|
|
124
|
+
log "No additional context found"
|
|
125
|
+
fi
|
|
126
|
+
|
|
127
|
+
exit 0
|
|
@@ -1,75 +1,109 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
# Post-commit hook
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
# Install: ln -s ../../.claude/hooks/post-commit-codebase-index .git/hooks/post-commit
|
|
2
|
+
# Post-commit hook - incremental RuVector indexing
|
|
3
|
+
# Handles: Added, Modified, Deleted, and Renamed files
|
|
4
|
+
# Symlink: ln -sf ../../.claude/hooks/post-commit-codebase-index .git/hooks/post-commit
|
|
6
5
|
|
|
7
6
|
set -euo pipefail
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
# Config
|
|
9
|
+
INDEXABLE_EXT="ts|tsx|js|jsx|rs|py|sh|md"
|
|
10
|
+
LOG_FILE="/tmp/ruvector-post-commit.log"
|
|
11
|
+
DB_PATH="$HOME/.local/share/ruvector/index_v2.db"
|
|
12
|
+
PROJECT_ROOT="$(pwd)"
|
|
12
13
|
|
|
13
14
|
# Colors
|
|
14
15
|
BLUE='\033[0;34m'
|
|
15
16
|
GREEN='\033[0;32m'
|
|
16
17
|
YELLOW='\033[1;33m'
|
|
18
|
+
RED='\033[0;31m'
|
|
17
19
|
NC='\033[0m'
|
|
18
20
|
|
|
19
|
-
echo -e "${BLUE}[RuVector]${NC}
|
|
21
|
+
log() { echo -e "${BLUE}[RuVector]${NC} $1" | tee -a "$LOG_FILE"; }
|
|
22
|
+
log_success() { echo -e "${GREEN}[RuVector]${NC} $1" | tee -a "$LOG_FILE"; }
|
|
23
|
+
log_warn() { echo -e "${YELLOW}[RuVector]${NC} $1" | tee -a "$LOG_FILE"; }
|
|
20
24
|
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
# Find ruvector binary
|
|
26
|
+
RUVECTOR_BIN="${RUVECTOR_BIN:-}"
|
|
27
|
+
[ -z "$RUVECTOR_BIN" ] && command -v local-ruvector >/dev/null && RUVECTOR_BIN="local-ruvector"
|
|
28
|
+
[ -z "$RUVECTOR_BIN" ] && [ -x "$HOME/.local/bin/local-ruvector" ] && RUVECTOR_BIN="$HOME/.local/bin/local-ruvector"
|
|
29
|
+
|
|
30
|
+
# Check if binary exists
|
|
31
|
+
if [ -z "$RUVECTOR_BIN" ]; then
|
|
32
|
+
log_warn "local-ruvector binary not found"
|
|
24
33
|
exit 0
|
|
25
34
|
fi
|
|
26
35
|
|
|
27
|
-
# Check if
|
|
28
|
-
if [
|
|
29
|
-
|
|
36
|
+
# Check if auto-index is enabled
|
|
37
|
+
if [ "${RUVECTOR_AUTO_INDEX:-true}" != "true" ]; then
|
|
38
|
+
log_warn "Auto-indexing disabled"
|
|
30
39
|
exit 0
|
|
31
40
|
fi
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
echo -e "${BLUE}[RuVector]${NC} Checking for file moves..."
|
|
35
|
-
"$MOVE_HANDLER" --from-commit 2>&1 | tee -a /tmp/ruvector-moves.log
|
|
42
|
+
log "Checking committed files..."
|
|
36
43
|
|
|
37
|
-
#
|
|
38
|
-
|
|
44
|
+
# === Handle DELETED files (D) ===
|
|
45
|
+
DELETED_FILES=$(git diff-tree --no-commit-id --name-only --diff-filter=D -r HEAD 2>/dev/null || true)
|
|
46
|
+
DELETED_INDEXABLE=$(echo "$DELETED_FILES" | grep -E "\.($INDEXABLE_EXT)$" || true)
|
|
39
47
|
|
|
40
|
-
if [[ -
|
|
41
|
-
echo
|
|
42
|
-
|
|
43
|
-
fi
|
|
48
|
+
if [ -n "$DELETED_INDEXABLE" ] && [ -f "$DB_PATH" ]; then
|
|
49
|
+
DELETE_COUNT=$(echo "$DELETED_INDEXABLE" | grep -c . || echo 0)
|
|
50
|
+
log "Removing $DELETE_COUNT deleted file(s) from index..."
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
while IFS= read -r file; do
|
|
53
|
+
[ -z "$file" ] && continue
|
|
54
|
+
FULL_PATH="$PROJECT_ROOT/$file"
|
|
55
|
+
# Escape single quotes for SQL
|
|
56
|
+
SAFE_PATH=$(echo "$FULL_PATH" | sed "s/'/''/g")
|
|
57
|
+
sqlite3 "$DB_PATH" "DELETE FROM entities WHERE file_path = '$SAFE_PATH';" 2>/dev/null || true
|
|
58
|
+
echo " Removed: $file" >> "$LOG_FILE"
|
|
59
|
+
done <<< "$DELETED_INDEXABLE"
|
|
60
|
+
|
|
61
|
+
log_success "Removed $DELETE_COUNT deleted file(s) from index"
|
|
62
|
+
fi
|
|
48
63
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
# === Handle RENAMED files (R) ===
|
|
65
|
+
# Git shows renames as: R100\told_path\tnew_path
|
|
66
|
+
RENAMED_FILES=$(git diff-tree --no-commit-id -r -M --diff-filter=R HEAD 2>/dev/null | awk '{print $6 "\t" $7}' || true)
|
|
67
|
+
|
|
68
|
+
if [ -n "$RENAMED_FILES" ] && [ -f "$DB_PATH" ]; then
|
|
69
|
+
RENAME_COUNT=$(echo "$RENAMED_FILES" | grep -c . || echo 0)
|
|
70
|
+
log "Updating $RENAME_COUNT renamed file(s) in index..."
|
|
71
|
+
|
|
72
|
+
while IFS=$'\t' read -r old_path new_path; do
|
|
73
|
+
[ -z "$old_path" ] || [ -z "$new_path" ] && continue
|
|
74
|
+
# Only process indexable file types
|
|
75
|
+
if echo "$new_path" | grep -qE "\.($INDEXABLE_EXT)$"; then
|
|
76
|
+
OLD_FULL="$PROJECT_ROOT/$old_path"
|
|
77
|
+
NEW_FULL="$PROJECT_ROOT/$new_path"
|
|
78
|
+
SAFE_OLD=$(echo "$OLD_FULL" | sed "s/'/''/g")
|
|
79
|
+
SAFE_NEW=$(echo "$NEW_FULL" | sed "s/'/''/g")
|
|
80
|
+
sqlite3 "$DB_PATH" "UPDATE entities SET file_path = '$SAFE_NEW' WHERE file_path = '$SAFE_OLD';" 2>/dev/null || true
|
|
81
|
+
echo " Renamed: $old_path -> $new_path" >> "$LOG_FILE"
|
|
55
82
|
fi
|
|
56
|
-
|
|
57
|
-
done <<< "$COMMITTED_FILES"
|
|
83
|
+
done <<< "$RENAMED_FILES"
|
|
58
84
|
|
|
59
|
-
|
|
60
|
-
|
|
85
|
+
log_success "Updated $RENAME_COUNT renamed file(s) in index"
|
|
86
|
+
fi
|
|
87
|
+
|
|
88
|
+
# === Handle ADDED and MODIFIED files (AM) ===
|
|
89
|
+
# Check for API key (only needed for indexing new/modified files)
|
|
90
|
+
if [ -z "${OPENAI_API_KEY:-}" ] && [ -z "${ZAI_API_KEY:-}" ]; then
|
|
91
|
+
log_warn "No API key found - skipping new file indexing"
|
|
61
92
|
exit 0
|
|
62
93
|
fi
|
|
63
94
|
|
|
64
|
-
|
|
95
|
+
FILES=$(git diff-tree --no-commit-id --name-only --diff-filter=AM -r HEAD 2>/dev/null || true)
|
|
96
|
+
INDEXABLE_FILES=$(echo "$FILES" | grep -E "\.($INDEXABLE_EXT)$" || true)
|
|
65
97
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
) &
|
|
98
|
+
if [ -z "$INDEXABLE_FILES" ]; then
|
|
99
|
+
log "No new/modified indexable files"
|
|
100
|
+
exit 0
|
|
101
|
+
fi
|
|
71
102
|
|
|
72
|
-
|
|
73
|
-
|
|
103
|
+
FILE_COUNT=$(echo "$INDEXABLE_FILES" | grep -c . || echo 0)
|
|
104
|
+
log "$FILE_COUNT file(s) added/modified, triggering incremental index..."
|
|
105
|
+
echo "$INDEXABLE_FILES" >> "$LOG_FILE"
|
|
106
|
+
nohup bash -c "$RUVECTOR_BIN index --path . >> '$LOG_FILE' 2>&1 && echo '[RuVector] Index updated' >> '$LOG_FILE'" >/dev/null 2>&1 &
|
|
107
|
+
log "Indexing started in background (log: $LOG_FILE)"
|
|
74
108
|
|
|
75
|
-
exit 0
|
|
109
|
+
exit 0
|
package/.claude/settings.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"_ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-4.6",
|
|
5
5
|
"_ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-4.6",
|
|
6
6
|
"_ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
|
|
7
|
-
"_ANTHROPIC_AUTH_TOKEN": "
|
|
7
|
+
"_ANTHROPIC_AUTH_TOKEN": "ba852d27d46c4a2688c96bbf4da7246e.KgXaXVvWiONN3eis"
|
|
8
8
|
},
|
|
9
9
|
"permissions": {
|
|
10
10
|
"allow": [
|
|
@@ -40,12 +40,23 @@
|
|
|
40
40
|
},
|
|
41
41
|
"hooks": {
|
|
42
42
|
"PreToolUse": [
|
|
43
|
+
{
|
|
44
|
+
"matcher": "Grep|Glob|Search",
|
|
45
|
+
"hooks": [
|
|
46
|
+
{
|
|
47
|
+
"type": "command",
|
|
48
|
+
"command": "bash .claude/hooks/cfn-smart-search-hook.sh",
|
|
49
|
+
"timeout": 5
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
},
|
|
43
53
|
{
|
|
44
54
|
"matcher": "Bash",
|
|
45
55
|
"hooks": [
|
|
46
56
|
{
|
|
47
57
|
"type": "command",
|
|
48
|
-
"command": "bash
|
|
58
|
+
"command": "bash .claude/hooks/cfn-bash-search-hook.sh",
|
|
59
|
+
"timeout": 6
|
|
49
60
|
}
|
|
50
61
|
]
|
|
51
62
|
},
|
|
@@ -188,7 +199,7 @@
|
|
|
188
199
|
],
|
|
189
200
|
"env": {
|
|
190
201
|
"CEREBRAS_API_KEY": "${CEREBRAS_API_KEY}",
|
|
191
|
-
"CEREBRAS_MODEL": "
|
|
202
|
+
"CEREBRAS_MODEL": "zai-glm-4.6"
|
|
192
203
|
}
|
|
193
204
|
},
|
|
194
205
|
"n8n-mcp": {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/mnt/c/Users/masha/Documents/claude-flow-novice/.claude/skills/hook-pipeline/security-scanner.sh
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
# CFN Integration Script for Local RuVector Accelerator
|
|
3
|
+
# Works for both source repo and npm-installed packages
|
|
3
4
|
|
|
4
5
|
set -e
|
|
5
6
|
|
|
6
7
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
7
|
-
BINARY_PATH="$SCRIPT_DIR/target/release/local-ruvector"
|
|
8
8
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
9
9
|
|
|
10
10
|
# Colors for output
|
|
@@ -30,12 +30,53 @@ log_error() {
|
|
|
30
30
|
echo -e "${RED}❌ $1${NC}"
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
# Find binary - check multiple locations
|
|
34
|
+
find_binary() {
|
|
35
|
+
# 1. Check if in PATH
|
|
36
|
+
if command -v local-ruvector &> /dev/null; then
|
|
37
|
+
echo "$(command -v local-ruvector)"
|
|
38
|
+
return 0
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# 2. Check ~/.local/bin
|
|
42
|
+
if [[ -x "$HOME/.local/bin/local-ruvector" ]]; then
|
|
43
|
+
echo "$HOME/.local/bin/local-ruvector"
|
|
44
|
+
return 0
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
# 3. Check local target directory (source repo)
|
|
48
|
+
if [[ -x "$SCRIPT_DIR/target/release/local-ruvector" ]]; then
|
|
49
|
+
echo "$SCRIPT_DIR/target/release/local-ruvector"
|
|
50
|
+
return 0
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
return 1
|
|
54
|
+
}
|
|
55
|
+
|
|
33
56
|
# Ensure binary exists
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
cargo
|
|
38
|
-
|
|
57
|
+
BINARY_PATH=""
|
|
58
|
+
if ! BINARY_PATH=$(find_binary); then
|
|
59
|
+
# Try to build if Rust is available
|
|
60
|
+
if command -v cargo &> /dev/null && [[ -f "$SCRIPT_DIR/Cargo.toml" ]]; then
|
|
61
|
+
log_info "Building Local RuVector..."
|
|
62
|
+
cd "$SCRIPT_DIR"
|
|
63
|
+
cargo build --release
|
|
64
|
+
BINARY_PATH="$SCRIPT_DIR/target/release/local-ruvector"
|
|
65
|
+
|
|
66
|
+
# Install to ~/.local/bin for future use
|
|
67
|
+
if [[ -n "$HOME" ]]; then
|
|
68
|
+
mkdir -p "$HOME/.local/bin"
|
|
69
|
+
cp "$BINARY_PATH" "$HOME/.local/bin/local-ruvector"
|
|
70
|
+
chmod +x "$HOME/.local/bin/local-ruvector"
|
|
71
|
+
log_success "Installed local-ruvector to ~/.local/bin/"
|
|
72
|
+
fi
|
|
73
|
+
log_success "Build complete"
|
|
74
|
+
else
|
|
75
|
+
log_error "local-ruvector binary not found and cannot build (Rust not available)"
|
|
76
|
+
log_info "Install Rust: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"
|
|
77
|
+
log_info "Then run: npm run ruvector:local:build"
|
|
78
|
+
exit 1
|
|
79
|
+
fi
|
|
39
80
|
fi
|
|
40
81
|
|
|
41
82
|
# CFN integration commands
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
//! - rs, ts, js, json, md, sh, yaml, yml, txt, config
|
|
16
16
|
//! - Use --types to specify custom extensions
|
|
17
17
|
//!
|
|
18
|
-
//! ## Excluded Directories (see EXCLUDED_DIRS constant -
|
|
18
|
+
//! ## Excluded Directories (see EXCLUDED_DIRS constant - 54 patterns):
|
|
19
19
|
//! - Dependencies: node_modules, vendor, .pnpm, .yarn
|
|
20
20
|
//! - Build artifacts: target, dist, build, out, .next, .nuxt, .output, .turbo, .parcel-cache
|
|
21
21
|
//! - VCS: .git, .svn, .hg
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
//! - Cache: .cache, __pycache__, .pytest_cache, .mypy_cache, .ruff_cache, coverage, .nyc_output
|
|
24
24
|
//! - Virtual envs: .venv, venv, env
|
|
25
25
|
//! - IaC: .terraform, .serverless, .aws-sam
|
|
26
|
-
//! - Project-specific: .artifacts, .ruvector, .archive, archive
|
|
26
|
+
//! - Project-specific: .artifacts, .ruvector, .archive, archive, .archived, archived
|
|
27
27
|
//! - Backups/temp: backups, .backups, backup, tmp, .tmp, temp, logs
|
|
28
28
|
//! - Test artifacts: __snapshots__, __mocks__, playwright-report, test-results
|
|
29
29
|
//! - Doc builds: _site, .docusaurus, site
|
|
@@ -63,7 +63,8 @@ use crate::extractors::text_fallback::TextFallbackExtractor;
|
|
|
63
63
|
use crate::store_v2::{StoreV2, Entity as StoreEntity, Reference as StoreReference, TypeUsage};
|
|
64
64
|
use crate::schema_v2::{EntityKind, RefKind, Visibility};
|
|
65
65
|
use crate::path_validator;
|
|
66
|
-
use local_ruvector::paths::{get_ruvector_dir, get_database_path
|
|
66
|
+
use local_ruvector::paths::{get_ruvector_dir, get_database_path};
|
|
67
|
+
// V1 index is deprecated - all operations use V2 (index_v2.db)
|
|
67
68
|
|
|
68
69
|
/// Directories to exclude from indexing.
|
|
69
70
|
/// These are typically build artifacts, dependencies, VCS, or sensitive directories.
|
|
@@ -122,6 +123,8 @@ const EXCLUDED_DIRS: &[&str] = &[
|
|
|
122
123
|
".ruvector", // RuVector local index (avoid self-indexing)
|
|
123
124
|
".archive", // Archived/deprecated code
|
|
124
125
|
"archive", // Archive directories
|
|
126
|
+
".archived", // Archived code (alternate naming)
|
|
127
|
+
"archived", // Archived directories
|
|
125
128
|
|
|
126
129
|
// Backups & generated
|
|
127
130
|
"backups", // Backup directories
|
|
@@ -8,7 +8,8 @@ use crate::embeddings::EmbeddingsManager;
|
|
|
8
8
|
use crate::search_engine::SearchEngine;
|
|
9
9
|
use crate::sqlite_store::SqliteStore;
|
|
10
10
|
use crate::migration_v2::MigrationV2;
|
|
11
|
-
use local_ruvector::paths::{get_ruvector_dir,
|
|
11
|
+
use local_ruvector::paths::{get_ruvector_dir, get_database_path};
|
|
12
|
+
// V1 index is deprecated - all operations use V2 (index_v2.db)
|
|
12
13
|
|
|
13
14
|
pub struct InitCommand {
|
|
14
15
|
project_dir: PathBuf,
|
|
@@ -60,8 +61,7 @@ impl InitCommand {
|
|
|
60
61
|
.context("Failed to create RuVector directory")?;
|
|
61
62
|
fs::create_dir_all(ruvector_dir.join("embeddings"))
|
|
62
63
|
.context("Failed to create embeddings directory")?;
|
|
63
|
-
|
|
64
|
-
.context("Failed to create index directory")?;
|
|
64
|
+
// V1 index directory no longer created - using centralized V2 database
|
|
65
65
|
fs::create_dir_all(ruvector_dir.join("cache"))
|
|
66
66
|
.context("Failed to create cache directory")?;
|
|
67
67
|
} else {
|
|
@@ -70,7 +70,7 @@ impl QueryCommand {
|
|
|
70
70
|
|
|
71
71
|
// Set default values
|
|
72
72
|
let max_results = self.config.max_results.unwrap_or(10);
|
|
73
|
-
let threshold = self.config.threshold.unwrap_or(0.
|
|
73
|
+
let threshold = self.config.threshold.unwrap_or(0.3);
|
|
74
74
|
|
|
75
75
|
// Perform search with project root isolation
|
|
76
76
|
let results = self.query_v2.search(&self.config.query, max_results, threshold, &self.project_dir)?;
|
|
@@ -24,6 +24,7 @@ pub use embeddings::EmbeddingsManager;
|
|
|
24
24
|
pub use sqlite_store::SqliteStore;
|
|
25
25
|
pub use search_engine::SearchEngine;
|
|
26
26
|
pub use paths::{get_ruvector_dir, get_database_path};
|
|
27
|
+
// V1 index functions are deprecated - use V2 via get_database_path()
|
|
27
28
|
pub use store_v2::StoreV2;
|
|
28
29
|
pub use store_v2_tx::StoreV2WithTx;
|
|
29
30
|
pub use schema_v2::SchemaV2;
|
|
@@ -22,8 +22,10 @@ pub fn get_database_path() -> Result<PathBuf> {
|
|
|
22
22
|
Ok(get_ruvector_dir()?.join("index_v2.db"))
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
///
|
|
26
|
-
///
|
|
25
|
+
/// DEPRECATED: V1 index is no longer used
|
|
26
|
+
/// All operations should use index_v2.db via get_database_path()
|
|
27
|
+
/// This function remains only for migration cleanup
|
|
28
|
+
#[deprecated(since = "2.0.0", note = "V1 index removed. Use get_database_path() for V2.")]
|
|
27
29
|
pub fn get_v1_index_dir() -> Result<PathBuf> {
|
|
28
30
|
Ok(get_ruvector_dir()?.join("index"))
|
|
29
31
|
}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
//! DEPRECATED: V1 Search Engine
|
|
2
|
+
//!
|
|
3
|
+
//! This module is deprecated. All new code should use:
|
|
4
|
+
//! - `query_v2::QueryV2` for semantic search
|
|
5
|
+
//! - `store_v2::StoreV2` for storage operations
|
|
6
|
+
//! - `schema_v2::SchemaV2` for database initialization
|
|
7
|
+
//!
|
|
8
|
+
//! The V1 system used a separate index directory (~/.local/share/ruvector/index/).
|
|
9
|
+
//! V2 uses a single centralized database (~/.local/share/ruvector/index_v2.db).
|
|
10
|
+
|
|
1
11
|
use anyhow::{Result, Context, anyhow};
|
|
2
12
|
use ndarray::{Array1, Array2};
|
|
3
13
|
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
|
@@ -10,6 +20,7 @@ use tracing::info;
|
|
|
10
20
|
use memmap2::MmapOptions;
|
|
11
21
|
use crate::embeddings::EmbeddingsManager;
|
|
12
22
|
use crate::sqlite_store::SqliteStore;
|
|
23
|
+
#[allow(deprecated)]
|
|
13
24
|
use crate::paths::get_v1_index_dir;
|
|
14
25
|
|
|
15
26
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|