pub mod call_graph_diff;
pub mod call_tree;
pub mod cli_args;
pub mod def_diff;
pub mod detailed_snapshot;
pub mod effects_graph;
pub mod program_diff;
#[cfg(not(target_arch = "wasm32"))]
pub mod injection;
#[cfg(not(target_arch = "wasm32"))]
pub mod analysis_cache;
#[cfg(not(target_arch = "wasm32"))]
pub mod cli_handlers;
#[cfg(not(target_arch = "wasm32"))]
pub mod deprecated_api;
#[cfg(not(target_arch = "wasm32"))]
pub mod public_api_check;
#[cfg(not(target_arch = "wasm32"))]
pub mod strict_check;
#[cfg(not(target_arch = "wasm32"))]
pub mod type_coverage;
#[cfg(not(target_arch = "wasm32"))]
pub mod verification;
#[cfg(not(target_arch = "wasm32"))]
pub static GLOBAL_TEST_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
#[cfg(not(target_arch = "wasm32"))]
static EMBEDDED_AGENTS_DOC_OVERRIDE: std::sync::OnceLock<&'static str> = std::sync::OnceLock::new();
#[cfg(not(target_arch = "wasm32"))]
pub fn set_embedded_agents_doc(doc: &'static str) {
let _ = EMBEDDED_AGENTS_DOC_OVERRIDE.set(doc);
}
#[cfg(not(target_arch = "wasm32"))]
pub fn embedded_agents_doc() -> Option<&'static str> {
if let Some(doc) = EMBEDDED_AGENTS_DOC_OVERRIDE.get() {
return Some(*doc);
}
#[cfg(test)]
{
Some(include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../docs/CalcitAgent.md")))
}
#[cfg(not(test))]
{
None
}
}
#[cfg(not(target_arch = "wasm32"))]
pub fn cached_core_snapshot() -> &'static calcit_core::snapshot::Snapshot {
calcit_core::core_snapshot().expect("core snapshot should load")
}
#[cfg(not(target_arch = "wasm32"))]
pub fn preprocess_dynamic_method_entries(
entries: &calcit_core::ProgramEntries,
) -> Result<Vec<calcit_core::calcit::LocatedWarning>, String> {
let warnings = std::cell::RefCell::new(Vec::new());
for (ns, def) in [(&entries.init_ns, &entries.init_def), (&entries.reload_ns, &entries.reload_def)] {
calcit_core::runner::preprocess::ensure_ns_def_compiled(ns, def, &warnings, &calcit_core::call_stack::CallStackList::default())
.map_err(|failure| failure.to_string())?;
}
Ok(warnings.into_inner())
}
#[cfg(not(target_arch = "wasm32"))]
pub fn attach_missing_core_namespaces(snapshot: &mut calcit_core::snapshot::Snapshot, core_snapshot: calcit_core::snapshot::Snapshot) {
for (namespace, file) in core_snapshot.files {
snapshot.files.entry(namespace).or_insert(file);
}
}
#[cfg(not(target_arch = "wasm32"))]
pub fn apply_strict_feature_policy_defaults(snapshot: &mut calcit_core::snapshot::Snapshot) -> Result<(), String> {
let entry_name = snapshot.active_entry_name().to_owned();
let entry = snapshot
.entries
.get_mut(&entry_name)
.ok_or_else(|| format!("Entry '{entry_name}' not found"))?;
entry
.feature_policy
.entry("js-ffi".to_owned())
.or_insert(calcit_core::snapshot::FeaturePolicy::Error);
Ok(())
}
#[cfg(not(target_arch = "wasm32"))]
pub struct ProgramOutputGuard {
redirect_stdout: bool,
silence_program_output: bool,
}
#[cfg(not(target_arch = "wasm32"))]
impl ProgramOutputGuard {
pub fn new(redirect_stdout: bool, silence_program_output: bool) -> Self {
if redirect_stdout {
injection::set_stdout_to_stderr(true);
}
if silence_program_output {
injection::set_program_output_silenced(true);
}
Self {
redirect_stdout,
silence_program_output,
}
}
}
#[cfg(not(target_arch = "wasm32"))]
impl Drop for ProgramOutputGuard {
fn drop(&mut self) {
if self.redirect_stdout {
injection::set_stdout_to_stderr(false);
}
if self.silence_program_output {
injection::set_program_output_silenced(false);
}
}
}