Skip to content

feat(search): add --git-branch, --model, --since, --until filter flags to query and MCP search_sessions - #51

Open
Adityakk9031 wants to merge 4 commits into
skillsynchq:mainfrom
Adityakk9031:feat/search-multi-criteria-filtering
Open

Adityakk9031 wants to merge 4 commits into
skillsynchq:mainfrom
Adityakk9031:feat/search-multi-criteria-filtering

Conversation

@Adityakk9031

@Adityakk9031 Adityakk9031 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Right now xcript query only lets you filter by harness and working directory. When working across multiple git branches or testing different models, searching turns up a lot of irrelevant matches.

This PR adds four new filter flags to narrow down sessions before scoring starts:

  • --git-branch : exact match against the recorded git branch
  • --model : case-insensitive substring match on model name (e.g. --model claude matches claude-3-5-sonnet)
  • --since / --until : filter sessions by creation timestamp. Accepts RFC3339 timestamps or bare dates like 2025-06-01 (matching list behavior)

The same filters are also exposed on the MCP search_sessions tool (git_branch, model, since, until).

Examples

\\sh

Search for 'relay bug' specifically on the feature branch

txcript query 'relay bug' --git-branch relay-protocol-v6

Search sessions using Claude from the past week

txcript query --model claude --since 2025-06-10 --until 2025-06-17

Scope by repo directory and branch

txcript query --cwd ~/projects/myapp --git-branch main
\\

Summary of changes:

  • src/search.rs: Added cwd, git_branch, model, since, and until to Query. Doc::selected() evaluates the new filters, using path_under() for path prefix matching.
  • cli/src/lib.rs: Added arguments to SessionCommand::Query and passed them down to �uild_index(), filtering sessions prior to indexing.
  • cli/src/mcp.rs: Added fields to SearchSessionsRequest and parsed date inputs with parse_since / parse_until.
  • docs/usage.md: Documented the new CLI flags and MCP parameters.
  • ests/integration/search.rs: Added integration tests covering branch matching, case-insensitive model matching, timestamp range boundaries, and cwd prefix logic.

…sions

Add --git-branch, --model, --since, and --until filter flags to the
CLI 'query' subcommand and to the MCP 'search_sessions' tool, mirroring
the existing --cwd filter and the 'list' command's --since/--until.

Library changes (src/search.rs):
- Add cwd, git_branch, model, since, until fields to Query struct
- Doc::selected() evaluates all five meta-filters; path_under() helper
  for component-wise prefix matching of cwd

CLI changes (cli/src/lib.rs):
- SessionCommand::Query gains --git-branch, --model, --since, --until args
- cmd_query and build_index accept and thread the new params through;
  build_index applies all filters at session-discovery time

MCP changes (cli/src/mcp.rs):
- SearchSessionsRequest gains git_branch, model, since, until fields
- search_sessions parses since/until via parse_since/parse_until helpers
  and passes all five new params into index_for; tool description updated

Tests (tests/integration/search.rs):
- query_filter_git_branch_exact_match: exact-match filter and no-match case
- query_filter_model_case_insensitive_substring: case-folded substring filter
- query_filter_since_and_until: timestamp lower/upper bounds and intersection
- query_filter_cwd_path_prefix: parent-dir matches both, child-dir matches one

Docs (docs/usage.md): document new flags for both CLI and MCP.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant