Skip to main content

Module auto_fix

Module auto_fix 

Source
Expand description

Auto-fix orchestration for limit fix --all.

run_auto_fix_all applies every non-destructive repair that is currently applicable — terminate ghost processes, copy .env.example → .env, then (unless --safe) install missing dependencies — in dependency order, re-runs the full diagnostics afterwards and returns a FixReport summarising what changed and what still needs a human.

§Ordering

Fixes run in dependency order:

  1. Kill ghost processes first — this frees the blocked dev ports.
  2. Copy .env.example → .env second — the app can then start up.
  3. Install dependencies last — the slowest, most disruptive step.
use limitless_cli::models::{EnvironmentState, ProjectStack};
use limitless_cli::modules::auto_fix::build_auto_fixes;

let mut state = EnvironmentState::default();
state.detected_stack = ProjectStack::Node {
    version: "22.9.0".into(),
    package_manager: "npm".into(),
};
state.env_example_exists = true;
state.dependencies_healthy = false;
state.blocked_ports = vec![(3000, 9921)];

let fixes = build_auto_fixes(&state, ".", true);
assert_eq!(fixes.len(), 3);
assert_eq!(fixes[0].id, "kill-ghost-9921");
assert_eq!(fixes[1].id, "copy-env-from-example");
assert_eq!(fixes[2].id, "install-dependencies-npm");

Structs§

FixReport
Result summary produced by run_auto_fix_all.

Constants§

REPORT_WIDTH
Width of the final auto-fix report box, measured in terminal columns.

Functions§

build_auto_fixes
Builds the ordered, non-destructive fix list for a state snapshot.
next_steps
Concrete manual steps (remediation hints) for every non-passing check.
remaining_issues
Human-readable messages for every check that is not Pass.
render_auto_fix_report
Renders the FixReport as a colorized summary box (ANSI included).
render_auto_fix_report_plain
Same layout as render_auto_fix_report with all ANSI codes stripped.
run_auto_fix
Runs limit fix --all: builds a fresh snapshot, applies the auto-fix suite and prints the report. When safe is set, dependency installs are skipped.
run_auto_fix_all
Runs the full auto-fix suite: kills ghost processes, copies the env template and installs missing dependencies, then re-runs the diagnostics and reports the outcome.
run_auto_fix_safe
Like run_auto_fix_all but never installs dependencies (--safe mode).