Skip to content

feat(cli): share codebase indexes across worktrees - #11182

Merged
marius-kilocode merged 8 commits into
mainfrom
skinny-poetry
Jun 17, 2026
Merged

feat(cli): share codebase indexes across worktrees#11182
marius-kilocode merged 8 commits into
mainfrom
skinny-poetry

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

Codebase indexing was disabled in Agent Manager worktrees because independently indexing every checkout duplicated embeddings and vector storage. Worktree sessions therefore could not use semantic search, even when the primary checkout already had a complete compatible index.

This change treats the primary checkout index as a shared baseline and keeps a small per-worktree overlay for modified, added, deleted, or ignored files. Worktree searches embed the query once, query the baseline and overlay together, mask stale baseline paths, and merge only results valid for the current checkout. Sibling worktree overlays remain physically separate and are never queried together.

Indexing workers are shared process-wide and native store initialization is serialized, avoiding Bun crashes when Agent Manager initializes several LanceDB-backed worktrees concurrently. Semantic search registration now follows the effective indexing configuration rather than index completion timing, so new Agent Manager sessions receive the tool while their worktree overlay initializes.

Comment thread packages/opencode/src/kilocode/indexing-worker.ts Outdated
Comment thread packages/kilo-indexing/src/indexing/manager.ts Outdated
Comment thread packages/kilo-indexing/src/indexing/manager.ts Outdated
Comment thread packages/kilo-indexing/src/indexing/search-service.ts
@kilo-code-bot

kilo-code-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 8 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 4
SUGGESTION 4
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/kilocode/indexing-worker.ts initQueue grows unbounded and is never reset
packages/kilo-indexing/src/indexing/manager.ts _disposed check is missing after async gap in refreshBaseline
packages/kilo-indexing/src/indexing/worktree-overlay.ts Redundant + weak chunk verification when both files have matching hashes
packages/opencode/src/kilocode/indexing-worker.ts Init lock is too coarse — serializes everything, not just init

SUGGESTION

File Line Issue
packages/kilo-indexing/src/indexing/search-service.ts 48 overlay.ready throws before reconciliation completes; visible to user
packages/kilo-indexing/src/indexing/manager.ts 457 Baseline cache reloaded on every search (refreshBaseline on each call)
packages/kilo-indexing/src/indexing/manager.ts openExisting()/close() intent unclear
packages/opencode/src/kilocode/indexing-worker-client.ts 198 Hosts map grows monotonically — never cleaned after per-host downloads
Incremental Review Notes (commit 019270e → HEAD)

Changes since the previous review commit are housekeeping:

  • packages/sdk/js/src/gen/openapi.json — auto-generated SDK schema regeneration
  • packages/ui/src/components/markdown.tsxkilocode_change marker added for import split
  • script/check-opencode-promise-facades.ts — ratchet config updates (count adjustments, new test entries)
  • script/upstream/utils/config.ts — upstream merge ignore list additions

No new issues found. All 8 previous issues remain open on unchanged files.

Files Reviewed (35 files — unchanged from previous review)
  • .changeset/share-worktree-indexes.md
  • packages/kilo-indexing/src/file/ignore.ts
  • packages/kilo-indexing/src/indexing/cache-manager.ts
  • packages/kilo-indexing/src/indexing/interfaces/file-processor.ts
  • packages/kilo-indexing/src/indexing/interfaces/manager.ts
  • packages/kilo-indexing/src/indexing/interfaces/vector-store.ts
  • packages/kilo-indexing/src/indexing/manager.ts — 2 warnings + 1 suggestion
  • packages/kilo-indexing/src/indexing/orchestrator.ts
  • packages/kilo-indexing/src/indexing/processors/file-watcher.ts
  • packages/kilo-indexing/src/indexing/processors/scanner.ts
  • packages/kilo-indexing/src/indexing/search-service.ts — 1 suggestion
  • packages/kilo-indexing/src/indexing/service-factory.ts
  • packages/kilo-indexing/src/indexing/vector-store/lancedb-vector-store.ts
  • packages/kilo-indexing/src/indexing/vector-store/qdrant-client.ts
  • packages/kilo-indexing/src/indexing/worktree-overlay.ts — 1 warning
  • packages/opencode/src/kilocode/indexing-worker-client.ts — 1 suggestion
  • packages/opencode/src/kilocode/indexing-worker.ts — 2 warnings
  • packages/opencode/src/kilocode/indexing.ts
  • packages/opencode/src/kilocode/tool/registry.ts
  • packages/opencode/src/tool/registry.ts
  • (plus test files for kilo-indexing and opencode)

Fix these issues in Kilo Cloud

Previous Review Summaries (2 snapshots, latest commit 019270e)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 019270e)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/kilo-indexing/src/indexing/search-service.ts 48 overlay.ready is only true after reconciliation completes. Throwing here is visible to the user; a fallback or wait would be more graceful.
Incremental Review Notes

Since the previous review commit (0e735ba), the only changes to PR-owned files are:

  • packages/kilo-indexing/package.json — version bump (7.3.44 → 7.3.45)
  • packages/opencode/test/kilocode/indexing-worktree.test.ts — adds await KiloIndexing.search("ordinary directory") before the state assertion to ensure indexing completes; clean fix.

All other changes in the incremental diff (snapshot materialization, security fixes, work-style onboarding, JetBrains prompt enhancement, question routing, runner ordering) came from separate PRs merged into main and subsequently merged into this branch. They are not part of this PR's own diff and were not re-reviewed here.

