feat: search improvements and tool_use indexing#2
Merged
Conversation
Split multi-word queries into individual terms and require all terms to appear somewhere across the session's messages. Single-term queries retain exact substring matching. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Show [u]/[a] prefix in table output and structured role field in JSON to distinguish user vs assistant messages in search matches. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add -s/--session flag to `cct search` to scope search to a single session, eliminating the need for `cct export <id> | grep`. Fix a bug where sub-agent files (agent-*.jsonl) had their file-derived ID overwritten by the parent session's `sessionId` field from the JSONL content. This caused FindByPrefix to see multiple "different" sessions with the same ID (e.g. the parent file + 2 sub-agent files all claiming to be c8035fd7), returning ErrMultipleMatches and blocking --session, info, export, and resume for any session that had sub-agents. Root cause: extractUserMetadata (parse.go) unconditionally replaced s.ID with the `sessionId` value from the first user message. For regular sessions this was redundant (sessionId == filename). For sub-agent files, `sessionId` pointed to the parent session, causing identity collision. Verified across 501 non-agent files that sessionId always matches the filename, confirming the override was never needed. Fix: remove the sessionId override entirely. The file-derived ID (from the .jsonl filename) is always the correct, unique identifier. This resolved 313 duplicate ID collisions across 2847 sessions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Exclude agent-*.jsonl files from list and stats by default (--agents to include). Keep agents in search by default (--no-agents to exclude) and tag them with "(agent)" in the PROJECT column. Fix ShortID for agent files: return the full 14-char ID instead of truncating to 8 chars, which caused collisions (only 256 possible values for 2157 agent files). Skip agent sessions in resume hints. Add IsAgentSession helper and IsAgent field to Session struct. Widen SESSION column from 10 to 16 chars to fit agent IDs. Also clean up 7 redundant comments across 4 files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Search tool_use blocks: extract tool name and string input values (file paths, commands, patterns, URLs) so they are searchable. Matches show source labels like [a:Read] and [a:Bash]. - Add -C/--context flag to search for wider snippet context. - Add Match.Source field to attribute matches to specific tools. - Extract parallelMap generic helper, deduplicating ScanFiles and SearchFiles worker pool boilerplate. - Extract printResumeHints helper, deduplicating list.go and search.go. - Simplify FindByPrefixFull to return full parse directly. - Simplify exportJSON encoder setup to create writer first. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cct search "Read search.go"matches sessions containing all terms[u]/[a]prefixes to distinguish user vs assistant matches--sessionflag: scope search to a single session with-s <id>--no-agentsexcludes agent sessions from search;--agentsincludes them in list/stats; ShortID preserves full agent IDs to avoid collisions[a:Read],[a:Bash]-Ccontext flag:cct search "query" -C 200adds extra characters to snippet width for more surrounding contextparallelMapdeduplicates worker pool boilerplate;printResumeHintsdeduplicates hint loops;FindByPrefixFullsimplified;exportJSONencoder setup cleaned upTest plan
go test ./...— all passgo vet ./...— clean-Cflag with default, 0, 100, 500 values[a:Read],[a:Bash],[a:ToolSearch]source labels in output--no-agents,--session,--jsonflags🤖 Generated with Claude Code