use serde::{Deserialize, Serialize};
use serde_json::{Map, Value};
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct RepositoryFingerprint {
pub remote_url: Option<String>,
pub host: Option<String>,
pub owner: Option<String>,
pub repo_name: Option<String>,
pub default_branch: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkspaceBinding {
pub project_id: String,
pub local_root: Option<String>,
pub branch: Option<String>,
pub last_commit: Option<String>,
pub client_label: Option<String>,
pub last_sync: Option<String>,
}
impl Default for WorkspaceBinding {
fn default() -> Self {
Self {
project_id: "pending".to_string(),
local_root: None,
branch: None,
last_commit: None,
client_label: None,
last_sync: None,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProjectResolutionRequest {
pub fingerprint: RepositoryFingerprint,
pub suggested_slug: Option<String>,
pub workspace_binding: Option<WorkspaceBinding>,
pub project_metadata: Option<ProjectMetadataEnvelope>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProjectRecord {
pub project_id: String,
pub slug: String,
pub fingerprint: Option<RepositoryFingerprint>,
pub created_at: String,
pub updated_at: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProjectResolutionResponse {
pub project: ProjectRecord,
pub workspace_bound: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolDefinition {
pub name: String,
pub description: String,
#[serde(rename = "inputSchema")]
pub input_schema: Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolListResponse {
pub tools: Vec<ToolDefinition>,
pub total: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolCallRequest {
pub name: String,
pub arguments: Map<String, Value>,
pub project_id: Option<String>,
pub project_slug: Option<String>,
pub repository_fingerprint: Option<RepositoryFingerprint>,
pub workspace_binding: Option<WorkspaceBinding>,
pub project_metadata: Option<ProjectMetadataEnvelope>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolCallResponse {
pub result: Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServerConnection {
pub endpoint: String,
pub token: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProjectMetadataEnvelope {
pub schema_version: u32,
pub summary: ProjectMetadataSummary,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProjectMetadataSummary {
pub total_file_count: u64,
pub source_file_count: u64,
pub markers: Vec<String>,
pub languages: Vec<ProjectLanguageStat>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProjectLanguageStat {
pub language: String,
pub file_count: u64,
}
#[derive(Debug, Clone)]
pub struct ProjectContext {
pub project_slug: String,
pub project_root: String,
pub fingerprint: RepositoryFingerprint,
pub workspace_binding: WorkspaceBinding,
pub project_metadata: Option<ProjectMetadataEnvelope>,
}
pub type RepositoryContext = ProjectContext;