mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-04 02:17:49 +00:00
refactor(core): centralize claude paths and command parsing
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Shared extended context helpers used by CLI + UI.
|
||||
*/
|
||||
|
||||
/** Extended context suffix recognized by Claude Code. */
|
||||
export const EXTENDED_CONTEXT_SUFFIX = '[1m]';
|
||||
|
||||
/** Check if model is a native Gemini model (auto-enabled behavior). */
|
||||
export function isNativeGeminiModel(modelId: string): boolean {
|
||||
return modelId.toLowerCase().startsWith('gemini-');
|
||||
}
|
||||
|
||||
/** Check if model already has [1m] suffix. */
|
||||
export function hasExtendedContextSuffix(model: string): boolean {
|
||||
return model.toLowerCase().endsWith(EXTENDED_CONTEXT_SUFFIX.toLowerCase());
|
||||
}
|
||||
|
||||
/** Apply [1m] suffix to model if not already present. */
|
||||
export function applyExtendedContextSuffix(model: string): string {
|
||||
if (!model) return model;
|
||||
if (hasExtendedContextSuffix(model)) return model;
|
||||
return `${model}${EXTENDED_CONTEXT_SUFFIX}`;
|
||||
}
|
||||
|
||||
/** Strip [1m] suffix from model string. */
|
||||
export function stripExtendedContextSuffix(model: string): string {
|
||||
if (!model) return model;
|
||||
return hasExtendedContextSuffix(model) ? model.slice(0, -EXTENDED_CONTEXT_SUFFIX.length) : model;
|
||||
}
|
||||
Reference in New Issue
Block a user