claude-flow-novice 2.18.22 → 2.18.24

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.
Files changed (36) hide show
  1. package/.claude/CLAUDE.md +17 -0
  2. package/.claude/cfn-scripts/check-memory.sh +150 -0
  3. package/.claude/cfn-scripts/run-with-memory-limit.sh +91 -0
  4. package/.claude/commands/cfn-loop/cfn-loop-cli.md +9 -0
  5. package/.claude/commands/cfn-loop-task.md +11 -0
  6. package/.claude/commands/cfn-ruvector/cfn-codebase-reindex.md +23 -4
  7. package/.claude/commands/cfn-ruvector/cfn-codebase-search.md +10 -2
  8. package/.claude/commands/cfn-ruvector/cfn-detect-stale-docs.md +22 -4
  9. package/.claude/hooks/README.md +148 -148
  10. package/.claude/hooks/cfn-bash-search-hook.sh +87 -0
  11. package/.claude/hooks/cfn-smart-search-hook.sh +127 -0
  12. package/.claude/hooks/deprecated/cfn-SessionStart-cfn-load-openai-key.sh +48 -0
  13. package/.claude/hooks/post-commit-codebase-index +79 -45
  14. package/.claude/settings.json +20 -11
  15. package/.claude/skills/CLAUDE.md +70 -0
  16. package/.claude/skills/cfn-edit-safety/lib/hooks/security-scanner.sh +1 -0
  17. package/.claude/skills/cfn-local-ruvector-accelerator/SKILL.md +37 -21
  18. package/.claude/skills/cfn-local-ruvector-accelerator/cfn-integration.sh +47 -6
  19. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/index.rs +2 -1
  20. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/init.rs +3 -3
  21. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/query.rs +1 -1
  22. package/.claude/skills/cfn-local-ruvector-accelerator/src/lib.rs +1 -0
  23. package/.claude/skills/cfn-local-ruvector-accelerator/src/paths.rs +4 -2
  24. package/.claude/skills/cfn-local-ruvector-accelerator/src/search_engine.rs +11 -0
  25. package/.claude/skills/cfn-local-ruvector-accelerator/test_query_api.sh +102 -102
  26. package/CLAUDE.md +63 -373
  27. package/docs/CFN_LOOP_CLI_MODE.md +134 -0
  28. package/package.json +9 -5
  29. package/scripts/cfn-init.js +8 -2
  30. package/scripts/organize-root-files.sh +340 -340
  31. package/scripts/postinstall.js +120 -3
  32. package/test-epic-creator-security.sh +202 -202
  33. package/.claude/hooks/SessionStart:cfn-build-ruvector.sh +0 -28
  34. package/.claude/hooks/SessionStart:cfn-load-openai-key.sh +0 -35
  35. /package/.claude/hooks/{SessionStart-cfn-build-ruvector.sh → cfn-SessionStart-cfn-build-ruvector.sh} +0 -0
  36. /package/.claude/hooks/{cfn-load-cerebras-env.sh → deprecated/cfn-load-cerebras-env.sh} +0 -0
@@ -1,75 +1,109 @@
1
1
  #!/bin/bash
2
- # Post-commit hook for incremental codebase indexing
3
- # Automatically updates RuVector index with committed files
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
- SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../skills/ruvector-codebase-index" && pwd)"
10
- INDEX_SCRIPT="$SKILL_DIR/index.sh"
11
- MOVE_HANDLER="$SKILL_DIR/handle-file-moves.sh"
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} Post-commit indexing hook triggered"
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
- # Check if indexing is enabled
22
- if [[ "${RUVECTOR_AUTO_INDEX:-true}" != "true" ]]; then
23
- echo -e "${YELLOW}[RuVector]${NC} Auto-indexing disabled (set RUVECTOR_AUTO_INDEX=true to enable)"
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 API key is available
28
- if [[ -z "${OPENAI_API_KEY:-}" && -z "${ZAI_API_KEY:-}" ]]; then
29
- echo -e "${YELLOW}[RuVector]${NC} Skipping indexing: No API key found"
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
- # STEP 1: Handle file moves/renames (delete old entries, index new locations)
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
- # STEP 2: Get list of added/modified files from the last commit
38
- COMMITTED_FILES=$(git diff-tree --no-commit-id --name-only --diff-filter=AM -r HEAD 2>/dev/null || echo "")
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 [[ -z "$COMMITTED_FILES" ]]; then
41
- echo -e "${YELLOW}[RuVector]${NC} No files to index"
42
- exit 0
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
- # Filter for indexable files
46
- CONFIG_FILE="$SKILL_DIR/config.json"
47
- INDEXABLE_EXTENSIONS=$(jq -r '.indexableExtensions[]' "$CONFIG_FILE" 2>/dev/null || echo "")
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
- INDEXABLE_FILES=()
50
- while IFS= read -r file; do
51
- if [[ -f "$file" ]]; then
52
- ext=".${file##*.}"
53
- if echo "$INDEXABLE_EXTENSIONS" | grep -q "$ext"; then
54
- INDEXABLE_FILES+=("$file")
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
- fi
57
- done <<< "$COMMITTED_FILES"
83
+ done <<< "$RENAMED_FILES"
58
84
 
