-
Notifications
You must be signed in to change notification settings - Fork 25
Add Claude Code hooks and watch daemon #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add `codemap hook <name>` subcommand for Claude Code integration - Implement 6 hooks: session-start, pre-edit, post-edit, prompt-submit, pre-compact, session-stop - Rewrite FileGraph to use ast-grep for multi-language import extraction - Replace language-specific switch with universal fuzzy matcher - Add suffix-based matching for nested packages (e.g., app.core.config -> */app/core/config.py) - Update YAML rules to capture import paths via meta-variables 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add `codemap watch start/stop/status` subcommands - Add Stop() function to send SIGTERM to daemon - Write initial state on daemon start for immediate hook access - Remove redundant hooks/ shell scripts (replaced by cmd/hooks.go) - Remove cmd/hub-check/ (consolidated into hooks) The watch daemon now: - Starts via `codemap watch start` (forks background process) - Writes state.json immediately on start - Tracks file events with line deltas and hub detection - Can be queried via `codemap watch status` - Cleanly stops via `codemap watch stop` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Ignore .codemap/ directory (runtime state, events, pid files) - Ignore test binaries: codemap-test, mcp-test, hub-check - Ignore .claude/settings.local.json 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add cmd/hooks_test.go with tests for hub detection, JSON parsing, output formatting, and file mention regex patterns - Add tsx/jsx to file extension detection in prompt-submit hook - Fix empty header output when no files have importers - Document hooks as recommended Claude integration in README 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- Add platform-specific daemon_unix.go and daemon_windows.go for Setpgid handling (Unix-only syscall) - Fix gofmt issues in watch/watch.go and mcp/main.go 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When a new directory is created after the daemon starts, the daemon now adds it to the watcher so files created inside are tracked. Fixes: directory CREATE events were filtered out by isSourceFile check 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Break up the ~680 line watch.go into four single-responsibility files: - types.go: Event, FileState, DepContext, Graph, State structs - daemon.go: Daemon struct and lifecycle (NewDaemon, Start, Stop) - events.go: event loop, handling, logging, and delta calculations - state.go: PID management, state persistence, daemon control No functional changes - all tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
This PR adds a comprehensive Claude Code integration through hooks and a background watch daemon:
Claude Code Hooks (
cmd/hooks.go,HOOKS.md) - Automatic context injection at every step of a Claude Code session:session-start: Shows project structure and hub filespre-edit/post-edit: Warns when editing high-impact filesprompt-submit: Detects file mentions and shows dependency contextpre-compact: Saves hub state before context compactionsession-stop: Summarizes session changes and stops daemonWatch Daemon (
watch/watch.go) - Background file watcher that tracks:.codemap/state.jsonFileGraph (
scanner/filegraph.go) - Import/dependency analysis:MCP Server enhancements - New tools for live watching and file context
Tests - Added
cmd/hooks_test.goandwatch/watch_test.goTest plan
go test ./...passescodemap hook session-start🤖 Generated with Claude Code