mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 06:15:51 +00:00
style: 完成所有文件的lint
This commit is contained in:
@@ -1,70 +1,70 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { isModelAlias, isModelFamilyAlias } from "../aliases";
|
||||
import { describe, expect, test } from 'bun:test'
|
||||
import { isModelAlias, isModelFamilyAlias } from '../aliases'
|
||||
|
||||
describe("isModelAlias", () => {
|
||||
describe('isModelAlias', () => {
|
||||
test('returns true for "sonnet"', () => {
|
||||
expect(isModelAlias("sonnet")).toBe(true);
|
||||
});
|
||||
expect(isModelAlias('sonnet')).toBe(true)
|
||||
})
|
||||
|
||||
test('returns true for "opus"', () => {
|
||||
expect(isModelAlias("opus")).toBe(true);
|
||||
});
|
||||
expect(isModelAlias('opus')).toBe(true)
|
||||
})
|
||||
|
||||
test('returns true for "haiku"', () => {
|
||||
expect(isModelAlias("haiku")).toBe(true);
|
||||
});
|
||||
expect(isModelAlias('haiku')).toBe(true)
|
||||
})
|
||||
|
||||
test('returns true for "best"', () => {
|
||||
expect(isModelAlias("best")).toBe(true);
|
||||
});
|
||||
expect(isModelAlias('best')).toBe(true)
|
||||
})
|
||||
|
||||
test('returns true for "sonnet[1m]"', () => {
|
||||
expect(isModelAlias("sonnet[1m]")).toBe(true);
|
||||
});
|
||||
expect(isModelAlias('sonnet[1m]')).toBe(true)
|
||||
})
|
||||
|
||||
test('returns true for "opus[1m]"', () => {
|
||||
expect(isModelAlias("opus[1m]")).toBe(true);
|
||||
});
|
||||
expect(isModelAlias('opus[1m]')).toBe(true)
|
||||
})
|
||||
|
||||
test('returns true for "opusplan"', () => {
|
||||
expect(isModelAlias("opusplan")).toBe(true);
|
||||
});
|
||||
expect(isModelAlias('opusplan')).toBe(true)
|
||||
})
|
||||
|
||||
test("returns false for full model ID", () => {
|
||||
expect(isModelAlias("claude-sonnet-4-6-20250514")).toBe(false);
|
||||
});
|
||||
test('returns false for full model ID', () => {
|
||||
expect(isModelAlias('claude-sonnet-4-6-20250514')).toBe(false)
|
||||
})
|
||||
|
||||
test("returns false for unknown string", () => {
|
||||
expect(isModelAlias("gpt-4")).toBe(false);
|
||||
});
|
||||
test('returns false for unknown string', () => {
|
||||
expect(isModelAlias('gpt-4')).toBe(false)
|
||||
})
|
||||
|
||||
test("is case-sensitive", () => {
|
||||
expect(isModelAlias("Sonnet")).toBe(false);
|
||||
});
|
||||
});
|
||||
test('is case-sensitive', () => {
|
||||
expect(isModelAlias('Sonnet')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe("isModelFamilyAlias", () => {
|
||||
describe('isModelFamilyAlias', () => {
|
||||
test('returns true for "sonnet"', () => {
|
||||
expect(isModelFamilyAlias("sonnet")).toBe(true);
|
||||
});
|
||||
expect(isModelFamilyAlias('sonnet')).toBe(true)
|
||||
})
|
||||
|
||||
test('returns true for "opus"', () => {
|
||||
expect(isModelFamilyAlias("opus")).toBe(true);
|
||||
});
|
||||
expect(isModelFamilyAlias('opus')).toBe(true)
|
||||
})
|
||||
|
||||
test('returns true for "haiku"', () => {
|
||||
expect(isModelFamilyAlias("haiku")).toBe(true);
|
||||
});
|
||||
expect(isModelFamilyAlias('haiku')).toBe(true)
|
||||
})
|
||||
|
||||
test('returns false for "best"', () => {
|
||||
expect(isModelFamilyAlias("best")).toBe(false);
|
||||
});
|
||||
expect(isModelFamilyAlias('best')).toBe(false)
|
||||
})
|
||||
|
||||
test('returns false for "opusplan"', () => {
|
||||
expect(isModelFamilyAlias("opusplan")).toBe(false);
|
||||
});
|
||||
expect(isModelFamilyAlias('opusplan')).toBe(false)
|
||||
})
|
||||
|
||||
test('returns false for "sonnet[1m]"', () => {
|
||||
expect(isModelFamilyAlias("sonnet[1m]")).toBe(false);
|
||||
});
|
||||
});
|
||||
expect(isModelFamilyAlias('sonnet[1m]')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,92 +1,92 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { firstPartyNameToCanonical } from "../model";
|
||||
import { describe, expect, test } from 'bun:test'
|
||||
import { firstPartyNameToCanonical } from '../model'
|
||||
|
||||
describe("firstPartyNameToCanonical", () => {
|
||||
test("maps opus-4-6 full name to canonical", () => {
|
||||
expect(firstPartyNameToCanonical("claude-opus-4-6-20250514")).toBe(
|
||||
"claude-opus-4-6"
|
||||
);
|
||||
});
|
||||
describe('firstPartyNameToCanonical', () => {
|
||||
test('maps opus-4-6 full name to canonical', () => {
|
||||
expect(firstPartyNameToCanonical('claude-opus-4-6-20250514')).toBe(
|
||||
'claude-opus-4-6',
|
||||
)
|
||||
})
|
||||
|
||||
test("maps sonnet-4-6 full name", () => {
|
||||
expect(firstPartyNameToCanonical("claude-sonnet-4-6-20250514")).toBe(
|
||||
"claude-sonnet-4-6"
|
||||
);
|
||||
});
|
||||
test('maps sonnet-4-6 full name', () => {
|
||||
expect(firstPartyNameToCanonical('claude-sonnet-4-6-20250514')).toBe(
|
||||
'claude-sonnet-4-6',
|
||||
)
|
||||
})
|
||||
|
||||
test("maps haiku-4-5", () => {
|
||||
expect(firstPartyNameToCanonical("claude-haiku-4-5-20251001")).toBe(
|
||||
"claude-haiku-4-5"
|
||||
);
|
||||
});
|
||||
test('maps haiku-4-5', () => {
|
||||
expect(firstPartyNameToCanonical('claude-haiku-4-5-20251001')).toBe(
|
||||
'claude-haiku-4-5',
|
||||
)
|
||||
})
|
||||
|
||||
test("maps 3P provider format", () => {
|
||||
expect(
|
||||
firstPartyNameToCanonical("us.anthropic.claude-opus-4-6-v1:0")
|
||||
).toBe("claude-opus-4-6");
|
||||
});
|
||||
test('maps 3P provider format', () => {
|
||||
expect(firstPartyNameToCanonical('us.anthropic.claude-opus-4-6-v1:0')).toBe(
|
||||
'claude-opus-4-6',
|
||||
)
|
||||
})
|
||||
|
||||
test("maps claude-3-7-sonnet", () => {
|
||||
expect(firstPartyNameToCanonical("claude-3-7-sonnet-20250219")).toBe(
|
||||
"claude-3-7-sonnet"
|
||||
);
|
||||
});
|
||||
test('maps claude-3-7-sonnet', () => {
|
||||
expect(firstPartyNameToCanonical('claude-3-7-sonnet-20250219')).toBe(
|
||||
'claude-3-7-sonnet',
|
||||
)
|
||||
})
|
||||
|
||||
test("maps claude-3-5-sonnet", () => {
|
||||
expect(firstPartyNameToCanonical("claude-3-5-sonnet-20241022")).toBe(
|
||||
"claude-3-5-sonnet"
|
||||
);
|
||||
});
|
||||
test('maps claude-3-5-sonnet', () => {
|
||||
expect(firstPartyNameToCanonical('claude-3-5-sonnet-20241022')).toBe(
|
||||
'claude-3-5-sonnet',
|
||||
)
|
||||
})
|
||||
|
||||
test("maps claude-3-5-haiku", () => {
|
||||
expect(firstPartyNameToCanonical("claude-3-5-haiku-20241022")).toBe(
|
||||
"claude-3-5-haiku"
|
||||
);
|
||||
});
|
||||
test('maps claude-3-5-haiku', () => {
|
||||
expect(firstPartyNameToCanonical('claude-3-5-haiku-20241022')).toBe(
|
||||
'claude-3-5-haiku',
|
||||
)
|
||||
})
|
||||
|
||||
test("maps claude-3-opus", () => {
|
||||
expect(firstPartyNameToCanonical("claude-3-opus-20240229")).toBe(
|
||||
"claude-3-opus"
|
||||
);
|
||||
});
|
||||
test('maps claude-3-opus', () => {
|
||||
expect(firstPartyNameToCanonical('claude-3-opus-20240229')).toBe(
|
||||
'claude-3-opus',
|
||||
)
|
||||
})
|
||||
|
||||
test("is case insensitive", () => {
|
||||
expect(firstPartyNameToCanonical("Claude-Opus-4-6-20250514")).toBe(
|
||||
"claude-opus-4-6"
|
||||
);
|
||||
});
|
||||
test('is case insensitive', () => {
|
||||
expect(firstPartyNameToCanonical('Claude-Opus-4-6-20250514')).toBe(
|
||||
'claude-opus-4-6',
|
||||
)
|
||||
})
|
||||
|
||||
test("falls back to input for unknown model", () => {
|
||||
expect(firstPartyNameToCanonical("unknown-model")).toBe("unknown-model");
|
||||
});
|
||||
test('falls back to input for unknown model', () => {
|
||||
expect(firstPartyNameToCanonical('unknown-model')).toBe('unknown-model')
|
||||
})
|
||||
|
||||
test("differentiates opus-4 vs opus-4-5 vs opus-4-6", () => {
|
||||
expect(firstPartyNameToCanonical("claude-opus-4-20240101")).toBe(
|
||||
"claude-opus-4"
|
||||
);
|
||||
expect(firstPartyNameToCanonical("claude-opus-4-5-20240101")).toBe(
|
||||
"claude-opus-4-5"
|
||||
);
|
||||
expect(firstPartyNameToCanonical("claude-opus-4-6-20240101")).toBe(
|
||||
"claude-opus-4-6"
|
||||
);
|
||||
});
|
||||
test('differentiates opus-4 vs opus-4-5 vs opus-4-6', () => {
|
||||
expect(firstPartyNameToCanonical('claude-opus-4-20240101')).toBe(
|
||||
'claude-opus-4',
|
||||
)
|
||||
expect(firstPartyNameToCanonical('claude-opus-4-5-20240101')).toBe(
|
||||
'claude-opus-4-5',
|
||||
)
|
||||
expect(firstPartyNameToCanonical('claude-opus-4-6-20240101')).toBe(
|
||||
'claude-opus-4-6',
|
||||
)
|
||||
})
|
||||
|
||||
test("maps opus-4-1", () => {
|
||||
expect(firstPartyNameToCanonical("claude-opus-4-1-20240101")).toBe(
|
||||
"claude-opus-4-1"
|
||||
);
|
||||
});
|
||||
test('maps opus-4-1', () => {
|
||||
expect(firstPartyNameToCanonical('claude-opus-4-1-20240101')).toBe(
|
||||
'claude-opus-4-1',
|
||||
)
|
||||
})
|
||||
|
||||
test("maps sonnet-4-5", () => {
|
||||
expect(firstPartyNameToCanonical("claude-sonnet-4-5-20240101")).toBe(
|
||||
"claude-sonnet-4-5"
|
||||
);
|
||||
});
|
||||
test('maps sonnet-4-5', () => {
|
||||
expect(firstPartyNameToCanonical('claude-sonnet-4-5-20240101')).toBe(
|
||||
'claude-sonnet-4-5',
|
||||
)
|
||||
})
|
||||
|
||||
test("maps sonnet-4", () => {
|
||||
expect(firstPartyNameToCanonical("claude-sonnet-4-20240101")).toBe(
|
||||
"claude-sonnet-4"
|
||||
);
|
||||
});
|
||||
});
|
||||
test('maps sonnet-4', () => {
|
||||
expect(firstPartyNameToCanonical('claude-sonnet-4-20240101')).toBe(
|
||||
'claude-sonnet-4',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -141,10 +141,7 @@ export function getDefaultOpusModel(): ModelName {
|
||||
export function getDefaultSonnetModel(): ModelName {
|
||||
const provider = getAPIProvider()
|
||||
// For OpenAI provider, check OPENAI_DEFAULT_SONNET_MODEL first
|
||||
if (
|
||||
provider === 'openai' &&
|
||||
process.env.OPENAI_DEFAULT_SONNET_MODEL
|
||||
) {
|
||||
if (provider === 'openai' && process.env.OPENAI_DEFAULT_SONNET_MODEL) {
|
||||
return process.env.OPENAI_DEFAULT_SONNET_MODEL
|
||||
}
|
||||
// For Gemini provider, check GEMINI_DEFAULT_SONNET_MODEL
|
||||
|
||||
@@ -51,7 +51,6 @@ export async function validateModel(
|
||||
return { valid: true }
|
||||
}
|
||||
|
||||
|
||||
// Try to make an actual API call with minimal parameters
|
||||
try {
|
||||
await sideQuery({
|
||||
|
||||
Reference in New Issue
Block a user