mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-19 02:01:32 +00:00
Fix wrap-ansi test to use node:test instead of vitest
This commit is contained in:
parent
4a972fbe6c
commit
ee83284dcf
2 changed files with 58 additions and 62 deletions
|
|
@ -4983,9 +4983,9 @@ export const MODELS = {
|
||||||
contextWindow: 32768,
|
contextWindow: 32768,
|
||||||
maxTokens: 4096,
|
maxTokens: 4096,
|
||||||
} satisfies Model<"openai-completions">,
|
} satisfies Model<"openai-completions">,
|
||||||
"anthropic/claude-3.5-haiku-20241022": {
|
"anthropic/claude-3.5-haiku": {
|
||||||
id: "anthropic/claude-3.5-haiku-20241022",
|
id: "anthropic/claude-3.5-haiku",
|
||||||
name: "Anthropic: Claude 3.5 Haiku (2024-10-22)",
|
name: "Anthropic: Claude 3.5 Haiku",
|
||||||
api: "openai-completions",
|
api: "openai-completions",
|
||||||
provider: "openrouter",
|
provider: "openrouter",
|
||||||
baseUrl: "https://openrouter.ai/api/v1",
|
baseUrl: "https://openrouter.ai/api/v1",
|
||||||
|
|
@ -5000,9 +5000,9 @@ export const MODELS = {
|
||||||
contextWindow: 200000,
|
contextWindow: 200000,
|
||||||
maxTokens: 8192,
|
maxTokens: 8192,
|
||||||
} satisfies Model<"openai-completions">,
|
} satisfies Model<"openai-completions">,
|
||||||
"anthropic/claude-3.5-haiku": {
|
"anthropic/claude-3.5-haiku-20241022": {
|
||||||
id: "anthropic/claude-3.5-haiku",
|
id: "anthropic/claude-3.5-haiku-20241022",
|
||||||
name: "Anthropic: Claude 3.5 Haiku",
|
name: "Anthropic: Claude 3.5 Haiku (2024-10-22)",
|
||||||
api: "openai-completions",
|
api: "openai-completions",
|
||||||
provider: "openrouter",
|
provider: "openrouter",
|
||||||
baseUrl: "https://openrouter.ai/api/v1",
|
baseUrl: "https://openrouter.ai/api/v1",
|
||||||
|
|
@ -5153,23 +5153,6 @@ export const MODELS = {
|
||||||
contextWindow: 32768,
|
contextWindow: 32768,
|
||||||
maxTokens: 4096,
|
maxTokens: 4096,
|
||||||
} satisfies Model<"openai-completions">,
|
} satisfies Model<"openai-completions">,
|
||||||
"cohere/command-r-08-2024": {
|
|
||||||
id: "cohere/command-r-08-2024",
|
|
||||||
name: "Cohere: Command R (08-2024)",
|
|
||||||
api: "openai-completions",
|
|
||||||
provider: "openrouter",
|
|
||||||
baseUrl: "https://openrouter.ai/api/v1",
|
|
||||||
reasoning: false,
|
|
||||||
input: ["text"],
|
|
||||||
cost: {
|
|
||||||
input: 0.15,
|
|
||||||
output: 0.6,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
},
|
|
||||||
contextWindow: 128000,
|
|
||||||
maxTokens: 4000,
|
|
||||||
} satisfies Model<"openai-completions">,
|
|
||||||
"cohere/command-r-plus-08-2024": {
|
"cohere/command-r-plus-08-2024": {
|
||||||
id: "cohere/command-r-plus-08-2024",
|
id: "cohere/command-r-plus-08-2024",
|
||||||
name: "Cohere: Command R+ (08-2024)",
|
name: "Cohere: Command R+ (08-2024)",
|
||||||
|
|
@ -5187,6 +5170,23 @@ export const MODELS = {
|
||||||
contextWindow: 128000,
|
contextWindow: 128000,
|
||||||
maxTokens: 4000,
|
maxTokens: 4000,
|
||||||
} satisfies Model<"openai-completions">,
|
} satisfies Model<"openai-completions">,
|
||||||
|
"cohere/command-r-08-2024": {
|
||||||
|
id: "cohere/command-r-08-2024",
|
||||||
|
name: "Cohere: Command R (08-2024)",
|
||||||
|
api: "openai-completions",
|
||||||
|
provider: "openrouter",
|
||||||
|
baseUrl: "https://openrouter.ai/api/v1",
|
||||||
|
reasoning: false,
|
||||||
|
input: ["text"],
|
||||||
|
cost: {
|
||||||
|
input: 0.15,
|
||||||
|
output: 0.6,
|
||||||
|
cacheRead: 0,
|
||||||
|
cacheWrite: 0,
|
||||||
|
},
|
||||||
|
contextWindow: 128000,
|
||||||
|
maxTokens: 4000,
|
||||||
|
} satisfies Model<"openai-completions">,
|
||||||
"sao10k/l3.1-euryale-70b": {
|
"sao10k/l3.1-euryale-70b": {
|
||||||
id: "sao10k/l3.1-euryale-70b",
|
id: "sao10k/l3.1-euryale-70b",
|
||||||
name: "Sao10K: Llama 3.1 Euryale 70B v2.2",
|
name: "Sao10K: Llama 3.1 Euryale 70B v2.2",
|
||||||
|
|
@ -5238,23 +5238,6 @@ export const MODELS = {
|
||||||
contextWindow: 128000,
|
contextWindow: 128000,
|
||||||
maxTokens: 16384,
|
maxTokens: 16384,
|
||||||
} satisfies Model<"openai-completions">,
|
} satisfies Model<"openai-completions">,
|
||||||
"meta-llama/llama-3.1-8b-instruct": {
|
|
||||||
id: "meta-llama/llama-3.1-8b-instruct",
|
|
||||||
name: "Meta: Llama 3.1 8B Instruct",
|
|
||||||
api: "openai-completions",
|
|
||||||
provider: "openrouter",
|
|
||||||
baseUrl: "https://openrouter.ai/api/v1",
|
|
||||||
reasoning: false,
|
|
||||||
input: ["text"],
|
|
||||||
cost: {
|
|
||||||
input: 0.02,
|
|
||||||
output: 0.03,
|
|
||||||
cacheRead: 0,
|
|
||||||
cacheWrite: 0,
|
|
||||||
},
|
|
||||||
contextWindow: 131072,
|
|
||||||
maxTokens: 16384,
|
|
||||||
} satisfies Model<"openai-completions">,
|
|
||||||
"meta-llama/llama-3.1-405b-instruct": {
|
"meta-llama/llama-3.1-405b-instruct": {
|
||||||
id: "meta-llama/llama-3.1-405b-instruct",
|
id: "meta-llama/llama-3.1-405b-instruct",
|
||||||
name: "Meta: Llama 3.1 405B Instruct",
|
name: "Meta: Llama 3.1 405B Instruct",
|
||||||
|
|
@ -5272,6 +5255,23 @@ export const MODELS = {
|
||||||
contextWindow: 130815,
|
contextWindow: 130815,
|
||||||
maxTokens: 4096,
|
maxTokens: 4096,
|
||||||
} satisfies Model<"openai-completions">,
|
} satisfies Model<"openai-completions">,
|
||||||
|
"meta-llama/llama-3.1-8b-instruct": {
|
||||||
|
id: "meta-llama/llama-3.1-8b-instruct",
|
||||||
|
name: "Meta: Llama 3.1 8B Instruct",
|
||||||
|
api: "openai-completions",
|
||||||
|
provider: "openrouter",
|
||||||
|
baseUrl: "https://openrouter.ai/api/v1",
|
||||||
|
reasoning: false,
|
||||||
|
input: ["text"],
|
||||||
|
cost: {
|
||||||
|
input: 0.02,
|
||||||
|
output: 0.03,
|
||||||
|
cacheRead: 0,
|
||||||
|
cacheWrite: 0,
|
||||||
|
},
|
||||||
|
contextWindow: 131072,
|
||||||
|
maxTokens: 16384,
|
||||||
|
} satisfies Model<"openai-completions">,
|
||||||
"meta-llama/llama-3.1-70b-instruct": {
|
"meta-llama/llama-3.1-70b-instruct": {
|
||||||
id: "meta-llama/llama-3.1-70b-instruct",
|
id: "meta-llama/llama-3.1-70b-instruct",
|
||||||
name: "Meta: Llama 3.1 70B Instruct",
|
name: "Meta: Llama 3.1 70B Instruct",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { describe, expect, it } from "vitest";
|
import assert from "node:assert";
|
||||||
|
import { describe, it } from "node:test";
|
||||||
import { visibleWidth, wrapTextWithAnsi } from "../src/utils.js";
|
import { visibleWidth, wrapTextWithAnsi } from "../src/utils.js";
|
||||||
|
|
||||||
describe("wrapTextWithAnsi", () => {
|
describe("wrapTextWithAnsi", () => {
|
||||||
|
|
@ -12,11 +13,11 @@ describe("wrapTextWithAnsi", () => {
|
||||||
const wrapped = wrapTextWithAnsi(text, 40);
|
const wrapped = wrapTextWithAnsi(text, 40);
|
||||||
|
|
||||||
// First line should NOT contain underline code - it's just "read this thread "
|
// First line should NOT contain underline code - it's just "read this thread "
|
||||||
expect(wrapped[0]).toBe("read this thread ");
|
assert.strictEqual(wrapped[0], "read this thread ");
|
||||||
|
|
||||||
// Second line should start with underline, have URL content
|
// Second line should start with underline, have URL content
|
||||||
expect(wrapped[1].startsWith(underlineOn)).toBe(true);
|
assert.strictEqual(wrapped[1].startsWith(underlineOn), true);
|
||||||
expect(wrapped[1]).toContain("https://");
|
assert.ok(wrapped[1].includes("https://"));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not bleed underline to padding - each line should end with reset for underline only", () => {
|
it("should not bleed underline to padding - each line should end with reset for underline only", () => {
|
||||||
|
|
@ -33,8 +34,8 @@ describe("wrapTextWithAnsi", () => {
|
||||||
const line = wrapped[i];
|
const line = wrapped[i];
|
||||||
if (line.includes(underlineOn)) {
|
if (line.includes(underlineOn)) {
|
||||||
// Should end with underline off, NOT full reset
|
// Should end with underline off, NOT full reset
|
||||||
expect(line.endsWith(underlineOff)).toBe(true);
|
assert.strictEqual(line.endsWith(underlineOff), true);
|
||||||
expect(line.endsWith("\x1b[0m")).toBe(false);
|
assert.strictEqual(line.endsWith("\x1b[0m"), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -50,12 +51,12 @@ describe("wrapTextWithAnsi", () => {
|
||||||
|
|
||||||
// Each line should have background color
|
// Each line should have background color
|
||||||
for (const line of wrapped) {
|
for (const line of wrapped) {
|
||||||
expect(line.includes(bgBlue)).toBe(true);
|
assert.ok(line.includes(bgBlue));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Middle lines should NOT end with full reset (kills background for padding)
|
// Middle lines should NOT end with full reset (kills background for padding)
|
||||||
for (let i = 0; i < wrapped.length - 1; i++) {
|
for (let i = 0; i < wrapped.length - 1; i++) {
|
||||||
expect(wrapped[i].endsWith("\x1b[0m")).toBe(false);
|
assert.strictEqual(wrapped[i].endsWith("\x1b[0m"), false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -68,15 +69,10 @@ describe("wrapTextWithAnsi", () => {
|
||||||
|
|
||||||
const wrapped = wrapTextWithAnsi(text, 20);
|
const wrapped = wrapTextWithAnsi(text, 20);
|
||||||
|
|
||||||
console.log("Wrapped lines:");
|
|
||||||
for (let i = 0; i < wrapped.length; i++) {
|
|
||||||
console.log(` [${i}]: ${JSON.stringify(wrapped[i])}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// All lines should have background color 41 (either as \x1b[41m or combined like \x1b[4;41m)
|
// All lines should have background color 41 (either as \x1b[41m or combined like \x1b[4;41m)
|
||||||
for (const line of wrapped) {
|
for (const line of wrapped) {
|
||||||
const hasBgColor = line.includes("[41m") || line.includes(";41m") || line.includes("[41;");
|
const hasBgColor = line.includes("[41m") || line.includes(";41m") || line.includes("[41;");
|
||||||
expect(hasBgColor).toBe(true);
|
assert.ok(hasBgColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lines with underlined content should use underline-off at end, not full reset
|
// Lines with underlined content should use underline-off at end, not full reset
|
||||||
|
|
@ -87,8 +83,8 @@ describe("wrapTextWithAnsi", () => {
|
||||||
(line.includes("[4m") || line.includes("[4;") || line.includes(";4m")) &&
|
(line.includes("[4m") || line.includes("[4;") || line.includes(";4m")) &&
|
||||||
!line.includes(underlineOff)
|
!line.includes(underlineOff)
|
||||||
) {
|
) {
|
||||||
expect(line.endsWith(underlineOff)).toBe(true);
|
assert.strictEqual(line.endsWith(underlineOff), true);
|
||||||
expect(line.endsWith("\x1b[0m")).toBe(false);
|
assert.strictEqual(line.endsWith("\x1b[0m"), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -99,10 +95,10 @@ describe("wrapTextWithAnsi", () => {
|
||||||
const text = "hello world this is a test";
|
const text = "hello world this is a test";
|
||||||
const wrapped = wrapTextWithAnsi(text, 10);
|
const wrapped = wrapTextWithAnsi(text, 10);
|
||||||
|
|
||||||
expect(wrapped.length).toBeGreaterThan(1);
|
assert.ok(wrapped.length > 1);
|
||||||
wrapped.forEach((line) => {
|
for (const line of wrapped) {
|
||||||
expect(visibleWidth(line)).toBeLessThanOrEqual(10);
|
assert.ok(visibleWidth(line) <= 10);
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should preserve color codes across wraps", () => {
|
it("should preserve color codes across wraps", () => {
|
||||||
|
|
@ -114,12 +110,12 @@ describe("wrapTextWithAnsi", () => {
|
||||||
|
|
||||||
// Each continuation line should start with red code
|
// Each continuation line should start with red code
|
||||||
for (let i = 1; i < wrapped.length; i++) {
|
for (let i = 1; i < wrapped.length; i++) {
|
||||||
expect(wrapped[i].startsWith(red)).toBe(true);
|
assert.strictEqual(wrapped[i].startsWith(red), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Middle lines should not end with full reset
|
// Middle lines should not end with full reset
|
||||||
for (let i = 0; i < wrapped.length - 1; i++) {
|
for (let i = 0; i < wrapped.length - 1; i++) {
|
||||||
expect(wrapped[i].endsWith("\x1b[0m")).toBe(false);
|
assert.strictEqual(wrapped[i].endsWith("\x1b[0m"), false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue