Find definitions by symbol, and decide against a second index - #77
Merged
Conversation
Ctrl+T 가 TypeScript 프로젝트에서 늘 빈 목록이었음. lspClient 만 물어보는데
TS/JS 는 LSP 세션이 아니라 Monaco 내장 워커가 맡아서. 이 저장소가 딱 그랬다.
getNavigateToItems 는 Monaco 워커가 노출 안 함(Missing requestHandler or
method). getNavigationTree 는 되니까 파일별 트리를 모아서 만듦.
에이전트용 find_symbol 도구도 같은 소스. 색인이 아예 없는 경우와 찾았는데
없는 경우를 구분해서 답한다 — 안 그러면 "그런 심볼 없음" 이 "그 언어 지원
안 함" 을 덮어버림.
트리에서 걸러낸 것 두 가지. import 로 끌어온 이름(alias)과
describe("이름", ...) 블록. 둘 다 "정의가 어디" 의 답이 아님. 앞은 빼고
뒤는 뒤로 민다.
0.4.0 계획서에 실측 결과와 2단계(자체 인덱스) 접는 근거 반영.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 1 of the 0.4.0 plan, and the measurement that closes step 2.
What was broken
Ctrl+Treturned nothing in a TypeScript project. It askedlspClientonly, but TS/JS is served by Monaco's built-in worker, not an LSP session — this repository is exactly that case, so workspace symbol search has never worked here.What it does now
src/editor/symbolIndex.tsmerges both sources: the TS worker and any live LSP sessions.Ctrl+Tand a newfind_symbolagent tool share it.Monaco's worker proxy does not expose
getNavigateToItems— it answersMissing requestHandler or method. It does exposegetNavigationTree, so workspace symbols are assembled from per-file trees. Flattening lives insrc/engine/navTree.tsas pure functions with 18 tests.The tool distinguishes no index from no match. Without that, "no such symbol" silently swallows "this language has no index at all", and the model concludes the thing does not exist.
Two kinds of noise are filtered out of the TS tree, both found by measuring rather than reading:
applyProposalis defined returned theimportline in a test file.describe("name", …)blocks — TS names those nodes after the string, so a test suite outranked the definition. These are pushed to the back rather than dropped, since sometimes the test is what you want.Exact name matches are ranked first.
Measurement (this repository, 207 models)
applyProposalengine/editApply.ts:41flattenNavTreeengine/navTree.ts:38writeAtomicelectron/checkpoints.cjs:66notifyActiveEditorext/extHost.ts:90planFileOpsext/fileOps.ts:55makeTouchSetelectron/touchSet.cjs:39grep returns 5.5× more (105 vs 19). Symbols are 4–6× slower in absolute terms, but 150–280 ms is nothing inside an agent round. All six first results are the real definition.
What the measurement decided
Step 2 of the plan — building our own index — is dropped. The precision problem is already solved, TS/JS is covered by the worker and everything else by LSP, and a second table of the same facts would only add a staleness problem to maintain. The remaining gap is languages with neither, and that is a question of attaching a language server, not of building an index — and it pays better, since definitions, references and diagnostics all arrive together.
That also removes the update-strategy work the plan spent a section on: if we hold no table, nothing goes stale.
1089 unit tests passing.
npm run typecheckclean. Verified in the real app on a fresh TypeScript project: 5/5, including that a comment mentioning the name and the call site are not returned.