opencode-rag-plugin 2.11.0 → 2.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunker/grammar.d.ts +4 -1
- package/dist/chunker/grammar.js +9 -3
- package/dist/chunker/skeleton.js +61 -4
- package/dist/web/ui/assets/{ScatterPlot3D-CKwyh1Ec.js → ScatterPlot3D-XjXIwavM.js} +5 -5
- package/dist/web/ui/assets/index-FFPRbgLx.js +4 -0
- package/dist/web/ui/index.html +1 -1
- package/package.json +6 -2
- package/dist/web/ui/assets/index-ChGi2bSp.js +0 -4
|
@@ -90,6 +90,9 @@ export declare function buildByteOffsetMap(source: string): Map<number, number>
|
|
|
90
90
|
* @param source - Full source text (used to slice node text and comments).
|
|
91
91
|
* @param maxDepth - Maximum recursion depth (default: 10).
|
|
92
92
|
* @param depth - Current recursion depth (internal, start at 0).
|
|
93
|
+
* @param descend - When true, keep walking into a matched node's children so
|
|
94
|
+
* nested members are returned too. The chunker keeps the default (false) so
|
|
95
|
+
* one matched declaration stays one chunk; the skeleton outline opts in.
|
|
93
96
|
* @returns An array of {@link AstNode} objects for matching declarations.
|
|
94
97
|
*/
|
|
95
|
-
export declare function walkTree(node: Node, nodeTypes: Set<string>, source: string, maxDepth?: number, depth?: number, offsetMap?: Map<number, number> | null): AstNode[];
|
|
98
|
+
export declare function walkTree(node: Node, nodeTypes: Set<string>, source: string, maxDepth?: number, depth?: number, offsetMap?: Map<number, number> | null, descend?: boolean): AstNode[];
|
package/dist/chunker/grammar.js
CHANGED
|
@@ -249,9 +249,12 @@ function extractDocstringFromBody(node, source, offsetMap) {
|
|
|
249
249
|
* @param source - Full source text (used to slice node text and comments).
|
|
250
250
|
* @param maxDepth - Maximum recursion depth (default: 10).
|
|
251
251
|
* @param depth - Current recursion depth (internal, start at 0).
|
|
252
|
+
* @param descend - When true, keep walking into a matched node's children so
|
|
253
|
+
* nested members are returned too. The chunker keeps the default (false) so
|
|
254
|
+
* one matched declaration stays one chunk; the skeleton outline opts in.
|
|
252
255
|
* @returns An array of {@link AstNode} objects for matching declarations.
|
|
253
256
|
*/
|
|
254
|
-
export function walkTree(node, nodeTypes, source, maxDepth = 10, depth = 0, offsetMap) {
|
|
257
|
+
export function walkTree(node, nodeTypes, source, maxDepth = 10, depth = 0, offsetMap, descend = false) {
|
|
255
258
|
const results = [];
|
|
256
259
|
if (nodeTypes.has(node.type) && depth > 0) {
|
|
257
260
|
const leadingComments = extractLeadingComments(node, source, offsetMap);
|
|
@@ -268,11 +271,14 @@ export function walkTree(node, nodeTypes, source, maxDepth = 10, depth = 0, offs
|
|
|
268
271
|
type: node.type,
|
|
269
272
|
leadingDoc: leadingDoc.length > 0 ? leadingDoc : undefined,
|
|
270
273
|
});
|
|
271
|
-
|
|
274
|
+
// The chunker stops at the first matched declaration so that one
|
|
275
|
+
// declaration produces one chunk. The skeleton opts into descending.
|
|
276
|
+
if (!descend)
|
|
277
|
+
return results;
|
|
272
278
|
}
|
|
273
279
|
if (depth < maxDepth) {
|
|
274
280
|
for (const child of node.children) {
|
|
275
|
-
results.push(...walkTree(child, nodeTypes, source, maxDepth, depth + 1, offsetMap));
|
|
281
|
+
results.push(...walkTree(child, nodeTypes, source, maxDepth, depth + 1, offsetMap, descend));
|
|
276
282
|
}
|
|
277
283
|
}
|
|
278
284
|
return results;
|
package/dist/chunker/skeleton.js
CHANGED
|
@@ -21,16 +21,16 @@ export const SKELETON_CONFIGS = {
|
|
|
21
21
|
".jsx": { grammarName: "javascript", nodeTypes: ["function_declaration", "method_definition", "class_declaration", "arrow_function"] },
|
|
22
22
|
".mjs": { grammarName: "javascript", nodeTypes: ["function_declaration", "method_definition", "class_declaration", "arrow_function"] },
|
|
23
23
|
".cjs": { grammarName: "javascript", nodeTypes: ["function_declaration", "method_definition", "class_declaration", "arrow_function"] },
|
|
24
|
-
".py": { grammarName: "python", nodeTypes: ["function_definition", "class_definition"
|
|
24
|
+
".py": { grammarName: "python", nodeTypes: ["function_definition", "class_definition"] },
|
|
25
25
|
".java": { grammarName: "java", nodeTypes: ["class_declaration", "method_declaration", "interface_declaration", "enum_declaration"] },
|
|
26
|
-
".go": { grammarName: "go", nodeTypes: ["function_declaration", "method_declaration", "
|
|
26
|
+
".go": { grammarName: "go", nodeTypes: ["function_declaration", "method_declaration", "type_spec", "type_alias"] },
|
|
27
27
|
".rs": { grammarName: "rust", nodeTypes: ["function_item", "struct_item", "enum_item", "impl_item", "trait_item", "type_item"] },
|
|
28
28
|
".c": { grammarName: "c", nodeTypes: ["function_definition", "struct_specifier", "enum_specifier"] },
|
|
29
29
|
".cpp": { grammarName: "cpp", nodeTypes: ["function_definition", "class_specifier", "struct_specifier", "enum_specifier"] },
|
|
30
30
|
".cxx": { grammarName: "cpp", nodeTypes: ["function_definition", "class_specifier", "struct_specifier", "enum_specifier"] },
|
|
31
31
|
".h": { grammarName: "cpp", nodeTypes: ["function_definition", "class_specifier", "struct_specifier", "enum_specifier"] },
|
|
32
32
|
".hpp": { grammarName: "cpp", nodeTypes: ["function_definition", "class_specifier", "struct_specifier", "enum_specifier"] },
|
|
33
|
-
".cs": { grammarName: "c_sharp", nodeTypes: ["class_declaration", "
|
|
33
|
+
".cs": { grammarName: "c_sharp", nodeTypes: ["class_declaration", "struct_declaration", "interface_declaration", "enum_declaration", "record_declaration", "delegate_declaration", "constructor_declaration", "destructor_declaration", "method_declaration", "property_declaration", "indexer_declaration", "event_field_declaration", "event_declaration", "operator_declaration", "conversion_operator_declaration"] },
|
|
34
34
|
".rb": { grammarName: "ruby", nodeTypes: ["method", "class", "module"] },
|
|
35
35
|
".swift": { grammarName: "swift", nodeTypes: ["function_declaration", "class_declaration", "struct_declaration", "enum_declaration", "protocol_declaration"] },
|
|
36
36
|
".kt": { grammarName: "kotlin", nodeTypes: ["function_declaration", "class_declaration", "interface_declaration", "object_declaration"] },
|
|
@@ -99,6 +99,61 @@ function resolveSkeletonKey(ext, overrides) {
|
|
|
99
99
|
// line-count fallback instead of using it.
|
|
100
100
|
return hit ?? NO_SKELETON;
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Node types that represent executable bodies. A callable nested inside
|
|
104
|
+
* another callable is an implementation detail (callback, local helper), not
|
|
105
|
+
* a member of the file's outline, so descent drops it. A callable nested in a
|
|
106
|
+
* type (a method, constructor, …) is kept.
|
|
107
|
+
*/
|
|
108
|
+
const CALLABLE_NODE_TYPES = new Set([
|
|
109
|
+
"function_declaration",
|
|
110
|
+
"function_definition",
|
|
111
|
+
"function_item",
|
|
112
|
+
"function",
|
|
113
|
+
"method_declaration",
|
|
114
|
+
"method_definition",
|
|
115
|
+
"method",
|
|
116
|
+
"constructor_declaration",
|
|
117
|
+
"destructor_declaration",
|
|
118
|
+
"operator_declaration",
|
|
119
|
+
"conversion_operator_declaration",
|
|
120
|
+
"arrow_function",
|
|
121
|
+
"generator_function_declaration",
|
|
122
|
+
"generator_function",
|
|
123
|
+
"lambda",
|
|
124
|
+
"lambda_expression",
|
|
125
|
+
"lambda_literal",
|
|
126
|
+
"func_literal",
|
|
127
|
+
"closure_expression",
|
|
128
|
+
"anonymous_function",
|
|
129
|
+
]);
|
|
130
|
+
/**
|
|
131
|
+
* Drop a callable whose nearest outlined ancestor is also a callable, keeping
|
|
132
|
+
* the outer one. Types and their members are unaffected: only body-level
|
|
133
|
+
* nesting is removed, so a method of a local class still appears.
|
|
134
|
+
*/
|
|
135
|
+
function dropNestedCallables(nodes) {
|
|
136
|
+
return nodes.filter((node) => {
|
|
137
|
+
if (!CALLABLE_NODE_TYPES.has(node.type))
|
|
138
|
+
return true;
|
|
139
|
+
let nearest;
|
|
140
|
+
for (const other of nodes) {
|
|
141
|
+
if (other === node)
|
|
142
|
+
continue;
|
|
143
|
+
const contains = other.startIndex <= node.startIndex &&
|
|
144
|
+
other.endIndex >= node.endIndex &&
|
|
145
|
+
(other.startIndex < node.startIndex || other.endIndex > node.endIndex);
|
|
146
|
+
if (!contains)
|
|
147
|
+
continue;
|
|
148
|
+
if (!nearest ||
|
|
149
|
+
other.startIndex > nearest.startIndex ||
|
|
150
|
+
(other.startIndex === nearest.startIndex && other.endIndex < nearest.endIndex)) {
|
|
151
|
+
nearest = other;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return !nearest || !CALLABLE_NODE_TYPES.has(nearest.type);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
102
157
|
/**
|
|
103
158
|
* Extract structural outline from source code using tree-sitter.
|
|
104
159
|
* Falls back to regex patterns for languages without WASM grammars, and to a
|
|
@@ -150,7 +205,9 @@ export async function extractSkeleton(content, ext, options) {
|
|
|
150
205
|
return [];
|
|
151
206
|
try {
|
|
152
207
|
const nodeTypes = new Set(config.nodeTypes);
|
|
153
|
-
|
|
208
|
+
// Descend into matched declarations: a skeleton describes the members
|
|
209
|
+
// inside a type, whereas the chunker intentionally stops at the type.
|
|
210
|
+
const astNodes = dropNestedCallables(walkTree(tree.rootNode, nodeTypes, content, 15, 0, undefined, true));
|
|
154
211
|
return astNodes.map((node) => ({
|
|
155
212
|
type: node.type,
|
|
156
213
|
name: extractNodeName(node.text, node.type),
|