UNPKG

aiwg

Version:

Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo

84 lines 2.95 kB
/** * Context Budget — configurable context/generation token split * * Manages token budgets for context windows with a default 70/30 split * (70% context, 30% generation). Supports priority scoring based on * recency, similarity, and @-mention presence. * * @module metrics/context-budget * @issue #144 */ export interface BudgetConfig { /** Total context window size in tokens */ totalTokens: number; /** Fraction allocated to context (0-1), default 0.70 */ contextFraction: number; /** Fraction allocated to generation (0-1), default 0.30 */ generationFraction: number; /** Warning threshold as fraction of context budget (0-1), default 0.85 */ warningThreshold: number; /** Hard limit as fraction of context budget (0-1), default 0.95 */ hardLimitThreshold: number; } export interface ContextItem { /** Unique identifier */ id: string; /** The content text */ content: string; /** Estimated token count */ tokens: number; /** Priority score (higher = more important, 0-1) */ priority: number; /** Source metadata */ source: { /** How the item was included */ type: 'at-mention' | 'auto' | 'system' | 'user'; /** ISO timestamp of when the item was added */ addedAt: string; /** Similarity score to current task (0-1) */ similarity?: number; }; } export interface BudgetStatus { /** Total budget for context in tokens */ contextBudget: number; /** Total budget for generation in tokens */ generationBudget: number; /** Tokens currently used by context items */ contextUsed: number; /** Remaining context tokens */ contextRemaining: number; /** Usage fraction (0-1) */ usageFraction: number; /** Current status level */ level: 'ok' | 'warning' | 'critical' | 'exceeded'; /** Number of context items */ itemCount: number; } export interface DegradationResult { /** Items that were kept */ kept: ContextItem[]; /** Items that were dropped */ dropped: ContextItem[]; /** Tokens freed by degradation */ tokensFreed: number; } export declare class ContextBudgetManager { private config; private items; private projectPath; constructor(projectPath: string, config?: Partial<BudgetConfig>); get contextBudget(): number; get generationBudget(): number; addItem(id: string, content: string, sourceType: ContextItem['source']['type'], similarity?: number): ContextItem; removeItem(id: string): boolean; getStatus(): BudgetStatus; wouldExceed(content: string): boolean; degrade(): DegradationResult; getItems(): ContextItem[]; loadConfig(): Promise<void>; saveConfig(): Promise<void>; getConfig(): BudgetConfig; } export declare function calculatePriority(sourceType: ContextItem['source']['type'], similarity?: number): number; //# sourceMappingURL=context-budget.d.ts.map