@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
40 lines • 1.35 kB
JavaScript
import { selectTip } from "./scheduler.js";
/**
* Per-turn cache for the working-status tip.
*
* The tip is chosen once per turn and must survive the working indicator being
* hidden and reshown mid-turn; `resetForNewTurn()` is called only at a real turn
* boundary (agent_start).
*/
export class WorkingTipCache {
resetForNewTurn() {
this.cached = undefined;
}
resolve(compute, onFirstResolve) {
if (this.cached !== undefined)
return this.cached.value;
const value = compute();
this.cached = { value };
if (value)
onFirstResolve?.(value);
return value;
}
}
export function resolveWorkingTipLine(options) {
if (!options.tipsEnabled)
return undefined;
const tip = selectTip(options.definitions, options.history, options.now, {
keys: options.keys,
...(options.hasCommand ? { hasCommand: options.hasCommand } : {}),
exclude: options.sessionShownTipIds,
});
if (!tip)
return undefined;
const body = tip
.render(options.keys)
.replace(/\s*\n\s*/g, " ")
.trim();
const pointer = "↳ Want the full story on any tip? Ask about it: the give-me-tips skill has the tour.";
return { line: `Tip: ${body}\n${pointer}`, tipId: tip.id };
}
//# sourceMappingURL=working-tip.js.map