ruvector 0.1.73 → 0.1.75
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/bin/cli.js +102 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -12
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -2752,6 +2752,7 @@ hooksCmd.command('init')
|
|
|
2752
2752
|
.description('Initialize hooks in current project')
|
|
2753
2753
|
.option('--force', 'Force overwrite existing settings')
|
|
2754
2754
|
.option('--minimal', 'Only basic hooks (no env, permissions, or advanced hooks)')
|
|
2755
|
+
.option('--fast', 'Use fast local wrapper (20x faster, bypasses npx overhead)')
|
|
2755
2756
|
.option('--no-claude-md', 'Skip CLAUDE.md creation')
|
|
2756
2757
|
.option('--no-permissions', 'Skip permissions configuration')
|
|
2757
2758
|
.option('--no-env', 'Skip environment variables')
|
|
@@ -2763,6 +2764,7 @@ hooksCmd.command('init')
|
|
|
2763
2764
|
.action(async (opts) => {
|
|
2764
2765
|
const settingsPath = path.join(process.cwd(), '.claude', 'settings.json');
|
|
2765
2766
|
const settingsDir = path.dirname(settingsPath);
|
|
2767
|
+
const isWindows = process.platform === 'win32';
|
|
2766
2768
|
if (!fs.existsSync(settingsDir)) fs.mkdirSync(settingsDir, { recursive: true });
|
|
2767
2769
|
let settings = {};
|
|
2768
2770
|
if (fs.existsSync(settingsPath) && !opts.force) {
|
|
@@ -2836,32 +2838,36 @@ hooksCmd.command('init')
|
|
|
2836
2838
|
// StatusLine configuration (unless --minimal or --no-statusline)
|
|
2837
2839
|
if (!opts.minimal && opts.statusline !== false) {
|
|
2838
2840
|
if (!settings.statusLine) {
|
|
2839
|
-
const isWindows = process.platform === 'win32';
|
|
2840
|
-
|
|
2841
2841
|
if (isWindows) {
|
|
2842
2842
|
// Windows: PowerShell statusline
|
|
2843
2843
|
const statuslineScript = path.join(settingsDir, 'statusline-command.ps1');
|
|
2844
2844
|
const statuslineContent = `# RuVector Intelligence Statusline for Windows PowerShell
|
|
2845
|
+
# Compatible with PowerShell 5.1+ and PowerShell Core
|
|
2845
2846
|
$ErrorActionPreference = "SilentlyContinue"
|
|
2847
|
+
$e = [char]27
|
|
2846
2848
|
$inputData = [Console]::In.ReadToEnd()
|
|
2847
2849
|
$data = $inputData | ConvertFrom-Json
|
|
2848
2850
|
$Model = if ($data.model.display_name) { $data.model.display_name } else { "Claude" }
|
|
2849
2851
|
$CWD = if ($data.workspace.current_dir) { $data.workspace.current_dir } else { $data.cwd }
|
|
2850
2852
|
$Dir = Split-Path -Leaf $CWD
|
|
2851
|
-
$Branch = $null
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
Write-Host $Line1
|
|
2856
|
-
$IntelFile = "$CWD\.ruvector\intelligence.json"
|
|
2853
|
+
$Branch = $null
|
|
2854
|
+
try { Push-Location $CWD -ErrorAction Stop; $Branch = git branch --show-current 2>$null; Pop-Location } catch {}
|
|
2855
|
+
Write-Host "$e[1m$Model$e[0m in $e[36m$Dir$e[0m$(if($Branch){" on $e[33m$Branch$e[0m"})"
|
|
2856
|
+
$IntelFile = Join-Path $CWD ".ruvector\intelligence.json"
|
|
2857
2857
|
if (Test-Path $IntelFile) {
|
|
2858
2858
|
$Intel = Get-Content $IntelFile -Raw | ConvertFrom-Json
|
|
2859
|
-
$
|
|
2860
|
-
$
|
|
2861
|
-
$
|
|
2862
|
-
|
|
2859
|
+
$Mem = if ($Intel.memories) { $Intel.memories.Count } else { 0 }
|
|
2860
|
+
$Traj = if ($Intel.trajectories) { $Intel.trajectories.Count } else { 0 }
|
|
2861
|
+
$Sess = if ($Intel.stats -and $Intel.stats.session_count) { $Intel.stats.session_count } else { 0 }
|
|
2862
|
+
$Pat = if ($Intel.patterns) { ($Intel.patterns | Get-Member -MemberType NoteProperty).Count } else { 0 }
|
|
2863
|
+
$Line2 = "$e[35m RuVector$e[0m"
|
|
2864
|
+
if ($Pat -gt 0) { $Line2 += " $e[32m$Pat patterns$e[0m" } else { $Line2 += " $e[2mlearning$e[0m" }
|
|
2865
|
+
if ($Mem -gt 0) { $Line2 += " $e[34m$Mem mem$e[0m" }
|
|
2866
|
+
if ($Traj -gt 0) { $Line2 += " $e[33m$Traj traj$e[0m" }
|
|
2867
|
+
if ($Sess -gt 0) { $Line2 += " $e[2m#$Sess$e[0m" }
|
|
2868
|
+
Write-Host $Line2
|
|
2863
2869
|
} else {
|
|
2864
|
-
Write-Host "$
|
|
2870
|
+
Write-Host "$e[2m RuVector: run 'npx ruvector hooks session-start'$e[0m"
|
|
2865
2871
|
}
|
|
2866
2872
|
`;
|
|
2867
2873
|
fs.writeFileSync(statuslineScript, statuslineContent);
|
|
@@ -2914,19 +2920,82 @@ fi
|
|
|
2914
2920
|
}
|
|
2915
2921
|
}
|
|
2916
2922
|
|
|
2917
|
-
//
|
|
2923
|
+
// Fast wrapper creation (--fast option) - 20x faster than npx
|
|
2924
|
+
let hookCmd = 'npx ruvector@latest';
|
|
2925
|
+
let fastTimeouts = { simple: 2000, complex: 2000, session: 5000 };
|
|
2926
|
+
if (opts.fast && !isWindows) {
|
|
2927
|
+
const fastWrapperPath = path.join(settingsDir, 'ruvector-fast.sh');
|
|
2928
|
+
const fastWrapperContent = `#!/bin/bash
|
|
2929
|
+
# Fast RuVector hooks wrapper - avoids npx overhead (20x faster)
|
|
2930
|
+
# Usage: .claude/ruvector-fast.sh hooks <command> [args...]
|
|
2931
|
+
|
|
2932
|
+
# Find ruvector CLI - check local first, then global
|
|
2933
|
+
RUVECTOR_CLI=""
|
|
2934
|
+
|
|
2935
|
+
# Check local npm package (for development)
|
|
2936
|
+
if [ -f "$PWD/npm/packages/ruvector/bin/cli.js" ]; then
|
|
2937
|
+
RUVECTOR_CLI="$PWD/npm/packages/ruvector/bin/cli.js"
|
|
2938
|
+
# Check node_modules
|
|
2939
|
+
elif [ -f "$PWD/node_modules/ruvector/bin/cli.js" ]; then
|
|
2940
|
+
RUVECTOR_CLI="$PWD/node_modules/ruvector/bin/cli.js"
|
|
2941
|
+
# Check global npm installation
|
|
2942
|
+
elif [ -f "$PWD/node_modules/.bin/ruvector" ]; then
|
|
2943
|
+
exec "$PWD/node_modules/.bin/ruvector" "$@"
|
|
2944
|
+
elif command -v ruvector &> /dev/null; then
|
|
2945
|
+
exec ruvector "$@"
|
|
2946
|
+
# Fallback to npx (slow but works)
|
|
2947
|
+
else
|
|
2948
|
+
exec npx ruvector@latest "$@"
|
|
2949
|
+
fi
|
|
2950
|
+
|
|
2951
|
+
# Execute with node directly (fast path)
|
|
2952
|
+
exec node "$RUVECTOR_CLI" "$@"
|
|
2953
|
+
`;
|
|
2954
|
+
fs.writeFileSync(fastWrapperPath, fastWrapperContent);
|
|
2955
|
+
fs.chmodSync(fastWrapperPath, '755');
|
|
2956
|
+
hookCmd = '.claude/ruvector-fast.sh';
|
|
2957
|
+
fastTimeouts = { simple: 300, complex: 500, session: 1000 };
|
|
2958
|
+
// Add permission for fast wrapper
|
|
2959
|
+
if (settings.permissions && settings.permissions.allow) {
|
|
2960
|
+
if (!settings.permissions.allow.includes('Bash(.claude/ruvector-fast.sh:*)')) {
|
|
2961
|
+
settings.permissions.allow.push('Bash(.claude/ruvector-fast.sh:*)');
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
console.log(chalk.blue(' ✓ Fast wrapper created (.claude/ruvector-fast.sh) - 20x faster hooks'));
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
// Core hooks (always included) - with timeouts and error suppression
|
|
2918
2968
|
settings.hooks = settings.hooks || {};
|
|
2919
2969
|
settings.hooks.PreToolUse = [
|
|
2920
|
-
{
|
|
2921
|
-
|
|
2970
|
+
{
|
|
2971
|
+
matcher: 'Edit|Write|MultiEdit',
|
|
2972
|
+
hooks: [
|
|
2973
|
+
{ type: 'command', timeout: fastTimeouts.complex, command: `${hookCmd} hooks pre-edit "$TOOL_INPUT_file_path" 2>/dev/null || true` },
|
|
2974
|
+
{ type: 'command', timeout: fastTimeouts.complex, command: `${hookCmd} hooks coedit-suggest --file "$TOOL_INPUT_file_path" 2>/dev/null || true` }
|
|
2975
|
+
]
|
|
2976
|
+
},
|
|
2977
|
+
{ matcher: 'Bash', hooks: [{ type: 'command', timeout: fastTimeouts.complex, command: `${hookCmd} hooks pre-command "$TOOL_INPUT_command" 2>/dev/null || true` }] },
|
|
2978
|
+
{ matcher: 'Read', hooks: [{ type: 'command', timeout: fastTimeouts.simple, command: `${hookCmd} hooks remember "Reading: $TOOL_INPUT_file_path" -t file_access 2>/dev/null || true` }] },
|
|
2979
|
+
{ matcher: 'Glob|Grep', hooks: [{ type: 'command', timeout: fastTimeouts.simple, command: `${hookCmd} hooks remember "Search: $TOOL_INPUT_pattern" -t search_pattern 2>/dev/null || true` }] },
|
|
2980
|
+
{ matcher: 'Task', hooks: [{ type: 'command', timeout: fastTimeouts.simple, command: `${hookCmd} hooks remember "Agent: $TOOL_INPUT_subagent_type" -t agent_spawn 2>/dev/null || true` }] }
|
|
2922
2981
|
];
|
|
2923
2982
|
settings.hooks.PostToolUse = [
|
|
2924
|
-
{ matcher: 'Edit|Write|MultiEdit', hooks: [{ type: 'command', command:
|
|
2925
|
-
{ matcher: 'Bash', hooks: [{ type: 'command', command:
|
|
2983
|
+
{ matcher: 'Edit|Write|MultiEdit', hooks: [{ type: 'command', timeout: fastTimeouts.complex, command: `${hookCmd} hooks post-edit "$TOOL_INPUT_file_path" 2>/dev/null || true` }] },
|
|
2984
|
+
{ matcher: 'Bash', hooks: [{ type: 'command', timeout: fastTimeouts.complex, command: `${hookCmd} hooks post-command "$TOOL_INPUT_command" 2>/dev/null || true` }] }
|
|
2926
2985
|
];
|
|
2927
|
-
settings.hooks.SessionStart = [{
|
|
2928
|
-
|
|
2929
|
-
|
|
2986
|
+
settings.hooks.SessionStart = [{
|
|
2987
|
+
hooks: [
|
|
2988
|
+
{ type: 'command', timeout: fastTimeouts.session, command: `${hookCmd} hooks session-start 2>/dev/null || true` },
|
|
2989
|
+
{ type: 'command', timeout: fastTimeouts.complex, command: `${hookCmd} hooks trajectory-begin -c "claude-session" -a "claude" 2>/dev/null || true` }
|
|
2990
|
+
]
|
|
2991
|
+
}];
|
|
2992
|
+
settings.hooks.Stop = [{
|
|
2993
|
+
hooks: [
|
|
2994
|
+
{ type: 'command', timeout: fastTimeouts.complex, command: `${hookCmd} hooks trajectory-end --success --quality 0.8 2>/dev/null || true` },
|
|
2995
|
+
{ type: 'command', timeout: fastTimeouts.complex, command: `${hookCmd} hooks session-end 2>/dev/null || true` }
|
|
2996
|
+
]
|
|
2997
|
+
}];
|
|
2998
|
+
console.log(chalk.blue(` ✓ Core hooks (PreToolUse, PostToolUse, SessionStart, Stop) ${opts.fast ? 'with fast wrapper' : 'with error handling'}`));
|
|
2930
2999
|
|
|
2931
3000
|
// Advanced hooks (unless --minimal)
|
|
2932
3001
|
if (!opts.minimal) {
|
|
@@ -2934,8 +3003,8 @@ fi
|
|
|
2934
3003
|
settings.hooks.UserPromptSubmit = [{
|
|
2935
3004
|
hooks: [{
|
|
2936
3005
|
type: 'command',
|
|
2937
|
-
timeout:
|
|
2938
|
-
command:
|
|
3006
|
+
timeout: fastTimeouts.complex,
|
|
3007
|
+
command: `${hookCmd} hooks suggest-context 2>/dev/null || true`
|
|
2939
3008
|
}]
|
|
2940
3009
|
}];
|
|
2941
3010
|
|
|
@@ -2943,18 +3012,17 @@ fi
|
|
|
2943
3012
|
settings.hooks.PreCompact = [
|
|
2944
3013
|
{
|
|
2945
3014
|
matcher: 'auto',
|
|
2946
|
-
hooks: [
|
|
2947
|
-
type: 'command',
|
|
2948
|
-
timeout:
|
|
2949
|
-
|
|
2950
|
-
}]
|
|
3015
|
+
hooks: [
|
|
3016
|
+
{ type: 'command', timeout: fastTimeouts.session, command: `${hookCmd} hooks pre-compact --auto 2>/dev/null || true` },
|
|
3017
|
+
{ type: 'command', timeout: fastTimeouts.session, command: `${hookCmd} hooks compress 2>/dev/null || true` }
|
|
3018
|
+
]
|
|
2951
3019
|
},
|
|
2952
3020
|
{
|
|
2953
3021
|
matcher: 'manual',
|
|
2954
3022
|
hooks: [{
|
|
2955
3023
|
type: 'command',
|
|
2956
|
-
timeout:
|
|
2957
|
-
command:
|
|
3024
|
+
timeout: fastTimeouts.session,
|
|
3025
|
+
command: `${hookCmd} hooks pre-compact 2>/dev/null || true`
|
|
2958
3026
|
}]
|
|
2959
3027
|
}
|
|
2960
3028
|
];
|
|
@@ -2964,11 +3032,11 @@ fi
|
|
|
2964
3032
|
matcher: '.*',
|
|
2965
3033
|
hooks: [{
|
|
2966
3034
|
type: 'command',
|
|
2967
|
-
timeout:
|
|
2968
|
-
command:
|
|
3035
|
+
timeout: fastTimeouts.simple,
|
|
3036
|
+
command: `${hookCmd} hooks track-notification 2>/dev/null || true`
|
|
2969
3037
|
}]
|
|
2970
3038
|
}];
|
|
2971
|
-
console.log(chalk.blue(
|
|
3039
|
+
console.log(chalk.blue(` ✓ Advanced hooks (UserPromptSubmit, PreCompact, Notification, Compress)${opts.fast ? ' - fast mode' : ''}`));
|
|
2972
3040
|
|
|
2973
3041
|
// Extended environment variables for new capabilities
|
|
2974
3042
|
settings.env.RUVECTOR_AST_ENABLED = settings.env.RUVECTOR_AST_ENABLED || 'true';
|
|
@@ -3170,6 +3238,7 @@ Stored in \`.ruvector/intelligence.json\`:
|
|
|
3170
3238
|
\`\`\`bash
|
|
3171
3239
|
npx ruvector hooks init # Full configuration with all capabilities
|
|
3172
3240
|
npx ruvector hooks init --minimal # Basic hooks only
|
|
3241
|
+
npx ruvector hooks init --fast # Use fast local wrapper (20x faster)
|
|
3173
3242
|
npx ruvector hooks init --pretrain # Initialize + pretrain from git history
|
|
3174
3243
|
npx ruvector hooks init --build-agents quality # Generate optimized agents
|
|
3175
3244
|
npx ruvector hooks init --force # Overwrite existing configuration
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[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
41
41
|
implementationType = 'native';
|
|
42
|
-
// Verify it's actually working
|
|
43
|
-
if (typeof implementation.
|
|
44
|
-
throw new Error('Native module loaded but
|
|
42
|
+
// Verify it's actually working (native module exports VectorDb, not VectorDB)
|
|
43
|
+
if (typeof implementation.VectorDb !== 'function') {
|
|
44
|
+
throw new Error('Native module loaded but VectorDb class not found');
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
catch (e) {
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
// Graceful fallback - don't crash, just warn
|
|
49
|
+
console.warn('[RuVector] Native module not available:', e.message);
|
|
50
|
+
console.warn('[RuVector] Vector operations will be limited. Install @ruvector/core for full functionality.');
|
|
51
|
+
// Create a stub implementation that provides basic functionality
|
|
52
|
+
implementation = {
|
|
53
|
+
VectorDb: class StubVectorDb {
|
|
54
|
+
constructor() {
|
|
55
|
+
console.warn('[RuVector] Using stub VectorDb - install @ruvector/core for native performance');
|
|
56
|
+
}
|
|
57
|
+
async insert() { return 'stub-id-' + Date.now(); }
|
|
58
|
+
async insertBatch(entries) { return entries.map(() => 'stub-id-' + Date.now()); }
|
|
59
|
+
async search() { return []; }
|
|
60
|
+
async delete() { return true; }
|
|
61
|
+
async get() { return null; }
|
|
62
|
+
async len() { return 0; }
|
|
63
|
+
async isEmpty() { return true; }
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
implementationType = 'wasm'; // Mark as fallback mode
|
|
57
67
|
}
|
|
58
68
|
/**
|
|
59
69
|
* Get the current implementation type
|