Previous Issues Status
File Issue Status
packages/opencode/src/kilocode/indexing-worker.ts initQueue grows unbounded and is never reset Still open
packages/kilo-indexing/src/indexing/manager.ts:463 Missing _disposed guard after async gap in refreshBaseline Still open
packages/kilo-indexing/src/indexing/manager.ts:489 openExisting()/close() intent unclear Still open
packages/kilo-indexing/src/indexing/search-service.ts:48 overlay.ready throws before reconciliation completes Still open
Files Reviewed (PR diff — 35 files)
  • .changeset/share-worktree-indexes.md
  • packages/kilo-indexing/src/file/ignore.ts
  • packages/kilo-indexing/src/indexing/cache-manager.ts
  • packages/kilo-indexing/src/indexing/interfaces/file-processor.ts
  • packages/kilo-indexing/src/indexing/interfaces/manager.ts
  • packages/kilo-indexing/src/indexing/interfaces/vector-store.ts
  • packages/kilo-indexing/src/indexing/manager.ts
  • packages/kilo-indexing/src/indexing/orchestrator.ts
  • packages/kilo-indexing/src/indexing/processors/file-watcher.ts
  • packages/kilo-indexing/src/indexing/processors/scanner.ts
  • packages/kilo-indexing/src/indexing/search-service.ts — 1 suggestion (unchanged)
  • packages/kilo-indexing/src/indexing/service-factory.ts
  • packages/kilo-indexing/src/indexing/vector-store/lancedb-vector-store.ts
  • packages/kilo-indexing/src/indexing/vector-store/qdrant-client.ts
  • packages/kilo-indexing/src/indexing/worktree-overlay.ts
  • packages/opencode/src/kilocode/indexing-worker-client.ts
  • packages/opencode/src/kilocode/indexing-worker.ts
  • packages/opencode/src/kilocode/indexing.ts
  • packages/opencode/src/kilocode/tool/registry.ts
  • packages/opencode/src/tool/registry.ts
  • packages/opencode/test/kilocode/indexing-startup.test.ts
  • packages/opencode/test/kilocode/indexing-worker.test.ts
  • packages/opencode/test/kilocode/indexing-worktree.test.ts — updated (clean)
  • packages/opencode/test/kilocode/tool-registry-indexing.test.ts
  • packages/opencode/test/kilocode/tool-registry-semantic-import-failure.test.ts
  • (plus test files for kilo-indexing)

Fix these issues in Kilo Cloud

Previous review (commit 0e735ba)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/kilo-indexing/src/indexing/search-service.ts 48 overlay.ready is only true after reconciliation completes. Throwing here is visible to the user; a fallback or wait would be more graceful.
Resolved in Latest Commits
File Issue Status
packages/opencode/src/kilocode/indexing-worker.ts initQueue grew unbounded on rejection ✅ Fixed
packages/kilo-indexing/src/indexing/manager.ts:463 Missing _disposed guard after async gap in refreshBaseline ✅ Fixed
packages/kilo-indexing/src/indexing/manager.ts:487 openExisting()/close() intent unclear ✅ Fixed (inline comment added)
Files Reviewed (21 files)
  • .changeset/share-worktree-indexes.md
  • packages/kilo-indexing/src/file/ignore.ts
  • packages/kilo-indexing/src/indexing/cache-manager.ts — clean
  • packages/kilo-indexing/src/indexing/interfaces/file-processor.ts
  • packages/kilo-indexing/src/indexing/interfaces/manager.ts
  • packages/kilo-indexing/src/indexing/interfaces/vector-store.ts
  • packages/kilo-indexing/src/indexing/manager.ts — fixed, clean
  • packages/kilo-indexing/src/indexing/orchestrator.ts — clean
  • packages/kilo-indexing/src/indexing/processors/file-watcher.ts — clean
  • packages/kilo-indexing/src/indexing/processors/scanner.ts — clean
  • packages/kilo-indexing/src/indexing/search-service.ts — 1 suggestion (unchanged)
  • packages/kilo-indexing/src/indexing/service-factory.ts — clean
  • packages/kilo-indexing/src/indexing/vector-store/lancedb-vector-store.ts — clean
  • packages/kilo-indexing/src/indexing/vector-store/qdrant-client.ts — clean
  • packages/kilo-indexing/src/indexing/worktree-overlay.ts — clean
  • packages/opencode/src/kilocode/indexing-worker-client.ts — clean
  • packages/opencode/src/kilocode/indexing-worker.ts — fixed, clean
  • packages/opencode/src/kilocode/indexing.ts — clean
  • packages/opencode/src/kilocode/tool/registry.ts — clean
  • packages/opencode/src/tool/registry.ts — clean
  • packages/opencode/test/kilocode/tool-registry-indexing.test.ts — clean (tests updated to match config-driven registration)

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4-pro-20260423 · 262,307 tokens

Review guidance: REVIEW.md from base branch main

# Conflicts:
#	packages/opencode/src/kilocode/indexing-worker-client.ts
#	packages/opencode/test/kilocode/indexing-worktree.test.ts

@markijbema markijbema left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main asks from review (posting as line comments).

Comment thread packages/kilo-indexing/src/indexing/manager.ts
Comment thread packages/kilo-indexing/src/indexing/worktree-overlay.ts Outdated
Comment thread packages/opencode/src/kilocode/indexing-worker-client.ts
Comment thread packages/opencode/src/kilocode/indexing-worker.ts Outdated
@marius-kilocode
marius-kilocode disabled auto-merge June 16, 2026 09:31
# Conflicts:
#	packages/kilo-indexing/test/kilocode/indexing/manager.test.ts
@marius-kilocode
marius-kilocode merged commit 0a50a50 into main Jun 17, 2026
20 checks passed
@marius-kilocode
marius-kilocode deleted the skinny-poetry branch June 17, 2026 06:21
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
feat(cli): share codebase indexes across worktrees
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