magellan 3.1.9

Deterministic codebase mapping tool for local development
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
//! Get command - Retrieve source code for symbols
//!
//! Usage: magellan get --db <FILE> --file <PATH> --symbol <NAME>

use anyhow::Result;
use std::path::PathBuf;

// Use the library items through the magellan library
use magellan::backend_router::MagellanBackend;
use magellan::common::detect_language_from_path;
use magellan::generation::schema::CodeChunk;
use magellan::graph::query;
use magellan::output::rich::{SpanChecksums, SpanContext};
use magellan::output::{output_json, JsonResponse, Span, SymbolMatch};
use magellan::{generate_execution_id, CodeGraph, OutputFormat};
use serde::{Deserialize, Serialize};

/// Response for get command with rich span data
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GetResponse {
    /// Symbol details
    pub symbol: SymbolMatch,
    /// Source code content
    pub content: String,
}

pub fn run_get(
    db_path: PathBuf,
    file_path: String,
    symbol_name: String,
    output_format: OutputFormat,
    with_context: bool,
    with_semantics: bool,
    with_checksums: bool,
    context_lines: usize,
) -> Result<()> {
    // Build args for execution tracking
    let args = vec![
        "get".to_string(),
        "--db".to_string(),
        db_path.to_string_lossy().to_string(),
        "--file".to_string(),
        file_path.clone(),
        "--symbol".to_string(),
        symbol_name.clone(),
    ];

    let backend = MagellanBackend::open(&db_path)?;
    let exec_id = generate_execution_id();
    let db_path_str = db_path.to_string_lossy().to_string();

    backend.start_execution(
        &exec_id,
        env!("CARGO_PKG_VERSION"),
        &args,
        None,
        &db_path_str,
    )?;

    let chunks = backend.get_code_chunks_for_symbol(&file_path, &symbol_name)?;

    if chunks.is_empty() {
        eprintln!(
            "No code chunks found for symbol '{}' in file '{}'",
            symbol_name, file_path
        );
        backend.finish_execution(&exec_id, "success", None, 0, 0, 0)?;
        return Ok(());
    }

    // Handle JSON output mode
    if output_format == OutputFormat::Json || output_format == OutputFormat::Pretty {
        // For Geo backend, use backend-neutral API
        #[cfg(feature = "geometric-backend")]
        if matches!(
            MagellanBackend::detect_type(&db_path),
            magellan::backend_router::BackendType::Geometric
        ) {
            // Geo backend: use backend-neutral API
            let symbols = backend.symbols_in_file(&file_path)?;
            if let Some(symbol_info) = symbols.iter().find(|s| s.name == symbol_name) {
                // Create span from symbol info
                let span = Span::new(
                    symbol_info.file_path.clone(),
                    symbol_info.byte_start as usize,
                    symbol_info.byte_end as usize,
                    symbol_info.start_line as usize,
                    symbol_info.start_col as usize,
                    symbol_info.end_line as usize,
                    symbol_info.end_col as usize,
                );

                let mut enriched_span = span;

                // Add context if requested
                if with_context {
                    if let Some(context) = SpanContext::extract(
                        &symbol_info.file_path,
                        symbol_info.start_line as usize,
                        symbol_info.end_line as usize,
                        context_lines,
                    ) {
                        enriched_span = enriched_span.with_context(context);
                    }
                }

                // Add semantics if requested
                if with_semantics {
                    let kind = format!("{:?}", symbol_info.kind);
                    let language = symbol_info
                        .language
                        .clone()
                        .unwrap_or_else(|| detect_language_from_path(&symbol_info.file_path));
                    enriched_span = enriched_span.with_semantics_from(kind, language);
                }

                // Add checksums if requested
                if with_checksums {
                    let checksums = SpanChecksums::compute(
                        &symbol_info.file_path,
                        symbol_info.byte_start as usize,
                        symbol_info.byte_end as usize,
                    );
                    enriched_span = enriched_span.with_checksums(checksums);
                }

                let symbol_match = SymbolMatch::new(
                    symbol_info.name.clone(),
                    format!("{:?}", symbol_info.kind),
                    enriched_span,
                    None,
                    Some(format!("{}", symbol_info.id)),
                );

                // Get the content from chunks
                let content = chunks
                    .iter()
                    .map(|c| c.content.clone())
                    .collect::<Vec<_>>()
                    .join("\n");

                let response = GetResponse {
                    symbol: symbol_match,
                    content,
                };

                let json_response = JsonResponse::new(response, &exec_id);
                output_json(&json_response, output_format)?;
                backend.finish_execution(&exec_id, "success", None, 0, 0, 0)?;
                return Ok(());
            } else {
                eprintln!("Symbol '{}' not found in file '{}'", symbol_name, file_path);
                backend.finish_execution(&exec_id, "success", None, 0, 0, 0)?;
                return Ok(());
            }
        }

        // For SQLite backend (or no Geo feature), use SQLite-specific query
        let mut graph = CodeGraph::open(&db_path)?;
        if let Ok(symbol_entries) = query::symbol_nodes_in_file_with_ids(&mut graph, &file_path) {
            for (_node_id, symbol, symbol_id) in symbol_entries {
                if let Some(ref name) = symbol.name {
                    if name == &symbol_name {
                        // Found the symbol - create enriched span
                        let span = Span::new(
                            symbol.file_path.to_string_lossy().to_string(),
                            symbol.byte_start,
                            symbol.byte_end,
                            symbol.start_line,
                            symbol.start_col,
                            symbol.end_line,
                            symbol.end_col,
                        );

                        let mut enriched_span = span;

                        // Add context if requested
                        if with_context {
                            if let Some(context) = SpanContext::extract(
                                symbol.file_path.to_string_lossy().as_ref(),
                                symbol.start_line,
                                symbol.end_line,
                                context_lines,
                            ) {
                                enriched_span = enriched_span.with_context(context);
                            }
                        }

                        // Add semantics if requested
                        if with_semantics {
                            let kind = symbol.kind_normalized.clone();
                            let language = detect_language_from_path(
                                symbol.file_path.to_string_lossy().as_ref(),
                            );
                            enriched_span = enriched_span.with_semantics_from(kind, language);
                        }

                        // Add checksums if requested
                        if with_checksums {
                            let checksums = SpanChecksums::compute(
                                symbol.file_path.to_string_lossy().as_ref(),
                                symbol.byte_start,
                                symbol.byte_end,
                            );
                            enriched_span = enriched_span.with_checksums(checksums);
                        }

                        let symbol_match = SymbolMatch::new(
                            name.clone(),
                            symbol.kind_normalized.clone(),
                            enriched_span,
                            None,
                            symbol_id,
                        );

                        // Get the content from chunks
                        let content = chunks
                            .iter()
                            .map(|c| c.content.clone())
                            .collect::<Vec<_>>()
                            .join("\n");

                        let response = GetResponse {
                            symbol: symbol_match,
                            content,
                        };

                        let json_response = JsonResponse::new(response, &exec_id);
                        output_json(&json_response, output_format)?;
                        break;
                    }
                }
            }
        }
        backend.finish_execution(&exec_id, "success", None, 0, 0, 0)?;
        return Ok(());
    }

    // Human mode (backend-neutral)
    for chunk in chunks {
        println!(
            "// Symbol: {} in {}",
            chunk.symbol_name.as_ref().unwrap_or(&symbol_name),
            chunk.file_path
        );
        println!(
            "// Kind: {}",
            chunk.symbol_kind.as_ref().unwrap_or(&"?".to_string())
        );
        println!("// Bytes: {}-{}", chunk.byte_start, chunk.byte_end);
        println!("{}", chunk.content);
        println!();
    }

    backend.finish_execution(&exec_id, "success", None, 0, 0, 0)?;
    Ok(())
}

