Class: GeminiFormatter¶
Defined in: formatters/src/formatters/gemini.ts:57
Formatter for Gemini CLI instructions.
Gemini uses GEMINI.md as its main configuration file, .gemini/commands/
Gemini has no agent concept.
Supports three versions: - simple: Single GEMINI.md file - multifile: GEMINI.md + commands (TOML) + skills - full (default): Multifile + skills
Example¶
Extends¶
Constructors¶
Constructor¶
new GeminiFormatter():
GeminiFormatter
Defined in: formatters/src/formatters/gemini.ts:58
Returns¶
GeminiFormatter
Overrides¶
MarkdownInstructionFormatter.constructor
Properties¶
config¶
protectedreadonlyconfig:MarkdownFormatterConfig
Defined in: formatters/src/markdown-instruction-formatter.ts:152
Inherited from¶
MarkdownInstructionFormatter.config
defaultConvention¶
readonlydefaultConvention:string
Defined in: formatters/src/markdown-instruction-formatter.ts:150
Default convention for this formatter
Inherited from¶
MarkdownInstructionFormatter.defaultConvention
description¶
readonlydescription:string
Defined in: formatters/src/markdown-instruction-formatter.ts:149
Human-readable description
Inherited from¶
MarkdownInstructionFormatter.description
name¶
readonlyname:string
Defined in: formatters/src/markdown-instruction-formatter.ts:147
Unique formatter identifier
Inherited from¶
MarkdownInstructionFormatter.name
outputPath¶
readonlyoutputPath:string
Defined in: formatters/src/markdown-instruction-formatter.ts:148
Default output file path
Inherited from¶
MarkdownInstructionFormatter.outputPath
standardsExtractor¶
protectedreadonlystandardsExtractor:StandardsExtractor
Defined in: formatters/src/base-formatter.ts:28
Shared standards extractor for consistent extraction across all formatters.
Inherited from¶
MarkdownInstructionFormatter.standardsExtractor
Methods¶
addCommonSections()¶
protectedaddCommonSections(ast,renderer,sections):void
Defined in: formatters/src/markdown-instruction-formatter.ts:637
Parameters¶
ast¶
renderer¶
sections¶
string[]
Returns¶
void
Inherited from¶
MarkdownInstructionFormatter.addCommonSections
addSection()¶
protectedaddSection(sections,content):void
Defined in: formatters/src/markdown-instruction-formatter.ts:657
Parameters¶
sections¶
string[]
content¶
string | null
Returns¶
void
Inherited from¶
MarkdownInstructionFormatter.addSection
architecture()¶
protectedarchitecture(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:756
Parameters¶
ast¶
renderer¶
Returns¶
string | null
Inherited from¶
MarkdownInstructionFormatter.architecture
codeStandards()¶
protectedcodeStandards(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:769
Parameters¶
ast¶
renderer¶
Returns¶
string | null
Inherited from¶
MarkdownInstructionFormatter.codeStandards
commands()¶
protectedcommands(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:825
Parameters¶
ast¶
renderer¶
Returns¶
string | null
Inherited from¶
MarkdownInstructionFormatter.commands
configFiles()¶
protectedconfigFiles(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:807
Parameters¶
ast¶
renderer¶
Returns¶
string | null
Inherited from¶
MarkdownInstructionFormatter.configFiles
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¶
MarkdownInstructionFormatter.createRenderer
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¶
MarkdownInstructionFormatter.dedent
diagrams()¶
protecteddiagrams(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:888
Parameters¶
ast¶
renderer¶
Returns¶
string | null
Inherited from¶
MarkdownInstructionFormatter.diagrams
documentation()¶
protecteddocumentation(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:869
Parameters¶
ast¶
renderer¶
Returns¶
string | null
Inherited from¶
MarkdownInstructionFormatter.documentation
examples()¶
protectedexamples(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:960
Parameters¶
ast¶
renderer¶
Returns¶
string | null
Inherited from¶
MarkdownInstructionFormatter.examples
extractAgents()¶
protectedextractAgents(ast):MarkdownAgentConfig[]
Defined in: formatters/src/markdown-instruction-formatter.ts:558
Parameters¶
ast¶
Returns¶
Inherited from¶
MarkdownInstructionFormatter.extractAgents
extractCommands()¶
protectedextractCommands(ast):MarkdownCommandConfig[]
Defined in: formatters/src/markdown-instruction-formatter.ts:385
Parameters¶
ast¶
Returns¶
Inherited from¶
MarkdownInstructionFormatter.extractCommands
extractExamples()¶
protectedextractExamples(ast):object[]
Defined in: formatters/src/base-formatter.ts:599
Extract examples from the
Parameters¶
ast¶
Returns¶
object[]
Examples¶
block. Returns an array of example definitions with name, input, output, and optional description.
Inherited from¶
MarkdownInstructionFormatter.extractExamples
extractRestrictionsItems()¶
protectedextractRestrictionsItems(content):string[]
Defined in: formatters/src/markdown-instruction-formatter.ts:964
Parameters¶
content¶
Returns¶
string[]
Inherited from¶
MarkdownInstructionFormatter.extractRestrictionsItems
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¶
MarkdownInstructionFormatter.extractSectionWithCodeBlock
extractSkillExamples()¶
protectedextractSkillExamples(skillProps):object[]
Defined in: formatters/src/base-formatter.ts:612
Extract examples from a skill's nested examples property. Returns the same shape as extractExamples.
Parameters¶
skillProps¶
Record\<string, Value>
Returns¶
object[]
Inherited from¶
MarkdownInstructionFormatter.extractSkillExamples
extractSkills()¶
protectedextractSkills(ast,options?):MarkdownSkillConfig[]
Defined in: formatters/src/markdown-instruction-formatter.ts:455
Parameters¶
ast¶
options?¶
Returns¶
Inherited from¶
MarkdownInstructionFormatter.extractSkills
extractTechStackFromContext()¶
protectedextractTechStackFromContext(context):string[]
Defined in: formatters/src/markdown-instruction-formatter.ts:714
Parameters¶
context¶
Block | undefined
Returns¶
string[]
Inherited from¶
MarkdownInstructionFormatter.extractTechStackFromContext
extractTechStackFromStandards()¶
protectedextractTechStackFromStandards(standards):string[]
Defined in: formatters/src/markdown-instruction-formatter.ts:740
Parameters¶
standards¶
Block | undefined
Returns¶
string[]
Inherited from¶
MarkdownInstructionFormatter.extractTechStackFromStandards
extractText()¶
protectedextractText(content):string
Defined in: formatters/src/base-formatter.ts:69
Extract text from block content.
Parameters¶
content¶
Returns¶
string
Inherited from¶
MarkdownInstructionFormatter.extractText
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¶
MarkdownInstructionFormatter.findBlock
format()¶
format(
ast,options?):FormatterOutput
Defined in: formatters/src/markdown-instruction-formatter.ts:177
Transform AST to tool-specific format
Parameters¶
ast¶
options?¶
Returns¶
Inherited from¶
MarkdownInstructionFormatter.format
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¶
MarkdownInstructionFormatter.formatArray
formatFull()¶
protectedformatFull(ast,options?):FormatterOutput
Defined in: formatters/src/formatters/gemini.ts:95
Gemini treats full mode as multifile (no agents).
Parameters¶
ast¶
options?¶
Returns¶
Overrides¶
MarkdownInstructionFormatter.formatFull
formatMultifile()¶
protectedformatMultifile(ast,options?):FormatterOutput
Defined in: formatters/src/markdown-instruction-formatter.ts:230
Parameters¶
ast¶
options?¶
Returns¶
Inherited from¶
MarkdownInstructionFormatter.formatMultifile
formatSimple()¶
protectedformatSimple(ast,options?):FormatterOutput
Defined in: formatters/src/markdown-instruction-formatter.ts:205
Parameters¶
ast¶
options?¶
Returns¶
Inherited from¶
MarkdownInstructionFormatter.formatSimple
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¶
MarkdownInstructionFormatter.formatStandardsList
generateAgentFile()¶
protectedgenerateAgentFile(config):FormatterOutput
Defined in: formatters/src/markdown-instruction-formatter.ts:582
Parameters¶
config¶
Returns¶
Inherited from¶
MarkdownInstructionFormatter.generateAgentFile
generateCommandFile()¶
protectedgenerateCommandFile(config):FormatterOutput
Defined in: formatters/src/formatters/gemini.ts:102
Gemini uses TOML format for command files instead of YAML frontmatter.
Parameters¶
config¶
Returns¶
Overrides¶
MarkdownInstructionFormatter.generateCommandFile
generateFrontmatter()¶
protectedgenerateFrontmatter(_ast,_options?):string|undefined
Defined in: formatters/src/markdown-instruction-formatter.ts:361
Parameters¶
_ast¶
_options?¶
Returns¶
string | undefined
Inherited from¶
MarkdownInstructionFormatter.generateFrontmatter
generateMcpConfig()¶
protectedgenerateMcpConfig(ast):FormatterOutput|undefined
Defined in: formatters/src/markdown-instruction-formatter.ts:338
Generate MCP config file from
Parameters¶
ast¶
Returns¶
FormatterOutput | undefined
Mcp Servers¶
block if configured. Returns FormatterOutput or undefined if no MCP block or no config path.
Inherited from¶
MarkdownInstructionFormatter.generateMcpConfig
generateSkillFile()¶
protectedgenerateSkillFile(config,options?):FormatterOutput
Defined in: formatters/src/markdown-instruction-formatter.ts:491
Parameters¶
config¶
options?¶
Returns¶
Inherited from¶
MarkdownInstructionFormatter.generateSkillFile
getArrayElements()¶
protectedgetArrayElements(content):Value[]
Defined in: formatters/src/base-formatter.ts:144
Extract array elements from block content.
Parameters¶
content¶
Returns¶
Value[]
Inherited from¶
MarkdownInstructionFormatter.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¶
MarkdownInstructionFormatter.getMetaField
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¶
MarkdownInstructionFormatter.getOutputPath
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¶
MarkdownInstructionFormatter.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¶
MarkdownInstructionFormatter.getProp
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¶
MarkdownInstructionFormatter.getProps
getSectionName()¶
protectedgetSectionName(key):string
Defined in: formatters/src/markdown-instruction-formatter.ts:369
Parameters¶
key¶
Returns¶
string
Inherited from¶
MarkdownInstructionFormatter.getSectionName
getSkillBasePath()¶
getSkillBasePath():
string|null
Defined in: formatters/src/formatters/gemini.ts:88
Resolve the skill base path based on the skillPath target option. - agents (default): .agents/skills/ (interoperable) - gemini: .gemini/skills/ (legacy) - both: .agents/skills/ (primary; both mode handled in format)
Returns¶
string | null
Overrides¶
MarkdownInstructionFormatter.getSkillBasePath
getSkillFileName()¶
getSkillFileName():
string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:168
Skill file name, or null if formatter has no skill support.
Returns¶
string | null
Inherited from¶
MarkdownInstructionFormatter.getSkillFileName
gitCommits()¶
protectedgitCommits(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:785
Parameters¶
ast¶
renderer¶
Returns¶
string | null
Inherited from¶
MarkdownInstructionFormatter.gitCommits
isSafeName()¶
protectedisSafeName(name):boolean
Defined in: formatters/src/base-formatter.ts:699
Check if a name is safe for use in file paths. Rejects path traversal sequences and path separators.
Parameters¶
name¶
string
Returns¶
boolean
Inherited from¶
MarkdownInstructionFormatter.isSafeName
isSafeSkillName()¶
protectedisSafeSkillName(name):boolean
Defined in: formatters/src/base-formatter.ts:706
Check if a skill name is safe for use in file paths.
Parameters¶
name¶
string
Returns¶
boolean
Inherited from¶
MarkdownInstructionFormatter.isSafeSkillName
knowledgeContent()¶
protectedknowledgeContent(ast,_renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:913
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().
Inherited from¶
MarkdownInstructionFormatter.knowledgeContent
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¶
MarkdownInstructionFormatter.normalizeMarkdownForPrettier
normalizeOutputDir()¶
protectednormalizeOutputDir(dir):string
Defined in: formatters/src/base-formatter.ts:485
Normalize a user-provided output directory (from @use ... into "<path>" or skillTargets config) to a safe forward-slash relative path. Rejects .., . and leading slashes so the result can be appended to a target's dot-directory without escaping it.
Parameters¶
dir¶
string
Returns¶
string
Inherited from¶
MarkdownInstructionFormatter.normalizeOutputDir
postWork()¶
protectedpostWork(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:856
Parameters¶
ast¶
renderer¶
Returns¶
string | null
Inherited from¶
MarkdownInstructionFormatter.postWork
project()¶
protectedproject(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:661
Parameters¶
ast¶
renderer¶
Returns¶
string | null
Inherited from¶
MarkdownInstructionFormatter.project
referenceProvenance()¶
protectedreferenceProvenance(sourcePath):string
Defined in: formatters/src/base-formatter.ts:691
Generate a provenance comment for a reference file.
Parameters¶
sourcePath¶
string
Returns¶
string
Inherited from¶
MarkdownInstructionFormatter.referenceProvenance
referencesMode()¶
referencesMode():
"none"|"directory"|"inline"
Defined in: formatters/src/markdown-instruction-formatter.ts:173
How this formatter handles skill references. - 'directory': emit as separate files in references/ subdirectory - 'inline': append as sections in the main output file - 'none': references not supported
Returns¶
"none" | "directory" | "inline"
Inherited from¶
MarkdownInstructionFormatter.referencesMode
renderCodeFence()¶
protectedrenderCodeFence(content,lang?):string
Defined in: formatters/src/base-formatter.ts:714
Render content inside a code fence, using a longer fence if the content itself contains triple backticks (prevents code fence injection).
Parameters¶
content¶
string
lang?¶
string = ''
Returns¶
string
Inherited from¶
MarkdownInstructionFormatter.renderCodeFence
renderExamplesSection()¶
protectedrenderExamplesSection(ast,renderer,sectionName?):string|null
Defined in: formatters/src/base-formatter.ts:628
Render an examples section from the
Parameters¶
ast¶
renderer¶
sectionName?¶
string = 'Examples'
Custom section heading name (default: 'Examples')
Returns¶
string | null
Examples¶
block. Shared rendering logic used by Claude, GitHub, and MarkdownInstructionFormatter.
Inherited from¶
MarkdownInstructionFormatter.renderExamplesSection
resolveSkillDir()¶
protectedresolveSkillDir(defaultSkillBasePath,skillName,outputDir?,options?):string
Defined in: formatters/src/base-formatter.ts:515
Resolve the directory for a generated skill, respecting per-target skill base overrides while preserving existing @use ... into behavior.
Parameters¶
defaultSkillBasePath¶
string
skillName¶
string
outputDir?¶
string
options?¶
Returns¶
string
Inherited from¶
MarkdownInstructionFormatter.resolveSkillDir
resolveVersion()¶
protectedresolveVersion(version?):MarkdownVersion
Defined in: formatters/src/formatters/gemini.ts:123
Override version resolution: full maps to multifile for Gemini.
Parameters¶
version?¶
string
Returns¶
Overrides¶
MarkdownInstructionFormatter.resolveVersion
restrictions()¶
protectedrestrictions(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:950
Parameters¶
ast¶
renderer¶
Returns¶
string | null
Inherited from¶
MarkdownInstructionFormatter.restrictions
sanitizeResourceFiles()¶
protectedsanitizeResourceFiles(resources,targetDir):FormatterOutput[]
Defined in: formatters/src/base-formatter.ts:549
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¶
MarkdownInstructionFormatter.sanitizeResourceFiles
shouldIncludeSkill()¶
protectedshouldIncludeSkill(name,options?):boolean
Defined in: formatters/src/base-formatter.ts:504
Return true when the target configuration allows emitting the given skill.
Parameters¶
name¶
string
options?¶
Returns¶
boolean
Inherited from¶
MarkdownInstructionFormatter.shouldIncludeSkill
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¶
MarkdownInstructionFormatter.stripAllIndent
techStack()¶
protectedtechStack(ast,renderer):string|null
Defined in: formatters/src/markdown-instruction-formatter.ts:694
Parameters¶
ast¶
renderer¶
Returns¶
string | null
Inherited from¶
MarkdownInstructionFormatter.techStack
transformInjectedSkillContent()¶
transformInjectedSkillContent(
content):string
Defined in: formatters/src/base-formatter.ts:684
Default pass-through for injected skill content. Formatters whose target tools restrict skill frontmatter (e.g. Factory AI) override this hook to filter unsupported fields before the compiler writes the file.
Parameters¶
content¶
string
Returns¶
string
Inherited from¶
MarkdownInstructionFormatter.transformInjectedSkillContent
transformRestrictionItem()¶
protectedtransformRestrictionItem(s):string
Defined in: formatters/src/markdown-instruction-formatter.ts:377
Parameters¶
s¶
string
Returns¶
string
Inherited from¶
MarkdownInstructionFormatter.transformRestrictionItem
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¶
MarkdownInstructionFormatter.truncate
valueToString()¶
protectedvalueToString(value):string
Defined in: formatters/src/base-formatter.ts:154
Convert value to string representation.
Parameters¶
value¶
Returns¶
string
Inherited from¶
MarkdownInstructionFormatter.valueToString
yamlString()¶
protectedyamlString(value):string
Defined in: formatters/src/markdown-instruction-formatter.ts:608
Parameters¶
value¶
string
Returns¶
string
Inherited from¶
MarkdownInstructionFormatter.yamlString
getSupportedVersions()¶
staticgetSupportedVersions():object
Defined in: formatters/src/formatters/gemini.ts:78
Get supported versions for this formatter.
Returns¶
object
full¶
readonlyfull:object
full.description¶
readonlydescription:"Multifile (Gemini has no agent concept, equivalent to multifile)"='Multifile (Gemini has no agent concept, equivalent to multifile)'
full.name¶
readonlyname:"full"='full'
full.outputPath¶
readonlyoutputPath:"GEMINI.md"='GEMINI.md'
multifile¶
readonlymultifile:object
multifile.description¶
readonlydescription:"GEMINI.md + .gemini/commands/<name>.toml + .gemini/skills/<name>/skill.md"='GEMINI.md + .gemini/commands/<name>.toml + .gemini/skills/<name>/skill.md'
multifile.name¶
readonlyname:"multifile"='multifile'
multifile.outputPath¶
readonlyoutputPath:"GEMINI.md"='GEMINI.md'
simple¶
readonlysimple:object
simple.description¶
readonlydescription:"Single GEMINI.md file"='Single GEMINI.md file'
simple.name¶
readonlyname:"simple"='simple'
simple.outputPath¶
readonlyoutputPath:"GEMINI.md"='GEMINI.md'