render

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package render turns domain types into the two output forms: compact fixed-column text and flat JSON.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorEnabled added in v0.11.0

func ColorEnabled(w io.Writer) bool

ColorEnabled decides whether output to w carries color: the environment contract applied to whether w is a real terminal.

func CursorHookJSON added in v0.11.0

func CursorHookJSON(w io.Writer, primer string) error

CursorHookJSON writes the primer as the JSON object Cursor's sessionStart hook reads: its stdout must be valid JSON — bare primer text fails the parse — and the context travels in additional_context. The spelling is snake_case on purpose: Cursor ignores Claude Code's camelCase additionalContext field.

func EpicList

func EpicList(w io.Writer, issues []model.Issue, s Style)

EpicList renders epics with their progress rollups.

func EpicStatus

func EpicStatus(w io.Writer, epic model.Issue, children []model.Issue, s Style)

EpicStatus renders one epic and its children. Children are the epic's full parent-backlinked set (complete even when the sub-issue connection was capped); the rollup line keeps the server-side completed/total.

func FormatCycle

func FormatCycle(path []int) string

FormatCycle renders a cycle's member path as "#a → #b → … → #a".

func FormatWarning

func FormatWarning(w model.Warning) string

FormatWarning renders a structured warning as the human sentence shown in prime and ready output. It is the single place warning prose lives.

func JSONEpicStatus

func JSONEpicStatus(w io.Writer, epic model.Issue, children []model.Issue) error

JSONEpicStatus writes one epic and its children. Children are the epic's full parent-backlinked set, so every entry is a real fetched issue — no fabricated placeholders — and the list is complete even when the epic's sub-issue connection was capped.

func JSONIssue

func JSONIssue(w io.Writer, i model.Issue, children []model.Issue) error

JSONIssue writes one issue with full detail. Children is the issue's parent-backlinked child set, used to name the next workable child when the issue is an epic.

func JSONList

func JSONList(w io.Writer, issues []model.Issue, withBodies bool) error

JSONList writes issues as NDJSON — one compact object per line. Unlike an array, it stays parseable under head/grep and agent output truncation, which is how list output actually gets consumed. withBodies carries each issue's body (list --bodies), turning dedup over the triaged tracker into a single call instead of a show per candidate.

func JSONPrime

func JSONPrime(w io.Writer, d PrimeData) error

JSONPrime writes the primer's live state as JSON (the static primer text is for context injection, not machine consumption).

func JSONShow added in v0.13.0

func JSONShow(w io.Writer, i model.Issue, children []model.Issue) error

JSONShow is JSONIssue plus attributed findings, for the show read only — write commands reuse JSONIssue and stay unannotated. Clean issues omit textFindings, so their detail output is unchanged.

func JSONTriage added in v0.12.0

func JSONTriage(w io.Writer, issues []model.Issue) error

JSONTriage adds findings to the normal NDJSON issue schema only on triage. Clean issues omit textFindings, preserving their ordinary list representation.

func JSONUnchanged added in v0.15.0

func JSONUnchanged(w io.Writer, i model.Issue) error

JSONUnchanged writes one issue with full detail plus unchanged: true, the marker for a write whose requested state already held. Changed writes emit JSONIssue, which omits the field.

func Line

func Line(i model.Issue, s Style) string

Line renders one issue as `#n meta title`, unaligned. Under a color style the number is amber and the priority green.

func List

func List(w io.Writer, issues []model.Issue, s Style)

List renders one aligned line per issue, annotated with whatever keeps it from being plain ready work.

func ListWithAssignees

func ListWithAssignees(w io.Writer, issues []model.Issue, s Style)

ListWithAssignees renders lines with @assignee suffixes (in-progress view).

func Prime

func Prime(w io.Writer, static string, d PrimeData, s Style)

Prime renders the session-start primer: static conventions, live state, contradictions. Sections are omitted when empty.

func SanitizeInline added in v0.11.0

func SanitizeInline(s string) string

