mirror of
https://github.com/tiennm99/ccstatusline.git
synced 2026-09-02 04:19:47 +00:00
Lint fixes, version bump
This commit is contained in:
+1
-1
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
+23
-22
@@ -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;
|
||||
}
|
||||
@@ -52,4 +52,4 @@ export function isKnownWidgetType(type: string): boolean {
|
||||
return widgetRegistry.has(type)
|
||||
|| type === 'separator'
|
||||
|| type === 'flex-separator';
|
||||
}
|
||||
}
|
||||
@@ -28,4 +28,4 @@ export class ClaudeSessionIdWidget implements Widget {
|
||||
|
||||
supportsRawValue(): boolean { return true; }
|
||||
supportsColors(item: WidgetItem): boolean { return true; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user