Skip to content

Commit 0e0dcdd

Browse files
committed
refactor: update code to use codegraph binary consistently and improve variable naming
1 parent 3316d1e commit 0e0dcdd

File tree

9 files changed

+30
-46
lines changed

9 files changed

+30
-46
lines changed

CLAUDE.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,34 +92,28 @@ cargo doc --workspace --no-deps --open
9292

9393
### Running the MCP Server
9494

95-
**Note:** The MCP server has two binaries:
96-
- `codegraph-official` (recommended): Uses official rmcp SDK, supports both STDIO and HTTP transports
97-
- `codegraph` (legacy): Original implementation, STDIO only
98-
99-
All examples below use `codegraph-official` for consistency.
100-
10195
```bash
10296
# Build the MCP server binary (with AutoAgents experimental feature)
103-
cargo build --release -p codegraph-mcp --bin codegraph-official --features "ai-enhanced,autoagents-experimental,faiss,ollama"
97+
cargo build --release -p codegraph-mcp --bin codegraph --features "ai-enhanced,autoagents-experimental,faiss,ollama"
10498

10599
# Or use Makefile target
106100
make build-mcp-autoagents
107101

108102
# Or build without AutoAgents (uses legacy orchestrator)
109-
cargo build --release -p codegraph-mcp --bin codegraph-official --features "ai-enhanced,faiss,ollama"
103+
cargo build --release -p codegraph-mcp --bin codegraph --features "ai-enhanced,faiss,ollama"
110104

111105
# Start MCP server (stdio mode - RECOMMENDED)
112-
./target/release/codegraph-official serve --transport stdio
106+
./target/release/codegraph start stdio
113107

114108
# Check agentic tool configuration
115-
./target/release/codegraph-official config agent-status
109+
./target/release/codegraph config agent-status
116110
```
117111

118112
**HTTP Transport (Experimental):**
119113
- HTTP transport with SSE streaming is now available
120114
- Requires `server-http` feature flag
121115
- Build: `cargo build --release --features "ai-enhanced,autoagents-experimental,faiss,ollama,server-http"`
122-
- Start: `./target/release/codegraph-official serve --transport http --port 3000`
116+
- Start: `./target/release/codegraph start http --port 3000`
123117
- Endpoints:
124118
- `POST /mcp` - Send MCP requests (returns SSE stream)
125119
- `GET /sse` - Reconnect to existing session
@@ -134,10 +128,10 @@ cargo build --release -p codegraph-mcp --bin codegraph-official --features "ai-e
134128
cargo build --release -p codegraph-mcp --features "ai-enhanced,autoagents-experimental,faiss,ollama,server-http"
135129

136130
# Start HTTP server (default: http://127.0.0.1:3000)
137-
./target/release/codegraph-official serve --transport http
131+
./target/release/codegraph start http
138132

139133
# Custom host and port
140-
./target/release/codegraph-official serve --transport http --host 0.0.0.0 --port 8080
134+
./target/release/codegraph start http --host 0.0.0.0 --port 8080
141135

142136
# Test with curl
143137
curl http://127.0.0.1:3000/health # Should return "OK"
@@ -483,9 +477,9 @@ sudo apt-get install libfaiss-dev # Ubuntu
483477
- Verify SurrealDB connection is working
484478

485479
**MCP tests fail**
486-
- Check binary exists: `./target/release/codegraph-official` or `./target/debug/codegraph-official`
487-
- Try building with AutoAgents: `cargo build -p codegraph-mcp --bin codegraph-official --features "ai-enhanced,autoagents-experimental,faiss,ollama"`
488-
- Or without AutoAgents (legacy): `cargo build -p codegraph-mcp --bin codegraph-official --features "ai-enhanced,faiss,ollama"`
480+
- Check binary exists: `./target/release/codegraph` or `./target/debug/codegraph`
481+
- Try building with AutoAgents: `cargo build -p codegraph-mcp --bin codegraph --features "ai-enhanced,autoagents-experimental,faiss,ollama"`
482+
- Or without AutoAgents (legacy): `cargo build -p codegraph-mcp --bin codegraph --features "ai-enhanced,faiss,ollama"`
489483

