MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / toolWithContent

Function toolWithContent

packages/agent-core/test/tools/read.test.ts:67–80  ·  view source on GitHub ↗
(content: string, workspace: WorkspaceConfig = PERMISSIVE_WORKSPACE)

Source from the content-addressed store, hash-verified

65}
66
67function toolWithContent(content: string, workspace: WorkspaceConfig = PERMISSIVE_WORKSPACE) {
68 const bytes = Buffer.from(content, 'utf8');
69 return new ReadTool(
70 createFakeKaos({
71 stat: vi.fn<Kaos['stat']>().mockResolvedValue(REGULAR_FILE_STAT),
72 readBytes: vi.fn<Kaos['readBytes']>().mockImplementation(async (_path, n) => {
73 return n === undefined ? bytes : bytes.subarray(0, n);
74 }),
75 readLines: vi.fn<Kaos['readLines']>().mockImplementation(readLinesFromContent(content)),
76 readText: vi.fn<Kaos['readText']>().mockResolvedValue(content),
77 }),
78 workspace,
79 );
80}
81
82describe('ReadTool', () => {
83 it('exposes current metadata and schema', () => {

Callers 1

read.test.tsFile · 0.70

Calls 2

createFakeKaosFunction · 0.90
readLinesFromContentFunction · 0.70

Tested by

no test coverage detected