mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
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:
1 parent
da283a82cf
commit
3461f86556
132 files changed
+11448
-2834
No files matched your search
+1
-35
@@ -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.'
|
||||
|
||||
Reference in new issue
Block a user