takes

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package takes manages candidate takes and the selected slot for a reel workspace (spec 0001 §3.2 "take management"; contract 0002 §2, R-WS-1). N candidate takes are generated into <kind>/takes/, then one is *selected* — promoted to the committed slot that assembly consumes. This replaces the manual `cp take vo/NN.mp3`. Pure afero logic; unit-tested in memory.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoTake = errors.NewSentinel("keyrx.no_take", "take not found")

ErrNoTake is returned when a requested take does not exist.

View Source
var ErrNotATake = errors.NewSentinel("keyrx.not_a_take", "not a take")

ErrNotATake is returned for a path that is not a candidate take at all.

View Source
var ErrTakeInUse = errors.NewSentinel("keyrx.take_in_use", "take is currently promoted")

ErrTakeInUse is returned when the take is the promoted one — discarding it would leave its slot dangling mid-edit, so promote another first (0041 D5).

Functions

func CardSelected

func CardSelected(ws string, card int, ext string) string

func CardTake

func CardTake(ws string, card, take int, ext string) string

CardTake / CardSelected: cards/takes/NN-T.<ext> and cards/NN.<ext>.

func CardTakesDir

func CardTakesDir(ws string) string

CardTakesDir is the directory holding a workspace's candidate card takes.

func CommitDiscard added in v0.9.0

func CommitDiscard(fs afero.Fs, ws, rel string) error

CommitDiscard makes the discard final by dropping the parked copy. The blob in the object store is untouched — `media gc --prune` reclaims it safely (D2). Committing something already gone is fine: the end state is what was asked for.

func CoverSelected

func CoverSelected(ws string) string

func CoverTake

func CoverTake(ws string, take int, ext string) string

CoverTake / CoverSelected: cover/takes/T.<ext> and cover.png (the bookend slot).

func CoverTakesDir

func CoverTakesDir(ws string) string

func Current added in v0.9.0

func Current(fs afero.Fs, ws string, takeRels []string, selFor func(name string) string) string

Current reports which of the ws-relative candidate takes is the one in use: promote() copies bytes into the selected slot, so the take whose content equals the slot resolved by selFor (given the take's base filename) is current. Returns "" when nothing is promoted yet, or the slot was replaced outside the takes flow (e.g. an upload). selFor takes the filename because the slot can depend on it (card slots carry the take's extension).

func Discard added in v0.9.0

func Discard(fs afero.Fs, ws, rel string) error

Discard moves a candidate take aside into .cache/discarded/, leaving the bytes intact for Restore. It refuses the promoted take (ErrTakeInUse) and anything that is not a take (ErrNotATake); a take that isn't there is ErrNoTake.

func DiscardedPath added in v0.9.0

func DiscardedPath(ws, rel string) string

DiscardedPath is where a workspace-relative take is parked while discarded.

func HasCardSelected

func HasCardSelected(fs afero.Fs, ws string, card int) bool

HasCardSelected reports whether card has a selected illustration (cards/NN.<any>).

func HasVOSelected

func HasVOSelected(fs afero.Fs, ws string, line int) bool

HasVOSelected reports whether line's selected VO take (vo/NN.mp3) exists.

func IsPromoted added in v0.9.0

func IsPromoted(fs afero.Fs, ws, rel string) bool

IsPromoted reports whether the take is the one currently in its slot, compared by content — the same test the galleries use to mark the current take.

func ListCardTakes

func ListCardTakes(fs afero.Fs, ws string, card int) []string

ListCardTakes returns the take filenames for a card (1-based), sorted. A missing takes dir yields an empty list (no takes generated yet).

func ListCoverTakes

func ListCoverTakes(fs afero.Fs, ws string) []string

ListCoverTakes returns the cover take filenames, sorted (empty if none).

func ListMusicTakes

func ListMusicTakes(fs afero.Fs, ws string) []string

ListMusicTakes returns the music bed take filenames (music/takes/T.mp3), sorted.

func ListPortraitTakes

