saga

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CurrentVersion = 2
	SchemaURL      = "https://changesaga.dev/schema/v2/saga.schema.json"
)
View Source
const MaxNoteRunes = 2000

MaxNoteRunes bounds sticky note text so a single annotation stays a compact canvas note rather than an unbounded document; schema/v2 enforces the same limit as maxLength.

Variables

This section is empty.

Functions

func ChapterTarget

func ChapterTarget(sagaID, chapterID string) string

func EntrypointError

func EntrypointError(value string) string

EntrypointError reports why a fragment entrypoint is unusable, or "" when it is a well-formed package-relative path.

The check is deliberately expressed in slash-path terms rather than through path/filepath. filepath.Clean rewrites "assets/app.js" to "assets\app.js" on Windows, so an OS-dependent normalization comparison would reject a portable nested entrypoint on exactly one platform. Backslashes are rejected outright because they are an ordinary filename byte on Unix and a separator on Windows, which would make one saga address two different files.

func FragmentTarget

func FragmentTarget(sagaID, fragmentID string) string

func LandmarkTarget

func LandmarkTarget(sagaID, fragmentID, landmarkID string) string

func Load

func Load(root string) (*Saga, Validation, error)

func PortabilityWarning

func PortabilityWarning(name string) string

PortabilityWarning reports why a path component cannot exist on every platform Change Saga supports, or "" when the name is portable. It never produces errors: a saga that already contains such a name stays loadable on the platform that created it, but authors are told before publishing it.

func PortablePathWarning

func PortablePathWarning(value string) string

PortablePathWarning applies PortabilityWarning to every component of a slash path.

func SagaTarget

func SagaTarget(sagaID string) string

func SectionTarget

func SectionTarget(sagaID, sectionID string) string

func ValidAnnotationColor

func ValidAnnotationColor(value string) bool

func ValidID

func ValidID(value string) bool

func ValidMarkdownAnchor

func ValidMarkdownAnchor(value string) bool

func ValidMediaType

func ValidMediaType(value string) bool

