agentic_navigation_guide/
types.rs1use serde::{Deserialize, Serialize};
4use std::path::PathBuf;
5
6#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
8pub enum FilesystemItem {
9 File {
11 path: String,
13 comment: Option<String>,
15 },
16 Directory {
18 path: String,
20 comment: Option<String>,
22 children: Vec<NavigationGuideLine>,
24 },
25 Symlink {
27 path: String,
29 comment: Option<String>,
31 target: Option<String>,
33 },
34}
35
36#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
38pub struct NavigationGuideLine {
39 pub line_number: usize,
41 pub indent_level: usize,
43 pub item: FilesystemItem,
45}
46
47impl NavigationGuideLine {
48 pub fn path(&self) -> &str {
50 match &self.item {
51 FilesystemItem::File { path, .. }
52 | FilesystemItem::Directory { path, .. }
53 | FilesystemItem::Symlink { path, .. } => path,
54 }
55 }
56
57 pub fn comment(&self) -> Option<&str> {
59 match &self.item {
60 FilesystemItem::File { comment, .. }
61 | FilesystemItem::Directory { comment, .. }
62 | FilesystemItem::Symlink { comment, .. } => comment.as_deref(),
63 }
64 }
65
66 pub fn is_directory(&self) -> bool {
68 matches!(self.item, FilesystemItem::Directory { .. })
69 }
70
71 pub fn children(&self) -> Option<&[NavigationGuideLine]> {
73 match &self.item {
74 FilesystemItem::Directory { children, .. } => Some(children),
75 _ => None,
76 }
77 }
78}
79
80#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
82pub struct NavigationGuide {
83 pub items: Vec<NavigationGuideLine>,
85 pub prologue: Option<String>,
87 pub epilogue: Option<String>,
89}
90
91impl NavigationGuide {
92 pub fn new() -> Self {
94 Self {
95 items: Vec::new(),
96 prologue: None,
97 epilogue: None,
98 }
99 }
100
101 pub fn get_full_path(&self, item: &NavigationGuideLine) -> PathBuf {
103 PathBuf::from(item.path())
106 }
107}
108
109impl Default for NavigationGuide {
110 fn default() -> Self {
111 Self::new()
112 }
113}
114
115#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
117pub enum ExecutionMode {
118 Default,
120 PostToolUse,
122 PreCommitHook,
124}
125
126impl Default for ExecutionMode {
127 fn default() -> Self {
128 Self::Default
129 }
130}
131
132#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
134pub enum LogLevel {
135 Quiet,
137 Default,
139 Verbose,
141}
142
143impl Default for LogLevel {
144 fn default() -> Self {
145 Self::Default
146 }
147}
148
149#[derive(Debug, Clone, Serialize, Deserialize, Default)]
151pub struct Config {
152 pub execution_mode: ExecutionMode,
154 pub log_level: LogLevel,
156 pub root_path: Option<PathBuf>,
158 pub guide_path: Option<PathBuf>,
160 pub original_guide_path: Option<String>,
162 pub original_root_path: Option<String>,
164}