Skip to content

Commit bb1fde5

Browse files
authored
Merge pull request #60 from sopaco/dev
Dev
2 parents 4e1bc22 + ec83478 commit bb1fde5

59 files changed

Lines changed: 3556 additions & 1666 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ chrono = { version = "0.4", features = ["serde"] }
4141
rig-core = "0.31"
4242

4343
# HTTP client
44-
reqwest = { version = "0.12", features = ["json"] }
44+
reqwest = { version = "0.12", features = ["json", "rustls-tls"], default-features = false }
4545

4646
# Logging
4747
tracing = "0.1"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ The benchmark uses a professional memory system evaluation framework located in
428428
- **Professional Metrics**: Recall@K, Precision@K, MRR, NDCG, and answer quality metrics
429429
- **Enhanced Dataset**: 50 conversations with 150 questions covering various scenarios
430430
- **Statistical Analysis**: 95% confidence intervals, standard deviation, and category-based statistics
431-
- **Multi-System Support**: Supports comparison between Cortex Memory, LangMem, and Simple RAG baselines
431+
- **Cortex-Only Evaluation**: Dedicated evaluation workflow for Cortex Memory using the LoCoMo methodology
432432

433433
For more details on running the evaluation, see the [lomoco-evaluation README](examples/lomoco-evaluation/README.md).
434434

README_zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ Cortex Memory已使用**LOCOMO数据集**(50个对话,150个问题)通过
429429
- **专业指标**:Recall@K、Precision@K、MRR、NDCG和答案质量指标
430430
- **增强数据集**:50个对话,150个问题,涵盖各种场景
431431
- **统计分析**:95%置信区间、标准差和基于类别的统计
432-
- **多系统支持**支持Cortex Memory、LangMem和简单RAG基线之间的比较
432+
- **Cortex 专用评测**基于 LoCoMo 方法的 Cortex Memory 专用评测流程
433433

434434
有关运行评估的更多详细信息,请参阅[lomoco-evaluation README](examples/lomoco-evaluation/README.md)
435435

cortex-mem-cli/src/main.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,26 @@ async fn main() -> Result<()> {
205205
})?;
206206

207207
// Determine data directory
208-
let data_dir = config.cortex.data_dir();
208+
// Priority:
209+
// 1. data_dir specified in config file (supports relative path to config file location)
210+
// 2. CORTEX_DATA_DIR environment variable
211+
// 3. Directory containing config.toml (the workspace root)
212+
let config_dir = cli.config.parent().map(|p| p.to_path_buf()).unwrap_or_default();
213+
214+
let data_dir = if let Some(ref dir) = config.cortex.data_dir {
215+
// If data_dir is a relative path, resolve it relative to config file location
216+
let dir_path = std::path::Path::new(dir);
217+
if dir_path.is_relative() {
218+
config_dir.join(dir_path).to_string_lossy().to_string()
219+
} else {
220+
dir.clone()
221+
}
222+
} else if let Ok(env_dir) = std::env::var("CORTEX_DATA_DIR") {
223+
env_dir
224+
} else {
225+
// Use the directory containing config.toml as the workspace root
226+
config_dir.to_string_lossy().to_string()
227+
};
209228

210229
// Handle tenant list command early (doesn't need MemoryOperations)
211230
if let Commands::Tenant { action } = cli.command {

cortex-mem-config/src/lib.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,22 @@ fn default_enable_intent_analysis() -> bool {
4444

4545
impl CortexConfig {
4646
/// Get the effective data directory
47+
/// Returns the configured data_dir, or falls back to default behavior.
48+
/// Note: Callers should handle the None case appropriately based on their context.
4749
pub fn data_dir(&self) -> String {
4850
self.data_dir.clone().unwrap_or_else(|| {
4951
Self::default_data_dir()
5052
})
5153
}
5254

5355
/// Get the default data directory
56+
/// Priority:
57+
/// 1. Environment variable CORTEX_DATA_DIR
58+
/// 2. Current directory "."
5459
fn default_data_dir() -> String {
55-
// 优先级:
56-
// 1. 环境变量 CORTEX_DATA_DIR
57-
// 2. 应用数据目录/cortex (TARS 应用)
58-
// 3. 当前目录 ./.cortex
5960
std::env::var("CORTEX_DATA_DIR")
6061
.ok()
61-
.or_else(|| {
62-
// 尝试使用应用数据目录(TARS 默认路径)
63-
directories::ProjectDirs::from("com", "cortex-mem", "tars")
64-
.map(|dirs| {
65-
let cortex_dir = dirs.data_dir().join("cortex");
66-
cortex_dir.to_string_lossy().to_string()
67-
})
68-
})
69-
.unwrap_or_else(|| "./.cortex".to_string())
62+
.unwrap_or_else(|| ".".to_string())
7063
}
7164
}
7265

cortex-mem-insights/src/lib/api.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ class ApiClient {
7272

7373
// Filesystem endpoints
7474
async listDirectory(path: string): Promise<FileEntryResponse[]> {
75-
return this.request<FileEntryResponse[]>(`/filesystem/list?uri=${encodeURIComponent(path)}`);
75+
const response = await this.request<{ uri: string; total: number; entries: FileEntryResponse[] }>(
76+
`/filesystem/list?uri=${encodeURIComponent(path)}`
77+
);
78+
return response.entries;
7679
}
7780

7881
async readFile(path: string): Promise<string> {

cortex-mem-insights/src/lib/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ export interface FileEntryResponse {
1515
modified: string;
1616
}
1717

18+
export interface LsResponse {
19+
uri: string;
20+
total: number;
21+
entries: FileEntryResponse[];
22+
}
23+
1824
export interface SessionInfo {
1925
thread_id: string;
2026
status: string;

cortex-mem-mcp/src/main.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,35 @@ struct Cli {
4848
/// Disable auto-trigger feature
4949
#[arg(long, default_value = "false")]
5050
no_auto_trigger: bool,
51+
52+
/// Path to log file. If specified, logs will be written to this file.
53+
/// If not specified, logging is disabled (MCP protocol uses stdio).
54+
#[arg(long)]
55+
log_file: Option<PathBuf>,
5156
}
5257

5358
#[tokio::main]
5459
async fn main() -> Result<()> {
5560
let cli = Cli::parse();
5661

57-
// Initialize logging
58-
tracing_subscriber::fmt()
59-
.with_max_level(tracing::Level::INFO)
60-
.init();
62+
// Initialize logging only if --log-file is specified
63+
// MCP protocol uses stdio for JSON-RPC, so we avoid console output by default
64+
if let Some(ref log_file) = cli.log_file {
65+
// Create parent directory if needed
66+
if let Some(parent) = log_file.parent() {
67+
std::fs::create_dir_all(parent)?;
68+
}
69+
70+
let file = std::fs::OpenOptions::new()
71+
.create(true)
72+
.append(true)
73+
.open(log_file)?;
74+
75+
tracing_subscriber::fmt()
76+
.with_writer(std::sync::Arc::new(file))
77+
.with_max_level(tracing::Level::INFO)
78+
.init();
79+
}
6180

6281
info!("Starting Cortex Memory MCP Server");
6382
info!("Using configuration file: {:?}", cli.config);

0 commit comments

Comments
 (0)