feat(database): add git worktree support #199

Merged
jack merged 4 commits from feat/180-git-worktree-support into main 2026-01-24 17:20:38 +00:00
Owner

Summary

  • Implements Issue #180 - Git Worktree Support for consistent project identification across git worktrees
  • Adds git-utils module with getRepoInfo() for detecting worktrees and canonical repo paths
  • Extends Session and Observation entities with repo_path, is_worktree, and branch fields
  • Updates hooks handlers to detect and pass git repository information on session start

Changes

  • packages/shared: New git-utils.ts module with worktree detection
  • packages/types: Extended SdkSessionRecord and ObservationRecord types
  • packages/database:
    • Migration for new columns
    • Updated entities and repository
  • packages/hooks: Updated session-start and user-prompt-submit handlers
  • packages/backend: Updated routes to accept worktree parameters

Test plan

  • Start a session in a git worktree directory
  • Verify repo_path is set to the canonical repository path
  • Verify is_worktree is true for worktree directories
  • Verify sessions from different worktrees of the same repo are grouped together
  • Start a session in a non-worktree git repo
  • Verify is_worktree is false
  • Start a session in a non-git directory
  • Verify fields remain null/undefined

Closes #180

🤖 Generated with Claude Code

## Summary - Implements Issue #180 - Git Worktree Support for consistent project identification across git worktrees - Adds `git-utils` module with `getRepoInfo()` for detecting worktrees and canonical repo paths - Extends Session and Observation entities with `repo_path`, `is_worktree`, and `branch` fields - Updates hooks handlers to detect and pass git repository information on session start ## Changes - **packages/shared**: New `git-utils.ts` module with worktree detection - **packages/types**: Extended `SdkSessionRecord` and `ObservationRecord` types - **packages/database**: - Migration for new columns - Updated entities and repository - **packages/hooks**: Updated session-start and user-prompt-submit handlers - **packages/backend**: Updated routes to accept worktree parameters ## Test plan - [ ] Start a session in a git worktree directory - [ ] Verify `repo_path` is set to the canonical repository path - [ ] Verify `is_worktree` is true for worktree directories - [ ] Verify sessions from different worktrees of the same repo are grouped together - [ ] Start a session in a non-worktree git repo - [ ] Verify `is_worktree` is false - [ ] Start a session in a non-git directory - [ ] Verify fields remain null/undefined Closes #180 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(database): add git worktree support
Some checks failed
CI / build (pull_request) Failing after 31s
d172d76bd8
Implements Issue #180 - Git Worktree Support for consistent project identification
across git worktrees.

- Add git-utils module with getRepoInfo() for worktree detection
- Add repo_path, is_worktree, branch fields to Session entity
- Add repo_path field to Observation entity for tracking
- Add migration for new database columns
- Update SessionRepository to handle new fields
- Update hooks handlers to pass repo info on session start
- Update backend routes to accept worktree parameters

This allows sessions and observations from different git worktrees
to be properly grouped under the same canonical repository.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
fix(hooks): fix type error in context query params
All checks were successful
CI / build (pull_request) Successful in 38s
0450ad72fa
Build query params object conditionally to avoid passing undefined
values where strings are expected.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Merge branch 'main' into feat/180-git-worktree-support
All checks were successful
CI / build (pull_request) Successful in 54s
0ed4b7b130
Merge branch 'main' into feat/180-git-worktree-support
All checks were successful
CI / build (pull_request) Successful in 40s
6c3608ffb2
jack merged commit 5f0b500404 into main 2026-01-24 17:20:38 +00:00
Sign in to join this conversation.
No description provided.