1pub mod db;
2pub mod formatters;
3pub mod models;
4pub mod ops;
5pub mod queries;
6pub mod slicer;
7pub mod sync;
8pub mod telemetry;
9pub mod watcher;
10pub mod workspace;
11
12pub use db::{
13 Connection, DbError, ensure_fts_index, ensure_fts_index_path, open_read_only, open_read_write,
14};
15pub use formatters::{
16 format_blast_radius, format_context_slice, format_fact_categories, format_file_skeleton,
17 format_find_symbol_results, format_import_summary, format_no_facts, format_references,
18 format_search_results, format_structural_facts, format_symbol_body, no_facts_heading,
19};
20pub use models::{
21 BlastRadiusResult, ContextSlice, FileFact, ImpactedSymbol, LiteralFact, ReferenceSite,
22 SearchExplain, StructuralFact, Symbol, SymbolSearchResult, TestTarget, TypeFact,
23};
24pub use ops::{
25 OpError, SymbolSelector, blast_radius_op, blast_radius_selected_op, codebase_outline_op,
26 file_skeleton_op, get_context_slice_op, get_context_slice_selected_op, get_symbol_body_op,
27 get_symbol_body_selected_op, resolve_symbol_op,
28};
29pub use queries::{
30 QueryError, compute_blast_radius, compute_blast_radius_scoped,
31 compute_blast_radius_scoped_with_ids, count_file_symbols, file_sizes_for_paths,
32 find_callee_signatures, find_literals, find_literals_scoped, find_references,
33 find_references_ext, find_references_for_symbol, find_references_for_symbol_ext,
34 find_references_scoped, find_related_tests, find_structural_facts,
35 find_structural_facts_scoped, find_type_facts, fts_search_symbols_explained,
36 fts_search_symbols_scoped, get_file, get_symbol_by_id, get_symbol_by_name,
37 get_symbol_by_name_exact, import_sites, is_category_alias, is_test_path,
38 list_structural_fact_categories, list_structural_fact_categories_scoped, load_file_symbols,
39 load_scoped_outline_symbols, normalize_kind, qualify_members, sanitize_fts5_query,
40 search_symbols, search_symbols_scoped, suggest_file_paths, suggest_symbol_names,
41 workspace_name,
42};
43pub use slicer::{SliceError, slice_symbol, slice_symbol_body};
44pub use sync::{
45 PINNED_JULIE_VERSION, ReconcileReport, SyncError, create_index, delete_file, ensure_fresh_file,
46 ensure_index_matches_extractor, find_julie_extract_binary, installed_extractor_version,
47 reconcile_offline_edits, scan_workspace, update_file,
48};
49pub use telemetry::{
50 BugReportBundle, IndexFacts, TelemetryErrorRecord, TelemetryFilter, TelemetrySummary,
51 TimeWindow, ToolInvocation, ToolStat, format_telemetry_summary, generate_bug_report,
52 get_global_telemetry_dir, get_telemetry_summary, open_global_telemetry_db, open_telemetry_db,
53 record_tool_call, record_tool_call_conn,
54};
55pub use watcher::{WatcherError, WatcherHandle, start_watcher};
56pub use workspace::{
57 Workspace, WorkspaceError, is_hard_excluded, is_project_root, normalize_path, parse_file_uri,
58 strip_prefix_lossy, to_forward_slash,
59};
60
61pub fn safe_tempdir() -> tempfile::TempDir {
64 if let Ok(target_tmp) = std::env::var("CARGO_TARGET_TMPDIR") {
65 let path = std::path::PathBuf::from(&target_tmp);
66 if (path.exists() || std::fs::create_dir_all(&path).is_ok())
67 && let Ok(dir) = tempfile::TempDir::new_in(&path)
68 {
69 return dir;
70 }
71 }
72 if let Ok(tmp) = std::env::var("TMPDIR") {
73 let path = std::path::PathBuf::from(tmp);
74 if (path.exists() || std::fs::create_dir_all(&path).is_ok())
75 && let Ok(dir) = tempfile::TempDir::new_in(&path)
76 {
77 return dir;
78 }
79 }
80
81 let mut search_dirs = Vec::new();
83 if let Ok(manifest_dir) = std::env::var("CARGO_MANIFEST_DIR") {
84 search_dirs.push(std::path::PathBuf::from(manifest_dir));
85 }
86 if let Ok(cwd) = std::env::current_dir() {
87 search_dirs.push(cwd);
88 }
89 for base in search_dirs {
90 let mut cur = base;
91 loop {
92 let candidate = cur.join("target/tmp");
93 if (cur.join("Cargo.toml").exists() || cur.join(".git").exists())
94 && (candidate.exists() || std::fs::create_dir_all(&candidate).is_ok())
95 && let Ok(dir) = tempfile::TempDir::new_in(&candidate)
96 {
97 return dir;
98 }
99 if !cur.pop() {
100 break;
101 }
102 }
103 }
104
105 tempfile::tempdir().expect("failed to create temporary directory")
106}