{"modulePath":"github.com/driangle/taskmd/apps/cli","version":"v0.0.0-20261105072926-5f6f96789b57","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package sync\n\n## Constants\n\n```go\nconst (\n\tConflictSkip   = \"skip\"   // default: skip conflicting tasks\n\tConflictRemote = \"remote\" // overwrite local with remote\n\tConflictLocal  = \"local\"  // keep local, update state hashes\n)\n```\nConflictStrategy controls how conflicts are resolved during sync.\n\n## Functions\n\n```go\nfunc HashExternalTask(ext ExternalTask) string\n```\nHashExternalTask returns a deterministic hash of an external task's content.\n\n```go\nfunc HashLocalFile(path string) (string, error)\n```\nHashLocalFile returns the SHA-256 hash of a file's contents.\n\n```go\nfunc Register(s Source)\n```\nRegister adds a source to the global registry.\n\n```go\nfunc RegisteredNames() []string\n```\nRegisteredNames returns the sorted names of all registered sources.\n\n```go\nfunc SaveState(dir, sourceName string, state *SyncState) error\n```\nSaveState writes the state file for a source.\n\n```go\nfunc Unregister(name string)\n```\nUnregister removes a source from the registry. Intended for testing.\n\n```go\nfunc UpdateSyncedTaskFile(filePath string, mapped MappedTask) error\n```\nUpdateSyncedTaskFile updates an existing synced task file.\n\n```go\nfunc WriteTaskFile(dir, id string, mapped MappedTask, externalID, sourceName string) (string, error)\n```\nWriteTaskFile creates a new task markdown file and returns the file path.\n\n## Types\n\n```go\ntype Config struct {\n\tSync SyncConfig `yaml:\"sync\"`\n}\n```\nConfig is the top-level project configuration.\n\n```go\ntype Engine struct {\n\tConfigDir        string\n\tVerbose          bool\n\tDryRun           bool\n\tConflictStrategy string\n}\n```\nEngine orchestrates syncing tasks from external sources.\n\n```go\nfunc (e *Engine) RunSync(srcCfg SourceConfig) (*SyncResult, error)\n```\nRunSync syncs tasks for a single source configuration.\n\n```go\ntype ExternalTask struct {\n\tExternalID  string\n\tTitle       string\n\tDescription string\n\tStatus      string\n\tPriority    string\n\tAssignee    string\n\tLabels      []string\n\tCreatedAt   time.Time\n\tUpdatedAt   time.Time\n\tURL         string\n\tExtra       map[string]string\n}\n```\nExternalTask represents a task fetched from an external source.\n\n```go\ntype FieldMap struct {\n\tStatus          map[string]string `yaml:\"status\"`\n\tPriority        map[string]string `yaml:\"priority\"`\n\tLabelsToTags    bool              `yaml:\"labels_to_tags\"`\n\tAssigneeToOwner bool              `yaml:\"assignee_to_owner\"`\n}\n```\nFieldMap configures how external fields are mapped to taskmd frontmatter.\n\n```go\ntype ImportAction struct {\n\tExternalID string\n\tLocalID    string\n\tFilePath   string\n\tTitle      string\n\tReason     string // \"created\" or \"skipped_duplicate\"\n}\n```\nImportAction describes a single import operation.\n\n```go\ntype ImportConfig struct {\n\tSourceName string\n\tSourceCfg  SourceConfig\n\tOutputDir  string\n\tScanDir    string\n\tDryRun     bool\n\tVerbose    bool\n}\n```\nImportConfig holds configuration for a one-shot import run.\n\n```go\ntype ImportResult struct {\n\tCreated []ImportAction\n\tSkipped []ImportAction\n\tErrors  []SyncError\n}\n```\nImportResult holds the outcome of an import run.\n\n```go\nfunc RunImport(cfg ImportConfig) (*ImportResult, error)\n```\nRunImport fetches tasks from an external source and writes them as local task files. Unlike RunSync, it performs no state tracking — it is a one-shot operation that detects duplicates via external\\_id in existing task files.\n\n```go\ntype MappedTask struct {\n\tTitle       string\n\tDescription string\n\tStatus      string\n\tPriority    string\n\tOwner       string\n\tTags        []string\n\tURL         string\n}\n```\nMappedTask holds the result of mapping an ExternalTask to taskmd fields.\n\n```go\nfunc MapExternalTask(ext ExternalTask, fm FieldMap) MappedTask\n```\nMapExternalTask converts an ExternalTask to taskmd fields using the FieldMap.\n\n```go\ntype Source interface {\n\tName() string\n\tValidateConfig(cfg SourceConfig) error\n\tFetchTasks(cfg SourceConfig) ([]ExternalTask, error)\n}\n```\nSource defines the interface that external task providers must implement.\n\n```go\nfunc GetSource(name string) (Source, error)\n```\nGetSource returns a registered source by name.\n\n```go\ntype SourceConfig struct {\n\tName      string            `yaml:\"name\"`\n\tProject   string            `yaml:\"project\"`\n\tBaseURL   string            `yaml:\"base_url\"`\n\tTokenEnv  string            `yaml:\"token_env\"`\n\tUserEnv   string            `yaml:\"user_env\"`\n\tOutputDir string            `yaml:\"output_dir\"`\n\tFieldMap  FieldMap          `yaml:\"field_map\"`\n\tFilters   map[string]any    `yaml:\"filters\"`\n\tExtra     map[string]string `yaml:\"extra\"`\n}\n```\nSourceConfig describes a single external source.\n\n```go\ntype SyncAction struct {\n\tExternalID string\n\tLocalID    string\n\tFilePath   string\n\tTitle      string\n\tReason     string\n}\n```\nSyncAction describes a single sync operation.\n\n```go\ntype SyncConfig struct {\n\tSources []SourceConfig `yaml:\"sources\"`\n}\n```\nSyncConfig holds the sync-specific configuration.\n\n```go\nfunc LoadConfig(dir string) (*SyncConfig, error)\n```\nLoadConfig reads the project config from dir/.taskmd.yaml and returns the sync section.\n\n```go\ntype SyncError struct {\n\tExternalID string\n\tTitle      string\n\tErr        error\n}\n```\nSyncError describes an error during sync.\n\n```go\ntype SyncResult struct {\n\tCreated   []SyncAction\n\tUpdated   []SyncAction\n\tSkipped   []SyncAction\n\tConflicts []SyncAction\n\tErrors    []SyncError\n}\n```\nSyncResult holds the outcome of a sync run.\n\n```go\ntype SyncState struct {\n\tSource   string               `yaml:\"source\"`\n\tTasks    map[string]TaskState `yaml:\"tasks\"`\n\tLastSync time.Time            `yaml:\"last_sync\"`\n}\n```\nSyncState tracks the last-synced state for a single source.\n\n```go\nfunc LoadState(dir, sourceName string) (*SyncState, error)\n```\nLoadState reads the state file for a source. Returns empty state if file doesn't exist.\n\n```go\ntype TaskState struct {\n\tExternalID   string    `yaml:\"external_id\"`\n\tLocalID      string    `yaml:\"local_id\"`\n\tFilePath     string    `yaml:\"file_path\"`\n\tExternalHash string    `yaml:\"external_hash\"`\n\tLocalHash    string    `yaml:\"local_hash\"`\n\tLastSynced   time.Time `yaml:\"last_synced\"`\n}\n```\nTaskState tracks the sync state of a single task.\n\n","path":"github.com/driangle/taskmd/apps/cli/internal/sync","name":"sync","synopsis":"","isRedistributable":true}
