UNPKG

@promptbook/vercel

Version:

Promptbook: Turn your company's scattered knowledge into AI ready books

54 lines (53 loc) 2.63 kB
import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements'; import type { CommitmentDefinition } from './CommitmentDefinition'; /** * Base implementation of CommitmentDefinition that provides common functionality * Most commitments can extend this class and only override the applyToAgentModelRequirements method * * @private */ export declare abstract class BaseCommitmentDefinition<TBookCommitment extends string> implements CommitmentDefinition { readonly type: TBookCommitment; readonly aliases: string[]; constructor(type: TBookCommitment, aliases?: string[]); /** * Short one-line markdown description; concise, may use inline **markdown**. * Must be implemented by each concrete commitment. */ abstract get description(): string; /** * Human-readable markdown documentation for this commitment, available at runtime. * Must be implemented by each concrete commitment. */ abstract get documentation(): string; /** * Creates a regex pattern to match this commitment in agent source * Uses the existing createCommitmentRegex function as internal helper */ createRegex(): RegExp; /** * Creates a regex pattern to match just the commitment type * Uses the existing createCommitmentTypeRegex function as internal helper */ createTypeRegex(): RegExp; /** * Applies this commitment's logic to the agent model requirements * This method must be implemented by each specific commitment */ abstract applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements; /** * Helper method to create a new requirements object with updated system message * This is commonly used by many commitments */ protected updateSystemMessage(requirements: AgentModelRequirements, messageUpdate: string | ((currentMessage: string) => string)): AgentModelRequirements; /** * Helper method to append content to the system message */ protected appendToSystemMessage(requirements: AgentModelRequirements, content: string, separator?: string): AgentModelRequirements; /** * Helper method to add a comment section to the system message * Comments are lines starting with # that will be removed from the final system message * but can be useful for organizing and structuring the message during processing */ protected addCommentSection(requirements: AgentModelRequirements, commentTitle: string, content: string, position?: 'beginning' | 'end'): AgentModelRequirements; }