claude-baseline-1752109170

pull/1635/head
zolinthecow 2 days ago
parent 3a9a4d0944
commit 2692bd2359

@ -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
SOFTWARE.
This line was added by Claude!
Testing hooks - this should trigger pre and post hooks!
Hooks are now properly installed!
Testing hook debug logging!
Another test edit to see the diff!
Final test - hooks working perfectly!
Testing cumulative diff system!
Second edit - should show both changes!
Third edit - testing cumulative system!
Fourth edit - all changes should accumulate!
Testing auto-installed hooks and cumulative diff!
First edit after restart - should create baseline!
First edit with new cumulative system!
Second edit - hooks should work now!
Testing with verbose logging!
Testing basic hook execution!
Testing hooks after JSON fix!
First edit with working cumulative system!

@ -6,14 +6,16 @@ M.pre_edit_commit = nil
function M.setup()
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
-- Pre-tool-use hook: Create baseline commit only if one doesn't exist
function M.pre_tool_use_hook()
-- Debug log to file
local log_file = io.open('/tmp/claude-hook-debug.log', 'a')
log_file:write(os.date() .. ' - Pre-hook called\n')
log_file:close()
vim.notify('Pre-hook called', vim.log.levels.INFO)
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
function M.post_tool_use_hook()
-- Debug log to file
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-hook called', vim.log.levels.INFO)
vim.notify('Post-tool-use hook triggered', vim.log.levels.INFO)
@ -312,4 +311,51 @@ function M.setup_commands()
})
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

@ -109,6 +109,10 @@ end
function M.setup(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
M.tmux = require('nvim-claude.tmux')
M.git = require('nvim-claude.git')
@ -129,6 +133,14 @@ function M.setup(user_config)
M.commands.setup(M)
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
if M.config.mappings then
require('nvim-claude.mappings').setup(M.config.mappings, M.commands)

Loading…
Cancel
Save