Skip to content

feat(jetbrains): intellij_read PSI code intelligence tool#12114

Draft
kirillk wants to merge 3 commits into
mainfrom
suave-supernova
Draft

feat(jetbrains): intellij_read PSI code intelligence tool#12114
kirillk wants to merge 3 commits into
mainfrom
suave-supernova

Conversation

@kirillk

@kirillk kirillk commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What

Adds an experimental, JetBrains-only intellij_read tool that lets the agent use IntelliJ's already-indexed PSI model for precise, type-aware navigation: goToDefinition, findReferences, goToImplementation, workspaceSymbol, documentSymbol, and typeHierarchy.

The tool is gated behind both KILO_CLIENT === "jetbrains" and the experimental.ide_code_intelligence config flag.

How it works

The CLI does no analysis itself. intellij_read publishes a request on the bus and awaits a reply; the JetBrains backend drains pending requests over HTTP (/kilocode/ide-lsp), runs PSI queries inside a read action, and posts a structured reply/reject. This mirrors the existing notebook-host pattern.

Readiness & fallback (avoiding false negatives)

Code intelligence returns empty when IntelliJ isn't ready, which the agent would otherwise trust as an authoritative "no results". To prevent that, results now carry a status (ready | indexing | unavailable) plus a human-readable reason:

  • IndexingDumbService.isDumb / IndexNotReadyException report indexing.
  • Project not imported — for file-based operations the backend checks ProjectFileIndex.isInProject(file); if the file isn't part of the imported model, it returns unavailable instead of an empty result. This is a language-agnostic signal (no JVM-biased source-root/SDK heuristics).
  • No open project / unsupported language — also mapped to unavailable.

When the status is not ready, the tool tells the agent not to trust the empty result and to fall back to grep/glob/read (and the lsp tool if enabled).

Notes for reviewers

  • JetBrains runtime uses the CLI release pinned in packages/kilo-jetbrains/package.json; these CLI/SDK changes require a newly published/pinned CLI release before the JetBrains plugin picks them up.
  • workspaceSymbol is intentionally left ungated (it genuinely searches indexed content; gating risked false "unavailable").

Testing

  • CLI: bun run typecheck, bun test ./test/kilocode/ide-lsp/service.test.ts (5 pass)
  • JetBrains: ./gradlew :backend:test --tests KiloCliDataParserTest (green; backend main sources compile)
  • SDK regenerated via ./script/generate.ts

kirillk added 3 commits July 9, 2026 13:16
When IntelliJ is still indexing or the file is not part of the imported
project model, intellij_read now returns a status (indexing/unavailable)
with a reason and instructs the agent to fall back to grep/glob/read
instead of trusting an empty result as authoritative.
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.

1 participant