Thank you for considering contributing! This document provides guidelines and information to help you get started contributing to the project.
CodeCompanion History is an extension for codecompanion.nvim that provides persistent chat history functionality. It hooks into CodeCompanion's events to automatically save chat sessions and allows users to browse and restore them.
The extension handles:
- Automatic saving of chat sessions
- Title generation for chats
- State preservation (messages, tools, references)
- History browsing via Telescope or default UI
- Neovim 0.8.0+
- lua-language-server
- stylua
- plenary.nvim
- telescope.nvim (optional, for enhanced UI)
- codecompanion.nvim
- Fork and clone the repository:
git clone https://github.com/ravitemer/codecompanion-history.nvim
cd codecompanion-history.nvim- Add repo to your runtime
vim.opt.runtimepath:prepend(os.getenv("HOME") .. "path/to/codecompanion-history.nvim")- Configure for development:
local codecompanion = require("codecompanion")
codecompanion.setup({
extensions = {
history = {
enabled = true,
opts = {
file_path = vim.fn.expand("~/cc_history_dev.json"), -- Different path for development
auto_generate_title = true,
default_buf_title = "[CC-Dev]",
keymap = "gh",
picker = "telescope",
}
}
}
})lua/codecompanion/_extensions/history/- Main extension codeinit.lua- Extension entry point and setupstorage.lua- Chat state persistencetitle_generator.lua- Smart title generationui.lua- History browser interfacepickers/- UI implementationstypes.lua- Type definitionsutils.lua- Shared utilities
- See the above Development Environment Setup for details
- Follow existing code patterns
- Update relevant documentation
- Add tests for new functionality
- Run
make formatto format code using stylua - Run
make docsto generate documentation
- Use stylua for code formatting
- Configuration is in
stylua.toml - Run
make formatbefore submitting PRs - Follow existing code patterns and naming conventions
Documentation is built using panvimdoc:
make docs # Generate plugin documentationThe extension uses Mini.Test:
make test # Run all tests
make test_file FILE=path/to/test_file.lua # Run specific test fileWhen adding new features:
- Add tests in
tests/ - Test chat state restoration
- Ensure proper error handling
- Update documentation if behavior changes
- Add tests for new features
- Format code:
make format - Generate docs:
make docs - Include:
- Clear description
- Related issue references
- Screenshots/gifs if UI changes
- Log examples if relevant
- Check creating extensions guide
- Open an issue with detailed description
- Search existing issues/PRs first
- Provide error logs and steps to reproduce
By contributing, you agree that your contributions will be licensed under the MIT License.