Skip to content

Edison-A-N/opencode-worktree-memory-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

opencode-worktree-memory-sync

OpenCode plugin that automatically syncs .opencode/memory/ from your main repository into git worktrees.

Problem

When you create a git worktree via OpenCode's /worktree command, the new worktree gets a fresh .opencode/memory/ directory with only empty frontmatter scaffolds. All your project memory (conventions, architecture notes, preferences) is lost.

Solution

This plugin runs on every session initialization. When it detects the current directory is a git worktree, it locates the main repository and copies the memory files over — but only if the destination memory is empty (so it never overwrites your changes).

Install

Add to your opencode.json:

{
  "plugin": ["opencode-worktree-memory-sync"]
}

Restart OpenCode. That's it.

How It Works

  1. On session init, reads the .git file to detect if the directory is a worktree
  2. Parses the gitdir: path to resolve the main repository root
  3. Checks if .opencode/memory/ in the worktree only contains empty scaffolds
  4. If empty, copies all memory files from the main repo's .opencode/memory/

Non-worktree directories are silently ignored. Worktrees with existing memory content are skipped.

License

MIT

About

OpenCode plugin that auto-syncs .opencode/memory/ files to new worktrees

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors