Documentation
¶
Overview ¶
Package markdown provides parsing and mutation for SPEC.md files. It operates on line-level patterns, not a full AST — sufficient for the structured SPEC.md format.
Index ¶
- Constants
- func AppendDecision(path, question, user string) (int, error)
- func Body(content string) string
- func FormatDecisionTable(entries []DecisionEntry) string
- func IsSectionNonEmpty(sections []Section, slug string) bool
- func IsValidSectionSlug(slug string) bool
- func NextSpecID(existingFiles []string) string
- func NextTriageID(existingFiles []string) string
- func ReplaceSection(path, slug, newContent string) error
- func ReplaceSectionContent(content, slug, newContent string) (string, error)
- func ResolveDecision(path string, number int, decision, rationale, user string) error
- func ScaffoldSpec(id, title, author, cycle, source string) string
- func ScaffoldTriage(id, title, priority, source, sourceRef, reportedBy string) string
- func UpdateFrontmatter(content string, meta *SpecMeta) (string, error)
- func ValidSectionSlugs() []string
- func WriteMeta(path string, meta *SpecMeta) error
- type BuildStep
- type DecisionEntry
- type ReviewApproval
- type ReviewState
- type Section
- type SpecMeta
- type TriageMeta
Constants ¶
const ( StepStatusPending = "pending" StepStatusInProgress = "in-progress" StepStatusComplete = "complete" StepStatusBlocked = "blocked" )
Step status constants.
const ( ReviewStatusPending = "pending" ReviewStatusApproved = "approved" ReviewStatusChangesRequested = "changes_requested" )
Review status constants.
Variables ¶
This section is empty.
Functions ¶
func AppendDecision ¶
AppendDecision adds a new question to the decision log in a file. Returns the assigned decision number.
func FormatDecisionTable ¶
func FormatDecisionTable(entries []DecisionEntry) string
FormatDecisionTable renders decision entries as a markdown table.
func IsSectionNonEmpty ¶
IsSectionNonEmpty checks if a section has meaningful content (not just whitespace).
func IsValidSectionSlug ¶
IsValidSectionSlug checks if the slug is a known section.
func NextSpecID ¶
NextSpecID scans existing spec filenames and returns the next sequential ID. Files should be like SPEC-001.md, SPEC-002.md, etc.
func NextTriageID ¶
NextTriageID scans existing triage filenames and returns the next sequential ID.
func ReplaceSection ¶
ReplaceSection replaces the content of a section in a file.
func ReplaceSectionContent ¶
ReplaceSectionContent replaces a section's content in the markdown string.
func ResolveDecision ¶
ResolveDecision updates an existing decision log entry.
func ScaffoldSpec ¶
ScaffoldSpec generates a new SPEC.md from the template.
func ScaffoldTriage ¶
ScaffoldTriage generates a new TRIAGE.md from the template.
func UpdateFrontmatter ¶
UpdateFrontmatter returns content with updated frontmatter, preserving the body. It also updates the 'updated' field to today's date.
func ValidSectionSlugs ¶
func ValidSectionSlugs() []string
ValidSectionSlugs returns all valid section slugs from the spec template.
Types ¶
type BuildStep ¶
type BuildStep struct {
// Repo is the repository this step targets.
Repo string `yaml:"repo"`
// Description is a brief summary of what this step accomplishes.
Description string `yaml:"description"`
// Branch is the git branch name for this step (auto-generated if empty).
Branch string `yaml:"branch,omitempty"`
// PR is the pull request number once created.
PR int `yaml:"pr,omitempty"`
// Status tracks the step's progress: pending, in-progress, complete, blocked.
Status string `yaml:"status"`
// BlockedReason explains why this step is blocked (when Status == "blocked").
BlockedReason string `yaml:"blocked_reason,omitempty"`
}
BuildStep represents a single step in the build plan. Steps are a checklist of work items, not git-level PR stacking.
type DecisionEntry ¶
type DecisionEntry struct {
Number int
Question string
Options string
Decision string
Rationale string
DecidedBy string
Date string
}
DecisionEntry represents a row in the decision log table.
func ParseDecisionLog ¶
func ParseDecisionLog(content string) ([]DecisionEntry, error)
ParseDecisionLog extracts decision entries from markdown content.
func ParseDecisionLogFromFile ¶
func ParseDecisionLogFromFile(path string) ([]DecisionEntry, error)
ParseDecisionLogFromFile reads a spec file and extracts the decision log.
type ReviewApproval ¶
type ReviewApproval struct {
Reviewer string `yaml:"reviewer"`
ApprovedAt string `yaml:"approved_at"`
}
ReviewApproval records a single reviewer's approval.
type ReviewState ¶
type ReviewState struct {
// RequestedAt is when the review was requested.
RequestedAt string `yaml:"requested_at,omitempty"`
// Reviewers is the list of users/roles who should review.
Reviewers []string `yaml:"reviewers,omitempty"`
// Approvals records who has approved and when.
Approvals []ReviewApproval `yaml:"approvals,omitempty"`
// Status is the overall review state: pending, approved, changes_requested.
Status string `yaml:"status"`
// Feedback contains reviewer feedback when changes are requested.
Feedback string `yaml:"feedback,omitempty"`
}
ReviewState tracks plan review status for async approval workflow.
type Section ¶
type Section struct {
Slug string // e.g., "problem_statement"
Heading string // e.g., "## 1. Problem Statement"
Level int // heading level (2 = ##, 3 = ###)
Owner string // from <!-- owner: role --> marker, or "auto"
Content string // raw markdown content (excluding heading line)
StartLine int // line number in the source file (1-indexed)
EndLine int // line number (exclusive)
}
Section represents a parsed markdown section with ownership.
func ExtractSections ¶
ExtractSections parses markdown content into sections.
func ExtractSectionsFromFile ¶
ExtractSectionsFromFile reads a file and extracts sections.
func FindSection ¶
FindSection returns the section with the given slug, or nil.
func SectionsOwnedBy ¶
SectionsOwnedBy returns sections owned by the given role.
type SpecMeta ¶
type SpecMeta struct {
ID string `yaml:"id"`
Title string `yaml:"title"`
Status string `yaml:"status"`
Version string `yaml:"version"`
Author string `yaml:"author"`
Cycle string `yaml:"cycle"`
EpicKey string `yaml:"epic_key,omitempty"`
Repos []string `yaml:"repos,omitempty"`
RevertCount int `yaml:"revert_count"`
Source string `yaml:"source,omitempty"`
Created string `yaml:"created"`
Updated string `yaml:"updated"`
// Steps is the structured build plan.
// Replaces unstructured §7.3 prose with authoritative step tracking.
Steps []BuildStep `yaml:"steps,omitempty"`
// Review tracks plan review state for the engineering stage.
Review *ReviewState `yaml:"review,omitempty"`
// FastTrack marks this as a fast-track bug fix (skips ceremony stages).
FastTrack bool `yaml:"fast_track,omitempty"`
}
SpecMeta represents the YAML frontmatter of a SPEC.md file.
func (*SpecMeta) AllStepsComplete ¶
AllStepsComplete returns true if all steps have status "complete".
func (*SpecMeta) CurrentStep ¶
CurrentStep returns the index (0-based) of the first non-complete step, or -1 if all steps are complete or there are no steps.
func (*SpecMeta) IsReviewApproved ¶
IsReviewApproved returns true if the review status is "approved".
func (*SpecMeta) IsReviewChangesRequested ¶
IsReviewChangesRequested returns true if reviewer requested changes.
func (*SpecMeta) IsReviewPending ¶
IsReviewPending returns true if review was requested but not yet completed.
func (*SpecMeta) StepsExist ¶
StepsExist returns true if at least one step is defined.
type TriageMeta ¶
type TriageMeta struct {
ID string `yaml:"id"`
Title string `yaml:"title"`
Status string `yaml:"status"`
Priority string `yaml:"priority"`
Source string `yaml:"source,omitempty"`
SourceRef string `yaml:"source_ref,omitempty"`
ReportedBy string `yaml:"reported_by,omitempty"`
Created string `yaml:"created"`
}
TriageMeta represents the YAML frontmatter of a TRIAGE.md file.
func ParseTriageMeta ¶
func ParseTriageMeta(content string) (*TriageMeta, error)
ParseTriageMeta parses triage YAML frontmatter.
func ReadTriageMeta ¶
func ReadTriageMeta(path string) (*TriageMeta, error)
ReadTriageMeta reads and parses triage frontmatter.