pub fn run_get_file(db_path: PathBuf, file_path: String) -> Result<()> {
    // Build args for execution tracking
    let args = vec![
        "get-file".to_string(),
        "--db".to_string(),
        db_path.to_string_lossy().to_string(),
        "--file".to_string(),
        file_path.clone(),
    ];

    let backend = MagellanBackend::open(&db_path)?;
    let exec_id = generate_execution_id();
    let db_path_str = db_path.to_string_lossy().to_string();

    backend.start_execution(
        &exec_id,
        env!("CARGO_PKG_VERSION"),
        &args,
        None,
        &db_path_str,
    )?;

    let chunks = backend.get_code_chunks(&file_path)?;

    if chunks.is_empty() {
        eprintln!("No code chunks found for file '{}'", file_path);
        backend.finish_execution(&exec_id, "success", None, 0, 0, 0)?;
        return Ok(());
    }

    println!("// {} code chunks in {}", chunks.len(), file_path);
    println!();

    for chunk in chunks {
        let symbol = chunk.symbol_name.as_deref().unwrap_or("<unnamed>");
        let kind = chunk.symbol_kind.as_deref().unwrap_or("?");

        println!(
            "// {} ({}) [{}-{}]",
            symbol, kind, chunk.byte_start, chunk.byte_end
        );
        println!("{}", chunk.content);
        println!();
    }

    backend.finish_execution(&exec_id, "success", None, 0, 0, 0)?;
    Ok(())
}

