opencode-rag-plugin 1.8.4 → 1.10.2
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/ReadMe.md +25 -5
- package/dist/api.d.ts +27 -0
- package/dist/api.js +125 -0
- package/dist/api.js.map +1 -0
- package/dist/chunker/base.d.ts +2 -0
- package/dist/chunker/base.js +18 -7
- package/dist/chunker/base.js.map +1 -1
- package/dist/chunker/bash.d.ts +8 -0
- package/dist/chunker/bash.js +11 -0
- package/dist/chunker/bash.js.map +1 -0
- package/dist/chunker/dockerfile.d.ts +8 -0
- package/dist/chunker/dockerfile.js +29 -0
- package/dist/chunker/dockerfile.js.map +1 -0
- package/dist/chunker/factory.d.ts +9 -1
- package/dist/chunker/factory.js +24 -3
- package/dist/chunker/factory.js.map +1 -1
- package/dist/chunker/grammar.d.ts +1 -0
- package/dist/chunker/grammar.js +42 -2
- package/dist/chunker/grammar.js.map +1 -1
- package/dist/chunker/ini.d.ts +8 -0
- package/dist/chunker/ini.js +11 -0
- package/dist/chunker/ini.js.map +1 -0
- package/dist/chunker/markdown.d.ts +4 -3
- package/dist/chunker/markdown.js +4 -91
- package/dist/chunker/markdown.js.map +1 -1
- package/dist/chunker/php.d.ts +8 -0
- package/dist/chunker/php.js +12 -0
- package/dist/chunker/php.js.map +1 -0
- package/dist/chunker/powershell.d.ts +8 -0
- package/dist/chunker/powershell.js +11 -0
- package/dist/chunker/powershell.js.map +1 -0
- package/dist/chunker/razor.js +0 -1
- package/dist/chunker/razor.js.map +1 -1
- package/dist/chunker/sql.d.ts +8 -0
- package/dist/chunker/sql.js +11 -0
- package/dist/chunker/sql.js.map +1 -0
- package/dist/chunker/tex.js +2 -2
- package/dist/chunker/tex.js.map +1 -1
- package/dist/chunker/toml.d.ts +8 -0
- package/dist/chunker/toml.js +13 -0
- package/dist/chunker/toml.js.map +1 -0
- package/dist/chunker/yaml.d.ts +8 -0
- package/dist/chunker/yaml.js +12 -0
- package/dist/chunker/yaml.js.map +1 -0
- package/dist/cli.js +50 -11
- package/dist/cli.js.map +1 -1
- package/dist/core/config.d.ts +10 -1
- package/dist/core/config.js +127 -11
- package/dist/core/config.js.map +1 -1
- package/dist/embedder/openai.js +1 -5
- package/dist/embedder/openai.js.map +1 -1
- package/dist/eval/storage.d.ts +1 -0
- package/dist/eval/storage.js +4 -0
- package/dist/eval/storage.js.map +1 -1
- package/dist/eval/types.js +0 -1
- package/dist/eval/types.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/indexer.d.ts +9 -0
- package/dist/indexer.js +27 -6
- package/dist/indexer.js.map +1 -1
- package/dist/mcp/cli.d.ts +4 -0
- package/dist/mcp/cli.js +15 -0
- package/dist/mcp/cli.js.map +1 -0
- package/dist/mcp/handlers.d.ts +46 -0
- package/dist/mcp/handlers.js +300 -0
- package/dist/mcp/handlers.js.map +1 -0
- package/dist/mcp/server.d.ts +12 -0
- package/dist/mcp/server.js +124 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/opencode/read-format.d.ts +1 -1
- package/dist/opencode/read-format.js +1 -1
- package/dist/opencode/tools.js +0 -5
- package/dist/opencode/tools.js.map +1 -1
- package/dist/plugin.js +18 -37
- package/dist/plugin.js.map +1 -1
- package/dist/retriever/keyword-index.js +7 -1
- package/dist/retriever/keyword-index.js.map +1 -1
- package/dist/retriever/retriever.js +51 -46
- package/dist/retriever/retriever.js.map +1 -1
- package/dist/watcher.js +1 -0
- package/dist/watcher.js.map +1 -1
- package/dist/web/api.js +10 -1
- package/dist/web/api.js.map +1 -1
- package/package.json +19 -2
package/dist/chunker/markdown.js
CHANGED
|
@@ -1,96 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export class MarkdownChunker {
|
|
1
|
+
import { TreeSitterChunker } from "./base.js";
|
|
2
|
+
export class MarkdownChunker extends TreeSitterChunker {
|
|
4
3
|
language = "markdown";
|
|
5
4
|
fileExtensions = [".md", ".mdx"];
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return [];
|
|
9
|
-
const chunks = [];
|
|
10
|
-
const lines = content.split("\n");
|
|
11
|
-
const sections = [];
|
|
12
|
-
let inCodeBlock = false;
|
|
13
|
-
let currentSectionStart = 1;
|
|
14
|
-
let currentHeading = "";
|
|
15
|
-
let currentLevel = 0;
|
|
16
|
-
for (let i = 0; i < lines.length; i++) {
|
|
17
|
-
const line = lines[i] ?? "";
|
|
18
|
-
if (line.trim().startsWith("```")) {
|
|
19
|
-
inCodeBlock = !inCodeBlock;
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
if (inCodeBlock)
|
|
23
|
-
continue;
|
|
24
|
-
const match = HEADING_REGEX.exec(line);
|
|
25
|
-
HEADING_REGEX.lastIndex = 0;
|
|
26
|
-
if (match) {
|
|
27
|
-
if (currentHeading) {
|
|
28
|
-
sections.push({
|
|
29
|
-
heading: currentHeading,
|
|
30
|
-
level: currentLevel,
|
|
31
|
-
startLine: currentSectionStart,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
currentHeading = match[2] ?? "";
|
|
35
|
-
currentLevel = match[1]?.length ?? 1;
|
|
36
|
-
currentSectionStart = i + 1;
|
|
37
|
-
if (currentLevel <= 2) {
|
|
38
|
-
sections.push({
|
|
39
|
-
heading: currentHeading,
|
|
40
|
-
level: currentLevel,
|
|
41
|
-
startLine: currentSectionStart,
|
|
42
|
-
});
|
|
43
|
-
currentHeading = "";
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// Last section
|
|
48
|
-
if (currentHeading) {
|
|
49
|
-
sections.push({
|
|
50
|
-
heading: currentHeading,
|
|
51
|
-
level: currentLevel,
|
|
52
|
-
startLine: currentSectionStart,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
// If no sections found, create one chunk for the whole file
|
|
56
|
-
if (sections.length === 0) {
|
|
57
|
-
return [
|
|
58
|
-
{
|
|
59
|
-
id: uuid(),
|
|
60
|
-
content,
|
|
61
|
-
metadata: {
|
|
62
|
-
filePath,
|
|
63
|
-
startLine: 1,
|
|
64
|
-
endLine: lines.length,
|
|
65
|
-
language: this.language,
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
];
|
|
69
|
-
}
|
|
70
|
-
for (let i = 0; i < sections.length; i++) {
|
|
71
|
-
const section = sections[i];
|
|
72
|
-
const startLine = section.startLine;
|
|
73
|
-
const endLine = i + 1 < sections.length
|
|
74
|
-
? sections[i + 1].startLine - 1
|
|
75
|
-
: lines.length;
|
|
76
|
-
if (startLine > endLine)
|
|
77
|
-
continue;
|
|
78
|
-
const chunkContent = lines.slice(startLine - 1, endLine).join("\n").trim();
|
|
79
|
-
if (chunkContent.length === 0)
|
|
80
|
-
continue;
|
|
81
|
-
chunks.push({
|
|
82
|
-
id: uuid(),
|
|
83
|
-
content: chunkContent,
|
|
84
|
-
metadata: {
|
|
85
|
-
filePath,
|
|
86
|
-
startLine,
|
|
87
|
-
endLine,
|
|
88
|
-
language: this.language,
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return chunks;
|
|
93
|
-
}
|
|
5
|
+
grammarName = "markdown";
|
|
6
|
+
nodeTypes = new Set(["section"]);
|
|
94
7
|
}
|
|
95
8
|
export const markdownChunker = new MarkdownChunker();
|
|
96
9
|
//# sourceMappingURL=markdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/chunker/markdown.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/chunker/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,OAAO,eAAgB,SAAQ,iBAAiB;IAC3C,QAAQ,GAAG,UAAU,CAAC;IACtB,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACjC,WAAW,GAAG,UAAU,CAAC;IACzB,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;CAC3C;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TreeSitterChunker } from "./base.js";
|
|
2
|
+
export declare class PhpChunker extends TreeSitterChunker {
|
|
3
|
+
readonly language = "php";
|
|
4
|
+
readonly fileExtensions: string[];
|
|
5
|
+
readonly grammarName = "php";
|
|
6
|
+
readonly nodeTypes: Set<string>;
|
|
7
|
+
}
|
|
8
|
+
export declare const phpChunker: PhpChunker;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TreeSitterChunker } from "./base.js";
|
|
2
|
+
export class PhpChunker extends TreeSitterChunker {
|
|
3
|
+
language = "php";
|
|
4
|
+
fileExtensions = [".php"];
|
|
5
|
+
grammarName = "php";
|
|
6
|
+
nodeTypes = new Set([
|
|
7
|
+
"function_definition",
|
|
8
|
+
"method_declaration",
|
|
9
|
+
]);
|
|
10
|
+
}
|
|
11
|
+
export const phpChunker = new PhpChunker();
|
|
12
|
+
//# sourceMappingURL=php.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"php.js","sourceRoot":"","sources":["../../src/chunker/php.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,OAAO,UAAW,SAAQ,iBAAiB;IACtC,QAAQ,GAAG,KAAK,CAAC;IACjB,cAAc,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,WAAW,GAAG,KAAK,CAAC;IACpB,SAAS,GAAG,IAAI,GAAG,CAAC;QAC3B,qBAAqB;QACrB,oBAAoB;KACrB,CAAC,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TreeSitterChunker } from "./base.js";
|
|
2
|
+
export declare class PowerShellChunker extends TreeSitterChunker {
|
|
3
|
+
readonly language = "powershell";
|
|
4
|
+
readonly fileExtensions: string[];
|
|
5
|
+
readonly grammarName = "powershell";
|
|
6
|
+
readonly nodeTypes: Set<string>;
|
|
7
|
+
}
|
|
8
|
+
export declare const powershellChunker: PowerShellChunker;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TreeSitterChunker } from "./base.js";
|
|
2
|
+
export class PowerShellChunker extends TreeSitterChunker {
|
|
3
|
+
language = "powershell";
|
|
4
|
+
fileExtensions = [".ps1", ".psm1", ".psd1"];
|
|
5
|
+
grammarName = "powershell";
|
|
6
|
+
nodeTypes = new Set([
|
|
7
|
+
"function_statement",
|
|
8
|
+
]);
|
|
9
|
+
}
|
|
10
|
+
export const powershellChunker = new PowerShellChunker();
|
|
11
|
+
//# sourceMappingURL=powershell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"powershell.js","sourceRoot":"","sources":["../../src/chunker/powershell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB;IAC7C,QAAQ,GAAG,YAAY,CAAC;IACxB,cAAc,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5C,WAAW,GAAG,YAAY,CAAC;IAC3B,SAAS,GAAG,IAAI,GAAG,CAAC;QAC3B,oBAAoB;KACrB,CAAC,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC"}
|
package/dist/chunker/razor.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"razor.js","sourceRoot":"","sources":["../../src/chunker/razor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WA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ACE,EAAE,EAAE,IAAI,EAAE;oBACV,OAAO;oBACP,QAAQ,EAAE;wBACR,QAAQ;wBACR,SAAS,EAAE,CAAC;wBACZ,OAAO,EAAE,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC;wBACnD,QAAQ,EAAE,IAAI,CAAC,QAAQ;qBACxB;iBACF;aACF,CAAC;QACJ,CAAC;QAED,OAAO,OAAO;aACX,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE;YACtB,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;YACtD,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;YAE3C,OAAO;gBACL,EAAE,EAAE,IAAI,EAAE;gBACV,OAAO,EAAE,YAAY;gBACrB,QAAQ,EAAE;oBACR,QAAQ;oBACR,SAAS,EAAE,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC;oBAC5C,OAAO,EAAE,aAAa,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC;oBACxC,QAAQ,EAAE,IAAI,CAAC,QAAQ;iBACxB;aACF,CAAC;QACJ,CAAC,CAAC;aACD,MAAM,CAAC,CAAC,CAAC,EAAc,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;IAC3C,CAAC;CACF;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TreeSitterChunker } from "./base.js";
|
|
2
|
+
export declare class SqlChunker extends TreeSitterChunker {
|
|
3
|
+
readonly language = "sql";
|
|
4
|
+
readonly fileExtensions: string[];
|
|
5
|
+
readonly grammarName = "sql";
|
|
6
|
+
readonly nodeTypes: Set<string>;
|
|
7
|
+
}
|
|
8
|
+
export declare const sqlChunker: SqlChunker;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TreeSitterChunker } from "./base.js";
|
|
2
|
+
export class SqlChunker extends TreeSitterChunker {
|
|
3
|
+
language = "sql";
|
|
4
|
+
fileExtensions = [".sql"];
|
|
5
|
+
grammarName = "sql";
|
|
6
|
+
nodeTypes = new Set([
|
|
7
|
+
"statement",
|
|
8
|
+
]);
|
|
9
|
+
}
|
|
10
|
+
export const sqlChunker = new SqlChunker();
|
|
11
|
+
//# sourceMappingURL=sql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql.js","sourceRoot":"","sources":["../../src/chunker/sql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,OAAO,UAAW,SAAQ,iBAAiB;IACtC,QAAQ,GAAG,KAAK,CAAC;IACjB,cAAc,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,WAAW,GAAG,KAAK,CAAC;IACpB,SAAS,GAAG,IAAI,GAAG,CAAC;QAC3B,WAAW;KACZ,CAAC,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC"}
|
package/dist/chunker/tex.js
CHANGED
|
@@ -15,13 +15,13 @@ export class TexChunker {
|
|
|
15
15
|
let currentName = "";
|
|
16
16
|
for (let i = 0; i < lines.length; i++) {
|
|
17
17
|
const line = lines[i] ?? "";
|
|
18
|
-
const commentMatch = line.match(
|
|
18
|
+
const commentMatch = line.match(/\\begin\{comment\}/);
|
|
19
19
|
if (commentMatch) {
|
|
20
20
|
inCommentBlock = true;
|
|
21
21
|
continue;
|
|
22
22
|
}
|
|
23
23
|
if (inCommentBlock) {
|
|
24
|
-
if (line.match(
|
|
24
|
+
if (line.match(/\\end\{comment\}/)) {
|
|
25
25
|
inCommentBlock = false;
|
|
26
26
|
}
|
|
27
27
|
continue;
|
package/dist/chunker/tex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tex.js","sourceRoot":"","sources":["../../src/chunker/tex.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,aAAa,GAAG,yDAAyD,CAAC;AAEhF,MAAM,OAAO,UAAU;IACZ,QAAQ,GAAG,OAAO,CAAC;IACnB,cAAc,GAAG,CAAC,MAAM,CAAC,CAAC;IAEnC,KAAK,CAAC,KAAK,CAAC,QAAgB,EAAE,OAAe;QAC3C,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAE3C,MAAM,MAAM,GAAY,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,QAAQ,GAA2D,EAAE,CAAC;QAE5E,IAAI,cAAc,GAAG,KAAK,CAAC;QAC3B,IAAI,mBAAmB,GAAG,CAAC,CAAC;QAC5B,IAAI,cAAc,GAAG,EAAE,CAAC;QACxB,IAAI,WAAW,GAAG,EAAE,CAAC;QAErB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAE5B,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"tex.js","sourceRoot":"","sources":["../../src/chunker/tex.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,aAAa,GAAG,yDAAyD,CAAC;AAEhF,MAAM,OAAO,UAAU;IACZ,QAAQ,GAAG,OAAO,CAAC;IACnB,cAAc,GAAG,CAAC,MAAM,CAAC,CAAC;IAEnC,KAAK,CAAC,KAAK,CAAC,QAAgB,EAAE,OAAe;QAC3C,IA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CAAC;YAEnB,IAAI,SAAS,GAAG,OAAO;gBAAE,SAAS;YAElC,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;YAC3E,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;gBAAE,SAAS;YAExC,MAAM,CAAC,IAAI,CAAC;gBACV,EAAE,EAAE,IAAI,EAAE;gBACV,OAAO,EAAE,YAAY;gBACrB,QAAQ,EAAE;oBACR,QAAQ;oBACR,SAAS;oBACT,OAAO;oBACP,QAAQ,EAAE,IAAI,CAAC,QAAQ;iBACxB;aACF,CAAC,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TreeSitterChunker } from "./base.js";
|
|
2
|
+
export declare class TomlChunker extends TreeSitterChunker {
|
|
3
|
+
readonly language = "toml";
|
|
4
|
+
readonly fileExtensions: string[];
|
|
5
|
+
readonly grammarName = "toml";
|
|
6
|
+
readonly nodeTypes: Set<string>;
|
|
7
|
+
}
|
|
8
|
+
export declare const tomlChunker: TomlChunker;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TreeSitterChunker } from "./base.js";
|
|
2
|
+
export class TomlChunker extends TreeSitterChunker {
|
|
3
|
+
language = "toml";
|
|
4
|
+
fileExtensions = [".toml"];
|
|
5
|
+
grammarName = "toml";
|
|
6
|
+
nodeTypes = new Set([
|
|
7
|
+
"table",
|
|
8
|
+
"table_array_element",
|
|
9
|
+
"pair",
|
|
10
|
+
]);
|
|
11
|
+
}
|
|
12
|
+
export const tomlChunker = new TomlChunker();
|
|
13
|
+
//# sourceMappingURL=toml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toml.js","sourceRoot":"","sources":["../../src/chunker/toml.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IACvC,QAAQ,GAAG,MAAM,CAAC;IAClB,cAAc,GAAG,CAAC,OAAO,CAAC,CAAC;IAC3B,WAAW,GAAG,MAAM,CAAC;IACrB,SAAS,GAAG,IAAI,GAAG,CAAC;QAC3B,OAAO;QACP,qBAAqB;QACrB,MAAM;KACP,CAAC,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TreeSitterChunker } from "./base.js";
|
|
2
|
+
export declare class YamlChunker extends TreeSitterChunker {
|
|
3
|
+
readonly language = "yaml";
|
|
4
|
+
readonly fileExtensions: string[];
|
|
5
|
+
readonly grammarName = "yaml";
|
|
6
|
+
readonly nodeTypes: Set<string>;
|
|
7
|
+
}
|
|
8
|
+
export declare const yamlChunker: YamlChunker;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TreeSitterChunker } from "./base.js";
|
|
2
|
+
export class YamlChunker extends TreeSitterChunker {
|
|
3
|
+
language = "yaml";
|
|
4
|
+
fileExtensions = [".yaml", ".yml"];
|
|
5
|
+
grammarName = "yaml";
|
|
6
|
+
nodeTypes = new Set([
|
|
7
|
+
"block_mapping_pair",
|
|
8
|
+
"block_sequence_item",
|
|
9
|
+
]);
|
|
10
|
+
}
|
|
11
|
+
export const yamlChunker = new YamlChunker();
|
|
12
|
+
//# sourceMappingURL=yaml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml.js","sourceRoot":"","sources":["../../src/chunker/yaml.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IACvC,QAAQ,GAAG,MAAM,CAAC;IAClB,cAAc,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACnC,WAAW,GAAG,MAAM,CAAC;IACrB,SAAS,GAAG,IAAI,GAAG,CAAC;QAC3B,oBAAoB;QACpB,qBAAqB;KACtB,CAAC,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -176,6 +176,16 @@ function buildOpencodeConfig(existing) {
|
|
|
176
176
|
// init versions would trigger npm install (which fails due to native
|
|
177
177
|
// dependencies like canvas) and produce "Plugin export is not a function".
|
|
178
178
|
delete next.plugin;
|
|
179
|
+
// Register MCP server for semantic code retrieval
|
|
180
|
+
next.mcp = {
|
|
181
|
+
...(next.mcp ?? {}),
|
|
182
|
+
"opencode-rag": {
|
|
183
|
+
type: "local",
|
|
184
|
+
command: ["npx", "-y", "opencode-rag-plugin", "mcp"],
|
|
185
|
+
cwd: ".",
|
|
186
|
+
enabled: true,
|
|
187
|
+
},
|
|
188
|
+
};
|
|
179
189
|
return next;
|
|
180
190
|
}
|
|
181
191
|
export function removeStaleGlobalPluginRegistrations(homeDir, pluginName) {
|
|
@@ -241,8 +251,7 @@ function generateSkillFile() {
|
|
|
241
251
|
"",
|
|
242
252
|
"| Tool | Use when | Example |",
|
|
243
253
|
"|------|----------|---------|",
|
|
244
|
-
"| `
|
|
245
|
-
"| `search_semantic` | Conceptual question — \"how does X work?\" or \"where is Y?\" | `\"How does the chunking pipeline work?\"` |",
|
|
254
|
+
"| `search_semantic` | Any code search — find relevant code by meaning or keyword | `\"authentication middleware\"` |",
|
|
246
255
|
"| `get_file_skeleton` | You have a file path but need to orient before reading | `\"src/plugin.ts\"` |",
|
|
247
256
|
"| `find_usages` | Before editing any function, class, or variable — check all call sites | `\"createRagHooks\"` |",
|
|
248
257
|
"",
|
|
@@ -250,13 +259,12 @@ function generateSkillFile() {
|
|
|
250
259
|
"",
|
|
251
260
|
"1. **Skeleton first** — call `get_file_skeleton(filePath)` to see structure",
|
|
252
261
|
"2. **Find usages** — call `find_usages(symbolName)` before modifying any symbol",
|
|
253
|
-
"3. **Search** — call `
|
|
262
|
+
"3. **Search** — call `search_semantic(query)` to find relevant code",
|
|
254
263
|
"4. **Read** — use the `read` tool on specific line ranges identified above",
|
|
255
264
|
"5. **Edit** — now you have full context to make safe changes",
|
|
256
265
|
"",
|
|
257
266
|
"### Parameters",
|
|
258
267
|
"",
|
|
259
|
-
"- `opencode-rag-context`: `query` (req), `pathHints?`, `languageHints?`, `topK?`",
|
|
260
268
|
"- `search_semantic`: `query` (req), `pathHints?`, `languageHints?`, `topK?`",
|
|
261
269
|
"- `get_file_skeleton`: `filePath` (req)",
|
|
262
270
|
"- `find_usages`: `symbolName` (req), `pathHint?`, `topK?`",
|
|
@@ -431,7 +439,11 @@ program
|
|
|
431
439
|
});
|
|
432
440
|
const shutdown = async () => {
|
|
433
441
|
scheduler.close();
|
|
434
|
-
await
|
|
442
|
+
await scheduler.waitForIdle();
|
|
443
|
+
await Promise.race([
|
|
444
|
+
watcher.close(),
|
|
445
|
+
new Promise((r) => setTimeout(r, 5000)),
|
|
446
|
+
]);
|
|
435
447
|
process.exit(0);
|
|
436
448
|
};
|
|
437
449
|
process.once("SIGINT", () => void shutdown());
|
|
@@ -695,12 +707,17 @@ program
|
|
|
695
707
|
logCliInfo(logFilePath, "ui", ` ${c.dim("Press Ctrl+C to stop")}\n`);
|
|
696
708
|
if (openBrowser) {
|
|
697
709
|
const { spawn } = await import("node:child_process");
|
|
698
|
-
|
|
699
|
-
|
|
710
|
+
try {
|
|
711
|
+
if (process.platform === "win32") {
|
|
712
|
+
spawn("cmd.exe", ["/c", "start", url], { detached: true, stdio: "ignore" }).unref();
|
|
713
|
+
}
|
|
714
|
+
else {
|
|
715
|
+
const cmd = process.platform === "darwin" ? "open" : "xdg-open";
|
|
716
|
+
spawn(cmd, [url], { detached: true, stdio: "ignore" }).unref();
|
|
717
|
+
}
|
|
700
718
|
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
spawn(cmd, [url], { detached: true, stdio: "ignore" }).unref();
|
|
719
|
+
catch {
|
|
720
|
+
console.error(c.dim(`Could not open browser automatically. Open ${url} manually.`));
|
|
704
721
|
}
|
|
705
722
|
}
|
|
706
723
|
process.on("SIGINT", async () => {
|
|
@@ -719,6 +736,25 @@ program
|
|
|
719
736
|
process.exit(1);
|
|
720
737
|
}
|
|
721
738
|
});
|
|
739
|
+
program
|
|
740
|
+
.command("mcp")
|
|
741
|
+
.description("Start MCP server for semantic code retrieval (stdio transport)")
|
|
742
|
+
.option("-c, --config <path>", "path to config file")
|
|
743
|
+
.action(async (options) => {
|
|
744
|
+
try {
|
|
745
|
+
const { runMcpServer } = await import("./mcp/cli.js");
|
|
746
|
+
await runMcpServer({
|
|
747
|
+
configPath: options.config,
|
|
748
|
+
cwd: process.cwd(),
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
catch (err) {
|
|
752
|
+
const message = err.message || String(err);
|
|
753
|
+
const logFilePath = path.resolve(process.cwd(), ".opencode", "opencode-rag.log");
|
|
754
|
+
logCliError(logFilePath, "mcp", `\nMCP server failed: ${message}`, err);
|
|
755
|
+
process.exit(1);
|
|
756
|
+
}
|
|
757
|
+
});
|
|
722
758
|
function generateDefaultConfigJson() {
|
|
723
759
|
return JSON.stringify({
|
|
724
760
|
embedding: {
|
|
@@ -762,6 +798,9 @@ function generateDefaultConfigJson() {
|
|
|
762
798
|
maxTokens: DEFAULT_CONFIG.openCode.autoInject.maxTokens,
|
|
763
799
|
},
|
|
764
800
|
},
|
|
801
|
+
mcp: {
|
|
802
|
+
enabled: DEFAULT_CONFIG.mcp.enabled,
|
|
803
|
+
},
|
|
765
804
|
logging: {
|
|
766
805
|
level: DEFAULT_CONFIG.logging.level,
|
|
767
806
|
logFilePath: DEFAULT_CONFIG.logging.logFilePath,
|
|
@@ -964,7 +1003,7 @@ if (shouldAutoRunCli(import.meta.url, process.argv[1])) {
|
|
|
964
1003
|
else {
|
|
965
1004
|
// Fallback: if the module appears to be running as a CLI (has argv with commands like 'init', 'index', etc.)
|
|
966
1005
|
// and not being imported as a library, parse the arguments anyway
|
|
967
|
-
const commands = ['init', 'index', 'query', 'clear', 'status', 'list', 'show', 'dump', 'ui'];
|
|
1006
|
+
const commands = ['init', 'index', 'query', 'clear', 'status', 'list', 'show', 'dump', 'ui', 'mcp'];
|
|
968
1007
|
const cmd = process.argv[2];
|
|
969
1008
|
if (process.argv.length > 2 && cmd && commands.includes(cmd.toLowerCase())) {
|
|
970
1009
|
void program.parseAsync(process.argv);
|