- collector, classify, prompt-parser, server (TypeScript) - web panel (app.js, index.html, style.css) - smoke and load-test scripts - DESIGN.md and README.md
65 lines
2.8 KiB
TypeScript
65 lines
2.8 KiB
TypeScript
/**
|
|
* classify.ts — the single source of truth for context kinds and their colors.
|
|
* Color is data, never decoration: every hue maps to exactly one context type.
|
|
*/
|
|
import type { ContextKind } from "./types.ts";
|
|
|
|
export interface KindStyle {
|
|
label: string;
|
|
/** Dark theme foreground (panels sit on #16181D). */
|
|
color: string;
|
|
/** Light theme foreground. */
|
|
lightColor: string;
|
|
/** Shape hint for color-blind mode: filled bar, dotted bar, hatched bar... */
|
|
pattern: "solid" | "dashed" | "dotted" | "hatched";
|
|
}
|
|
|
|
export const KIND_STYLES: Record<ContextKind, KindStyle> = {
|
|
preamble: { label: "base instructions", color: "#4A9EFF", lightColor: "#1565C0", pattern: "solid" },
|
|
"tool-rules": { label: "tool rules", color: "#B388FF", lightColor: "#6A3FC0", pattern: "solid" },
|
|
docs: { label: "pi docs", color: "#7E8AA2", lightColor: "#5A6577", pattern: "dotted" },
|
|
"context-file": { label: "context file", color: "#3DDC84", lightColor: "#1B7A47", pattern: "solid" },
|
|
"skill-list": { label: "skill list", color: "#FFD54F", lightColor: "#9A7400", pattern: "dotted" },
|
|
"skill-loaded": { label: "skill loaded", color: "#FF9800", lightColor: "#B25E00", pattern: "hatched" },
|
|
"user-append": { label: "user append", color: "#FF7AB2", lightColor: "#B03060", pattern: "dashed" },
|
|
"custom-section": { label: "custom section", color: "#5CE1D9", lightColor: "#00796B", pattern: "dashed" },
|
|
forced: { label: "forced / replaced", color: "#FF5C5C", lightColor: "#C62828", pattern: "hatched" },
|
|
compaction: { label: "compaction", color: "#9E9E9E", lightColor: "#616161", pattern: "dotted" },
|
|
user: { label: "user", color: "#D7DCE2", lightColor: "#37474F", pattern: "solid" },
|
|
assistant: { label: "assistant", color: "#9DB4D0", lightColor: "#33566E", pattern: "solid" },
|
|
tool: { label: "tool", color: "#6B7480", lightColor: "#455A64", pattern: "solid" },
|
|
other: { label: "other", color: "#55606D", lightColor: "#607D8B", pattern: "solid" },
|
|
};
|
|
|
|
export function kindColor(kind: ContextKind, appearance: "dark" | "light" = "dark"): string {
|
|
const style = KIND_STYLES[kind] ?? KIND_STYLES.other;
|
|
return appearance === "dark" ? style.color : style.lightColor;
|
|
}
|
|
|
|
export function kindLabel(kind: ContextKind): string {
|
|
return (KIND_STYLES[kind] ?? KIND_STYLES.other).label;
|
|
}
|
|
|
|
/** Map a pi system-prompt section tag to a context kind. */
|
|
export function sectionKind(tag: string): ContextKind {
|
|
switch (tag) {
|
|
case "preamble":
|
|
return "preamble";
|
|
case "tools":
|
|
case "rules":
|
|
return "tool-rules";
|
|
case "docs":
|
|
return "docs";
|
|
case "addendum":
|
|
return "user-append";
|
|
case "project_context":
|
|
return "context-file";
|
|
case "skills":
|
|
return "skill-list";
|
|
case "cwd":
|
|
return "other";
|
|
default:
|
|
return "custom-section";
|
|
}
|
|
}
|