Files
opencode-manager/ocm-cli/src/manager-repos.ts
T
Chris Scott 61efcf9ad1 feat(ocm-cli): add session move with local history export and TUI plugin (#304)
* loop: ocm-session-move completed after 7 iterations

* feat(ocm-cli): add session move with local history export and TUI plugin

* docs(ocm-cli): update plugin config to tui-only entry and clarify session history source

* fix(ocm-cli): replace raw postinstall output with TUI toast notification
2026-07-08 17:23:53 -04:00

32 lines
914 B
TypeScript

import type { RemoteRepoSummary } from './mirror.js'
export interface ManagerRepo {
repoId: number
name: string
branch: string | null
cloneStatus: string
directory: string
projectId?: string | null
extra: { repoId: number; localPath: string; fullPath: string }
}
export async function fetchRepos(managerUrl: string, token: string): Promise<ManagerRepo[]> {
const res = await fetch(`${managerUrl}/api/internal/opencode-workspaces`, {
headers: { Authorization: `Bearer ${token}` },
})
if (!res.ok) {
throw new Error(`manager responded ${res.status} ${res.statusText}`)
}
const data = (await res.json()) as { workspaces: ManagerRepo[] }
return data.workspaces
}
export function toRemoteRepoSummaries(repos: ManagerRepo[]): RemoteRepoSummary[] {
return repos.map((r) => ({
repoId: r.repoId,
name: r.name,
projectId: r.projectId ?? null,
branch: r.branch,
}))
}