Documentation
¶
Overview ¶
Package view aggregates everything known about one requirement — tokens, files, tests, dependencies, spec/plan, diagrams, ticket link — into one bounded, agent-friendly answer. CANARY: REQ=CP-270; FEATURE="RequirementView"; ASPECT=CLI; STATUS=TESTED; TEST=TestCANARY_CBIN_204_BuildView,TestCANARY_CBIN_204_BuildView_DeclaredWording,TestViewCustomDBAndRoot; UPDATED=2026-08-31 CANARY: REQ=ENG-4325; FEATURE="MigrateNotesView"; ASPECT=CLI; STATUS=TESTED; TEST=TestCANARY_CBIN_301_BuildView_MigrateNotes,TestCANARY_CBIN_301_BuildView_MigrateNotesCap; UPDATED=2026-08-29 CANARY: REQ=CP-278; FEATURE="DriftedView"; ASPECT=CLI; STATUS=TESTED; TEST=TestCANARY_CBIN_305_BuildView_Drifted,TestCANARY_CBIN_305_BuildView_NotDrifted,TestCANARY_CBIN_305_BuildView_NonGitRootSoftSkip; UPDATED=2026-08-29
Index ¶
Constants ¶
const DefaultViewLimit = 10
DefaultViewLimit bounds list sections (files, diagrams) by default; agents raise it with --limit when they need the full list.
Variables ¶
This section is empty.
Functions ¶
func CreateViewCommand ¶
CreateViewCommand returns the `canary view` command.
--root and --db give view the same scope parity pkg/cmds/deps and pkg/cmds/bug already have (Tasks 9/14): a relative --db is resolved beneath --root, never CWD, so `view --root X <REQ-ID>` reads X's database without also needing --db, and `view --root X --db custom.db` opens X/custom.db rather than CWD/custom.db. Before this, view hardcoded ".canary/canary.db" and "." regardless of any flag (V4-12/GAP :23).
Types ¶
type View ¶
type View struct {
ReqID string `json:"req_id"`
Source string `json:"source,omitempty"`
TicketURL string `json:"ticket_url,omitempty"`
Statuses map[string]int `json:"statuses"` // status -> token count
// DeclaredCompletionPct is the percentage of tokens declaring
// STATUS=TESTED or STATUS=BENCHED -- declared status, not verified
// evidence (R-15). Renamed from "Completion" so the field name itself
// cannot be misread as a verified completion percentage.
DeclaredCompletionPct int `json:"declared_completion_pct"`
Features []string `json:"features"` // "Feature (ASPECT, STATUS)"
Files []string `json:"files"` // capped at limit
FilesTotal int `json:"files_total"`
Tests []string `json:"tests"`
Benches []string `json:"benches,omitempty"`
DependsOn []string `json:"depends_on,omitempty"`
Blocks []string `json:"blocks,omitempty"`
RelatedTo []string `json:"related_to,omitempty"`
SpecPath string `json:"spec_path,omitempty"`
PlanPath string `json:"plan_path,omitempty"`
Diagrams []string `json:"diagrams,omitempty"` // "file:line"
DiagramsTotal int `json:"diagrams_total,omitempty"`
MigrateNotes []string `json:"migrate_notes,omitempty"` // "file:line: text"
MigrateNotesTotal int `json:"migrate_notes_total,omitempty"`
Drifted bool `json:"drifted,omitempty"`
DriftReason string `json:"drift_reason,omitempty"`
}
View is the aggregate answer for one requirement: everything an agent or a human needs to orient on CANARY tokens, files, tests, dependencies, spec/plan location, diagram refs, and (when configured) the owning ticket system — in one bounded call.
func BuildView ¶
BuildView assembles the view from the index DB plus filesystem conventions. The database is opened read-only: viewing a requirement never creates or migrates an index. projectID scopes the lookup; "" spans every project and reports storage.ErrProjectRequired when that would be ambiguous.