play

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package play implements shared reading annotations. Notes are anchored to passages in a source text, with separate authors, timestamps, and threaded replies. A changed source produces an explicit anchor conflict rather than silently moving notes.

Companion view for nova-tools #223: browse shared moments without rewriting the record.

View renders an explicitly selected sample of Markdown records into a static, chronological timeline on one machine. It is read-only: it opens each selected file, parses a card from it, and prints text. It never writes, seals, rolls up or deletes anything, and an excluded record is never even opened.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Export

func Export(source string) (string, error)

Export returns a portable markdown-formatted string of all annotations for a source, with authors, timestamps, threads, and anchor status.

func HashSource

func HashSource(path string) (string, error)

HashSource returns the sha256 hex of the source file contents.

func NoteFile

func NoteFile(source string) string

NoteFile returns the annotation file path for a given source.

func SaveStore

func SaveStore(source string, s *Store) error

SaveStore writes the store to the annotation file.

func View

func View(sources []string, exclude []string, max int) (string, error)

View renders sources into a static timeline and returns it as text.

Every path in sources is explicit: there is no default file, no directory walk and no discovery. A path matching an exclude glob — against the path as given or its base name — is skipped before it is opened and counted as excluded. max caps the cards printed (0 prints every card); the summary line always carries the totals, so a capped run still says how much it stood aside. A negative max, a bad glob, or an unreadable selection is an error and prints nothing half-done.

Types

type Anchor

type Anchor struct {
	SourcePath string // path to the source text
	SourceHash string // sha256 of the source at annotation time
}

Anchor holds the source hash used to detect stale anchors.

type Note

type Note struct {
	ID        string    // sha12 of author+passage+note at creation
	Author    string    // who wrote this
	Passage   string    // the anchored passage text
	Note      string    // the annotation text
	CreatedAt time.Time // when this was written
	Replies   []Reply   // threaded replies
}

Note is a single annotation anchored to a passage.

func Annotate

func Annotate(source, author, passage, note string) (Note, error)

Annotate adds a note to the store. It verifies the passage exists in the source and records the source hash for stale-anchor detection.

func ReadNotes

func ReadNotes(source string) ([]Note, string, error)

ReadNotes returns all notes for a source, checking anchor consistency.

type Reply

type Reply struct {
	ID        string // sha12 of author+note at creation
	Author    string
	Note      string
	CreatedAt time.Time
}

Reply is a response to a Note.

func ReplyTo

func ReplyTo(source, noteID, author, note string) (Reply, error)

ReplyTo adds a reply to an existing note.

type Store

type Store struct {
	Anchor  Anchor `json:"anchor"`
	Notes   []Note `json:"notes"`
	Version int    `json:"version"`
}

Store is the on-disk format for annotations.

func LoadStore

func LoadStore(source string) (*Store, error)

LoadStore reads the annotation store for a source. Returns an empty store if the file does not exist.

Jump to

Keyboard shortcuts

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