Skip to content

Feature (optional): store context hydration helper #30

@lwyBZss8924d

Description

@lwyBZss8924d

Summary

Provide a helper API to hydrate context lines for ranked results, simplifying CLI/orchestrator code that needs to render snippets.

Motivation

  • Multiple callers (CLI, agents) need to read files and extract n_lines context around a matched line.
  • Centralizing this logic improves consistency and reduces duplication.

Proposed API (Rust)

// File: src/workspace/store.rs
use anyhow::Result;
use crate::workspace::store::RankedLine;

pub async fn hydrate_context(
    &self,
    ranked: &[RankedLine],
    n_lines: usize,
) -> Result<Vec<(RankedLine, Vec<String>)>> {
    // Reads each file once, extracts [start..end) lines, returns alongside RankedLine
}

Notes

  • This is an optional helper; not required for JSON output features.
  • search CLI could reuse it when --output json to include the lines field consistently for workspace-backed results.

Acceptance criteria

  • Helper compiles and is covered by a basic test reading temp files.
  • No change to defaults unless explicitly used by callers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions