Abstract Class: MarkdownInstructionFormatter¶
Defined in: formatters/src/markdown-instruction-formatter.ts:118
Abstract base class for markdown-based instruction formatters.
Provides shared section extraction logic (project, tech stack, architecture, code standards, git commits, config files, commands, post-work, documentation, diagrams, restrictions) and standard simple/multifile/full mode implementations.
Subclasses configure behavior via MarkdownFormatterConfig and can override specific methods for format-specific customization.
Extends¶
Extended by¶
FactoryFormatterGeminiFormatterWindsurfFormatterContinueFormatterTraeFormatterKiroFormatterZencoderFormatter
Constructors¶
Constructor¶
new MarkdownInstructionFormatter(
config):MarkdownInstructionFormatter
Defined in: formatters/src/markdown-instruction-formatter.ts:126
Parameters¶
config¶
Returns¶
MarkdownInstructionFormatter
Overrides¶
Properties¶
config¶
protectedreadonlyconfig:MarkdownFormatterConfig
Defined in: formatters/src/markdown-instruction-formatter.ts:124
defaultConvention¶
readonlydefaultConvention:string
Defined in: formatters/src/markdown-instruction-formatter.ts:122
Default convention for this formatter
Overrides¶
BaseFormatter.defaultConvention
description¶
readonlydescription:string
Defined in: formatters/src/markdown-instruction-formatter.ts:121
Human-readable description
Overrides¶
name¶
readonlyname:string
Defined in: formatters/src/markdown-instruction-formatter.ts:119
Unique formatter identifier
Overrides¶
outputPath¶
readonlyoutputPath:string
Defined in: formatters/src/markdown-instruction-formatter.ts:120
Default output file path
Overrides¶
standardsExtractor¶
protectedreadonlystandardsExtractor:StandardsExtractor
Defined in: formatters/src/base-formatter.ts:28
Shared standards extractor for consistent extraction across all formatters.
Inherited from¶
BaseFormatter.standardsExtractor
Methods¶
addCommonSections()¶
protectedaddCommonSections(ast,renderer,sections):void
Defined in: formatters/src/markdown-instruction-formatter.ts:499
Parameters¶
ast¶
renderer¶
sections¶
string[]
Returns¶
void
addSection()¶
protectedaddSection(sections,content):void
Defined in: formatters/src/markdown-instruction-formatter.ts:518
Parameters¶
sections¶
string[]
content¶
string | null
Returns¶
void
architecture()¶
protectedarchitecture(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:617
Parameters¶
ast¶
renderer¶
Returns¶
string | null
codeStandards()¶
protectedcodeStandards(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:630
Parameters¶
ast¶
renderer¶
Returns¶
string | null
commands()¶
protectedcommands(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:686
Parameters¶
ast¶
renderer¶
Returns¶
string | null
configFiles()¶
protectedconfigFiles(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:668
Parameters¶
ast¶
renderer¶
Returns¶
string | null
createRenderer()¶
protectedcreateRenderer(options?):ConventionRenderer
Defined in: formatters/src/base-formatter.ts:34
Create a convention renderer for this formatter. Uses the provided convention from options or falls back to the default.
Parameters¶
options?¶
Returns¶
Inherited from¶
dedent()¶
protecteddedent(text):string
Defined in: formatters/src/base-formatter.ts:452
Remove common leading whitespace from all lines (dedent). Handles the case where trim() was already called, causing the first line to lose its indentation while subsequent lines retain theirs. Calculates minimum indent from lines 2+ only.
Parameters¶
text¶
string
Returns¶
string
Inherited from¶
diagrams()¶
protecteddiagrams(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:749
Parameters¶
ast¶
renderer¶
Returns¶
string | null
documentation()¶
protecteddocumentation(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:730
Parameters¶
ast¶
renderer¶
Returns¶
string | null
extractAgents()¶
protectedextractAgents(ast):MarkdownAgentConfig[]
Defined in: formatters/src/markdown-instruction-formatter.ts:420
Parameters¶
ast¶
Returns¶
extractCommands()¶
protectedextractCommands(ast):MarkdownCommandConfig[]
Defined in: formatters/src/markdown-instruction-formatter.ts:286
Parameters¶
ast¶
Returns¶
extractRestrictionsItems()¶
protectedextractRestrictionsItems(content):string[]
Defined in: formatters/src/markdown-instruction-formatter.ts:821
Parameters¶
content¶
Returns¶
string[]
extractSectionWithCodeBlock()¶
protectedextractSectionWithCodeBlock(text,header):string|null
Defined in: formatters/src/base-formatter.ts:176
Safe extraction of a section that contains a header + content + code block + content Avoids ReDoS by using string search instead of backtracking regex. Matches pattern: Header ... ...
Parameters¶
text¶
string
header¶
string
Returns¶
string | null
Inherited from¶
BaseFormatter.extractSectionWithCodeBlock
extractSkills()¶
protectedextractSkills(ast):MarkdownSkillConfig[]
Defined in: formatters/src/markdown-instruction-formatter.ts:352
Parameters¶
ast¶
Returns¶
extractTechStackFromContext()¶
protectedextractTechStackFromContext(context):string[]
Defined in: formatters/src/markdown-instruction-formatter.ts:575
Parameters¶
context¶
Block | undefined
Returns¶
string[]
extractTechStackFromStandards()¶
protectedextractTechStackFromStandards(standards):string[]
Defined in: formatters/src/markdown-instruction-formatter.ts:601
Parameters¶
standards¶
Block | undefined
Returns¶
string[]
extractText()¶
protectedextractText(content):string
Defined in: formatters/src/base-formatter.ts:69
Extract text from block content.
Parameters¶
content¶
Returns¶
string
Inherited from¶
findBlock()¶
protectedfindBlock(ast,name):Block|undefined
Defined in: formatters/src/base-formatter.ts:62
Find a block by name, ignoring internal blocks (starting with __).
Parameters¶
ast¶
name¶
string
Returns¶
Block | undefined
Inherited from¶
format()¶
format(
ast,options?):FormatterOutput
Defined in: formatters/src/markdown-instruction-formatter.ts:143
Transform AST to tool-specific format
Parameters¶
ast¶
options?¶
Returns¶
Overrides¶
formatArray()¶
protectedformatArray(arr):string
Defined in: formatters/src/base-formatter.ts:120
Format an array as comma-separated string.
Parameters¶
arr¶
unknown[]
Returns¶
string
Inherited from¶
formatFull()¶
protectedformatFull(ast,options?):FormatterOutput
Defined in: formatters/src/markdown-instruction-formatter.ts:227
Parameters¶
ast¶
options?¶
Returns¶
formatMultifile()¶
protectedformatMultifile(ast,options?):FormatterOutput
Defined in: formatters/src/markdown-instruction-formatter.ts:191
Parameters¶
ast¶
options?¶
Returns¶
formatSimple()¶
protectedformatSimple(ast,options?):FormatterOutput
Defined in: formatters/src/markdown-instruction-formatter.ts:171
Parameters¶
ast¶
options?¶
Returns¶
formatStandardsList()¶
protectedformatStandardsList(items):string[]
Defined in: formatters/src/base-formatter.ts:112
Format standards list from array of values (pass-through). Returns array of strings for rendering as bullet list.
Parameters¶
items¶
Returns¶
string[]
Inherited from¶
BaseFormatter.formatStandardsList
generateAgentFile()¶
protectedgenerateAgentFile(config):FormatterOutput
Defined in: formatters/src/markdown-instruction-formatter.ts:444
Parameters¶
config¶
Returns¶
generateCommandFile()¶
protectedgenerateCommandFile(config):FormatterOutput
Defined in: formatters/src/markdown-instruction-formatter.ts:325
Parameters¶
config¶
Returns¶
generateSkillFile()¶
protectedgenerateSkillFile(config):FormatterOutput
Defined in: formatters/src/markdown-instruction-formatter.ts:384
Parameters¶
config¶
Returns¶
getArrayElements()¶
protectedgetArrayElements(content):Value[]
Defined in: formatters/src/base-formatter.ts:144
Extract array elements from block content.
Parameters¶
content¶
Returns¶
Value[]
Inherited from¶
BaseFormatter.getArrayElements
getMetaField()¶
protectedgetMetaField(ast,key):string|undefined
Defined in: formatters/src/base-formatter.ts:134
Get meta field value as string.
Parameters¶
ast¶
key¶
string
Returns¶
string | undefined
Inherited from¶
getOutputPath()¶
protectedgetOutputPath(options?):string
Defined in: formatters/src/base-formatter.ts:55
Get the output path, respecting options override.
Parameters¶
options?¶
Returns¶
string
Inherited from¶
getPrettierOptions()¶
protectedgetPrettierOptions(options?):Required\<PrettierMarkdownOptions>
Defined in: formatters/src/base-formatter.ts:45
Get resolved Prettier options, merging provided options with defaults.
Parameters¶
options?¶
Returns¶
Required\<PrettierMarkdownOptions>
Inherited from¶
BaseFormatter.getPrettierOptions
getProp()¶
protectedgetProp(content,key):Value|undefined
Defined in: formatters/src/base-formatter.ts:83
Get a specific property from block content.
Parameters¶
content¶
key¶
string
Returns¶
Value | undefined
Inherited from¶
getProps()¶
protectedgetProps(content):Record\<string,Value>
Defined in: formatters/src/base-formatter.ts:97
Get all properties from block content.
Parameters¶
content¶
Returns¶
Record\<string, Value>
Inherited from¶
getSectionName()¶
protectedgetSectionName(key):string
Defined in: formatters/src/markdown-instruction-formatter.ts:270
Parameters¶
key¶
Returns¶
string
getSkillBasePath()¶
getSkillBasePath():
string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:135
Base path for skills, or null if formatter has no skill support.
Returns¶
string | null
Overrides¶
BaseFormatter.getSkillBasePath
getSkillFileName()¶
getSkillFileName():
string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:139
Skill file name, or null if formatter has no skill support.
Returns¶
string | null
Overrides¶
BaseFormatter.getSkillFileName
gitCommits()¶
protectedgitCommits(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:646
Parameters¶
ast¶
renderer¶
Returns¶
string | null
isSafeSkillName()¶
protectedisSafeSkillName(name):boolean
Defined in: formatters/src/base-formatter.ts:515
Check if a skill name is safe for use in file paths.
Parameters¶
name¶
string
Returns¶
boolean
Inherited from¶
knowledgeContent()¶
protectedknowledgeContent(ast,_renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:774
Render remaining
Parameters¶
ast¶
_renderer¶
Returns¶
string | null
Knowledge¶
text content that isn't consumed by other sections. Strips "## Development Commands" and "## Post-Work Verification" sub-sections since those are already rendered by commands() and postWork().
normalizeMarkdownForPrettier()¶
protectednormalizeMarkdownForPrettier(content):string
Defined in: formatters/src/base-formatter.ts:204
Normalize markdown content to match Prettier formatting. - Strips common leading indentation from lines - Trims trailing whitespace from lines - Normalizes markdown table formatting - Adds blank lines before lists when preceded by text - Adds blank lines before code blocks when preceded by text - Escapes markdown special characters in paths
Parameters¶
content¶
string
Returns¶
string
Inherited from¶
BaseFormatter.normalizeMarkdownForPrettier
postWork()¶
protectedpostWork(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:717
Parameters¶
ast¶
renderer¶
Returns¶
string | null
project()¶
protectedproject(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:522
Parameters¶
ast¶
renderer¶
Returns¶
string | null
resolveVersion()¶
protectedresolveVersion(version?):MarkdownVersion
Defined in: formatters/src/markdown-instruction-formatter.ts:161
Parameters¶
version?¶
string
Returns¶
restrictions()¶
protectedrestrictions(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:811
Parameters¶
ast¶
renderer¶
Returns¶
string | null
sanitizeResourceFiles()¶
protectedsanitizeResourceFiles(resources,targetDir):FormatterOutput[]
Defined in: formatters/src/base-formatter.ts:483
Filter resource files to only include safe paths. Rejects paths with traversal, absolute paths, and unsafe names.
Parameters¶
resources¶
object[] | undefined
targetDir¶
string
Returns¶
Inherited from¶
BaseFormatter.sanitizeResourceFiles
stripAllIndent()¶
protectedstripAllIndent(content):string
Defined in: formatters/src/base-formatter.ts:348
Strip all leading indentation from markdown content. Used for AGENTS.md where content from multiple sources has inconsistent indentation. Preserves indentation inside code blocks.
Parameters¶
content¶
string
Returns¶
string
Inherited from¶
techStack()¶
protectedtechStack(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:555
Parameters¶
ast¶
renderer¶
Returns¶
string | null
transformRestrictionItem()¶
protectedtransformRestrictionItem(s):string
Defined in: formatters/src/markdown-instruction-formatter.ts:278
Parameters¶
s¶
string
Returns¶
string
truncate()¶
protectedtruncate(str,max):string
Defined in: formatters/src/base-formatter.ts:127
Truncate string to max length with ellipsis.
Parameters¶
str¶
string
max¶
number
Returns¶
string
Inherited from¶
valueToString()¶
protectedvalueToString(value):string
Defined in: formatters/src/base-formatter.ts:154
Convert value to string representation.
Parameters¶
value¶
Returns¶
string
Inherited from¶
yamlString()¶
protectedyamlString(value):string
Defined in: formatters/src/markdown-instruction-formatter.ts:470
Parameters¶
value¶
string
Returns¶
string