abc_mine.prompts¶
WARNING
This documentation is almost entirely "vibe coded"; while a helpful resource for humans and agents to understand this codebase, it should not be considered a source of ground truth in the way documentation normally is, and the user is responsible for verifying that all instructions given here are safe.
abc_mine.prompts
¶
Prompt composition: generic templates, per-codebase slots, and overrides.
abc-mine ships generic prompt templates (abc_mine/templates/)
that know nothing about any particular codebase. There are two, deliberately
distinct, mechanisms for adapting them to a specific repository.
.. _prompt-layering:
The two layers
A prompt pack is a directory the user points at with prompts.pack:
.. code-block:: text
my-codebase-prompts/
slots/ # (1) ADDITIVE context — the normal path
codebase_overview.md
build_test_guidance.md
verification_guidance.md
screening_notes.md
ranking_notes.md
construction_notes.md
exclusions.md
overrides/ # (2) FULL REPLACEMENT — advanced, opt-in
screen_system.md
...
(1) Slots — additive, the expected path. Each file fills one named slot in the shipped templates. A slot renders as a whole titled section that disappears entirely when the file is absent, so the surrounding prose reads correctly whether or not the user supplied anything. Writing a slot pack requires no knowledge of the base templates. Every slot is optional; the tool works with an empty pack, or no pack at all.
(2) Overrides — full replacement, deliberately gated. Occasionally a user needs to rewrite a base template outright rather than append to it. That is supported, but it is intentionally hard to do by accident, because a silently overridden system prompt is a debugging nightmare. Three independent things must line up:
- the file must live in
overrides/(notslots/), - it must be named exactly after a known base template (unknown names are a hard error, never a silent no-op),
- the run config must set
prompts.allow_template_overrides: true.
If overrides/ contains files but the flag is not set, loading fails
loudly rather than ignoring them — the one thing worse than an accidental
override is an accidentally-ignored one. Active overrides are recorded in the run
manifest with their SHA-256 and announced in a banner at every stage start, so a
run using them can never be mistaken for a stock run.
Overrides still receive normal placeholder substitution (including slots), and are validated: a template that drops a mechanically required placeholder — an output path the stage depends on — is rejected, since the stage could not function. Dropping a merely advisory placeholder (e.g. the rubric table) warns instead. That severity split is deliberate: mechanical breakage is an error, prompt-quality regression is the user's call.
Placeholder syntax
All substitution uses @@name@@. Unlike {name}, this cannot collide with
the JSON braces that appear throughout these prompts (the original Truchas
pipeline needed a single-pass regex hack to work around exactly that), so
injected JSON blocks are never re-scanned or mangled.
Slots are referenced as @@slot:codebase_overview@@.
Slot
dataclass
¶
One named, optional, per-codebase prompt slot.
Attributes:
| Name | Type | Description |
|---|---|---|
key |
str
|
Slot name; the file stem under |
heading |
str
|
Markdown heading emitted above the user's content when the slot is filled. Omitted entirely when the slot is empty. |
purpose |
str
|
One-line description shown by |
templates |
tuple[str, ...]
|
Base templates in which this slot appears. |
Source code in abc_mine/prompts.py
PromptError
¶
PromptPack
dataclass
¶
A loaded prompt pack: per-codebase slot content plus any overrides.
Attributes:
| Name | Type | Description |
|---|---|---|
root |
Path or None
|
The pack directory, or |
slots |
dict[str, str]
|
Slot key -> file content, for slots the user actually supplied. Absent and whitespace-only files are omitted, so an empty file behaves exactly like a missing one (a blank slot must not emit a dangling heading). |
overrides |
dict[str, str]
|
Template name -> replacement body, for active overrides only. |
override_digests |
dict[str, str]
|
Template name -> SHA-256 of the override body, recorded in the run manifest so an overridden run is auditable after the fact. |
warnings |
list[str]
|
Non-fatal problems (e.g. an override dropping an advisory placeholder), surfaced by the CLI at stage start. |
Source code in abc_mine/prompts.py
banner
¶
Return a loud multi-line banner when overrides are active, else None.
Source code in abc_mine/prompts.py
load_pack
¶
load_pack(pack_dir: Path | str | None, *, allow_template_overrides: bool = False) -> PromptPack
Load a prompt pack from pack_dir.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pack_dir
|
Path, str, or None
|
The pack directory. |
required |
allow_template_overrides
|
bool
|
Whether |
False
|
Raises:
| Type | Description |
|---|---|
PromptError
|
If the directory does not exist; if |
Source code in abc_mine/prompts.py
strip_comments
¶
Remove HTML comments from slot content and normalize surrounding blanks.
Scaffolded slot files consist of an instructional <!-- ... --> block
describing what to write. Those comments must never reach a live prompt: a
freshly-scaffolded pack would otherwise inject "this file is OPTIONAL, delete
it" into the agent's instructions under a real heading. Stripping them also
means a comment-only file is correctly treated as empty, so its slot
vanishes exactly as an absent file's would — which is what a user who
scaffolded a pack and filled in only two slots expects.
Users may also keep explanatory comments alongside real content; those are removed too, so a slot's rendered form is only its prose.
Source code in abc_mine/prompts.py
load_template
¶
load_template(name: str, pack: PromptPack | None = None) -> str
Return the body of base template name, honoring an active override.
Source code in abc_mine/prompts.py
render_slot
¶
render_slot(key: str, pack: PromptPack | None) -> str
Render one slot as a complete titled section, or an empty string.
This all-or-nothing shape is what lets the base templates read naturally in both states: an unfilled slot leaves no heading, no lead-in, and no stray whitespace behind — as though the section had never been written.
Source code in abc_mine/prompts.py
render
¶
render(name: str, *, pack: PromptPack | None = None, variables: Mapping[str, Any] | None = None, strict: bool = True) -> str
Render template name with slots and variables substituted.
Substitution is a single simultaneous pass: replaced content is never
re-scanned, so an injected value that happens to contain @@foo@@ (or JSON
braces) is left intact.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Base template name. |
required |
pack
|
PromptPack
|
Loaded prompt pack supplying slot content and overrides. |
None
|
variables
|
mapping
|
Values for |
None
|
strict
|
bool
|
If True (default), an unresolved non-slot placeholder raises. This
catches the class of bug where a stage forgets to pass a path and the
agent receives a literal |
True
|
Raises:
| Type | Description |
|---|---|
PromptError
|
If |
Source code in abc_mine/prompts.py
compose
¶
compose(system_name: str, task_name: str, *, pack: PromptPack | None = None, variables: Mapping[str, Any] | None = None, strict: bool = True) -> str
Render a system + task template pair into one prompt string.
The agent harness takes a single task prompt, so the stage-specific "system" guidance is prepended to the task instructions with a horizontal rule between them (matching how the original pipeline composed its prompts).
Source code in abc_mine/prompts.py
scaffold
¶
Create an empty, commented prompt pack at dest.
Writes one placeholder file per slot under slots/, each containing only a
comment describing its purpose — so a user can fill in what they need and
delete the rest. overrides/ is created only when explicitly
requested, keeping the advanced mechanism out of sight for users who do not
need it.
Returns the list of created paths.