vv_agent/memory/
summary.rs1use serde::Serialize;
2
3use crate::types::Message;
4
5mod events;
6mod files;
7mod original;
8mod text;
9
10use events::{build_progress_events, collect_errors, current_work_state};
11use files::collect_file_actions;
12use original::collect_original_user_messages;
13
14#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
15pub struct FileAction {
16 pub path: String,
17 pub action: String,
18 pub summary: String,
19}
20
21#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
22pub struct LocalSummary {
23 pub summary_version: String,
24 pub original_user_messages: Vec<String>,
25 pub user_constraints: Vec<String>,
26 pub decisions: Vec<String>,
27 pub files_examined_or_modified: Vec<FileAction>,
28 pub errors_and_fixes: Vec<String>,
29 pub progress: Vec<String>,
30 pub key_facts: Vec<String>,
31 pub open_issues: Vec<String>,
32 pub current_work_state: String,
33 pub next_steps: Vec<String>,
34}
35
36impl LocalSummary {
37 pub fn from_messages(messages: &[Message], event_limit: usize) -> Self {
38 Self {
39 summary_version: "2.0".to_string(),
40 original_user_messages: collect_original_user_messages(messages),
41 user_constraints: Vec::new(),
42 decisions: Vec::new(),
43 files_examined_or_modified: collect_file_actions(messages),
44 errors_and_fixes: collect_errors(messages),
45 progress: build_progress_events(messages, event_limit),
46 key_facts: Vec::new(),
47 open_issues: Vec::new(),
48 current_work_state: current_work_state(messages),
49 next_steps: Vec::new(),
50 }
51 }
52
53 pub fn to_json_string(&self) -> String {
54 serde_json::to_string(self).unwrap_or_else(|_| "{}".to_string())
55 }
56}