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

+1 -35
View File
@@ -1,7 +1,7 @@
import { useQuery } from '@tanstack/react-query'
import { fetchWrapper, FetchError } from './fetchWrapper'
import { API_BASE_URL } from '@/config'
import type { GitStatusResponse, FileDiffResponse, GitCommit, CommitDetails } from '@/types/git'
import type { GitStatusResponse, FileDiffResponse, GitCommit } from '@/types/git'
export async function fetchGitStatus(repoId: number): Promise<GitStatusResponse> {
return fetchWrapper(`${API_BASE_URL}/api/repos/${repoId}/git/status`)
@@ -22,12 +22,6 @@ export async function fetchFileDiff(repoId: number, path: string, includeStaged?
})
}
export async function fetchCommitFileDiff(repoId: number, commitHash: string, path: string): Promise<FileDiffResponse> {
return fetchWrapper(`${API_BASE_URL}/api/repos/${repoId}/git/commit/${commitHash}/diff`, {
params: { path },
})
}
export async function fetchGitDiff(repoId: number, path: string): Promise<{ diff: string }> {
const data = await fetchWrapper<string>(`${API_BASE_URL}/api/repos/${repoId}/git/diff`, {
params: { path },
@@ -41,10 +35,6 @@ export async function fetchGitLog(repoId: number, limit?: number): Promise<{ com
})
}
export async function fetchCommitDetails(repoId: number, hash: string): Promise<CommitDetails> {
return fetchWrapper(`${API_BASE_URL}/api/repos/${repoId}/git/commit/${hash}`)
}
export async function gitFetch(repoId: number): Promise<GitStatusResponse> {
return fetchWrapper(`${API_BASE_URL}/api/repos/${repoId}/git/fetch`, {
method: 'POST',
@@ -89,14 +79,6 @@ export async function gitUnstageFiles(repoId: number, paths: string[]): Promise<
})
}
export async function gitDiscardFiles(repoId: number, paths: string[], staged: boolean): Promise<GitStatusResponse> {
return fetchWrapper(`${API_BASE_URL}/api/repos/${repoId}/git/discard`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ paths, staged }),
})
}
export async function gitReset(repoId: number, commitHash: string): Promise<GitStatusResponse> {
return fetchWrapper(`${API_BASE_URL}/api/repos/${repoId}/git/reset`, {
method: 'POST',
@@ -122,14 +104,6 @@ export function useFileDiff(repoId: number | undefined, path: string | undefined
})
}
export function useCommitFileDiff(repoId: number | undefined, commitHash: string | undefined, path: string | undefined) {
return useQuery({
queryKey: ['commitFileDiff', repoId, commitHash, path],
queryFn: () => (repoId && commitHash && path) ? fetchCommitFileDiff(repoId, commitHash, path) : Promise.reject(new Error('Missing params')),
enabled: !!repoId && !!commitHash && !!path,
})
}
export function useGitLog(repoId: number | undefined, limit?: number) {
return useQuery({
queryKey: ['gitLog', repoId, limit],
@@ -138,14 +112,6 @@ export function useGitLog(repoId: number | undefined, limit?: number) {
})
}
export function useCommitDetails(repoId: number | undefined, hash: string | undefined) {
return useQuery({
queryKey: ['commitDetails', repoId, hash],
queryFn: () => (repoId && hash) ? fetchCommitDetails(repoId, hash) : Promise.reject(new Error('Missing params')),
enabled: !!repoId && !!hash,
})
}
function parseGitErrorMessage(message: string): string {
if (message.includes('no upstream') || message.includes('does not have any commits yet')) {
return 'No upstream branch configured. Push with --set-upstream or create commits first.'
+96
View File
@@ -0,0 +1,96 @@
import { fetchWrapper, fetchWrapperVoid } from './fetchWrapper'
import { API_BASE_URL } from '@/config'
import type { Memory, MemoryStats, CreateMemoryRequest, UpdateMemoryRequest, PluginConfig } from '@opencode-manager/shared/types'
export async function listMemories(filters?: {
projectId?: string
scope?: string
content?: string
limit?: number
offset?: number
}): Promise<{ memories: Memory[] }> {
const params = new URLSearchParams()
if (filters?.projectId) params.set('projectId', filters.projectId)
if (filters?.scope) params.set('scope', filters.scope)
if (filters?.content) params.set('content', filters.content)
if (filters?.limit) params.set('limit', String(filters.limit))
if (filters?.offset) params.set('offset', String(filters.offset))
const query = params.toString()
return fetchWrapper(`${API_BASE_URL}/api/memory${query ? `?${query}` : ''}`)
}
export async function createMemory(data: CreateMemoryRequest): Promise<{ memory: Memory }> {
return fetchWrapper(`${API_BASE_URL}/api/memory`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
})
}
export async function getMemory(id: number): Promise<{ memory: Memory }> {
return fetchWrapper(`${API_BASE_URL}/api/memory/${id}`)
}
export async function updateMemory(id: number, data: UpdateMemoryRequest): Promise<{ memory: Memory }> {
return fetchWrapper(`${API_BASE_URL}/api/memory/${id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
})
}
export async function deleteMemory(id: number): Promise<void> {
return fetchWrapperVoid(`${API_BASE_URL}/api/memory/${id}`, {
method: 'DELETE',
})
}
export async function getProjectSummary(
repoId: number
): Promise<{ projectId: string | null; stats: MemoryStats; error?: string }> {
return fetchWrapper(`${API_BASE_URL}/api/memory/project-summary?repoId=${repoId}`)
}
export async function getPluginConfig(): Promise<{ config: PluginConfig }> {
return fetchWrapper(`${API_BASE_URL}/api/memory/plugin-config`)
}
export async function updatePluginConfig(config: PluginConfig): Promise<{ success: boolean; config: PluginConfig }> {
return fetchWrapper(`${API_BASE_URL}/api/memory/plugin-config`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(config),
})
}
export interface ReindexResult {
success: boolean
message: string
total: number
embedded: number
failed: number
requiresRestart?: boolean
}
export async function reindexMemories(): Promise<ReindexResult> {
return fetchWrapper(`${API_BASE_URL}/api/memory/reindex`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
})
}
export interface TestEmbeddingResult {
success: boolean
error?: string
message?: string
dimensions?: number
}
export async function testEmbeddingConfig(): Promise<TestEmbeddingResult> {
return fetchWrapper(`${API_BASE_URL}/api/memory/test-embedding`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({}),
})
}
+1 -5
View File
@@ -1,5 +1,5 @@
import type { Repo } from './types'
import { FetchError, fetchWrapper, fetchWrapperText, fetchWrapperVoid, fetchWrapperBlob } from './fetchWrapper'
import { FetchError, fetchWrapper, fetchWrapperVoid, fetchWrapperBlob } from './fetchWrapper'
import { API_BASE_URL } from '@/config'
export async function createRepo(
@@ -51,10 +51,6 @@ export async function pullRepo(id: number): Promise<Repo> {
})
}
export async function getServerLogs(id: number): Promise<string> {
return fetchWrapperText(`${API_BASE_URL}/api/repos/${id}/server/logs`)
}
export async function switchRepoConfig(id: number, configName: string): Promise<Repo> {
return fetchWrapper(`${API_BASE_URL}/api/repos/${id}/config/switch`, {
method: 'POST',
+4
View File
@@ -210,6 +210,10 @@ export const settingsApi = {
getVersionInfo: async (): Promise<VersionInfo> => {
return fetchWrapper(`${API_BASE_URL}/api/health/version`)
},
getMemoryPluginStatus: async (): Promise<{ memoryPluginEnabled: boolean }> => {
return fetchWrapper(`${API_BASE_URL}/api/settings/memory-plugin-status`)
},
}
export interface VersionInfo {
+7 -6
View File
@@ -1,14 +1,15 @@
import { API_BASE_URL } from '@/config'
import { fetchWrapper } from './fetchWrapper'
import { API_BASE_URL } from '@/config'
export function respondSSHHostKey(requestId: string, approved: boolean): Promise<{ success: boolean; error?: string }> {
interface SSHHostKeyResponse {
success: boolean
error?: string
}
export async function respondSSHHostKey(requestId: string, approved: boolean): Promise<SSHHostKeyResponse> {
return fetchWrapper(`${API_BASE_URL}/api/ssh/host-key/respond`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ requestId, response: approved ? 'accept' : 'reject' }),
})
}
export function getSSHHostKeyStatus(): Promise<{ success: boolean; pendingCount?: number; error?: string }> {
return fetchWrapper(`${API_BASE_URL}/api/ssh/host-key/status`)
}
+1 -7
View File
@@ -19,12 +19,6 @@ export interface CustomCommand {
promptTemplate: string
}
export interface CustomAgent {
name: string
description: string
config: Record<string, unknown>
}
export interface GitCredential {
name: string
host: string
@@ -55,13 +49,13 @@ export interface UserPreferences {
directShortcuts?: string[]
keyboardShortcuts: Record<string, string>
customCommands: CustomCommand[]
customAgents: CustomAgent[]
gitCredentials?: GitCredential[]
gitIdentity?: GitIdentity
tts?: TTSConfig
stt?: STTConfig
notifications?: NotificationPreferences
repoOrder?: number[]
memoryDedupThreshold?: number
}
export interface SettingsResponse {