Skip to content

Commit f64f91f

Browse files
committed
chore: bump version to 0.1.20 and fix indexer loop
1 parent c3279ea commit f64f91f

9 files changed

Lines changed: 90 additions & 16 deletions

File tree

Cargo.lock

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

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ccm-cli"
3-
version = "0.1.19"
3+
version = "0.1.20"
44
edition = "2021"
55
authors = ["Senol Dogan"]
66
description = "CLI for Cognitive Codebase Matrix"

cli/src/main.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,22 @@ async fn main() -> anyhow::Result<()> {
111111
notify::recommended_watcher(move |res: notify::Result<notify::Event>| {
112112
match res {
113113
Ok(event) => {
114-
// Simple filter for interesting extensions
114+
// Filter out ignored directories and relevant extensions
115115
let is_relevant = event.paths.iter().any(|p| {
116+
// Skip common ignored directories
117+
for component in p.components() {
118+
let s = component.as_os_str().to_string_lossy();
119+
if s == "data"
120+
|| s == ".ccm"
121+
|| s == "node_modules"
122+
|| s == "target"
123+
|| s == ".git"
124+
|| s == ".agent"
125+
{
126+
return false;
127+
}
128+
}
129+
116130
if let Some(ext) = p.extension().and_then(|e| e.to_str()) {
117131
matches!(
118132
ext,
@@ -156,7 +170,14 @@ async fn main() -> anyhow::Result<()> {
156170
while rx.try_recv().is_ok() {}
157171

158172
tracing::info!("Re-indexing...");
159-
let _ = ccm_core::index_directory(&path_str, db_path_str.as_deref()).await;
173+
if let Err(e) = ccm_core::update_index(&path_str, db_path_str.as_deref()).await
174+
{
175+
tracing::warn!(
176+
"Incremental indexing failed: {}. Falling back to full index.",
177+
e
178+
);
179+
let _ = ccm_core::index_directory(&path_str, db_path_str.as_deref()).await;
180+
}
160181
}
161182
}
162183
}

core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ccm-core"
3-
version = "0.1.19"
3+
version = "0.1.20"
44
edition = "2021"
55
authors = ["Senol Dogan"]
66
description = "Core engine for Cognitive Codebase Matrix"

core/src/lib.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,57 @@ pub async fn index_directory(path: &str, db_path: Option<&str>) -> Result<IndexS
177177
Ok(stats)
178178
}
179179

180+
/// Updates an existing index incrementally (using Git).
181+
/// If the index or graph does not exist, it falls back to a full index.
182+
pub async fn update_index(path: &str, db_path: Option<&str>) -> Result<()> {
183+
use tracing::{info, warn};
184+
185+
// Determine paths
186+
let default_db_path = std::path::Path::new(path).join("data/ccm_db");
187+
let db_path_buf = db_path
188+
.map(std::path::PathBuf::from)
189+
.unwrap_or(default_db_path);
190+
let db_path_str = db_path_buf.to_string_lossy().to_string();
191+
192+
let parent_dir = db_path_buf.parent().ok_or_else(|| {
193+
anyhow::anyhow!(
194+
"Invalid DB path '{}': cannot determine parent directory",
195+
db_path_str
196+
)
197+
})?;
198+
199+
let graph_path = parent_dir.join("ccm_graph.json");
200+
201+
if !graph_path.exists() {
202+
info!(
203+
"Graph not found at {}, performing full index",
204+
graph_path.display()
205+
);
206+
index_directory(path, db_path).await?;
207+
return Ok(());
208+
}
209+
210+
// Load graph
211+
let graph = CodeGraph::from_file(&graph_path.to_string_lossy())?;
212+
let store = LanceDbStore::new(&db_path_str, "code_vectors").await?;
213+
let graph_arc = std::sync::Arc::new(tokio::sync::RwLock::new(graph));
214+
215+
let engine = RetrievalEngine::new(graph_arc.clone(), store);
216+
217+
// Run incremental index
218+
info!("Starting incremental indexing for {}", path);
219+
engine.incremental_index(path).await?;
220+
221+
// Save graph back to disk
222+
let updated_graph = graph_arc.read().await;
223+
match updated_graph.save_to_file(&graph_path.to_string_lossy()) {
224+
Ok(_) => info!(path = %graph_path.display(), "Graph updated on disk"),
225+
Err(e) => warn!(error = %e, "Failed to save updated graph"),
226+
}
227+
228+
Ok(())
229+
}
230+
180231
/// Statistics from an indexing operation
181232
#[derive(Debug, Default)]
182233
pub struct IndexStats {

core/src/vector/store.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,14 @@ impl LanceDbStore {
125125

126126
let total_batches = all_chunks.len().div_ceil(BATCH_SIZE);
127127
for (batch_idx, batch) in all_chunks.chunks(BATCH_SIZE).enumerate() {
128-
eprintln!(
129-
"Embedding batch {}/{} ({} chunks)",
130-
batch_idx + 1,
131-
total_batches,
132-
batch.len()
133-
);
128+
if batch_idx % 20 == 0 || (batch_idx + 1) == total_batches {
129+
eprintln!(
130+
"Embedding batch {}/{} ({} chunks)",
131+
batch_idx + 1,
132+
total_batches,
133+
batch.len()
134+
);
135+
}
134136

135137
let batch_texts: Vec<String> = batch.to_vec();
136138
let batch_embeddings = embedder.embed(batch_texts).await?;

mcp/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ccm-mcp"
3-
version = "0.1.19"
3+
version = "0.1.20"
44
edition = "2021"
55
description = "MCP (Model Context Protocol) Server for CCM"
66
authors = ["Senol Dogan"]

npm/bin/ccm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const fs = require('fs');
66
const os = require('os');
77
const https = require('https');
88

9-
const VERSION = "0.1.19";
9+
const VERSION = "0.1.20";
1010
const REPO = 'senoldogann/LLM-Context-Manager';
1111
const BIN_DIR = path.join(os.homedir(), '.ccm', 'bin');
1212

npm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@senoldogann/context-manager",
3-
"version": "0.1.19",
3+
"version": "0.1.20",
44
"description": "LLM Context Manager MCP Server & CLI wrapper using npx",
55
"main": "bin/ccm.js",
66
"bin": {

0 commit comments

Comments
 (0)