59
- if [[ ${#INDEXABLE_FILES[@]} -eq 0 ]]; then
60
- echo -e "${YELLOW}[RuVector]${NC} No indexable files in commit"
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
- echo -e "${BLUE}[RuVector]${NC} Indexing ${#INDEXABLE_FILES[@]} file(s)..."
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
- # Run indexing in background to not block git operations
67
- (
68
- "$INDEX_SCRIPT" --files "${INDEXABLE_FILES[@]}" > /tmp/ruvector-index.log 2>&1
69
- echo -e "${GREEN}[RuVector]${NC} Index updated successfully"
70
- ) &
98
+ if [ -z "$INDEXABLE_FILES" ]; then
99
+ log "No new/modified indexable files"
100
+ exit 0
101
+ fi
71
102
 
72
- # Don't wait for indexing to complete
73
- echo -e "${BLUE}[RuVector]${NC} Indexing started in background (check /tmp/ruvector-index.log for details)"
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
@@ -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": "22f735783ea54c69a8e5d79b731eb4f4.gDXkwrMNlYcqE8mF"
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 -c 'CMD=$(cat | jq -r \".tool_input.command // empty\"); if echo \"$CMD\" | grep -q \"find /mnt/c\"; then echo \"🔴 BLOCKED: find on /mnt/c paths forbidden (causes memory leak - use Glob tool instead)\" >&2; exit 1; fi; echo \"[Hook] Command validated\" >&2; exit 0'"
58
+ "command": "bash .claude/hooks/cfn-bash-search-hook.sh",
59
+ "timeout": 6
49
60
  }
50
61
  ]
51
62
  },
@@ -142,23 +153,21 @@
142
153
  }
143
154
  ],
144
155
  "SessionStart": [
145
- {
156
+ {
157
+ "matcher": "startup",
146
158
  "hooks": [
147
159
  {
148
160
  "type": "command",
149
- "command": "bash -c 'echo \"[SessionStart] Initializing session context...\" >&2; if [ -f \"./.claude/hooks/cfn-load-cerebras-env.sh\" ]; then RESULT=$(./.claude/hooks/cfn-load-cerebras-env.sh 2>&1); if echo \"$RESULT\" | jq . >/dev/null 2>&1; then echo \"$RESULT\"; else echo \"$RESULT\" >&2; fi; fi; if [ -f \"./.claude/skills/cfn-memory-persistence/lib/auto/auto-load-session-context.sh\" ]; then ./.claude/skills/cfn-memory-persistence/lib/auto/auto-load-session-context.sh --session-id \"${SESSION_ID:-$(date +%s)}\" 2>&1 || true; fi; if [ -f \"./.claude/skills/cfn-transparency-middleware/invoke-transparency-init.sh\" ]; then ./.claude/skills/cfn-transparency-middleware/invoke-transparency-init.sh --task-id \"${SESSION_ID:-session}\" --level standard 2>&1 || true; fi; echo \"[SessionStart] Context loaded\" >&2; exit 0'",
150
- "timeout": 15
161
+ "command": "nohup ~/.local/bin/wsl-memory-monitor.sh > /dev/null 2>&1 & sleep 0.5 && echo \"[WSL Memory Monitor] Running (PID: $(cat /tmp/wsl-memory-monitor.pid 2>/dev/null || echo starting))\""
151
162
  }
152
163
  ]
153
- }
154
- ],
155
- "Stop": [
164
+ },
156
165
  {
157
166
  "hooks": [
158
167
  {
159
168
  "type": "command",
160
- "command": "bash -c 'echo \"[SessionEnd] Persisting session state...\" >&2; if [ -f \"./.claude/skills/cfn-memory-persistence/lib/auto/save-session-context.sh\" ]; then ./.claude/skills/cfn-memory-persistence/lib/auto/save-session-context.sh --session-id \"${SESSION_ID:-$(date +%s)}\" 2>&1 || true; fi; if [ -f \"./.claude/skills/cfn-knowledge-base/cli/knowledge-base.sh\" ]; then ./.claude/skills/cfn-knowledge-base/cli/knowledge-base.sh store-learning --type session-end --category completed --confidence 0.85 2>&1 || true; fi; echo \"[SessionEnd] Session ended\" >&2; exit 0'",
161
- "timeout": 15
169
+ "command": "bash .claude/hooks/cfn-SessionStart-cfn-build-ruvector.sh",
170
+ "timeout": 60
162
171
  }
163
172
  ]
164
173
  }
@@ -188,7 +197,7 @@
188
197
  ],
