From 03d19692ab15fd87ef0f4796dc0f46b447a222cc Mon Sep 17 00:00:00 2001 From: Matthew Breedlove Date: Mon, 17 Nov 2025 16:58:03 -0500 Subject: [PATCH] Lint fixes, version bump --- package.json | 2 +- src/utils/__tests__/model-context.test.ts | 126 +++++++++++----------- src/utils/model-context.ts | 45 ++++---- src/utils/widgets.ts | 2 +- src/widgets/ClaudeSessionId.ts | 2 +- 5 files changed, 91 insertions(+), 86 deletions(-) diff --git a/package.json b/package.json index b36ad37..99408ff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ccstatusline", - "version": "2.0.22", + "version": "2.0.23", "description": "A customizable status line formatter for Claude Code CLI", "module": "src/ccstatusline.ts", "type": "module", diff --git a/src/utils/__tests__/model-context.test.ts b/src/utils/__tests__/model-context.test.ts index 30bb923..7d25099 100644 --- a/src/utils/__tests__/model-context.test.ts +++ b/src/utils/__tests__/model-context.test.ts @@ -1,71 +1,75 @@ -import { describe, expect, it } from "vitest"; +import { + describe, + expect, + it +} from 'vitest'; -import { getContextConfig } from "../model-context"; +import { getContextConfig } from '../model-context'; -describe("getContextConfig", () => { - describe("Sonnet 4.5 models with [1m] suffix", () => { - it("should return 1M context window for claude-sonnet-4-5 with [1m] suffix", () => { - const config = getContextConfig("claude-sonnet-4-5-20250929[1m]"); +describe('getContextConfig', () => { + describe('Sonnet 4.5 models with [1m] suffix', () => { + it('should return 1M context window for claude-sonnet-4-5 with [1m] suffix', () => { + const config = getContextConfig('claude-sonnet-4-5-20250929[1m]'); - expect(config.maxTokens).toBe(1000000); - expect(config.usableTokens).toBe(800000); + expect(config.maxTokens).toBe(1000000); + expect(config.usableTokens).toBe(800000); + }); + + it('should return 1M context window for AWS Bedrock format with [1m] suffix', () => { + const config = getContextConfig( + 'us.anthropic.claude-sonnet-4-5-20250929-v1:0[1m]' + ); + + expect(config.maxTokens).toBe(1000000); + expect(config.usableTokens).toBe(800000); + }); + + it('should return 1M context window with uppercase [1M] suffix', () => { + const config = getContextConfig('claude-sonnet-4-5-20250929[1M]'); + + expect(config.maxTokens).toBe(1000000); + expect(config.usableTokens).toBe(800000); + }); }); - it("should return 1M context window for AWS Bedrock format with [1m] suffix", () => { - const config = getContextConfig( - "us.anthropic.claude-sonnet-4-5-20250929-v1:0[1m]" - ); + describe('Sonnet 4.5 models without [1m] suffix', () => { + it('should return 200k context window for claude-sonnet-4-5 without [1m] suffix', () => { + const config = getContextConfig('claude-sonnet-4-5-20250929'); - expect(config.maxTokens).toBe(1000000); - expect(config.usableTokens).toBe(800000); + expect(config.maxTokens).toBe(200000); + expect(config.usableTokens).toBe(160000); + }); + + it('should return 200k context window for AWS Bedrock format without [1m] suffix', () => { + const config = getContextConfig( + 'us.anthropic.claude-sonnet-4-5-20250929-v1:0' + ); + + expect(config.maxTokens).toBe(200000); + expect(config.usableTokens).toBe(160000); + }); }); - it("should return 1M context window with uppercase [1M] suffix", () => { - const config = getContextConfig("claude-sonnet-4-5-20250929[1M]"); + describe('Older/default models', () => { + it('should return 200k context window for older Sonnet 3.5 model', () => { + const config = getContextConfig('claude-3-5-sonnet-20241022'); - expect(config.maxTokens).toBe(1000000); - expect(config.usableTokens).toBe(800000); + expect(config.maxTokens).toBe(200000); + expect(config.usableTokens).toBe(160000); + }); + + it('should return 200k context window when model ID is undefined', () => { + const config = getContextConfig(undefined); + + expect(config.maxTokens).toBe(200000); + expect(config.usableTokens).toBe(160000); + }); + + it('should return 200k context window for unknown model ID', () => { + const config = getContextConfig('claude-unknown-model'); + + expect(config.maxTokens).toBe(200000); + expect(config.usableTokens).toBe(160000); + }); }); - }); - - describe("Sonnet 4.5 models without [1m] suffix", () => { - it("should return 200k context window for claude-sonnet-4-5 without [1m] suffix", () => { - const config = getContextConfig("claude-sonnet-4-5-20250929"); - - expect(config.maxTokens).toBe(200000); - expect(config.usableTokens).toBe(160000); - }); - - it("should return 200k context window for AWS Bedrock format without [1m] suffix", () => { - const config = getContextConfig( - "us.anthropic.claude-sonnet-4-5-20250929-v1:0" - ); - - expect(config.maxTokens).toBe(200000); - expect(config.usableTokens).toBe(160000); - }); - }); - - describe("Older/default models", () => { - it("should return 200k context window for older Sonnet 3.5 model", () => { - const config = getContextConfig("claude-3-5-sonnet-20241022"); - - expect(config.maxTokens).toBe(200000); - expect(config.usableTokens).toBe(160000); - }); - - it("should return 200k context window when model ID is undefined", () => { - const config = getContextConfig(undefined); - - expect(config.maxTokens).toBe(200000); - expect(config.usableTokens).toBe(160000); - }); - - it("should return 200k context window for unknown model ID", () => { - const config = getContextConfig("claude-unknown-model"); - - expect(config.maxTokens).toBe(200000); - expect(config.usableTokens).toBe(160000); - }); - }); -}); +}); \ No newline at end of file diff --git a/src/utils/model-context.ts b/src/utils/model-context.ts index 186a7c0..a1efb20 100644 --- a/src/utils/model-context.ts +++ b/src/utils/model-context.ts @@ -1,29 +1,30 @@ interface ModelContextConfig { - maxTokens: number; - usableTokens: number; + maxTokens: number; + usableTokens: number; } export function getContextConfig(modelId?: string): ModelContextConfig { - // Default to 200k for older models - const defaultConfig = { - maxTokens: 200000, - usableTokens: 160000, - }; - - if (!modelId) return defaultConfig; - - // Sonnet 4.5 variants with 1M context (requires [1m] suffix for long context beta) - if ( - modelId.includes("claude-sonnet-4-5") && - modelId.toLowerCase().includes("[1m]") - ) { - return { - maxTokens: 1000000, - usableTokens: 800000, // 80% of 1M + // Default to 200k for older models + const defaultConfig = { + maxTokens: 200000, + usableTokens: 160000 }; - } - // Add future models here as needed + if (!modelId) + return defaultConfig; - return defaultConfig; -} + // Sonnet 4.5 variants with 1M context (requires [1m] suffix for long context beta) + if ( + modelId.includes('claude-sonnet-4-5') + && modelId.toLowerCase().includes('[1m]') + ) { + return { + maxTokens: 1000000, + usableTokens: 800000 // 80% of 1M + }; + } + + // Add future models here as needed + + return defaultConfig; +} \ No newline at end of file diff --git a/src/utils/widgets.ts b/src/utils/widgets.ts index fc98f47..15a2510 100644 --- a/src/utils/widgets.ts +++ b/src/utils/widgets.ts @@ -52,4 +52,4 @@ export function isKnownWidgetType(type: string): boolean { return widgetRegistry.has(type) || type === 'separator' || type === 'flex-separator'; -} +} \ No newline at end of file diff --git a/src/widgets/ClaudeSessionId.ts b/src/widgets/ClaudeSessionId.ts index 193201f..a94bebd 100644 --- a/src/widgets/ClaudeSessionId.ts +++ b/src/widgets/ClaudeSessionId.ts @@ -28,4 +28,4 @@ export class ClaudeSessionIdWidget implements Widget { supportsRawValue(): boolean { return true; } supportsColors(item: WidgetItem): boolean { return true; } -} +} \ No newline at end of file