@@ -16,6 +16,15 @@ pub struct MissingSourceIssue {
1616 pub path : PathBuf ,
1717}
1818
19+ /// Checks whether the configured source directory exists and reports the result.
20+ ///
21+ /// # Examples
22+ ///
23+ /// ```
24+ /// use std::path::Path;
25+ ///
26+ /// assert_eq!(check_source_directory(Path::new(".")), 0);
27+ /// ```
1928fn check_source_directory ( source_dir : & Path ) -> usize {
2029 if !source_dir. exists ( ) {
2130 println ! (
@@ -34,6 +43,18 @@ fn check_source_directory(source_dir: &Path) -> usize {
3443 }
3544}
3645
46+ /// Checks enabled targets for configuration warnings, missing sources, and skills-layout mismatches.
47+ ///
48+ /// Returns the number of issues found and reports each issue to the diagnostic output.
49+ ///
50+ /// # Examples
51+ ///
52+ /// ```ignore
53+ /// use std::path::Path;
54+ ///
55+ /// let issue_count = check_target_sources(&linker, Path::new("src"));
56+ /// assert_eq!(issue_count, 0);
57+ /// ```
3758fn check_target_sources ( linker : & Linker , source_dir : & Path ) -> usize {
3859 let mut issues = 0 ;
3960 let mut missing_targets = 0 ;
@@ -100,6 +121,16 @@ fn check_target_sources(linker: &Linker, source_dir: &Path) -> usize {
100121 issues
101122}
102123
124+ /// Reports duplicate and overlapping destinations configured for enabled targets.
125+ ///
126+ /// Prints each conflict and returns the number of conflicts found.
127+ ///
128+ /// # Examples
129+ ///
130+ /// ```ignore
131+ /// let issue_count = check_destination_conflicts(&linker);
132+ /// assert_eq!(issue_count, 0);
133+ /// ```
103134fn check_destination_conflicts ( linker : & Linker ) -> usize {
104135 let mut issues = 0 ;
105136 let mut destinations: Vec < ( String , String , String ) > = Vec :: new ( ) ;
@@ -138,6 +169,20 @@ fn check_destination_conflicts(linker: &Linker) -> usize {
138169 issues
139170}
140171
172+ /// Audits enabled MCP servers and reports commands that cannot be found.
173+ ///
174+ /// Disabled servers and servers without configured commands are skipped from
175+ /// command validation.
176+ ///
177+ /// # Examples
178+ ///
179+ /// ```rust,ignore
180+ /// let issue_count = check_mcp_servers(&linker);
181+ /// assert_eq!(issue_count, 0);
182+ /// ```
183+ ///
184+ /// Returns the number of enabled MCP servers whose configured commands cannot
185+ /// be found.
141186fn check_mcp_servers ( linker : & Linker ) -> usize {
142187 let mut issues = 0 ;
143188 if !linker. config ( ) . mcp . enabled {
@@ -175,6 +220,15 @@ fn check_mcp_servers(linker: &Linker) -> usize {
175220 issues
176221}
177222
223+ /// Checks the project's managed `.gitignore` section and reports any issues.
224+ ///
225+ /// # Examples
226+ ///
227+ /// ```ignore
228+ /// let issue_count = check_gitignore(&linker);
229+ /// assert_eq!(issue_count, 0);
230+ /// ```
231+ fn check_gitignore( linker : & Linker ) -> usize {
178232fn check_gitignore ( linker : & Linker ) -> usize {
179233 let gitignore_path = linker. project_root ( ) . join ( ".gitignore" ) ;
180234 if !gitignore_path. exists ( ) {
@@ -253,6 +307,18 @@ fn check_gitignore(linker: &Linker) -> usize {
253307 issues
254308}
255309
310+ /// Checks whether Claude skills are managed by an enabled target and reports a warning when they are not.
311+ ///
312+ /// # Returns
313+ ///
314+ /// The number of issues found: `1` when unmanaged skills are detected, otherwise `0`.
315+ ///
316+ /// # Examples
317+ ///
318+ /// ```ignore
319+ /// let issues = check_unmanaged_skills(&linker);
320+ /// assert!(issues <= 1);
321+ /// ```
256322fn check_unmanaged_skills ( linker : & Linker ) -> usize {
257323 if let Some ( warning) = check_unmanaged_claude_skills ( linker. project_root ( ) , linker. config ( ) ) {
258324 println ! ( " {} {}" , "⚠" . yellow( ) , warning) ;
@@ -262,6 +328,18 @@ fn check_unmanaged_skills(linker: &Linker) -> usize {
262328 }
263329}
264330
331+ /// Runs diagnostic checks for the project configuration and reports any issues found.
332+ ///
333+ /// Configuration discovery and parsing failures are reported to the user and do not
334+ /// cause the diagnostic command to return an error.
335+ ///
336+ /// # Examples
337+ ///
338+ /// ```
339+ /// let project_root = std::env::current_dir()?;
340+ /// run_doctor(project_root)?;
341+ /// # Ok::<(), Box<dyn std::error::Error>>(())
342+ /// ```
265343pub fn run_doctor ( project_root : PathBuf ) -> Result < ( ) > {
266344 println ! ( "{}" , "🩺 Running AgentSync Diagnostic..." . bold( ) . cyan( ) ) ;
267345
0 commit comments