ruvector 0.1.42 → 0.1.44
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 +64 -1
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -2267,7 +2267,7 @@ class Intelligence {
|
|
|
2267
2267
|
// Hooks command group
|
|
2268
2268
|
const hooksCmd = program.command('hooks').description('Self-learning intelligence hooks for Claude Code');
|
|
2269
2269
|
|
|
2270
|
-
hooksCmd.command('init').description('Initialize hooks in current project').option('--force', 'Force overwrite').action((opts) => {
|
|
2270
|
+
hooksCmd.command('init').description('Initialize hooks in current project').option('--force', 'Force overwrite').option('--no-claude-md', 'Skip CLAUDE.md creation').action((opts) => {
|
|
2271
2271
|
const settingsPath = path.join(process.cwd(), '.claude', 'settings.json');
|
|
2272
2272
|
const settingsDir = path.dirname(settingsPath);
|
|
2273
2273
|
if (!fs.existsSync(settingsDir)) fs.mkdirSync(settingsDir, { recursive: true });
|
|
@@ -2275,6 +2275,15 @@ hooksCmd.command('init').description('Initialize hooks in current project').opti
|
|
|
2275
2275
|
if (fs.existsSync(settingsPath) && !opts.force) {
|
|
2276
2276
|
try { settings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8')); } catch {}
|
|
2277
2277
|
}
|
|
2278
|
+
// Fix schema if present
|
|
2279
|
+
if (settings.$schema) {
|
|
2280
|
+
settings.$schema = 'https://json.schemastore.org/claude-code-settings.json';
|
|
2281
|
+
}
|
|
2282
|
+
// Clean up invalid hook names
|
|
2283
|
+
if (settings.hooks) {
|
|
2284
|
+
if (settings.hooks.Start) { delete settings.hooks.Start; }
|
|
2285
|
+
if (settings.hooks.End) { delete settings.hooks.End; }
|
|
2286
|
+
}
|
|
2278
2287
|
settings.hooks = settings.hooks || {};
|
|
2279
2288
|
settings.hooks.PreToolUse = [
|
|
2280
2289
|
{ matcher: 'Edit|Write|MultiEdit', hooks: [{ type: 'command', command: 'npx ruvector hooks pre-edit "$TOOL_INPUT_file_path"' }] },
|
|
@@ -2288,6 +2297,60 @@ hooksCmd.command('init').description('Initialize hooks in current project').opti
|
|
|
2288
2297
|
settings.hooks.Stop = [{ hooks: [{ type: 'command', command: 'npx ruvector hooks session-end' }] }];
|
|
2289
2298
|
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
2290
2299
|
console.log(chalk.green('✅ Hooks initialized in .claude/settings.json'));
|
|
2300
|
+
|
|
2301
|
+
// Create CLAUDE.md if it doesn't exist (or force)
|
|
2302
|
+
const claudeMdPath = path.join(process.cwd(), 'CLAUDE.md');
|
|
2303
|
+
if (opts.claudeMd !== false && (!fs.existsSync(claudeMdPath) || opts.force)) {
|
|
2304
|
+
const claudeMdContent = `# Claude Code Project Configuration
|
|
2305
|
+
|
|
2306
|
+
## RuVector Self-Learning Hooks
|
|
2307
|
+
|
|
2308
|
+
This project uses RuVector's self-learning intelligence hooks for enhanced AI-assisted development.
|
|
2309
|
+
|
|
2310
|
+
### Active Hooks
|
|
2311
|
+
|
|
2312
|
+
| Hook | Trigger | Purpose |
|
|
2313
|
+
|------|---------|---------|
|
|
2314
|
+
| PreToolUse | Before Edit/Write/Bash | Agent routing, command analysis |
|
|
2315
|
+
| PostToolUse | After Edit/Write/Bash | Q-learning update, pattern recording |
|
|
2316
|
+
| SessionStart | Conversation begins | Load intelligence, display stats |
|
|
2317
|
+
| Stop | Conversation ends | Save learning data |
|
|
2318
|
+
|
|
2319
|
+
### Commands
|
|
2320
|
+
|
|
2321
|
+
\`\`\`bash
|
|
2322
|
+
# View learning statistics
|
|
2323
|
+
npx ruvector hooks stats
|
|
2324
|
+
|
|
2325
|
+
# Route a task to best agent
|
|
2326
|
+
npx ruvector hooks route "implement feature X"
|
|
2327
|
+
|
|
2328
|
+
# Store context in memory
|
|
2329
|
+
npx ruvector hooks remember "important context" -t project
|
|
2330
|
+
|
|
2331
|
+
# Recall from memory
|
|
2332
|
+
npx ruvector hooks recall "context query"
|
|
2333
|
+
\`\`\`
|
|
2334
|
+
|
|
2335
|
+
### How It Works
|
|
2336
|
+
|
|
2337
|
+
1. **Pre-edit hooks** analyze files and suggest the best agent for the task
|
|
2338
|
+
2. **Post-edit hooks** record outcomes to improve future suggestions via Q-learning
|
|
2339
|
+
3. **Memory hooks** store and retrieve context using vector embeddings
|
|
2340
|
+
4. **Session hooks** manage learning state across conversations
|
|
2341
|
+
|
|
2342
|
+
### Configuration
|
|
2343
|
+
|
|
2344
|
+
Settings are stored in \`.claude/settings.json\`. Run \`npx ruvector hooks init\` to regenerate.
|
|
2345
|
+
|
|
2346
|
+
---
|
|
2347
|
+
*Powered by [RuVector](https://github.com/ruvnet/ruvector) self-learning intelligence*
|
|
2348
|
+
`;
|
|
2349
|
+
fs.writeFileSync(claudeMdPath, claudeMdContent);
|
|
2350
|
+
console.log(chalk.green('✅ CLAUDE.md created in project root'));
|
|
2351
|
+
} else if (fs.existsSync(claudeMdPath) && !opts.force) {
|
|
2352
|
+
console.log(chalk.yellow('ℹ️ CLAUDE.md already exists (use --force to overwrite)'));
|
|
2353
|
+
}
|
|
2291
2354
|
});
|
|
2292
2355
|
|
|
2293
2356
|
hooksCmd.command('stats').description('Show intelligence statistics').action(() => {
|