mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-23 12:55:26 +00:00
feat(cli): Implement full hooks system in Rust CLI
Add comprehensive hooks subcommand to ruvector CLI with: Core Commands: - init: Initialize hooks in project - install: Install hooks into Claude settings - stats: Show intelligence statistics Hook Operations: - pre-edit/post-edit: File editing intelligence - pre-command/post-command: Command execution hooks - session-start/session-end: Session management - pre-compact: Pre-compact hook Memory & Learning: - remember: Store content in semantic memory - recall: Search memory semantically - learn: Record Q-learning trajectories - suggest: Get best action for state - route: Route task to best agent V3 Intelligence: - record-error: Learn from error patterns - suggest-fix: Get fixes for error codes - suggest-next: Predict next files to edit - should-test: Check if tests should run Swarm/Hive-Mind: - swarm-register: Register agents - swarm-coordinate: Record coordination - swarm-optimize: Optimize task distribution - swarm-recommend: Get best agent - swarm-heal: Handle agent failures - swarm-stats: Show swarm statistics All commands tested and working. Data persists to ~/.ruvector/intelligence.json for cross-session learning.
This commit is contained in:
parent
b3b6e00b1a
commit
4ab66c7314
5 changed files with 1448 additions and 15 deletions
1342
crates/ruvector-cli/src/cli/hooks.rs
Normal file
1342
crates/ruvector-cli/src/cli/hooks.rs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -3,9 +3,11 @@
|
|||
pub mod commands;
|
||||
pub mod format;
|
||||
pub mod graph;
|
||||
pub mod hooks;
|
||||
pub mod progress;
|
||||
|
||||
pub use commands::*;
|
||||
pub use format::*;
|
||||
pub use graph::*;
|
||||
pub use hooks::*;
|
||||
pub use progress::ProgressTracker;
|
||||
|
|
|
|||
|
|
@ -136,6 +136,12 @@ enum Commands {
|
|||
#[command(subcommand)]
|
||||
action: cli::graph::GraphCommands,
|
||||
},
|
||||
|
||||
/// Self-learning intelligence hooks for Claude Code
|
||||
Hooks {
|
||||
#[command(subcommand)]
|
||||
action: cli::hooks::HooksCommands,
|
||||
},
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
|
|
@ -230,6 +236,82 @@ async fn main() -> Result<()> {
|
|||
} => cli::graph::serve_graph(&db, &host, http_port, grpc_port, graphql, &config),
|
||||
}
|
||||
}
|
||||
Commands::Hooks { action } => {
|
||||
use cli::hooks::HooksCommands;
|
||||
match action {
|
||||
HooksCommands::Init { force } => cli::hooks::init_hooks(force, &config),
|
||||
HooksCommands::Install { settings_dir } => cli::hooks::install_hooks(&settings_dir, &config),
|
||||
HooksCommands::Stats => cli::hooks::show_stats(&config),
|
||||
HooksCommands::Remember { memory_type, content } => {
|
||||
cli::hooks::remember_content(&memory_type, &content.join(" "), &config)
|
||||
}
|
||||
HooksCommands::Recall { query, top_k } => {
|
||||
cli::hooks::recall_content(&query.join(" "), top_k, &config)
|
||||
}
|
||||
HooksCommands::Learn { state, action, reward } => {
|
||||
cli::hooks::learn_trajectory(&state, &action, reward, &config)
|
||||
}
|
||||
HooksCommands::Suggest { state, actions } => {
|
||||
cli::hooks::suggest_action(&state, &actions, &config)
|
||||
}
|
||||
HooksCommands::Route { task, file, crate_name, operation } => {
|
||||
cli::hooks::route_task(
|
||||
&task.join(" "),
|
||||
file.as_deref(),
|
||||
crate_name.as_deref(),
|
||||
&operation,
|
||||
&config,
|
||||
)
|
||||
}
|
||||
HooksCommands::PreEdit { file } => cli::hooks::pre_edit_hook(&file, &config),
|
||||
HooksCommands::PostEdit { file, success } => {
|
||||
cli::hooks::post_edit_hook(&file, success, &config)
|
||||
}
|
||||
HooksCommands::PreCommand { command } => {
|
||||
cli::hooks::pre_command_hook(&command.join(" "), &config)
|
||||
}
|
||||
HooksCommands::PostCommand { command, success, stderr } => {
|
||||
cli::hooks::post_command_hook(&command.join(" "), success, stderr.as_deref(), &config)
|
||||
}
|
||||
HooksCommands::SessionStart { session_id } => {
|
||||
cli::hooks::session_start_hook(session_id.as_deref(), &config)
|
||||
}
|
||||
HooksCommands::SessionEnd { export_metrics } => {
|
||||
cli::hooks::session_end_hook(export_metrics, &config)
|
||||
}
|
||||
HooksCommands::PreCompact { length } => {
|
||||
cli::hooks::pre_compact_hook(length, &config)
|
||||
}
|
||||
HooksCommands::RecordError { command, stderr } => {
|
||||
cli::hooks::record_error_cmd(&command, &stderr, &config)
|
||||
}
|
||||
HooksCommands::SuggestFix { error_code } => {
|
||||
cli::hooks::suggest_fix_cmd(&error_code, &config)
|
||||
}
|
||||
HooksCommands::SuggestNext { file, count } => {
|
||||
cli::hooks::suggest_next_cmd(&file, count, &config)
|
||||
}
|
||||
HooksCommands::ShouldTest { file } => {
|
||||
cli::hooks::should_test_cmd(&file, &config)
|
||||
}
|
||||
HooksCommands::SwarmRegister { agent_id, agent_type, capabilities } => {
|
||||
cli::hooks::swarm_register_cmd(&agent_id, &agent_type, capabilities.as_deref(), &config)
|
||||
}
|
||||
HooksCommands::SwarmCoordinate { source, target, weight } => {
|
||||
cli::hooks::swarm_coordinate_cmd(&source, &target, weight, &config)
|
||||
}
|
||||
HooksCommands::SwarmOptimize { tasks } => {
|
||||
cli::hooks::swarm_optimize_cmd(&tasks, &config)
|
||||
}
|
||||
HooksCommands::SwarmRecommend { task_type } => {
|
||||
cli::hooks::swarm_recommend_cmd(&task_type, &config)
|
||||
}
|
||||
HooksCommands::SwarmHeal { agent_id } => {
|
||||
cli::hooks::swarm_heal_cmd(&agent_id, &config)
|
||||
}
|
||||
HooksCommands::SwarmStats => cli::hooks::swarm_stats_cmd(&config),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Handle errors
|
||||
|
|
|
|||
|
|
@ -2,20 +2,24 @@
|
|||
|
||||
Complete command-line reference for the RuVector hooks system.
|
||||
|
||||
> **Implementation Status**
|
||||
> - **Working NOW**: `.claude/intelligence/cli.js` (Node.js)
|
||||
> - **Planned**: `npx ruvector hooks` (Rust CLI - see [Implementation Plan](IMPLEMENTATION_PLAN.md))
|
||||
> **Implementation Status**: ✅ **FULLY IMPLEMENTED**
|
||||
> - **Rust CLI**: `ruvector hooks <command>` (recommended)
|
||||
> - **Node.js**: `.claude/intelligence/cli.js` (legacy)
|
||||
|
||||
## Synopsis
|
||||
|
||||
**Current (Node.js):**
|
||||
**Rust CLI (Recommended):**
|
||||
```bash
|
||||
node .claude/intelligence/cli.js <command> [args]
|
||||
# Direct execution
|
||||
cargo run --bin ruvector -- hooks <command> [options]
|
||||
|
||||
# After installation
|
||||
ruvector hooks <command> [options]
|
||||
```
|
||||
|
||||
**Planned (Rust CLI):**
|
||||
**Node.js (Legacy):**
|
||||
```bash
|
||||
npx ruvector hooks <command> [options]
|
||||
node .claude/intelligence/cli.js <command> [args]
|
||||
```
|
||||
|
||||
---
|
||||
|
|
|
|||
|
|
@ -2,18 +2,21 @@
|
|||
|
||||
Intelligent hooks for Claude Code that provide automatic agent assignment, code formatting, neural pattern training, and cross-session memory persistence.
|
||||
|
||||
> **Implementation Status**: The hooks intelligence layer is fully functional via Node.js CLI (`.claude/intelligence/cli.js`). The portable Rust CLI (`npx ruvector hooks`) is planned - see [Implementation Plan](IMPLEMENTATION_PLAN.md).
|
||||
> **Implementation Status**: ✅ **FULLY IMPLEMENTED** - Both implementations are now functional:
|
||||
> - **Rust CLI**: `ruvector hooks <command>` (portable, high-performance)
|
||||
> - **Node.js**: `.claude/intelligence/cli.js` (legacy compatibility)
|
||||
|
||||
## Current Implementation
|
||||
## Available Implementations
|
||||
|
||||
```bash
|
||||
# Working NOW - Node.js intelligence layer
|
||||
node .claude/intelligence/cli.js pre-edit <file>
|
||||
node .claude/intelligence/cli.js stats
|
||||
# Rust CLI (recommended - faster, portable)
|
||||
cargo run --bin ruvector -- hooks stats
|
||||
cargo run --bin ruvector -- hooks pre-edit <file>
|
||||
cargo run --bin ruvector -- hooks post-edit <file> --success
|
||||
|
||||
# Planned - Portable Rust CLI (see Implementation Plan)
|
||||
npx ruvector hooks pre-edit --file <file>
|
||||
npx ruvector hooks stats
|
||||
# Node.js (legacy - still functional)
|
||||
node .claude/intelligence/cli.js stats
|
||||
node .claude/intelligence/cli.js pre-edit <file>
|
||||
```
|
||||
|
||||
## Quick Navigation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue