/** * Pure-logic helpers for prompt assembly. * * Extracted from hooks/prompt.ts per PRI-444. These functions contain NO I/O * and NO side effects — they are independently unit-testable. * * I/O helpers (cachedReadFile, loadContextInjectionConfig) * remain in prompt.ts because they depend on module-level cache state and fs. * * Pattern follows after-tool-call-helpers.ts (PRI-326): plugin-internal * decomposition + core pure-function reuse. * * ERR checklist: * EP-01: All unknown inputs use typeof/Object.hasOwn guards, never `as` * EP-03: Pure functions never swallow errors; invalid input returns empty string * EP-09: Pure functions are independently unit-testable without mocks */ import type { ExtractedUserMessage, CorePrincipleEntry, EvolutionPrincipleEntry, AppendSystemContextParts } from './prompt-types.js'; /** * Extract the actual user message from the raw prompt text. * * The prompt may contain: * - Boot check messages (system-generated, return empty) * - Feishu wrapper format 1: "Sender (untrusted metadata): ```json {...}``` text" * - Feishu wrapper format 2: "Conversation info (untrusted metadata): ```json {...}``` text" * - Clean user message text * * Also detects agent-to-agent messages (so user-interaction-only injections — * correction cues, behavioral constraints — are skipped for them). * * Pure logic — no I/O, no side effects. */ export declare function extractUserMessageFromPrompt(prompt: string, sessionId: string | undefined): ExtractedUserMessage; /** * Build the governance context section for prependSystemContext. * * Pre-pivot identity block (autonomous evolution framing) removed per * PRI-547 Round 3: PD does not own Agent identity or autonomous evolution; * it provides governance boundaries. This text is deliberately persona-free. * * Pure logic — returns a constant string. */ export declare function buildGovernanceContext(): string; /** * Build the empathy output restriction constraint text. * * Still live after PRI-819: PD's signal pipeline parses structured empathy * markers (damageDetected / tags) out of agent output as evidence. * A main agent emitting them itself would corrupt that evidence channel, so * normal output must keep them out. (PRI-819: the stale claim that "the * empathy observer subagent" handles detection was removed — detection is * owned by signal-collector-host / DetectionService.) * * Pure logic — returns a constant string. */ export declare function buildEmpathySilenceConstraint(): string; /** * Wrap heartbeat checklist content in XML tags. * * Pure logic — no I/O, no side effects. */ export declare function assembleHeartbeatChecklist(content: string): string; /** * Format core principles into prompt-ready text. * * Pure logic — uses escapeXml for safe XML embedding. * * @param principles Active principles from evolution reducer * @returns Formatted lines (empty string if no principles) */ export declare function formatCorePrinciples(principles: CorePrincipleEntry[]): string; /** * Format evolution principles (active + probation) into prompt-ready text. * * Pure logic — uses escapeXml for safe XML embedding. * * @param active Active principles (high priority) * @param probation Probation principles (contextual, caution) * @returns Formatted lines (empty string if no principles) */ export declare function formatEvolutionPrinciples(active: EvolutionPrincipleEntry[], probation: EvolutionPrincipleEntry[]): string; /** * Assemble appendSystemContext from ordered parts. * * Content order (most important last): * behavioral_constraints → project_context → intent_block → working_memory → * thinking_os → evolution_principles → core_principles * * PRI-467: intent_block (INTENT.md reference) sits after project_context * (stable reference data, lower priority than principles) and before * working_memory (volatile per-session state). * * Pure logic — string assembly only, no I/O. * * @param parts Ordered content parts (empty/undefined parts are skipped) * @returns Assembled appendSystemContext (empty string if no parts) */ export declare function assembleAppendSystemContext(parts: AppendSystemContextParts): string;