UNPKG

@phren/cli

Version:

Knowledge layer for AI agents - CLI, MCP server, and data layer

114 lines (113 loc) • 4.44 kB
import type { DreamChange, DreamChangeset, DreamOp } from "./types.js"; export type DreamMode = "propose" | "apply"; /** `deferred`: an addition still waiting for review queue publication. */ export type DreamOutcomeStatus = "applied" | "proposed" | "skipped" | "deferred" | "failed"; export interface DreamOutcome { index: number; op: DreamOp; status: DreamOutcomeStatus; detail: string; } /** A change validation refused, with why; `index` is its position in the model's answer. */ export interface DreamDrop { index: number; op: string; reason: string; } export declare const DREAM_ACCEPTANCE_DEFAULT_LIMIT = 20; export declare const clean: (text: string, max?: number) => string; export declare function dreamRecordFile(phrenPath: string, project: string, runId: string): string; export declare function readDreamRecord(file: string, project: string, runId: string): DreamRecord; export interface DreamRecord { changeset: DreamChangeset; findingVersions?: Record<string, string>; warnings?: string[]; mode: DreamMode; model?: string; finishedAt: string; outcomes: DreamOutcome[]; dropped: DreamDrop[]; costUSD?: number; } export interface DreamCounts { applied: number; proposed: number; skipped: number; deferred: number; failed: number; dropped: number; } export declare function countOutcomes(outcomes: DreamOutcome[], dropped: DreamDrop[]): DreamCounts; export declare function recordDream(phrenPath: string, project: string, record: DreamRecord): string; export interface DreamLastRun { at: string; trigger: "manual" | "scheduled"; runId: string; startedAt: string; finishedAt: string; to: string; mode: DreamMode; status: string; counts?: DreamCounts; } export declare function writeLastRun(phrenPath: string, project: string, marker: Omit<DreamLastRun, "at">): void; export declare function readLastRun(phrenPath: string, project: string): DreamLastRun | undefined; export interface DreamDecision { id: string; runId: string; index: number; op: DreamOp; outcome: "applied" | "rejected"; decidedAt?: string; computer: string; reason?: string; supersedes?: string[]; } export interface DreamEffectiveOutcome extends Omit<DreamOutcome, "status"> { status: DreamOutcomeStatus | "rejected" | "conflicted"; decidedAt?: string; reason?: string; reasons?: string[]; } export declare function isPendingProposal({ status }: Pick<DreamEffectiveOutcome, "status">): boolean; type StoredDreamDecision = DreamDecision & { decidedAt: string; }; type DecisionInput = Omit<StoredDreamDecision, "id" | "decidedAt" | "computer">; export declare function writeDreamDecision(phrenPath: string, project: string, input: DecisionInput): void; export declare function beginDreamApply(phrenPath: string, project: string, runId: string, index: number, change: DreamChange, before: string): () => void; export declare function recoverDreamDecision(phrenPath: string, project: string, runId: string, index: number, change: DreamChange, inspect: () => { fingerprint: string; applied: boolean; }): void; export declare function readDreamDecisions(phrenPath: string, project: string, runId: string): Map<number, DreamDecision[]>; export declare function isStructuredProposal(outcome: DreamOutcome): boolean; export declare function activeDreamDecisions(runId: string, outcome: DreamOutcome, decisions?: DreamDecision[]): DreamDecision[]; export declare function effectiveDreamOutcome(outcome: DreamOutcome, active: DreamDecision[]): DreamEffectiveOutcome; interface DreamOpAcceptance { proposed: number; applied: number; rejected: number; pending: number; conflicted: number; skipped: number; acceptRate: number | null; } export interface DreamAcceptance { runs: number; byOp: Partial<Record<DreamOp, DreamOpAcceptance>>; } export interface DreamDecisionConflict { runId: string; index: number; op: DreamOp; decisions: DreamDecision[]; } export declare function formatDreamAcceptance(counts: DreamOpAcceptance): string; export declare function pendingDreamProposals(phrenPath: string, project: string): number; export declare function dreamProposalStats(phrenPath: string, project: string, limit: number): { pendingProposals: number; acceptance: DreamAcceptance; conflicts: DreamDecisionConflict[]; }; export {};