readPromptSegment
readPromptSegment(
segment,config):string
Defined in: _worktrees/docs-release/gaunt-sloth/packages/core/src/utils/llmUtils.ts:268
GS2-43 — the single composition point for one prompt segment, honouring the segment’s
prompts.<segment> config:
- no setting → the segment’s default-named file (PROMPT_SEGMENT_FILES), falling back
to the bundled default unless
noDefaultPrompts— exactly the pre-GS2-43 behaviour; - a
string→ shorthand for{ path }; enabled: false→ the segment is dropped entirely (returns''), even its bundled default;path+mode: 'replace'(default) → the file replaces the built-in segment content;path+mode: 'append'→ the file content is appended after the built-in content.
CFG-70 — and then the run’s selected path-scoped overlays are appended, for every one of the
seven segments and therefore for every caller. This is the seam because it is the sole reader of
config.prompts?.[segment]: readGuidelines, readReviewInstructions, readSystemPrompt,
readChatPrompt, readCodePrompt, readExecPrompt and readBackstory are all thin wrappers,
so one edit here reaches buildSystemMessages, getReviewPreamble and the gth get system-prompt introspection alike, with no site left to forget.
The scoped overlay survives enabled: false, deliberately. A disabled root segment plus
matched scoped entries composes to the module blocks ALONE. Read against enabled’s own
docstring above — “the segment is dropped entirely” — that looks like a bug, and it is not:
enabled turns off the repository-wide segment, which is a coherent and useful monorepo
config alongside prompts.paths (“no guidelines for the repo, only per-module ones”). Honouring
it the other way would silently discard entries the user wrote explicitly, and force that user
to point guidelines at an empty file to express what they already expressed. Never discarding
configuration someone wrote on purpose is the principle the whole feature is built on.
.filter(Boolean) is load-bearing, not tidiness. With no scoped entries selected — which is
every run today, and every run of a project that does not use the feature — all four branches
must compose byte-identically to what they composed before this existed. A plain
[base, scoped].join('\n') appends a trailing newline when scoped is empty; the filter is
what makes the unset path an exact identity rather than an almost-identity.
Parameters
Section titled “Parameters”segment
Section titled “segment”config
Section titled “config”PromptReadConfig
Returns
Section titled “Returns”string