-
Notifications
You must be signed in to change notification settings - Fork 72
Add search, continue commands and Nix packaging #459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bf56b1b to
46a9a34
Compare
f5293c4 to
bd33c43
Compare
Implement two new commands for querying and restoring AI prompt history: - `git-ai search` finds AI sessions by commit, file/line range, text pattern, or prompt ID with five output formats (default, JSON, verbose, porcelain, count) and filters for tool, author, and time range. - `git-ai continue` restores conversation context from prompt history and delivers it via agent launch (using Unix exec() for proper terminal passthrough), clipboard, JSON, or stdout with secret redaction and message truncation. Also adds format_transcript() utility for rendering PromptRecord messages as labeled text, and comprehensive integration tests for both commands. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Register the git-ai-search skill alongside the existing prompt-analysis skill so it deploys automatically when git-ai installs into Claude Code environments. The SKILL.md provides workflow-oriented documentation with decision tables, seven usage patterns, command references, and integration examples for CI/CD and shell scripting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When launching an agent with `git ai continue --launch`, the agent now starts silently by default. Pass `--summary` to have the agent produce a brief overview of what was being worked on, what was accomplished, and what remains before prompting for input. Also refactors launch_agent() to build the command incrementally, keeping the unix exec() and non-unix subprocess paths in sync. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Enhance the continue command to provide comprehensive context when restoring AI sessions. Previously, only conversation history and basic commit metadata were included; the restored agent lacked the broader repository context needed to continue work effectively. Add helper functions to retrieve commit diffs (get_commit_diff), project instructions from CLAUDE.md (read_project_context), and current git status (get_git_status_info). Introduce SessionContext struct and gather_session_context to centralize context collection, replacing scattered inline logic in both CLI and TUI code paths. The restored session now includes: full commit messages (not just subject lines), commit diffs with stat and patch output, CLAUDE.md project instructions, and current branch/recent commit status. All context is size-limited (100KB diffs, 50KB CLAUDE.md) and secrets are redacted before output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bd33c43 to
ec67904
Compare
Use floor_char_boundary() before slicing strings at byte offsets in get_commit_diff() and read_project_context(). Without this, truncating at MAX_DIFF_BYTES or MAX_CONTEXT_BYTES could land in the middle of a multi-byte UTF-8 character, causing a panic when processing diffs or project files containing non-ASCII content. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve all clippy lints found during PR review:
- Collapse nested if statements using let-chains (Rust 2024)
- Remove unnecessary return statement in exec() error path
- Use push('\n') instead of push_str("\n")
- Use replace(['\t', '\n'], " ") instead of chained replace()
- Use RangeInclusive::contains for date validation
- Use struct initialization with ..Default::default()
- Rename SearchMode variants to drop redundant By prefix
- Remove unused merge_results function
- Warn when using unimplemented --since/--until filters
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address PR git-ai-project#459 review comments: 1. continue_session.rs: --json flag now prevents auto-launch to agent. Previously, running `git-ai continue --commit X --json` in an interactive terminal would pass JSON to launch_agent() instead of printing to stdout, breaking scripting/pipeline use. 2. search.rs: Fix byte-length vs char-count mismatch in ellipsis logic. The snippet uses chars().take(80) but the ellipsis check used text.len() (byte length), causing spurious "..." on multi-byte text. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Remove duplicate `let (messages_to_show, omitted) =` that caused a
parse error ("expected expression, found let statement") on all CI
platforms. Also iterate with `&messages_to_show` so pattern-matched
`text` fields bind as `&String` (auto-deref to `&str`), fixing the
type mismatch errors on push_str calls.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass ContinueOptions through to handle_continue_tui so that flags like --summary, --max-messages, --clipboard, and --json are respected when the user enters interactive mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Five tests in opencode.rs race on the GIT_AI_OPENCODE_STORAGE_PATH environment variable when run in parallel, causing intermittent CI failures. Add #[serial_test::serial] to serialize them, matching the pattern already used in github_copilot.rs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The --max-messages flag was silently ignored in JSON output mode. Extract message filtering and truncation outside the json! macro so both text and JSON formats respect the same limit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The --workdir flag was silently accepted but never applied to search results. Add a warning message matching the pattern used by --since and --until so users know the filter is currently a no-op. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle_continue_tui was unconditionally using format_context_block, ignoring the options.json flag. Now checks options.json to select between format_context_json and format_context_block, matching the non-interactive code path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When --file was specified a second time, the parser cloned line_ranges from the previous file into the new one. A new --file should always start with empty line_ranges. Fixed in both search and continue argument parsers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
flake.nixwith NixOS and Home Manager modules, comprehensive settings options (includePromptsInRepositories,defaultPromptStorage), and documentationgit-ai searchcommand: Search AI prompt sessions by commit, commit range, file (with line ranges), pattern, or prompt ID — with JSON, verbose, and summary output modesgit-ai continuecommand: Restore AI session context from search results, with launch (spawns Claude Code), clipboard, and interactive TUI session selection modesgit-ai-searchskill: Claude Code skill for AI context discovery using the new search/continue commandsTest plan
cargo testpasses for existing and new integration testsgit-ai search --commit <sha>returns prompt metadata for a known commitgit-ai search --file <path> --lines <range>filters correctlygit-ai continue --commit <sha>outputs formatted context blocksgit-ai continue --commit <sha> --launchspawns Claude Code with contextnix buildproduces a workinggit-aibinary🤖 Generated with Claude Code