UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

47 lines • 1.9 kB
import { Container } from "@earendil-works/pi-tui"; import { buildNoticeBox } from "../../../notice/index.js"; export class RulesBanner extends Container { constructor(props, theme) { super(); this.props = props; this.theme = theme; } render(width) { return renderBannerLines(this.props, this.theme, width); } invalidate() { } } export function renderBannerLines(props, theme, width) { if (props.ruleCount === 0) { return buildNoticeBox({ title: "[pi-rules] No rules discovered", tone: "accent", why: "No rules were discovered.", }, { expanded: false }, theme).render(width); } const extra = (props.topRules ?? []).map((rule) => { const hasDiagnostic = props.diagnostics.some((diagnostic) => diagnostic.source === rule.path || diagnostic.source === rule.relativePath); const annotation = typeof rule.matchReason === "object" && rule.matchReason.kind === "glob" ? ` ${rule.matchReason.pattern}` : ""; return { text: ` ${hasDiagnostic ? "⚠" : "●"} ${rule.relativePath}${annotation}`, tone: hasDiagnostic ? "error" : "success", }; }); if (props.diagnostics.length > 0) { extra.push({ text: ` ⚠ ${props.diagnostics.length} warning(s)`, tone: "warning" }); } return buildNoticeBox({ title: `[pi-rules] ${props.ruleCount} active rules`, tone: "accent", why: `${props.ruleCount} active rules were discovered.`, extra, }, { expanded: false }, theme).render(width); } export function statusLineText(input, theme) { const base = `[pi-rules] ${input.ruleCount} active`; if (input.hasErrors) { return theme.fg("muted", `${base} · `) + theme.fg("error", "⚠ errors"); } return theme.fg("muted", base); } //# sourceMappingURL=rules-banner.js.map