Skip to content

Conversation

@brojonat
Copy link

@brojonat brojonat commented Nov 15, 2025

This feature allows users to run configurable shell commands before and after every LLM query. It is similar to the existing shell command functionality, but runs an arbitrary number of commands automatically. I'm not sure this is necessarily a "good" change to the API, but it's something I'm experimenting with.

Key features:

  • Pre-hooks execute before LLM queries
  • Stdout automatically captured to temp files when add_to_context = true
  • Temp files automatically added to context (only when stdout is not empty)
  • Post-hooks execute after LLM response completes
  • Automatic cleanup of temp files (no manual file management needed)
  • Support for multiple pre-hooks and post-hooks

Example use case: Integrate github.com/brojonat/context-vacuum for dynamic project context generation without manual file creation/deletion.

brojonat and others added 4 commits November 15, 2025 14:49
This feature allows users to run configurable shell commands before and after
LLM queries, enabling dynamic context generation workflows.

Key features:
- Pre-hooks execute before LLM queries
- Stdout automatically captured to temp files when add_to_context = true
- Temp files automatically added to context
- Post-hooks execute after LLM response completes
- Automatic cleanup of temp files (no manual file management)
- Support for multiple pre-hooks and post-hooks

Example use case: Integrate context-vacuum for dynamic project context
generation without manual file creation/deletion.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Clarify automatic temp file management with vim.fn.tempname()
- Emphasize zero manual file path management
- Add debugging section with :Lazy sync reminder
- Update examples to use realistic commands and modern model names
- Add installation instructions for the pre-hook branch
- Remove outdated/unimplemented advanced patterns
- Simplify examples based on real-world usage

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
The implementation is simple enough that the example config and
inline comments are sufficient. No need for extensive markdown docs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Pre-hooks and post-hooks are simple enough that an example config
file is unnecessary. Users can see the schema in the type definitions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@brojonat brojonat changed the title Add pre-hook and post-hook support for dynamic context generation Add pre-hook and post-hook support Nov 16, 2025
@mozanunal
Copy link
Owner

Sounds like a super interesting addition, lmk it is ready for a review

Only create temp files and add to context when pre-hook stdout
has non-whitespace content. Prevents empty files from cluttering
the context when hooks produce no output.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@brojonat brojonat marked this pull request as ready for review November 16, 2025 23:14
@brojonat
Copy link
Author

@mozanunal this is ready for review and I've updated the README since this is an addition to the existing config interface. This has been somewhat useful for me. No pressure though; I totally understand if you'd rather not grow the API like this.

Copy link
Owner

@mozanunal mozanunal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for contributing to the sllm.nvim tool. This looks good, only concern is the implementation, I think we can do it similarly how we are adding the command outputs to the context (or any other ones except the file (fragment) additions). The issue is the tempfiles, we don't need them. Please raise if you have any concerns. If you have the availability, please go ahead with the changes otherwise I can takeover the PR. I really like the idea ⭐

@mozanunal
Copy link
Owner

I have enabled the CI runs, please check the CI error as well!

@mozanunal
Copy link
Owner

Now I have sometime to work on the changes I described, let me do that @brojonat

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.

2 participants