189
198
  "env": {
190
199
  "CEREBRAS_API_KEY": "${CEREBRAS_API_KEY}",
191
- "CEREBRAS_MODEL": "llama3.1-8b"
200
+ "CEREBRAS_MODEL": "zai-glm-4.6"
192
201
  }
193
202
  },
194
203
  "n8n-mcp": {
@@ -0,0 +1,70 @@
1
+ # Claude Code Skills Development Guide
2
+
3
+ **Purpose:** Guidelines for developing, testing, and maintaining CFN skills.
4
+
5
+ ---
6
+
7
+ ## Skill Development Principles
8
+
9
+ - **Modularity:** Each skill handles one responsibility; compose skills for complex operations
10
+ - **Explicit Interfaces:** Document inputs, outputs, and side effects in SKILL.md
11
+ - **Minimal Dependencies:** Skills should be self-contained; avoid cross-skill imports
12
+ - **Thorough Testing:** Every skill needs functional tests and edge case coverage
13
+
14
+ ## Testing Requirements (STRAT-005)
15
+
16
+ Skills must include tests covering:
17
+ - Functional requirements (happy path)
18
+ - Edge cases: timeouts, blocking operations, invalid inputs
19
+ - Resource cleanup on failure
20
+
21
+ **Example test location:** `.claude/skills/cfn-coordination/test-orchestrator.sh`
22
+
23
+ ## Core Skill References
24
+
25
+ - **Coordination:** `.claude/skills/cfn-coordination/SKILL.md` - chain, broadcast, mesh, consensus patterns
26
+ - **Agent Spawning:** `.claude/skills/cfn-agent-spawning/SKILL.md` - agent lifecycle management
27
+ - **Loop Validation:** `.claude/skills/cfn-loop-validation/SKILL.md` - gate checks and consensus
28
+
29
+ ## Skill File Structure
30
+
31
+ ```
32
+ .claude/skills/<skill-name>/
33
+ ├── SKILL.md # Skill documentation (required)
34
+ ├── <main-script>.sh # Primary entry point
35
+ ├── lib/ # Helper scripts/modules
36
+ └── tests/ # Skill-specific tests
37
+ ```
38
+
39
+ ## Skill Documentation Template
40
+
41
+ ```markdown
42
+ # Skill: <name>
43
+
44
+ ## Purpose
45
+ One-line description of what this skill does.
46
+
47
+ ## Inputs
48
+ - `$1`: Description
49
+ - `ENV_VAR`: Description
50
+
51
+ ## Outputs
52
+ - stdout: Description
53
+ - exit code: 0 = success, non-zero = failure
54
+
55
+ ## Usage
56
+ \`\`\`bash
57
+ ./.claude/skills/<skill-name>/<script>.sh [args]
58
+ \`\`\`
59
+
60
+ ## Dependencies
61
+ - List required tools/skills
62
+ ```
63
+
64
+ ## Quality Checklist
65
+
66
+ - [ ] SKILL.md documents all inputs/outputs
67
+ - [ ] Scripts use `set -euo pipefail`
68
+ - [ ] Cleanup traps handle interrupts
69
+ - [ ] Tests cover happy path and failure modes
70
+ - [ ] No hardcoded paths (use `PROJECT_ROOT`)
@@ -0,0 +1 @@
1
+ /mnt/c/Users/masha/Documents/claude-flow-novice/.claude/skills/hook-pipeline/security-scanner.sh
@@ -1,25 +1,41 @@
1
+ ---
2
+ name: ruvector-code-search
3
+ description: "MANDATORY: Query RuVector BEFORE using grep, glob, find, or search. Performs 400x faster semantic and structural code search via SQL on indexed codebase. Use for finding functions, classes, patterns, callers, and implementations. Agents MUST query RuVector first; grep is only allowed after RuVector returns zero results."
4
+ allowed-tools: Bash, Read, SlashCommand
5
+ ---
6
+
1
7
  # RuVector Local Semantic Code Search
2
8
 
3
- ## WHEN TO USE THIS SKILL
9
+ ## MANDATORY: QUERY RUVECTOR BEFORE GREP/GLOB
10
+
11
+ **This is a PROTOCOL REQUIREMENT, not a suggestion. Failure to query RuVector first is a violation.**
12
+
13
+ ### WHY THIS IS MANDATORY
14
+ - RuVector SQL: 0.002s | grep: 0.8s (400x slower)
15
+ - Agents using grep first waste tokens and time
16
+ - Index already exists at `~/.local/share/ruvector/index_v2.db`
4
17
 
5
- **USE RuVector V2 SQL for ALL indexed projects (400x FASTER than grep):**
18
+ ### ALWAYS USE RUVECTOR FIRST
6
19
  ```bash
7
- # Exact name lookup - 0.002s vs grep's 0.8s
20
+ # Exact name lookup - 0.002s
8
21
  sqlite3 ~/.local/share/ruvector/index_v2.db "SELECT file_path, line_number FROM entities WHERE name = 'MyFunction';"
9
22
 
10
23
  # Fuzzy search - 0.004s
11
24
  sqlite3 ~/.local/share/ruvector/index_v2.db "SELECT file_path, line_number FROM entities WHERE name LIKE '%Store%' LIMIT 10;"
25
+
26
+ # Semantic search
27
+ /codebase-search "authentication middleware pattern"
12
28
  ```
13
29
 
14
- **USE grep/rg ONLY when:**
15
- - Project is NOT indexed yet
16
- - Searching for strings that aren't code entities (error messages, comments, config values)
17
- - Quick one-off search in small directory
30
+ ### GREP IS ONLY ALLOWED WHEN:
31
+ - RuVector query returned zero results AND project confirmed not indexed
32
+ - Searching literal strings (error messages, comments, config values)
33
+ - Explicit user request for grep
18
34
 
19
- **USE RuVector semantic search when:**
20
- - "Where is authentication implemented?" (conceptual search)
21
- - Finding similar patterns you can't name exactly
22
- - Discovering how a feature is built
35
+ ### FOR CONCEPTUAL QUESTIONS:
36
+ - "Where is X implemented?" RuVector semantic search
37
+ - "Find similar patterns" RuVector embeddings
38
+ - "How is feature Y built?" → RuVector first, then read files
23
39
 
24
40
  ## Quick Commands
25
41
 
@@ -108,20 +124,20 @@ sqlite3 ~/.local/share/ruvector/index_v2.db "SELECT project_root, COUNT(*) FROM
108
124
  ~/.local/share/ruvector/index_v2.db
109
125
  ```
110
126
 
111
- ## For Agents
127
+ ## For Agents (MANDATORY PROTOCOL)
128
+
129
+ **DO NOT use grep/glob until you have queried RuVector. This is enforced.**
112
130
 
113
- Before implementing changes, ALWAYS query RuVector first:
114
131
  ```bash
115
- # Find similar patterns (slash command uses --top, CLI uses --max-results)
132
+ # STEP 1: Query RuVector FIRST (required)
116
133
  /codebase-search "relevant search terms" --top 5
117
- # Or via CLI:
118
- local-ruvector query "relevant search terms" --max-results 5
134
+ # Or SQL:
135
+ sqlite3 ~/.local/share/ruvector/index_v2.db "SELECT file_path, line_number FROM entities WHERE name LIKE '%keyword%';"
119
136
 
120
- # Query past errors
121
- ./.claude/skills/cfn-ruvector-codebase-index/query-error-patterns.sh --task-description "description"
137
+ # STEP 2: Query past errors/patterns
138
+ ./.claude/skills/cfn-local-ruvector-accelerator/query-agent-patterns.sh "description"
122
139
 
123
- # Query learnings
124
- ./.claude/skills/cfn-ruvector-codebase-index/query-learnings.sh --task-description "description" --category PATTERN
140
+ # STEP 3: Only if RuVector returns nothing, then use grep
125
141
  ```
126
142
 
127
- This prevents duplicated work and leverages existing solutions.
143
+ **Violation of this protocol wastes tokens and time. RuVector exists to prevent duplicated work.**
@@ -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
- if [[ ! -f "$BINARY_PATH" ]]; then
35
- log_info "Building Local RuVector..."
36
- cd "$SCRIPT_DIR"
37
- cargo build --release
38
- log_success "Build complete"
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
@@ -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, get_v1_index_dir};
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.
@@ -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, get_v1_index_dir, get_database_path};
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
- fs::create_dir_all(get_v1_index_dir()?)
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.5);
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
- /// Get the legacy V1 index path (for migration)
26
- /// Location: ~/.local/share/ruvector/index/
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)]