Documentation
¶
Overview ¶
internal/content/dynamic.go
Index ¶
- Variables
- func FormatOutput(text, format string) string
- func IsBuiltinProfile(id string) bool
- func MatchesLearningFilters(product, productCategory string, roles []string, f LearningProfileFilters) bool
- func ParseConstraintForTest(required, found string) bool
- func RenderContext(packs []*Pack, profile *Profile, dynamic *DynamicContext, verbosity string) string
- func TrimToBytes(s string, maxBytes int) string
- func ValidateContextSections(packID string, content string)
- type CheckStatus
- type CommandInfo
- type ContentLoader
- type DiscoveryGuidanceRef
- type DiscoveryMissionRef
- type DiscoveryProfileFilters
- type DiscoveryServiceRef
- type DiscoveryYAML
- type DynamicContext
- type EventInstance
- type EventType
- type HookDef
- type Influencer
- func FilterInfluencersByPack(packs []*Pack, packID string) []Influencer
- func FilterInfluencersByTags(influencers []Influencer, tags []string) []Influencer
- func FindInfluencer(influencers []Influencer, id string) *Influencer
- func FlattenInfluencers(packs []*Pack) []Influencer
- func RandomInfluencer(influencers []Influencer, seed int64) *Influencer
- type KnownError
- func FilterKnownErrors(errors []KnownError, query string) []KnownError
- func FilterKnownErrorsByPack(packs []*Pack, packID string) []KnownError
- func FilterKnownErrorsByTags(errors []KnownError, tags []string) []KnownError
- func FindKnownError(errors []KnownError, id string) *KnownError
- func FlattenKnownErrors(packs []*Pack) []KnownError
- type LearningJourneyInjection
- type LearningPathDef
- type LearningPathStepDef
- type LearningProfileFilters
- type LearningRef
- type LearningYAML
- type MCPInstall
- type MCPServer
- type Pack
- type PackWeight
- type Profile
- type ProjectFact
- type ProjectFinding
- type ProjectInfo
- type Resource
- type Runner
- type Sample
- type SkillDef
- type Tip
- type ToolDef
- type ToolDetect
- type ToolResult
- type TutorialRef
- type VerbositySections
- type Video
- type WhatsNewEntry
- type WiredMCPEntry
- type YouTubeSource
Constants ¶
This section is empty.
Variables ¶
var RecognizedContextSections = []string{
"Overview",
"Key Concepts",
"Best Practices",
"Anti-patterns",
"Code Examples",
}
Functions ¶
func FormatOutput ¶
FormatOutput converts text to the target format. format == "markdown" (or empty): returns text unchanged. format == "plain-prose": strips Markdown syntax for plain-text UI fields.
func IsBuiltinProfile ¶
IsBuiltinProfile reports whether id is a reserved built-in profile ID.
func MatchesLearningFilters ¶
func MatchesLearningFilters(product, productCategory string, roles []string, f LearningProfileFilters) bool
MatchesLearningFilters checks if a journey matches the profile filters.
func ParseConstraintForTest ¶
ParseConstraintForTest exposes parseConstraint for use in external test packages.
func RenderContext ¶
func RenderContext(packs []*Pack, profile *Profile, dynamic *DynamicContext, verbosity string) string
RenderContext builds the Markdown string injected into AI tool configuration. Packs are rendered in the order provided (caller applies profile weights first). dynamic may be nil; when non-nil a runtime context section is prepended.
func TrimToBytes ¶
TrimToBytes truncates s to at most maxBytes bytes, cutting at the last complete UTF-8 rune boundary. Returns s unchanged if maxBytes <= 0 or len(s) <= maxBytes.
func ValidateContextSections ¶
Types ¶
type CheckStatus ¶
type CheckStatus string
CheckStatus represents the result of a tool version check.
const ( StatusOK CheckStatus = "ok" StatusFail CheckStatus = "fail" StatusMissing CheckStatus = "missing" StatusUnknown CheckStatus = "unknown" // required is "latest" )
type CommandInfo ¶
CommandInfo describes a single CLI command for injection into AI context.
type ContentLoader ¶
type ContentLoader struct {
OfficialDir string
CompanyDir string // empty if not configured
UserDir string
ProjectDir string // empty if not in a project
}
ContentLoader merges packs from multiple layers: official → company → user → project.
func (*ContentLoader) FindProfile ¶
func (cl *ContentLoader) FindProfile(id string) (*Profile, error)
FindProfile returns a profile by ID from all layers, or nil if not found. Built-in profile IDs (all, minimal) are returned directly without file I/O.
func (*ContentLoader) LoadPacks ¶
func (cl *ContentLoader) LoadPacks(profile *Profile, lang string) ([]*Pack, error)
LoadPacks loads and merges packs from all configured layers, then orders them by the given profile. Later layers override earlier ones by pack ID.
func (*ContentLoader) LoadProfiles ¶
func (cl *ContentLoader) LoadProfiles() ([]*Profile, error)
LoadProfiles loads profiles from all configured layers (later layers override). Built-in profiles (all, minimal) are always appended last and cannot be shadowed by file-backed profiles with the same ID.
type DiscoveryGuidanceRef ¶
DiscoveryGuidanceRef is a curated guidance reference in discovery.yaml.
func FlattenDiscoveryGuidanceRefs ¶
func FlattenDiscoveryGuidanceRefs(packs []*Pack) []DiscoveryGuidanceRef
FlattenDiscoveryGuidanceRefs collects all curated guidance refs from all packs.
type DiscoveryMissionRef ¶
type DiscoveryMissionRef struct {
ID int `yaml:"id"`
Name string `yaml:"name"`
Featured bool `yaml:"featured,omitempty"`
PackID string // set at load time
}
DiscoveryMissionRef is a curated mission reference in discovery.yaml.
func FlattenDiscoveryMissionRefs ¶
func FlattenDiscoveryMissionRefs(packs []*Pack) []DiscoveryMissionRef
FlattenDiscoveryMissionRefs collects all curated mission refs from all packs.
type DiscoveryProfileFilters ¶
type DiscoveryProfileFilters struct {
Products []string `yaml:"products,omitempty"`
Categories []string `yaml:"categories,omitempty"`
FocusTags []string `yaml:"focus_tags,omitempty"`
}
DiscoveryProfileFilters maps a pack to Discovery Center filter values.
func CollectProfileFilters ¶
func CollectProfileFilters(packs []*Pack) DiscoveryProfileFilters
CollectProfileFilters unions all DiscoveryProfileFilters across active packs.
type DiscoveryServiceRef ¶
type DiscoveryServiceRef struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Featured bool `yaml:"featured,omitempty"`
PackID string
}
DiscoveryServiceRef is a curated service reference in discovery.yaml.
func FlattenDiscoveryServiceRefs ¶
func FlattenDiscoveryServiceRefs(packs []*Pack) []DiscoveryServiceRef
FlattenDiscoveryServiceRefs collects all curated service refs from all packs.
type DiscoveryYAML ¶
type DiscoveryYAML struct {
ProfileFilters *DiscoveryProfileFilters `yaml:"profile_filters,omitempty"`
Missions []DiscoveryMissionRef `yaml:"missions,omitempty"`
Services []DiscoveryServiceRef `yaml:"services,omitempty"`
Guidance []DiscoveryGuidanceRef `yaml:"guidance,omitempty"`
}
DiscoveryYAML is the intermediate struct for unmarshaling discovery.yaml. Unlike most pack YAML files (top-level arrays), this is a top-level object.
type DynamicContext ¶
type DynamicContext struct {
CLIVersion string
ActiveProfile string // profile.Name, or profile.ID, or ""
LoadedPackIDs []string
LastSynced *time.Time
Project *ProjectInfo
ProjectFindings []ProjectFinding
WiredMCPServers []WiredMCPEntry
Commands []CommandInfo
ScratchNotes []string
WhatsNew []WhatsNewEntry
WhatsNewDate *time.Time
}
DynamicContext holds runtime-gathered information injected before pack content. All fields are optional; zero values mean "not available".
type EventInstance ¶
type EventInstance struct {
ID string `yaml:"id"`
Type string `yaml:"type"`
Title string `yaml:"title"`
DateStr string `yaml:"date"`
EndDateStr string `yaml:"end_date,omitempty"`
Location string `yaml:"location,omitempty"`
Scope string `yaml:"scope"`
URL string `yaml:"url"`
Room string `yaml:"room,omitempty"`
Speaker string `yaml:"speaker,omitempty"`
Tags []string `yaml:"tags,omitempty"`
PackID string // set at load time
}
EventInstance is a specific event occurrence.
func FilterEventsByQuery ¶
func FilterEventsByQuery(events []EventInstance, query string) []EventInstance
FilterEventsByQuery returns events matching query in title, location, or tags.
func FilterEventsByType ¶
func FilterEventsByType(events []EventInstance, typeID string) []EventInstance
FilterEventsByType returns events matching the given type ID.
func FindEvent ¶
func FindEvent(events []EventInstance, id string) *EventInstance
FindEvent returns a pointer to the first event with an exact ID match, or nil.
func FlattenEventInstances ¶
func FlattenEventInstances(packs []*Pack) []EventInstance
FlattenEventInstances collects all event instances from all packs.
func (*EventInstance) ParseDate ¶
func (e *EventInstance) ParseDate() (time.Time, error)
ParseDate parses the DateStr field into time.Time.
func (*EventInstance) ParseEndDate ¶
func (e *EventInstance) ParseEndDate() (time.Time, error)
ParseEndDate parses the EndDateStr field into time.Time.
type EventType ¶
type EventType struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Description string `yaml:"description,omitempty"`
Source string `yaml:"source"`
RSSURL string `yaml:"rss_url,omitempty"`
KhorosBoardID string `yaml:"khoros_board_id,omitempty"`
DefaultScope string `yaml:"default_scope"`
Tags []string `yaml:"tags,omitempty"`
PackID string // set at load time
}
EventType defines a category of events and its data source.
func FlattenEventTypes ¶
FlattenEventTypes collects all event types from all packs.
type HookDef ¶
type HookDef struct {
ID string `yaml:"id"`
Event string `yaml:"event"`
Command string `yaml:"command"`
Tools []string `yaml:"tools"`
PackID string // set at load time, not in YAML
}
HookDef declares a hook command to wire into an AI tool's event system.
func FindHookDef ¶
FindHookDef returns the first HookDef with the given ID across packs, or nil.
func FlattenHooks ¶
FlattenHooks returns all HookDef entries from all packs in order.
type Influencer ¶
type Influencer struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Role string `yaml:"role"`
Org string `yaml:"org"`
Focus []string `yaml:"focus"`
Links map[string]string `yaml:"links"`
PackID string // set at load time, not in YAML
}
Influencer is a community influencer or thought leader within a pack.
func FilterInfluencersByPack ¶
func FilterInfluencersByPack(packs []*Pack, packID string) []Influencer
FilterInfluencersByPack returns influencers from packs matching the given pack ID.
func FilterInfluencersByTags ¶
func FilterInfluencersByTags(influencers []Influencer, tags []string) []Influencer
FilterInfluencersByTags returns influencers with at least one focus tag matching any of the provided tags (OR semantics, case-insensitive).
func FindInfluencer ¶
func FindInfluencer(influencers []Influencer, id string) *Influencer
FindInfluencer returns a pointer to the first influencer with an exact ID match, or nil.
func FlattenInfluencers ¶
func FlattenInfluencers(packs []*Pack) []Influencer
FlattenInfluencers collects all influencers from all packs into a single slice.
func RandomInfluencer ¶
func RandomInfluencer(influencers []Influencer, seed int64) *Influencer
RandomInfluencer returns one random influencer from the slice using the given seed.
type KnownError ¶
type KnownError struct {
ID string `yaml:"id"`
Pattern string `yaml:"pattern"`
Cause string `yaml:"cause"`
Fix string `yaml:"fix"`
Docs string `yaml:"docs,omitempty"`
Tags []string `yaml:"tags,omitempty"`
PackID string
}
KnownError is a common SAP error pattern with its cause and fix.
func FilterKnownErrors ¶
func FilterKnownErrors(errors []KnownError, query string) []KnownError
FilterKnownErrors returns errors whose ID, Pattern, Cause, Fix, or any Tag contains query (case-insensitive substring match).
func FilterKnownErrorsByPack ¶
func FilterKnownErrorsByPack(packs []*Pack, packID string) []KnownError
FilterKnownErrorsByPack returns errors from the pack matching the given pack ID.
func FilterKnownErrorsByTags ¶
func FilterKnownErrorsByTags(errors []KnownError, tags []string) []KnownError
FilterKnownErrorsByTags returns errors with at least one tag matching any of the provided tags (OR semantics, case-insensitive).
func FindKnownError ¶
func FindKnownError(errors []KnownError, id string) *KnownError
FindKnownError returns a pointer to the first error with an exact ID match, or nil.
func FlattenKnownErrors ¶
func FlattenKnownErrors(packs []*Pack) []KnownError
FlattenKnownErrors collects all known errors from all packs into a single slice.
type LearningJourneyInjection ¶
LearningJourneyInjection is a pre-resolved learning journey for context injection.
type LearningPathDef ¶
type LearningPathDef struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Description string `yaml:"description,omitempty"`
Level string `yaml:"level,omitempty"`
Steps []LearningPathStepDef `yaml:"steps"`
PackID string // set at load time
}
LearningPathDef is the YAML-parsed shape from paths.yaml.
func FlattenLearningPaths ¶
func FlattenLearningPaths(packs []*Pack) []LearningPathDef
FlattenLearningPaths collects all curated learning paths from all packs.
type LearningPathStepDef ¶
LearningPathStepDef is a single step in a curated path.
type LearningProfileFilters ¶
type LearningProfileFilters struct {
Products []string `yaml:"products,omitempty"`
ProductCategories []string `yaml:"product_categories,omitempty"`
Roles []string `yaml:"roles,omitempty"`
}
LearningProfileFilters maps a pack to learning.sap.com filter values.
func CollectLearningFilters ¶
func CollectLearningFilters(packs []*Pack) LearningProfileFilters
CollectLearningFilters unions all LearningProfileFilters across active packs.
type LearningRef ¶
type LearningRef struct {
Slug string `yaml:"slug"`
Featured bool `yaml:"featured,omitempty"`
PackID string // set at load time
}
LearningRef is a curated learning journey reference in learning.yaml.
func FlattenLearningRefs ¶
func FlattenLearningRefs(packs []*Pack) []LearningRef
FlattenLearningRefs collects all curated learning refs from all packs.
type LearningYAML ¶
type LearningYAML struct {
ProfileFilters *LearningProfileFilters `yaml:"profile_filters,omitempty"`
Journeys []LearningRef `yaml:"journeys,omitempty"`
}
LearningYAML is the intermediate struct for unmarshaling learning.yaml.
type MCPInstall ¶
type MCPInstall struct {
Command string `yaml:"command"`
Args []string `yaml:"args"`
Type string `yaml:"type"`
}
MCPInstall defines how to run the MCP server.
type MCPServer ¶
type MCPServer struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Description string `yaml:"description"`
Install MCPInstall `yaml:"install"`
Hosts []string `yaml:"hosts"`
PackID string // set at load time, not in YAML
}
MCPServer defines an installable MCP server for this pack's domain.
func FindMCPServer ¶
FindMCPServer returns the first MCPServer with the given ID across packs, or nil.
func FlattenMCPServers ¶
FlattenMCPServers returns all MCPServer entries from all packs in order.
type Pack ¶
type Pack struct {
ID string
Name string
Description string
Tags []string
Profiles []string
Weight int
Overlaps []string
Base bool
Additive bool
AdditivePosition string // "before" | "after"; normalised to "after" if empty
Context VerbositySections
Resources []Resource
Tools []ToolDef
MCPServers []MCPServer
Tips []Tip
PreambleMD string
Constraints VerbositySections
Hooks []HookDef
Skills []SkillDef
Influencers []Influencer
Samples []Sample
KnownErrors []KnownError
TutorialRefs []TutorialRef
EventTypes []EventType
EventInstances []EventInstance
YouTubeSources []YouTubeSource
Videos []Video
DiscoveryMissions []DiscoveryMissionRef
DiscoveryServices []DiscoveryServiceRef
DiscoveryGuidance []DiscoveryGuidanceRef
DiscoveryFilters *DiscoveryProfileFilters
LearningRefs []LearningRef
LearningFilters *LearningProfileFilters
LearningForInject []LearningJourneyInjection // populated at inject time
LearningPaths []LearningPathDef
Versions map[string]string
}
Pack is a named bundle of SAP knowledge for a specific domain.
func ApplyWeights ¶
ApplyWeights returns packs sorted by the profile's weight declarations. Packs not mentioned by the profile retain their base weight.
func LoadPack ¶
LoadPack reads all files from packDir and returns a populated Pack. lang selects locale-specific files and metadata overrides (e.g. "de", "fr"). Pass "" or "en" to use the base (English) content.
func TrimPacks ¶
TrimPacks filters packs to fit within maxBytes, applying overlap deduplication and pack-level budget enforcement. Pass maxBytes=0 for unconstrained. Packs must already be sorted by weight descending (LoadPacks guarantees this). Base packs (Pack.Base == true) are exempt from both trimming passes and always appear first in the returned slice.
type PackWeight ¶
PackWeight pairs a pack ID with a priority weight.
type Profile ¶
type Profile struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Description string `yaml:"description"`
Packs []PackWeight `yaml:"packs"`
TipTags []string `yaml:"tip_tags"`
}
Profile is a developer persona that weights packs by relevance.
func BuiltinProfiles ¶
func BuiltinProfiles() []*Profile
BuiltinProfiles returns the two hardcoded built-in profiles. These profiles require no YAML file on disk.
func LoadProfile ¶
LoadProfile reads a profile YAML file.
func LoadProfiles ¶
LoadProfiles reads all *.yaml files from profilesDir.
type ProjectFact ¶
ProjectFact is a single key/value pair detected from the project.
type ProjectFinding ¶
ProjectFinding is a single health-check result surfaced during inject.
type ProjectInfo ¶
type ProjectInfo struct {
Type string
CAPVersion string
Facts []ProjectFact
BTPFacts []ProjectFact
}
ProjectInfo holds detected facts about the current project, mirroring project.ProjectContext fields needed for rendering. Populated by internal/dynamic at gather time — kept in content to avoid an import cycle (internal/project imports internal/content for pack access).
type Resource ¶
type Resource struct {
ID string `yaml:"id"`
Title string `yaml:"title"`
URL string `yaml:"url"`
Type string `yaml:"type"`
Tags []string `yaml:"tags"`
Advocate string `yaml:"advocate,omitempty"`
PackID string // set at load time, not in YAML
}
Resource is a curated link within a pack.
func FilterResources ¶
FilterResources returns resources whose id, title, type, or any tag contains query (case-insensitive substring match).
func FindResource ¶
FindResource returns a pointer to the first resource with an exact ID match, or nil.
func FlattenResources ¶
FlattenResources collects all resources from all packs into a single slice.
type Runner ¶
Runner abstracts exec.Command for testability. It receives the full command string (e.g. "node --version") and returns the combined stdout+stderr output.
type Sample ¶
type Sample struct {
ID string `yaml:"id"`
Label string `yaml:"label"`
URL string `yaml:"url"`
Description string `yaml:"description"`
Tags []string `yaml:"tags"`
Inject bool `yaml:"inject"`
PackID string // set at load time, not in YAML
}
Sample is a canonical code sample reference within a pack.
func FilterSamples ¶
FilterSamples returns samples whose ID, Label, Description, or any Tag contains query (case-insensitive substring match).
func FilterSamplesByPack ¶
FilterSamplesByPack returns samples from the pack matching the given pack ID.
func FilterSamplesByTags ¶
FilterSamplesByTags returns samples with at least one tag matching any of the provided tags (OR semantics, case-insensitive).
func FindSample ¶
FindSample returns a pointer to the first sample with an exact ID match, or nil.
func FlattenSamples ¶
FlattenSamples collects all samples from all packs into a single slice.
type SkillDef ¶
type SkillDef struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Description string `yaml:"description"`
File string `yaml:"file"`
Tools []string `yaml:"tools"`
Content string
PackID string
}
SkillDef declares an installable skill file for an AI tool.
func FindSkillDef ¶
FindSkillDef returns the first SkillDef with the given ID across packs, or nil.
func FlattenSkills ¶
FlattenSkills returns all SkillDef entries from all packs in order.
type Tip ¶
Tip is a single actionable tip with profile tags.
type ToolDef ¶
type ToolDef struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Required string `yaml:"required"`
Detect ToolDetect `yaml:"detect"`
Install map[string]string `yaml:"install"`
Docs string `yaml:"docs"`
}
ToolDef is an entry in the tool catalog with version detection rules.
type ToolDetect ¶
ToolDetect holds the command and regex to detect an installed tool's version.
type ToolResult ¶
type ToolResult struct {
Tool ToolDef
Status CheckStatus
Found string // raw captured version string, empty if missing
}
ToolResult holds the outcome of checking a single tool.
func CheckTool ¶
func CheckTool(tool ToolDef, run Runner) ToolResult
CheckTool runs the tool's detect command via run, extracts the version using the tool's regex pattern, and compares it against tool.Required.
func CheckTools ¶
func CheckTools(tools []ToolDef, run Runner) []ToolResult
CheckTools runs CheckTool for each tool, deduplicating by ID (first seen wins).
type TutorialRef ¶
type TutorialRef struct {
Slug string `yaml:"slug"`
Featured bool `yaml:"featured,omitempty"`
PackID string // set at load time, not in YAML
}
TutorialRef is a curated tutorial reference in a pack's tutorials.yaml.
func FilterTutorialRefsByPack ¶
func FilterTutorialRefsByPack(packs []*Pack, packID string) []TutorialRef
FilterTutorialRefsByPack returns tutorial refs from the matching pack.
func FindTutorialRef ¶
func FindTutorialRef(packs []*Pack, slug string) *TutorialRef
FindTutorialRef returns the first tutorial ref matching slug, or nil.
func FlattenTutorialRefs ¶
func FlattenTutorialRefs(packs []*Pack) []TutorialRef
FlattenTutorialRefs collects all tutorial references from all packs.
type VerbositySections ¶
func ParseVerbositySections ¶
func ParseVerbositySections(md string) VerbositySections
func (VerbositySections) AtLevel ¶
func (v VerbositySections) AtLevel(level string) string
type Video ¶
type Video struct {
ID string `json:"id"`
Title string `json:"title"`
URL string `json:"url"`
VideoID string `json:"video_id"`
Published time.Time `json:"published"`
Description string `json:"description"`
Duration string `json:"duration,omitempty"`
SourceID string `json:"source_id"`
Tags []string `json:"tags,omitempty"`
PackID string `json:"pack_id"`
}
Video is a resolved YouTube video (fetched from a playlist or declared individually).
type WhatsNewEntry ¶
WhatsNewEntry is a single changelog item rendered in the ## What's New block.
type WiredMCPEntry ¶
WiredMCPEntry records SAP MCP servers registered in a specific AI tool's config.
type YouTubeSource ¶
type YouTubeSource struct {
ID string `yaml:"id"`
Type string `yaml:"type"`
Name string `yaml:"name"`
PlaylistID string `yaml:"playlist_id,omitempty"`
VideoID string `yaml:"video_id,omitempty"`
Tags []string `yaml:"tags,omitempty"`
PackID string
}
YouTubeSource declares a playlist or individual video in youtube.yaml.