Skip to content

Commit 568c38b

Browse files
committed
adjust logs
1 parent 0223d8a commit 568c38b

9 files changed

Lines changed: 67 additions & 55 deletions

File tree

codewiki/src/be/agent_orchestrator.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# )
3030

3131
# logfire.instrument_pydantic_ai()
32-
# logger.info(f"Logfire configured successfully for project: {logfire_project}")
32+
# logger.debug(f"Logfire configured successfully for project: {logfire_project}")
3333

3434
# except Exception as e:
3535
# logger.warning(f"Failed to configure logfire: {e}")
@@ -45,10 +45,11 @@
4545
LEAF_SYSTEM_PROMPT,
4646
format_user_prompt,
4747
)
48-
from .utils import is_complex_module
48+
from codewiki.src.be.utils import is_complex_module
4949
from codewiki.src.config import (
5050
Config,
5151
MODULE_TREE_FILENAME,
52+
OVERVIEW_FILENAME,
5253
)
5354
from codewiki.src.utils import file_manager
5455
from codewiki.src.be.dependency_analyzer.models.core import Node
@@ -88,7 +89,7 @@ def create_agent(self, module_name: str, components: Dict[str, Any],
8889
async def process_module(self, module_name: str, components: Dict[str, Node],
8990
core_component_ids: List[str], module_path: List[str], working_dir: str) -> Dict[str, Any]:
9091
"""Process a single module and generate its documentation."""
91-
logger.info(f"Processing module: {module_name}")
92+
logger.debug(f"Processing module: {module_name}")
9293

9394
# Load or create module tree
9495
module_tree_path = os.path.join(working_dir, MODULE_TREE_FILENAME)
@@ -111,6 +112,12 @@ async def process_module(self, module_name: str, components: Dict[str, Node],
111112
config=self.config
112113
)
113114

115+
# check if overview docs already exists
116+
overview_docs_path = os.path.join(working_dir, OVERVIEW_FILENAME)
117+
if os.path.exists(overview_docs_path):
118+
logger.info(f"Overview docs already exists at {overview_docs_path}")
119+
return module_tree
120+
114121
# check if module docs already exists
115122
docs_path = os.path.join(working_dir, f"{module_name}.md")
116123
if os.path.exists(docs_path):
@@ -131,7 +138,7 @@ async def process_module(self, module_name: str, components: Dict[str, Node],
131138

132139
# Save updated module tree
133140
file_manager.save_json(deps.module_tree, module_tree_path)
134-
logger.info(f"Successfully processed module: {module_name}")
141+
logger.debug(f"Successfully processed module: {module_name}")
135142

136143
return deps.module_tree
137144

codewiki/src/be/cluster_modules.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def cluster_modules(
5454
potential_core_components, potential_core_components_with_code = format_potential_core_components(leaf_nodes, components)
5555

5656
if count_tokens(potential_core_components_with_code) <= MAX_TOKEN_PER_MODULE:
57-
logger.info(f"Skipping clustering for {current_module_name} because the potential core components are too few: {count_tokens(potential_core_components_with_code)} tokens")
57+
logger.debug(f"Skipping clustering for {current_module_name} because the potential core components are too few: {count_tokens(potential_core_components_with_code)} tokens")
5858
return {}
5959

6060
prompt = format_cluster_prompt(potential_core_components, current_module_tree, current_module_name)
@@ -79,7 +79,7 @@ def cluster_modules(
7979

8080
# check if the module tree is valid
8181
if len(module_tree) <= 1:
82-
logger.info(f"Skipping clustering for {current_module_name} because the module tree is too small: {len(module_tree)} modules")
82+
logger.debug(f"Skipping clustering for {current_module_name} because the module tree is too small: {len(module_tree)} modules")
8383
return {}
8484

8585
if current_module_tree == {}:

codewiki/src/be/dependency_analyzer/analysis/analysis_service.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def analyze_local_repository(
5555
Dict with analysis results including nodes and relationships
5656
"""
5757
try:
58-
logger.info(f"Analyzing local repository at {repo_path}")
58+
logger.debug(f"Analyzing local repository at {repo_path}")
5959

6060
# Get repo analyzer to find files
6161
repo_analyzer = RepoAnalyzer()
@@ -71,9 +71,9 @@ def analyze_local_repository(
7171
# Limit number of files
7272
if len(code_files) > max_files:
7373
code_files = code_files[:max_files]
74-
logger.info(f"Limited analysis to {max_files} files")
74+
logger.debug(f"Limited analysis to {max_files} files")
7575

76-
logger.info(f"Analyzing {len(code_files)} files")
76+
logger.debug(f"Analyzing {len(code_files)} files")
7777

7878
# Analyze files
7979
result = self.call_graph_analyzer.analyze_code_files(code_files, repo_path)
@@ -115,18 +115,18 @@ def analyze_repository_full(
115115
"""
116116
temp_dir = None
117117
try:
118-
logger.info(f"Starting full analysis of {github_url}")
118+
logger.debug(f"Starting full analysis of {github_url}")
119119

120120
temp_dir = self._clone_repository(github_url)
121121
repo_info = self._parse_repository_info(github_url)
122122

123-
logger.info("Analyzing repository file structure...")
123+
logger.debug("Analyzing repository file structure...")
124124
structure_result = self._analyze_structure(temp_dir, include_patterns, exclude_patterns)
125-
logger.info(f"Found {structure_result['summary']['total_files']} files to analyze.")
125+
logger.debug(f"Found {structure_result['summary']['total_files']} files to analyze.")
126126

127-
logger.info("Starting call graph analysis...")
127+
logger.debug("Starting call graph analysis...")
128128
call_graph_result = self._analyze_call_graph(structure_result["file_tree"], temp_dir)
129-
logger.info(
129+
logger.debug(
130130
f"Call graph analysis complete. Found {call_graph_result['call_graph']['total_functions']} functions."
131131
)
132132

@@ -152,10 +152,10 @@ def analyze_repository_full(
152152
readme_content=readme_content,
153153
)
154154

155-
logger.info(f"Cleaning up temporary repository directory: {temp_dir}")
155+
logger.debug(f"Cleaning up temporary repository directory: {temp_dir}")
156156
self._cleanup_repository(temp_dir)
157157

158-
logger.info(
158+
logger.debug(
159159
f"Analysis completed: {analysis_result.summary['total_functions']} functions found"
160160
)
161161
return analysis_result
@@ -185,7 +185,7 @@ def analyze_repository_structure_only(
185185
"""
186186
temp_dir = None
187187
try:
188-
logger.info(f"Starting structure analysis of {github_url}")
188+
logger.debug(f"Starting structure analysis of {github_url}")
189189

190190
temp_dir = self._clone_repository(github_url)
191191
repo_info = self._parse_repository_info(github_url)
@@ -203,7 +203,7 @@ def analyze_repository_structure_only(
203203

204204
self._cleanup_repository(temp_dir)
205205

206-
logger.info(
206+
logger.debug(
207207
f"Structure analysis completed: {result['file_summary']['total_files']} files found"
208208
)
209209
return result
@@ -216,9 +216,9 @@ def analyze_repository_structure_only(
216216

217217
def _clone_repository(self, github_url: str) -> str:
218218
"""Clone repository and return temp dir path."""
219-
logger.info(f"Cloning {github_url}...")
219+
logger.debug(f"Cloning {github_url}...")
220220
temp_dir = clone_repository(github_url)
221-
logger.info(f"Repository cloned to {temp_dir}")
221+
logger.debug(f"Repository cloned to {temp_dir}")
222222
self._temp_directories.append(temp_dir)
223223
return temp_dir
224224

@@ -233,7 +233,7 @@ def _analyze_structure(
233233
exclude_patterns: Optional[List[str]],
234234
) -> Dict[str, Any]:
235235
"""Analyze repository file structure with filtering."""
236-
logger.info(
236+
logger.debug(
237237
f"Initializing RepoAnalyzer with include: {include_patterns}, exclude: {exclude_patterns}"
238238
)
239239
repo_analyzer = RepoAnalyzer(include_patterns, exclude_patterns)
@@ -246,12 +246,12 @@ def _read_readme_file(self, repo_dir: str) -> Optional[str]:
246246
# readme_path = Path(repo_dir) / name
247247
# if readme_path.exists():
248248
# try:
249-
# logger.info(f"Found README file at {readme_path}")
249+
# logger.debug(f"Found README file at {readme_path}")
250250
# return readme_path.read_text(encoding="utf-8")
251251
# except Exception as e:
252252
# logger.warning(f"Could not read README file at {readme_path}: {e}")
253253
# return None
254-
# logger.info("No README file found in repository root.")
254+
# logger.debug("No README file found in repository root.")
255255
# return None
256256
base = Path(repo_dir)
257257
possible_readme_names = ["README.md", "README", "readme.md", "README.txt"]
@@ -260,12 +260,12 @@ def _read_readme_file(self, repo_dir: str) -> Optional[str]:
260260
if p.exists():
261261
try:
262262
assert_safe_path(base, p)
263-
logger.info(f"Found README file at {p}")
263+
logger.debug(f"Found README file at {p}")
264264
return safe_open_text(base, p, encoding="utf-8")
265265
except Exception as e:
266266
logger.warning(f"Skipping unsafe/ unreadable README at {p}: {e}")
267267
return None
268-
logger.info("No README file found in repository root.")
268+
logger.debug("No README file found in repository root.")
269269
return None
270270

271271
def _analyze_call_graph(self, file_tree: Dict[str, Any], repo_dir: str) -> Dict[str, Any]:
@@ -277,12 +277,12 @@ def _analyze_call_graph(self, file_tree: Dict[str, Any], repo_dir: str) -> Dict[
277277
- JavaScript/TypeScript AST analysis (planned)
278278
- Additional language support (future)
279279
"""
280-
logger.info("Extracting code files from file tree...")
280+
logger.debug("Extracting code files from file tree...")
281281
code_files = self.call_graph_analyzer.extract_code_files(file_tree)
282282

283-
logger.info(f"Found {len(code_files)} total code files. Filtering for supported languages.")
283+
logger.debug(f"Found {len(code_files)} total code files. Filtering for supported languages.")
284284
supported_files = self._filter_supported_languages(code_files)
285-
logger.info(f"Analyzing {len(supported_files)} supported files.")
285+
logger.debug(f"Analyzing {len(supported_files)} supported files.")
286286

287287
result = self.call_graph_analyzer.analyze_code_files(supported_files, repo_dir)
288288

@@ -321,7 +321,7 @@ def _get_supported_languages(self) -> List[str]:
321321

322322
def _cleanup_repository(self, temp_dir: str):
323323
"""Clean up cloned repository."""
324-
logger.info(f"Attempting to clean up {temp_dir}")
324+
logger.debug(f"Attempting to clean up {temp_dir}")
325325
cleanup_repository(temp_dir)
326326
if temp_dir in self._temp_directories:
327327
self._temp_directories.remove(temp_dir)

codewiki/src/be/dependency_analyzer/ast_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(self, repo_path: str):
2626
self.analysis_service = AnalysisService()
2727

2828
def parse_repository(self, filtered_folders: List[str] = None) -> Dict[str, Node]:
29-
logger.info(f"Parsing repository at {self.repo_path}")
29+
logger.debug(f"Parsing repository at {self.repo_path}")
3030

3131
structure_result = self.analysis_service._analyze_structure(
3232
self.repo_path,
@@ -41,7 +41,7 @@ def parse_repository(self, filtered_folders: List[str] = None) -> Dict[str, Node
4141

4242
self._build_components_from_analysis(call_graph_result)
4343

44-
logger.info(f"Found {len(self.components)} components across {len(self.modules)} modules")
44+
logger.debug(f"Found {len(self.components)} components across {len(self.modules)} modules")
4545
return self.components
4646

4747
def _build_components_from_analysis(self, call_graph_result: Dict):
@@ -141,5 +141,5 @@ def save_dependency_graph(self, output_path: str):
141141
with open(output_path, 'w', encoding='utf-8') as f:
142142
json.dump(result, f, indent=2, ensure_ascii=False)
143143

144-
logger.info(f"Saved {len(self.components)} components to {output_path}")
144+
logger.debug(f"Saved {len(self.components)} components to {output_path}")
145145
return result

codewiki/src/be/dependency_analyzer/dependency_graphs_builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def build_dependency_graph(self) -> tuple[Dict[str, Any], List[str]]:
4141

4242
filtered_folders = None
4343
# if os.path.exists(filtered_folders_path):
44-
# logger.info(f"Loading filtered folders from {filtered_folders_path}")
44+
# logger.debug(f"Loading filtered folders from {filtered_folders_path}")
4545
# filtered_folders = file_manager.load_json(filtered_folders_path)
4646
# else:
4747
# # Parse repository

codewiki/src/be/dependency_analyzer/topo_sort.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def concise_node(leaf_nodes: Set[str]) -> Set[str]:
321321

322322
concise_leaf_nodes = concise_node(leaf_nodes)
323323
if len(concise_leaf_nodes) >= 400:
324-
logger.info(f"Leaf nodes are too many ({len(concise_leaf_nodes)}), removing dependencies of other nodes")
324+
logger.debug(f"Leaf nodes are too many ({len(concise_leaf_nodes)}), removing dependencies of other nodes")
325325
# Remove nodes that are dependencies of other nodes
326326
for node, deps in acyclic_graph.items():
327327
for dep in deps:

codewiki/src/be/documentation_generator.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def create_documentation_metadata(self, working_dir: str, components: Dict[str,
7070

7171
metadata_path = os.path.join(working_dir, "metadata.json")
7272
file_manager.save_json(metadata, metadata_path)
73-
logger.info(f"Documentation metadata saved to: {metadata_path}")
73+
logger.debug(f"Documentation metadata saved to: {metadata_path}")
7474

7575
def get_processing_order(self, module_tree: Dict[str, Any], parent_path: List[str] = []) -> List[tuple[List[str], str]]:
7676
"""Get the processing order using topological sort (leaf modules first)."""
@@ -135,7 +135,7 @@ async def generate_module_documentation(self, components: Dict[str, Any], leaf_n
135135

136136
# Get processing order (leaf modules first)
137137
processing_order = self.get_processing_order(first_module_tree)
138-
logger.info(f"Processing {len(processing_order)} modules in dependency order:\n{processing_order}")
138+
logger.debug(f"Processing {len(processing_order)} modules in dependency order:\n{processing_order}")
139139

140140
# Process modules in dependency order
141141
final_module_tree = module_tree
@@ -175,12 +175,12 @@ async def generate_module_documentation(self, components: Dict[str, Any], leaf_n
175175
continue
176176

177177
# Generate repo overview
178-
logger.info(f"Generating repo overview")
178+
logger.debug(f"Generating repo overview")
179179
final_module_tree = await self.generate_parent_module_docs(
180180
[], working_dir
181181
)
182182
else:
183-
logger.info(f"Processing whole repo because repo can fit in the context window")
183+
logger.debug(f"Processing whole repo because repo can fit in the context window")
184184
repo_name = os.path.basename(os.path.normpath(self.config.repo_path))
185185
final_module_tree = await self.agent_orchestrator.process_module(
186186
repo_name, components, leaf_nodes, [], working_dir
@@ -197,12 +197,18 @@ async def generate_parent_module_docs(self, module_path: List[str],
197197
"""Generate documentation for a parent module based on its children's documentation."""
198198
module_name = module_path[-1] if len(module_path) >= 1 else os.path.basename(os.path.normpath(self.config.repo_path))
199199

200-
logger.info(f"Generating parent documentation for: {module_name}")
200+
logger.debug(f"Generating parent documentation for: {module_name}")
201201

202202
# Load module tree
203203
module_tree_path = os.path.join(working_dir, MODULE_TREE_FILENAME)
204204
module_tree = file_manager.load_json(module_tree_path)
205-
205+
206+
# check if parent docs already exists
207+
parent_docs_path = os.path.join(working_dir, f"{module_name if len(module_path) >= 1 else OVERVIEW_FILENAME.replace('.md', '')}.md")
208+
if os.path.exists(parent_docs_path):
209+
logger.info(f"Parent docs already exists at {parent_docs_path}")
210+
return module_tree
211+
206212
# Create repo structure with 1-depth children docs and target indicator
207213
repo_structure = self.build_overview_structure(module_tree, module_path, working_dir)
208214

@@ -220,10 +226,9 @@ async def generate_parent_module_docs(self, module_path: List[str],
220226
# Parse and save parent documentation
221227
parent_content = parent_docs.split("<OVERVIEW>")[1].split("</OVERVIEW>")[0].strip()
222228
# parent_content = prompt
223-
parent_docs_path = os.path.join(working_dir, f"{module_name if len(module_path) >= 1 else OVERVIEW_FILENAME.replace('.md', '')}.md")
224229
file_manager.save_text(parent_content, parent_docs_path)
225230

226-
logger.info(f"Successfully generated parent documentation for: {module_name}")
231+
logger.debug(f"Successfully generated parent documentation for: {module_name}")
227232
return module_tree
228233

229234
except Exception as e:
@@ -236,8 +241,8 @@ async def run(self) -> None:
236241
# Build dependency graph
237242
components, leaf_nodes = self.graph_builder.build_dependency_graph()
238243

239-
logger.info(f"Found {len(leaf_nodes)} leaf nodes")
240-
# logger.info(f"Leaf nodes:\n{'\n'.join(sorted(leaf_nodes)[:200])}")
244+
logger.debug(f"Found {len(leaf_nodes)} leaf nodes")
245+
# logger.debug(f"Leaf nodes:\n{'\n'.join(sorted(leaf_nodes)[:200])}")
241246
# exit()
242247

243248
# Cluster modules
@@ -248,16 +253,16 @@ async def run(self) -> None:
248253

249254
# Check if module tree exists
250255
if os.path.exists(first_module_tree_path):
251-
logger.info(f"Module tree found at {first_module_tree_path}")
256+
logger.debug(f"Module tree found at {first_module_tree_path}")
252257
module_tree = file_manager.load_json(first_module_tree_path)
253258
else:
254-
logger.info(f"Module tree not found at {module_tree_path}, clustering modules")
259+
logger.debug(f"Module tree not found at {module_tree_path}, clustering modules")
255260
module_tree = cluster_modules(leaf_nodes, components, self.config)
256261
file_manager.save_json(module_tree, first_module_tree_path)
257262

258263
file_manager.save_json(module_tree, module_tree_path)
259264

260-
logger.info(f"Grouped components into {len(module_tree)} modules")
265+
logger.debug(f"Grouped components into {len(module_tree)} modules")
261266

262267
# Generate module documentation using dynamic programming approach
263268
# This processes leaf modules first, then parent modules
@@ -266,9 +271,9 @@ async def run(self) -> None:
266271
# Create documentation metadata
267272
self.create_documentation_metadata(working_dir, components, len(leaf_nodes))
268273

269-
logger.info(f"Documentation generation completed successfully using dynamic programming!")
270-
logger.info(f"Processing order: leaf modules → parent modules → repository overview")
271-
logger.info(f"Documentation saved to: {working_dir}")
274+
logger.debug(f"Documentation generation completed successfully using dynamic programming!")
275+
logger.debug(f"Processing order: leaf modules → parent modules → repository overview")
276+
logger.debug(f"Documentation saved to: {working_dir}")
272277

273278
except Exception as e:
274279
logger.error(f"Documentation generation failed: {str(e)}")

codewiki/src/be/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async def main() -> None:
5050
await doc_generator.run()
5151

5252
except KeyboardInterrupt:
53-
logger.info("Documentation generation interrupted by user")
53+
logger.debug("Documentation generation interrupted by user")
5454
except Exception as e:
5555
logger.error(f"Unexpected error: {str(e)}")
5656
raise

0 commit comments

Comments
 (0)