sync

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UserHomeDir = os.UserHomeDir

UserHomeDir is a package-level variable to allow test stubbing across packages.

Functions

func CleanCopilotOutputs added in v0.9.2

func CleanCopilotOutputs(sys System, root string) error

CleanCopilotOutputs removes Copilot CLI artifacts generated by previous syncs. Call this when agents.copilot_cli is disabled so stale config and skills do not persist and get consumed by Copilot tooling.

func EnsureEnabled

func EnsureEnabled(name string, enabled *bool) error

EnsureEnabled is a helper for command handlers.

func EnsureGeminiTrustedFolder added in v0.8.5

func EnsureGeminiTrustedFolder(sys System, root string) *warnings.Warning

EnsureGeminiTrustedFolder adds root to ~/.gemini/trustedFolders.json so that Gemini CLI treats the workspace as trusted and loads project-level settings. Returns a warning on failure; never returns an error.

func ResolvePromptServerCommand added in v0.9.0

func ResolvePromptServerCommand(sys System, root string) (string, []string, error)

ResolvePromptServerCommand returns the command and args used to run the internal MCP prompt server. Args: sys provides filesystem/exec access; root is the repo root. Returns: the resolved command/args or an error when resolution fails.

func WriteAntigravitySkills

func WriteAntigravitySkills(sys System, root string, commands []config.Skill) error

WriteAntigravitySkills generates Antigravity skill files for skills.

func WriteClaudeSettings

func WriteClaudeSettings(sys System, root string, project *config.ProjectConfig) error

WriteClaudeSettings generates .claude/settings.json.

func WriteCodexConfig

func WriteCodexConfig(sys System, root string, project *config.ProjectConfig) error

WriteCodexConfig generates .codex/config.toml.

func WriteCodexInstructions

func WriteCodexInstructions(sys System, root string, instructions []config.InstructionFile) error

WriteCodexInstructions generates the Codex-specific instruction shim.

func WriteCodexRules

func WriteCodexRules(sys System, root string, project *config.ProjectConfig) error

WriteCodexRules generates .codex/rules/default.rules.

func WriteCodexSkills

func WriteCodexSkills(sys System, root string, commands []config.Skill) error

WriteCodexSkills generates Codex skill files for skills.

func WriteCopilotMCPConfig added in v0.9.2

func WriteCopilotMCPConfig(sys System, root string, project *config.ProjectConfig) error

WriteCopilotMCPConfig generates .copilot/mcp-config.json for GitHub Copilot CLI. Unlike Claude's .mcp.json, this does NOT include the internal agent-layer prompt server because Copilot CLI already reads AGENTS.md and .github/copilot-instructions.md.

func WriteCopilotSkills added in v0.9.2

func WriteCopilotSkills(sys System, root string, skills []config.Skill) error

WriteCopilotSkills generates skill files in .github/skills/<name>/SKILL.md.

func WriteGeminiSettings

func WriteGeminiSettings(sys System, root string, project *config.ProjectConfig) error

WriteGeminiSettings generates .gemini/settings.json.

func WriteInstructionShims

func WriteInstructionShims(sys System, root string, instructions []config.InstructionFile) error

WriteInstructionShims generates instruction shims for supported clients.

func WriteMCPConfig

func WriteMCPConfig(sys System, root string, project *config.ProjectConfig) error

WriteMCPConfig generates .mcp.json for Claude Code.

func WriteVSCodeMCPConfig

func WriteVSCodeMCPConfig(sys System, root string, project *config.ProjectConfig) error

WriteVSCodeMCPConfig generates .vscode/mcp.json.

func WriteVSCodePrompts

func WriteVSCodePrompts(sys System, root string, commands []config.Skill) error

WriteVSCodePrompts generates VS Code prompt files for skills.

func WriteVSCodeSettings

func WriteVSCodeSettings(sys System, root string, project *config.ProjectConfig) error

WriteVSCodeSettings generates .vscode/settings.json.

Types

type OrderedMap

type OrderedMap[T any] map[string]T

OrderedMap marshals map keys in a stable order.

func ResolvePromptServerEnv added in v0.9.0

func ResolvePromptServerEnv(root string) (OrderedMap[string], error)

ResolvePromptServerEnv returns the environment variables for the internal MCP prompt server. Args: root is the repo root. Returns: ordered env vars or an error when resolution fails.

func (OrderedMap[T]) MarshalJSON

func (m OrderedMap[T]) MarshalJSON() ([]byte, error)

MarshalJSON encodes a map with sorted keys for deterministic output.

type RealSystem added in v0.5.4

type RealSystem struct{}

RealSystem implements System using actual system calls.

func (RealSystem) LookPath added in v0.5.4

func (RealSystem) LookPath(file string) (string, error)

LookPath searches for an executable named file in the directories named by the PATH environment variable.

func (RealSystem) MarshalIndent added in v0.5.4

func (RealSystem) MarshalIndent(v any, prefix, indent string) ([]byte, error)

MarshalIndent returns the JSON encoding of v with indentation.

func (RealSystem) MkdirAll added in v0.5.4

func (RealSystem) MkdirAll(path string, perm os.FileMode) error

MkdirAll creates a directory named path, along with any necessary parents.

func (RealSystem) ReadDir added in v0.8.0

func (RealSystem) ReadDir(name string) ([]os.DirEntry, error)

ReadDir reads the named directory and returns all directory entries.

func (RealSystem) ReadFile added in v0.5.4

func (RealSystem) ReadFile(name string) ([]byte, error)

ReadFile reads the named file and returns the contents.

func (RealSystem) Remove added in v0.8.0

func (RealSystem) Remove(name string) error

Remove removes the named file or empty directory.

func (RealSystem) RemoveAll added in v0.8.0

func (RealSystem) RemoveAll(path string) error

RemoveAll removes path and any children it contains.

func (RealSystem) Stat added in v0.5.4

func (RealSystem) Stat(name string) (os.FileInfo, error)

Stat returns a FileInfo describing the named file.

func (RealSystem) WriteFileAtomic added in v0.5.4

func (RealSystem) WriteFileAtomic(filename string, data []byte, perm os.FileMode) error

WriteFileAtomic writes data to a file atomically by writing to a temp file and renaming.

type Result added in v0.8.1

type Result struct {
	Warnings    []warnings.Warning
	AllWarnings []warnings.Warning
}

Result holds the outcome of a sync operation.

func Run

func Run(root string) (*Result, error)

Run regenerates all configured outputs for the repo. Returns any sync-time warnings and an error if sync failed.

func RunWithProject

func RunWithProject(sys System, root string, project *config.ProjectConfig) (*Result, error)

RunWithProject regenerates outputs using an already loaded project config. Returns any sync-time warnings and an error if sync failed.

func RunWithSystemFS added in v0.5.7

func RunWithSystemFS(sys System, fsys fs.FS, root string) (*Result, error)

RunWithSystemFS loads project config from fsys and runs sync with the provided System. sys provides OS operations for sync writers; fsys must be rooted at repo root.

type System added in v0.5.4

type System interface {
	LookPath(file string) (string, error)
	Stat(name string) (os.FileInfo, error)
	MkdirAll(path string, perm os.FileMode) error
	WriteFileAtomic(filename string, data []byte, perm os.FileMode) error
	MarshalIndent(v any, prefix, indent string) ([]byte, error)
	ReadFile(name string) ([]byte, error)
	ReadDir(name string) ([]os.DirEntry, error)
	Remove(name string) error
	RemoveAll(path string) error
}

System abstracts system-level operations to enable dependency injection in sync logic.

Jump to

Keyboard shortcuts

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