Opt-in custom tree-sitter queries whose matches are stored on the node (`CBM_EXTRA_QUERIES`)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start with the prototype locations named in the issue: internal/cbm/extract_queries.c, pass_definitions.c, pass_parallel.c, and result_compact.c. Read the existing extraction and definition storage paths, then review the five extraction tests and the sequential and parallel pipeline test. Done means the proposed query matches are stored under custom on the containing node, including through both indexing routes, while invalid queries are skipped and indexing continues.
由索引模型根據 Issue 內容生成。
描述
Proposal
#3144 lists facts the extractor parses but does not store (modifiers, call counts, local variables, ...). Each one needs its own schema decision. This is a generic, opt-in alternative: the user writes tree-sitter queries, and CBM stores what they match on the node that contains the match. Nothing else in the graph changes.
How it works
- Set
CBM_EXTRA_QUERIESto a folder with one query file per language, named after the language:java.scm,csharp.scm,python.scm, ... - While indexing, CBM runs that query on the syntax tree it has already parsed (no second parse).
- Every match is stored on the innermost function, method, field or class that contains it, in one new node property:
custom.
If the variable is not set, nothing changes.
Example
Source file Box.java:
class Box {
private static final int MAX = 3;
public int run(Box b) {
int n = b.size();
n += b.size();
return n;
}
int size() { return MAX; }
}
Query file java.scm:
(modifiers ["public" "private" "static" "final"] @modifier)
(local_variable_declaration
type: (_) @local.type
declarator: (variable_declarator name: (identifier) @local.name))
(method_invocation object: (_) @call.receiver name: (identifier) @call.name)
Result, properties.custom of the stored nodes:
// Method run
{"call": [{"receiver": "b", "name": "size", "line": 4},
{"receiver": "b", "name": "size", "line": 5}],
"local": [{"type": "int", "name": "n", "line": 4}],
"modifier": ["public"]}
// Field MAX
{"modifier": ["private", "static", "final"]}
// Method size, class Box: no `custom` property (nothing matched inside them)
The capture name decides the shape:
@modifier(no dot): every captured node becomes one string in the listmodifier.@local.type+@local.name(same prefix, with a dot): each match becomes one object in the listlocal, with one key per capture and the line where it starts.@_name(leading underscore): helper capture, not stored.
Behaviour and limits
- A query that does not compile is logged once (
extract.queries.invalid, with the error offset) and skipped. Indexing continues. - Text predicates (
#eq?,#match?) are not evaluated; every structural match is stored. - Bounds: 512 bytes per captured text, 100,000 values per file, 1 MiB per query file.
- Cost measured on three open-source Java/C# repositories: index time unchanged, database 2-3% larger. With the variable unset, the cost is one atomic load per file.
Implementation (prototype ready)
- New
internal/cbm/extract_queries.c: compiles each language's query once, runs it after extraction, attaches matches to the innermost definition (new tail fieldCBMDefinition.custom_props). build_def_propsinpass_definitions.cand its twin inpass_parallel.cwrite it ascustomand count it in the buffer sizing;result_compact.ccopies it, so spilled results keep it.- Tests: 5 extraction tests and 1 pipeline test that indexes through both the sequential and the parallel route and checks the stored property.
Questions
- Is a generic hook like this acceptable, alongside or instead of the per-fact items in #3144?
- Environment variable, or would you prefer a config file entry or an
index_repositoryargument? - Are the property name
customand the file naming by language name fine?
If the shape is OK, I will open one PR for it (Closes #<this issue>).
- 主要語言
- C
- 星號
- 45.8k
- 分支
- 3.8k
- 平均合併
- 2 天 18 小時
- 30 天內合併 PR
- 108
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
DeusData/codebase-memory-mcp 的其他 Issue
-
bug ux/behavior
難度 2/5 1-3 小時 新手友好度 70/100
DeusData/codebase-memory-mcp#3191 ·
維護者通常 1 天內回覆
-
documentation enhancement parsing/quality ux/behavior
難度 1/5 1-3 小時 新手友好度 82/100
DeusData/codebase-memory-mcp#3131 · 1 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
hook-augment: the five-row cap keeps the first five search_graph rows, so variables and modules displace function definitions (v0.12.1)可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉bug editor/integration parsing/quality ux/behavior
難度 2/5 1-3 小時 新手友好度 75/100
DeusData/codebase-memory-mcp#3062 · 2 則留言 ·
維護者通常 1 天內回覆
-
bug documentation editor/integration parsing/quality
難度 2/5 1-3 小時 新手友好度 75/100
DeusData/codebase-memory-mcp#3050 · 1 則留言 ·
維護者通常 1 天內回覆
-
editor/integration parsing/quality
難度 2/5 1-3 小時 新手友好度 68/100
DeusData/codebase-memory-mcp#2286 ·
維護者通常 1 天內回覆
查看 DeusData/codebase-memory-mcp 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 70/100
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
-
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
NVIDIA/open-gpu-kernel-modules#1635 ·
維護者通常 1 天內回覆
-
iOS: the "Edit controls" button never hides, even with a controller connected, and covers the game未關閉game: 010065A014024000 ios
難度 2/5 1-3 小時 新手友好度 76/100
seedds/nxnative#3714 · 1 則留言 ·
維護者通常 2 天內回覆