Skip to content

Commit e46db45

Browse files
committed
improve docs frontend
1 parent 7dd6623 commit e46db45

11 files changed

Lines changed: 3953 additions & 923 deletions

‎codewiki/cli/adapters/doc_generator.py‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ async def _run_backend_generation(self, backend_config: BackendConfig):
215215
from codewiki.src.be.cluster_modules import (
216216
cluster_modules,
217217
get_clustering_input_token_count,
218+
super_group_modules,
218219
)
219220
from codewiki.src.utils import file_manager
220221
from codewiki.src.config import FIRST_MODULE_TREE_FILENAME, MODULE_TREE_FILENAME
@@ -227,6 +228,12 @@ async def _run_backend_generation(self, backend_config: BackendConfig):
227228
try:
228229
if os.path.exists(first_module_tree_path):
229230
module_tree = file_manager.load_json(first_module_tree_path)
231+
# Never clobber an existing module_tree.json with the cached
232+
# first tree: it carries sub-modules inserted by agents in
233+
# earlier (resumed) runs, and those modules short-circuit on
234+
# their existing .md without re-inserting their children.
235+
if not os.path.exists(module_tree_path):
236+
file_manager.save_json(module_tree, module_tree_path)
230237
if self.verbose:
231238
self.progress_tracker.update_stage(0.5, "Loaded cached module tree")
232239
else:
@@ -259,13 +266,19 @@ async def _run_backend_generation(self, backend_config: BackendConfig):
259266
backend_config,
260267
completer=lambda p: doc_generator.backend.complete(p, model=cluster_model),
261268
)
269+
if module_tree:
270+
module_tree = super_group_modules(
271+
module_tree,
272+
backend_config,
273+
completer=lambda p: doc_generator.backend.complete(p, model=cluster_model),
274+
)
262275
# Only freshly clustered trees are deduped: renaming a cached
263276
# key whose .md already exists would orphan the doc.
264277
from codewiki.src.be.module_naming import dedupe_module_tree_names
265278
module_tree = dedupe_module_tree_names(module_tree)
266279
file_manager.save_json(module_tree, first_module_tree_path)
280+
file_manager.save_json(module_tree, module_tree_path)
267281

268-
file_manager.save_json(module_tree, module_tree_path)
269282
self.job.module_count = len(module_tree)
270283

271284
if self.verbose:

‎codewiki/src/be/documentation_generator.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,12 @@ async def run(self) -> None:
330330
if os.path.exists(first_module_tree_path):
331331
logger.debug(f"Module tree found at {first_module_tree_path}")
332332
module_tree = file_manager.load_json(first_module_tree_path)
333+
# Never clobber an existing module_tree.json with the cached
334+
# first tree: it carries sub-modules inserted by agents in
335+
# earlier (resumed) runs, and those modules short-circuit on
336+
# their existing .md without re-inserting their children.
337+
if not os.path.exists(module_tree_path):
338+
file_manager.save_json(module_tree, module_tree_path)
333339
else:
334340
logger.debug(f"Module tree not found at {module_tree_path}, clustering modules")
335341
clustering_tokens = get_clustering_input_token_count(
@@ -362,8 +368,7 @@ async def run(self) -> None:
362368
# key whose .md already exists would orphan the doc.
363369
module_tree = dedupe_module_tree_names(module_tree)
364370
file_manager.save_json(module_tree, first_module_tree_path)
365-
366-
file_manager.save_json(module_tree, module_tree_path)
371+
file_manager.save_json(module_tree, module_tree_path)
367372

368373
if len(module_tree) == 0:
369374
logger.info(

0 commit comments

Comments
 (0)