{"modulePath":"github.com/memcode-ai/memcode","version":"v0.56.16","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package sync\n\nPackage 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.\n\n## Functions\n\n```go\nfunc ActiveTargets(root string, cfg config.SyncConfig) []config.SyncTargetMeta\n```\nActiveTargets returns the SyncTargetMeta entries that should be written based on the stored SyncConfig and what's currently detected on disk.\n\n\"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.\n\n```go\nfunc InstallGitHook(root string) error\n```\nInstallGitHook 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.\n\n```go\nfunc Write(root string, content string, targets []config.SyncTargetMeta) error\n```\nWrite writes content to the given target paths under root. Each file gets the managed header prepended. Parent directories are created as needed.\n\n## Types\n\n```go\ntype DetectedTarget struct {\n\tconfig.SyncTargetMeta\n\tExists  bool // file is present in the repo\n\tManaged bool // file starts with the memcode managed header\n}\n```\nDetectTargets returns the subset of SyncTargetAll that already exist on disk, and whether each one is already managed by memcode.\n\n```go\nfunc Detect(root string) []DetectedTarget\n```\nDetect scans root for known AI-editor context files.\n\n","path":"github.com/memcode-ai/memcode/internal/sync","name":"sync","synopsis":"Package sync writes project memory to AI-editor context files (CLAUDE.md, .github/copilot-instructions.md, .cursor/rules, .windsurfrules).","isRedistributable":true}