func ListPortraitTakes(fs afero.Fs, ws string) []string

ListPortraitTakes returns the portrait take filenames, sorted (empty if none).

func ListVOTakes

func ListVOTakes(fs afero.Fs, ws string, line int) []string

ListVOTakes returns a line's VO take filenames (vo/takes/NN-T.mp3), sorted.

func MusicSelected

func MusicSelected(ws string) string

func MusicTake

func MusicTake(ws string, take int) string

MusicTake / MusicSelected: music/takes/T.mp3 and music.mp3.

func MusicTakesDir

func MusicTakesDir(ws string) string

func NextCardTake

func NextCardTake(fs afero.Fs, ws string, card int, ext string) int

NextCardTake returns the next take number for a card.

func NextCoverTake

func NextCoverTake(fs afero.Fs, ws string) int

func NextMusicTake

func NextMusicTake(fs afero.Fs, ws string) int

NextMusicTake returns the next bed take number.

func NextPortraitTake

func NextPortraitTake(fs afero.Fs, ws string) int

func NextVOTake

func NextVOTake(fs afero.Fs, ws string, line int) int

NextVOTake returns the next take number for a line (1-based).

func ParseCardTake

func ParseCardTake(name string) (card, take int, ext string, err error)

ParseCardTake extracts the card index, take number, and extension from a card take filename "NN-T.ext" (e.g. "02-3.png" → 2, 3, "png").

func ParseTake

func ParseTake(name string) (take int, ext string, err error)

ParseTake extracts the take number + extension from a single-slot take filename "T.ext" (cover/portrait, e.g. "3.png" → 3, "png").

func PortraitSelected

func PortraitSelected(ws string) string

func PortraitTake

func PortraitTake(ws string, take int, ext string) string

PortraitTake / PortraitSelected: portrait/takes/T.<ext> and portrait.png.

func PortraitTakesDir

func PortraitTakesDir(ws string) string

func Prune

func Prune(fs afero.Fs, ws string) error

Prune removes the disposable takes dirs and the generation cache (R-WS-22 / `keryx reel prune`); the selected artefacts are untouched.

func Restore added in v0.9.0

func Restore(fs afero.Fs, ws, rel string) error

Restore returns a discarded take to its gallery — the undo. A take that was never discarded is ErrNoTake rather than a silent no-op, so a stale undo surfaces instead of pretending to succeed.

func SelectCard

func SelectCard(fs afero.Fs, ws string, card, take int, ext string) error

SelectCard promotes cards/takes/NN-T.<ext> to cards/NN.<ext>.

func SelectCover

func SelectCover(fs afero.Fs, ws string, take int) error

SelectCover promotes cover/takes/T.png to cover.png.

func SelectMusic

func SelectMusic(fs afero.Fs, ws string, take int) error

SelectMusic promotes music/takes/T.mp3 to music.mp3.

func SelectPortrait

func SelectPortrait(fs afero.Fs, ws string, take int) error

SelectPortrait promotes portrait/takes/T.png to portrait.png.

func SelectVO

func SelectVO(fs afero.Fs, ws string, line, take int) error

SelectVO promotes vo/takes/NN-T.mp3 to vo/NN.mp3.

func SetCard

func SetCard(fs afero.Fs, ws string, card int, src string) error

SetCard copies an external pre-rendered file into the selected card slot (uploaded media — `keryx cards set`), inferring the extension from src.

func SlotFor added in v0.9.0

func SlotFor(ws, rel string) string

SlotFor maps a workspace-relative TAKE path to the slot path it occupies when promoted, or "" when rel is not a recognised take. One mapping serves every media kind, which is what lets discard have a single implementation.

func VOSelected

func VOSelected(ws string, line int) string

func VOTake

func VOTake(ws string, line, take int) string

VOTake / VOSelected: vo/takes/NN-T.mp3 and vo/NN.mp3.

func VOTakesDir

func VOTakesDir(ws string) string

VOTakesDir / MusicTakesDir: the dirs holding candidate audio takes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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