/// List all code chunks in the database.
///
/// Usage: magellan chunks --db <FILE> [--limit N] [--file PATTERN] [--kind KIND] [--output FORMAT]
pub fn run_chunks(
    db_path: PathBuf,
    output_format: OutputFormat,
    limit: Option<usize>,
    file_filter: Option<String>,
    kind_filter: Option<String>,
) -> Result<()> {
    // Build args for execution tracking
    let mut args = vec![
        "chunks".to_string(),
        "--db".to_string(),
        db_path.to_string_lossy().to_string(),
    ];
    if let Some(ref limit_val) = limit {
        args.push("--limit".to_string());
        args.push(limit_val.to_string());
    }
    if let Some(ref file) = file_filter {
        args.push("--file".to_string());
        args.push(file.clone());
    }
    if let Some(ref kind) = kind_filter {
        args.push("--kind".to_string());
        args.push(kind.clone());
    }

    // NOTE: file_filter and kind_filter are SQLite-specific features
    // For Geo backend, we currently get all chunks and filter
    let backend = MagellanBackend::open(&db_path)?;
    let exec_id = generate_execution_id();
    let db_path_str = db_path.to_string_lossy().to_string();

    backend.start_execution(
        &exec_id,
        env!("CARGO_PKG_VERSION"),
        &args,
        None,
        &db_path_str,
    )?;

    // For now, we need to use SQLite directly for filtering
    // TODO: Add filtering support to MagellanBackend
    #[cfg(feature = "geometric-backend")]
    let chunks = if matches!(
        MagellanBackend::detect_type(&db_path),
        magellan::backend_router::BackendType::Geometric
    ) {
        // For Geo backend, get all chunks (no filtering support yet)
        // This is a known limitation - filtering is SQLite-only for now
        Vec::new() // Placeholder - would need to implement get_all_chunks()
    } else {
        // Fallback to SQLite for filtering
        use rusqlite::Connection;
        let conn = Connection::open(&db_path)?;

        let mut query = String::from(
            "SELECT id, file_path, byte_start, byte_end, content, content_hash,
                 symbol_name, symbol_kind, created_at
                 FROM code_chunks
                 WHERE 1=1",
        );

        let mut params: Vec<String> = Vec::new();

        if let Some(ref file_pattern) = file_filter {
            query.push_str(&format!(" AND file_path LIKE ?{}", params.len() + 1));
            params.push(format!("%{}%", file_pattern));
        }

        if let Some(ref kind) = kind_filter {
            query.push_str(&format!(" AND symbol_kind = ?{}", params.len() + 1));
            params.push(kind.to_string());
        }

        query.push_str(" ORDER BY file_path, byte_start");

        if let Some(limit_val) = limit {
            query.push_str(&format!(" LIMIT {}", limit_val));
        }

        let mut stmt = conn.prepare(&query)?;
        let params_ref: Vec<&dyn rusqlite::ToSql> =
            params.iter().map(|s| s as &dyn rusqlite::ToSql).collect();

        let chunk_iter = stmt.query_map(params_ref.as_slice(), |row| {
            Ok(CodeChunk {
                id: Some(row.get(0)?),
                file_path: row.get(1)?,
                byte_start: row.get(2)?,
                byte_end: row.get(3)?,
                content: row.get(4)?,
                content_hash: row.get(5)?,
                symbol_name: row.get(6)?,
                symbol_kind: row.get(7)?,
                created_at: row.get(8)?,
            })
        })?;

        let chunks: Result<Vec<CodeChunk>, _> = chunk_iter.collect();
        chunks?
    };

    #[cfg(not(feature = "geometric-backend"))]
    let chunks = {
        // SQLite-only path
        use rusqlite::Connection;
        let conn = Connection::open(&db_path)?;

        let mut query = String::from(
            "SELECT id, file_path, byte_start, byte_end, content, content_hash,
                 symbol_name, symbol_kind, created_at
                 FROM code_chunks
                 WHERE 1=1",
        );

        let mut params: Vec<String> = Vec::new();

        if let Some(ref file_pattern) = file_filter {
            query.push_str(&format!(" AND file_path LIKE ?{}", params.len() + 1));
            params.push(format!("%{}%", file_pattern));
        }

        if let Some(ref kind) = kind_filter {
            query.push_str(&format!(" AND symbol_kind = ?{}", params.len() + 1));
            params.push(kind.to_string());
        }

        query.push_str(" ORDER BY file_path, byte_start");

        if let Some(limit_val) = limit {
            query.push_str(&format!(" LIMIT {}", limit_val));
        }

        let mut stmt = conn.prepare(&query)?;
        let params_ref: Vec<&dyn rusqlite::ToSql> =
            params.iter().map(|s| s as &dyn rusqlite::ToSql).collect();

        let chunk_iter = stmt.query_map(params_ref.as_slice(), |row| {
            Ok(CodeChunk {
                id: Some(row.get(0)?),
                file_path: row.get(1)?,
                byte_start: row.get(2)?,
                byte_end: row.get(3)?,
                content: row.get(4)?,
                content_hash: row.get(5)?,
                symbol_name: row.get(6)?,
                symbol_kind: row.get(7)?,
                created_at: row.get(8)?,
            })
        })?;

        let chunks: Result<Vec<CodeChunk>, _> = chunk_iter.collect();
        chunks?
    };

    if chunks.is_empty() {
        eprintln!("No code chunks found in database");
        backend.finish_execution(&exec_id, "success", None, 0, 0, 0)?;
        return Ok(());
    }

    // Handle JSON output
    if output_format == OutputFormat::Json || output_format == OutputFormat::Pretty {
        let json_response = JsonResponse::new(chunks, &exec_id);
        output_json(&json_response, output_format)?;
        backend.finish_execution(&exec_id, "success", None, 0, 0, 0)?;
        return Ok(());
    }

    // Human output
    println!("// {} code chunks in database", chunks.len());
    println!();

    for chunk in chunks {
        let symbol = chunk.symbol_name.as_deref().unwrap_or("<unnamed>");
        let kind = chunk.symbol_kind.as_deref().unwrap_or("?");
        let preview: String = chunk
            .content
            .lines()
            .next()
            .unwrap_or("")
            .chars()
            .take(80)
            .collect();

        println!(
            "{}: {} ({}) [{}-{}]",
            chunk.file_path, symbol, kind, chunk.byte_start, chunk.byte_end
        );
        println!("  {}", preview);
        println!();
    }

    backend.finish_execution(&exec_id, "success", None, 0, 0, 0)?;
    Ok(())
}

