refactor(core): centralize claude paths and command parsing

This commit is contained in:
Tam Nhu Tran
2026-02-21 01:31:16 +07:00
parent 6a9abd2a48
commit 8d2ec86155
18 changed files with 395 additions and 486 deletions
+29
View File
@@ -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;
}