Files
mcp-memory/server/src/models.rs
T

222 lines
5.8 KiB
Rust

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct CodeChange {
pub timestamp: u64,
pub file_path: String,
pub description: String,
pub git_commit: Option<String>,
pub git_branch: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct StickyNote {
pub timestamp: u64,
pub content: String,
#[serde(default)]
pub expires_at: Option<u64>,
}
pub fn default_namespace() -> String {
"global".to_string()
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct Entity {
pub name: String,
pub entity_type: String,
#[serde(default)]
pub observations: Vec<String>,
#[serde(default = "default_namespace")]
pub namespace: String,
#[serde(default)]
pub git_branch: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, JsonSchema)]
pub struct Relation {
pub from: String,
pub to: String,
pub relation_type: String,
#[serde(default = "default_namespace")]
pub namespace: String,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct KnowledgeGraph {
#[serde(default)]
pub entities: HashMap<String, Entity>,
#[serde(default)]
pub relations: Vec<Relation>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct AcceptanceCriteria {
pub id: String,
pub description: String,
pub is_met: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Task {
pub id: String,
pub title: String,
pub status: String,
pub description: String,
pub created_at: u64,
pub updated_at: u64,
pub git_branch: Option<String>,
#[serde(default)]
pub parent_id: Option<String>,
#[serde(default)]
pub expires_at: Option<u64>,
#[serde(default)]
pub dependencies: Vec<String>,
#[serde(default)]
pub acceptance_criteria: Vec<AcceptanceCriteria>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Snippet {
pub name: String,
pub language: String,
pub code: String,
pub description: String,
pub updated_at: u64,
#[serde(default)]
pub embedding: Option<Vec<f32>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Adr {
pub id: String,
pub title: String,
pub context: String,
pub decision: String,
pub consequence: String,
#[serde(default = "default_adr_status")]
pub status: String,
#[serde(default)]
pub supersedes: Option<String>,
pub timestamp: u64,
}
fn default_adr_status() -> String {
"accepted".to_string()
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Preference {
pub key: String,
pub value: String,
pub updated_at: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct ErrorFix {
pub signature: String,
pub solution: String,
pub timestamp: u64,
pub git_commit: Option<String>,
pub git_branch: Option<String>,
#[serde(default)]
pub embedding: Option<Vec<f32>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct PinnedFile {
pub namespace: String,
pub file_path: String,
pub timestamp: u64,
pub git_branch: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct SessionSummary {
pub timestamp: u64,
pub summary: String,
pub namespace: String,
#[serde(default)]
pub expires_at: Option<u64>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct HandoffMemo {
pub id: String,
pub author: String,
pub content: String,
#[serde(default)]
pub expires_at: Option<u64>,
pub namespace: String,
pub timestamp: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct EnvFingerprint {
pub namespace: String,
pub os: String,
pub shell: String,
pub tool_versions: HashMap<String, String>,
pub updated_at: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct EnvRequirement {
pub namespace: String,
pub key: String,
pub description: String,
pub is_secret: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Milestone {
pub id: String,
pub title: String,
pub status: String,
pub namespace: String,
pub target_date: Option<u64>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct EnvironmentDetail {
pub namespace: String,
pub name: String,
pub url: String,
pub description: String,
pub requires_vpn: bool,
pub updated_at: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct PrChecklistItem {
pub namespace: String,
pub id: String,
pub description: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct TechDebt {
pub id: String,
pub namespace: String,
pub description: String,
pub ideal_solution: String,
pub is_resolved: bool,
pub created_at: u64,
pub git_commit: Option<String>,
pub git_branch: Option<String>,
#[serde(default)]
pub embedding: Option<Vec<f32>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct ContextWorkspace {
pub name: String,
pub namespace: String,
pub pinned_files: Vec<String>,
pub active_task_ids: Vec<String>,
pub saved_at: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct GateRecord {
pub id: String,
pub action: String,
pub target: String,
pub namespace: Option<String>,
pub params: std::collections::HashMap<String, String>,
pub status: String,
pub reason: Option<String>,
pub timestamp: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct TerminalHistory {
pub command: String,
pub exit_code: i32,
pub cwd: String,
pub os: String,
pub timestamp: u64,
}