mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
feat(opencode): migrate OpenCode Manager to OpenCode 2 (#359)
* feat(opencode): migrate OpenCode Manager to OpenCode 2 Port the backend lifecycle, generated plugins, event aggregation, schedules, worktrees, provider credentials, MCP, config handling, the frontend chat model, and the ocm CLI to OpenCode 2. Adopt @opencode/client 2.0.15 as the single typed V2 API contract, require OpenCode 2.0.0 or newer (pinned 2.0.15), and delete every V1-only code path. * refactor(opencode): reload config in place and drop v1 compatibility shims Route config/skill/AGENTS.md changes through the OpenCode location reload API instead of a full server restart, stop auto-resuming interrupted sessions, remove the restart coordinator and v1 MCP/version shims, and pin support to OpenCode >=2.0.15 <3.0.0. Adds integration-ready retries, service-mode launch, ocm-cli repo proxy, and new frontend form/MCP helpers. * refactor(opencode): consolidate v2 migration helpers and harden install, proxy, and session flows - extract shared semver and model-ref utilities, reuse across version checks - share the OpenCode release download script across Docker, entrypoint, dev setup - unify install/upgrade failure recovery and guard externally managed OPENCODE_BIN - scope the repo proxy location rewrite and surface ocm proxy errors - rework frontend session projection, permission lookup, and cache invalidation * fix(schedules): reject unavailable agents before creating a session * feat(opencode): add ocm install, schedule agent fallback, and session move guards
This commit is contained in:
1 parent
6c2ebd764b
commit
dacde879d6
383 files changed
+29905
-46566
No files matched your search
@@ -1,3 +1,4 @@
|
||||
export * from './jsonc'
|
||||
export * from './repo'
|
||||
export * from './sandbox-command'
|
||||
export * from './semver'
|
||||
@@ -56,6 +56,10 @@ export function sanitizeBranchForDirectory(branch: string): string {
|
||||
return branch.replace(/[\\/]/g, '-')
|
||||
}
|
||||
|
||||
export function isWorktreeSibling(sibling: { worktreeStrategy?: string }): boolean {
|
||||
return sibling.worktreeStrategy !== undefined
|
||||
}
|
||||
|
||||
export function getRepoBaseDirectoryName(repo: { localPath: string; branch?: string; isWorktree?: boolean }): string {
|
||||
if (repo.isWorktree && repo.branch) {
|
||||
const suffix = `-${sanitizeBranchForDirectory(repo.branch)}`
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
export type SemverPrereleaseIdentifier = number | string
|
||||
|
||||
export interface Semver {
|
||||
major: number
|
||||
minor: number
|
||||
patch: number
|
||||
prerelease: SemverPrereleaseIdentifier[]
|
||||
}
|
||||
|
||||
const SEMVER_PATTERN =
|
||||
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
|
||||
|
||||
export function normalizeSemver(version: string): string {
|
||||
return version.trim().replace(/^v/, '')
|
||||
}
|
||||
|
||||
export function parseSemver(version: string): Semver | null {
|
||||
const match = SEMVER_PATTERN.exec(normalizeSemver(version))
|
||||
if (!match) return null
|
||||
return {
|
||||
major: Number(match[1]),
|
||||
minor: Number(match[2]),
|
||||
patch: Number(match[3]),
|
||||
prerelease: match[4]
|
||||
? match[4].split('.').map((identifier) => (/^\d+$/.test(identifier) ? Number(identifier) : identifier))
|
||||
: [],
|
||||
}
|
||||
}
|
||||
|
||||
function comparePrereleaseIdentifiers(
|
||||
left: SemverPrereleaseIdentifier[],
|
||||
right: SemverPrereleaseIdentifier[],
|
||||
): number {
|
||||
if (left.length === 0 || right.length === 0) return right.length - left.length
|
||||
|
||||
for (let index = 0; index < Math.max(left.length, right.length); index++) {
|
||||
const leftIdentifier = left[index]
|
||||
const rightIdentifier = right[index]
|
||||
|
||||
if (leftIdentifier === undefined) return -1
|
||||
if (rightIdentifier === undefined) return 1
|
||||
if (leftIdentifier === rightIdentifier) continue
|
||||
|
||||
const leftNumeric = typeof leftIdentifier === 'number'
|
||||
const rightNumeric = typeof rightIdentifier === 'number'
|
||||
if (leftNumeric && rightNumeric) return leftIdentifier > rightIdentifier ? 1 : -1
|
||||
if (leftNumeric) return -1
|
||||
if (rightNumeric) return 1
|
||||
return leftIdentifier > rightIdentifier ? 1 : -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
export function compareParsedSemver(left: Semver, right: Semver): number {
|
||||
if (left.major !== right.major) return left.major - right.major
|
||||
if (left.minor !== right.minor) return left.minor - right.minor
|
||||
if (left.patch !== right.patch) return left.patch - right.patch
|
||||
return comparePrereleaseIdentifiers(left.prerelease, right.prerelease)
|
||||
}
|
||||
|
||||
export function compareSemver(left: string, right: string): number {
|
||||
const parsedLeft = parseSemver(left)
|
||||
const parsedRight = parseSemver(right)
|
||||
if (!parsedLeft || !parsedRight) {
|
||||
throw new Error(`Cannot compare invalid semver versions: ${left} and ${right}`)
|
||||
}
|
||||
return compareParsedSemver(parsedLeft, parsedRight)
|
||||
}
|
||||
Reference in new issue
Block a user