Skip to content

Conversation

@JordanCoin
Copy link
Owner

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 files
    • pre-edit / post-edit: Warns when editing high-impact files
    • prompt-submit: Detects file mentions and shows dependency context
    • pre-compact: Saves hub state before context compaction
    • session-stop: Summarizes session changes and stops daemon
  • Watch Daemon (watch/watch.go) - Background file watcher that tracks:

    • Real-time file changes with timestamps and line deltas
    • Hub files (imported by 3+ files)
    • Edit timeline for session summaries
    • Persists state to .codemap/state.json
  • FileGraph (scanner/filegraph.go) - Import/dependency analysis:

    • Builds graph of internal imports between files
    • Identifies hub files and their dependents
    • Supports universal import resolution across languages
  • MCP Server enhancements - New tools for live watching and file context

  • Tests - Added cmd/hooks_test.go and watch/watch_test.go

Test plan

  • go test ./... passes
  • Hooks fire correctly in live Claude Code session
  • Watch daemon starts/stops cleanly
  • Hub detection works across Go, Python, TypeScript
  • Test on fresh clone with codemap hook session-start

🤖 Generated with Claude Code

JordanCoin and others added 4 commits December 6, 2025 18:26
- 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>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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".

JordanCoin and others added 3 commits December 6, 2025 22:18
- 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>
@JordanCoin JordanCoin merged commit 2d3077a into main Dec 7, 2025
12 checks passed
@JordanCoin JordanCoin deleted the watch-experiment branch December 7, 2025 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants