templates

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 7 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 templates renders every piece of markdown patchy writes — issue bodies, comments, pull-request bodies, and the agent-facing handoff files — from embedded text/templates, so the artifacts stay consistent across the estate.

The issue body carries a machine-readable manifest block (an HTML comment holding JSON) that is the authoritative record of the alerts accumulated into the issue; the human-readable body is re-rendered from the manifest on every accumulation, never string-edited. The accumulator (source-controller) owns the body; everyone else appends comments.

Index

Constants

View Source
const (
	ClassificationReportHeading = "Classification"
	RemediationReportHeading    = "Remediation"
)

The stage headings on report comments. They are load-bearing: the /approve path recovers the classification report from its comment by looking for this heading, so GitHub stays the only state store.

Variables

This section is empty.

Functions

func AccumulationComment

func AccumulationComment(alert Alert) (string, error)

AccumulationComment announces an alert being folded into an existing issue.

func ApproveComment

func ApproveComment(reason string) (string, error)

ApproveComment renders the human instructions for forcing a remediation attempt on an issue the pipeline held back.

func EnhancementComment

func EnhancementComment(enhancerID, markdown string) (string, error)

EnhancementComment wraps an enhancer's contribution with attribution.

func IssueTitle

func IssueTitle(m Manifest) string

IssueTitle is the canonical security-finding issue title.

func PRBody

func PRBody(issue int, report string) (string, error)

PRBody renders the pull-request body for a remediation branch; issue is the tracked issue number ("Fixes #issue" auto-links and auto-closes).

func RenderClassifyPrompt

func RenderClassifyPrompt(p ClassifyPrompt) (string, error)

RenderClassifyPrompt renders the classification prompt.

func RenderEnrichmentComment

func RenderEnrichmentComment(e Enrichment, markdown string) (string, error)

RenderEnrichmentComment renders an enhancement comment: attributed human-readable markdown plus the embedded machine block.

func RenderIssueBody

func RenderIssueBody(m Manifest) (string, error)

RenderIssueBody renders the full issue body — human summary plus the machine manifest block — from the manifest.

func RenderRemediatePrompt

func RenderRemediatePrompt(p RemediatePrompt) (string, error)

RenderRemediatePrompt renders the remediation prompt.

func RenderWorkspaceIssue

func RenderWorkspaceIssue(w WorkspaceIssue) (string, error)

RenderWorkspaceIssue renders the workspace issue.md handoff file.

func ReportComment

func ReportComment(stage, report string) (string, error)

ReportComment wraps an agent stage report for posting to the issue.

Types

type Alert

type Alert struct {
	Number    int               `json:"number"`
	HTMLURL   string            `json:"url,omitempty"`
	Locations []source.Location `json:"locations,omitempty"`
}

Alert is one accumulated finding instance.

type ClassifyPrompt

type ClassifyPrompt struct {
	IssuePath          string
	ReportPath         string
	AllowedModels      []string
	MaxTurnsCeiling    int
	TokenBudgetCeiling int
}

ClassifyPrompt is the data for the stage-1 (classification) prompt.

type Enrichment

type Enrichment struct {
	Enhancer   string            `json:"enhancer"`
	Owners     []string          `json:"owners,omitempty"`
	Attributes map[string]string `json:"attributes,omitempty"`
}

Enrichment is the machine-readable part of an enhancement comment: the facts downstream automation consumes (owners for assignment, attributes for future mapping). The human-readable markdown travels alongside it in the same comment.

func ParseEnrichment

func ParseEnrichment(comment string) (Enrichment, bool)

ParseEnrichment recovers the machine block from one comment; ok reports whether the comment carries one.

type Manifest

type Manifest struct {
	Source string `json:"source"`
	// Advisories are the categorization IDs, most authoritative first;
	// Advisories[0] is the accumulation key.
	Advisories []string `json:"advisories"`
	RuleID     string   `json:"rule_id,omitempty"`
	Title      string   `json:"title"`
	// Description is the rule's markdown help text, shared by every alert of
	// the family.
	Description string  `json:"description,omitempty"`
	Severity    string  `json:"severity,omitempty"`
	Alerts      []Alert `json:"alerts"`
}

Manifest is the machine-readable state embedded in the issue body: the finding family the issue tracks and every alert accumulated into it. The body is derived from the manifest, so mutating the manifest and re-rendering is the only way the body changes.

func NewManifest

func NewManifest(f source.Finding) Manifest

NewManifest starts a manifest from the finding that opens an issue.

func ParseManifest

func ParseManifest(body string) (Manifest, error)

ParseManifest recovers the manifest from an issue body written by RenderIssueBody.

func (*Manifest) Add

func (m *Manifest) Add(f source.Finding) bool

Add accumulates a finding's alert into the manifest, reporting whether it was new (false means the alert number was already recorded — a redelivery).

func (Manifest) AlertNumbers

func (m Manifest) AlertNumbers() []int

AlertNumbers lists the accumulated alert numbers in insertion order.

func (Manifest) Primary

func (m Manifest) Primary() string

Primary is the accumulation-key advisory.

type RemediatePrompt

type RemediatePrompt struct {
	IssuePath          string
	ClassificationPath string
	ReportPath         string
	CommitScriptPath   string
}

RemediatePrompt is the data for the stage-2 (remediation) prompt.

type WorkspaceIssue

type WorkspaceIssue struct {
	Repo     string
	Number   int
	Title    string
	Body     string
	Comments []string
}

WorkspaceIssue is the data for the issue handoff file the agent reads.

Jump to

Keyboard shortcuts

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