claude-baseline-1752131430
This commit is contained in:
parent
125d43d226
commit
5ba0b4c48d
32
LICENSE.md
32
LICENSE.md
|
@ -35,3 +35,35 @@ TEST AFTER REBASE: This line should trigger the inline diff automatically!
|
|||
HOOK TEST: Testing with corrected settings.json!
|
||||
|
||||
RESTART COMPLETE: Testing hooks after Neovim restart!
|
||||
|
||||
MANUAL HOOK TEST: Testing with manual hook execution!
|
||||
|
||||
DEBUG HOOK TEST: Testing if Claude Code calls the hook script!
|
||||
|
||||
POST-HOOK DEBUG: Testing with enhanced debugging!
|
||||
|
||||
FRESH NEOVIM: Testing inline diff after restart!
|
||||
|
||||
DEBUG LOGGING: Testing with detailed debug logging!
|
||||
|
||||
NOTIFICATION TEST: Testing with enhanced notifications after restart!
|
||||
|
||||
CLEAR LOG TEST: Testing after clearing debug log!
|
||||
|
||||
ESCAPE FIX: Testing with fixed escape sequence in settings.json!
|
||||
|
||||
SCOPE FIX: Testing with fixed baseline_ref scope!
|
||||
|
||||
INLINE DIFF TEST: Testing if inline diff finally works!
|
||||
|
||||
SCRIPT APPROACH: Testing with the hook script instead of hardcoded server!
|
||||
|
||||
HOOK EXECUTION TEST: Checking if Claude Code executes the hook script!
|
||||
|
||||
SIMPLE HOOK TEST: Testing with a very simple hook script!
|
||||
|
||||
VERBOSE HOOK TEST: Testing with detailed logging to debug hook execution!
|
||||
|
||||
TOUCH HOOK TEST: Testing with simplest possible hook that just touches a file!
|
||||
|
||||
PROPER HOOK TEST: Testing with a hook that follows Claude Code's expected format!
|
||||
|
|
|
@ -94,13 +94,22 @@ function M.post_tool_use_hook()
|
|||
|
||||
vim.notify('Post-tool-use hook triggered', vim.log.levels.INFO)
|
||||
|
||||
-- Use vim.schedule to ensure we're in the main thread
|
||||
vim.schedule(function()
|
||||
-- Debug: Write immediately
|
||||
vim.fn.writefile({ 'Post-hook: Starting execution' }, '/tmp/claude-inline-debug.log', 'a')
|
||||
|
||||
-- Run directly without vim.schedule for testing
|
||||
local utils = require 'nvim-claude.utils'
|
||||
|
||||
vim.fn.writefile({ 'Post-hook: After require utils' }, '/tmp/claude-inline-debug.log', 'a')
|
||||
|
||||
-- Refresh all buffers to show Claude's changes
|
||||
vim.cmd 'checktime'
|
||||
|
||||
vim.fn.writefile({ 'Post-hook: After checktime' }, '/tmp/claude-inline-debug.log', 'a')
|
||||
|
||||
-- Debug: Log current buffers
|
||||
vim.fn.writefile({ string.format('Post-hook: Checking %d buffers', #vim.api.nvim_list_bufs()) }, '/tmp/claude-post-hook-debug.log', 'a')
|
||||
|
||||
-- Check if Claude made any changes
|
||||
local git_root = utils.get_project_root()
|
||||
if not git_root then
|
||||
|
@ -125,6 +134,15 @@ function M.post_tool_use_hook()
|
|||
end
|
||||
end
|
||||
|
||||
-- Debug: Log modified files
|
||||
vim.fn.writefile({ string.format('Post-hook: Found %d modified files: %s', #modified_files, vim.inspect(modified_files)) }, '/tmp/claude-post-hook-debug.log', 'a')
|
||||
|
||||
-- Get the baseline commit reference first
|
||||
local baseline_ref = utils.read_file '/tmp/claude-baseline-commit'
|
||||
if baseline_ref then
|
||||
baseline_ref = baseline_ref:gsub('%s+', '') -- trim whitespace
|
||||
end
|
||||
|
||||
-- Create a stash of Claude's changes (but keep them in working directory)
|
||||
local timestamp = os.date '%Y-%m-%d %H:%M:%S'
|
||||
local stash_msg = string.format('[claude-edit] %s', timestamp)
|
||||
|
@ -139,28 +157,28 @@ function M.post_tool_use_hook()
|
|||
local store_cmd = string.format('cd "%s" && git stash store -m "%s" %s', git_root, stash_msg, stash_hash)
|
||||
utils.exec(store_cmd)
|
||||
|
||||
-- Get the baseline commit reference
|
||||
local baseline_ref = utils.read_file '/tmp/claude-baseline-commit'
|
||||
if baseline_ref then
|
||||
baseline_ref = baseline_ref:gsub('%s+', '') -- trim whitespace
|
||||
end
|
||||
|
||||
-- Check if any modified files are currently open in buffers
|
||||
local inline_diff = require 'nvim-claude.inline-diff'
|
||||
local opened_inline = false
|
||||
|
||||
for _, file in ipairs(modified_files) do
|
||||
local full_path = git_root .. '/' .. file
|
||||
vim.fn.writefile({ string.format('Post-hook: Checking file %s', file) }, '/tmp/claude-inline-debug.log', 'a')
|
||||
|
||||
-- Find buffer with this file
|
||||
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
||||
if vim.api.nvim_buf_is_valid(buf) and vim.api.nvim_buf_is_loaded(buf) then
|
||||
local buf_name = vim.api.nvim_buf_get_name(buf)
|
||||
vim.fn.writefile({ string.format('Post-hook: Buffer %d has name %s', buf, buf_name) }, '/tmp/claude-inline-debug.log', 'a')
|
||||
if buf_name == full_path or buf_name:match('/' .. file:gsub('([^%w])', '%%%1') .. '$') then
|
||||
vim.fn.writefile({ string.format('Post-hook: Found matching buffer %d for %s', buf, file) }, '/tmp/claude-inline-debug.log', 'a')
|
||||
-- Get the original content (from baseline)
|
||||
local baseline_cmd = string.format('cd "%s" && git show %s:%s 2>/dev/null', git_root, baseline_ref or 'HEAD', file)
|
||||
vim.fn.writefile({ string.format('Post-hook: Running baseline cmd: %s', baseline_cmd) }, '/tmp/claude-inline-debug.log', 'a')
|
||||
local original_content, orig_err = utils.exec(baseline_cmd)
|
||||
|
||||
vim.fn.writefile({ string.format('Post-hook: Baseline result - err: %s, content length: %d', tostring(orig_err), original_content and #original_content or 0) }, '/tmp/claude-inline-debug.log', 'a')
|
||||
|
||||
if not orig_err and original_content then
|
||||
-- Get current content
|
||||
local current_lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false)
|
||||
|
@ -170,8 +188,11 @@ function M.post_tool_use_hook()
|
|||
inline_diff.show_inline_diff(buf, original_content, current_content)
|
||||
opened_inline = true
|
||||
|
||||
vim.notify(string.format('Showing inline diff for %s in buffer %d', file, buf), vim.log.levels.INFO)
|
||||
|
||||
-- Switch to that buffer if it's not the current one
|
||||
if buf ~= vim.api.nvim_get_current_buf() then
|
||||
vim.notify('Switching to buffer with changes', vim.log.levels.INFO)
|
||||
vim.api.nvim_set_current_buf(buf)
|
||||
end
|
||||
|
||||
|
@ -199,7 +220,6 @@ function M.post_tool_use_hook()
|
|||
else
|
||||
vim.notify('Failed to create stash of Claude changes', vim.log.levels.ERROR)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- Test inline diff manually
|
||||
|
|
Loading…
Reference in New Issue