Skip to content

Commit c6b4dad

Browse files
Improve conversation search output and flags
1 parent 60fdddc commit c6b4dad

2 files changed

Lines changed: 35 additions & 24 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ sgrep conv index --watch
117117

118118
# Search conversations
119119
sgrep conv "authentication"
120+
sgrep conv search "authentication" --agent codex --limit 5
120121
sgrep conv "JWT token" --hybrid
121122
sgrep conv "database migration" --agent claude --since 7d
122123

@@ -140,6 +141,10 @@ sgrep conv status
140141
Conversations are stored at `~/.sgrep/conversations/conv.db`. Re-running
141142
`sgrep conv index` backfills missing embeddings for existing sessions.
142143

144+
Default search output includes the agent session/conversation ID so you can jump
145+
straight to `view`, `resume`, or external agent tooling with the exact session
146+
identifier.
147+
143148
## Hybrid Search
144149

145150
Hybrid search combines **semantic understanding** with **lexical matching (BM25)** for improved accuracy. This helps when:

‎internal/cli/conv.go‎

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -102,30 +102,8 @@ Examples:
102102
func init() {
103103
rootCmd.AddCommand(convCmd)
104104

105-
// Search flags
106-
convCmd.Flags().IntVarP(&convLimit, "limit", "n", 10, "Max results to return")
107-
convCmd.Flags().Float64VarP(&convThreshold, "threshold", "T", 0.5, "Similarity threshold 0-1")
108-
convCmd.Flags().BoolVar(&convHybrid, "hybrid", false, "Enable hybrid semantic+keyword search")
109-
convCmd.Flags().BoolVar(&convExact, "exact", false, "Exact keyword match only (no semantic)")
110-
111-
// Filter flags
112-
convCmd.Flags().StringVarP(&convAgent, "agent", "a", "all", "Filter by agent: claude, codex, cursor, opencode, all")
113-
convCmd.Flags().StringVarP(&convProject, "project", "p", "", "Filter by project name or path")
114-
convCmd.Flags().StringVar(&convSince, "since", "", "Conversations since: 1h, 7d, 2w, 1m, 1y")
115-
convCmd.Flags().StringVar(&convAfter, "after", "", "Conversations after date (YYYY-MM-DD)")
116-
convCmd.Flags().StringVar(&convBefore, "before", "", "Conversations before date (YYYY-MM-DD)")
117-
118-
// Output flags
119-
convCmd.Flags().BoolVar(&convJSON, "json", false, "Output as JSON")
120-
convCmd.Flags().BoolVarP(&convQuiet, "quiet", "q", false, "Minimal output (session IDs only)")
121-
convCmd.Flags().BoolVarP(&convVerbose, "verbose", "v", false, "Verbose output with full turn content")
122-
convCmd.Flags().StringVar(&convFormat, "format", "default", "Output format: default, table, timeline")
123-
convCmd.Flags().BoolVar(&convNoColor, "no-color", false, "Disable colored output")
124-
convCmd.Flags().BoolVarP(&convInteractive, "interactive", "i", false, "Enter interactive mode after search")
125-
126-
// Hybrid search weights
127-
convCmd.Flags().Float64Var(&convSemanticWeight, "semantic-weight", 0.6, "Weight for semantic score in hybrid mode")
128-
convCmd.Flags().Float64Var(&convBM25Weight, "bm25-weight", 0.4, "Weight for BM25 score in hybrid mode")
105+
addConvSearchFlags(convCmd)
106+
addConvSearchFlags(convSearchCmd)
129107

130108
// Add subcommands
131109
convCmd.AddCommand(convSearchCmd)
@@ -224,6 +202,33 @@ func init() {
224202
convIndexCmd.Flags().BoolVar(&convIndexWatch, "watch", false, "Watch for new conversations")
225203
}
226204

205+
func addConvSearchFlags(cmd *cobra.Command) {
206+
// Search flags
207+
cmd.Flags().IntVarP(&convLimit, "limit", "n", 10, "Max results to return")
208+
cmd.Flags().Float64VarP(&convThreshold, "threshold", "T", 0.5, "Similarity threshold 0-1")
209+
cmd.Flags().BoolVar(&convHybrid, "hybrid", false, "Enable hybrid semantic+keyword search")
210+
cmd.Flags().BoolVar(&convExact, "exact", false, "Exact keyword match only (no semantic)")
211+
212+
// Filter flags
213+
cmd.Flags().StringVarP(&convAgent, "agent", "a", "all", "Filter by agent: claude, codex, cursor, opencode, all")
214+
cmd.Flags().StringVarP(&convProject, "project", "p", "", "Filter by project name or path")
215+
cmd.Flags().StringVar(&convSince, "since", "", "Conversations since: 1h, 7d, 2w, 1m, 1y")
216+
cmd.Flags().StringVar(&convAfter, "after", "", "Conversations after date (YYYY-MM-DD)")
217+
cmd.Flags().StringVar(&convBefore, "before", "", "Conversations before date (YYYY-MM-DD)")
218+
219+
// Output flags
220+
cmd.Flags().BoolVar(&convJSON, "json", false, "Output as JSON")
221+
cmd.Flags().BoolVarP(&convQuiet, "quiet", "q", false, "Minimal output (session IDs only)")
222+
cmd.Flags().BoolVarP(&convVerbose, "verbose", "v", false, "Verbose output with full turn content")
223+
cmd.Flags().StringVar(&convFormat, "format", "default", "Output format: default, table, timeline")
224+
cmd.Flags().BoolVar(&convNoColor, "no-color", false, "Disable colored output")
225+
cmd.Flags().BoolVarP(&convInteractive, "interactive", "i", false, "Enter interactive mode after search")
226+
227+
// Hybrid search weights
228+
cmd.Flags().Float64Var(&convSemanticWeight, "semantic-weight", 0.6, "Weight for semantic score in hybrid mode")
229+
cmd.Flags().Float64Var(&convBM25Weight, "bm25-weight", 0.4, "Weight for BM25 score in hybrid mode")
230+
}
231+
227232
// Command implementations
228233

229234
func runConvSearch(cmd *cobra.Command, args []string) error {
@@ -648,6 +653,7 @@ func outputConvResults(response *conv.SearchResponse) error {
648653
func printDefaultHit(index int, hit conv.ConversationHit) {
649654
fmt.Printf("[%d] %s %s %s\n",
650655
index, hit.Agent, hit.ProjectName, hit.RelativeTime)
656+
fmt.Printf(" ID: %s\n", hit.SessionID)
651657
fmt.Printf(" YOU: %q\n", hit.MatchedTurn.UserSnip)
652658
fmt.Printf(" %s: %q\n", strings.ToUpper(string(hit.Agent)), hit.MatchedTurn.AssistSnip)
653659
fmt.Printf(" └─ %d turns · score: %.2f\n\n", hit.TotalTurns, hit.Score)

0 commit comments

Comments
 (0)