From ab0a3f03303d9b4308fd022364fd28df6810db38 Mon Sep 17 00:00:00 2001 From: Gabriel Gordon-Hall Date: Mon, 29 Jan 2024 18:31:45 +0000 Subject: [PATCH 1/2] make repo_name ; make autocomplete and folder queries case insensitive; remove repo.display_name() --- server/bleep/src/agent/prompts.rs | 2 +- server/bleep/src/agent/symbol.rs | 2 +- server/bleep/src/indexes/schema.rs | 2 +- server/bleep/src/query/compiler.rs | 2 +- server/bleep/src/repo.rs | 11 +---------- server/bleep/src/webserver/autocomplete.rs | 4 ++++ server/bleep/src/webserver/file.rs | 1 + server/bleep/src/webserver/repos.rs | 2 +- 8 files changed, 11 insertions(+), 15 deletions(-) diff --git a/server/bleep/src/agent/prompts.rs b/server/bleep/src/agent/prompts.rs index 059b18679b..efe7c947f4 100644 --- a/server/bleep/src/agent/prompts.rs +++ b/server/bleep/src/agent/prompts.rs @@ -100,7 +100,7 @@ pub fn system<'a>(paths: impl IntoIterator) -> String { if iter.peek().is_some() { s.push_str("\n## PATHS ##\nindex, repo, path\n"); for (i, path) in iter.enumerate() { - let repo = path.repo.display_name(); + let repo = path.repo.indexed_name(); let path = &path.path; s.push_str(&format!("{}, {}, {}\n", i, repo, path)); } diff --git a/server/bleep/src/agent/symbol.rs b/server/bleep/src/agent/symbol.rs index d40f7e90e6..a5fe2a4765 100644 --- a/server/bleep/src/agent/symbol.rs +++ b/server/bleep/src/agent/symbol.rs @@ -65,7 +65,7 @@ impl Agent { .to_string(), token_info_request: TokenInfoRequest { relative_path: chunk.repo_path.path.clone(), - repo_ref: chunk.repo_path.repo.display_name(), + repo_ref: chunk.repo_path.repo.indexed_name(), branch: None, start: range.start.byte, end: range.end.byte, diff --git a/server/bleep/src/indexes/schema.rs b/server/bleep/src/indexes/schema.rs index 54ac40fe96..f7f0cd961a 100644 --- a/server/bleep/src/indexes/schema.rs +++ b/server/bleep/src/indexes/schema.rs @@ -80,7 +80,7 @@ impl File { let repo_disk_path = builder.add_text_field("repo_disk_path", STRING); let repo_ref = builder.add_text_field("repo_ref", STRING | STORED); - let repo_name = builder.add_text_field("repo_name", trigram.clone()); + let repo_name = builder.add_text_field("repo_name", STRING | STORED); let relative_path = builder.add_text_field("relative_path", trigram.clone()); let content = builder.add_text_field("content", trigram.clone()); diff --git a/server/bleep/src/query/compiler.rs b/server/bleep/src/query/compiler.rs index 68414c4a64..97920efb00 100644 --- a/server/bleep/src/query/compiler.rs +++ b/server/bleep/src/query/compiler.rs @@ -255,7 +255,7 @@ pub fn case_permutations(s: &str) -> impl Iterator { // Make sure not to overflow. The end condition is a mask with the highest bit set, and we use // `u32` masks. - debug_assert!(chars.len() <= 31); + debug_assert!(chars.len() <= 5); let num_chars = chars.len(); diff --git a/server/bleep/src/repo.rs b/server/bleep/src/repo.rs index 9600770501..f064577a22 100644 --- a/server/bleep/src/repo.rs +++ b/server/bleep/src/repo.rs @@ -97,23 +97,14 @@ impl RepoRef { pub fn indexed_name(&self) -> String { // Local repos indexed as: dirname - // Github repos indexed as: github.com/org/repo + // Github repos indexed as: org/repo match self.backend { Backend::Local => Path::new(&self.name) .file_name() .expect("last component is `..`") .to_string_lossy() .into(), - Backend::Github => format!("{}", self), - } - } - - pub fn display_name(&self) -> String { - match self.backend { - // org_name/repo_name Backend::Github => self.name.to_owned(), - // repo_name - Backend::Local => self.indexed_name(), } } diff --git a/server/bleep/src/webserver/autocomplete.rs b/server/bleep/src/webserver/autocomplete.rs index c945590246..1684f5e341 100644 --- a/server/bleep/src/webserver/autocomplete.rs +++ b/server/bleep/src/webserver/autocomplete.rs @@ -52,6 +52,10 @@ pub(super) async fn handle( let queries = parser::parse(&api_params.q) .map_err(Error::user)? .into_iter() + .map(|q| parser::Query { + case_sensitive: Some(true), + ..q + }) .map(|mut q| { let keywords = &["lang:", "path:", "repo:"]; diff --git a/server/bleep/src/webserver/file.rs b/server/bleep/src/webserver/file.rs index 6f9d554dde..07f5ba726e 100644 --- a/server/bleep/src/webserver/file.rs +++ b/server/bleep/src/webserver/file.rs @@ -100,6 +100,7 @@ pub(super) async fn folder( repo: Some(parser::Literal::from(¶ms.repo_ref.indexed_name())), path: Some(parser::Literal::from(params.path.to_string_lossy())), branch: params.branch.map(|b| parser::Literal::from(&b)), + case_sensitive: Some(true), ..Default::default() }; diff --git a/server/bleep/src/webserver/repos.rs b/server/bleep/src/webserver/repos.rs index 67bbccb243..636cb9d86b 100644 --- a/server/bleep/src/webserver/repos.rs +++ b/server/bleep/src/webserver/repos.rs @@ -128,7 +128,7 @@ impl From<(&RepoRef, &Repository)> for Repo { Repo { provider: key.backend(), - name: key.display_name(), + name: key.indexed_name(), repo_ref: key.clone(), sync_status: repo.pub_sync_status.clone(), local_duplicates: vec![], From c44f20c2aa2b67b8c832ab0aab3642ef4877c164 Mon Sep 17 00:00:00 2001 From: Gabriel Gordon-Hall Date: Mon, 29 Jan 2024 18:52:36 +0000 Subject: [PATCH 2/2] use stringified repo_ref in prompt --- server/bleep/src/agent/prompts.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/bleep/src/agent/prompts.rs b/server/bleep/src/agent/prompts.rs index efe7c947f4..0f3bb4d5fe 100644 --- a/server/bleep/src/agent/prompts.rs +++ b/server/bleep/src/agent/prompts.rs @@ -100,7 +100,8 @@ pub fn system<'a>(paths: impl IntoIterator) -> String { if iter.peek().is_some() { s.push_str("\n## PATHS ##\nindex, repo, path\n"); for (i, path) in iter.enumerate() { - let repo = path.repo.indexed_name(); + let repo = &path.repo; + let repo = &format!("{repo}"); let path = &path.path; s.push_str(&format!("{}, {}, {}\n", i, repo, path)); }