1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
//! # CAI Core - Shared types, traits, and utilities
//!
//! This crate provides the foundational data structures and shared utilities
//! used throughout the CAI (Coding Agent Insights) workspace.
//!
//! ## Overview
//!
//! `cai-core` defines the core domain model for representing AI coding interactions.
//! All other crates in the workspace depend on these types to ensure consistency
//! across the system.
//!
//! ## Core Types
//!
//! - [`Entry`] - Represents a single AI coding interaction with all associated data
//! - [`Source`] - Identifies the origin system (Claude, Codex, Git, etc.)
//! - [`Metadata`] - Extensible metadata for additional context
//! - [`Error`] - Unified error type for CAI operations
//! - [`Result<T>`] - Type alias for `Result<T, Error>`
//!
//! ## Usage
//!
//! Creating a basic entry:
//!
//! ```rust
//! use cai_core::{Entry, Source, Metadata};
//! use chrono::Utc;
//!
//! let entry = Entry {
//! id: "test-entry-123".to_string(),
//! source: Source::Claude,
//! timestamp: Utc::now(),
//! prompt: "Help me refactor this function".to_string(),
//! response: "Here's the improved version...".to_string(),
//! metadata: Metadata::default(),
//! };
//! ```
//!
//! Working with metadata:
//!
//! ```rust
//! use cai_core::Metadata;
//! use std::collections::HashMap;
//!
//! let mut metadata = Metadata {
//! file_path: Some("src/main.rs".to_string()),
//! repo_url: Some("https://github.com/user/repo".to_string()),
//! commit_hash: Some("abc123def".to_string()),
//! language: Some("Rust".to_string()),
//! extra: HashMap::new(),
//! };
//!
//! // Add custom fields
//! metadata.extra.insert("complexity".to_string(), "high".to_string());
//! metadata.extra.insert("reviewed".to_string(), "true".to_string());
//! ```
//!
//! Error handling:
//!
//! ```rust
//! use cai_core::{Error, Result, Entry};
//!
//! fn process_entry(entry: &Entry) -> Result<()> {
//! if entry.prompt.is_empty() {
//! return Err(Error::Message("Prompt cannot be empty".to_string()));
//! }
//! // Process the entry...
//! Ok(())
//! }
//! ```
//!
//! ## Design Principles
//!
//! - **Minimal dependencies**: Only essential dependencies (serde, chrono)
//! - **Serialization**: All public types implement `Serialize` and `Deserialize`
//! - **Extensibility**: `Metadata.extra` allows custom fields without breaking changes
//! - **Type safety**: Enums use `#[non_exhaustive]` for future-proofing
//!
//! ## Testing
//!
//! ```bash
//! # Run all tests
//! cargo test -p cai-core
//!
//! # Run with coverage
//! cargo llvm-cov -p cai-core
//! ```
use ;
use ;
/// Core entry representing a single AI coding interaction
/// Source system identifier
/// Metadata associated with an entry
/// Result type for CAI operations
pub type Result<T> = Result;
/// Core error types