@phren/cli
Version:
Knowledge layer for AI agents - CLI, MCP server, and data layer
83 lines (82 loc) • 3.69 kB
TypeScript
/**
* The `dreaming` config domain: the offline pass that reorganizes a project's
* memory between sessions (docs/dreaming.md). Off by default.
*
* Global values live in `.config/dreaming.json`; a project overrides any of
* them under `config.dreaming` in its `phren.project.yaml`. Reads are lenient
* (an invalid value falls back to the level below it); writes validate and say
* why a value was refused.
*/
export declare const DREAM_MODES: readonly ["propose", "apply"];
export type DreamMode = typeof DREAM_MODES[number];
export declare const DREAM_CADENCES: readonly ["nightly", "idle", "weekly", "manual"];
export type DreamCadence = typeof DREAM_CADENCES[number];
export declare const DREAM_PHASES: readonly ["capture", "correct", "organize", "prune"];
export type DreamPhase = typeof DREAM_PHASES[number];
export interface DreamingConfig {
enabled: boolean;
mode: DreamMode;
cadence: DreamCadence;
/** `HH:MM-HH:MM` local time; may wrap midnight (`22:00-02:00`). */
window: string;
idleMinutes: number;
lookbackHours: number;
maxChanges: number;
injectBudgetKB: number;
phases: DreamPhase[];
/** Empty means the project's helper model. */
model: string;
}
export declare const DEFAULT_DREAMING_CONFIG: Readonly<DreamingConfig>;
/** Inclusive ranges for the numeric keys; the schema descriptors share them. */
export declare const DREAMING_RANGES: {
readonly idleMinutes: {
readonly min: 5;
readonly max: 1440;
readonly step: 5;
};
readonly lookbackHours: {
readonly min: 1;
readonly max: 720;
readonly step: 1;
};
readonly maxChanges: {
readonly min: 1;
readonly max: 200;
readonly step: 1;
};
readonly injectBudgetKB: {
readonly min: 1;
readonly max: 256;
readonly step: 1;
};
};
export declare const DREAMING_KEYS: Array<keyof DreamingConfig>;
/** Minutes after local midnight for each end of a `HH:MM-HH:MM` window, or null when malformed. */
export declare function parseDreamWindow(window: string): {
start: number;
end: number;
} | null;
/** True when `date`'s local time of day falls inside the window (start inclusive, end exclusive). */
export declare function insideDreamWindow(window: string, date: Date): boolean;
export interface DreamingPatchResult {
patch: Partial<DreamingConfig>;
/** One sentence per refused key. */
errors: string[];
/** Keys that are not dreaming settings. */
unknown: string[];
}
/** Validate a user-supplied partial config. Values may be strings (CLI) or typed (MCP, JSON). */
export declare function parseDreamingPatch(raw: unknown): DreamingPatchResult;
/** The valid keys of a stored object; anything malformed is dropped so the level below shows through. */
export declare function normalizeDreamingLevel(raw: unknown): Partial<DreamingConfig>;
export declare function globalDreamingPath(phrenPath: string): string;
export declare function readGlobalDreaming(phrenPath: string): Partial<DreamingConfig>;
export declare function readProjectDreaming(phrenPath: string, project: string): Partial<DreamingConfig>;
/** The effective dreaming config: defaults, then the global file, then the project's override. */
export declare function getDreamingConfig(phrenPath: string, project?: string): DreamingConfig;
/**
* Write a validated patch globally or for one project. `null` for a key on a
* project removes that project's override so it inherits again.
*/
export declare function updateDreamingConfig(phrenPath: string, patch: Partial<DreamingConfig>, project?: string, clear?: Array<keyof DreamingConfig>): Partial<DreamingConfig>;