Section

View as MarkdownOpen in Claude

A Section is a single node in a PromptObjectModel tree. Each section has a title, optional body text, optional bullet points, and any number of nested subsections.

1import { Section } from '@signalwire/sdk';
2
3const section = new Section('Role', { body: 'You are a helpful assistant.' });
4section.addBullets(['Be concise', 'Be accurate']);
5console.log(section.renderMarkdown());

Constructor

title
string | nullDefaults to null

Section title. null is permitted only on the very first top-level section of a model.

opts
object

Optional section content.

opts.body
string

Section body text.

opts.bullets
string[]

List of bullet point strings.

opts.numbered
boolean | null

Whether this section is numbered when rendered.

opts.numberedBullets
boolean

Whether bullet points are rendered as a numbered list instead of using bullet markers.

Properties

title
string | null

Section heading text, or null if untitled.

body
string

Section body paragraph text.

bullets
string[]

List of bullet point strings.

subsections
Section[]

Nested child sections.

numbered
boolean | null

Whether this section is numbered when rendered.

numberedBullets
boolean

Whether bullet points are rendered as a numbered list.

Methods

addBody

1addBody(body: string): void

Set or replace the body text for this section.

body
stringRequired

The body paragraph text.

addBullets

1addBullets(bullets: string[]): void

Append bullet points to this section, extending the existing list.

bullets
string[]Required

Bullet point strings to add.

addSubsection

1addSubsection(title: string, opts?): Section

Add a titled subsection to this section and return it. Subsections must have a title.

title
stringRequired

Subsection title.

opts
object

Optional body, bullets, numbered, and numberedBullets for the subsection.

Returns the newly created Section.

toDict

1toDict(): SectionData

Convert this section (and its subsections) to a plain SectionData object.

renderMarkdown

1renderMarkdown(level?: number, sectionNumber?: number[] | null): string

Render this section and its subsections as Markdown.

level
numberDefaults to 2

The heading level to start at (2 renders a ## heading).

sectionNumber
number[] | null

The current section number used for numbered sections.

renderXml

1renderXml(indent?: number, sectionNumber?: number[] | null): string

Render this section and its subsections as XML.

indent
numberDefaults to 0

The indentation level to start at.

sectionNumber
number[] | null

The current section number used for numbered sections.