refactor(opencode): use existing mem0 SDK instead of delegating to MCP, load skills properly instead of dumping them in .opencode (#5323)

Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
This commit is contained in:
ChrisFloofyKitsune
2026-06-17 09:48:39 -06:00
committed by GitHub
parent 703e8a035d
commit 9ed1983b85
48 changed files with 1691 additions and 5933 deletions
@@ -0,0 +1,20 @@
/**
* Project identity resolution for the Mem0 OpenCode plugin.
*
* The project id (`app_id`) scopes memories to a repo. We derive it from the
* git remote so it is stable across clones, worktrees, and sub-directories —
* falling back (in opencode-mem0.ts) to the git repo root dir name, then the
* cwd. Keeping the parser pure makes the tricky remote formats testable.
*/
/**
* Parse `owner/repo` out of a git remote URL and return it as `owner-repo`.
* Handles https, scp-style ssh, custom ssh host aliases (e.g.
* `git@github.com-work:owner/repo.git`), an optional `.git` suffix, and a
* trailing slash. Returns null when no owner/repo can be found.
*/
export function parseProjectFromRemote(remote: string): string | null {
const m = remote.trim().match(/[:/]([^/:]+)\/([^/:]+?)(?:\.git)?\/?$/);
if (!m) return null;
return `${m[1]}-${m[2]}`;
}