show

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package show implements the `aiwf show` verb (per-verb subpackage of M-0116). The neutral, Cobra-free view-building helpers (HistoryEvent, ScopeView, AssembleScopeViews, ReadEntityBody, ...) live in internal/entityview; this package holds the Cobra wiring plus the git-orchestrating LoadEntityScopeViews (scopes.go), which composes them with cliutil's scope-FSM reads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreaMissLine added in v0.17.0

func AreaMissLine(id, actual, requested string) string

AreaMissLine is the one-line text rendered when `aiwf show <id> --area <name>` filters the named entity out because its effective area differs (E-0043, M-0174/AC-3). `show` is single-entity, so the predicate hides the one entity (like an empty list) rather than listing — the line tells the operator the entity exists but lives elsewhere. An untagged entity (actual == "") gets its own wording.

func LoadEntityScopeViews

func LoadEntityScopeViews(ctx context.Context, root, id string) ([]entityview.ScopeView, error)

LoadEntityScopeViews returns every scope that ever applied to id — scopes opened ON id (directly), plus scopes from elsewhere that authorized work touching id (via `aiwf-authorized-by:`).

Source (b) — scopes opened directly on id — comes from id's own history via cliutil.LoadEntityScopes, which is width-tolerant: this is both the single source of truth for direct scopes and the fix for the narrow-id omission (a raw-id `ent == id` compare against a canonicalized map value silently dropped `aiwf show E-14`'s table; M-0223).

Source (a) — scopes opened elsewhere that authorized work on id — is the only reason to run the repo-wide authorize-opener grep (cliutil.AuthorizeOpeners), and only when id was actually worked under a foreign scope (entityview.HasAuthorizedBy). An active direct-scope opener, which has no `aiwf-authorized-by`, resolves entirely from source (b) without the grep (E-0054 read-verb guard).

Empty / pre-aiwf repos return (nil, nil).

The git-reading orchestration lives here (in the CLI layer, via cliutil) rather than in internal/entityview: the neutral package stays free of internal/cli dependencies, and cliutil.LoadEntityScopes / cliutil.AuthorizeOpeners are full scope-FSM replays, not the kind of small self-contained helper worth duplicating across the boundary.

func NewCmd

func NewCmd(correlationID string) *cobra.Command

NewCmd builds `aiwf show <id>`. Aggregates per-entity state from the existing data sources — frontmatter (entity), git log (history), aiwf check (findings) — into one human-readable view (or one JSON envelope when --format=json). No new state; pure projection.

For composite ids (M-NNN/AC-N), renders just the AC's slice of the parent milestone plus its history.

func Run

func Run(id, root, format, area string, pretty bool, historyLimit int, correlationID string) (code int)

Run executes `aiwf show`. Returns one of the cliutil.Exit* codes.

Types

type CrossBranchView added in v0.27.0

type CrossBranchView struct {
	// Ref is the ref content was read from. Empty when Collision is
	// true — no single ref was chosen.
	Ref string `json:"ref,omitempty"`
	// Collision is true when the candidate refs carry divergent
	// content (M-0259/AC-3). Title/Status/Body/ACs are left empty on
	// the ShowView in that case — aiwf show declines to pick a side
	// (M-0260/AC-3) rather than render one ref's content as canonical.
	Collision bool     `json:"collision"`
	Refs      []string `json:"refs"`
}

CrossBranchView carries the read-side resolution state for an id resolved from another ref (M-0260/AC-1/AC-2/AC-3). Refs always lists every candidate ref the id is known on — one entry when Collision is false, two or more when true.

type ShowAC

type ShowAC struct {
	ID          string `json:"id"`
	Title       string `json:"title"`
	Status      string `json:"status"`
	TDDPhase    string `json:"tdd_phase,omitempty"`
	Description string `json:"description,omitempty"`
}

ShowAC is one AC's view inside a milestone show. Description carries the prose under the matching `### AC-N — <title>` heading in the milestone body, trimmed of surrounding whitespace; empty when the milestone body has no body section for this AC (e.g. seeded purely via frontmatter).

type ShowView

