openpod

An opencode plugin that spins up a dedicated virtual machine for each session to isolate agent work.
git clone https://unitehenry.com/git/openpod.git
Log | Files | Refs | README

commit b6a397d685e1266b42f2a7d50c6805f722aa63ed
parent af997c1e3ffbd74288b6f73f6cfed4905c2e6d1f
Author: admin <unitehenry@gmail.com>
Date:   Mon, 19 Oct 2026 00:40:39 +0000

feat: copy over remotes when project is cloned to openpod directory

Diffstat:
MREADME.md | 5++++-
Mindex.ts | 71++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 74 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md @@ -11,10 +11,12 @@ prompt check if session is new if in git repo git clone to `~/.local/share/openpod/<sessionId>` +copy over remotes (origin, upstream, etc.) from original project + (plain `git clone` of local dir only sets a local-path origin) move session to clone repo else skip cleanup (on session.deleted event) limactl stop --force + delete --force <sessionId> -rm -rf ~/.local/share/openpod/<sessionId> +rm -rf ~/.local/share/openpod/<sessionId> +\ No newline at end of file diff --git a/index.ts b/index.ts @@ -73,6 +73,7 @@ function cloneRepo(source: string, target: string): void { if (result.status !== 0) { throw new Error(`git clone failed with exit code ${result.status}`); } + copyRemotes(source, target); } catch (err) { writeLog(`${err}`); try { @@ -81,6 +82,73 @@ function cloneRepo(source: string, target: string): void { } } +function copyRemotes(source: string, target: string): void { + try { + writeLog(`copying remotes from ${source} to ${target}`); + + // clone always sets "origin" to point at the local source path; + // remove it so we can restore the original remotes (if any) + spawnSync("git", ["-C", target, "remote", "remove", "origin"], { + stdio: "ignore", + }); + + const listResult = spawnSync( + "git", + ["-C", source, "remote", "-v"], + { + encoding: "utf8", + stdio: ["ignore", "pipe", "ignore"], + }, + ); + if (listResult.status !== 0 || !listResult.stdout?.trim()) { + writeLog("no remotes found in source (origin removed from clone)"); + return; + } + + const lines = listResult.stdout.trim().split("\n"); + const remotes: Record<string, { fetch?: string; push?: string }> = {}; + + for (const line of lines) { + const match = line.match(/^(\S+)\s+(\S+)\s+\((fetch|push)\)$/); + if (match) { + const [, name, url, type] = match; + if (!remotes[name]) { + remotes[name] = {}; + } + if (type === "fetch") { + remotes[name].fetch = url; + } else { + remotes[name].push = url; + } + } + } + + for (const [name, urls] of Object.entries(remotes)) { + if (urls.fetch) { + const addRes = spawnSync( + "git", + ["-C", target, "remote", "add", name, urls.fetch], + { stdio: "ignore" }, + ); + if (addRes.status !== 0) { + writeLog(`failed to add remote ${name} ${urls.fetch}`); + } + } + if (urls.push && urls.push !== urls.fetch) { + spawnSync( + "git", + ["-C", target, "remote", "set-url", "--push", name, urls.push], + { stdio: "ignore" }, + ); + } + } + + writeLog(`copied ${Object.keys(remotes).length} remotes`); + } catch (err) { + writeLog(`copy remotes error: ${err}`); + } +} + function getLimaName(dir: string): string | null { try { writeLog(`get lima name for ${openpodRoot} ${dir}`) @@ -284,4 +352,4 @@ export default Plugin.define({ return () => controller.abort(); }, -}); +}); +\ No newline at end of file