sync

package
v0.31.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package sync writes project memory to AI-editor context files (CLAUDE.md, .github/copilot-instructions.md, .cursor/rules, .windsurfrules). It is driven by the /sync slash command and optionally by a post-commit hook.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveTargets

func ActiveTargets(root string, cfg config.SyncConfig) []config.SyncTargetMeta

ActiveTargets returns the SyncTargetMeta entries that should be written based on the stored SyncConfig and what's currently detected on disk.

"Everything" means every AI-editor file that ALREADY EXISTS in the repo, plus any that appear later (each run re-detects, so a newly-created .cursor/rules is adopted automatically) — NOT every possible target. Writing all four blindly would litter repos with context files for editors the user doesn't use, on every commit. An explicit target list, by contrast, is honored verbatim: if you pick Cursor before the file exists, we create it.

func InstallGitHook

func InstallGitHook(root string) error

InstallGitHook writes a post-commit hook under root/.git/hooks/post-commit that calls `memcode sync --auto`. It is idempotent: a no-op if our hook is already present. If a hook already exists that isn't ours, it appends to it.

func Write

func Write(root string, content string, targets []config.SyncTargetMeta) error

Write writes content to the given target paths under root. Each file gets the managed header prepended. Parent directories are created as needed.

Types

type DetectedTarget

type DetectedTarget struct {
	config.SyncTargetMeta
	Exists  bool // file is present in the repo
	Managed bool // file starts with the memcode managed header
}

DetectTargets returns the subset of SyncTargetAll that already exist on disk, and whether each one is already managed by memcode.

func Detect

func Detect(root string) []DetectedTarget

Detect scans root for known AI-editor context files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL