mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
style: 完成所有文件的lint
This commit is contained in:
@@ -1,101 +1,109 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { stripHtmlComments, isMemoryFilePath, getLargeMemoryFiles } from "../../src/utils/claudemd";
|
||||
import { buildEffectiveSystemPrompt } from "../../src/utils/systemPrompt";
|
||||
import { createTempDir, cleanupTempDir, writeTempFile } from "../mocks/file-system";
|
||||
import { describe, expect, test } from 'bun:test'
|
||||
import {
|
||||
stripHtmlComments,
|
||||
isMemoryFilePath,
|
||||
getLargeMemoryFiles,
|
||||
} from '../../src/utils/claudemd'
|
||||
import { buildEffectiveSystemPrompt } from '../../src/utils/systemPrompt'
|
||||
import {
|
||||
createTempDir,
|
||||
cleanupTempDir,
|
||||
writeTempFile,
|
||||
} from '../mocks/file-system'
|
||||
|
||||
// ─── CLAUDE.md Integration with System Prompt ─────────────────────────
|
||||
|
||||
describe("Context build: CLAUDE.md + system prompt integration", () => {
|
||||
test("buildEffectiveSystemPrompt passes through default prompt", () => {
|
||||
describe('Context build: CLAUDE.md + system prompt integration', () => {
|
||||
test('buildEffectiveSystemPrompt passes through default prompt', () => {
|
||||
const result = buildEffectiveSystemPrompt({
|
||||
defaultSystemPrompt: "You are Claude.",
|
||||
});
|
||||
defaultSystemPrompt: 'You are Claude.',
|
||||
})
|
||||
// Result is an array of strings (may be split differently)
|
||||
const joined = Array.from(result).join("");
|
||||
expect(joined).toBe("You are Claude.");
|
||||
});
|
||||
const joined = Array.from(result).join('')
|
||||
expect(joined).toBe('You are Claude.')
|
||||
})
|
||||
|
||||
test("buildEffectiveSystemPrompt handles empty prompts", () => {
|
||||
test('buildEffectiveSystemPrompt handles empty prompts', () => {
|
||||
const result = buildEffectiveSystemPrompt({
|
||||
defaultSystemPrompt: "",
|
||||
});
|
||||
const joined = Array.from(result).join("");
|
||||
expect(joined).toBe("");
|
||||
});
|
||||
defaultSystemPrompt: '',
|
||||
})
|
||||
const joined = Array.from(result).join('')
|
||||
expect(joined).toBe('')
|
||||
})
|
||||
|
||||
test("buildEffectiveSystemPrompt with overrideSystemPrompt replaces everything", () => {
|
||||
test('buildEffectiveSystemPrompt with overrideSystemPrompt replaces everything', () => {
|
||||
const result = buildEffectiveSystemPrompt({
|
||||
defaultSystemPrompt: "Default",
|
||||
overrideSystemPrompt: "Override",
|
||||
});
|
||||
const joined = Array.from(result).join("");
|
||||
expect(joined).toBe("Override");
|
||||
});
|
||||
defaultSystemPrompt: 'Default',
|
||||
overrideSystemPrompt: 'Override',
|
||||
})
|
||||
const joined = Array.from(result).join('')
|
||||
expect(joined).toBe('Override')
|
||||
})
|
||||
|
||||
test("buildEffectiveSystemPrompt with customSystemPrompt replaces default", () => {
|
||||
test('buildEffectiveSystemPrompt with customSystemPrompt replaces default', () => {
|
||||
const result = buildEffectiveSystemPrompt({
|
||||
defaultSystemPrompt: "Default",
|
||||
customSystemPrompt: "Custom",
|
||||
});
|
||||
const joined = Array.from(result).join("");
|
||||
expect(joined).toBe("Custom");
|
||||
});
|
||||
defaultSystemPrompt: 'Default',
|
||||
customSystemPrompt: 'Custom',
|
||||
})
|
||||
const joined = Array.from(result).join('')
|
||||
expect(joined).toBe('Custom')
|
||||
})
|
||||
|
||||
test("buildEffectiveSystemPrompt with appendSystemPrompt includes both", () => {
|
||||
test('buildEffectiveSystemPrompt with appendSystemPrompt includes both', () => {
|
||||
const result = buildEffectiveSystemPrompt({
|
||||
defaultSystemPrompt: "Main prompt",
|
||||
appendSystemPrompt: "Appended",
|
||||
});
|
||||
const joined = Array.from(result).join("");
|
||||
expect(joined).toContain("Main prompt");
|
||||
expect(joined).toContain("Appended");
|
||||
defaultSystemPrompt: 'Main prompt',
|
||||
appendSystemPrompt: 'Appended',
|
||||
})
|
||||
const joined = Array.from(result).join('')
|
||||
expect(joined).toContain('Main prompt')
|
||||
expect(joined).toContain('Appended')
|
||||
// Appended should come after main
|
||||
expect(joined.indexOf("Main prompt")).toBeLessThan(
|
||||
joined.indexOf("Appended")
|
||||
);
|
||||
});
|
||||
});
|
||||
expect(joined.indexOf('Main prompt')).toBeLessThan(
|
||||
joined.indexOf('Appended'),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
// ─── CLAUDE.md Discovery with Real File System ───────────────────────
|
||||
|
||||
describe("Context build: CLAUDE.md file system integration", () => {
|
||||
let tempDir: string;
|
||||
describe('Context build: CLAUDE.md file system integration', () => {
|
||||
let tempDir: string
|
||||
|
||||
test("strips HTML comments from CLAUDE.md content", () => {
|
||||
const input = "<!-- this is a comment -->Actual content";
|
||||
const { content, stripped } = stripHtmlComments(input);
|
||||
expect(content).toBe("Actual content");
|
||||
expect(stripped).toBe(true);
|
||||
});
|
||||
test('strips HTML comments from CLAUDE.md content', () => {
|
||||
const input = '<!-- this is a comment -->Actual content'
|
||||
const { content, stripped } = stripHtmlComments(input)
|
||||
expect(content).toBe('Actual content')
|
||||
expect(stripped).toBe(true)
|
||||
})
|
||||
|
||||
test("preserves code blocks when stripping HTML comments", () => {
|
||||
const input = "```\n<!-- not a real comment -->\n```\nReal text";
|
||||
const { content } = stripHtmlComments(input);
|
||||
expect(content).toContain("<!-- not a real comment -->");
|
||||
expect(content).toContain("Real text");
|
||||
});
|
||||
test('preserves code blocks when stripping HTML comments', () => {
|
||||
const input = '```\n<!-- not a real comment -->\n```\nReal text'
|
||||
const { content } = stripHtmlComments(input)
|
||||
expect(content).toContain('<!-- not a real comment -->')
|
||||
expect(content).toContain('Real text')
|
||||
})
|
||||
|
||||
test("isMemoryFilePath correctly identifies CLAUDE.md paths", () => {
|
||||
expect(isMemoryFilePath("/project/CLAUDE.md")).toBe(true);
|
||||
expect(isMemoryFilePath("/project/CLAUDE.local.md")).toBe(true);
|
||||
expect(isMemoryFilePath("/project/.claude/rules/file.md")).toBe(true);
|
||||
expect(isMemoryFilePath("/project/README.md")).toBe(false);
|
||||
expect(isMemoryFilePath("/project/src/index.ts")).toBe(false);
|
||||
});
|
||||
});
|
||||
test('isMemoryFilePath correctly identifies CLAUDE.md paths', () => {
|
||||
expect(isMemoryFilePath('/project/CLAUDE.md')).toBe(true)
|
||||
expect(isMemoryFilePath('/project/CLAUDE.local.md')).toBe(true)
|
||||
expect(isMemoryFilePath('/project/.claude/rules/file.md')).toBe(true)
|
||||
expect(isMemoryFilePath('/project/README.md')).toBe(false)
|
||||
expect(isMemoryFilePath('/project/src/index.ts')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
// ─── Large Memory File Filtering ──────────────────────────────────────
|
||||
|
||||
describe("Context build: large memory file filtering", () => {
|
||||
test("getLargeMemoryFiles returns empty for empty input", () => {
|
||||
expect(getLargeMemoryFiles([])).toEqual([]);
|
||||
});
|
||||
describe('Context build: large memory file filtering', () => {
|
||||
test('getLargeMemoryFiles returns empty for empty input', () => {
|
||||
expect(getLargeMemoryFiles([])).toEqual([])
|
||||
})
|
||||
|
||||
test("getLargeMemoryFiles returns empty when all files are small", () => {
|
||||
test('getLargeMemoryFiles returns empty when all files are small', () => {
|
||||
const files = [
|
||||
{ path: "/a/CLAUDE.md", content: "small" },
|
||||
{ path: "/b/CLAUDE.md", content: "also small" },
|
||||
];
|
||||
expect(getLargeMemoryFiles(files)).toEqual([]);
|
||||
});
|
||||
});
|
||||
{ path: '/a/CLAUDE.md', content: 'small' },
|
||||
{ path: '/b/CLAUDE.md', content: 'also small' },
|
||||
]
|
||||
expect(getLargeMemoryFiles(files)).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,65 +1,65 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { describe, expect, test } from 'bun:test'
|
||||
import {
|
||||
createUserMessage,
|
||||
createAssistantMessage,
|
||||
normalizeMessages,
|
||||
extractTag,
|
||||
} from "../../src/utils/messages";
|
||||
} from '../../src/utils/messages'
|
||||
|
||||
// ─── Message Structure ────────────────────────────────────────────────
|
||||
|
||||
describe("Message pipeline: message structure", () => {
|
||||
describe('Message pipeline: message structure', () => {
|
||||
test("createUserMessage returns a Message with type 'user'", () => {
|
||||
const msg = createUserMessage("hello");
|
||||
expect(msg.type).toBe("user");
|
||||
expect(msg.message.role).toBe("user");
|
||||
expect(msg.uuid).toBeTruthy();
|
||||
expect(msg.timestamp).toBeTruthy();
|
||||
});
|
||||
const msg = createUserMessage('hello')
|
||||
expect(msg.type).toBe('user')
|
||||
expect(msg.message.role).toBe('user')
|
||||
expect(msg.uuid).toBeTruthy()
|
||||
expect(msg.timestamp).toBeTruthy()
|
||||
})
|
||||
|
||||
test("createAssistantMessage returns a Message with type 'assistant'", () => {
|
||||
const msg = createAssistantMessage("response");
|
||||
expect(msg.type).toBe("assistant");
|
||||
expect(msg.message.role).toBe("assistant");
|
||||
expect(msg.uuid).toBeTruthy();
|
||||
});
|
||||
const msg = createAssistantMessage('response')
|
||||
expect(msg.type).toBe('assistant')
|
||||
expect(msg.message.role).toBe('assistant')
|
||||
expect(msg.uuid).toBeTruthy()
|
||||
})
|
||||
|
||||
test("user and assistant messages have different UUIDs", () => {
|
||||
const user = createUserMessage("hello");
|
||||
const assistant = createAssistantMessage("response");
|
||||
expect(user.uuid).not.toBe(assistant.uuid);
|
||||
});
|
||||
});
|
||||
test('user and assistant messages have different UUIDs', () => {
|
||||
const user = createUserMessage('hello')
|
||||
const assistant = createAssistantMessage('response')
|
||||
expect(user.uuid).not.toBe(assistant.uuid)
|
||||
})
|
||||
})
|
||||
|
||||
// ─── Tag Extraction ───────────────────────────────────────────────────
|
||||
|
||||
describe("Message pipeline: tag extraction", () => {
|
||||
test("extractTag returns null for non-matching tag", () => {
|
||||
expect(extractTag("no tags here", "think")).toBeNull();
|
||||
});
|
||||
describe('Message pipeline: tag extraction', () => {
|
||||
test('extractTag returns null for non-matching tag', () => {
|
||||
expect(extractTag('no tags here', 'think')).toBeNull()
|
||||
})
|
||||
|
||||
test("extractTag returns null for empty string", () => {
|
||||
expect(extractTag("", "think")).toBeNull();
|
||||
});
|
||||
test('extractTag returns null for empty string', () => {
|
||||
expect(extractTag('', 'think')).toBeNull()
|
||||
})
|
||||
|
||||
test("extractTag requires tagName parameter", () => {
|
||||
test('extractTag requires tagName parameter', () => {
|
||||
// Calling without tagName throws
|
||||
expect(() => (extractTag as any)("hello")).toThrow();
|
||||
});
|
||||
});
|
||||
expect(() => (extractTag as any)('hello')).toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
// ─── Normalization ────────────────────────────────────────────────────
|
||||
|
||||
describe("Message pipeline: normalization", () => {
|
||||
test("normalizeMessages returns an array", () => {
|
||||
const msg = createUserMessage("hello");
|
||||
const result = normalizeMessages([msg]);
|
||||
expect(Array.isArray(result)).toBe(true);
|
||||
});
|
||||
describe('Message pipeline: normalization', () => {
|
||||
test('normalizeMessages returns an array', () => {
|
||||
const msg = createUserMessage('hello')
|
||||
const result = normalizeMessages([msg])
|
||||
expect(Array.isArray(result)).toBe(true)
|
||||
})
|
||||
|
||||
test("normalizeMessages preserves at least one message for simple input", () => {
|
||||
const msg = createUserMessage("hello");
|
||||
const result = normalizeMessages([msg]);
|
||||
expect(result.length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
test('normalizeMessages preserves at least one message for simple input', () => {
|
||||
const msg = createUserMessage('hello')
|
||||
const result = normalizeMessages([msg])
|
||||
expect(result.length).toBeGreaterThanOrEqual(1)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,141 +1,141 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { getAllBaseTools, parseToolPreset, getTools } from "../../src/tools.ts";
|
||||
import { describe, expect, test } from 'bun:test'
|
||||
import { getAllBaseTools, parseToolPreset, getTools } from '../../src/tools.ts'
|
||||
import {
|
||||
findToolByName,
|
||||
getEmptyToolPermissionContext,
|
||||
buildTool,
|
||||
} from "../../src/Tool.ts";
|
||||
} from '../../src/Tool.ts'
|
||||
|
||||
// ─── Tool Registration & Discovery ──────────────────────────────────────
|
||||
|
||||
describe("Tool chain: registration and discovery", () => {
|
||||
test("getAllBaseTools returns a non-empty array of tools", () => {
|
||||
const tools = getAllBaseTools();
|
||||
expect(tools.length).toBeGreaterThan(0);
|
||||
});
|
||||
describe('Tool chain: registration and discovery', () => {
|
||||
test('getAllBaseTools returns a non-empty array of tools', () => {
|
||||
const tools = getAllBaseTools()
|
||||
expect(tools.length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
test("all base tools have required fields", () => {
|
||||
const tools = getAllBaseTools();
|
||||
test('all base tools have required fields', () => {
|
||||
const tools = getAllBaseTools()
|
||||
for (const tool of tools) {
|
||||
expect(tool.name).toBeTruthy();
|
||||
expect(tool.description).toBeTruthy();
|
||||
expect(tool.inputSchema).toBeDefined();
|
||||
expect(typeof tool.call).toBe("function");
|
||||
expect(tool.name).toBeTruthy()
|
||||
expect(tool.description).toBeTruthy()
|
||||
expect(tool.inputSchema).toBeDefined()
|
||||
expect(typeof tool.call).toBe('function')
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
test("findToolByName finds core tools from the full list", () => {
|
||||
const tools = getAllBaseTools();
|
||||
const bash = findToolByName(tools, "Bash");
|
||||
expect(bash).toBeDefined();
|
||||
expect(bash!.name).toBe("Bash");
|
||||
test('findToolByName finds core tools from the full list', () => {
|
||||
const tools = getAllBaseTools()
|
||||
const bash = findToolByName(tools, 'Bash')
|
||||
expect(bash).toBeDefined()
|
||||
expect(bash!.name).toBe('Bash')
|
||||
|
||||
const read = findToolByName(tools, "Read");
|
||||
expect(read).toBeDefined();
|
||||
expect(read!.name).toBe("Read");
|
||||
const read = findToolByName(tools, 'Read')
|
||||
expect(read).toBeDefined()
|
||||
expect(read!.name).toBe('Read')
|
||||
|
||||
const edit = findToolByName(tools, "Edit");
|
||||
expect(edit).toBeDefined();
|
||||
expect(edit!.name).toBe("Edit");
|
||||
});
|
||||
const edit = findToolByName(tools, 'Edit')
|
||||
expect(edit).toBeDefined()
|
||||
expect(edit!.name).toBe('Edit')
|
||||
})
|
||||
|
||||
test("findToolByName returns undefined for non-existent tool", () => {
|
||||
const tools = getAllBaseTools();
|
||||
expect(findToolByName(tools, "NonExistentTool")).toBeUndefined();
|
||||
});
|
||||
test('findToolByName returns undefined for non-existent tool', () => {
|
||||
const tools = getAllBaseTools()
|
||||
expect(findToolByName(tools, 'NonExistentTool')).toBeUndefined()
|
||||
})
|
||||
|
||||
test("findToolByName is case-sensitive (exact match only)", () => {
|
||||
const tools = getAllBaseTools();
|
||||
expect(findToolByName(tools, "Bash")).toBeDefined();
|
||||
expect(findToolByName(tools, "bash")).toBeUndefined();
|
||||
});
|
||||
test('findToolByName is case-sensitive (exact match only)', () => {
|
||||
const tools = getAllBaseTools()
|
||||
expect(findToolByName(tools, 'Bash')).toBeDefined()
|
||||
expect(findToolByName(tools, 'bash')).toBeUndefined()
|
||||
})
|
||||
|
||||
test("findToolByName resolves via toolMatchesName", () => {
|
||||
const tools = getAllBaseTools();
|
||||
const agent = findToolByName(tools, "Agent");
|
||||
expect(agent).toBeDefined();
|
||||
test('findToolByName resolves via toolMatchesName', () => {
|
||||
const tools = getAllBaseTools()
|
||||
const agent = findToolByName(tools, 'Agent')
|
||||
expect(agent).toBeDefined()
|
||||
// Verify it can also find by checking name directly
|
||||
expect(tools.some(t => t.name === "Agent")).toBe(true);
|
||||
});
|
||||
expect(tools.some(t => t.name === 'Agent')).toBe(true)
|
||||
})
|
||||
|
||||
test("tool names are unique across the base tool list", () => {
|
||||
const tools = getAllBaseTools();
|
||||
const names = tools.map(t => t.name);
|
||||
expect(new Set(names).size).toBe(names.length);
|
||||
});
|
||||
});
|
||||
test('tool names are unique across the base tool list', () => {
|
||||
const tools = getAllBaseTools()
|
||||
const names = tools.map(t => t.name)
|
||||
expect(new Set(names).size).toBe(names.length)
|
||||
})
|
||||
})
|
||||
|
||||
// ─── Tool Presets ──────────────────────────────────────────────────────
|
||||
|
||||
describe("Tool chain: presets", () => {
|
||||
describe('Tool chain: presets', () => {
|
||||
test('parseToolPreset("default") returns "default" string', () => {
|
||||
// parseToolPreset returns a preset name string, not a tool array
|
||||
expect(parseToolPreset("default")).toBe("default");
|
||||
});
|
||||
expect(parseToolPreset('default')).toBe('default')
|
||||
})
|
||||
|
||||
test("parseToolPreset returns null for unknown preset", () => {
|
||||
expect(parseToolPreset("nonexistent")).toBeNull();
|
||||
});
|
||||
test('parseToolPreset returns null for unknown preset', () => {
|
||||
expect(parseToolPreset('nonexistent')).toBeNull()
|
||||
})
|
||||
|
||||
test("parseToolPreset is case-insensitive", () => {
|
||||
expect(parseToolPreset("DEFAULT")).toBe("default");
|
||||
});
|
||||
});
|
||||
test('parseToolPreset is case-insensitive', () => {
|
||||
expect(parseToolPreset('DEFAULT')).toBe('default')
|
||||
})
|
||||
})
|
||||
|
||||
// ─── getTools (with permission context) ────────────────────────────────
|
||||
|
||||
describe("Tool chain: getTools with context", () => {
|
||||
test("getTools returns tools (subset of base tools)", () => {
|
||||
const allTools = getAllBaseTools();
|
||||
const ctx = getEmptyToolPermissionContext();
|
||||
const tools = getTools(ctx);
|
||||
expect(tools.length).toBeGreaterThan(0);
|
||||
expect(tools.length).toBeLessThanOrEqual(allTools.length);
|
||||
});
|
||||
describe('Tool chain: getTools with context', () => {
|
||||
test('getTools returns tools (subset of base tools)', () => {
|
||||
const allTools = getAllBaseTools()
|
||||
const ctx = getEmptyToolPermissionContext()
|
||||
const tools = getTools(ctx)
|
||||
expect(tools.length).toBeGreaterThan(0)
|
||||
expect(tools.length).toBeLessThanOrEqual(allTools.length)
|
||||
})
|
||||
|
||||
test("getTools results all have name and call function", () => {
|
||||
const ctx = getEmptyToolPermissionContext();
|
||||
const tools = getTools(ctx);
|
||||
test('getTools results all have name and call function', () => {
|
||||
const ctx = getEmptyToolPermissionContext()
|
||||
const tools = getTools(ctx)
|
||||
for (const tool of tools) {
|
||||
expect(tool.name).toBeTruthy();
|
||||
expect(typeof tool.call).toBe("function");
|
||||
expect(tool.name).toBeTruthy()
|
||||
expect(typeof tool.call).toBe('function')
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
// ─── buildTool + findToolByName end-to-end ─────────────────────────────
|
||||
|
||||
describe("Tool chain: buildTool + findToolByName", () => {
|
||||
test("a built tool can be found in a custom list", () => {
|
||||
describe('Tool chain: buildTool + findToolByName', () => {
|
||||
test('a built tool can be found in a custom list', () => {
|
||||
const customTool = buildTool({
|
||||
name: "TestTool",
|
||||
description: "A test tool",
|
||||
name: 'TestTool',
|
||||
description: 'A test tool',
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
properties: { input: { type: "string" } },
|
||||
required: ["input"],
|
||||
type: 'object' as const,
|
||||
properties: { input: { type: 'string' } },
|
||||
required: ['input'],
|
||||
},
|
||||
call: async () => ({ output: "test" }),
|
||||
});
|
||||
call: async () => ({ output: 'test' }),
|
||||
})
|
||||
|
||||
const found = findToolByName([customTool], "TestTool");
|
||||
expect(found).toBe(customTool);
|
||||
});
|
||||
const found = findToolByName([customTool], 'TestTool')
|
||||
expect(found).toBe(customTool)
|
||||
})
|
||||
|
||||
test("built tool defaults are correctly applied", () => {
|
||||
test('built tool defaults are correctly applied', () => {
|
||||
const tool = buildTool({
|
||||
name: "MinimalTool",
|
||||
description: "Minimal",
|
||||
name: 'MinimalTool',
|
||||
description: 'Minimal',
|
||||
inputSchema: {
|
||||
type: "object" as const,
|
||||
type: 'object' as const,
|
||||
properties: {},
|
||||
},
|
||||
call: async () => ({}),
|
||||
});
|
||||
})
|
||||
|
||||
expect(tool.isEnabled()).toBe(true);
|
||||
expect(tool.isConcurrencySafe()).toBe(false);
|
||||
expect(tool.isReadOnly()).toBe(false);
|
||||
expect(tool.isDestructive()).toBe(false);
|
||||
});
|
||||
});
|
||||
expect(tool.isEnabled()).toBe(true)
|
||||
expect(tool.isConcurrencySafe()).toBe(false)
|
||||
expect(tool.isReadOnly()).toBe(false)
|
||||
expect(tool.isDestructive()).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
export const mockStreamResponse = {
|
||||
type: "message_start" as const,
|
||||
type: 'message_start' as const,
|
||||
message: {
|
||||
id: "msg_mock_001",
|
||||
type: "message" as const,
|
||||
role: "assistant",
|
||||
id: 'msg_mock_001',
|
||||
type: 'message' as const,
|
||||
role: 'assistant',
|
||||
content: [],
|
||||
model: "claude-sonnet-4-20250514",
|
||||
model: 'claude-sonnet-4-20250514',
|
||||
stop_reason: null,
|
||||
stop_sequence: null,
|
||||
usage: { input_tokens: 100, output_tokens: 0 },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export const mockTextBlock = {
|
||||
type: "content_block_start" as const,
|
||||
type: 'content_block_start' as const,
|
||||
index: 0,
|
||||
content_block: { type: "text" as const, text: "Mock response" },
|
||||
};
|
||||
content_block: { type: 'text' as const, text: 'Mock response' },
|
||||
}
|
||||
|
||||
export const mockToolUseBlock = {
|
||||
type: "content_block_start" as const,
|
||||
type: 'content_block_start' as const,
|
||||
index: 1,
|
||||
content_block: {
|
||||
type: "tool_use" as const,
|
||||
id: "toolu_mock_001",
|
||||
name: "Read",
|
||||
input: { file_path: "/tmp/test.txt" },
|
||||
type: 'tool_use' as const,
|
||||
id: 'toolu_mock_001',
|
||||
name: 'Read',
|
||||
input: { file_path: '/tmp/test.txt' },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export const mockEndEvent = {
|
||||
type: "message_stop" as const,
|
||||
};
|
||||
type: 'message_stop' as const,
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
export function debugMock() {
|
||||
return {
|
||||
getMinDebugLogLevel: () => "debug" as const,
|
||||
getMinDebugLogLevel: () => 'debug' as const,
|
||||
isDebugMode: () => false,
|
||||
enableDebugLogging: () => false,
|
||||
getDebugFilter: () => null,
|
||||
@@ -19,7 +19,7 @@ export function debugMock() {
|
||||
getHasFormattedOutput: () => false,
|
||||
flushDebugLogs: async () => {},
|
||||
logForDebugging: () => {},
|
||||
getDebugLogPath: () => "/tmp/mock-debug.log",
|
||||
getDebugLogPath: () => '/tmp/mock-debug.log',
|
||||
logAntError: () => {},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
},
|
||||
"assistantMessage": {
|
||||
"role": "assistant",
|
||||
"content": [
|
||||
{ "type": "text", "text": "Hello! How can I help?" }
|
||||
]
|
||||
"content": [{ "type": "text", "text": "Hello! How can I help?" }]
|
||||
},
|
||||
"toolUseMessage": {
|
||||
"role": "assistant",
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
export function logMock() {
|
||||
return {
|
||||
logError: () => {},
|
||||
getLogDisplayTitle: () => "",
|
||||
dateToFilename: (d: Date) => d.toISOString().replace(/[:.]/g, "-"),
|
||||
getLogDisplayTitle: () => '',
|
||||
dateToFilename: (d: Date) => d.toISOString().replace(/[:.]/g, '-'),
|
||||
attachErrorLogSink: () => {},
|
||||
getInMemoryErrors: () => [] as Array<{ error: string; timestamp: string }>,
|
||||
loadErrorLogs: async () => [],
|
||||
|
||||
Reference in New Issue
Block a user