{"version":3,"file":"caveman-command.d.ts","sourceRoot":"","sources":["../../src/core/caveman-command.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAC7D,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEpD,eAAO,MAAM,qBAAqB,iDAAiD,CAAC;AAEpF,MAAM,WAAW,oBAAoB;IACpC,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;CAC3C;AAID;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAiB3E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CA+BlF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,CAuC7F","sourcesContent":["export type CavemanLevel = \"off\" | \"lite\" | \"full\" | \"ultra\";\nexport type CavemanAction = CavemanLevel | \"status\";\n\nexport const CAVEMAN_COMMAND_USAGE = \"Usage: /caveman [lite|full|ultra|off|status]\";\n\nexport interface CavemanCommandTarget {\n\tcavemanLevel: CavemanLevel;\n\tsetCavemanLevel(level: CavemanLevel): void;\n}\n\nconst CAVEMAN_COMMAND_NAME = \"/caveman\";\n\n/**\n * Parse a caveman command from input text.\n * Returns the action or undefined if not a caveman command.\n *\n * Handles:\n * - `/caveman` alone → defaults to \"full\"\n * - `/caveman <level>` where level is lite|full|ultra|off|status\n * - Natural language phrases via parseCavemanNaturalLanguage\n */\nexport function parseCavemanCommand(text: string): CavemanAction | undefined {\n\tconst parts = text.trim().split(/\\s+/);\n\tif (parts[0]?.toLowerCase() !== CAVEMAN_COMMAND_NAME) {\n\t\treturn undefined;\n\t}\n\n\tconst action = parts[1]?.toLowerCase();\n\tif (action === \"lite\" || action === \"full\" || action === \"ultra\" || action === \"off\" || action === \"status\") {\n\t\treturn action;\n\t}\n\n\t// `/caveman` with no argument defaults to \"full\"\n\tif (parts.length === 1) {\n\t\treturn \"full\";\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Parse natural language phrases for caveman activation/deactivation.\n * Uses WORD-BOUNDARY matching to avoid false positives.\n *\n * Activation phrases (maps to \"full\"): \"caveman mode\", \"talk like caveman\", \"be brief\",\n * \"less tokens\", \"me caveman\", \"caveman style\", \"make it briefer\", \"shorter please\"\n *\n * Deactivation phrases (maps to \"off\"): \"normal mode\", \"stop caveman\"\n *\n * @returns \"full\" for activation, \"off\" for deactivation, undefined if no match\n */\nexport function parseCavemanNaturalLanguage(text: string): CavemanLevel | undefined {\n\tconst lowerText = text.toLowerCase();\n\n\t// Activation phrases - must match full phrase with word boundaries\n\tconst activationPhrases = [\n\t\t/\\bcaveman mode\\b/i,\n\t\t/\\btalk like caveman\\b/i,\n\t\t/\\bbe brief\\b/i,\n\t\t/\\bless tokens\\b/i,\n\t\t/\\bme caveman\\b/i,\n\t\t/\\bcaveman style\\b/i,\n\t\t/\\bmake it briefer\\b/i,\n\t\t/\\bshorter please\\b/i,\n\t];\n\n\tfor (const pattern of activationPhrases) {\n\t\tif (pattern.test(lowerText)) {\n\t\t\treturn \"full\";\n\t\t}\n\t}\n\n\t// Deactivation phrases - must match full phrase with word boundaries\n\tconst deactivationPhrases = [/\\bnormal mode\\b/i, /\\bstop caveman\\b/i];\n\n\tfor (const pattern of deactivationPhrases) {\n\t\tif (pattern.test(lowerText)) {\n\t\t\treturn \"off\";\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Run a caveman command on the target session.\n * Returns a status string describing the result.\n */\nexport function runCavemanCommand(target: CavemanCommandTarget, action: CavemanAction): string {\n\tif (action === \"status\") {\n\t\tconst level = target.cavemanLevel;\n\t\tif (level === \"off\") {\n\t\t\treturn \"Caveman compression is disabled for this session only (runtime-only). Normal assistant prose is active.\";\n\t\t}\n\t\tif (level === \"lite\") {\n\t\t\treturn \"Caveman Lite compression is active for this session only (runtime-only). Paragraph-level summaries.\";\n\t\t}\n\t\tif (level === \"full\") {\n\t\t\treturn \"Caveman Full compression is active for this session only (runtime-only). Sentence-level summaries.\";\n\t\t}\n\t\tif (level === \"ultra\") {\n\t\t\treturn \"Caveman Ultra compression is active for this session only (runtime-only). Keyword-level responses.\";\n\t\t}\n\t\treturn \"Unknown caveman level.\";\n\t}\n\n\tif (action === \"off\") {\n\t\ttarget.setCavemanLevel(\"off\");\n\t\treturn \"Disabled Caveman compression for this session only (runtime-only). Normal assistant prose is active.\";\n\t}\n\n\tif (action === \"lite\") {\n\t\ttarget.setCavemanLevel(\"lite\");\n\t\treturn \"Caveman Lite compression activated for this session only (runtime-only). Paragraph-level summaries.\";\n\t}\n\n\tif (action === \"full\") {\n\t\ttarget.setCavemanLevel(\"full\");\n\t\treturn \"Caveman Full compression activated for this session only (runtime-only). Sentence-level summaries.\";\n\t}\n\n\tif (action === \"ultra\") {\n\t\ttarget.setCavemanLevel(\"ultra\");\n\t\treturn \"Caveman Ultra compression activated for this session only (runtime-only). Keyword-level responses.\";\n\t}\n\n\treturn CAVEMAN_COMMAND_USAGE;\n}\n"]}