Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/infigraph-cli/src/analysis_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub(crate) fn cmd_security(
pub(crate) fn cmd_complexity(root: &Path, threshold: u32, file: Option<&str>) -> Result<()> {
let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
prism.init_read_only()?;

let backend = prism.backend().context("graph not initialized")?;
let rows = backend.get_complexity_ranking(file)?;
Expand Down Expand Up @@ -203,7 +203,7 @@ pub(crate) fn cmd_semantic_diff(root: &Path, old_ref: &str, new_ref: &str) -> Re
pub(crate) fn cmd_sequence(root: &Path, symbol_id: &str, depth: u32) -> Result<()> {
let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
prism.init_read_only()?;
let backend = prism.backend().context("not initialized")?;
let diagram = infigraph_core::sequence::generate_sequence_mermaid(backend, symbol_id, depth)?;
println!("{}", diagram);
Expand All @@ -223,7 +223,7 @@ pub(crate) fn cmd_review(
) -> Result<()> {
let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
prism.init_read_only()?;
let backend = prism
.backend()
.context("graph not initialized -- run 'infigraph index' first")?;
Expand Down
7 changes: 6 additions & 1 deletion crates/infigraph-cli/src/graph_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ use infigraph_languages::bundled_registry;
pub(crate) fn cmd_query(root: &Path, cypher: &str) -> Result<()> {
let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
// Read-only, matching the `query_graph` MCP tool: `cypher` is arbitrary
// user input, but rather than inspect it for write statements, this
// relies on the backend's own read-only enforcement to reject them
// clearly ("Cannot execute write operations in a read-only database")
// -- exactly like `query_graph` already does.
prism.init_read_only()?;

let backend = prism.backend().context("graph not initialized")?;
let rows = backend.raw_query(cypher)?;
Expand Down
18 changes: 9 additions & 9 deletions crates/infigraph-cli/src/info_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use serde_json::json;
pub(crate) fn cmd_stats(root: &Path) -> Result<()> {
let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
prism.init_read_only()?;
let stats = prism.stats()?;
println!("{}", stats);
Ok(())
Expand All @@ -35,7 +35,7 @@ pub(crate) fn cmd_languages(project_root: Option<&Path>) -> Result<()> {
pub(crate) fn cmd_symbols(root: &Path, file: &str) -> Result<()> {
let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
prism.init_read_only()?;

let backend = prism.backend().context("graph not initialized")?;
let symbols = backend.symbols_in_file(file)?;
Expand All @@ -60,7 +60,7 @@ pub(crate) fn cmd_symbols(root: &Path, file: &str) -> Result<()> {
pub(crate) fn cmd_skeleton(root: &Path, file: &str) -> Result<()> {
let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
prism.init_read_only()?;

let backend = prism.backend().context("graph not initialized")?;
let result = backend.skeleton(file)?;
Expand Down Expand Up @@ -212,7 +212,7 @@ pub(crate) fn cmd_dependencies(root: &Path, ecosystem: Option<&str>) -> Result<(
pub(crate) fn cmd_api_surface(root: &Path, file_filter: Option<&str>) -> Result<()> {
let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
prism.init_read_only()?;
let backend = prism.backend().context("graph not initialized")?;
let mut syms = backend.get_api_surface()?;
if let Some(f) = file_filter {
Expand All @@ -234,7 +234,7 @@ pub(crate) fn cmd_api_surface(root: &Path, file_filter: Option<&str>) -> Result<
pub(crate) fn cmd_file_deps(root: &Path, file: &str) -> Result<()> {
let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
prism.init_read_only()?;
let backend = prism.backend().context("graph not initialized")?;
let deps = backend.get_file_deps(file)?;
println!("File dependencies for '{}':\n", file);
Expand All @@ -258,7 +258,7 @@ pub(crate) fn cmd_file_deps(root: &Path, file: &str) -> Result<()> {
pub(crate) fn cmd_type_hierarchy(root: &Path, symbol: &str, depth: u32) -> Result<()> {
let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
prism.init_read_only()?;
let backend = prism.backend().context("graph not initialized")?;
let hier = backend.get_type_hierarchy(symbol, depth)?;
println!("Type hierarchy for '{}':\n", hier.root_name);
Expand All @@ -282,7 +282,7 @@ pub(crate) fn cmd_type_hierarchy(root: &Path, symbol: &str, depth: u32) -> Resul
pub(crate) fn cmd_test_coverage(root: &Path, file_filter: Option<&str>) -> Result<()> {
let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
prism.init_read_only()?;
let backend = prism.backend().context("graph not initialized")?;
let mut cov = backend.get_test_coverage()?;
if let Some(f) = file_filter {
Expand Down Expand Up @@ -560,7 +560,7 @@ pub(crate) fn cmd_index_confluence(
pub(crate) fn cmd_list_files(root: &Path, glob: Option<&str>) -> Result<()> {
let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
prism.init_read_only()?;

let backend = prism.backend().context("graph not initialized")?;
let rows = backend.raw_query("MATCH (s:Symbol) RETURN DISTINCT s.file ORDER BY s.file")?;
Expand Down Expand Up @@ -592,7 +592,7 @@ pub(crate) fn cmd_generate_test_context(
) -> Result<()> {
let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
prism.init_read_only()?;

let backend = prism.backend().context("graph not initialized")?;
let ctx = backend.generate_test_context(file, limit, None)?;
Expand Down
6 changes: 3 additions & 3 deletions crates/infigraph-cli/src/search_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub(crate) fn cmd_search(root: &Path, query: &str, limit: usize, alpha: f32) ->

let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
prism.init_read_only()?;

let backend = prism.backend().context("graph not initialized")?;
let rows =
Expand Down Expand Up @@ -132,7 +132,7 @@ pub(crate) fn cmd_search_code(
pub(crate) fn cmd_snippet(root: &Path, symbol_id: &str) -> Result<()> {
let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
prism.init_read_only()?;

let backend = prism.backend().context("graph not initialized")?;
let detail = backend
Expand All @@ -158,7 +158,7 @@ pub(crate) fn cmd_snippet(root: &Path, symbol_id: &str) -> Result<()> {
pub(crate) fn cmd_find_refs(root: &Path, symbol: &str) -> Result<()> {
let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
prism.init_read_only()?;
let backend = prism.backend().context("graph not initialized")?;
let refs = backend.find_all_references(symbol)?;
if refs.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion crates/infigraph-cli/src/viz_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub(crate) fn cmd_visualize_symbol(root: &Path, symbol_id: &str, depth: u32) ->
pub(crate) fn cmd_routes(root: &Path) -> Result<()> {
let registry = bundled_registry()?;
let mut prism = Infigraph::open(root, registry)?;
prism.init()?;
prism.init_read_only()?;

let backend = prism.backend().context("graph not initialized")?;

Expand Down
Loading