type ShowView struct {
	ID     string `json:"id"`
	Kind   string `json:"kind"`
	Title  string `json:"title"`
	Status string `json:"status"`
	Path   string `json:"path,omitempty"`
	Parent string `json:"parent,omitempty"`
	TDD    string `json:"tdd,omitempty"`
	// Priority carries the entity's own `priority` frontmatter
	// (G-0078, E-0066, M-0263) — empty for a kind that never carries
	// one (entity.CarriesOwnPriority) or an unprioritized gap/decision.
	Priority     string                    `json:"priority,omitempty"`
	ACs          []ShowAC                  `json:"acs,omitempty"`
	Body         map[string]string         `json:"body,omitempty"`
	History      []entityview.HistoryEvent `json:"history,omitempty"`
	Findings     []check.Finding           `json:"findings,omitempty"`
	ReferencedBy []string                  `json:"referenced_by"`
	Scopes       []entityview.ScopeView    `json:"scopes,omitempty"`

	// Archived is true when the resolved entity's path lives under a
	// per-kind `archive/` subdirectory per ADR-0004. JSON shape uses
	// `omitempty` so active envelopes don't carry the field at all —
	// downstream tooling treats presence as the indicator. Text
	// rendering appends ` · archived` to the header line (see
	// renderShowText). M-0087/AC-5.
	Archived bool `json:"archived,omitempty"`

	// Composite-id-only fields (when querying M-NNN/AC-N): the AC's
	// own state, populated instead of (not in addition to) the
	// milestone's full ACs slice.
	AC       *ShowAC `json:"ac,omitempty"`
	ParentID string  `json:"parent_id,omitempty"`

	// CrossBranch is non-nil when id missed the local working tree but
	// resolved live from another local or remote-tracking ref (M-0260,
	// ADR-0030's read-side extension point). Nil for a locally-resolved
	// entity — the JSON envelope omits the field entirely so a
	// downstream consumer can treat its absence as "this is ordinary
	// local state."
	CrossBranch *CrossBranchView `json:"cross_branch,omitempty"`

	// Area carries the resolving ref's real `area:` for a cross-branch
	// hit so the `aiwf show --area` predicate can evaluate against the
	// entity's actual area instead of the local-only tr.ResolvedAreaByID
	// lookup, which reports any cross-branch id untagged (E-0067/M-0266,
	// G-0419). In-memory only (json:"-") — the JSON envelope's shape is
	// unchanged. Empty for a locally-resolved entity (the predicate uses
	// the local lookup there); for a cross-branch collision (the content,
	// including the area, is in dispute); and for a cross-branch
	// milestone, whose own `area:` is never stored — a milestone's area
	// rolls up from its parent epic, a resolution this own-field read
	// deliberately does not follow across refs.
	Area string `json:"-"`
}

ShowView is the aggregated per-entity state. Exported for the JSON envelope. Field-set varies by what kind of id was queried; absent fields render as empty / omitted in JSON via omitempty.

ReferencedBy is the inversion of the reference graph — every entity id that names this one as a target. Always emitted in JSON (zero- value `[]`) so downstream consumers never have to check for field presence; populated from tree.Tree.ReverseRefs at view-build time. For composite ids (M-NNN/AC-N), this lists referrers of the AC specifically; the parent milestone's referrers are not rolled in (use `aiwf show M-NNN` for that).

func BuildCompositeShowView

func BuildCompositeShowView(ctx context.Context, root string, t *tree.Tree, loadErrs []tree.LoadError, id string, historyLimit int) (ShowView, bool, error)

BuildCompositeShowView handles `aiwf show M-NNN/AC-N`. Returns ok=false when the parent or AC doesn't exist. err is non-nil only on a history/scope read failure (G-0427), mirroring BuildShowView.

func BuildShowView

func BuildShowView(ctx context.Context, root string, t *tree.Tree, loadErrs []tree.LoadError, id string, historyLimit int) (ShowView, bool, error)

BuildShowView assembles the view for id; ok=false when no entity (or AC) matches. Composite ids resolve via the parent milestone's ACs slice. err is non-nil only on a history/scope read failure (G-0427) — a genuine git/environmental fault, distinct from ok=false's "id not found," which is never an error.

Jump to

Keyboard shortcuts

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