opencode-rag-plugin 1.23.3 → 2.0.0
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/cli/commands/init-helpers.d.ts +2 -0
- package/dist/cli/commands/init-helpers.js +2 -2
- package/dist/index.d.ts +2 -10
- package/dist/index.js +1 -7
- package/dist/opencode/create-read-tool.js +2 -2
- package/dist/opencode/tools.js +7 -7
- package/dist/plugin-entry.d.ts +10 -12
- package/dist/plugin-entry.js +22 -8
- package/dist/plugin.js +1 -1
- package/dist/tui.d.ts +85 -2
- package/dist/tui.js +316 -375
- package/dist/v2/v2-adapter.d.ts +103 -0
- package/dist/v2/v2-adapter.js +226 -0
- package/dist/web/ui/assets/ScatterPlot3D-CKwyh1Ec.js +4108 -0
- package/dist/web/ui/assets/index-Cgv1RsGv.js +4 -0
- package/dist/web/ui/assets/index-DjJHIo9R.css +1 -0
- package/dist/web/ui/assets/vendor-Dg8wMT7C.js +1 -0
- package/dist/web/ui/index.html +3 -3
- package/package.json +16 -11
- package/dist/web/ui/assets/ScatterPlot3D-DQLl3sKN.js +0 -4116
- package/dist/web/ui/assets/index-BZh9MitV.js +0 -4
- package/dist/web/ui/assets/index-DKhjGsql.css +0 -1
- package/dist/web/ui/assets/vendor-Dy7HKFCY.js +0 -1
|
@@ -46,6 +46,8 @@ export declare function removeStaleGlobalPluginRegistrations(homeDir: string, pl
|
|
|
46
46
|
* Generate the content for `.opencode/plugins/rag-plugin.js`.
|
|
47
47
|
*
|
|
48
48
|
* This file re-exports the plugin from the workspace-local node_modules.
|
|
49
|
+
* The plugin entry default-exports the OpenCode V2 module shape
|
|
50
|
+
* (`{ id, setup }`), so a bare default re-export is all that is needed.
|
|
49
51
|
*
|
|
50
52
|
* @param packageName - The npm package name of the RAG plugin.
|
|
51
53
|
* @returns The JavaScript source code for the plugin entry file.
|
|
@@ -137,6 +137,8 @@ export function removeStaleGlobalPluginRegistrations(homeDir, pluginName) {
|
|
|
137
137
|
* Generate the content for `.opencode/plugins/rag-plugin.js`.
|
|
138
138
|
*
|
|
139
139
|
* This file re-exports the plugin from the workspace-local node_modules.
|
|
140
|
+
* The plugin entry default-exports the OpenCode V2 module shape
|
|
141
|
+
* (`{ id, setup }`), so a bare default re-export is all that is needed.
|
|
140
142
|
*
|
|
141
143
|
* @param packageName - The npm package name of the RAG plugin.
|
|
142
144
|
* @returns The JavaScript source code for the plugin entry file.
|
|
@@ -144,8 +146,6 @@ export function removeStaleGlobalPluginRegistrations(homeDir, pluginName) {
|
|
|
144
146
|
export function generateWorkspacePluginFile(packageName) {
|
|
145
147
|
return [
|
|
146
148
|
`import plugin from "../node_modules/${packageName}/dist/plugin-entry.js";`,
|
|
147
|
-
`export const id = plugin.id;`,
|
|
148
|
-
`export const server = plugin.server;`,
|
|
149
149
|
`export default plugin;`,
|
|
150
150
|
"",
|
|
151
151
|
].join("\n");
|
package/dist/index.d.ts
CHANGED
|
@@ -28,13 +28,5 @@ export type { SearchOptions, IndexOptions, ContextResult, ConfigValidationResult
|
|
|
28
28
|
/** Version check and self-update API. */
|
|
29
29
|
export { checkForUpdate, getCurrentVersion, installLatestUpdate, compareVersions } from "./core/version-check.js";
|
|
30
30
|
export type { UpdateInfo, InstallUpdateResult } from "./core/version-check.js";
|
|
31
|
-
/**
|
|
32
|
-
export
|
|
33
|
-
/** Unique identifier for the OpenCodeRAG plugin. */
|
|
34
|
-
export declare const id = "opencode-rag-plugin";
|
|
35
|
-
/** Default export conforming to OpenCode's plugin module signature. */
|
|
36
|
-
declare const _default: {
|
|
37
|
-
id: string;
|
|
38
|
-
server: import("@opencode-ai/plugin").Plugin;
|
|
39
|
-
};
|
|
40
|
-
export default _default;
|
|
31
|
+
/** Plugin entry — only importable inside OpenCode's runtime. */
|
|
32
|
+
export { id, default } from "./plugin-entry.js";
|
package/dist/index.js
CHANGED
|
@@ -24,11 +24,5 @@ export { search, indexWorkspace, getContext, validateConfig, scanWorkspace, getI
|
|
|
24
24
|
/** Version check and self-update API. */
|
|
25
25
|
export { checkForUpdate, getCurrentVersion, installLatestUpdate, compareVersions } from "./core/version-check.js";
|
|
26
26
|
/** Plugin entry — only importable inside OpenCode's runtime. */
|
|
27
|
-
|
|
28
|
-
/** The plugin server configuration object, used to register OpenCodeRAG as an OpenCode plugin. */
|
|
29
|
-
export const server = ragPlugin;
|
|
30
|
-
/** Unique identifier for the OpenCodeRAG plugin. */
|
|
31
|
-
export const id = "opencode-rag-plugin";
|
|
32
|
-
/** Default export conforming to OpenCode's plugin module signature. */
|
|
33
|
-
export default { id, server: ragPlugin };
|
|
27
|
+
export { id, default } from "./plugin-entry.js";
|
|
34
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -38,7 +38,7 @@ export function createRagReadTool(options) {
|
|
|
38
38
|
query: tool.schema.string().optional(),
|
|
39
39
|
reason: tool.schema.string().optional(),
|
|
40
40
|
},
|
|
41
|
-
async execute(args,
|
|
41
|
+
async execute(args, _context) {
|
|
42
42
|
let resolvedPath;
|
|
43
43
|
let normalized;
|
|
44
44
|
try {
|
|
@@ -52,7 +52,7 @@ export function createRagReadTool(options) {
|
|
|
52
52
|
let ragChunks = [];
|
|
53
53
|
let relatedFiles = [];
|
|
54
54
|
try {
|
|
55
|
-
const sessionID =
|
|
55
|
+
const sessionID = _context?.sessionID;
|
|
56
56
|
const messageText = sessionID ? sessionLastMessage?.get(sessionID) ?? "" : "";
|
|
57
57
|
const count = await store.count();
|
|
58
58
|
if (count > 0) {
|
package/dist/opencode/tools.js
CHANGED
|
@@ -202,7 +202,7 @@ export function createFileSkeletonTool(options) {
|
|
|
202
202
|
args: {
|
|
203
203
|
filePath: tool.schema.string().min(1, "A file path is required."),
|
|
204
204
|
},
|
|
205
|
-
async execute(args) {
|
|
205
|
+
async execute(args, _context) {
|
|
206
206
|
try {
|
|
207
207
|
const resolvedPath = resolveFilePath(args.filePath, worktree);
|
|
208
208
|
const content = readFileSync(resolvedPath, "utf-8");
|
|
@@ -266,7 +266,7 @@ export function createDescribeImageTool(options) {
|
|
|
266
266
|
filePath: tool.schema.string().min(1, "An image file path is required."),
|
|
267
267
|
systemPrompt: tool.schema.string().optional(),
|
|
268
268
|
},
|
|
269
|
-
async execute(args) {
|
|
269
|
+
async execute(args, _context) {
|
|
270
270
|
try {
|
|
271
271
|
const { existsSync, readFileSync } = await import("node:fs");
|
|
272
272
|
const path = await import("node:path");
|
|
@@ -396,7 +396,7 @@ export function createFindUsagesTool(options) {
|
|
|
396
396
|
pathHint: tool.schema.string().optional(),
|
|
397
397
|
topK: tool.schema.number().int().min(1).max(50).optional(),
|
|
398
398
|
},
|
|
399
|
-
async execute(args) {
|
|
399
|
+
async execute(args, _context) {
|
|
400
400
|
const symbolName = args.symbolName.trim();
|
|
401
401
|
const topK = args.topK ?? 30;
|
|
402
402
|
try {
|
|
@@ -527,7 +527,7 @@ export function createRecallQuirksTool(options) {
|
|
|
527
527
|
quirkType: tool.schema.string().optional(),
|
|
528
528
|
tags: tool.schema.array(tool.schema.string().min(1)).max(10).optional(),
|
|
529
529
|
},
|
|
530
|
-
async execute(args) {
|
|
530
|
+
async execute(args, _context) {
|
|
531
531
|
try {
|
|
532
532
|
const deps = { embedder, store, keywordIndex, cfg, storePath };
|
|
533
533
|
const results = await recallQuirks(deps, args.query, {
|
|
@@ -599,7 +599,7 @@ export function createAddQuirkTool(options) {
|
|
|
599
599
|
tags: tool.schema.array(tool.schema.string().min(1)).max(10).optional(),
|
|
600
600
|
sourceRef: tool.schema.string().optional(),
|
|
601
601
|
},
|
|
602
|
-
async execute(args) {
|
|
602
|
+
async execute(args, _context) {
|
|
603
603
|
try {
|
|
604
604
|
const deps = { embedder, store, keywordIndex, cfg, storePath };
|
|
605
605
|
const quirk = await addQuirk(deps, {
|
|
@@ -655,7 +655,7 @@ export function createUpdateQuirkTool(options) {
|
|
|
655
655
|
confidence: tool.schema.number().min(0).max(1).optional(),
|
|
656
656
|
sourceRef: tool.schema.string().optional(),
|
|
657
657
|
},
|
|
658
|
-
async execute(args) {
|
|
658
|
+
async execute(args, _context) {
|
|
659
659
|
try {
|
|
660
660
|
const deps = { embedder, store, keywordIndex, cfg, storePath };
|
|
661
661
|
const fields = [
|
|
@@ -722,7 +722,7 @@ export function createDeleteQuirkTool(options) {
|
|
|
722
722
|
args: {
|
|
723
723
|
id: tool.schema.string().min(1, "Quirk ID is required."),
|
|
724
724
|
},
|
|
725
|
-
async execute(args) {
|
|
725
|
+
async execute(args, _context) {
|
|
726
726
|
try {
|
|
727
727
|
const deps = { embedder, store, keywordIndex, cfg, storePath };
|
|
728
728
|
await removeQuirk(deps, args.id);
|
package/dist/plugin-entry.d.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
3
|
-
*
|
|
2
|
+
* @fileoverview OpenCode plugin entry point.
|
|
3
|
+
*
|
|
4
|
+
* OpenCode V2 entrypoint: default export `Plugin.define({ id, setup })` —
|
|
5
|
+
* `setup(ctx)` registers the RAG tools/hooks through the V2 context adapter
|
|
6
|
+
* and returns a cleanup function for plugin unload. OpenCode 1.x support has
|
|
7
|
+
* been dropped (v2.0.0); the V1 `ragPlugin` factory remains the single source
|
|
8
|
+
* of truth for RAG logic (config, store, embedder, indexer, auto-update) and is
|
|
9
|
+
* re-registered as V2 transforms/hooks by src/v2/v2-adapter.ts.
|
|
4
10
|
*/
|
|
11
|
+
import { Plugin } from "@opencode/plugin";
|
|
5
12
|
/** Unique identifier for the OpenCodeRAG plugin. */
|
|
6
13
|
export declare const id = "opencode-rag-plugin";
|
|
7
|
-
|
|
8
|
-
export declare const server: import("@opencode-ai/plugin").Plugin;
|
|
9
|
-
/**
|
|
10
|
-
* Default export conforming to OpenCode's plugin module signature.
|
|
11
|
-
* OpenCode discovers plugins by importing this default export.
|
|
12
|
-
*/
|
|
13
|
-
declare const _default: {
|
|
14
|
-
id: string;
|
|
15
|
-
server: import("@opencode-ai/plugin").Plugin;
|
|
16
|
-
};
|
|
14
|
+
declare const _default: Plugin.Plugin;
|
|
17
15
|
export default _default;
|
package/dist/plugin-entry.js
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
3
|
-
*
|
|
2
|
+
* @fileoverview OpenCode plugin entry point.
|
|
3
|
+
*
|
|
4
|
+
* OpenCode V2 entrypoint: default export `Plugin.define({ id, setup })` —
|
|
5
|
+
* `setup(ctx)` registers the RAG tools/hooks through the V2 context adapter
|
|
6
|
+
* and returns a cleanup function for plugin unload. OpenCode 1.x support has
|
|
7
|
+
* been dropped (v2.0.0); the V1 `ragPlugin` factory remains the single source
|
|
8
|
+
* of truth for RAG logic (config, store, embedder, indexer, auto-update) and is
|
|
9
|
+
* re-registered as V2 transforms/hooks by src/v2/v2-adapter.ts.
|
|
4
10
|
*/
|
|
5
|
-
import {
|
|
11
|
+
import { Plugin } from "@opencode/plugin";
|
|
12
|
+
import { registerRagPluginV2 } from "./v2/v2-adapter.js";
|
|
6
13
|
/** Unique identifier for the OpenCodeRAG plugin. */
|
|
7
14
|
export const id = "opencode-rag-plugin";
|
|
8
|
-
/** Plugin server hooks — the ragPlugin factory registered with OpenCode's plugin system. */
|
|
9
|
-
export const server = ragPlugin;
|
|
10
15
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
16
|
+
* V2 `setup`: run the V1 factory for this location and re-register the
|
|
17
|
+
* returned hooks as V2 transforms/hooks. Returns a cleanup function for
|
|
18
|
+
* plugin unload.
|
|
13
19
|
*/
|
|
14
|
-
|
|
20
|
+
async function setup(ctx) {
|
|
21
|
+
return registerRagPluginV2(ctx);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Default export. `Plugin.define` is the documented V2 entrypoint (identity —
|
|
25
|
+
* it returns the object unchanged).
|
|
26
|
+
*/
|
|
27
|
+
const definition = { id, setup };
|
|
28
|
+
export default Plugin.define(definition);
|
|
15
29
|
//# sourceMappingURL=plugin-entry.js.map
|
package/dist/plugin.js
CHANGED
|
@@ -474,7 +474,7 @@ export function createRagHooks(options) {
|
|
|
474
474
|
topK: tool.schema.number().int().min(1).max(25).optional(),
|
|
475
475
|
explain: tool.schema.boolean().optional(),
|
|
476
476
|
},
|
|
477
|
-
async execute(args) {
|
|
477
|
+
async execute(args, _context) {
|
|
478
478
|
try {
|
|
479
479
|
const count = await store.count();
|
|
480
480
|
if (count === 0) {
|
package/dist/tui.d.ts
CHANGED
|
@@ -2,13 +2,96 @@
|
|
|
2
2
|
* @fileoverview OpenCode TUI (Terminal UI) plugin: renders a sidebar with RAG status,
|
|
3
3
|
* settings dialog for editing config values, and model selection picker.
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
5
|
+
import type { JSX } from "@opentui/solid";
|
|
6
|
+
/**
|
|
7
|
+
* Structural subset of the OpenCode V2 TUI plugin context
|
|
8
|
+
* (`@opencode/plugin/tui`). Declared locally so this module compiles
|
|
9
|
+
* without depending on V2 type resolution; see `src/v2/v2-adapter.ts`
|
|
10
|
+
* for the server-side equivalent.
|
|
11
|
+
*/
|
|
12
|
+
type V2TuiContext = {
|
|
13
|
+
location?: {
|
|
14
|
+
directory?: string;
|
|
15
|
+
} | undefined;
|
|
16
|
+
app?: {
|
|
17
|
+
version?: string;
|
|
18
|
+
} | undefined;
|
|
19
|
+
theme?: unknown;
|
|
20
|
+
renderer?: unknown;
|
|
21
|
+
data?: {
|
|
22
|
+
provider?: {
|
|
23
|
+
list?: () => readonly unknown[] | undefined;
|
|
24
|
+
};
|
|
25
|
+
model?: {
|
|
26
|
+
list?: () => readonly unknown[] | undefined;
|
|
27
|
+
};
|
|
28
|
+
} | undefined;
|
|
29
|
+
ui?: {
|
|
30
|
+
slot: (claim: {
|
|
31
|
+
append: string;
|
|
32
|
+
render: (input: {
|
|
33
|
+
sessionID?: string;
|
|
34
|
+
}) => JSX.Element;
|
|
35
|
+
}) => () => void;
|
|
36
|
+
dialog: {
|
|
37
|
+
select: <Value>(options: {
|
|
38
|
+
title: string;
|
|
39
|
+
placeholder?: string;
|
|
40
|
+
options: readonly {
|
|
41
|
+
title: string;
|
|
42
|
+
value: Value;
|
|
43
|
+
description?: string;
|
|
44
|
+
}[];
|
|
45
|
+
}) => Promise<Value | undefined>;
|
|
46
|
+
prompt: (options: {
|
|
47
|
+
title: string;
|
|
48
|
+
placeholder?: string;
|
|
49
|
+
value?: string;
|
|
50
|
+
}) => Promise<string | undefined>;
|
|
51
|
+
clear: () => void;
|
|
52
|
+
};
|
|
53
|
+
toast: {
|
|
54
|
+
show: (options: {
|
|
55
|
+
title?: string;
|
|
56
|
+
message: string;
|
|
57
|
+
variant?: string;
|
|
58
|
+
}) => void;
|
|
59
|
+
};
|
|
60
|
+
} | undefined;
|
|
61
|
+
keymap?: {
|
|
62
|
+
layer: (input: () => {
|
|
63
|
+
mode?: string;
|
|
64
|
+
priority?: number;
|
|
65
|
+
commands: readonly {
|
|
66
|
+
id: string;
|
|
67
|
+
title?: string;
|
|
68
|
+
bind?: string;
|
|
69
|
+
run: (input?: string) => void;
|
|
70
|
+
}[];
|
|
71
|
+
bindings: readonly string[];
|
|
72
|
+
}) => void;
|
|
73
|
+
dispatch: (id: string, input?: string) => void;
|
|
74
|
+
} | undefined;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* OpenCode V2 entrypoint — satisfies the V2 default-export schema
|
|
78
|
+
* (`{id, setup}`), which the server-role loader validates (OpenCode ≥ 2.x
|
|
79
|
+
* rejects `{id, tui}`-only modules with `err_*` "Plugin must export a default
|
|
80
|
+
* definition with an id and an effect or setup function").
|
|
81
|
+
*
|
|
82
|
+
* The server role calls this with a server context (no `ui`/`keymap`) → no-op.
|
|
83
|
+
* The TUI role calls it with the V2 TUI context → registers the sidebar slot,
|
|
84
|
+
* keybindings, and the settings dialog. Returns a cleanup that unclaims the slot.
|
|
85
|
+
*/
|
|
86
|
+
declare function setup(context: V2TuiContext): Promise<(() => void) | undefined>;
|
|
6
87
|
/**
|
|
7
88
|
* The OpenCodeRAG TUI plugin module.
|
|
8
89
|
* Registers sidebar panels, keybindings, and the settings dialog with OpenCode's
|
|
9
90
|
* terminal UI framework.
|
|
10
91
|
*/
|
|
11
|
-
declare const plugin:
|
|
92
|
+
declare const plugin: {
|
|
12
93
|
id: string;
|
|
94
|
+
/** V2 entrypoint (schema `{id, setup}`); no-op under the server role, TUI registration under the TUI role. */
|
|
95
|
+
setup: typeof setup;
|
|
13
96
|
};
|
|
14
97
|
export default plugin;
|