SanitizeInline neutralizes every control character in a value rendered on one line. Newline and tab go too: neither is formatting there, and a newline would let a hostile title forge a line of its own. Exported so command-level messages that bypass the renderer (start's title echo, guard and warning logins) route through the same sanitizer.

func Show

func Show(w io.Writer, i model.Issue, children []model.Issue, s Style)

Show renders the full detail view for one issue. Children is the issue's parent-backlinked child set (empty for non-epics), used to name the epic's next workable child.

func Triage added in v0.12.0

func Triage(w io.Writer, issues []model.Issue, s Style)

Triage adds advisory Unicode findings without filtering or rewriting issues.

func WriteJSON

func WriteJSON(w io.Writer, v any) error

WriteJSON writes any value in the standard indented form; for the odd command whose output isn't issue-shaped.

Types

type CommentJSON

type CommentJSON struct {
	Author    string    `json:"author"`
	CreatedAt time.Time `json:"createdAt"`
	Body      string    `json:"body"`
}

CommentJSON is one recent comment in show --json.

type EpicStatusJSON

type EpicStatusJSON struct {
	Epic     IssueJSON   `json:"epic"`
	Next     *int        `json:"next"`
	Children []IssueJSON `json:"children"`
}

EpicStatusJSON pairs an epic with its resolved children and the next workable one (null when the sequence is dry).

type IssueJSON

type IssueJSON struct {
	Number             int       `json:"number"`
	Title              string    `json:"title"`
	State              string    `json:"state"`
	Priority           *string   `json:"priority"`
	Type               *string   `json:"type"`
	Areas              []string  `json:"areas"`
	Assignees          []string  `json:"assignees"`
	Epic               bool      `json:"epic"`
	InProgress         bool      `json:"inProgress"`
	Untriaged          bool      `json:"untriaged"`
	Parent             *int      `json:"parent"`
	BlockedBy          []int     `json:"blockedBy"`
	BlockedByTotal     int       `json:"blockedByTotal"`
	OpenBlockers       []int     `json:"openBlockers"`
	SubIssues          []int     `json:"subIssues"`
	SubIssuesTotal     int       `json:"subIssuesTotal"`
	SubIssuesCompleted int       `json:"subIssuesCompleted"`
	CreatedAt          time.Time `json:"createdAt"`
	// Next is set only for an epic's detail view (show --json): the next
	// workable child's number. Absent, not null, for non-epics and when the
	// sequence is dry — consumers key on the epic field for the difference.
	Next *int `json:"next,omitempty"`
	// Body is a pointer so presence tracks the mode (show, list --bodies)
	// rather than emptiness: modes that carry it emit the field on every
	// issue, empty or not, and plain list lines stay byte-for-byte body-free.
	Body          *string       `json:"body,omitempty"`
	Comments      []CommentJSON `json:"comments,omitempty"`
	CommentsTotal int           `json:"commentsTotal,omitempty"`
}

IssueJSON is the stable flat schema for --json output: deps as number arrays, GraphQL shapes hidden.

func ToJSON

func ToJSON(i model.Issue, withDetail bool) IssueJSON

ToJSON converts an issue to the flat schema. Body and comments are only carried when withDetail is set (show).

type PrimeData

type PrimeData struct {
	Repo            string
	Ready           []model.Issue // already capped to top N
	ReadyTotal      int
	OpenTotal       int
	InProgress      []model.Issue // already capped to top N
	InProgressTotal int
	Epics           []model.Issue // already capped to top N
	EpicsTotal      int
	Warnings        []model.Warning
	Untriaged       int
}

PrimeData is everything the primer needs, precomputed by the command.

type PrimeJSON

type PrimeJSON struct {
	Repo            string        `json:"repo"`
	OpenTotal       int           `json:"openTotal"`
	ReadyTotal      int           `json:"readyTotal"`
	Ready           []IssueJSON   `json:"ready"`
	InProgress      []IssueJSON   `json:"inProgress"`
	InProgressTotal int           `json:"inProgressTotal"`
	Epics           []IssueJSON   `json:"epics"`
	EpicsTotal      int           `json:"epicsTotal"`
	Untriaged       int           `json:"untriaged"`
	Warnings        []WarningJSON `json:"warnings"`
}

PrimeJSON is the structured form of the primer's live state.

type Style added in v0.11.0

type Style struct {
	// contains filtered or unexported fields
}

Style carries whether text renderers wrap their semantic spans in ANSI. The zero value renders plain — every existing golden test, agent pipe, and --json stream stays byte-identical.

func StyleFor added in v0.11.0

func StyleFor(on bool) Style

StyleFor converts the precomputed color decision into a Style. The decision is made once, in main, against the real stdout; the renderers only ever see the boolean.

type TextFindingJSON added in v0.13.0

type TextFindingJSON struct {
	Source       string `json:"source"`
	CommentIndex *int   `json:"commentIndex,omitempty"`
	model.TextFindings
}

TextFindingJSON is one field's advisory Unicode findings in show --json. Source is "title", "body" or "comment"; CommentIndex is set only for a comment and indexes the emitted comments array.

type WarningJSON

type WarningJSON struct {
	Kind    string `json:"kind"`
	Issue   int    `json:"issue,omitempty"`
	Cycle   []int  `json:"cycle,omitempty"`
	Total   int    `json:"total,omitempty"`
	Fetched int    `json:"fetched,omitempty"`
	Message string `json:"message"`
}

WarningJSON is one structured warning: a machine-readable kind plus the numbers involved, alongside the rendered human message. Consumers branch on kind rather than parsing message prose.

Jump to

Keyboard shortcuts

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