ValidMediaType reports whether a fragment media type is one the format defines. Engines render text/markdown, text/html, text/plain, image/svg+xml, and raster image/* fragments.

func ValidateAnchor

func ValidateAnchor(anchor Anchor) error

Types

type Anchor

type Anchor struct {
	Type       string        `json:"type"`
	Shapes     []Shape       `json:"shapes,omitempty"`
	Text       *TextSelector `json:"text,omitempty"`
	Note       *NoteSelector `json:"note,omitempty"`
	Diff       *DiffSelector `json:"diff,omitempty"`
	Coordinate string        `json:"coordinate_space,omitempty"`
}

type ChapterManifest

type ChapterManifest struct {
	Version int    `json:"version"`
	ID      string `json:"id"`
	Title   string `json:"title"`
	Order   int    `json:"order,omitempty"`
}

type DiffFile

type DiffFile struct {
	Path    string          `json:"-"`
	Version int             `json:"version"`
	Diffs   []DiffReference `json:"diffs"`
}

type DiffReference

type DiffReference struct {
	URI  string `json:"uri"`
	Note string `json:"note,omitempty"`
}

type DiffReview

type DiffReview struct {
	Path              string    `json:"-"`
	AttributionDetail string    `json:"-"`
	Version           int       `json:"version"`
	ID                string    `json:"id"`
	URI               string    `json:"uri"`
	Author            string    `json:"author,omitempty"`
	State             string    `json:"state"`
	CreatedAt         time.Time `json:"created_at"`
}

type DiffSelector

type DiffSelector struct {
	URI string `json:"uri"`
}

type Fragment

type Fragment struct {
	Path       string     `json:"path"`
	Directory  string     `json:"-"`
	ID         string     `json:"id"`
	Title      string     `json:"title,omitempty"`
	MediaType  string     `json:"media_type"`
	Entrypoint string     `json:"entrypoint"`
	Order      int        `json:"order,omitempty"`
	Target     string     `json:"target"`
	Diffs      []DiffFile `json:"diffs,omitempty"`
	Landmarks  []Landmark `json:"landmarks,omitempty"`
	Reviews    []Review   `json:"reviews,omitempty"`
}

type FragmentManifest

type FragmentManifest struct {
	Version    int    `json:"version"`
	ID         string `json:"id"`
	Title      string `json:"title,omitempty"`
	MediaType  string `json:"media_type"`
	Entrypoint string `json:"entrypoint"`
	Order      int    `json:"order,omitempty"`
}

type Issue

type Issue struct {
	Severity string `json:"severity"`
	Path     string `json:"path"`
	Message  string `json:"message"`
}

type Landmark

type Landmark struct {
	Path      string           `json:"-"`
	Directory string           `json:"-"`
	Version   int              `json:"version"`
	ID        string           `json:"id"`
	Label     string           `json:"label"`
	Selector  LandmarkSelector `json:"selector"`
	Hotspot   *LandmarkRegion  `json:"hotspot,omitempty"`
	Target    string           `json:"target"`
	Diffs     []DiffFile       `json:"diffs,omitempty"`
}

type LandmarkRegion

type LandmarkRegion struct {
	X      float64 `json:"x"`
	Y      float64 `json:"y"`
	Width  float64 `json:"width"`
	Height float64 `json:"height"`
}

type LandmarkSelector

type LandmarkSelector struct {
	Type      string  `json:"type"`
	ElementID string  `json:"element_id,omitempty"`
	HeadingID string  `json:"heading_id,omitempty"`
	Exact     string  `json:"exact,omitempty"`
	Prefix    string  `json:"prefix,omitempty"`
	Suffix    string  `json:"suffix,omitempty"`
	X         float64 `json:"x,omitempty"`
	Y         float64 `json:"y,omitempty"`
	Width     float64 `json:"width,omitempty"`
	Height    float64 `json:"height,omitempty"`
}

type Manifest

type Manifest struct {
	Schema  string `json:"$schema,omitempty"`
	Version int    `json:"version"`
	ID      string `json:"id"`
	Title   string `json:"title"`
	PR      *PR    `json:"pr,omitempty"`
	Source  Source `json:"source"`
}

type MarkdownHeading

type MarkdownHeading struct {
	Level    int
	Text     string
	Anchor   string
	Explicit bool
}

MarkdownHeading describes the small heading subset supported by the reference renderer. Explicit anchors use: ## Heading {#stable-anchor}.

func MarkdownHeadings

func MarkdownHeadings(source string) []MarkdownHeading

func ParseMarkdownHeading

func ParseMarkdownHeading(line string) (MarkdownHeading, bool)

type Message

type Message struct {
	Path              string      `json:"-"`
	AttributionDetail string      `json:"-"`
	ID                string      `json:"id"`
	Author            string      `json:"author,omitempty"`
	CreatedAt         time.Time   `json:"created_at"`
	Fragments         []*Fragment `json:"fragments"`
}

type MessageManifest

type MessageManifest struct {
	Version   int       `json:"version"`
	ID        string    `json:"id"`
	Author    string    `json:"author,omitempty"`
	CreatedAt time.Time `json:"created_at"`
}

type NoteSelector

type NoteSelector struct {
	Text  string  `json:"text"`
	X     float64 `json:"x"`
	Y     float64 `json:"y"`
	Color string  `json:"color,omitempty"`
}

type PR

type PR struct {
	Number *int   `json:"number,omitempty"`
	URL    string `json:"url,omitempty"`
}

PR uses a pointer for Number so an absent pull request number stays absent. schema/v2/saga.schema.json requires a positive number when the field is present; a plain int could not tell "unset" from an invalid literal 0.

type Point

type Point struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

type Review

type Review struct {
	Path              string    `json:"-"`
	AttributionDetail string    `json:"-"`
	Version           int       `json:"version"`
	ID                string    `json:"id"`
	Author            string    `json:"author,omitempty"`
	State             string    `json:"state"`
	Body              string    `json:"body,omitempty"`
	CreatedAt         time.Time `json:"created_at"`
}

type Saga

type Saga struct {
	Root        string       `json:"root"`
	Manifest    Manifest     `json:"manifest"`
	Section     *Section     `json:"section"`
	Threads     []*Thread    `json:"threads,omitempty"`
	DiffReviews []DiffReview `json:"diff_reviews,omitempty"`
}

type Section

type Section struct {
	Path      string      `json:"path"`
	Kind      string      `json:"kind"`
	ID        string      `json:"id"`
	Title     string      `json:"title"`
	Order     int         `json:"order,omitempty"`
	Target    string      `json:"target"`
	Children  []*Section  `json:"children,omitempty"`
	Fragments []*Fragment `json:"fragments,omitempty"`
	Diffs     []DiffFile  `json:"diffs,omitempty"`
	Reviews   []Review    `json:"reviews,omitempty"`
}

type SectionManifest

type SectionManifest struct {
	Version int    `json:"version"`
	ID      string `json:"id"`
	Title   string `json:"title"`
	Order   int    `json:"order,omitempty"`
}

type Shape

type Shape struct {
	Type        string  `json:"type"`
	X           float64 `json:"x,omitempty"`
	Y           float64 `json:"y,omitempty"`
	Width       float64 `json:"width,omitempty"`
	Height      float64 `json:"height,omitempty"`
	Points      []Point `json:"points,omitempty"`
	Color       string  `json:"color,omitempty"`
	StrokeWidth float64 `json:"stroke_width,omitempty"`
}

type Source

type Source struct {
	Repository string `json:"repository"`
	Base       string `json:"base"`
	Head       string `json:"head"`
}

type Suggestion

type Suggestion struct {
	Replacement string `json:"replacement"`
}

type TextSelector

type TextSelector struct {
	Exact  string `json:"exact"`
	Prefix string `json:"prefix,omitempty"`
	Suffix string `json:"suffix,omitempty"`
	Start  int    `json:"start,omitempty"`
	End    int    `json:"end,omitempty"`
	Color  string `json:"color,omitempty"`
}

type Thread

type Thread struct {
	Version           int           `json:"version"`
	ID                string        `json:"id"`
	Target            string        `json:"target"`
	Anchor            Anchor        `json:"anchor"`
	Kind              string        `json:"kind,omitempty"`
	Suggestion        *Suggestion   `json:"suggestion,omitempty"`
	CreatedBy         string        `json:"created_by,omitempty"`
	CreatedAt         time.Time     `json:"created_at"`
	Directory         string        `json:"-"`
	AttributionDetail string        `json:"-"`
	Messages          []*Message    `json:"messages,omitempty"`
	Events            []ThreadEvent `json:"events,omitempty"`
	State             string        `json:"state"`
}

type ThreadEvent

type ThreadEvent struct {
	Path              string    `json:"-"`
	AttributionDetail string    `json:"-"`
	Version           int       `json:"version"`
	ID                string    `json:"id"`
	Author            string    `json:"author,omitempty"`
	State             string    `json:"state,omitempty"`
	Anchor            *Anchor   `json:"anchor,omitempty"`
	CreatedAt         time.Time `json:"created_at"`
}

type ThreadManifest

type ThreadManifest struct {
	Version    int         `json:"version"`
	ID         string      `json:"id"`
	Target     string      `json:"target"`
	Anchor     Anchor      `json:"anchor"`
	Kind       string      `json:"kind,omitempty"`
	Suggestion *Suggestion `json:"suggestion,omitempty"`
	CreatedBy  string      `json:"created_by,omitempty"`
	CreatedAt  time.Time   `json:"created_at"`
}

type Validation

type Validation struct {
	Valid  bool    `json:"valid"`
	Issues []Issue `json:"issues"`
}

Jump to

Keyboard shortcuts

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