/// Get a code chunk by file path and byte range.
///
/// Usage: magellan chunk-by-span --db <FILE> --file <PATH> --start <N> --end <N> [--output FORMAT]
pub fn run_chunk_by_span(
    db_path: PathBuf,
    file_path: String,
    byte_start: usize,
    byte_end: usize,
    output_format: OutputFormat,
) -> Result<()> {
    // Build args for execution tracking
    let args = vec![
        "chunk-by-span".to_string(),
        "--db".to_string(),
        db_path.to_string_lossy().to_string(),
        "--file".to_string(),
        file_path.clone(),
        "--start".to_string(),
        byte_start.to_string(),
        "--end".to_string(),
        byte_end.to_string(),
    ];

    let backend = MagellanBackend::open(&db_path)?;
    let exec_id = generate_execution_id();
    let db_path_str = db_path.to_string_lossy().to_string();

    backend.start_execution(
        &exec_id,
        env!("CARGO_PKG_VERSION"),
        &args,
        None,
        &db_path_str,
    )?;

    let chunk = backend.get_code_chunk_by_span(&file_path, byte_start, byte_end)?;

    let chunk = match chunk {
        Some(c) => c,
        None => {
            eprintln!(
                "No code chunk found at {}:{}-{}",
                file_path, byte_start, byte_end
            );
            backend.finish_execution(&exec_id, "success", None, 0, 0, 0)?;
            return Ok(());
        }
    };

    // Handle JSON output
    if output_format == OutputFormat::Json || output_format == OutputFormat::Pretty {
        let json_response = JsonResponse::new(chunk, &exec_id);
        output_json(&json_response, output_format)?;
        backend.finish_execution(&exec_id, "success", None, 0, 0, 0)?;
        return Ok(());
    }

    // Human output
    let symbol = chunk.symbol_name.as_deref().unwrap_or("<unnamed>");
    let kind = chunk.symbol_kind.as_deref().unwrap_or("?");

    println!("// File: {}", chunk.file_path);
    println!("// Symbol: {} ({})", symbol, kind);
    println!("// Bytes: {}-{}", chunk.byte_start, chunk.byte_end);
    println!("// Hash: {}", chunk.content_hash);
    println!();
    println!("{}", chunk.content);

    backend.finish_execution(&exec_id, "success", None, 0, 0, 0)?;
    Ok(())
}

