Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

1021 B
Raw Blame
import type { OutputStyleSelectionEntry } from "./apply.ts";

interface LegacyOutputModeConfig {
  enabled?: boolean;
  intensity?: "lite" | "full" | "ultra";
}

interface ConfigSlice {
  outputStyles?: OutputStyleSelectionEntry[];
  cavemanOutputMode?: LegacyOutputModeConfig;
}

/**
 * Resolve the effective output-style selection (D-A5 back-compat).
 * Precedence: an explicit non-empty `outputStyles` wins; otherwise a stored
 * `cavemanOutputMode` (when enabled) maps to `[{ terse-prose, <intensity> }]`,
 * so existing installs keep the legacy instruction text below the marker line
 * until they opt into other styles.
 * Pure; never throws.
 */
export function resolveOutputStyleSelection(config: ConfigSlice): OutputStyleSelectionEntry[] {
  if (Array.isArray(config.outputStyles) && config.outputStyles.length > 0) {
    return config.outputStyles;
  }
  const legacy = config.cavemanOutputMode;
  if (legacy?.enabled) {
    return [{ id: "terse-prose", level: legacy.intensity ?? "full" }];
  }
  return [];
}