claude-baseline-1752109170
This commit is contained in:
parent
3a9a4d0944
commit
2692bd2359
19
LICENSE.md
19
LICENSE.md
|
@ -18,13 +18,12 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
|
||||||
This line was added by Claude!
|
Testing auto-installed hooks and cumulative diff!
|
||||||
Testing hooks - this should trigger pre and post hooks!
|
First edit after restart - should create baseline!
|
||||||
Hooks are now properly installed!
|
|
||||||
Testing hook debug logging!
|
First edit with new cumulative system!
|
||||||
Another test edit to see the diff!
|
Second edit - hooks should work now!
|
||||||
Final test - hooks working perfectly!
|
Testing with verbose logging!
|
||||||
Testing cumulative diff system!
|
Testing basic hook execution!
|
||||||
Second edit - should show both changes!
|
Testing hooks after JSON fix!
|
||||||
Third edit - testing cumulative system!
|
First edit with working cumulative system!
|
||||||
Fourth edit - all changes should accumulate!
|
|
||||||
|
|
|
@ -6,14 +6,16 @@ M.pre_edit_commit = nil
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
vim.notify('Hooks module loaded', vim.log.levels.DEBUG)
|
vim.notify('Hooks module loaded', vim.log.levels.DEBUG)
|
||||||
|
|
||||||
|
-- Auto-cleanup old Claude commits on startup
|
||||||
|
vim.defer_fn(function()
|
||||||
|
M.cleanup_old_commits()
|
||||||
|
end, 200)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Pre-tool-use hook: Create baseline commit only if one doesn't exist
|
-- Pre-tool-use hook: Create baseline commit only if one doesn't exist
|
||||||
function M.pre_tool_use_hook()
|
function M.pre_tool_use_hook()
|
||||||
-- Debug log to file
|
vim.notify('Pre-hook called', vim.log.levels.INFO)
|
||||||
local log_file = io.open('/tmp/claude-hook-debug.log', 'a')
|
|
||||||
log_file:write(os.date() .. ' - Pre-hook called\n')
|
|
||||||
log_file:close()
|
|
||||||
|
|
||||||
local utils = require('nvim-claude.utils')
|
local utils = require('nvim-claude.utils')
|
||||||
|
|
||||||
|
@ -71,10 +73,7 @@ end
|
||||||
|
|
||||||
-- Post-tool-use hook: Create stash of Claude's changes and trigger diff review
|
-- Post-tool-use hook: Create stash of Claude's changes and trigger diff review
|
||||||
function M.post_tool_use_hook()
|
function M.post_tool_use_hook()
|
||||||
-- Debug log to file
|
vim.notify('Post-hook called', vim.log.levels.INFO)
|
||||||
local log_file = io.open('/tmp/claude-hook-debug.log', 'a')
|
|
||||||
log_file:write(os.date() .. ' - Post-hook called\n')
|
|
||||||
log_file:close()
|
|
||||||
|
|
||||||
vim.notify('Post-tool-use hook triggered', vim.log.levels.INFO)
|
vim.notify('Post-tool-use hook triggered', vim.log.levels.INFO)
|
||||||
|
|
||||||
|
@ -312,4 +311,51 @@ function M.setup_commands()
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Cleanup old Claude commits and temp files
|
||||||
|
function M.cleanup_old_commits()
|
||||||
|
local utils = require('nvim-claude.utils')
|
||||||
|
|
||||||
|
local git_root = utils.get_project_root()
|
||||||
|
if not git_root then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Clean up old temp files
|
||||||
|
local temp_files = {
|
||||||
|
'/tmp/claude-pre-edit-commit',
|
||||||
|
'/tmp/claude-baseline-commit',
|
||||||
|
'/tmp/claude-last-snapshot',
|
||||||
|
'/tmp/claude-hook-test.log'
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, file in ipairs(temp_files) do
|
||||||
|
if vim.fn.filereadable(file) == 1 then
|
||||||
|
vim.fn.delete(file)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Clean up old Claude commits (keep only the last 5)
|
||||||
|
local log_cmd = string.format('cd "%s" && git log --oneline --grep="claude-" --grep="claude-baseline" --grep="claude-pre-edit" --all --max-count=10', git_root)
|
||||||
|
local log_result = utils.exec(log_cmd)
|
||||||
|
|
||||||
|
if log_result and log_result ~= '' then
|
||||||
|
local commits = {}
|
||||||
|
for line in log_result:gmatch('[^\n]+') do
|
||||||
|
local hash = line:match('^(%w+)')
|
||||||
|
if hash then
|
||||||
|
table.insert(commits, hash)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Keep only the last 5 Claude commits, remove the rest
|
||||||
|
if #commits > 5 then
|
||||||
|
for i = 6, #commits do
|
||||||
|
local reset_cmd = string.format('cd "%s" && git rebase --onto %s^ %s', git_root, commits[i], commits[i])
|
||||||
|
utils.exec(reset_cmd)
|
||||||
|
end
|
||||||
|
vim.notify('Cleaned up old Claude commits', vim.log.levels.DEBUG)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
|
@ -109,6 +109,10 @@ end
|
||||||
function M.setup(user_config)
|
function M.setup(user_config)
|
||||||
M.config = merge_config(user_config)
|
M.config = merge_config(user_config)
|
||||||
|
|
||||||
|
-- Force reload modules to ensure latest code
|
||||||
|
package.loaded['nvim-claude.hooks'] = nil
|
||||||
|
package.loaded['nvim-claude.diff-review'] = nil
|
||||||
|
|
||||||
-- Load submodules
|
-- Load submodules
|
||||||
M.tmux = require('nvim-claude.tmux')
|
M.tmux = require('nvim-claude.tmux')
|
||||||
M.git = require('nvim-claude.git')
|
M.git = require('nvim-claude.git')
|
||||||
|
@ -129,6 +133,14 @@ function M.setup(user_config)
|
||||||
M.commands.setup(M)
|
M.commands.setup(M)
|
||||||
M.hooks.setup_commands()
|
M.hooks.setup_commands()
|
||||||
|
|
||||||
|
-- Auto-install hooks if we're in a git repository
|
||||||
|
vim.defer_fn(function()
|
||||||
|
if M.utils.get_project_root() then
|
||||||
|
M.hooks.install_hooks()
|
||||||
|
vim.notify('Claude Code hooks auto-installed', vim.log.levels.INFO)
|
||||||
|
end
|
||||||
|
end, 100)
|
||||||
|
|
||||||
-- Set up keymappings if enabled
|
-- Set up keymappings if enabled
|
||||||
if M.config.mappings then
|
if M.config.mappings then
|
||||||
require('nvim-claude.mappings').setup(M.config.mappings, M.commands)
|
require('nvim-claude.mappings').setup(M.config.mappings, M.commands)
|
||||||
|
|
Loading…
Reference in New Issue