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 Placeholder {
36 comment: Option<String>,
38 },
39}
40
41#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
43pub struct NavigationGuideLine {
44 pub line_number: usize,
46 pub indent_level: usize,
48 pub item: FilesystemItem,
50}
51
52impl NavigationGuideLine {
53 pub fn path(&self) -> &str {
55 match &self.item {
56 FilesystemItem::File { path, .. }
57 | FilesystemItem::Directory { path, .. }
58 | FilesystemItem::Symlink { path, .. } => path,
59 FilesystemItem::Placeholder { .. } => "...",
60 }
61 }
62
63 pub fn comment(&self) -> Option<&str> {
65 match &self.item {
66 FilesystemItem::File { comment, .. }
67 | FilesystemItem::Directory { comment, .. }
68 | FilesystemItem::Symlink { comment, .. }
69 | FilesystemItem::Placeholder { comment, .. } => comment.as_deref(),
70 }
71 }
72
73 pub fn is_directory(&self) -> bool {
75 matches!(self.item, FilesystemItem::Directory { .. })
76 }
77
78 pub fn is_placeholder(&self) -> bool {
80 matches!(self.item, FilesystemItem::Placeholder { .. })
81 }
82
83 pub fn children(&self) -> Option<&[NavigationGuideLine]> {
85 match &self.item {
86 FilesystemItem::Directory { children, .. } => Some(children),
87 _ => None,
88 }
89 }
90}
91
92#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
94pub struct NavigationGuide {
95 pub items: Vec<NavigationGuideLine>,
97 pub prologue: Option<String>,
99 pub epilogue: Option<String>,
101 pub ignore: bool,
103}
104
105impl NavigationGuide {
106 pub fn new() -> Self {
108 Self {
109 items: Vec::new(),
110 prologue: None,
111 epilogue: None,
112 ignore: false,
113 }
114 }
115
116 pub fn get_full_path(&self, item: &NavigationGuideLine) -> PathBuf {
118 PathBuf::from(item.path())
121 }
122}
123
124impl Default for NavigationGuide {
125 fn default() -> Self {
126 Self::new()
127 }
128}
129
130#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
132pub enum ExecutionMode {
133 Default,
135 PostToolUse,
137 PreCommitHook,
139 GitHubActions,
141}
142
143impl Default for ExecutionMode {
144 fn default() -> Self {
145 Self::Default
146 }
147}
148
149#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
151pub enum LogLevel {
152 Quiet,
154 Default,
156 Verbose,
158}
159
160impl Default for LogLevel {
161 fn default() -> Self {
162 Self::Default
163 }
164}
165
166#[derive(Debug, Clone, Serialize, Deserialize, Default)]
168pub struct Config {
169 pub execution_mode: ExecutionMode,
171 pub log_level: LogLevel,
173 pub root_path: Option<PathBuf>,
175 pub guide_path: Option<PathBuf>,
177 pub original_guide_path: Option<String>,
179 pub original_root_path: Option<String>,
181}