@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
64 lines • 2.79 kB
TypeScript
/**
* Tick-prompt templates with cache-friendly sentinel expansion.
*
* `buildTickMessage` is pure: it reads no files, touches no clock, and mutates nothing.
* The caller resolves the loop file (see `loopfile.ts`) and hands the snapshot in; this
* module decides full-vs-reminder delivery, renders the tick text, and returns the
* updated sentinel delivery state to persist.
*
* Cache discipline: the long instruction blocks are delivered once (the "anchor") and
* later ticks send a short reminder that points back at that anchored message, so the
* cached message prefix stays stable across fires.
*/
import type { DeliveryId, LoopFileFingerprint, LoopId, LoopPayload, LoopSentinel, SentinelDeliveryState } from "./types.ts";
export type LoopMode = "fixed" | "dynamic";
/** `prompt` covers a verbatim user prompt; sentinels alternate between full and reminder. */
export type TickDelivery = "full" | "reminder" | "prompt";
/** Resolved loop-file state for this fire, produced by the caller's loop-file reader. */
export type LoopFileSnapshot = {
readonly present: false;
} | {
readonly present: true;
readonly path: string;
/** Model-visible (already truncated) representation. */
readonly content: string;
readonly mtimeMs: number;
readonly size: number;
/** SHA-256 of the model-visible representation. */
readonly contentHash: string;
};
export interface TickPromptInput {
readonly loopId: LoopId;
readonly deliveryId: DeliveryId;
readonly mode: LoopMode;
readonly payload: LoopPayload;
/** Canonical re-entry text, e.g. `/loop check the deploy` or `/loop`. */
readonly reentryPrompt: string;
readonly deliveryState: SentinelDeliveryState;
readonly loopFile: LoopFileSnapshot;
}
export interface LoopTickDetails {
readonly loopId: LoopId;
readonly deliveryId: DeliveryId;
readonly mode: LoopMode;
readonly delivery: TickDelivery;
readonly sentinel?: LoopSentinel;
readonly loopFile?: LoopFileFingerprint;
}
export interface TickPromptResult {
readonly text: string;
readonly delivery: TickDelivery;
readonly details: LoopTickDetails;
/** Delivery state to persist after this tick is dispatched. */
readonly deliveryState: SentinelDeliveryState;
}
/**
* Render one tick message plus the delivery state to persist afterwards.
*
* Full delivery happens on the first sentinel delivery, when `forceFullDelivery` is set
* (accepted compaction or a missing anchor on resume), when the loop file's fingerprint
* changed, or when the file reappeared after absence. Otherwise the tick is a short
* reminder anchored to the last full message.
*/
export declare function buildTickMessage(input: TickPromptInput): TickPromptResult;
//# sourceMappingURL=tick-prompt.d.ts.map