490484
## Additional Resources
491485

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/codegraph-mcp/src/bin/codegraph.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -912,11 +912,11 @@ async fn handle_start(
912912
.map_err(|e| anyhow::anyhow!("Server error: {}", e))?;
913913
}
914914
TransportType::Http {
915-
host: _host,
916-
port: _port,
917-
tls: _tls,
918-
cert: _cert,
919-
key: _key,
915+
host,
916+
port,
917+
tls,
918+
cert,
919+
key,
920920
cors: _,
921921
} => {
922922
#[cfg(not(feature = "server-http"))]

crates/codegraph-vector/src/gpu.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl GpuMemoryAllocation {
4444

4545
#[derive(Debug)]
4646
pub struct GpuVectorData {
47-
allocation: GpuMemoryAllocation,
47+
_allocation: GpuMemoryAllocation,
4848
vector_count: usize,
4949
dimension: usize,
5050
uploaded: bool,
@@ -53,7 +53,7 @@ pub struct GpuVectorData {
5353
impl GpuVectorData {
5454
pub fn new(allocation: GpuMemoryAllocation, vector_count: usize, dimension: usize) -> Self {
5555
Self {
56-
allocation,
56+
_allocation: allocation,
5757
vector_count,
5858
dimension,
5959
uploaded: false,

crates/codegraph-vector/src/memory.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct MemoryBlock {
5050
ptr: *mut u8,
5151
size: usize,
5252
used: bool,
53-
allocation_id: usize,
53+
_allocation_id: usize,
5454
}
5555

5656
unsafe impl Send for MemoryBlock {}
@@ -72,7 +72,7 @@ impl MemoryBlock {
7272
ptr,
7373
size,
7474
used: true,
75-
allocation_id,
75+
_allocation_id: allocation_id,
7676
})
7777
}
7878

crates/codegraph-vector/src/rag/context_retriever.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,6 @@ impl ContextRetriever {
188188
Ok(results)
189189
}
190190

191-
#[cfg(not(feature = "faiss"))]
192-
async fn semantic_similarity_search(
193-
&self,
194-
_query_embedding: &[f32],
195-
) -> Result<Vec<RetrievalResult>> {
196-
Ok(Vec::new())
197-
}
198-
199191
async fn keyword_matching_search(&self, keywords: &[String]) -> Result<Vec<RetrievalResult>> {
200192
let mut results = Vec::new();
201193

@@ -397,6 +389,7 @@ impl ContextRetriever {
397389
}
398390
}
399391

392+
#[cfg(feature = "faiss")]
400393
async fn get_node(&self, node_id: NodeId) -> Result<Option<CodeNode>> {
401394
Ok(self.node_cache.get(&node_id).cloned())
402395
}
@@ -464,14 +457,6 @@ fn cosine_similarity(a: &[f32], b: &[f32]) -> f32 {
464457
}
465458
}
466459

467-
fn simple_hash(text: &str) -> u32 {
468-
let mut hash = 5381u32;
469-
for byte in text.bytes() {
470-
hash = hash.wrapping_mul(33).wrapping_add(byte as u32);
471-
}
472-
hash
473-
}
474-
475460
#[cfg(test)]
476461
mod tests {
477462
use super::*;

crates/codegraph-vector/src/rag/rag_system.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::rag::{
22
ContextRetriever, GeneratedResponse, GenerationConfig, ProcessedQuery, QueryProcessor,
33
RankedResult, RankingConfig, ResponseGenerator, ResultRanker, RetrievalConfig,
44
};
5+
#[cfg(feature = "faiss")]
56
use crate::EmbeddingGenerator;
67
#[cfg(feature = "faiss")]
78
use crate::{FaissVectorStore, SemanticSearch};
@@ -71,6 +72,7 @@ pub struct RAGSystem {
7172
response_generator: ResponseGenerator,
7273
#[cfg(feature = "faiss")]
7374
semantic_search: Option<Arc<SemanticSearch>>,
75+
#[cfg(feature = "faiss")]
7476
embedding_generator: Arc<EmbeddingGenerator>,
7577
query_cache: Arc<RwLock<HashMap<String, QueryResult>>>,
7678
#[cfg(feature = "cache")]
@@ -99,6 +101,7 @@ impl RAGSystem {
99101
config.ranking.clone(),
100102
)));
101103
let response_generator = ResponseGenerator::with_config(config.generation.clone());
104+
#[cfg(feature = "faiss")]
102105
let embedding_generator = Arc::new(EmbeddingGenerator::default());
103106

104107
#[cfg(feature = "cache")]
@@ -126,6 +129,7 @@ impl RAGSystem {
126129
response_generator,
127130
#[cfg(feature = "faiss")]
128131
semantic_search: None,
132+
#[cfg(feature = "faiss")]
129133
embedding_generator,
130134
query_cache: Arc::new(RwLock::new(HashMap::new())),
131135
#[cfg(feature = "cache")]

crates/codegraph-vector/src/rag/response_generator.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ pub struct ResponseGenerator {
6262
struct ResponseTemplate {
6363
pattern: String,
6464
template: String,
65-
confidence_boost: f32,
6665
}
6766

6867
impl ResponseGenerator {
@@ -687,22 +686,18 @@ impl ResponseGenerator {
687686
ResponseTemplate {
688687
pattern: "how".to_string(),
689688
template: "To accomplish this, you can use {node_name} which is a {node_type}:\n\n{content}".to_string(),
690-
confidence_boost: 0.2,
691689
},
692690
ResponseTemplate {
693691
pattern: "what".to_string(),
694692
template: "{node_name} is a {node_type} that provides the following functionality:\n\n{content}".to_string(),
695-
confidence_boost: 0.1,
696693
},
697694
ResponseTemplate {
698695
pattern: "find".to_string(),
699696
template: "I found {node_name} ({node_type}) which matches your criteria:\n\n{content}".to_string(),
700-
confidence_boost: 0.1,
701697
},
702698
ResponseTemplate {
703699
pattern: "error".to_string(),
704700
template: "For error handling, consider using {node_name}:\n\n{content}".to_string(),
705-
confidence_boost: 0.3,
706701
},
707702
]
708703
}

crates/codegraph-vector/src/search.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ impl SemanticSearch {
524524
}
525525
}
526526

527+
#[cfg(feature = "faiss")]
527528
fn cosine_similarity(a: &[f32], b: &[f32]) -> f32 {
528529
if a.len() != b.len() {
529530
return 0.0;
@@ -540,6 +541,7 @@ fn cosine_similarity(a: &[f32], b: &[f32]) -> f32 {
540541
}
541542
}
542543

544+
#[cfg(feature = "faiss")]
543545
fn simple_hash(text: &str) -> u32 {
544546
let mut hash = 5381u32;
545547
for byte in text.bytes() {
@@ -548,6 +550,7 @@ fn simple_hash(text: &str) -> u32 {
548550
hash
549551
}
550552

553+
#[cfg(feature = "faiss")]
551554
fn build_filter_signature(filters: Option<&SearchFilters>) -> String {
552555
if let Some(f) = filters {
553556
let mut langs: Vec<String> = f
@@ -579,6 +582,7 @@ fn build_filter_signature(filters: Option<&SearchFilters>) -> String {
579582
}
580583
}
581584

585+
#[cfg(feature = "faiss")]
582586
fn normalize_scores(results: &mut [SearchResult]) {
583587
if results.is_empty() {
584588
return;

0 commit comments

Comments
 (0)