5555)
5656from models import ExportEntry , SchemaError # noqa: E402
5757from services .workspace_db import ( # noqa: E402
58- _build_composer_id_to_workspace_id ,
59- _collect_invalid_workspace_ids ,
60- _collect_workspace_entries ,
58+ build_composer_id_to_workspace_id ,
59+ collect_invalid_workspace_ids ,
60+ collect_workspace_entries ,
6161 load_bubble_map ,
6262 load_code_block_diff_map ,
6363 load_project_layouts_map ,
64- _open_global_db ,
64+ open_global_db ,
6565)
6666from services .workspace_resolver import ( # noqa: E402
67- _determine_project_for_conversation ,
68- _get_workspace_display_name ,
69- _infer_invalid_workspace_aliases ,
70- _create_project_name_to_workspace_id_map ,
71- _create_workspace_path_to_id_map ,
67+ create_project_name_to_workspace_id_map ,
68+ create_workspace_path_to_id_map ,
69+ determine_project_for_conversation ,
70+ infer_invalid_workspace_aliases ,
71+ lookup_workspace_display_name ,
7272)
7373
7474_logger = logging .getLogger (__name__ )
7575
7676
77- def _configure_cli_logging () -> None :
77+ def configure_cli_logging () -> None :
7878 """Route log records to stderr so stdout stays for export progress lines."""
7979 root = logging .getLogger ()
8080 if root .handlers :
@@ -86,15 +86,15 @@ def _configure_cli_logging() -> None:
8686 )
8787
8888
89- def _json_dump_safe (value ) -> str :
89+ def json_dump_safe (value ) -> str :
9090 """Best-effort JSON serialization for exclusion matching."""
9191 try :
9292 return json .dumps (value , ensure_ascii = False , sort_keys = True )
9393 except Exception :
9494 return str (value ) if value is not None else ""
9595
9696
97- def _load_manifest_entries (manifest_path : str ) -> dict :
97+ def load_manifest_entries (manifest_path : str ) -> dict :
9898 """Load manifest entries keyed by log_id from a JSONL file."""
9999 existing : dict = {}
100100 if not os .path .isfile (manifest_path ):
@@ -117,7 +117,7 @@ def _load_manifest_entries(manifest_path: str) -> dict:
117117 return existing
118118
119119
120- def _write_manifest_entries (manifest_path : str , entries_by_id : dict ):
120+ def write_manifest_entries (manifest_path : str , entries_by_id : dict ):
121121 """Write manifest entries to JSONL."""
122122 os .makedirs (os .path .dirname (manifest_path ), exist_ok = True )
123123 with open (manifest_path , "w" , encoding = "utf-8" ) as f :
@@ -177,7 +177,7 @@ def parse_args():
177177
178178
179179def main ():
180- _configure_cli_logging ()
180+ configure_cli_logging ()
181181 opts = parse_args ()
182182 since = opts ["since" ]
183183 out_dir = os .path .abspath (opts ["out_dir" ])
@@ -201,11 +201,11 @@ def main():
201201 pass
202202
203203 # ── Workspace scanning via service layer ──────────────────────────────────
204- workspace_entries = _collect_workspace_entries (workspace_path )
205- invalid_workspace_ids = _collect_invalid_workspace_ids (workspace_entries )
206- project_name_map = _create_project_name_to_workspace_id_map (workspace_entries )
207- workspace_path_map = _create_workspace_path_to_id_map (workspace_entries )
208- composer_id_to_ws = _build_composer_id_to_workspace_id (workspace_path , workspace_entries )
204+ workspace_entries = collect_workspace_entries (workspace_path )
205+ invalid_workspace_ids = collect_invalid_workspace_ids (workspace_entries )
206+ project_name_map = create_project_name_to_workspace_id_map (workspace_entries )
207+ workspace_path_map = create_workspace_path_to_id_map (workspace_entries )
208+ composer_id_to_ws = build_composer_id_to_workspace_id (workspace_path , workspace_entries )
209209
210210 # Build display-name and slug maps from workspace entries.
211211 # Entries whose workspace.json cannot be resolved are omitted so the
@@ -214,7 +214,7 @@ def main():
214214 workspace_id_to_display_name : dict [str , str ] = {}
215215 workspace_id_to_slug : dict [str , str ] = {}
216216 for e in workspace_entries :
217- display = _get_workspace_display_name (workspace_path , e ["name" ])
217+ display = lookup_workspace_display_name (workspace_path , e ["name" ])
218218 if display != e ["name" ]: # successfully resolved a human-readable name
219219 workspace_id_to_display_name [e ["name" ]] = display
220220 workspace_id_to_slug [e ["name" ]] = slug (display )
@@ -226,7 +226,7 @@ def main():
226226 ide_composer_rows : list = []
227227 invalid_workspace_aliases : dict = {}
228228
229- with _open_global_db (workspace_path ) as (global_db , global_db_path ):
229+ with open_global_db (workspace_path ) as (global_db , global_db_path ):
230230 if global_db is None :
231231 _logger .info (
232232 "Cursor IDE global storage not found at %s — skipping IDE chats." ,
@@ -245,7 +245,7 @@ def main():
245245 except sqlite3 .Error :
246246 pass
247247
248- invalid_workspace_aliases = _infer_invalid_workspace_aliases (
248+ invalid_workspace_aliases = infer_invalid_workspace_aliases (
249249 composer_rows = ide_composer_rows ,
250250 project_layouts_map = project_layouts_map ,
251251 project_name_map = project_name_map ,
@@ -278,7 +278,7 @@ def main():
278278 continue
279279
280280 # Workspace assignment via service layer
281- pid = _determine_project_for_conversation (
281+ pid = determine_project_for_conversation (
282282 cd , composer_id , project_layouts_map ,
283283 project_name_map , workspace_path_map ,
284284 workspace_entries , bubble_map , composer_id_to_ws , invalid_workspace_ids ,
@@ -307,9 +307,9 @@ def main():
307307 text = extract_text_from_bubble (b )
308308 if text :
309309 bubble_texts .append (text )
310- bubble_meta_parts .append (_json_dump_safe (b ))
310+ bubble_meta_parts .append (json_dump_safe (b ))
311311
312- code_diff_parts = [_json_dump_safe (d ) for d in code_block_diff_map .get (composer_id , [])]
312+ code_diff_parts = [json_dump_safe (d ) for d in code_block_diff_map .get (composer_id , [])]
313313 searchable = build_searchable_text (
314314 project_name = ws_display_name ,
315315 chat_title = title ,
@@ -320,7 +320,7 @@ def main():
320320 bubble_texts
321321 + bubble_meta_parts
322322 + code_diff_parts
323- + [_json_dump_safe (model_config ), _json_dump_safe (cd )]
323+ + [json_dump_safe (model_config ), json_dump_safe (cd )]
324324 )
325325 if p
326326 ),
@@ -484,7 +484,7 @@ def main():
484484 f .write (entry ["content" ])
485485
486486 manifest_path = os .path .join (out_dir , "manifest.jsonl" )
487- existing = _load_manifest_entries (manifest_path )
487+ existing = load_manifest_entries (manifest_path )
488488 for entry in exported :
489489 existing [entry ["id" ]] = {
490490 "log_id" : entry ["id" ],
@@ -494,10 +494,10 @@ def main():
494494 "updated_at" : datetime .fromtimestamp (entry ["updatedAt" ] / 1000 ).isoformat () if entry ["updatedAt" ] else datetime .now ().isoformat (),
495495 }
496496 if existing :
497- _write_manifest_entries (manifest_path , existing )
497+ write_manifest_entries (manifest_path , existing )
498498
499499 global_manifest_path = os .path .join (state_dir , "manifest.jsonl" )
500- global_existing = _load_manifest_entries (global_manifest_path )
500+ global_existing = load_manifest_entries (global_manifest_path )
501501 for entry in exported :
502502 global_existing [entry ["id" ]] = {
503503 "log_id" : entry ["id" ],
@@ -507,7 +507,7 @@ def main():
507507 "updated_at" : datetime .fromtimestamp (entry ["updatedAt" ] / 1000 ).isoformat () if entry ["updatedAt" ] else datetime .now ().isoformat (),
508508 }
509509 if global_existing :
510- _write_manifest_entries (global_manifest_path , global_existing )
510+ write_manifest_entries (global_manifest_path , global_existing )
511511 print (f"Exported { count } chat(s) to { out_dir } " )
512512
513513 state = {
0 commit comments