/// Get all code chunks for a symbol name (global search across files).
///
/// Usage: magellan chunk-by-symbol --db <FILE> --symbol <NAME> [--file PATTERN] [--output FORMAT]
pub fn run_chunk_by_symbol(
    db_path: PathBuf,
    symbol_name: String,
    output_format: OutputFormat,
    file_filter: Option<String>,
) -> Result<()> {
    // Build args for execution tracking
    let mut args = vec![
        "chunk-by-symbol".to_string(),
        "--db".to_string(),
        db_path.to_string_lossy().to_string(),
        "--symbol".to_string(),
        symbol_name.clone(),
    ];
    if let Some(ref file) = file_filter {
        args.push("--file".to_string());
        args.push(file.clone());
    }

    let backend = MagellanBackend::open(&db_path)?;
    let exec_id = generate_execution_id();
    let db_path_str = db_path.to_string_lossy().to_string();

    backend.start_execution(
        &exec_id,
        env!("CARGO_PKG_VERSION"),
        &args,
        None,
        &db_path_str,
    )?;

    // For global symbol search, we need to use SQLite directly for now
    // Geo backend requires file_path for chunk lookup
    // TODO: Implement global chunk search in Geo backend
    let chunks = {
        use rusqlite::Connection;
        let conn = Connection::open(&db_path)?;

        let mut query = String::from(
            "SELECT id, file_path, byte_start, byte_end, content, content_hash, \
             symbol_name, symbol_kind, created_at \
             FROM code_chunks \
             WHERE symbol_name = ?1",
        );

        let mut params: Vec<String> = vec![symbol_name.clone()];

        if let Some(ref file_pattern) = file_filter {
            query.push_str(&format!(" AND file_path LIKE ?{}", params.len() + 1));
            params.push(format!("%{}%", file_pattern));
        }

        query.push_str(" ORDER BY file_path, byte_start");

        let mut stmt = conn.prepare(&query)?;

        // Build params as references for rusqlite
        let params_ref: Vec<&dyn rusqlite::ToSql> =
            params.iter().map(|s| s as &dyn rusqlite::ToSql).collect();

        let chunk_iter = stmt.query_map(params_ref.as_slice(), |row| {
            Ok(CodeChunk {
                id: Some(row.get(0)?),
                file_path: row.get(1)?,
                byte_start: row.get(2)?,
                byte_end: row.get(3)?,
                content: row.get(4)?,
                content_hash: row.get(5)?,
                symbol_name: row.get(6)?,
                symbol_kind: row.get(7)?,
                created_at: row.get(8)?,
            })
        })?;

        let chunks: Result<Vec<CodeChunk>, _> = chunk_iter.collect();
        chunks?
    };

    if chunks.is_empty() {
        eprintln!("No code chunks found for symbol '{}'", symbol_name);
        backend.finish_execution(&exec_id, "success", None, 0, 0, 0)?;
        return Ok(());
    }

    // Handle JSON output
    if output_format == OutputFormat::Json || output_format == OutputFormat::Pretty {
        let json_response = JsonResponse::new(chunks, &exec_id);
        output_json(&json_response, output_format)?;
        backend.finish_execution(&exec_id, "success", None, 0, 0, 0)?;
        return Ok(());
    }

    // Human output - group by file
    println!("// {} chunks for symbol '{}'", chunks.len(), symbol_name);
    println!();

    // Group chunks by file path
    let mut chunks_by_file: std::collections::HashMap<String, Vec<&CodeChunk>> =
        std::collections::HashMap::new();
    for chunk in &chunks {
        chunks_by_file
            .entry(chunk.file_path.clone())
            .or_default()
            .push(chunk);
    }

    for (file_path, file_chunks) in chunks_by_file.iter() {
        println!("// File: {}", file_path);
        for chunk in file_chunks {
            let kind = chunk.symbol_kind.as_deref().unwrap_or("?");
            println!("  {} [{}-{}]", kind, chunk.byte_start, chunk.byte_end);
            for line in chunk.content.lines() {
                println!("    {}", line);
            }
            println!();
        }
    }

    backend.finish_execution(&exec_id, "success", None, 0, 0, 0)?;
    Ok(())
}