Add memory plugin with semantic search and session planning (#145)

* Add memory plugin with semantic search and session planning

* Clarify Memory Plugin is optional in docs
This commit is contained in:
Chris Scott authored and GitHub committed 2026-02-23 15:08:56 -05:00
1 parent da283a82cf
commit 3461f86556
132 files changed
+11448 -2834

No files matched your search

+12
View File
@@ -53,6 +53,7 @@ export const ENV = {
OPENCODE: {
PORT: getEnvNumber('OPENCODE_SERVER_PORT', DEFAULTS.OPENCODE.PORT),
HOST: getEnvString('OPENCODE_HOST', DEFAULTS.OPENCODE.HOST),
API_URL: process.env.OPENCODE_MANAGER_API_URL ?? `http://127.0.0.1:${DEFAULTS.SERVER.PORT}`,
},
DATABASE: {
@@ -106,12 +107,23 @@ export const ENV = {
PASSKEY_RP_NAME: getEnvString('PASSKEY_RP_NAME', 'OpenCode Manager'),
PASSKEY_ORIGIN: getEnvString('PASSKEY_ORIGIN', 'http://localhost:5003'),
},
REDIS: {
URL: getEnvString('REDIS_URL', ''),
PASSWORD: process.env.REDIS_PASSWORD ?? '',
DB: getEnvNumber('REDIS_DB', 0),
},
} as const
export const getWorkspacePath = () => ENV.WORKSPACE.BASE_PATH
export const getReposPath = () => path.join(ENV.WORKSPACE.BASE_PATH, ENV.WORKSPACE.REPOS_DIR)
export const getConfigPath = () => path.join(ENV.WORKSPACE.BASE_PATH, ENV.WORKSPACE.CONFIG_DIR)
export const getOpenCodeConfigFilePath = () => path.join(ENV.WORKSPACE.BASE_PATH, ENV.WORKSPACE.CONFIG_DIR, 'opencode.json')
export const getPluginSourcePath = () => {
const envPath = process.env.OPENCODE_PLUGIN_PATH
if (envPath) return path.resolve(envPath)
return path.resolve('packages/memory/src/index.ts')
}
export const getAgentsMdPath = () => path.join(ENV.WORKSPACE.BASE_PATH, ENV.WORKSPACE.CONFIG_DIR, 'AGENTS.md')
export const getAuthPath = () => path.join(ENV.WORKSPACE.BASE_PATH, ENV.WORKSPACE.AUTH_FILE)
export const getDatabasePath = () => ENV.DATABASE.PATH
+1
View File
@@ -6,3 +6,4 @@ export * from './auth'
export * from './sse'
export * from './notifications'
export * from './ssh'
export * from './memory'
+72
View File
@@ -0,0 +1,72 @@
import { z } from 'zod'
export const MemoryScopeSchema = z.enum(['convention', 'decision', 'context'])
export type MemoryScope = z.infer<typeof MemoryScopeSchema>
export const MemorySchema = z.object({
id: z.number(),
projectId: z.string(),
scope: MemoryScopeSchema,
content: z.string(),
filePath: z.string().nullable(),
accessCount: z.number().default(0),
lastAccessedAt: z.number().nullable(),
createdAt: z.number(),
updatedAt: z.number(),
})
export type Memory = z.infer<typeof MemorySchema>
export const CreateMemoryRequestSchema = z.object({
projectId: z.string(),
scope: MemoryScopeSchema,
content: z.string().min(1).max(10000),
})
export type CreateMemoryRequest = z.infer<typeof CreateMemoryRequestSchema>
export const UpdateMemoryRequestSchema = z.object({
content: z.string().min(1).max(10000).optional(),
scope: MemoryScopeSchema.optional(),
})
export type UpdateMemoryRequest = z.infer<typeof UpdateMemoryRequestSchema>
export const MemoryStatsSchema = z.object({
projectId: z.string(),
total: z.number(),
byScope: z.record(MemoryScopeSchema, z.number()),
})
export type MemoryStats = z.infer<typeof MemoryStatsSchema>
export const MemoryListQuerySchema = z.object({
projectId: z.string().optional(),
scope: MemoryScopeSchema.optional(),
content: z.string().optional(),
limit: z.number().min(1).max(100).default(20),
offset: z.number().min(0).default(0),
})
export type MemoryListQuery = z.infer<typeof MemoryListQuerySchema>
export const EmbeddingProviderTypeSchema = z.enum(['openai', 'voyage', 'local'])
export type EmbeddingProviderType = z.infer<typeof EmbeddingProviderTypeSchema>
export const EmbeddingConfigSchema = z.object({
provider: EmbeddingProviderTypeSchema,
model: z.string(),
dimensions: z.number().optional(),
baseUrl: z.string().optional(),
apiKey: z.string().optional(),
})
export type EmbeddingConfig = z.infer<typeof EmbeddingConfigSchema>
export const LoggingConfigSchema = z.object({
enabled: z.boolean(),
file: z.string().optional(),
})
export type LoggingConfig = z.infer<typeof LoggingConfigSchema>
export const PluginConfigSchema = z.object({
dataDir: z.string().optional(),
embedding: EmbeddingConfigSchema,
dedupThreshold: z.number().min(0).max(1).default(0.25),
logging: LoggingConfigSchema.optional(),
})
export type PluginConfig = z.infer<typeof PluginConfigSchema>
+1 -7
View File
@@ -32,12 +32,6 @@ export const STTConfigSchema = z.object({
lastModelsFetch: z.number().optional(),
});
export const CustomAgentSchema = z.object({
name: z.string(),
description: z.string(),
config: z.record(z.string(), z.any()),
});
export type TTSConfig = {
enabled: boolean;
provider: 'external' | 'builtin';
@@ -125,7 +119,6 @@ export const UserPreferencesSchema = z.object({
directShortcuts: z.array(z.string()).optional(),
keyboardShortcuts: z.record(z.string(), z.string()),
customCommands: z.array(CustomCommandSchema),
customAgents: z.array(CustomAgentSchema),
gitCredentials: z.array(GitCredentialSchema).optional(),
gitIdentity: GitIdentitySchema.optional(),
tts: TTSConfigSchema.optional(),
@@ -204,6 +197,7 @@ export const OpenCodeConfigSchema = z.object({
instructions: z.array(z.string()).optional(),
disabled_providers: z.array(z.string()).optional(),
share: z.enum(["manual", "auto", "disabled"]).optional(),
plugin: z.array(z.string()).optional(),
});
export type OpenCodeConfigContent = z.infer<typeof OpenCodeConfigSchema>;
+12 -2
View File
@@ -4,7 +4,6 @@ import {
SettingsResponseSchema,
UpdateSettingsRequestSchema,
CustomCommandSchema,
CustomAgentSchema,
OpenCodeConfigSchema,
OpenCodeConfigMetadataSchema,
CreateOpenCodeConfigRequestSchema,
@@ -41,7 +40,6 @@ export type UserPreferences = z.infer<typeof UserPreferencesSchema>
export type SettingsResponse = z.infer<typeof SettingsResponseSchema>
export type UpdateSettingsRequest = z.infer<typeof UpdateSettingsRequestSchema>
export type CustomCommand = z.infer<typeof CustomCommandSchema>
export type CustomAgent = z.infer<typeof CustomAgentSchema>
export type OpenCodeConfig = z.infer<typeof OpenCodeConfigMetadataSchema>
export type OpenCodeConfigInput = z.infer<typeof OpenCodeConfigSchema>
export type CreateOpenCodeConfigRequest = z.infer<typeof CreateOpenCodeConfigRequestSchema>
@@ -78,3 +76,15 @@ export interface SuccessResponse {
export type { SSHHostKeyRequest, SSHHostKeyResponse, TrustedSSHHost } from '../schemas/ssh'
export type { GitCredential } from '../schemas/settings'
export type {
Memory,
MemoryScope,
CreateMemoryRequest,
UpdateMemoryRequest,
MemoryStats,
EmbeddingProviderType,
EmbeddingConfig,
LoggingConfig,
PluginConfig,
} from '../schemas/memory'