planio

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package planio implements portable plan export and import for sharing cloop plans between teams without requiring git access. Supported formats: yaml, json, toml.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectFormat

func DetectFormat(path string) string

DetectFormat infers the serialization format from the file extension. Returns "yaml", "json", or "toml". Returns "" when the extension is unknown.

func Export

func Export(plan *pm.Plan, format, outputPath string) error

Export serialises plan to the given format and writes to outputPath. If outputPath is "-" or empty the result is written to stdout. format must be "yaml", "json", or "toml".

Types

type ImportResult

type ImportResult struct {
	Plan     *pm.Plan
	Added    int // tasks appended (merge mode only)
	Skipped  int // tasks skipped because they already existed (merge mode only)
	Replaced int // tasks in the new plan (replace mode only)
}

ImportResult carries the imported plan along with diagnostic counters.

func Import

func Import(filePath string, format string, existing *pm.Plan, mode MergeMode) (*ImportResult, error)

Import reads a plan file from filePath, validates it, and merges or replaces the existing plan according to mode. existing may be nil when there is no current plan (replace always succeeds; merge with a nil existing plan treats every imported task as new).

type MergeMode

type MergeMode string

MergeMode controls how Import handles an existing plan.

const (
	// MergeReplace discards the existing plan and replaces it with the imported one.
	MergeReplace MergeMode = "replace"
	// MergeMerge appends new tasks (by title) to the existing plan; existing tasks are kept.
	MergeMerge MergeMode = "merge"
)

type PlanFile

type PlanFile struct {
	SchemaVersion string     `json:"schema_version" yaml:"schema_version" toml:"schema_version"`
	ExportedAt    string     `json:"exported_at"    yaml:"exported_at"    toml:"exported_at"`
	Goal          string     `json:"goal"           yaml:"goal"           toml:"goal"`
	Tasks         []TaskFile `json:"tasks"          yaml:"tasks"          toml:"tasks"`
}

PlanFile is the portable interchange representation of a plan. It uses string tags across all three serialization formats so that exported files are human-readable and round-trip cleanly.

type TaskFile

type TaskFile struct {
	ID               int      `json:"id"                          yaml:"id"                          toml:"id"`
	Title            string   `json:"title"                       yaml:"title"                       toml:"title"`
	Description      string   `json:"description,omitempty"       yaml:"description,omitempty"       toml:"description,omitempty"`
	Priority         int      `json:"priority"                    yaml:"priority"                    toml:"priority"`
	Status           string   `json:"status"                      yaml:"status"                      toml:"status"`
	Role             string   `json:"role,omitempty"              yaml:"role,omitempty"              toml:"role,omitempty"`
	DependsOn        []int    `json:"depends_on,omitempty"        yaml:"depends_on,omitempty"        toml:"depends_on,omitempty"`
	Tags             []string `json:"tags,omitempty"              yaml:"tags,omitempty"              toml:"tags,omitempty"`
	EstimatedMinutes int      `json:"estimated_minutes,omitempty" yaml:"estimated_minutes,omitempty" toml:"estimated_minutes,omitempty"`
	Assignee         string   `json:"assignee,omitempty"          yaml:"assignee,omitempty"          toml:"assignee,omitempty"`
	Deadline         string   `json:"deadline,omitempty"          yaml:"deadline,omitempty"          toml:"deadline,omitempty"`
	Condition        string   `json:"condition,omitempty"         yaml:"condition,omitempty"         toml:"condition,omitempty"`
	Recurrence       string   `json:"recurrence,omitempty"        yaml:"recurrence,omitempty"        toml:"recurrence,omitempty"`
	RequiresApproval bool     `json:"requires_approval,omitempty" yaml:"requires_approval,omitempty" toml:"requires_approval,omitempty"`
	MaxMinutes       int      `json:"max_minutes,omitempty"       yaml:"max_minutes,omitempty"       toml:"max_minutes,omitempty"`
	ExternalURL      string   `json:"external_url,omitempty"      yaml:"external_url,omitempty"      toml:"external_url,omitempty"`
	Result           string   `json:"result,omitempty"            yaml:"result,omitempty"            toml:"result,omitempty"`
}

TaskFile is the portable representation of a single task. Only fields that are meaningful for interchange are included. Runtime-only fields (artifact paths, heal counters, internal state) are omitted.

Jump to

Keyboard shortcuts

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