Skip to content

PromptScript API


Class: GitHubFormatter

Defined in: formatters/src/formatters/github.ts:111

Formatter for GitHub Copilot instructions.

Supports three versions: - simple (default): Single .github/copilot-instructions.md file - multifile: Main + .github/instructions/*.instructions.md + .github/prompts/*.prompt.md - full: Multifile + .github/skills/<name>/SKILL.md + AGENTS.md

Example

targets:
  - github  # uses simple mode
  - github:
      version: multifile
  - github:
      version: full

See

https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot

Extends

Constructors

Constructor

new GitHubFormatter(): GitHubFormatter

Returns

GitHubFormatter

Inherited from

BaseFormatter.constructor

Properties

defaultConvention

readonly defaultConvention: "markdown" = 'markdown'

Defined in: formatters/src/formatters/github.ts:115

Default convention for this formatter

Overrides

BaseFormatter.defaultConvention


description

readonly description: "GitHub Copilot instructions (Markdown)" = 'GitHub Copilot instructions (Markdown)'

Defined in: formatters/src/formatters/github.ts:114

Human-readable description

Overrides

BaseFormatter.description


name

readonly name: "github" = 'github'

Defined in: formatters/src/formatters/github.ts:112

Unique formatter identifier

Overrides

BaseFormatter.name


outputPath

readonly outputPath: ".github/copilot-instructions.md" = '.github/copilot-instructions.md'

Defined in: formatters/src/formatters/github.ts:113

Default output file path

Overrides

BaseFormatter.outputPath

Methods

createRenderer()

protected createRenderer(options?): ConventionRenderer

Defined in: formatters/src/base-formatter.ts:20

Create a convention renderer for this formatter. Uses the provided convention from options or falls back to the default.

Parameters

options?

FormatOptions

Returns

ConventionRenderer

Inherited from

BaseFormatter.createRenderer


extractSectionWithCodeBlock()

protected extractSectionWithCodeBlock(text, header): string | null

Defined in: formatters/src/base-formatter.ts:140

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

string

Returns

string | null

Inherited from

BaseFormatter.extractSectionWithCodeBlock


extractText()

protected extractText(content): string

Defined in: formatters/src/base-formatter.ts:42

Extract text from block content.

Parameters

content

BlockContent

Returns

string

Inherited from

BaseFormatter.extractText


findBlock()

protected findBlock(ast, name): Block | undefined

Defined in: formatters/src/base-formatter.ts:35

Find a block by name, ignoring internal blocks (starting with __).

Parameters

ast

Program

name

string

Returns

Block | undefined

Inherited from

BaseFormatter.findBlock


format()

format(ast, options?): FormatterOutput

Defined in: formatters/src/formatters/github.ts:124

Transform AST to tool-specific format

Parameters

ast

Program

options?

FormatOptions

Returns

FormatterOutput

Overrides

BaseFormatter.format


formatArray()

protected formatArray(arr): string

Defined in: formatters/src/base-formatter.ts:84

Format an array as comma-separated string.

Parameters

arr

unknown[]

Returns

string

Inherited from

BaseFormatter.formatArray


getArrayElements()

protected getArrayElements(content): Value[]

Defined in: formatters/src/base-formatter.ts:108

Extract array elements from block content.

Parameters

content

BlockContent

Returns

Value[]

Inherited from

BaseFormatter.getArrayElements


getMetaField()

protected getMetaField(ast, key): string | undefined

Defined in: formatters/src/base-formatter.ts:98

Get meta field value as string.

Parameters

ast

Program

key

string

Returns

string | undefined

Inherited from

BaseFormatter.getMetaField


getOutputPath()

protected getOutputPath(options?): string

Defined in: formatters/src/base-formatter.ts:28

Get the output path, respecting options override.

Parameters

options?

FormatOptions

Returns

string

Inherited from

BaseFormatter.getOutputPath


getProp()

protected getProp(content, key): Value | undefined

Defined in: formatters/src/base-formatter.ts:56

Get a specific property from block content.

Parameters

content

BlockContent

key

string

Returns

Value | undefined

Inherited from

BaseFormatter.getProp


getProps()

protected getProps(content): Record\<string, Value>

Defined in: formatters/src/base-formatter.ts:70

Get all properties from block content.

Parameters

content

BlockContent

Returns

Record\<string, Value>

Inherited from

BaseFormatter.getProps


truncate()

protected truncate(str, max): string

Defined in: formatters/src/base-formatter.ts:91

Truncate string to max length with ellipsis.

Parameters

str

string

max

number

Returns

string

Inherited from

BaseFormatter.truncate


valueToString()

protected valueToString(value): string

Defined in: formatters/src/base-formatter.ts:118

Convert value to string representation.

Parameters

value

Value

Returns

string

Inherited from

BaseFormatter.valueToString


getSupportedVersions()

static getSupportedVersions(): object

Defined in: formatters/src/formatters/github.ts:120

Get supported versions for this formatter.

Returns

object

full

readonly full: object

full.description

readonly description: "Multifile + skills (.github/skills/) + agents (.github/agents/) + AGENTS.md" = 'Multifile + skills (.github/skills/) + agents (.github/agents/) + AGENTS.md'

full.name

readonly name: "full" = 'full'

full.outputPath

readonly outputPath: ".github/copilot-instructions.md" = '.github/copilot-instructions.md'

multifile

readonly multifile: object

multifile.description

readonly description: "Main + path-specific instructions (.github/instructions/) + prompts" = 'Main + path-specific instructions (.github/instructions/) + prompts'

multifile.name

readonly name: "multifile" = 'multifile'

multifile.outputPath

readonly outputPath: ".github/copilot-instructions.md" = '.github/copilot-instructions.md'

simple

readonly simple: object

simple.description

readonly description: "Single file output (.github/copilot-instructions.md)" = 'Single file output (.github/copilot-instructions.md)'

simple.name

readonly name: "simple" = 'simple'

simple.outputPath

readonly outputPath: ".github/copilot-instructions.md" = '.github/copilot-instructions.md'