Skip to content

feat(core): use git remote origin for shared team collection naming#373

Open
triadmoko wants to merge 2 commits into
zilliztech:masterfrom
triadmoko:feat/git-remote-shared-collection
Open

feat(core): use git remote origin for shared team collection naming#373
triadmoko wants to merge 2 commits into
zilliztech:masterfrom
triadmoko:feat/git-remote-shared-collection

Conversation

@triadmoko

Copy link
Copy Markdown

Summary

Closes #271

All developers who clone the same repository now automatically share one Milvus collection, regardless of their local checkout path. No extra configuration is needed — the feature is on by default.

How it works:

The collection name resolution now follows this priority order (steps 1–2 unchanged):

  1. ContextConfig.collectionNameOverride (constructor argument)
  2. CODE_CHUNKS_COLLECTION_NAME_OVERRIDE env var
  3. [NEW] git remote origin URL hash → enables team sharing
  4. local absolute-path hash (original fallback when not a git repo)

URL normalisation ensures SSH and HTTPS variants of the same repo resolve to the same hash:

Remote URL Normalised Collection name
https://github.com/org/repo.git github.com/org/repo code_chunks_git_<hash>
git@github.com:org/repo.git github.com/org/repo code_chunks_git_<hash> (same)
ssh://git@github.com/org/repo.git github.com/org/repo code_chunks_git_<hash> (same)

New env var: CLAUDE_CONTEXT_GIT_REMOTE_COLLECTION (default: true)
Set to false to opt out and restore path-hash behaviour.

Changes

  • packages/core/src/context.tsgetCollectionName() extended with git-remote fallback; added isGitRemoteCollectionEnabled(), getGitRemoteUrl() (with per-instance cache), and normalizeGitRemoteUrl() helpers
  • packages/core/src/context.git-remote.test.ts — 12 new unit tests covering: remote detection, fallback to path hash, opt-out env var, override precedence, caching, and URL normalisation for 6 remote formats
  • packages/mcp/src/config.ts — new env var documented in help text and startup log

Test plan

  • All 31 existing + new tests pass (pnpm test in packages/core)
  • pnpm build succeeds in packages/core
  • SSH and HTTPS variants produce identical collection name
  • Non-git directories fall back to path hash silently
  • CLAUDE_CONTEXT_GIT_REMOTE_COLLECTION=false restores original behaviour
  • CODE_CHUNKS_COLLECTION_NAME_OVERRIDE still takes full precedence

🤖 Generated with Claude Code

triadmoko added 2 commits May 6, 2026 23:56
All developers who clone the same repository now share one Milvus
collection automatically, regardless of their local checkout path.
SSH and HTTPS variants of the same remote URL are normalised to the
same hash before collection name resolution.

Resolution priority (unchanged for steps 1-2):
  1. ContextConfig.collectionNameOverride (constructor)
  2. CODE_CHUNKS_COLLECTION_NAME_OVERRIDE env var
  3. git remote origin URL hash [NEW] — enables team sharing
  4. local absolute-path hash (original fallback)

New env var CLAUDE_CONTEXT_GIT_REMOTE_COLLECTION (default: true)
lets users opt out and restore path-hash behaviour.

URL normalisation strips .git suffix, lowercases, and collapses
SSH (git@host:org/repo) and HTTPS (https://host/org/repo) variants
to the canonical form host/org/repo before hashing.

Closes zilliztech#271
…ication

Added the getCanonicalKey method to the Context class, which returns a normalized remote URL for git repositories or the absolute path for non-git directories. This ensures consistent identification of codebases across different environments. Updated related components to utilize the canonical key for indexing and syncing, enhancing team collaboration by sharing the same identifiers regardless of local paths.

Also, modified snapshot management to support canonical keys, improving the handling of indexed codebases.

Closes zilliztech#271
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.

Support shared indexes across machines via git-remote-based collection naming

1 participant