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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@ Cross.toml
ASSETS_LICENSES.md

external/
/.bitfun/search/flashgrep-index/
2 changes: 1 addition & 1 deletion resources/flashgrep/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Place the prebuilt `flashgrep` daemon binary in this directory.

Pinned release:

- `v0.2.6` from `wgqqqqq/flashgrep`
- `v0.2.10` from `wgqqqqq/flashgrep`

Expected filenames:

Expand Down
4 changes: 2 additions & 2 deletions resources/flashgrep/VERSION.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"repo": "wgqqqqq/flashgrep",
"tag": "v0.2.7",
"published_at": "2026-05-12T04:48:18Z"
"tag": "v0.2.10",
"published_at": "2026-06-17T08:15:11Z"
}
Binary file modified resources/flashgrep/flashgrep-aarch64-apple-darwin
Binary file not shown.
Binary file modified resources/flashgrep/flashgrep-aarch64-pc-windows-msvc.exe
Binary file not shown.
Binary file modified resources/flashgrep/flashgrep-aarch64-unknown-linux-musl
Binary file not shown.
Binary file modified resources/flashgrep/flashgrep-x86_64-apple-darwin
Binary file not shown.
Binary file modified resources/flashgrep/flashgrep-x86_64-pc-windows-msvc.exe
Binary file not shown.
Binary file modified resources/flashgrep/flashgrep-x86_64-unknown-linux-musl
Binary file not shown.
10 changes: 8 additions & 2 deletions scripts/dev.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,16 @@ function flashgrepBinaryNames() {
return ['flashgrep-aarch64-apple-darwin'];
}
if (process.platform === 'linux' && process.arch === 'x64') {
return ['flashgrep-x86_64-unknown-linux-gnu'];
return [
'flashgrep-x86_64-unknown-linux-musl',
'flashgrep-x86_64-unknown-linux-gnu',
];
}
if (process.platform === 'linux' && process.arch === 'arm64') {
return ['flashgrep-aarch64-unknown-linux-gnu'];
return [
'flashgrep-aarch64-unknown-linux-musl',
'flashgrep-aarch64-unknown-linux-gnu',
];
}
return [process.platform === 'win32' ? 'flashgrep.exe' : 'flashgrep'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ pub(crate) fn should_retry_remote_scan_fallback_as_files_with_matches(
primary_search_mode: SearchModeConfig,
search_results: &SearchResults,
) -> bool {
let primary_has_details = !search_results.hits.is_empty()
let primary_has_details = !search_results.line_matches.is_empty()
|| !search_results.file_counts.is_empty()
|| !search_results.file_match_counts.is_empty()
|| !search_results.matched_paths.is_empty();
Expand Down Expand Up @@ -289,8 +289,9 @@ fn hex_encode(bytes: &[u8]) -> String {
#[cfg(test)]
mod tests {
use super::*;
use crate::workspace_search::flashgrep::protocol::LineMatch;
use crate::workspace_search::flashgrep::{
FileCount, SearchBackend, SearchHit, SearchModeConfig, SearchResults,
FileCount, SearchBackend, SearchModeConfig, SearchResults,
};
use std::path::{Path, PathBuf};

Expand Down Expand Up @@ -450,16 +451,16 @@ mod tests {
&with_file_counts,
));

let mut with_hits = search_results_with_counts(7, 12);
with_hits.hits.push(SearchHit {
let mut with_line_matches = search_results_with_counts(7, 12);
with_line_matches.line_matches.push(LineMatch {
path: "/repo/src/lib.rs".to_string(),
matches: Vec::new(),
lines: Vec::new(),
line_number: 42,
line_text: Some("needle".to_string()),
});
assert!(!should_retry_remote_scan_fallback_as_files_with_matches(
SearchBackend::ScanFallback,
SearchModeConfig::LineMatches,
&with_hits,
&with_line_matches,
));
assert!(!should_retry_remote_scan_fallback_as_files_with_matches(
SearchBackend::IndexedClean,
Expand Down Expand Up @@ -492,7 +493,6 @@ mod tests {
file_counts: Vec::new(),
file_match_counts: Vec::new(),
line_matches: Vec::new(),
hits: Vec::new(),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ use crate::remote_ssh::{normalize_remote_workspace_path, RemoteWorkspaceEntry};
use crate::workspace_search::flashgrep::error::AppError;
use crate::workspace_search::flashgrep::{
drain_content_length_messages, log_flashgrep_stderr_line_with_context, ClientCapabilities,
ClientInfo, ConsistencyMode, FlashgrepRepoSession, GlobOutcome, GlobParams, GlobRequest,
InitializeParams, OpenRepoParams, ProtocolClient, QuerySpec, RefreshPolicyConfig, RepoConfig,
RepoRef, RepoStatus, Request, Response, SearchBackend, SearchModeConfig, SearchOutcome,
SearchParams, SearchRequest, SearchResults, TaskRef, TaskStatus, FLASHGREP_LOG_TARGET,
ClientInfo, FlashgrepRepoSession, GlobOutcome, GlobParams, GlobRequest, InitializeParams,
OpenRepoParams, ProtocolClient, QuerySpec, RefreshPolicyConfig, RepoConfig, RepoRef,
RepoStatus, Request, Response, SearchBackend, SearchModeConfig, SearchOutcome, SearchParams,
SearchRequest, SearchResults, TaskRef, TaskStatus, FLASHGREP_LOG_TARGET,
};
use crate::workspace_search::result_mapping::convert_search_results;
use crate::workspace_search::{
ContentSearchRequest, ContentSearchResult, GlobSearchRequest, GlobSearchResult,
IndexTaskHandle, WorkspaceIndexStatus, WorkspaceSearchFileCount, WorkspaceSearchHit,
WorkspaceSearchRepoStatus,
IndexTaskHandle, WorkspaceIndexStatus, WorkspaceSearchFileCount, WorkspaceSearchRepoStatus,
};
use async_trait::async_trait;
use bitfun_services_core::filesystem::FileSearchOutcome;
Expand Down Expand Up @@ -355,7 +354,6 @@ impl RemoteStdioRepoSession {
repo_id: self.repo_id.clone(),
query,
scope,
consistency: ConsistencyMode::WorkspaceEventual,
allow_scan_fallback: true,
},
})
Expand Down Expand Up @@ -633,10 +631,10 @@ impl RemoteWorkspaceSearchService {

let mut results = convert_search_results(&raw_results, output_mode);
log::debug!(
"Remote workspace content search converted: backend={:?}, repo_phase={:?}, hits={}, file_counts={}, file_match_counts={}, matched_paths={}, converted_results={}, matched_lines={}, matched_occurrences={}",
"Remote workspace content search converted: backend={:?}, repo_phase={:?}, line_matches={}, file_counts={}, file_match_counts={}, matched_paths={}, converted_results={}, matched_lines={}, matched_occurrences={}",
backend,
repo_status.phase,
raw_results.hits.len(),
raw_results.line_matches.len(),
raw_results.file_counts.len(),
raw_results.file_match_counts.len(),
raw_results.matched_paths.len(),
Expand All @@ -659,12 +657,7 @@ impl RemoteWorkspaceSearchService {
.into_iter()
.map(WorkspaceSearchFileCount::from)
.collect(),
hits: raw_results
.hits
.clone()
.into_iter()
.map(WorkspaceSearchHit::from)
.collect(),
hits: Vec::new(),
backend: backend.into(),
repo_status: repo_status.into(),
candidate_docs: raw_results.candidate_docs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ impl RepoSession {
repo_id: self.repo_id.clone(),
query: request.query,
scope: request.scope,
consistency: request.consistency,
allow_scan_fallback: request.allow_scan_fallback,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

mod client;
pub mod error;
mod protocol;
pub(crate) mod protocol;
mod repo_session;
mod rpc_client;
mod types;
pub(crate) mod types;

pub const FLASHGREP_LOG_TARGET: &str = "flashgrep";

Expand Down Expand Up @@ -47,14 +47,14 @@ pub fn log_flashgrep_stderr_line_with_context(context: Option<&str>, line: &str)

pub use client::{ManagedClient, RepoSession};
pub use protocol::{
ClientCapabilities, ClientInfo, FileMatch, GlobParams, InitializeParams, MatchLocation,
RepoRef, Request, Response, SearchHit, SearchLine, SearchParams, TaskRef,
ClientCapabilities, ClientInfo, GlobParams, InitializeParams, RepoRef, Request, Response,
SearchParams, TaskRef,
};
pub use repo_session::FlashgrepRepoSession;
pub use rpc_client::{drain_content_length_messages, ProtocolClient};
pub use types::{
ConsistencyMode, DirtyFileStats, FileCount, GlobOutcome, GlobRequest, OpenRepoParams,
PathScope, QuerySpec, RefreshPolicyConfig, RepoConfig, RepoPhase, RepoStatus, SearchBackend,
SearchModeConfig, SearchOutcome, SearchRequest, SearchResults, TaskKind, TaskPhase, TaskState,
TaskStatus, WorkspaceOverlayStatus,
DirtyFileStats, FileCount, GlobOutcome, GlobRequest, OpenRepoParams, PathScope, QuerySpec,
RefreshPolicyConfig, RepoConfig, RepoPhase, RepoStatus, SearchBackend, SearchModeConfig,
SearchOutcome, SearchRequest, SearchResults, TaskKind, TaskPhase, TaskState, TaskStatus,
WorkspaceOverlayStatus,
};
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ pub struct SearchParams {
#[serde(default)]
pub scope: PathScope,
#[serde(default)]
pub consistency: ConsistencyMode,
#[serde(default)]
pub allow_scan_fallback: bool,
}

Expand Down Expand Up @@ -241,21 +239,11 @@ pub enum CorpusModeConfig {
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Default, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum SearchModeConfig {
CountOnly,
CountMatches,
#[default]
MaterializeMatches,
FilesWithMatches,
LineMatches,
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize, Default)]
#[serde(rename_all = "snake_case")]
pub enum ConsistencyMode {
SnapshotOnly,
#[default]
WorkspaceEventual,
WorkspaceStrict,
LineMatches,
CountOnly,
CountMatches,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -324,8 +312,6 @@ pub enum Response {
SearchCompleted {
repo_id: String,
backend: SearchBackend,
#[serde(default, skip_serializing_if = "Option::is_none")]
consistency_applied: Option<ConsistencyMode>,
status: RepoStatus,
results: SearchResults,
},
Expand Down Expand Up @@ -364,8 +350,6 @@ pub struct ServerCapabilities {

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchProtocolCapabilities {
#[serde(default)]
pub consistency_modes: Vec<ConsistencyMode>,
pub search_modes: Vec<SearchModeConfig>,
}

Expand Down Expand Up @@ -473,7 +457,6 @@ pub enum TaskPhase {
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum SearchBackend {
IndexedSnapshot,
IndexedClean,
IndexedWorkspaceView,
RgFallback,
Expand All @@ -497,8 +480,6 @@ pub struct SearchResults {
pub file_match_counts: Vec<FileMatchCount>,
#[serde(default)]
pub line_matches: Vec<LineMatch>,
#[serde(default)]
pub hits: Vec<SearchHit>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand All @@ -517,35 +498,8 @@ pub struct FileMatchCount {
pub struct LineMatch {
pub path: String,
pub line_number: usize,
pub line_text: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchHit {
pub path: String,
pub matches: Vec<FileMatch>,
pub lines: Vec<SearchLine>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FileMatch {
pub location: MatchLocation,
pub snippet: String,
pub matched_text: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MatchLocation {
pub line: usize,
pub column: usize,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum SearchLine {
Match { value: FileMatch },
Context { line_number: usize, snippet: String },
ContextBreak,
#[serde(default)]
pub line_text: Option<String>,
}

fn default_top_k_tokens() -> usize {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
pub use super::protocol::{
ConsistencyMode, DirtyFileStats, FileCount, OpenRepoParams, PathScope, QuerySpec,
RefreshPolicyConfig, RepoConfig, RepoPhase, RepoStatus, SearchBackend, SearchModeConfig,
SearchResults, TaskKind, TaskPhase, TaskState, TaskStatus, WorkspaceOverlayStatus,
DirtyFileStats, FileCount, OpenRepoParams, PathScope, QuerySpec, RefreshPolicyConfig,
RepoConfig, RepoPhase, RepoStatus, SearchBackend, SearchModeConfig, SearchResults, TaskKind,
TaskPhase, TaskState, TaskStatus, WorkspaceOverlayStatus,
};

#[derive(Debug, Clone)]
pub struct SearchRequest {
pub query: QuerySpec,
pub scope: PathScope,
pub consistency: ConsistencyMode,
pub allow_scan_fallback: bool,
}

Expand All @@ -35,7 +34,6 @@ impl SearchRequest {
Self {
query,
scope: PathScope::default(),
consistency: ConsistencyMode::WorkspaceEventual,
allow_scan_fallback: false,
}
}
Expand All @@ -45,11 +43,6 @@ impl SearchRequest {
self
}

pub fn with_consistency(mut self, consistency: ConsistencyMode) -> Self {
self.consistency = consistency;
self
}

pub fn with_scan_fallback(mut self, allow_scan_fallback: bool) -> Self {
self.allow_scan_fallback = allow_scan_fallback;
self
Expand Down
Loading
Loading