opencode-mem 2.12.1 → 2.14.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/README.md +13 -3
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +43 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -20
- package/dist/plugin.d.ts +6 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +3 -2
- package/dist/services/ai/opencode-provider.d.ts +31 -25
- package/dist/services/ai/opencode-provider.d.ts.map +1 -1
- package/dist/services/ai/opencode-provider.js +76 -222
- package/dist/services/ai/providers/openai-chat-completion.d.ts +6 -5
- package/dist/services/ai/providers/openai-chat-completion.d.ts.map +1 -1
- package/dist/services/ai/providers/openai-chat-completion.js +56 -15
- package/dist/services/api-handlers.d.ts.map +1 -1
- package/dist/services/api-handlers.js +8 -3
- package/dist/services/auto-capture.js +8 -5
- package/dist/services/client.d.ts +3 -2
- package/dist/services/client.d.ts.map +1 -1
- package/dist/services/client.js +14 -8
- package/dist/services/embedding.d.ts.map +1 -1
- package/dist/services/embedding.js +28 -6
- package/dist/services/language-detector.d.ts.map +1 -1
- package/dist/services/language-detector.js +20 -3
- package/dist/services/sqlite/vector-search.d.ts.map +1 -1
- package/dist/services/sqlite/vector-search.js +15 -4
- package/dist/services/user-memory-learning.js +8 -5
- package/package.json +14 -7
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ The plugin downloads automatically on next startup.
|
|
|
53
53
|
```typescript
|
|
54
54
|
memory({ mode: "add", content: "Project uses microservices architecture" });
|
|
55
55
|
memory({ mode: "search", query: "architecture decisions" });
|
|
56
|
+
memory({ mode: "search", query: "architecture decisions", scope: "all-projects" });
|
|
56
57
|
memory({ mode: "profile" });
|
|
57
58
|
memory({ mode: "list", limit: 10 });
|
|
58
59
|
```
|
|
@@ -69,6 +70,9 @@ Configure at `~/.config/opencode/opencode-mem.jsonc`:
|
|
|
69
70
|
"userEmailOverride": "user@example.com",
|
|
70
71
|
"userNameOverride": "John Doe",
|
|
71
72
|
"embeddingModel": "Xenova/nomic-embed-text-v1",
|
|
73
|
+
"memory": {
|
|
74
|
+
"defaultScope": "project",
|
|
75
|
+
},
|
|
72
76
|
"webServerEnabled": true,
|
|
73
77
|
"webServerPort": 4747,
|
|
74
78
|
|
|
@@ -99,18 +103,24 @@ Configure at `~/.config/opencode/opencode-mem.jsonc`:
|
|
|
99
103
|
}
|
|
100
104
|
```
|
|
101
105
|
|
|
106
|
+
### Memory Scope
|
|
107
|
+
|
|
108
|
+
- `scope: "project"`: query only the current project. This is the default.
|
|
109
|
+
- `scope: "all-projects"`: query `search` / `list` across all project shards.
|
|
110
|
+
- `memory.defaultScope` sets the default query scope when no explicit scope is provided.
|
|
111
|
+
|
|
102
112
|
### Auto-Capture AI Provider
|
|
103
113
|
|
|
104
|
-
**Recommended:** Use
|
|
114
|
+
**Recommended:** Use any provider that is already authenticated in opencode (no separate API key needed in this plugin):
|
|
105
115
|
|
|
106
116
|
```jsonc
|
|
107
117
|
"opencodeProvider": "anthropic",
|
|
108
118
|
"opencodeModel": "claude-haiku-4-5-20251001",
|
|
109
119
|
```
|
|
110
120
|
|
|
111
|
-
|
|
121
|
+
The plugin issues structured-output requests to opencode's session API instead of calling provider endpoints directly, so opencode owns the auth, token refresh, and provider routing. Whatever you configured in opencode just works — Claude Pro/Max via OAuth, GitHub Copilot (personal & business), OpenAI / Anthropic API keys, custom providers, etc.
|
|
112
122
|
|
|
113
|
-
Supported providers: `anthropic`, `openai`
|
|
123
|
+
Supported providers: any provider listed by `opencode providers list` (e.g. `anthropic`, `openai`, `github-copilot`, ...).
|
|
114
124
|
|
|
115
125
|
**Fallback:** Manual API configuration (if not using opencodeProvider):
|
|
116
126
|
|
package/dist/config.d.ts
CHANGED
|
@@ -42,6 +42,9 @@ export declare let CONFIG: {
|
|
|
42
42
|
showAutoCaptureToasts: boolean;
|
|
43
43
|
showUserProfileToasts: boolean;
|
|
44
44
|
showErrorToasts: boolean;
|
|
45
|
+
memory: {
|
|
46
|
+
defaultScope: "project" | "all-projects" | undefined;
|
|
47
|
+
};
|
|
45
48
|
compaction: {
|
|
46
49
|
enabled: boolean | undefined;
|
|
47
50
|
memoryLimit: number | undefined;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AA2jBA,eAAO,IAAI,MAAM;;;;;;;;;;;;;;;;;oBA3DT,aAAa,GACb,kBAAkB,GAClB,WAAW;;;;;;;;mBASX,eAAe,GACf,SAAS,GACT,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAuCV,OAAO,GACP,QAAQ;;CAMgC,CAAC;AAEnD,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CASlD;AAED,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
|
package/dist/config.js
CHANGED
|
@@ -46,6 +46,9 @@ const DEFAULTS = {
|
|
|
46
46
|
showAutoCaptureToasts: true,
|
|
47
47
|
showUserProfileToasts: true,
|
|
48
48
|
showErrorToasts: true,
|
|
49
|
+
memory: {
|
|
50
|
+
defaultScope: "project",
|
|
51
|
+
},
|
|
49
52
|
compaction: {
|
|
50
53
|
enabled: true,
|
|
51
54
|
memoryLimit: 10,
|
|
@@ -144,21 +147,36 @@ const CONFIG_TEMPLATE = `{
|
|
|
144
147
|
// Similarity threshold (0-1) for detecting duplicates (higher = stricter)
|
|
145
148
|
"deduplicationSimilarityThreshold": 0.90,
|
|
146
149
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
// ============================================
|
|
151
|
+
// Memory Scope Settings
|
|
152
|
+
// ============================================
|
|
153
|
+
|
|
154
|
+
// Default scope for memory list/search queries
|
|
155
|
+
// "project" keeps queries within the current project, "all-projects" searches across all project shards
|
|
156
|
+
"memory": {
|
|
157
|
+
"defaultScope": "project"
|
|
158
|
+
},
|
|
150
159
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
160
|
+
// ============================================
|
|
161
|
+
// OpenCode Provider Settings (RECOMMENDED)
|
|
162
|
+
// ============================================
|
|
163
|
+
|
|
164
|
+
// Use any provider that is already authenticated in opencode for auto-capture
|
|
165
|
+
// and user profile learning. The plugin calls opencode's session.prompt API
|
|
166
|
+
// (with structured output) instead of talking to provider HTTPS endpoints
|
|
167
|
+
// directly, so opencode owns the auth, token refresh, and provider routing.
|
|
168
|
+
//
|
|
169
|
+
// No separate API key is needed in this plugin — whatever you configured in
|
|
170
|
+
// opencode (OAuth like Claude Pro/Max, GitHub Copilot personal/business,
|
|
171
|
+
// bring-your-own API key, custom provider, ...) just works.
|
|
154
172
|
//
|
|
155
173
|
// If NOT set, falls back to the manual config (memoryApiKey/memoryApiUrl/memoryModel below).
|
|
156
174
|
//
|
|
157
|
-
// Examples:
|
|
158
|
-
// Anthropic (OAuth/API key): "opencodeProvider": "anthropic",
|
|
159
|
-
// OpenAI (API key): "opencodeProvider": "openai",
|
|
175
|
+
// Examples (the provider name must be one returned by 'opencode providers list'):
|
|
176
|
+
// Anthropic (OAuth/API key): "opencodeProvider": "anthropic", "opencodeModel": "claude-haiku-4-5-20251001"
|
|
177
|
+
// OpenAI (API key): "opencodeProvider": "openai", "opencodeModel": "gpt-4o-mini"
|
|
178
|
+
// GitHub Copilot: "opencodeProvider": "github-copilot", "opencodeModel": "gpt-4o-mini"
|
|
160
179
|
//
|
|
161
|
-
// The provider name must match a connected provider in opencode (check with: opencode providers list)
|
|
162
180
|
// "opencodeProvider": "anthropic",
|
|
163
181
|
// "opencodeModel": "claude-haiku-4-5-20251001",
|
|
164
182
|
|
|
@@ -173,6 +191,8 @@ const CONFIG_TEMPLATE = `{
|
|
|
173
191
|
"autoCaptureEnabled": true,
|
|
174
192
|
|
|
175
193
|
// Provider type: "openai-chat" | "openai-responses" | "anthropic"
|
|
194
|
+
// Note: "openai-chat" is a generic OpenAI API-compatible mode.
|
|
195
|
+
// Any service that follows the OpenAI Chat Completions API can use it via custom "memoryApiUrl".
|
|
176
196
|
"memoryProvider": "openai-chat",
|
|
177
197
|
|
|
178
198
|
// REQUIRED for auto-capture (all 3 must be set):
|
|
@@ -186,11 +206,21 @@ const CONFIG_TEMPLATE = `{
|
|
|
186
206
|
// From env variable: "env://LITELLM_API_KEY"
|
|
187
207
|
|
|
188
208
|
// Examples for different providers:
|
|
209
|
+
// Any OpenAI-compatible endpoint can use the "openai-chat" provider pattern below.
|
|
210
|
+
// Common examples: DeepSeek, Qwen (via Alibaba Cloud ModelStudio),
|
|
211
|
+
// Zhipu GLM (BigModel platform), and Kimi (Moonshot AI platform).
|
|
212
|
+
|
|
189
213
|
// OpenAI Chat Completion (default, backward compatible):
|
|
190
214
|
// "memoryProvider": "openai-chat"
|
|
191
215
|
// "memoryModel": "gpt-4o-mini"
|
|
192
216
|
// "memoryApiUrl": "https://api.openai.com/v1"
|
|
193
217
|
// "memoryApiKey": "sk-..."
|
|
218
|
+
|
|
219
|
+
// DeepSeek (OpenAI-compatible example):
|
|
220
|
+
// "memoryProvider": "openai-chat"
|
|
221
|
+
// "memoryModel": "deepseek-chat"
|
|
222
|
+
// "memoryApiUrl": "https://api.deepseek.com/v1"
|
|
223
|
+
// "memoryApiKey": "sk-..."
|
|
194
224
|
|
|
195
225
|
// OpenAI Responses API (recommended, with session support):
|
|
196
226
|
// "memoryProvider": "openai-responses"
|
|
@@ -394,6 +424,9 @@ function buildConfig(fileConfig) {
|
|
|
394
424
|
showAutoCaptureToasts: fileConfig.showAutoCaptureToasts ?? DEFAULTS.showAutoCaptureToasts,
|
|
395
425
|
showUserProfileToasts: fileConfig.showUserProfileToasts ?? DEFAULTS.showUserProfileToasts,
|
|
396
426
|
showErrorToasts: fileConfig.showErrorToasts ?? DEFAULTS.showErrorToasts,
|
|
427
|
+
memory: {
|
|
428
|
+
defaultScope: fileConfig.memory?.defaultScope ?? DEFAULTS.memory.defaultScope,
|
|
429
|
+
},
|
|
397
430
|
compaction: {
|
|
398
431
|
enabled: fileConfig.compaction?.enabled ?? DEFAULTS.compaction.enabled,
|
|
399
432
|
memoryLimit: fileConfig.compaction?.memoryLimit ?? DEFAULTS.compaction.memoryLimit,
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAmB/D,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAmB/D,eAAO,MAAM,iBAAiB,EAAE,MA4hB/B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,6 @@ import { startWebServer, WebServer } from "./services/web-server.js";
|
|
|
10
10
|
import { isConfigured, CONFIG, initConfig } from "./config.js";
|
|
11
11
|
import { log } from "./services/logger.js";
|
|
12
12
|
import { getLanguageName } from "./services/language-detector.js";
|
|
13
|
-
import { setStatePath, setConnectedProviders } from "./services/ai/opencode-provider.js";
|
|
14
13
|
export const OpenCodeMemPlugin = async (ctx) => {
|
|
15
14
|
const { directory } = ctx;
|
|
16
15
|
initConfig(directory);
|
|
@@ -21,22 +20,23 @@ export const OpenCodeMemPlugin = async (ctx) => {
|
|
|
21
20
|
}
|
|
22
21
|
const GLOBAL_PLUGIN_WARMUP_KEY = Symbol.for("opencode-mem.plugin.warmedup");
|
|
23
22
|
if (!globalThis[GLOBAL_PLUGIN_WARMUP_KEY] && isConfigured()) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
// Fire-and-forget: warmup is slow (embedding model load + index rebuild).
|
|
24
|
+
// Awaiting it here serializes opencode's plugin loader and starves the TUI,
|
|
25
|
+
// which gave the symptom "opencode hangs ~70s then disconnects on startup".
|
|
26
|
+
(async () => {
|
|
27
|
+
try {
|
|
28
|
+
await memoryClient.warmup();
|
|
29
|
+
globalThis[GLOBAL_PLUGIN_WARMUP_KEY] = true;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
log("Plugin warmup failed", { error: String(error) });
|
|
33
|
+
}
|
|
34
|
+
})();
|
|
31
35
|
}
|
|
32
|
-
// Wire opencode state path and provider list — fire-and-forget to avoid blocking init
|
|
33
|
-
// These calls can hang if opencode isn't fully bootstrapped yet
|
|
34
36
|
(async () => {
|
|
35
37
|
try {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
setStatePath(pathResult.data.state);
|
|
39
|
-
}
|
|
38
|
+
const { setConnectedProviders, setV2Client, createV2Client } = await import("./services/ai/opencode-provider.js");
|
|
39
|
+
setV2Client(createV2Client(ctx.serverUrl));
|
|
40
40
|
const providerResult = await ctx.client.provider.list();
|
|
41
41
|
if (providerResult.data?.connected) {
|
|
42
42
|
setConnectedProviders(providerResult.data.connected);
|
|
@@ -207,7 +207,7 @@ export const OpenCodeMemPlugin = async (ctx) => {
|
|
|
207
207
|
},
|
|
208
208
|
tool: {
|
|
209
209
|
memory: tool({
|
|
210
|
-
description: `Manage and query project memory (MATCH USER LANGUAGE: ${getLanguageName(CONFIG.autoCaptureLanguage || "en")}). Use 'search' with technical keywords/tags, 'add' to store knowledge, 'profile' for preferences.`,
|
|
210
|
+
description: `Manage and query project memory (MATCH USER LANGUAGE: ${getLanguageName(CONFIG.autoCaptureLanguage || "en")}). Use 'search' with technical keywords/tags, 'add' to store knowledge, 'profile' for preferences. Search/list scope: project or all-projects.`,
|
|
211
211
|
args: {
|
|
212
212
|
mode: tool.schema.enum(["add", "search", "profile", "list", "forget", "help"]).optional(),
|
|
213
213
|
content: tool.schema.string().optional(),
|
|
@@ -216,6 +216,7 @@ export const OpenCodeMemPlugin = async (ctx) => {
|
|
|
216
216
|
type: tool.schema.string().optional(),
|
|
217
217
|
memoryId: tool.schema.string().optional(),
|
|
218
218
|
limit: tool.schema.number().optional(),
|
|
219
|
+
scope: tool.schema.enum(["project", "all-projects"]).optional(),
|
|
219
220
|
},
|
|
220
221
|
async execute(args, toolCtx) {
|
|
221
222
|
if (!isConfigured()) {
|
|
@@ -247,7 +248,11 @@ export const OpenCodeMemPlugin = async (ctx) => {
|
|
|
247
248
|
description: `Search memories via keywords (MATCH USER LANGUAGE: ${langName})`,
|
|
248
249
|
args: ["query"],
|
|
249
250
|
},
|
|
250
|
-
{
|
|
251
|
+
{
|
|
252
|
+
command: "profile",
|
|
253
|
+
description: "View user profile or save an explicit preference (provide content to write)",
|
|
254
|
+
args: ["content?"],
|
|
255
|
+
},
|
|
251
256
|
{ command: "list", description: "List recent memories", args: ["limit?"] },
|
|
252
257
|
{ command: "forget", description: "Remove memory", args: ["memoryId"] },
|
|
253
258
|
],
|
|
@@ -282,13 +287,65 @@ export const OpenCodeMemPlugin = async (ctx) => {
|
|
|
282
287
|
case "search":
|
|
283
288
|
if (!args.query)
|
|
284
289
|
return JSON.stringify({ success: false, error: "query required" });
|
|
285
|
-
const searchRes = await memoryClient.searchMemories(args.query, tags.project.tag);
|
|
290
|
+
const searchRes = await memoryClient.searchMemories(args.query, tags.project.tag, args.scope ?? CONFIG.memory.defaultScope);
|
|
286
291
|
if (!searchRes.success)
|
|
287
292
|
return JSON.stringify({ success: false, error: searchRes.error });
|
|
288
293
|
return formatSearchResults(args.query, searchRes, args.limit);
|
|
289
|
-
case "profile":
|
|
294
|
+
case "profile": {
|
|
295
|
+
if (args.query) {
|
|
296
|
+
return JSON.stringify({
|
|
297
|
+
success: false,
|
|
298
|
+
error: "query is not valid for profile mode. Use content to write a preference or omit all args to read.",
|
|
299
|
+
});
|
|
300
|
+
}
|
|
290
301
|
const { userProfileManager } = await import("./services/user-profile/user-profile-manager.js");
|
|
291
|
-
const
|
|
302
|
+
const userId = tags.user.userEmail || "unknown";
|
|
303
|
+
// --- WRITE: explicit preference ---
|
|
304
|
+
if (args.content !== undefined) {
|
|
305
|
+
const trimmed = args.content.trim();
|
|
306
|
+
if (!trimmed) {
|
|
307
|
+
return JSON.stringify({ success: false, error: "content must not be blank" });
|
|
308
|
+
}
|
|
309
|
+
if (!tags.user.userEmail) {
|
|
310
|
+
return JSON.stringify({
|
|
311
|
+
success: false,
|
|
312
|
+
error: "Cannot save profile preference because no user email could be resolved. Configure userEmailOverride or git user.email.",
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
const sanitizedContent = stripPrivateContent(trimmed);
|
|
316
|
+
const hasNonPrivateContent = sanitizedContent.replace(/\[REDACTED\]/g, "").trim().length > 0;
|
|
317
|
+
if (isFullyPrivate(trimmed) || !hasNonPrivateContent) {
|
|
318
|
+
return JSON.stringify({ success: false, error: "Private content blocked" });
|
|
319
|
+
}
|
|
320
|
+
const newPreference = {
|
|
321
|
+
category: "explicit",
|
|
322
|
+
description: sanitizedContent,
|
|
323
|
+
confidence: 1.0,
|
|
324
|
+
evidence: ["manual-write"],
|
|
325
|
+
lastUpdated: Date.now(),
|
|
326
|
+
};
|
|
327
|
+
const existingProfile = userProfileManager.getActiveProfile(userId);
|
|
328
|
+
if (existingProfile) {
|
|
329
|
+
const existingData = JSON.parse(existingProfile.profileData);
|
|
330
|
+
const mergedData = userProfileManager.mergeProfileData(existingData, {
|
|
331
|
+
preferences: [newPreference],
|
|
332
|
+
});
|
|
333
|
+
userProfileManager.updateProfile(existingProfile.id, mergedData, 0, `Explicit preference added: ${sanitizedContent.slice(0, 80)}`);
|
|
334
|
+
return JSON.stringify({
|
|
335
|
+
success: true,
|
|
336
|
+
message: "Preference saved to profile",
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
userProfileManager.createProfile(userId, tags.user.displayName || userId, tags.user.userName || userId, tags.user.userEmail || userId, { preferences: [newPreference], patterns: [], workflows: [] }, 0);
|
|
341
|
+
return JSON.stringify({
|
|
342
|
+
success: true,
|
|
343
|
+
message: "Profile created with preference",
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
// --- READ: no content provided ---
|
|
348
|
+
const profile = userProfileManager.getActiveProfile(userId);
|
|
292
349
|
if (!profile)
|
|
293
350
|
return JSON.stringify({ success: true, profile: null });
|
|
294
351
|
const pData = JSON.parse(profile.profileData);
|
|
@@ -300,8 +357,9 @@ export const OpenCodeMemPlugin = async (ctx) => {
|
|
|
300
357
|
lastAnalyzed: profile.lastAnalyzedAt,
|
|
301
358
|
},
|
|
302
359
|
});
|
|
360
|
+
}
|
|
303
361
|
case "list":
|
|
304
|
-
const listRes = await memoryClient.listMemories(tags.project.tag, args.limit || 20);
|
|
362
|
+
const listRes = await memoryClient.listMemories(tags.project.tag, args.limit || 20, args.scope ?? CONFIG.memory.defaultScope);
|
|
305
363
|
if (!listRes.success)
|
|
306
364
|
return JSON.stringify({ success: false, error: listRes.error });
|
|
307
365
|
return JSON.stringify({
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
declare const OpenCodeMemPlugin: import("@opencode-ai/plugin").Plugin;
|
|
2
|
+
export declare const id: string;
|
|
3
3
|
export { OpenCodeMemPlugin };
|
|
4
|
-
|
|
4
|
+
declare const _default: {
|
|
5
|
+
id: string;
|
|
6
|
+
server: import("@opencode-ai/plugin").Plugin;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
5
9
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAEA,QAAA,MAAQ,iBAAiB,sCAA+B,CAAC;AAEzD,eAAO,MAAM,EAAE,QACqE,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,CAAC;;;;;AAC7B,wBAAwE"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import pkg from "../package.json";
|
|
2
2
|
const { OpenCodeMemPlugin } = await import("./index.js");
|
|
3
|
+
export const id = typeof pkg.name === "string" && pkg.name.trim() ? pkg.name.trim() : "opencode-mem";
|
|
3
4
|
export { OpenCodeMemPlugin };
|
|
4
|
-
export default OpenCodeMemPlugin;
|
|
5
|
+
export default { id, server: OpenCodeMemPlugin };
|
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type
|
|
13
|
-
|
|
14
|
-
export declare function getStatePath(): string;
|
|
1
|
+
/**
|
|
2
|
+
* SDK-based structured output via opencode v2 session.prompt.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the old auth.json/OAuth-juggling flow. Instead of forging requests
|
|
5
|
+
* to provider HTTP endpoints ourselves, we delegate to the running opencode
|
|
6
|
+
* server: it already owns the user's auth (any provider, including
|
|
7
|
+
* github-copilot personal/business), token refresh, and provider routing.
|
|
8
|
+
*
|
|
9
|
+
* Per call we create a transient session, prompt with a JSON schema, then
|
|
10
|
+
* delete the session so it does not pollute the user's TUI session list.
|
|
11
|
+
*/
|
|
12
|
+
import type { z } from "zod";
|
|
13
|
+
import { type OpencodeClient } from "@opencode-ai/sdk/v2/client";
|
|
15
14
|
export declare function setConnectedProviders(providers: string[]): void;
|
|
16
15
|
export declare function isProviderConnected(providerName: string): boolean;
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function
|
|
19
|
-
export declare function
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
export declare function setV2Client(client: OpencodeClient): void;
|
|
17
|
+
export declare function getV2Client(): OpencodeClient | undefined;
|
|
18
|
+
export declare function createV2Client(serverUrl: URL | string): OpencodeClient;
|
|
19
|
+
export interface StructuredOutputOptions<T> {
|
|
20
|
+
client: OpencodeClient;
|
|
21
|
+
providerID: string;
|
|
22
|
+
modelID: string;
|
|
24
23
|
systemPrompt: string;
|
|
25
24
|
userPrompt: string;
|
|
26
|
-
schema: ZodType<T>;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
schema: z.ZodType<T>;
|
|
26
|
+
directory?: string;
|
|
27
|
+
retryCount?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Generate one structured-output completion via opencode's v2 API.
|
|
31
|
+
* Throws on: session.create failure, prompt failure, AssistantMessage.error
|
|
32
|
+
* (StructuredOutputError / ApiError / ...), missing `info.structured`,
|
|
33
|
+
* or final Zod validation failure.
|
|
34
|
+
*/
|
|
35
|
+
export declare function generateStructuredOutput<T>(opts: StructuredOutputOptions<T>): Promise<T>;
|
|
30
36
|
//# sourceMappingURL=opencode-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opencode-provider.d.ts","sourceRoot":"","sources":["../../../src/services/ai/opencode-provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"opencode-provider.d.ts","sourceRoot":"","sources":["../../../src/services/ai/opencode-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAKvF,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAE/D;AAED,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAExD;AAED,wBAAgB,WAAW,IAAI,cAAc,GAAG,SAAS,CAExD;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,GAAG,GAAG,MAAM,GAAG,cAAc,CAGtE;AAED,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACxC,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAAC,CAAC,EAAE,IAAI,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAgF9F"}
|